From: Andrew Morton <akpm@linux-foundation.org>
To: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Thierry Reding <thierry.reding@avionic-design.de>,
Alessandro Zummo <a.zummo@towertech.it>,
rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] rtc-pcf8523: Add low battery voltage support
Date: Wed, 19 Dec 2012 14:03:58 -0800 [thread overview]
Message-ID: <20121219140358.8658ee86.akpm@linux-foundation.org> (raw)
In-Reply-To: <20121219160033.GF14217@axis.com>
On Wed, 19 Dec 2012 17:00:33 +0100
Jesper Nilsson <jesper.nilsson@axis.com> wrote:
> This patch implements reading of the battery voltage low signal for
> rtc-pcf8523.
>
> The bit is read-only and cannot be cleared by software, so no
> clear-function is implemented.
>
> ...
>
> --- a/drivers/rtc/rtc-pcf8523.c
> +++ b/drivers/rtc/rtc-pcf8523.c
> @@ -23,6 +23,7 @@
> #define REG_CONTROL3_PM_VDD (1 << 6) /* switch-over disabled */
> #define REG_CONTROL3_PM_DSM (1 << 5) /* direct switching mode */
> #define REG_CONTROL3_PM_MASK 0xe0
> +#define REG_CONTROL3_BLF (1 << 2) /* battery low bit, read-only */
>
> #define REG_SECONDS 0x03
> #define REG_SECONDS_OS (1 << 7)
> @@ -250,9 +252,35 @@ static int pcf8523_rtc_set_time(struct device *dev, struct rtc_time *tm)
> return pcf8523_start_rtc(client);
> }
>
> +static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
> + unsigned long arg)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + u8 value;
> + int ret = 0, err;
> +
> + switch (cmd) {
> + case RTC_VL_READ:
> + err = pcf8523_read(client, REG_CONTROL3, &value);
> + if (err < 0)
> + return err;
> +
> + if (value & REG_CONTROL3_BLF)
> + ret = 1;
> +
> + if (copy_to_user((void __user *)arg, &ret, sizeof(int)))
> + return -EFAULT;
> +
> + return 0;
> + default:
> + return -ENOIOCTLCMD;
> + }
> +}
> +
> static const struct rtc_class_ops pcf8523_rtc_ops = {
> .read_time = pcf8523_rtc_read_time,
> .set_time = pcf8523_rtc_set_time,
> + .ioctl = pcf8523_rtc_ioctl,
> };
Other drivers make the ioctl conditional on CONFIG_RTC_INTF_DEV,
presumably to avoid bloat.
--- a/drivers/rtc/rtc-pcf8523.c~rtc-pcf8523-add-low-battery-voltage-support-fix
+++ a/drivers/rtc/rtc-pcf8523.c
@@ -251,6 +251,7 @@ static int pcf8523_rtc_set_time(struct d
return pcf8523_start_rtc(client);
}
+#ifdef CONFIG_RTC_INTF_DEV
static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
unsigned long arg)
{
@@ -275,6 +276,9 @@ static int pcf8523_rtc_ioctl(struct devi
return -ENOIOCTLCMD;
}
}
+#else
+#define pcf8523_rtc_ioctl NULL
+#endif
static const struct rtc_class_ops pcf8523_rtc_ops = {
.read_time = pcf8523_rtc_read_time,
_
prev parent reply other threads:[~2012-12-19 22:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 14:04 [PATCH] rtc-pcf8523: Add low battery voltage support Jesper Nilsson
2012-12-19 14:42 ` Thierry Reding
2012-12-19 15:10 ` Jesper Nilsson
2012-12-19 15:19 ` Thierry Reding
2012-12-19 15:34 ` [PATCH v2] " Jesper Nilsson
2012-12-19 15:48 ` Thierry Reding
2012-12-19 16:00 ` [PATCH v3] " Jesper Nilsson
2012-12-19 22:03 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121219140358.8658ee86.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.zummo@towertech.it \
--cc=jesper.nilsson@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=thierry.reding@avionic-design.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).