Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1388141 > unrolled thread

[PATCH v2 0/6] simplify rtc-generic driver

Started byArnd Bergmann <arnd@arndb.de>
First post2016-04-27 00:00 +0200
Last post2016-04-27 10:00 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/6] simplify rtc-generic driver Arnd Bergmann <arnd@arndb.de> - 2016-04-27 00:00 +0200
    [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly Arnd Bergmann <arnd@arndb.de> - 2016-04-27 00:00 +0200
      Re: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly kbuild test robot <lkp@intel.com> - 2016-04-27 02:30 +0200
        Re: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly Arnd Bergmann <arnd@arndb.de> - 2016-04-27 12:20 +0200
    [PATCH v2 2/6] rtc: m68k: provide ioctl for q40 Arnd Bergmann <arnd@arndb.de> - 2016-04-27 00:00 +0200
    Re: [PATCH v2 0/6] simplify rtc-generic driver Geert Uytterhoeven <geert@linux-m68k.org> - 2016-04-27 10:00 +0200

#1388141 — [PATCH v2 0/6] simplify rtc-generic driver

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-27 00:00 +0200
Subject[PATCH v2 0/6] simplify rtc-generic driver
Message-ID<rsjbs-6Bl-7@gated-at.bofh.it>
This is a resend of an earlier series, to clean up the rtc-generic
driver by avoiding the dependency on the architecture specific
include/asm/rtc.h header that after this series is only used
for the deprecated "genrtc" driver. As I've shown in another
series, only three architectures (m68k, powerpc, parisc)
actually use the genrtc driver, and they all support rtc-generic
as a replacement as well.

The only missing piece appears to be the ioctl support for
the m68k q40 machine that I'm adding in patch 2 here.

	Arnd

[toc] | [next] | [standalone]


#1388142 — [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-27 00:00 +0200
Subject[PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly
Message-ID<rsjbu-6Bl-45@gated-at.bofh.it>
In reply to#1388141
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 | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 58dd6801f5be..1338d92fc87b 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>
@@ -248,14 +249,47 @@ void __init start_cpu_itimer(void)
 	per_cpu(cpu_data, cpu).it_value = next_tick;
 }
 
+#ifdef CONFIG_RTC_DRV_GENERIC
+static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pdc_tod tod_data;
+
+	memset(tm, 0, sizeof(*tm));
+	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);
+#endif
 
 void read_persistent_clock(struct timespec *ts)
 {
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1388468 — Re: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly

Fromkbuild test robot <lkp@intel.com>
Date2016-04-27 02:30 +0200
SubjectRe: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly
Message-ID<rslwC-g8-13@gated-at.bofh.it>
In reply to#1388142

[Multipart message — attachments visible in raw view] — view raw

Hi,

[auto build test ERROR on next-20160426]
[cannot apply to m68k/for-next abelloni/rtc-next v4.6-rc5 v4.6-rc4 v4.6-rc3 v4.6-rc5]
[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/simplify-rtc-generic-driver/20160427-055751
config: parisc-c3000_defconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
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 

Note: the linux-review/Arnd-Bergmann/simplify-rtc-generic-driver/20160427-055751 HEAD ba518829eb442ee7f7806864a806fa45791f787f builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   arch/parisc/kernel/time.c: In function 'rtc_generic_get_time':
>> arch/parisc/kernel/time.c:262:37: error: passing argument 2 of 'rtc_time64_to_tm' from incompatible pointer type [-Werror=incompatible-pointer-types]
     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);
                ^
   cc1: some warnings being treated as errors

vim +/rtc_time64_to_tm +262 arch/parisc/kernel/time.c

   256	
   257		memset(tm, 0, sizeof(*tm));
   258		if (pdc_tod_read(&tod_data) < 0)
   259			return -EOPNOTSUPP;
   260	
   261		/* we treat tod_sec as unsigned, so this can work until year 2106 */
 > 262		rtc_time64_to_tm(tod_data.tod_sec, &tm);
   263		return rtc_valid_tm(tm);
   264	}
   265	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1388877 — Re: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-27 12:20 +0200
