diff mbox

[4/6] parisc: rtc: provide rtc_class_ops directly

Message ID 1456851608-3374907-5-git-send-email-arnd@arndb.de
State New
Headers show

Commit Message

Arnd Bergmann March 1, 2016, 5 p.m. UTC
The rtc-generic driver provides an architecture specific
wrapper on top of the generic rtc_class_ops abstraction,
and on pa-risc, that is implemented using an open-coded
version of rtc_time_to_tm/rtc_tm_to_time.

This changes the parisc rtc-generic device to provide its
rtc_class_ops directly, using the normal helper functions,
which makes this y2038 safe (on 32-bit) and simplifies
the implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/parisc/kernel/time.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

Comments

kernel test robot March 1, 2016, 5:19 p.m. UTC | #1
Hi Arnd,

[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.5-rc6 next-20160301]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/rtc-generic-follow-up-for-COMPILE_TEST/20160302-011032
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: parisc-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=parisc 

All error/warnings (new ones prefixed by >>):

   arch/parisc/kernel/time.c: In function 'rtc_generic_get_time':
>> arch/parisc/kernel/time.c:232:9: error: 'wtime' undeclared (first use in this function)
     memset(wtime, 0, sizeof(*wtime));
            ^
   arch/parisc/kernel/time.c:232:9: note: each undeclared identifier is reported only once for each function it appears in
>> arch/parisc/kernel/time.c:237:2: warning: passing argument 2 of 'rtc_time64_to_tm' from incompatible pointer type
     rtc_time64_to_tm(tod_data.tod_sec, &tm);
     ^
   In file included from arch/parisc/kernel/time.c:15:0:
   include/linux/rtc.h:23:13: note: expected 'struct rtc_time *' but argument is of type 'struct rtc_time **'
    extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm);
                ^

vim +/wtime +232 arch/parisc/kernel/time.c

   226	}
   227	
   228	static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
   229	{
   230		struct pdc_tod tod_data;
   231	
 > 232		memset(wtime, 0, sizeof(*wtime));
   233		if (pdc_tod_read(&tod_data) < 0)
   234			return -EOPNOTSUPP;
   235	
   236		/* we treat tod_sec as unsigned, so this can work until year 2106 */
 > 237		rtc_time64_to_tm(tod_data.tod_sec, &tm);
   238		return rtc_valid_tm(tm);
   239	}
   240	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Alexandre Belloni March 10, 2016, 4:34 a.m. UTC | #2
On 01/03/2016 at 18:00:00 +0100, Arnd Bergmann wrote :
> -	pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
> +	pdev = platform_device_register_data(NULL, "rtc-generic", -1,
> +					     &rtc_generic_ops,
> +					     sizeof(rtc_generic_ops));
> +
> +

spurious blank line

>  	return PTR_ERR_OR_ZERO(pdev);
>  }
>  device_initcall(rtc_init);
> -- 
> 2.7.0
>
diff mbox

Patch

diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 400acac0a304..176ef5c2aa82 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -12,6 +12,7 @@ 
  */
 #include <linux/errno.h>
 #include <linux/module.h>
+#include <linux/rtc.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
@@ -224,11 +225,43 @@  void __init start_cpu_itimer(void)
 	per_cpu(cpu_data, cpu).it_value = next_tick;
 }
 
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pdc_tod tod_data;
+
+	memset(wtime, 0, sizeof(*wtime));
+	if (pdc_tod_read(&tod_data) < 0)
+		return -EOPNOTSUPP;
+
+	/* we treat tod_sec as unsigned, so this can work until year 2106 */
+	rtc_time64_to_tm(tod_data.tod_sec, &tm);
+	return rtc_valid_tm(tm);
+}
+
+static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
+{
+	time64_t secs = rtc_tm_to_time64(tm);
+
+	if (pdc_tod_set(secs, 0) < 0)
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+
+static const struct rtc_class_ops rtc_generic_ops = {
+	.read_time = rtc_generic_get_time,
+	.set_time = rtc_generic_set_time,
+};
+
 static int __init rtc_init(void)
 {
 	struct platform_device *pdev;
 
-	pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
+	pdev = platform_device_register_data(NULL, "rtc-generic", -1,
+					     &rtc_generic_ops,
+					     sizeof(rtc_generic_ops));
+
+
 	return PTR_ERR_OR_ZERO(pdev);
 }
 device_initcall(rtc_init);