Skip to contentSkip to conversation

rtc: pcf2127: report battery switch over

PATCH New Alexandre Belloni 2 participants 2 messages May 11, 2020 Real time clock (RTC)

lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH v2 1/1 rtc: pcf2127: report battery switch over

Add support for the RTC_VL_BACKUP_SWITCH flag to report battery switch over events.

---
 drivers/rtc/rtc-pcf2127.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pcf2127.c +12 -4
index 039078029bd4..e5e3cd128476 100644
@@ -188,18 +188,27 @@ static int pcf2127_rtc_ioctl(struct device *dev,
 				unsigned int cmd, unsigned long arg)
 {
 	struct pcf2127 *pcf2127 = dev_get_drvdata(dev);
-	int touser;
+	int val, touser = 0;
 	int ret;
 
 	switch (cmd) {
 	case RTC_VL_READ:
-		ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL3, &touser);
+		ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL3, &val);
 		if (ret)
 			return ret;
 
-		touser = touser & PCF2127_BIT_CTRL3_BLF ? RTC_VL_BACKUP_LOW : 0;
+		if (val & PCF2127_BIT_CTRL3_BLF)
+			touser |= RTC_VL_BACKUP_LOW;
+
+		if (val & PCF2127_BIT_CTRL3_BF)
+			touser |= RTC_VL_BACKUP_SWITCH;
 
 		return put_user(touser, (unsigned int __user *)arg);
+
+	case RTC_VL_CLR:
+		return regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL3,
+					  PCF2127_BIT_CTRL3_BF, 0);
+
 	default:
 		return -ENOIOCTLCMD;
 	}
@@ -493,7 +502,6 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
 	 */
 	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL3,
 				 PCF2127_BIT_CTRL3_BTSE |
-				 PCF2127_BIT_CTRL3_BF |
 				 PCF2127_BIT_CTRL3_BIE |
 				 PCF2127_BIT_CTRL3_BLIE, 0);
 	if (ret) {
Signature · 1 line
2.26.2
#1 lore raw
I love your patch! Yet something to improve:

Hi Alexandre,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc5 next-20200511]
[cannot apply to abelloni/rtc-next linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexandre-Belloni/rtc-pcf2127-report-battery-switch-over/20200512-024648
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/rtc/rtc-pcf2127.c: In function 'pcf2127_rtc_ioctl':

>> drivers/rtc/rtc-pcf2127.c:206:14: error: 'RTC_VL_BACKUP_SWITCH' undeclared (first use in this function); did you mean 'RTC_VL_BACKUP_EMPTY'?
       touser |= RTC_VL_BACKUP_SWITCH;
                 ^~~~~~~~~~~~~~~~~~~~
                 RTC_VL_BACKUP_EMPTY

drivers/rtc/rtc-pcf2127.c:206:14: note: each undeclared identifier is reported only once for each function it appears in

vim +206 drivers/rtc/rtc-pcf2127.c

187
188 #ifdef CONFIG_RTC_INTF_DEV
189 static int pcf2127_rtc_ioctl(struct device *dev,
190 unsigned int cmd, unsigned long arg)
191 {
192 struct pcf2127 *pcf2127 = dev_get_drvdata(dev);
193 int val, touser = 0;
194 int ret;
195
196 switch (cmd) {
197 case RTC_VL_READ:
198 ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL3, &val);
199 if (ret)
200 return ret;
201
202 if (val & PCF2127_BIT_CTRL3_BLF)
203 touser |= RTC_VL_BACKUP_LOW;
204
205 if (val & PCF2127_BIT_CTRL3_BF)

 > 206				touser |= RTC_VL_BACKUP_SWITCH;

207
208 return put_user(touser, (unsigned int __user *)arg);
209
210 case RTC_VL_CLR:
211 return regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL3,
212 PCF2127_BIT_CTRL3_BF, 0);
213
214 default:
215 return -ENOIOCTLCMD;
216 }
217 }
218 #else
219 #define pcf2127_rtc_ioctl NULL
220 #endif
221

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org