Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: pcf8523: report oscillator failures

Report oscillator failures and invalid date/time on RTC_VL_READ.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418002023.1000265-3-alexandre.belloni@bootlin.com

+11 -2
+11 -2
drivers/rtc/rtc-pcf8523.c
··· 406 406 unsigned long arg) 407 407 { 408 408 struct i2c_client *client = to_i2c_client(dev); 409 + unsigned int flags = 0; 410 + u8 value; 409 411 int ret; 410 412 411 413 switch (cmd) { ··· 416 414 if (ret < 0) 417 415 return ret; 418 416 if (ret) 419 - ret = RTC_VL_BACKUP_LOW; 417 + flags |= RTC_VL_BACKUP_LOW; 420 418 421 - return put_user(ret, (unsigned int __user *)arg); 419 + ret = pcf8523_read(client, REG_SECONDS, &value); 420 + if (ret < 0) 421 + return ret; 422 + 423 + if (value & REG_SECONDS_OS) 424 + flags |= RTC_VL_DATA_INVALID; 425 + 426 + return put_user(flags, (unsigned int __user *)arg); 422 427 423 428 default: 424 429 return -ENOIOCTLCMD;