linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] rtc: rx8025: Switch to use %ptR
@ 2019-04-09 11:49 Dan Carpenter
  2019-04-09 14:43 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-04-09 11:49 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: linux-rtc

Hello Andy Shevchenko,

The patch 1921cab11723: "rtc: rx8025: Switch to use %ptR" from Dec 4,
2018, leads to the following static checker warning:

	drivers/rtc/rtc-rx8025.c:314 rx8025_read_alarm()
	error: '%ptR' expects argument of type struct 'rtc_time', argument 5 has type 'struct rtc_wkalrm*'

drivers/rtc/rtc-rx8025.c
    284 static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t)
                                                         ^^^^^^^^^^^^^^^^^^^^

    285 {
    286 	struct rx8025_data *rx8025 = dev_get_drvdata(dev);
    287 	struct i2c_client *client = rx8025->client;
    288 	u8 ald[2];
    289 	int ctrl2, err;
    290 
    291 	if (client->irq <= 0)
    292 		return -EINVAL;
    293 
    294 	err = rx8025_read_regs(client, RX8025_REG_ALDMIN, 2, ald);
    295 	if (err)
    296 		return err;
    297 
    298 	ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2);
    299 	if (ctrl2 < 0)
    300 		return ctrl2;
    301 
    302 	dev_dbg(dev, "%s: read alarm 0x%02x 0x%02x ctrl2 %02x\n",
    303 		__func__, ald[0], ald[1], ctrl2);
    304 
    305 	/* Hardware alarms precision is 1 minute! */
    306 	t->time.tm_sec = 0;
    307 	t->time.tm_min = bcd2bin(ald[0] & 0x7f);
    308 	if (rx8025->ctrl1 & RX8025_BIT_CTRL1_1224)
    309 		t->time.tm_hour = bcd2bin(ald[1] & 0x3f);
    310 	else
    311 		t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12
    312 			+ (ald[1] & 0x20 ? 12 : 0);
    313 
--> 314 	dev_dbg(dev, "%s: date: %ptRr\n", __func__, t);
                                        ^^^^^               ^
You mean t->time?

    315 	t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE);
    316 	t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled;
    317 
    318 	return err;
    319 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] rtc: rx8025: Switch to use %ptR
  2019-04-09 11:49 [bug report] rtc: rx8025: Switch to use %ptR Dan Carpenter
@ 2019-04-09 14:43 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2019-04-09 14:43 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-rtc

On Tue, Apr 09, 2019 at 02:49:11PM +0300, Dan Carpenter wrote:
> Hello Andy Shevchenko,
> 
> The patch 1921cab11723: "rtc: rx8025: Switch to use %ptR" from Dec 4,
> 2018, leads to the following static checker warning:
> 
> 	drivers/rtc/rtc-rx8025.c:314 rx8025_read_alarm()
> 	error: '%ptR' expects argument of type struct 'rtc_time', argument 5 has type 'struct rtc_wkalrm*'
> 
> drivers/rtc/rtc-rx8025.c
>     284 static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t)
>                                                          ^^^^^^^^^^^^^^^^^^^^
> 
>     285 {
>     286 	struct rx8025_data *rx8025 = dev_get_drvdata(dev);
>     287 	struct i2c_client *client = rx8025->client;
>     288 	u8 ald[2];
>     289 	int ctrl2, err;
>     290 
>     291 	if (client->irq <= 0)
>     292 		return -EINVAL;
>     293 
>     294 	err = rx8025_read_regs(client, RX8025_REG_ALDMIN, 2, ald);
>     295 	if (err)
>     296 		return err;
>     297 
>     298 	ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2);
>     299 	if (ctrl2 < 0)
>     300 		return ctrl2;
>     301 
>     302 	dev_dbg(dev, "%s: read alarm 0x%02x 0x%02x ctrl2 %02x\n",
>     303 		__func__, ald[0], ald[1], ctrl2);
>     304 
>     305 	/* Hardware alarms precision is 1 minute! */
>     306 	t->time.tm_sec = 0;
>     307 	t->time.tm_min = bcd2bin(ald[0] & 0x7f);
>     308 	if (rx8025->ctrl1 & RX8025_BIT_CTRL1_1224)
>     309 		t->time.tm_hour = bcd2bin(ald[1] & 0x3f);
>     310 	else
>     311 		t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12
>     312 			+ (ald[1] & 0x20 ? 12 : 0);
>     313 
> --> 314 	dev_dbg(dev, "%s: date: %ptRr\n", __func__, t);
>                                         ^^^^^               ^
> You mean t->time?

Looks more like pointer to t->time, but yes, the current is using a wrong type.

> 
>     315 	t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE);
>     316 	t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled;
>     317 
>     318 	return err;
>     319 }
> 
> regards,
> dan carpenter

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-09 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 11:49 [bug report] rtc: rx8025: Switch to use %ptR Dan Carpenter
2019-04-09 14:43 ` Andy Shevchenko

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).