SubjectRe: [PATCH v2 4/6] rtc: parisc: provide rtc_class_ops directly
Message-ID<rsuJz-7VP-13@gated-at.bofh.it>
In reply to#1388468
On Wednesday 27 April 2016 08:22:24 kbuild test robot wrote:
> 
>    256  
>    257          memset(tm, 0, sizeof(*tm));
>    258          if (pdc_tod_read(&tod_data) < 0)
>    259                  return -EOPNOTSUPP;
>    260  
>    261          /* we treat tod_sec as unsigned, so this can work until year 2106 */
>  > 262          rtc_time64_to_tm(tod_data.tod_sec, &tm);
>    263          return rtc_valid_tm(tm);
>    264  }
> 

Fixed, thanks!

	Arnd

[toc] | [prev] | [next] | [standalone]


#1388143 — [PATCH v2 2/6] rtc: m68k: provide ioctl for q40

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-27 00:00 +0200
Subject[PATCH v2 2/6] rtc: m68k: provide ioctl for q40
Message-ID<rsjbu-6Bl-43@gated-at.bofh.it>
In reply to#1388141
The q40 platform is the only machine in the kernel that provides
RTC_PLL_GET/RTC_PLL_SET ioctl commands in its rtc through the
mach_get_rtc_pll/mach_set_rtc_pll callbacks.

However, this currenctly works only in the old-style genrtc
driver, not the (somewhat) modern rtc-generic driver replacing
it. This adds an ioctl implementation to the m68k generic_rtc_ops
in order to let both drivers provide the same API.

After this, we should be able to remove support for genrtc
from the m68k architecture.

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

diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index fe35890feede..5f0a5826a05e 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -100,7 +100,32 @@ static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
 	return 0;
 }
 
+static int rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	struct rtc_pll_info pll;
+	struct rtc_pll_info __user *argp = (void __user *)arg;
+
+	switch (cmd) {
+	case RTC_PLL_GET:
+		if (!mach_get_rtc_pll || mach_get_rtc_pll(&pll))
+			return -EINVAL;
+		return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0;
+
+	case RTC_PLL_SET:
+		if (!mach_set_rtc_pll)
+			return -EINVAL;
+		if (!capable(CAP_SYS_TIME))
+			return -EACCES;
+		if (copy_from_user(&pll, argp, sizeof(pll)))
+			return -EFAULT;
+		return mach_set_rtc_pll(&pll);
+	}
+
+	return -ENOIOCTLCMD;
+}
+
 static const struct rtc_class_ops generic_rtc_ops = {
+	.ioctl = rtc_ioctl,
 	.read_time = rtc_generic_get_time,
 	.set_time = rtc_generic_set_time,
 };
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1388748

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-04-27 10:00 +0200
Message-ID<rssy6-5VB-13@gated-at.bofh.it>
In reply to#1388141
Hi Arnd,

On Tue, Apr 26, 2016 at 11:52 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> This is a resend of an earlier series, to clean up the rtc-generic
> driver by avoiding the dependency on the architecture specific
> include/asm/rtc.h header that after this series is only used
> for the deprecated "genrtc" driver. As I've shown in another
> series, only three architectures (m68k, powerpc, parisc)
> actually use the genrtc driver, and they all support rtc-generic
> as a replacement as well.
>
> The only missing piece appears to be the ioctl support for
> the m68k q40 machine that I'm adding in patch 2 here.

Apparently I had applied your previous version to my local tree, but I had
completely forgotten about it. So it has received quite some compile testing.

CONFIG_GEN_RTC is not enabled in any of the m68k defconfigs, so I think it's
been unused for a while.
CONFIG_RTC_DRV_GENERIC is modular, so I typically don't run-test it.
I just did that, and after fixing patch 1 to use IS_ENABLED() it worked fine
on ARAnyM.

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

I do not have a Q40, so I couldn't test that part.

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web