Skip to contentSkip to conversation

rtc: rx8025: Switch to use %ptR

bug report Dan Carpenter 2 participants 2 messages Apr 9, 2019 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 43 lines · Dan Carpenter

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);
                                        ^^^^^               ^
Quoted 1 line

You mean t->time?

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

Quoted 9 lines
    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

Signature · 2 lines
With Best Regards,
Andy Shevchenko