rtc: rzn1: Avoid mixing variables

In the ->set_offset() callback, the 'val' variable is used for two
different purposes at the same time, which is oviously wrong:
- It contains the intermediate value of the SUBU register that must be
written at the end of ->set_offset().
- It is used in the middle of the above calculations to poll the CTL2
register for a specific value.

Let's introduce a 'ctl2' variable just for the readl_poll_timeout()
call and use it there in place of 'var'.

In order to avoid mixing those two variables again, let's rename the
remaining occurences of 'val' into 'subu' and initialize it to 0 to
avoid the uninitialized variable situation reported by Tom Rix and Colin
Ian King already.

Fixes: be4a11cf98af ("rtc: rzn1: Add oscillator offset support")
Reported-by: Tom Rix <trix@redhat.com>
Reported-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220520082221.488849-1-miquel.raynal@bootlin.com

authored by Miquel Raynal and committed by Alexandre Belloni 64d69b5d b520cbe5

+8 -8
+8 -8
drivers/rtc/rtc-rzn1.c
··· 272 272 struct rzn1_rtc *rtc = dev_get_drvdata(dev); 273 273 unsigned int steps; 274 274 int stepsh, stepsl; 275 - u32 val; 275 + u32 subu = 0, ctl2; 276 276 int ret; 277 277 278 278 /* ··· 288 288 if (stepsh >= -0x3E && stepsh <= 0x3E) { 289 289 /* 1017 ppb per step */ 290 290 steps = stepsh; 291 - val |= RZN1_RTC_SUBU_DEV; 291 + subu |= RZN1_RTC_SUBU_DEV; 292 292 } else if (stepsl >= -0x3E && stepsl <= 0x3E) { 293 293 /* 3051 ppb per step */ 294 294 steps = stepsl; ··· 300 300 return 0; 301 301 302 302 if (steps > 0) { 303 - val |= steps + 1; 303 + subu |= steps + 1; 304 304 } else { 305 - val |= RZN1_RTC_SUBU_DECR; 306 - val |= (~(-steps - 1)) & 0x3F; 305 + subu |= RZN1_RTC_SUBU_DECR; 306 + subu |= (~(-steps - 1)) & 0x3F; 307 307 } 308 308 309 - ret = readl_poll_timeout(rtc->base + RZN1_RTC_CTL2, val, 310 - !(val & RZN1_RTC_CTL2_WUST), 100, 2000000); 309 + ret = readl_poll_timeout(rtc->base + RZN1_RTC_CTL2, ctl2, 310 + !(ctl2 & RZN1_RTC_CTL2_WUST), 100, 2000000); 311 311 if (ret) 312 312 return ret; 313 313 314 - writel(val, rtc->base + RZN1_RTC_SUBU); 314 + writel(subu, rtc->base + RZN1_RTC_SUBU); 315 315 316 316 return 0; 317 317 }