Skip to contentSkip to conversation

rtc: rx8111: demote warnings to debug level

PATCH In review [email protected] 2 participants 4 messages Apr 17, 2024 – Apr 19, 2024 Real time clock (RTC)

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/2 rtc: rx8111: demote warnings to debug level

From: Alexandre Belloni <[email protected]>

The proper way for userspace to react on a read time error is to have a look at the voltage low information. There is no point in cluttering dmesg as it is often not even visible to the end user.

---
 drivers/rtc/rtc-rx8111.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/rtc/rtc-rx8111.c +5 -5
index 62d2352de102..4a35bd921b33 100644
@@ -170,14 +170,14 @@ static int rx8111_read_time(struct device *dev, struct rtc_time *tm)
 	}
 
 	if (FIELD_GET(RX8111_FLAG_XST_BIT, regval)) {
-		dev_warn(data->dev,
-			 "Crystal oscillation stopped, time is not reliable\n");
+		dev_dbg(data->dev,
+			"Crystal oscillation stopped, time is not reliable\n");
 		return -EINVAL;
 	}
 
 	if (FIELD_GET(RX8111_FLAG_VLF_BIT, regval)) {
-		dev_warn(data->dev,
-			 "Low voltage detected, time is not reliable\n");
+		dev_dbg(data->dev,
+			"Low voltage detected, time is not reliable\n");
 		return -EINVAL;
 	}
 
@@ -188,7 +188,7 @@ static int rx8111_read_time(struct device *dev, struct rtc_time *tm)
 	}
 
 	if (regval) {
-		dev_warn(data->dev, "Clock stopped, time is not reliable\n");
+		dev_dbg(data->dev, "Clock stopped, time is not reliable\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 2/2 rtc: rx8111: handle VLOW flag

From: Alexandre Belloni <[email protected]>

Allow userspace to get battery status information and be able to warn when battery is low and has to be replaced.

---
 drivers/rtc/rtc-rx8111.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/rtc/rtc-rx8111.c +12 -0
index 4a35bd921b33..8450d9f0b566 100644
@@ -95,6 +95,9 @@ enum rx8111_regfield {
 	RX8111_REGF_INIEN,
 	RX8111_REGF_CHGEN,
 
+	/* RX8111_REG_STATUS_MON. */
+	RX8111_REGF_VLOW,
+
 	/* Sentinel value. */
 	RX8111_REGF_MAX
 };
@@ -129,6 +132,8 @@ static const struct reg_field rx8111_regfields[] = {
 	[RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3),
 	[RX8111_REGF_INIEN]  = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6),
 	[RX8111_REGF_CHGEN]  = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7),
+
+	[RX8111_REGF_VLOW]  = REG_FIELD(RX8111_REG_STATUS_MON, 1, 1),
 };
 
 static const struct regmap_config rx8111_regmap_config = {
@@ -276,6 +281,13 @@ static int rx8111_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
 
 		vlval = regval ? RTC_VL_DATA_INVALID : 0;
 
+		ret = regmap_field_read(data->regfields[RX8111_REGF_VLOW],
+					&regval);
+		if (ret)
+			return ret;
+
+		vlval |= regval ? RTC_VL_BACKUP_LOW : 0;
+
 		return put_user(vlval, (typeof(vlval) __user *)arg);
 	default:
 		return -ENOIOCTLCMD;
Signature · 1 line
2.44.0
Tested-by Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] rtc: rx8111: handle VLOW flag

Quoted 37 lines · On Wed, Apr 17, 2024 at 21:19 +0200 [email protected] wrote:

From: Alexandre Belloni <[email protected]>

Allow userspace to get battery status information and be able to warn when battery is low and has to be replaced.

---
 drivers/rtc/rtc-rx8111.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/rtc/rtc-rx8111.c +5 -0
index 4a35bd921b33..8450d9f0b566 100644
@@ -95,6 +95,9 @@ enum rx8111_regfield {
 	RX8111_REGF_INIEN,
 	RX8111_REGF_CHGEN,
 
+	/* RX8111_REG_STATUS_MON. */
+	RX8111_REGF_VLOW,
+
 	/* Sentinel value. */
 	RX8111_REGF_MAX
 };
@@ -129,6 +132,8 @@ static const struct reg_field rx8111_regfields[] = {
 	[RX8111_REGF_SWSEL1] = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 3, 3),
 	[RX8111_REGF_INIEN]  = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 6, 6),
 	[RX8111_REGF_CHGEN]  = REG_FIELD(RX8111_REG_PWR_SWITCH_CTRL, 7, 7),
+
+	[RX8111_REGF_VLOW]  = REG_FIELD(RX8111_REG_STATUS_MON, 1, 1),
 };
 
 static const struct regmap_config rx8111_regmap_config = {
@@ -276,6 +281,13 @@ static int rx8111_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
 
 		vlval = regval ? RTC_VL_DATA_INVALID : 0;
 

drivers/rtc/rtc-rx8111.c static int rx8111_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) · line 293

Quoted 10 lines
drivers/rtc/rtc-rx8111.c +7 -0
+		ret = regmap_field_read(data->regfields[RX8111_REGF_VLOW],
+					&regval);
+		if (ret)
+			return ret;
+
+		vlval |= regval ? RTC_VL_BACKUP_LOW : 0;
+
 		return put_user(vlval, (typeof(vlval) __user *)arg);
 	default:
 		return -ENOIOCTLCMD;

Looks good to me!

Reviewed-by on v1 1/2
#3 lore raw
In reply to [email protected]
Quoted 35 lines · On Wed, Apr 17, 2024 at 21:19 +0200 [email protected] wrote:

From: Alexandre Belloni <[email protected]>

The proper way for userspace to react on a read time error is to have a look at the voltage low information. There is no point in cluttering dmesg as it is often not even visible to the end user.

---
 drivers/rtc/rtc-rx8111.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/rtc/rtc-rx8111.c +4 -4
index 62d2352de102..4a35bd921b33 100644
@@ -170,14 +170,14 @@ static int rx8111_read_time(struct device *dev, struct rtc_time *tm)
 	}
 
 	if (FIELD_GET(RX8111_FLAG_XST_BIT, regval)) {
-		dev_warn(data->dev,
-			 "Crystal oscillation stopped, time is not reliable\n");
+		dev_dbg(data->dev,
+			"Crystal oscillation stopped, time is not reliable\n");
 		return -EINVAL;
 	}
 
 	if (FIELD_GET(RX8111_FLAG_VLF_BIT, regval)) {
-		dev_warn(data->dev,
-			 "Low voltage detected, time is not reliable\n");
+		dev_dbg(data->dev,
+			"Low voltage detected, time is not reliable\n");
 		return -EINVAL;
 	}
 

drivers/rtc/rtc-rx8111.c static int rx8111_read_time(struct device *dev, struct rtc_time *tm) · line 193

Quoted 7 lines
drivers/rtc/rtc-rx8111.c +1 -1
@@ -188,7 +188,7 @@ static int rx8111_read_time(struct device *dev, struct rtc_time *tm)
 	}
 
 	if (regval) {
-		dev_warn(data->dev, "Clock stopped, time is not reliable\n");
+		dev_dbg(data->dev, "Clock stopped, time is not reliable\n");
 		return -EINVAL;
 	}

There are several other drivers that uses dev_warn() in these cases, and it was just followed here as well. I agree with you here though!