* [bug report] rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time
@ 2019-02-13 13:17 Dan Carpenter
2019-02-13 17:51 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-02-13 13:17 UTC (permalink / raw)
To: u.kleine-koenig; +Cc: linux-rtc
Hello Uwe Kleine-König,
The patch 501f98266cad: "rtc: ds1307: rx8130: honor Voltage Loss Flag
when reading the time" from Jan 25, 2019, leads to the following
static checker warning:
drivers/rtc/rtc-ds1307.c:314 ds1307_set_time()
warn: this cast is a no-op
drivers/rtc/rtc-ds1307.c
304 result = regmap_bulk_write(ds1307->regmap, chip->offset, regs,
305 sizeof(regs));
306 if (result) {
307 dev_err(dev, "%s error %d\n", "write", result);
308 return result;
309 }
310
311 if (ds1307->type == rx_8130) {
312 /* clear Voltage Loss Flag as data is available now */
313 result = regmap_write(ds1307->regmap, RX8130_REG_FLAG,
--> 314 ~(u8)RX8130_REG_FLAG_VLF);
^^^^^^^^^^^^^^^^^^^^^^^^
RX8130_REG_FLAG_VLF is 0x2. The cast to u8 doesn't change anything
because it gets type promoted to int. I don't know what was intended.
315 if (result) {
316 dev_err(dev, "%s error %d\n", "write", result);
317 return result;
318 }
319 }
320
321 return 0;
322 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [bug report] rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time
2019-02-13 13:17 [bug report] rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time Dan Carpenter
@ 2019-02-13 17:51 ` Uwe Kleine-König
2019-02-13 19:43 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2019-02-13 17:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-rtc
Hello Dan,
On Wed, Feb 13, 2019 at 04:17:31PM +0300, Dan Carpenter wrote:
> The patch 501f98266cad: "rtc: ds1307: rx8130: honor Voltage Loss Flag
> when reading the time" from Jan 25, 2019, leads to the following
> static checker warning:
>
> drivers/rtc/rtc-ds1307.c:314 ds1307_set_time()
> warn: this cast is a no-op
>
> drivers/rtc/rtc-ds1307.c
> 304 result = regmap_bulk_write(ds1307->regmap, chip->offset, regs,
> 305 sizeof(regs));
> 306 if (result) {
> 307 dev_err(dev, "%s error %d\n", "write", result);
> 308 return result;
> 309 }
> 310
> 311 if (ds1307->type == rx_8130) {
> 312 /* clear Voltage Loss Flag as data is available now */
> 313 result = regmap_write(ds1307->regmap, RX8130_REG_FLAG,
> --> 314 ~(u8)RX8130_REG_FLAG_VLF);
> ^^^^^^^^^^^^^^^^^^^^^^^^
> RX8130_REG_FLAG_VLF is 0x2. The cast to u8 doesn't change anything
> because it gets type promoted to int. I don't know what was intended.
This reasoning looks right, yes. I don't remember why I added it.
Probably because I intended to create the value 0xfd and not 0xfffffffd
(aka -3).
Feel free to fix this in a patch blaming me.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [bug report] rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time
2019-02-13 17:51 ` Uwe Kleine-König
@ 2019-02-13 19:43 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-02-13 19:43 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: linux-rtc
On Wed, Feb 13, 2019 at 06:51:25PM +0100, Uwe Kleine-König wrote:
> Hello Dan,
>
> On Wed, Feb 13, 2019 at 04:17:31PM +0300, Dan Carpenter wrote:
> > The patch 501f98266cad: "rtc: ds1307: rx8130: honor Voltage Loss Flag
> > when reading the time" from Jan 25, 2019, leads to the following
> > static checker warning:
> >
> > drivers/rtc/rtc-ds1307.c:314 ds1307_set_time()
> > warn: this cast is a no-op
> >
> > drivers/rtc/rtc-ds1307.c
> > 304 result = regmap_bulk_write(ds1307->regmap, chip->offset, regs,
> > 305 sizeof(regs));
> > 306 if (result) {
> > 307 dev_err(dev, "%s error %d\n", "write", result);
> > 308 return result;
> > 309 }
> > 310
> > 311 if (ds1307->type == rx_8130) {
> > 312 /* clear Voltage Loss Flag as data is available now */
> > 313 result = regmap_write(ds1307->regmap, RX8130_REG_FLAG,
> > --> 314 ~(u8)RX8130_REG_FLAG_VLF);
> > ^^^^^^^^^^^^^^^^^^^^^^^^
> > RX8130_REG_FLAG_VLF is 0x2. The cast to u8 doesn't change anything
> > because it gets type promoted to int. I don't know what was intended.
>
> This reasoning looks right, yes. I don't remember why I added it.
> Probably because I intended to create the value 0xfd and not 0xfffffffd
> (aka -3).
>
> Feel free to fix this in a patch blaming me.
If it's working as-is then I'm not going to be the one to break it... :P
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-13 19:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-13 13:17 [bug report] rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time Dan Carpenter
2019-02-13 17:51 ` Uwe Kleine-König
2019-02-13 19:43 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).