aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/dev.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2021-10-18 17:19:31 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2021-10-18 17:20:50 +0200
commit0d20e9fb1262b1f9ac895b287db892bc75b05b84 (patch)
tree3d8e56cfa4e52674c2a8fbb0abb7c9b277676856 /drivers/rtc/dev.c
parenta6d8c6e1a5c6fb982964861dc84c0c7cb0151c7c (diff)
downloadlinux-0d20e9fb1262b1f9ac895b287db892bc75b05b84.tar.gz
rtc: add BSM parameter
BSM or Backup Switch Mode is a common feature on RTCs, allowing to select how the RTC will decide when to switch from its primary power supply to the backup power supply. It is necessary to be able to set it from userspace as there are uses cases where it has to be done dynamically. Supported values are: RTC_BSM_DISABLED: disabled RTC_BSM_DIRECT: switching will happen as soon as Vbackup > Vdd RTC_BSM_LEVEL: switching will happen around a threshold, usually with an hysteresis RTC_BSM_STANDBY: switching will not happen until Vdd > Vbackup, this is useful to ensure the RTC doesn't draw any power until the device is first powered on. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20211018151933.76865-6-alexandre.belloni@bootlin.com
Diffstat (limited to 'drivers/rtc/dev.c')
-rw-r--r--drivers/rtc/dev.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
index abee1fc4705e4..e104972a28fdf 100644
--- a/drivers/rtc/dev.c
+++ b/drivers/rtc/dev.c
@@ -409,7 +409,10 @@ static long rtc_dev_ioctl(struct file *file,
break;
default:
- err = -EINVAL;
+ if (rtc->ops->param_get)
+ err = rtc->ops->param_get(rtc->dev.parent, &param);
+ else
+ err = -EINVAL;
}
if (!err)
@@ -436,7 +439,10 @@ static long rtc_dev_ioctl(struct file *file,
return rtc_set_offset(rtc, param.svalue);
default:
- err = -EINVAL;
+ if (rtc->ops->param_set)
+ err = rtc->ops->param_set(rtc->dev.parent, &param);
+ else
+ err = -EINVAL;
}
break;