* [PATCH 00/17] rtc: Unify RTC_VL_READ meaning
@ 2019-12-14 22:02 Alexandre Belloni
2019-12-14 22:02 ` [PATCH 01/17] rtc: define RTC_VL_READ values Alexandre Belloni
` (16 more replies)
0 siblings, 17 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Hi,
This series unifies the meaning of RTC_VL_READ by redefining it as a
bitfield and defining the values of the various bits. This doesn't break
compatibility with userspaceas long as the return value was used as a
boolean, which should be the case.
The series also ensures RTC_VL_CLR doesn't clear the information when it
is about the data being invalid so the following rtc reads will properly
fail.
Alexandre Belloni (17):
rtc: define RTC_VL_READ values
rtc: Document RTC_VL_READ and RTC_VL_CLR ioctls
rtc: abx80x: return meaningful value for RTC_VL_READ
rtc: pcf2127: return meaningful value for RTC_VL_READ
rtc: pcf8523: return meaningful value for RTC_VL_READ
rtc: pcf8563: remove RTC_VL_CLR handling
rtc: pcf8563: remove conditional compilation
rtc: pcf8563: stop caching voltage_low
rtc: pcf8563: return meaningful value for RTC_VL_READ
rtc: pcf85063: remove RTC_VL_CLR handling
rtc: pcf85063: return meaningful value for RTC_VL_READ
rtc: rv3028: remove RTC_VL_CLR handling
rtc: rv3028: return meaningful value for RTC_VL_READ
rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR
rtc: rv8803: return meaningful value for RTC_VL_READ
rtc: rx8010: remove RTC_VL_CLR handling
rtc: rx8010: return meaningful value for RTC_VL_READ
Documentation/ABI/testing/rtc-cdev | 8 +++++++
drivers/rtc/rtc-abx80x.c | 7 ++----
drivers/rtc/rtc-pcf2127.c | 6 ++---
drivers/rtc/rtc-pcf85063.c | 16 ++-----------
drivers/rtc/rtc-pcf8523.c | 6 ++---
drivers/rtc/rtc-pcf8563.c | 36 ++++++------------------------
drivers/rtc/rtc-rv3028.c | 17 ++------------
drivers/rtc/rtc-rv8803.c | 16 ++++++-------
drivers/rtc/rtc-rx8010.c | 23 +++----------------
include/uapi/linux/rtc.h | 7 +++++-
10 files changed, 42 insertions(+), 100 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/17] rtc: define RTC_VL_READ values
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 02/17] rtc: Document RTC_VL_READ and RTC_VL_CLR ioctls Alexandre Belloni
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Currently, the meaning of the value returned by RTC_VL_READ is undocumented
and left to the driver implementation. In order to get more meaningful
values, define a set of values to use as to make clear to userspace what is
the status of the various voltages feeding the RTC.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
include/uapi/linux/rtc.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/rtc.h b/include/uapi/linux/rtc.h
index 2ad1788968d0..095af360326a 100644
--- a/include/uapi/linux/rtc.h
+++ b/include/uapi/linux/rtc.h
@@ -92,7 +92,12 @@ struct rtc_pll_info {
#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */
#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
-#define RTC_VL_READ _IOR('p', 0x13, int) /* Voltage low detector */
+#define RTC_VL_DATA_INVALID BIT(0) /* Voltage too low, RTC data is invalid */
+#define RTC_VL_BACKUP_LOW BIT(1) /* Backup voltage is low */
+#define RTC_VL_BACKUP_EMPTY BIT(2) /* Backup empty or not present */
+#define RTC_VL_ACCURACY_LOW BIT(3) /* Voltage is low, RTC accuracy is reduced */
+
+#define RTC_VL_READ _IOR('p', 0x13, unsigned int) /* Voltage low detection */
#define RTC_VL_CLR _IO('p', 0x14) /* Clear voltage low information */
/* interrupt flags */
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/17] rtc: Document RTC_VL_READ and RTC_VL_CLR ioctls
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
2019-12-14 22:02 ` [PATCH 01/17] rtc: define RTC_VL_READ values Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 03/17] rtc: abx80x: return meaningful value for RTC_VL_READ Alexandre Belloni
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
RTC_VL_READ and RTC_VL_CLR have been introduced in 2012 with commit
0f20b767e20a ("drivers/rtc/rtc-pcf8563.c: add RTC_VL_READ/RTC_VL_CLR ioctl
feature")
Document them now that they have been unified.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
Documentation/ABI/testing/rtc-cdev | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/ABI/testing/rtc-cdev b/Documentation/ABI/testing/rtc-cdev
index 97447283f13b..25910c3c3d7e 100644
--- a/Documentation/ABI/testing/rtc-cdev
+++ b/Documentation/ABI/testing/rtc-cdev
@@ -33,6 +33,14 @@ Description:
Requires a separate RTC_PIE_ON call to enable the periodic
interrupts.
+ * RTC_VL_READ: Read the voltage inputs status of the RTC when
+ supported. The value is a bit field of RTC_VL_*, giving the
+ status of the main and backup voltages.
+
+ * RTC_VL_CLEAR: Clear the voltage status of the RTC. Some RTCs
+ need user interaction when the backup power provider is
+ replaced or charged to be able to clear the status.
+
The ioctl() calls supported by the older /dev/rtc interface are
also supported by the newer RTC class framework. However,
because the chips and systems are not standardized, some PC/AT
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 03/17] rtc: abx80x: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
2019-12-14 22:02 ` [PATCH 01/17] rtc: define RTC_VL_READ values Alexandre Belloni
2019-12-14 22:02 ` [PATCH 02/17] rtc: Document RTC_VL_READ and RTC_VL_CLR ioctls Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 04/17] rtc: pcf2127: " Alexandre Belloni
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
ABX8XX_STATUS_BLF indicates the battery is low and needs to be replaced
soon.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-abx80x.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 73830670a41f..3521d8e8dc38 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -523,12 +523,9 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
if (status < 0)
return status;
- tmp = !!(status & ABX8XX_STATUS_BLF);
+ tmp = status & ABX8XX_STATUS_BLF ? RTC_VL_BACKUP_LOW : 0;
- if (copy_to_user((void __user *)arg, &tmp, sizeof(int)))
- return -EFAULT;
-
- return 0;
+ return put_user(tmp, (unsigned int __user *)arg);
case RTC_VL_CLR:
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/17] rtc: pcf2127: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (2 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 03/17] rtc: abx80x: return meaningful value for RTC_VL_READ Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 05/17] rtc: pcf8523: " Alexandre Belloni
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
PCF2127_BIT_CTRL3_BLF indicates the battery is low and needs to be replaced
soon.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf2127.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 5d8ea9ffd05b..5ac996578523 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -197,11 +197,9 @@ static int pcf2127_rtc_ioctl(struct device *dev,
if (ret)
return ret;
- touser = touser & PCF2127_BIT_CTRL3_BLF ? 1 : 0;
+ touser = touser & PCF2127_BIT_CTRL3_BLF ? RTC_VL_BACKUP_LOW : 0;
- if (copy_to_user((void __user *)arg, &touser, sizeof(int)))
- return -EFAULT;
- return 0;
+ return put_user(touser, (unsigned int __user *)arg);
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 05/17] rtc: pcf8523: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (3 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 04/17] rtc: pcf2127: " Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 06/17] rtc: pcf8563: remove RTC_VL_CLR handling Alexandre Belloni
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
REG_CONTROL3_BLF indicates the battery is low and needs to be replaced
soon.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf8523.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index b24c908f5f06..47e0f411dd5c 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -282,11 +282,11 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
ret = pcf8523_voltage_low(client);
if (ret < 0)
return ret;
+ if (ret)
+ ret = RTC_VL_BACKUP_LOW;
- if (copy_to_user((void __user *)arg, &ret, sizeof(int)))
- return -EFAULT;
+ return put_user(ret, (unsigned int __user *)arg);
- return 0;
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 06/17] rtc: pcf8563: remove RTC_VL_CLR handling
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (4 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 05/17] rtc: pcf8523: " Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 07/17] rtc: pcf8563: remove conditional compilation Alexandre Belloni
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Remove RTC_VL_CLR handling because it is a disservice to userspace as it
removes the important information that the RTC data is invalid. This may
lead userspace to set an invalid system time later on.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf8563.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 3c322f3079b0..c701eef82349 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -291,21 +291,6 @@ static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
sizeof(int)))
return -EFAULT;
return 0;
- case RTC_VL_CLR:
- /*
- * Clear the VL bit in the seconds register in case
- * the time has not been set already (which would
- * have cleared it). This does not really matter
- * because of the cached voltage_low value but do it
- * anyway for consistency.
- */
- if (pcf8563_rtc_read_time(dev, &tm))
- pcf8563_rtc_set_time(dev, &tm);
-
- /* Clear the cached value. */
- pcf8563->voltage_low = 0;
-
- return 0;
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 07/17] rtc: pcf8563: remove conditional compilation
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (5 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 06/17] rtc: pcf8563: remove RTC_VL_CLR handling Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 08/17] rtc: pcf8563: stop caching voltage_low Alexandre Belloni
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Always compile pcf8563_rtc_ioctl as we are sure that CONFIG_RTC_INTF_DEV is
selected on actual kernel configurations.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf8563.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index c701eef82349..026192fc0c2a 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -276,11 +276,9 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
9 - PCF8563_REG_SC, buf + PCF8563_REG_SC);
}
-#ifdef CONFIG_RTC_INTF_DEV
static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
struct pcf8563 *pcf8563 = i2c_get_clientdata(to_i2c_client(dev));
- struct rtc_time tm;
switch (cmd) {
case RTC_VL_READ:
@@ -295,9 +293,6 @@ static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
return -ENOIOCTLCMD;
}
}
-#else
-#define pcf8563_rtc_ioctl NULL
-#endif
static int pcf8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *tm)
{
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/17] rtc: pcf8563: stop caching voltage_low
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (6 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 07/17] rtc: pcf8563: remove conditional compilation Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 09/17] rtc: pcf8563: return meaningful value for RTC_VL_READ Alexandre Belloni
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
voltage_low is only updated when reading the time, this means that using
RTC_VL_READ will miss the VL flag if the time has not been read before
using the ioctl. Always read the status from the hardware.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf8563.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 026192fc0c2a..7fc43950cf6c 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -76,7 +76,6 @@ struct pcf8563 {
* 1970...2069.
*/
int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
- int voltage_low; /* incicates if a low_voltage was detected */
struct i2c_client *client;
#ifdef CONFIG_COMMON_CLK
@@ -208,7 +207,6 @@ static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
return err;
if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
- pcf8563->voltage_low = 1;
dev_err(&client->dev,
"low voltage detected, date/time is not reliable.\n");
return -EINVAL;
@@ -278,15 +276,19 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
- struct pcf8563 *pcf8563 = i2c_get_clientdata(to_i2c_client(dev));
+ struct i2c_client *client = to_i2c_client(dev);
+ int vl, ret;
switch (cmd) {
case RTC_VL_READ:
- if (pcf8563->voltage_low)
- dev_info(dev, "low voltage detected, date/time is not reliable.\n");
- if (copy_to_user((void __user *)arg, &pcf8563->voltage_low,
- sizeof(int)))
+ ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC);
+ if (ret < 0)
+ return ret;
+
+ vl = ret & PCF8563_SC_LV ? 1 : 0;
+
+ if (copy_to_user((void __user *)arg, &vl, sizeof(int)))
return -EFAULT;
return 0;
default:
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/17] rtc: pcf8563: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (7 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 08/17] rtc: pcf8563: stop caching voltage_low Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 10/17] rtc: pcf85063: remove RTC_VL_CLR handling Alexandre Belloni
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
PCF8563_SC_LV means the voltage dropped too low and data has been lost.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf8563.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 7fc43950cf6c..b282c6b07969 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -277,20 +277,16 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
struct i2c_client *client = to_i2c_client(dev);
- int vl, ret;
+ int ret;
switch (cmd) {
case RTC_VL_READ:
-
ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC);
if (ret < 0)
return ret;
- vl = ret & PCF8563_SC_LV ? 1 : 0;
-
- if (copy_to_user((void __user *)arg, &vl, sizeof(int)))
- return -EFAULT;
- return 0;
+ return put_user(ret & PCF8563_SC_LV ? RTC_VL_DATA_INVALID : 0,
+ (unsigned int __user *)arg);
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/17] rtc: pcf85063: remove RTC_VL_CLR handling
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (8 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 09/17] rtc: pcf8563: return meaningful value for RTC_VL_READ Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 11/17] rtc: pcf85063: return meaningful value for RTC_VL_READ Alexandre Belloni
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Remove RTC_VL_CLR handling because it is a disservice to userspace as it
removes the important information that the RTC data is invalid. This may
lead userspace to set an invalid system time later on.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf85063.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 1afa6d9fa9fb..2ddd95420a8c 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -299,12 +299,6 @@ static int pcf85063_ioctl(struct device *dev, unsigned int cmd,
return 0;
- case RTC_VL_CLR:
- ret = regmap_update_bits(pcf85063->regmap, PCF85063_REG_SC,
- PCF85063_REG_SC_OS, 0);
-
- return ret;
-
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/17] rtc: pcf85063: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (9 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 10/17] rtc: pcf85063: remove RTC_VL_CLR handling Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 12/17] rtc: rv3028: remove RTC_VL_CLR handling Alexandre Belloni
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
PCF85063_REG_SC_OS means the voltage dropped too low and data has been
lost.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf85063.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 2ddd95420a8c..1db17ba1fc64 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -289,15 +289,9 @@ static int pcf85063_ioctl(struct device *dev, unsigned int cmd,
if (ret < 0)
return ret;
- if (status & PCF85063_REG_SC_OS)
- dev_warn(&pcf85063->rtc->dev, "Voltage low, data loss detected.\n");
+ status = status & PCF85063_REG_SC_OS ? RTC_VL_DATA_INVALID : 0;
- status &= PCF85063_REG_SC_OS;
-
- if (copy_to_user((void __user *)arg, &status, sizeof(int)))
- return -EFAULT;
-
- return 0;
+ return put_user(status, (unsigned int __user *)arg);
default:
return -ENOIOCTLCMD;
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 12/17] rtc: rv3028: remove RTC_VL_CLR handling
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (10 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 11/17] rtc: pcf85063: return meaningful value for RTC_VL_READ Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 13/17] rtc: rv3028: return meaningful value for RTC_VL_READ Alexandre Belloni
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Remove RTC_VL_CLR handling because it is a disservice to userspace as it
removes the important information that the RTC data is invalid. This may
lead userspace to set an invalid system time later on.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rv3028.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
index 6b7b3a69601a..d1a2c22861f2 100644
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -438,12 +438,6 @@ static int rv3028_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
return 0;
- case RTC_VL_CLR:
- ret = regmap_update_bits(rv3028->regmap, RV3028_STATUS,
- RV3028_STATUS_PORF, 0);
-
- return ret;
-
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 13/17] rtc: rv3028: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (11 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 12/17] rtc: rv3028: remove RTC_VL_CLR handling Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 14/17] rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR Alexandre Belloni
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
RV3028_STATUS_PORF means the voltage dropped too low and data has been
lost.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rv3028.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
index d1a2c22861f2..a0ddc86c975a 100644
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -428,15 +428,8 @@ static int rv3028_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
if (ret < 0)
return ret;
- if (status & RV3028_STATUS_PORF)
- dev_warn(&rv3028->rtc->dev, "Voltage low, data loss detected.\n");
-
- status &= RV3028_STATUS_PORF;
-
- if (copy_to_user((void __user *)arg, &status, sizeof(int)))
- return -EFAULT;
-
- return 0;
+ status = status & RV3028_STATUS_PORF ? RTC_VL_DATA_INVALID : 0;
+ return put_user(status, (unsigned int __user *)arg);
default:
return -ENOIOCTLCMD;
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 14/17] rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (12 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 13/17] rtc: rv3028: return meaningful value for RTC_VL_READ Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 15/17] rtc: rv8803: return meaningful value for RTC_VL_READ Alexandre Belloni
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Stop clearing RV8803_FLAG_V2F in RTC_VL_CLR because it is a disservice to
userspace as it removes the important information that the RTC data is
invalid. This may lead userspace to set an invalid system time later on.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rv8803.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 4960f0a2b249..ed92116bdfa0 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -440,7 +440,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
return flags;
}
- flags &= ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F);
+ flags &= ~RV8803_FLAG_V1F;
ret = rv8803_write_reg(client, RV8803_FLAG, flags);
mutex_unlock(&rv8803->flags_lock);
if (ret)
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 15/17] rtc: rv8803: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (13 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 14/17] rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 16/17] rtc: rx8010: remove RTC_VL_CLR handling Alexandre Belloni
2019-12-14 22:02 ` [PATCH 17/17] rtc: rx8010: return meaningful value for RTC_VL_READ Alexandre Belloni
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
RV8803_FLAG_V1F means the voltage is too low to keep the temperature
compensation running and the accuracy of the RTC is affected.
RV8803_FLAG_V2F means the voltage dropped so low that data is now invalid.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rv8803.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index ed92116bdfa0..93c3a6b627bd 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -411,6 +411,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
struct i2c_client *client = to_i2c_client(dev);
struct rv8803_data *rv8803 = dev_get_drvdata(dev);
+ unsigned int vl = 0;
int flags, ret = 0;
switch (cmd) {
@@ -419,18 +420,15 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
if (flags < 0)
return flags;
- if (flags & RV8803_FLAG_V1F)
+ if (flags & RV8803_FLAG_V1F) {
dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n");
+ vl = RTC_VL_ACCURACY_LOW;
+ }
if (flags & RV8803_FLAG_V2F)
- dev_warn(&client->dev, "Voltage low, data loss detected.\n");
-
- flags &= RV8803_FLAG_V1F | RV8803_FLAG_V2F;
+ vl |= RTC_VL_DATA_INVALID;
- if (copy_to_user((void __user *)arg, &flags, sizeof(int)))
- return -EFAULT;
-
- return 0;
+ return put_user(vl, (unsigned int __user *)arg);
case RTC_VL_CLR:
mutex_lock(&rv8803->flags_lock);
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 16/17] rtc: rx8010: remove RTC_VL_CLR handling
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (14 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 15/17] rtc: rv8803: return meaningful value for RTC_VL_READ Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
2019-12-14 22:02 ` [PATCH 17/17] rtc: rx8010: return meaningful value for RTC_VL_READ Alexandre Belloni
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
Remove RTC_VL_CLR handling because it is a disservice to userspace as it
removes the important information that the RTC data is invalid. This may
lead userspace to set an invalid system time later on.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rx8010.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
index 8102469e27c0..9b106a26c64b 100644
--- a/drivers/rtc/rtc-rx8010.c
+++ b/drivers/rtc/rtc-rx8010.c
@@ -389,9 +389,8 @@ static int rx8010_alarm_irq_enable(struct device *dev,
static int rx8010_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
- struct i2c_client *client = to_i2c_client(dev);
struct rx8010_data *rx8010 = dev_get_drvdata(dev);
- int ret, tmp;
+ int tmp;
int flagreg;
switch (cmd) {
@@ -406,19 +405,6 @@ static int rx8010_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
return 0;
- case RTC_VL_CLR:
- flagreg = i2c_smbus_read_byte_data(rx8010->client, RX8010_FLAG);
- if (flagreg < 0) {
- return flagreg;
- }
-
- flagreg &= ~RX8010_FLAG_VLF;
- ret = i2c_smbus_write_byte_data(client, RX8010_FLAG, flagreg);
- if (ret < 0)
- return ret;
-
- return 0;
-
default:
return -ENOIOCTLCMD;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 17/17] rtc: rx8010: return meaningful value for RTC_VL_READ
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
` (15 preceding siblings ...)
2019-12-14 22:02 ` [PATCH 16/17] rtc: rx8010: remove RTC_VL_CLR handling Alexandre Belloni
@ 2019-12-14 22:02 ` Alexandre Belloni
16 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2019-12-14 22:02 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
RX8010_FLAG_VLF means the voltage dropped too low and data has been lost.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rx8010.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
index 9b106a26c64b..4021844bf2fa 100644
--- a/drivers/rtc/rtc-rx8010.c
+++ b/drivers/rtc/rtc-rx8010.c
@@ -399,11 +399,8 @@ static int rx8010_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
if (flagreg < 0)
return flagreg;
- tmp = !!(flagreg & RX8010_FLAG_VLF);
- if (copy_to_user((void __user *)arg, &tmp, sizeof(int)))
- return -EFAULT;
-
- return 0;
+ tmp = flagreg & RX8010_FLAG_VLF ? RTC_VL_DATA_INVALID : 0;
+ return put_user(tmp, (unsigned int __user *)arg);
default:
return -ENOIOCTLCMD;
--
2.23.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2019-12-14 22:04 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-14 22:02 [PATCH 00/17] rtc: Unify RTC_VL_READ meaning Alexandre Belloni
2019-12-14 22:02 ` [PATCH 01/17] rtc: define RTC_VL_READ values Alexandre Belloni
2019-12-14 22:02 ` [PATCH 02/17] rtc: Document RTC_VL_READ and RTC_VL_CLR ioctls Alexandre Belloni
2019-12-14 22:02 ` [PATCH 03/17] rtc: abx80x: return meaningful value for RTC_VL_READ Alexandre Belloni
2019-12-14 22:02 ` [PATCH 04/17] rtc: pcf2127: " Alexandre Belloni
2019-12-14 22:02 ` [PATCH 05/17] rtc: pcf8523: " Alexandre Belloni
2019-12-14 22:02 ` [PATCH 06/17] rtc: pcf8563: remove RTC_VL_CLR handling Alexandre Belloni
2019-12-14 22:02 ` [PATCH 07/17] rtc: pcf8563: remove conditional compilation Alexandre Belloni
2019-12-14 22:02 ` [PATCH 08/17] rtc: pcf8563: stop caching voltage_low Alexandre Belloni
2019-12-14 22:02 ` [PATCH 09/17] rtc: pcf8563: return meaningful value for RTC_VL_READ Alexandre Belloni
2019-12-14 22:02 ` [PATCH 10/17] rtc: pcf85063: remove RTC_VL_CLR handling Alexandre Belloni
2019-12-14 22:02 ` [PATCH 11/17] rtc: pcf85063: return meaningful value for RTC_VL_READ Alexandre Belloni
2019-12-14 22:02 ` [PATCH 12/17] rtc: rv3028: remove RTC_VL_CLR handling Alexandre Belloni
2019-12-14 22:02 ` [PATCH 13/17] rtc: rv3028: return meaningful value for RTC_VL_READ Alexandre Belloni
2019-12-14 22:02 ` [PATCH 14/17] rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR Alexandre Belloni
2019-12-14 22:02 ` [PATCH 15/17] rtc: rv8803: return meaningful value for RTC_VL_READ Alexandre Belloni
2019-12-14 22:02 ` [PATCH 16/17] rtc: rx8010: remove RTC_VL_CLR handling Alexandre Belloni
2019-12-14 22:02 ` [PATCH 17/17] rtc: rx8010: return meaningful value for RTC_VL_READ Alexandre Belloni
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).