Skip to contentSkip to conversation

rtc: add support for maxim dallas rtc ds1343 and ds1344

PATCH In review Raghavendra Ganiga 3 participants 4 messages May 6, 2014 – May 7, 2014 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: add support for maxim dallas rtc ds1343 and ds1344

This is a patch to add support for
maxim dallas rtc ds1343 and ds1344

---
 drivers/rtc/Kconfig      |   10 +
 drivers/rtc/Makefile     |    1 +
 drivers/rtc/rtc-ds1343.c |  679 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 690 insertions(+)
 create mode 100644 drivers/rtc/rtc-ds1343.c
drivers/rtc/Kconfig +10 -0
index 2e565f8..eb5cdcb 100644
@@ -573,6 +573,16 @@ config RTC_DRV_DS1305
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-ds1305.
 
+config RTC_DRV_DS1343
+	tristate "Dallas/Maxim DS1343/DS1344"
+	help
+	  If you say yes here you get support for the
+	  Dallas/Maxim DS1343 and DS1344 real time clock chips.
+	  Support for trickle charger, alarm is provided.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-ds1343.
+
 config RTC_DRV_DS1347
 	tristate "Dallas/Maxim DS1347"
 	help
drivers/rtc/Makefile +1 -0
index 40a0991..a8daf6c 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_DS1286)	+= rtc-ds1286.o
 obj-$(CONFIG_RTC_DRV_DS1302)	+= rtc-ds1302.o
 obj-$(CONFIG_RTC_DRV_DS1305)	+= rtc-ds1305.o
 obj-$(CONFIG_RTC_DRV_DS1307)	+= rtc-ds1307.o
+obj-$(CONFIG_RTC_DRV_DS1343)	+= rtc-ds1343.o
 obj-$(CONFIG_RTC_DRV_DS1347)	+= rtc-ds1347.o
 obj-$(CONFIG_RTC_DRV_DS1374)	+= rtc-ds1374.o
 obj-$(CONFIG_RTC_DRV_DS1390)	+= rtc-ds1390.o
drivers/rtc/rtc-ds1343.c new file +679 -0

679 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 11 lines · On Wed, 7 May 2014 00:33:56 +0530 Raghavendra Ganiga <[email protected]>…

This is a patch to add support for
maxim dallas rtc ds1343 and ds1344

...

drivers/rtc/rtc-ds1343.c new file +6 -0
+static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+#ifdef RTC_SET_CHARGE
+	case RTC_SET_CHARGE:
+	{

drivers/rtc/rtc-ds1343.c line 104

Quoted 10 lines
drivers/rtc/rtc-ds1343.c new file +10 -0
+		int val;
+
+		if (copy_from_user(&val, (int __user *)arg, sizeof(int)))
+			return -EFAULT;
+
+		return regmap_write(priv->map, DS1343_TRICKLE_REG, val);
+	}
+	break;
+#endif
+	}

Why is RTC_SET_CHARGE defined only for m32r? It seems pretty generic?

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return -ENOIOCTLCMD;
+}

It's possible that this should be -ENOTTY. I always forget the rule, but Alan never forgets anything ;)

#2 lore raw
Quoted 26 lines · On Wed, 7 May 2014 14:42:48 -0700 Andrew Morton <[email protected]>…
Quoted 11 lines · On Wed, 7 May 2014 00:33:56 +0530 Raghavendra Ganiga <[email protected]>…

This is a patch to add support for
maxim dallas rtc ds1343 and ds1344

...

drivers/rtc/rtc-ds1343.c new file +6 -0
+static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+#ifdef RTC_SET_CHARGE
+	case RTC_SET_CHARGE:
+	{

drivers/rtc/rtc-ds1343.c line 104

Quoted 10 lines
drivers/rtc/rtc-ds1343.c new file +10 -0
+		int val;
+
+		if (copy_from_user(&val, (int __user *)arg, sizeof(int)))
+			return -EFAULT;
+
+		return regmap_write(priv->map, DS1343_TRICKLE_REG, val);
+	}
+	break;
+#endif
+	}

Why is RTC_SET_CHARGE defined only for m32r? It seems pretty generic?

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return -ENOIOCTLCMD;
+}

It's possible that this should be -ENOTTY. I always forget the rule, but Alan never forgets anything ;)

I forget lots 8)

-ENOTTY if it will be returned to user space, -ENOIOCTLCMD is used by some core code internally as a way for the sub drivers to tell the core "I didn't handle this, maybe you have a default method ?"

Alan

#3 lore raw
Quoted 35 lines · On Wed, 7 May 2014 23:15:29 +0100 Alan Cox <[email protected]> wrote:
Quoted 26 lines · On Wed, 7 May 2014 14:42:48 -0700 Andrew Morton <[email protected]>…
Quoted 11 lines · On Wed, 7 May 2014 00:33:56 +0530 Raghavendra Ganiga <[email protected]>…

This is a patch to add support for
maxim dallas rtc ds1343 and ds1344

...

drivers/rtc/rtc-ds1343.c new file +6 -0
+static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+#ifdef RTC_SET_CHARGE
+	case RTC_SET_CHARGE:
+	{

drivers/rtc/rtc-ds1343.c line 104

Quoted 10 lines
drivers/rtc/rtc-ds1343.c new file +10 -0
+		int val;
+
+		if (copy_from_user(&val, (int __user *)arg, sizeof(int)))
+			return -EFAULT;
+
+		return regmap_write(priv->map, DS1343_TRICKLE_REG, val);
+	}
+	break;
+#endif
+	}

Why is RTC_SET_CHARGE defined only for m32r? It seems pretty generic?

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return -ENOIOCTLCMD;
+}

It's possible that this should be -ENOTTY. I always forget the rule, but Alan never forgets anything ;)

Quoted 5 lines

I forget lots 8)

-ENOTTY if it will be returned to user space, -ENOIOCTLCMD is used by some core code internally as a way for the sub drivers to tell the core "I didn't handle this, maybe you have a default method ?"

Ah OK, thanks.

drivers/rtc/rtc-dev.c does

	default:
		/* Finally try the driver's ioctl interface */
		if (ops->ioctl) {
			err = ops->ioctl(rtc->dev.parent, cmd, arg);
			if (err == -ENOIOCTLCMD)
				err = -ENOTTY;
		} else
			err = -ENOTTY;

so ENOIOCTLCMD is appropriate here.

Even though rtc is upside down - it prioritises the core's ioctl parsing ahead of the drivers'.