From patchwork Mon May 30 18:57:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102291 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1552928qge; Mon, 30 May 2016 11:58:32 -0700 (PDT) X-Received: by 10.98.58.156 with SMTP id v28mr48776870pfj.137.1464634712657; Mon, 30 May 2016 11:58:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si10488327pfk.60.2016.05.30.11.58.32; Mon, 30 May 2016 11:58:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161921AbcE3S63 (ORCPT + 30 others); Mon, 30 May 2016 14:58:29 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:59611 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161683AbcE3S6Z (ORCPT ); Mon, 30 May 2016 14:58:25 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LjbI0-1beJES2r7I-00bZ7u; Mon, 30 May 2016 20:57:57 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 01/16] rtc: cmos: remove empty asm/mc146818rtc.h files Date: Mon, 30 May 2016 20:57:49 +0200 Message-Id: <1464634684-1248135-2-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:1aXT3wg0IgxBgGufjeb3xIN4xcHwKpwHGaPrECr5QxRHAOypyID LhkwHrW50GmuqJc7ul46RSh+2oGwFAFl4L8dhVCRAg5P2T3f1Bj0G3raUTyuMOpurOSCHHR Ly+InAQJYCLKCda6lY3bLbQpqjDrMrZHZjef3oPV7p2ZS5AD+A241kcTN9QHLR/nDGXULMA BpzoNdfpOal8NuUFKoP2w== X-UI-Out-Filterresults: notjunk:1; V01:K0:e7zN+ECmFZI=:TB0W4atRK4s8jGOWel68YQ OEKTt5tIznrs/69D/e1lE6BLowMMNb0zrAE3ZI5rPsanJ15fnYTMtk01gkoRFR7y0ds6Wqiqi VlNO0ZbnSC6Z5goVFQ+iPotSJSAb8B8EjtiC7GSw/MvBsh/mp9DmiA+e+PzYy3hRxh0gw/wZf D/zFPcfXH/KDNU7yVE80wc/rAOP2p5eFXIm2b6INWhiPUw/QV+JGhZ8XnFbL4C7SDPWvv7uLq /C8S0wkX9Vle6prZdnmwNMHPxjfJj309OZPdHiEsu43FXNtab/c9tCdP59vuGHqW8clYSIaVB Tpn7rixo0zX1NzPoOE1pnzAnP7XarM5B9R4wmsoC/LYJtZ44E6tQIYzSBrp7BWgDYn0Fx0ocx Sc5sPECYH3OiAna+BwIYb7nnB99lSZukDv549VqtWo5eH9wjib5FdmJClxxvgkFr0VlbTgcVo 8yBBqJN866UwhHEDjbTaP+oaOR20ERBUF5K+Q7FBlivH61QTuB3VetxztAQH/+IDDHdZf3/N3 Cohfdz4IXr4wQeLU8hpL4LPzf/Ad+KQ0Y4veYEg+pmFVvK3HZVk+UObnHc5NzEiFbDpc2cpYd XYZQNp0Obe1DeEttb7zi2MGAo2VnmBKsuzzva+0GnPiMQ5aEsudlGBvDIjLnqJBaOGfSLTUUa jMStXrw8CAeHltsLzB4u5wZrF5gBCcjKIIzj7HMIhF8JbV4MKJu/NDQPNHeGXjNVJyyA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nothing on these architectures ever includes the asm/mc146818rtc.h file, the drivers that used to do this have been fixed long ago, and the remaining users are all PC-specific. This removes the files for good. Signed-off-by: Arnd Bergmann Acked-by: Alexandre Belloni --- arch/frv/include/asm/mc146818rtc.h | 16 ---------------- arch/h8300/include/asm/mc146818rtc.h | 9 --------- arch/ia64/include/asm/mc146818rtc.h | 10 ---------- arch/parisc/include/asm/mc146818rtc.h | 9 --------- arch/sh/include/asm/mc146818rtc.h | 7 ------- 5 files changed, 51 deletions(-) delete mode 100644 arch/frv/include/asm/mc146818rtc.h delete mode 100644 arch/h8300/include/asm/mc146818rtc.h delete mode 100644 arch/ia64/include/asm/mc146818rtc.h delete mode 100644 arch/parisc/include/asm/mc146818rtc.h delete mode 100644 arch/sh/include/asm/mc146818rtc.h -- 2.7.0 diff --git a/arch/frv/include/asm/mc146818rtc.h b/arch/frv/include/asm/mc146818rtc.h deleted file mode 100644 index 90dfb7a633d1..000000000000 --- a/arch/frv/include/asm/mc146818rtc.h +++ /dev/null @@ -1,16 +0,0 @@ -/* mc146818rtc.h: RTC defs - * - * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved. - * Written by David Howells (dhowells@redhat.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#ifndef _ASM_MC146818RTC_H -#define _ASM_MC146818RTC_H - - -#endif /* _ASM_MC146818RTC_H */ diff --git a/arch/h8300/include/asm/mc146818rtc.h b/arch/h8300/include/asm/mc146818rtc.h deleted file mode 100644 index ab9d9646d241..000000000000 --- a/arch/h8300/include/asm/mc146818rtc.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Machine dependent access functions for RTC registers. - */ -#ifndef _H8300_MC146818RTC_H -#define _H8300_MC146818RTC_H - -/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */ - -#endif /* _H8300_MC146818RTC_H */ diff --git a/arch/ia64/include/asm/mc146818rtc.h b/arch/ia64/include/asm/mc146818rtc.h deleted file mode 100644 index 407787a237ba..000000000000 --- a/arch/ia64/include/asm/mc146818rtc.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _ASM_IA64_MC146818RTC_H -#define _ASM_IA64_MC146818RTC_H - -/* - * Machine dependent access functions for RTC registers. - */ - -/* empty include file to satisfy the include in genrtc.c */ - -#endif /* _ASM_IA64_MC146818RTC_H */ diff --git a/arch/parisc/include/asm/mc146818rtc.h b/arch/parisc/include/asm/mc146818rtc.h deleted file mode 100644 index adf41631449f..000000000000 --- a/arch/parisc/include/asm/mc146818rtc.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Machine dependent access functions for RTC registers. - */ -#ifndef _ASM_MC146818RTC_H -#define _ASM_MC146818RTC_H - -/* empty include file to satisfy the include in genrtc.c */ - -#endif /* _ASM_MC146818RTC_H */ diff --git a/arch/sh/include/asm/mc146818rtc.h b/arch/sh/include/asm/mc146818rtc.h deleted file mode 100644 index 0aee96a97330..000000000000 --- a/arch/sh/include/asm/mc146818rtc.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Machine dependent access functions for RTC registers. - */ -#ifndef _ASM_MC146818RTC_H -#define _ASM_MC146818RTC_H - -#endif /* _ASM_MC146818RTC_H */ From patchwork Mon May 30 18:57:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102286 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553135qge; Mon, 30 May 2016 11:59:11 -0700 (PDT) X-Received: by 10.98.69.197 with SMTP id n66mr49337445pfi.75.1464634750568; Mon, 30 May 2016 11:59:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qz13si3614678pac.50.2016.05.30.11.59.10; Mon, 30 May 2016 11:59:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162036AbcE3S7E (ORCPT + 30 others); Mon, 30 May 2016 14:59:04 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:49288 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161992AbcE3S6r (ORCPT ); Mon, 30 May 2016 14:58:47 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M731J-1bSZfM12zF-00wmCx; Mon, 30 May 2016 20:57:57 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 02/16] rtc: cmos: move mc146818rtc code out of asm-generic/rtc.h Date: Mon, 30 May 2016 20:57:50 +0200 Message-Id: <1464634684-1248135-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:fjZE0d4y4EYuowh80NT1fVXQgpErEgI3RQ0AhwT47114juHWv9S 7kZSaomggSQ5hbAwiVU7bb9ErsPFiLVCfKU3qZoDxyDubgnoY7lBNuC4+IJBc8ZSxy+W620 gzWdPAC9a+a8fahAmKPcbq0bUSmxAok+zlCxTrE5MGArJgT7NNof3x7LbFGcVnEAru95vYm wqP4FTWoolOw/bBxS7CZQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:c0t4CetSlm0=:6TjECgdj3we/Kn/DGb2/Yx uR5Dv+WSVikb/rYO4iqdU3tHR0nf2eREgl2htKYy5aiYn+fQIvUf1+A7b34hGjUPVKEDGoh+3 yg4ENZTeK/SZDiPHWNfks/9/H+balaPVITqAqMJJRdzVX5+hd5Zxr8VfPOHNpTCq9LEst1f8i Ah7Jid817ogJmJf44l5QpllaSX+IzM5vVD3em16D0RJKV5tAT8VlyeSqUUcKrcxu2Uc+wQwDY 0pjCgI9Gs19FNstfIFUkd3wA3bRoRjOybvXQlz+jGMvN8uWRRPQoPTeVKSsr1IAXOXATw/Rde wDf5pmZT9TI2VD8bM0a5KntdhgyPRh1zcRyDxE3XlqhRjjG4GbNqOvJUTurkgnz25YGrZBfbt q9UhuBF6XoNkYFwebZVDPBTeCCWZRwOgI4kPuZVQWViOLmXoMIaU15WSG4xGiD+5M2eje+rba P0yoFhiF9Jso5sgwrwKrO1L7MCZ9gBwyyGCLeVmYQZc/yMURjpLJLbBPiM1bcTSC0gt5wk50U GjxSiL6z0q+/J+qBtpsg+OLVBqeLqou0rdpWoJsPJIvAXHNnIRPgMcgMFmjRuMtkSsV2R2YSB 3A7ljVSriFJ/OTQngW9DMIsymYD0gzcdiXVwQt+iC7jq2utAhI7P3SdD0QZS9yVzgu6f7dWmU q5aFURmI9auDIwimxV+2YyX02XsnBYFnvNqEIvTRIWB1CNSH4pEO8jeAP7Fl8Mlz5KbI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should not really include stuff from asm-generic directly, and the PC-style cmos rtc driver does this in order to reuse the mc146818 implementation of get_rtc_time/set_rtc_time rather than the architecture specific one for the architecture it gets built for. To make it more obvious what is going on, this moves and renames the two functions into include/linux/mc146818rtc.h, which holds the other mc146818 specific code. Ideally it would be in a .c file, but that would require extra infrastructure as the functions are called by multiple drivers with conflicting dependencies. With this change, the asm-generic/rtc.h header also becomes much more generic, so it can be reused more easily across any architecture that still relies on the genrtc driver. The only caller of the internal __get_rtc_time/__set_rtc_time functions is in arch/alpha/kernel/rtc.c, and we just change those over to the new naming. Signed-off-by: Arnd Bergmann Acked-by: Alexandre Belloni --- arch/alpha/kernel/rtc.c | 6 +- arch/x86/include/asm/mc146818rtc.h | 1 - arch/x86/platform/efi/efi_64.c | 1 + arch/x86/platform/intel-mid/intel_mid_vrtc.c | 1 + drivers/rtc/rtc-cmos.c | 12 +- include/asm-generic/rtc.h | 206 +-------------------------- include/linux/mc146818rtc.h | 194 +++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 212 deletions(-) -- 2.7.0 diff --git a/arch/alpha/kernel/rtc.c b/arch/alpha/kernel/rtc.c index f535a3fd0f60..ceed68c7500b 100644 --- a/arch/alpha/kernel/rtc.c +++ b/arch/alpha/kernel/rtc.c @@ -15,8 +15,6 @@ #include #include -#include - #include "proto.h" @@ -81,7 +79,7 @@ init_rtc_epoch(void) static int alpha_rtc_read_time(struct device *dev, struct rtc_time *tm) { - __get_rtc_time(tm); + mc146818_get_time(tm); /* Adjust for non-default epochs. It's easier to depend on the generic __get_rtc_time and adjust the epoch here than create @@ -112,7 +110,7 @@ alpha_rtc_set_time(struct device *dev, struct rtc_time *tm) tm = &xtm; } - return __set_rtc_time(tm); + return mc146818_set_time(tm); } static int diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h index 0f555cc31984..24acd9ba7837 100644 --- a/arch/x86/include/asm/mc146818rtc.h +++ b/arch/x86/include/asm/mc146818rtc.h @@ -6,7 +6,6 @@ #include #include -#include #ifndef RTC_PORT #define RTC_PORT(x) (0x70 + (x)) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 6e7242be1c87..663c282801f3 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/x86/platform/intel-mid/intel_mid_vrtc.c b/arch/x86/platform/intel-mid/intel_mid_vrtc.c index ee40fcb6e54d..58024862a7eb 100644 --- a/arch/x86/platform/intel-mid/intel_mid_vrtc.c +++ b/arch/x86/platform/intel-mid/intel_mid_vrtc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index fbe9c72438e1..cf8eb98382ce 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -43,7 +43,7 @@ #include /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ -#include +#include struct cmos_rtc { struct rtc_device *rtc; @@ -190,10 +190,10 @@ static inline void cmos_write_bank2(unsigned char val, unsigned char addr) static int cmos_read_time(struct device *dev, struct rtc_time *t) { /* REVISIT: if the clock has a "century" register, use - * that instead of the heuristic in get_rtc_time(). + * that instead of the heuristic in mc146818_get_time(). * That'll make Y3K compatility (year > 2070) easy! */ - get_rtc_time(t); + mc146818_get_time(t); return 0; } @@ -205,7 +205,7 @@ static int cmos_set_time(struct device *dev, struct rtc_time *t) * takes effect exactly 500ms after we write the register. * (Also queueing and other delays before we get this far.) */ - return set_rtc_time(t); + return mc146818_set_time(t); } static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) @@ -1142,14 +1142,14 @@ static __init void cmos_of_init(struct platform_device *pdev) if (val) CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT); - get_rtc_time(&time); + cmos_read_time(&pdev->dev, &time); ret = rtc_valid_tm(&time); if (ret) { struct rtc_time def_time = { .tm_year = 1, .tm_mday = 1, }; - set_rtc_time(&def_time); + cmos_set_time(&pdev->dev, &def_time); } } #else diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h index 4e3b6558331e..4fcff22cd707 100644 --- a/include/asm-generic/rtc.h +++ b/include/asm-generic/rtc.h @@ -12,12 +12,12 @@ #ifndef __ASM_RTC_H__ #define __ASM_RTC_H__ -#include #include -#include -#include -#ifdef CONFIG_ACPI -#include + +#ifndef get_rtc_time +#include +#define get_rtc_time mc146818_get_time +#define set_rtc_time mc146818_set_time #endif #define RTC_PIE 0x40 /* periodic interrupt enable */ @@ -31,202 +31,6 @@ #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ -/* - * Returns true if a clock update is in progress - */ -static inline unsigned char rtc_is_updating(void) -{ - unsigned char uip; - unsigned long flags; - - spin_lock_irqsave(&rtc_lock, flags); - uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP); - spin_unlock_irqrestore(&rtc_lock, flags); - return uip; -} - -static inline unsigned int __get_rtc_time(struct rtc_time *time) -{ - unsigned char ctrl; - unsigned long flags; - unsigned char century = 0; - -#ifdef CONFIG_MACH_DECSTATION - unsigned int real_year; -#endif - - /* - * read RTC once any update in progress is done. The update - * can take just over 2ms. We wait 20ms. There is no need to - * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. - * If you need to know *exactly* when a second has started, enable - * periodic update complete interrupts, (via ioctl) and then - * immediately read /dev/rtc which will block until you get the IRQ. - * Once the read clears, read the RTC time (again via ioctl). Easy. - */ - if (rtc_is_updating()) - mdelay(20); - - /* - * Only the values that we read from the RTC are set. We leave - * tm_wday, tm_yday and tm_isdst untouched. Even though the - * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated - * by the RTC when initially set to a non-zero value. - */ - spin_lock_irqsave(&rtc_lock, flags); - time->tm_sec = CMOS_READ(RTC_SECONDS); - time->tm_min = CMOS_READ(RTC_MINUTES); - time->tm_hour = CMOS_READ(RTC_HOURS); - time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH); - time->tm_mon = CMOS_READ(RTC_MONTH); - time->tm_year = CMOS_READ(RTC_YEAR); -#ifdef CONFIG_MACH_DECSTATION - real_year = CMOS_READ(RTC_DEC_YEAR); -#endif -#ifdef CONFIG_ACPI - if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && - acpi_gbl_FADT.century) - century = CMOS_READ(acpi_gbl_FADT.century); -#endif - ctrl = CMOS_READ(RTC_CONTROL); - spin_unlock_irqrestore(&rtc_lock, flags); - - if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) - { - time->tm_sec = bcd2bin(time->tm_sec); - time->tm_min = bcd2bin(time->tm_min); - time->tm_hour = bcd2bin(time->tm_hour); - time->tm_mday = bcd2bin(time->tm_mday); - time->tm_mon = bcd2bin(time->tm_mon); - time->tm_year = bcd2bin(time->tm_year); - century = bcd2bin(century); - } - -#ifdef CONFIG_MACH_DECSTATION - time->tm_year += real_year - 72; -#endif - - if (century) - time->tm_year += (century - 19) * 100; - - /* - * Account for differences between how the RTC uses the values - * and how they are defined in a struct rtc_time; - */ - if (time->tm_year <= 69) - time->tm_year += 100; - - time->tm_mon--; - - return RTC_24H; -} - -#ifndef get_rtc_time -#define get_rtc_time __get_rtc_time -#endif - -/* Set the current date and time in the real time clock. */ -static inline int __set_rtc_time(struct rtc_time *time) -{ - unsigned long flags; - unsigned char mon, day, hrs, min, sec; - unsigned char save_control, save_freq_select; - unsigned int yrs; -#ifdef CONFIG_MACH_DECSTATION - unsigned int real_yrs, leap_yr; -#endif - unsigned char century = 0; - - yrs = time->tm_year; - mon = time->tm_mon + 1; /* tm_mon starts at zero */ - day = time->tm_mday; - hrs = time->tm_hour; - min = time->tm_min; - sec = time->tm_sec; - - if (yrs > 255) /* They are unsigned */ - return -EINVAL; - - spin_lock_irqsave(&rtc_lock, flags); -#ifdef CONFIG_MACH_DECSTATION - real_yrs = yrs; - leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) || - !((yrs + 1900) % 400)); - yrs = 72; - - /* - * We want to keep the year set to 73 until March - * for non-leap years, so that Feb, 29th is handled - * correctly. - */ - if (!leap_yr && mon < 3) { - real_yrs--; - yrs = 73; - } -#endif - -#ifdef CONFIG_ACPI - if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && - acpi_gbl_FADT.century) { - century = (yrs + 1900) / 100; - yrs %= 100; - } -#endif - - /* These limits and adjustments are independent of - * whether the chip is in binary mode or not. - */ - if (yrs > 169) { - spin_unlock_irqrestore(&rtc_lock, flags); - return -EINVAL; - } - - if (yrs >= 100) - yrs -= 100; - - if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) - || RTC_ALWAYS_BCD) { - sec = bin2bcd(sec); - min = bin2bcd(min); - hrs = bin2bcd(hrs); - day = bin2bcd(day); - mon = bin2bcd(mon); - yrs = bin2bcd(yrs); - century = bin2bcd(century); - } - - save_control = CMOS_READ(RTC_CONTROL); - CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); - save_freq_select = CMOS_READ(RTC_FREQ_SELECT); - CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); - -#ifdef CONFIG_MACH_DECSTATION - CMOS_WRITE(real_yrs, RTC_DEC_YEAR); -#endif - CMOS_WRITE(yrs, RTC_YEAR); - CMOS_WRITE(mon, RTC_MONTH); - CMOS_WRITE(day, RTC_DAY_OF_MONTH); - CMOS_WRITE(hrs, RTC_HOURS); - CMOS_WRITE(min, RTC_MINUTES); - CMOS_WRITE(sec, RTC_SECONDS); -#ifdef CONFIG_ACPI - if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && - acpi_gbl_FADT.century) - CMOS_WRITE(century, acpi_gbl_FADT.century); -#endif - - CMOS_WRITE(save_control, RTC_CONTROL); - CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); - - spin_unlock_irqrestore(&rtc_lock, flags); - - return 0; -} - -#ifndef set_rtc_time -#define set_rtc_time __set_rtc_time -#endif - static inline unsigned int get_rtc_ss(void) { struct rtc_time h; diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h index 433e0c74d643..e9e346b37846 100644 --- a/include/linux/mc146818rtc.h +++ b/include/linux/mc146818rtc.h @@ -14,6 +14,12 @@ #include #include /* get the user-level API */ #include /* register access macros */ +#include +#include + +#ifdef CONFIG_ACPI +#include +#endif #ifdef __KERNEL__ #include /* spinlock_t */ @@ -120,4 +126,192 @@ struct cmos_rtc_board_info { #define RTC_IO_EXTENT_USED RTC_IO_EXTENT #endif /* ARCH_RTC_LOCATION */ +/* + * Returns true if a clock update is in progress + */ +static inline unsigned char mc146818_is_updating(void) +{ + unsigned char uip; + unsigned long flags; + + spin_lock_irqsave(&rtc_lock, flags); + uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP); + spin_unlock_irqrestore(&rtc_lock, flags); + return uip; +} + +static inline unsigned int mc146818_get_time(struct rtc_time *time) +{ + unsigned char ctrl; + unsigned long flags; + unsigned char century = 0; + +#ifdef CONFIG_MACH_DECSTATION + unsigned int real_year; +#endif + + /* + * read RTC once any update in progress is done. The update + * can take just over 2ms. We wait 20ms. There is no need to + * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. + * If you need to know *exactly* when a second has started, enable + * periodic update complete interrupts, (via ioctl) and then + * immediately read /dev/rtc which will block until you get the IRQ. + * Once the read clears, read the RTC time (again via ioctl). Easy. + */ + if (mc146818_is_updating()) + mdelay(20); + + /* + * Only the values that we read from the RTC are set. We leave + * tm_wday, tm_yday and tm_isdst untouched. Even though the + * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated + * by the RTC when initially set to a non-zero value. + */ + spin_lock_irqsave(&rtc_lock, flags); + time->tm_sec = CMOS_READ(RTC_SECONDS); + time->tm_min = CMOS_READ(RTC_MINUTES); + time->tm_hour = CMOS_READ(RTC_HOURS); + time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH); + time->tm_mon = CMOS_READ(RTC_MONTH); + time->tm_year = CMOS_READ(RTC_YEAR); +#ifdef CONFIG_MACH_DECSTATION + real_year = CMOS_READ(RTC_DEC_YEAR); +#endif +#ifdef CONFIG_ACPI + if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && + acpi_gbl_FADT.century) + century = CMOS_READ(acpi_gbl_FADT.century); +#endif + ctrl = CMOS_READ(RTC_CONTROL); + spin_unlock_irqrestore(&rtc_lock, flags); + + if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) + { + time->tm_sec = bcd2bin(time->tm_sec); + time->tm_min = bcd2bin(time->tm_min); + time->tm_hour = bcd2bin(time->tm_hour); + time->tm_mday = bcd2bin(time->tm_mday); + time->tm_mon = bcd2bin(time->tm_mon); + time->tm_year = bcd2bin(time->tm_year); + century = bcd2bin(century); + } + +#ifdef CONFIG_MACH_DECSTATION + time->tm_year += real_year - 72; +#endif + + if (century) + time->tm_year += (century - 19) * 100; + + /* + * Account for differences between how the RTC uses the values + * and how they are defined in a struct rtc_time; + */ + if (time->tm_year <= 69) + time->tm_year += 100; + + time->tm_mon--; + + return RTC_24H; +} + +/* Set the current date and time in the real time clock. */ +static inline int mc146818_set_time(struct rtc_time *time) +{ + unsigned long flags; + unsigned char mon, day, hrs, min, sec; + unsigned char save_control, save_freq_select; + unsigned int yrs; +#ifdef CONFIG_MACH_DECSTATION + unsigned int real_yrs, leap_yr; +#endif + unsigned char century = 0; + + yrs = time->tm_year; + mon = time->tm_mon + 1; /* tm_mon starts at zero */ + day = time->tm_mday; + hrs = time->tm_hour; + min = time->tm_min; + sec = time->tm_sec; + + if (yrs > 255) /* They are unsigned */ + return -EINVAL; + + spin_lock_irqsave(&rtc_lock, flags); +#ifdef CONFIG_MACH_DECSTATION + real_yrs = yrs; + leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) || + !((yrs + 1900) % 400)); + yrs = 72; + + /* + * We want to keep the year set to 73 until March + * for non-leap years, so that Feb, 29th is handled + * correctly. + */ + if (!leap_yr && mon < 3) { + real_yrs--; + yrs = 73; + } +#endif + +#ifdef CONFIG_ACPI + if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && + acpi_gbl_FADT.century) { + century = (yrs + 1900) / 100; + yrs %= 100; + } +#endif + + /* These limits and adjustments are independent of + * whether the chip is in binary mode or not. + */ + if (yrs > 169) { + spin_unlock_irqrestore(&rtc_lock, flags); + return -EINVAL; + } + + if (yrs >= 100) + yrs -= 100; + + if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) + || RTC_ALWAYS_BCD) { + sec = bin2bcd(sec); + min = bin2bcd(min); + hrs = bin2bcd(hrs); + day = bin2bcd(day); + mon = bin2bcd(mon); + yrs = bin2bcd(yrs); + century = bin2bcd(century); + } + + save_control = CMOS_READ(RTC_CONTROL); + CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); + save_freq_select = CMOS_READ(RTC_FREQ_SELECT); + CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); + +#ifdef CONFIG_MACH_DECSTATION + CMOS_WRITE(real_yrs, RTC_DEC_YEAR); +#endif + CMOS_WRITE(yrs, RTC_YEAR); + CMOS_WRITE(mon, RTC_MONTH); + CMOS_WRITE(day, RTC_DAY_OF_MONTH); + CMOS_WRITE(hrs, RTC_HOURS); + CMOS_WRITE(min, RTC_MINUTES); + CMOS_WRITE(sec, RTC_SECONDS); +#ifdef CONFIG_ACPI + if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && + acpi_gbl_FADT.century) + CMOS_WRITE(century, acpi_gbl_FADT.century); +#endif + + CMOS_WRITE(save_control, RTC_CONTROL); + CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); + + spin_unlock_irqrestore(&rtc_lock, flags); + + return 0; +} + #endif /* _MC146818RTC_H */ From patchwork Mon May 30 18:57:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102275 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1560314qge; Mon, 30 May 2016 12:16:11 -0700 (PDT) X-Received: by 10.66.1.135 with SMTP id 7mr49137491pam.106.1464635771470; Mon, 30 May 2016 12:16:11 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id su5si6472207pab.230.2016.05.30.12.16.11; Mon, 30 May 2016 12:16:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161916AbcE3TQH (ORCPT + 30 others); Mon, 30 May 2016 15:16:07 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:63792 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161631AbcE3TQA (ORCPT ); Mon, 30 May 2016 15:16:00 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MZDuG-1amc9J3myS-00KzgA; Mon, 30 May 2016 20:57:58 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 03/16] char/genrtc: x86: remove remnants of asm/rtc.h Date: Mon, 30 May 2016 20:57:51 +0200 Message-Id: <1464634684-1248135-4-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:UeyTAKDE/FG3Ux9naCi8rxsljrOVeHZiUemwJo2DqcIsc8lWLN2 kOpsoU+sxQBfkGDup7FEJFog/Ra5h2plV3PnMoMU2kCdR6nXYc1BHbOG+NK5vPfOYfhg+QX RIAKYVt3lvT4bFFmyVr9B3e7EL4ttBqmjM2raxhLCWviIx51bfhfWDwZh6Zr/NIwu7Q1dcK SeYWzBsChXn8MAZrl9k5Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:7fEGQ35PlUo=:6MiMlmnMtYwAFCeBN/ygw9 kpZqwRKd98A3YUxMXoPBQz6coUbCW142105X2iq8KkjIixD+G2fZqfA3nU7RjeKd5hLGlGooK uJ2UrLjy4W0A/xfUqroyWYIJhFU46hpz0gpA3+Q2oBO5N228OnCaH7a3US/djyY5jZe3tcPBH l/6zT4/HyBF6mrvTBv5IqTJOk3zQ9I6QbN+xfeAnUqV9fy8uevwMy27sUwPCLvkAyH6XJK9kU bVD5SMjBenmzr4YG2PA3++g7bkf8g5CxfOug2k3+DyH9b8muv+HSYG5kSSlr4v/QBrRKX9Brf Y9TcCgjnX+vif92kjKpZUyQ4pSgUvCxGI01IIzaxdXvMNEVKCXQGYH8jxBvBG+RVt72SgjsXu zVgzOI3jHd8UMSwv1zkRLuxVAAMlJa8tEQMFaogvqImw8kro7va4XPVJGGJzBURIxPhIGDtP0 SZtZ2cfSXaBEeyu0uWPceD4Md4FnRUiRT1g716KkVNzeH8QgXA4MLi2QWputJgzpCJOow84ha ecJCDbIzTrdjTJlE+GtDX//8PwrF7H1GLHTKSHdL8BtlEvsF2n6RpyhT7OQm2PwYSH3ksWkEy 9gi7iYA/9DG7DLWoy+JVqjZJ5/HQse9mGF/z8l6oYtBkhnbNRx4wiga5gkBifLOQupC9kxJSD 3fZRf7fjHb+hpunYvhmc3f0Omb5mHcXqfWPBzKSd1EqO83o6Xag/OjtVdyMiz35wA+OU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 3195ef59cb42 ("x86: Do full rtc synchronization with ntp") had the side-effect of unconditionally enabling the RTC_LIB symbol on x86, which in turn disables the selection of the CONFIG_RTC and CONFIG_GEN_RTC drivers that contain a two older implementations of the CONFIG_RTC_DRV_CMOS driver. This removes x86 from the list for genrtc, and changes all references to the asm/rtc.h header to instead point to the interfaces from linux/mc146818rtc.h. Signed-off-by: Arnd Bergmann --- arch/x86/include/asm/rtc.h | 1 - arch/x86/kernel/hpet.c | 3 +-- arch/x86/kernel/rtc.c | 3 +-- arch/x86/platform/efi/efi.c | 1 - drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/base/power/trace.c | 6 +++--- drivers/char/Kconfig | 2 +- drivers/rtc/rtc-mrst.c | 2 +- 8 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 arch/x86/include/asm/rtc.h -- 2.7.0 diff --git a/arch/x86/include/asm/rtc.h b/arch/x86/include/asm/rtc.h deleted file mode 100644 index f71c3b0ed360..000000000000 --- a/arch/x86/include/asm/rtc.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index f112af7aa62e..357900aad62c 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -1020,7 +1020,6 @@ void hpet_disable(void) */ #include #include -#include #define DEFAULT_RTC_INT_FREQ 64 #define DEFAULT_RTC_SHIFT 6 @@ -1244,7 +1243,7 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) memset(&curr_time, 0, sizeof(struct rtc_time)); if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) - get_rtc_time(&curr_time); + mc146818_set_time(&curr_time); if (hpet_rtc_flags & RTC_UIE && curr_time.tm_sec != hpet_prev_update_sec) { diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index eceaa082ec3f..79c6311cd912 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #ifdef CONFIG_X86_32 @@ -47,7 +46,7 @@ int mach_set_rtc_mmss(const struct timespec *now) rtc_time_to_tm(nowtime, &tm); if (!rtc_valid_tm(&tm)) { - retval = set_rtc_time(&tm); + retval = mc146818_set_time(&tm); if (retval) printk(KERN_ERR "%s: RTC write failed with error %d\n", __func__, retval); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f93545e7dc54..56400d03409f 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -51,7 +51,6 @@ #include #include #include -#include #include static struct efi efi_phys __initdata; diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c index 81dc75033f15..0980a133916f 100644 --- a/drivers/acpi/acpi_cmos_rtc.c +++ b/drivers/acpi/acpi_cmos_rtc.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include "internal.h" diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c index a6975795e7f3..efec10b49d59 100644 --- a/drivers/base/power/trace.c +++ b/drivers/base/power/trace.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include "power.h" @@ -103,7 +103,7 @@ static int set_magic_time(unsigned int user, unsigned int file, unsigned int dev n /= 24; time.tm_min = (n % 20) * 3; n /= 20; - set_rtc_time(&time); + mc146818_set_time(&time); return n ? -1 : 0; } @@ -112,7 +112,7 @@ static unsigned int read_magic_time(void) struct rtc_time time; unsigned int val; - get_rtc_time(&time); + mc146818_get_time(&time); pr_info("RTC time: %2d:%02d:%02d, date: %02d/%02d/%02d\n", time.tm_hour, time.tm_min, time.tm_sec, time.tm_mon + 1, time.tm_mday, time.tm_year % 100); diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 601f64fcc890..31b5861649ee 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -328,7 +328,7 @@ config JS_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on ALPHA || M68K || MN10300 || PARISC || PPC || X86 + depends on ALPHA || M68K || MN10300 || PARISC || PPC ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 0094d9bdd1e6..fe840c0edfef 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c @@ -32,11 +32,11 @@ #include #include #include +#include #include #include #include -#include #include #include #include From patchwork Mon May 30 18:57:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102280 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1554217qge; Mon, 30 May 2016 12:01:53 -0700 (PDT) X-Received: by 10.98.71.135 with SMTP id p7mr17357126pfi.165.1464634913167; Mon, 30 May 2016 12:01:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v80si38047361pfj.199.2016.05.30.12.01.52; Mon, 30 May 2016 12:01:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162064AbcE3TBE (ORCPT + 30 others); Mon, 30 May 2016 15:01:04 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:59219 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161879AbcE3S61 (ORCPT ); Mon, 30 May 2016 14:58:27 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MSa4i-1axel81ydA-00RcSQ; Mon, 30 May 2016 20:57:58 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 04/16] rtc: sh: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:57:52 +0200 Message-Id: <1464634684-1248135-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:uVTqh3HX7XO1GXHsHwf+L8Hy8iEKa56O5vgNcF1lBoE+Jt/jfab +ZKhioDvxQFESaH0HAQ9dJeh++0GQlzVtxut3v1P0CNuKzj7vtcjkJdiCy8hum3y9R8n/Hu t7aFJLtGPyCbQJA7Y1oKgQ2L+sg5NKDmeeaEMBh77BNF0RpGw2AMdtsyg1vPGJUMSuwBzXP PDPgwQXTYhzufSqVxQz3A== X-UI-Out-Filterresults: notjunk:1; V01:K0:FJ7KZKNcXt4=:bemJvfnJse1mPGm9r2UkAB j1sHYDNBtRFclAwLLbsVwciDlIGdIsaV73JF3SUkzoibAv2T+AMrl6GDquzQcaM/CDcuzSQFY I5ZGQLrJJtFf7oHox35AGD/R2pY1xauCYS7mQhdg+c556StiwcGK+NwfYgWG2RHzkOCoCmcnO LTHhTNQdaG3qbEhLGW3XB7n4qg+HXUQyZCFWxpagJt6Au6cQge7VHiAljcag8KSkEm84HVov1 wovSzwnl7WbyIh+u81R7+iEJGZgMi8xsc6Ub2Ckzupp9ZlJYZHZUYROyl90bdwBSf9YkzN7Oy 8cahDSAXFbyBCQ6m4RAxfqsfvhja3tR9/JQcwWEZ6NFrPMkTLmAN1ArhGTDLpFlW6+hWTHonL uPKwIXccjZ3CydxmMI/yxLVlTQQSIgQBr2y+FqbdB4U0cE0QsNe2/U9iEb+W/QMlAx9ftMy4Q iz6u3cmBmPrbhMAIFP2hBGf1e6w1ZGjiUCpvgrvwQ+TSwNlSnXQOkfJ/QRERAe6QdoEF34i7t MWH3wl8ivxexFSUsltqxGF1IBBdpcyV5jcJya24hZRYZCsezJas8nrBeEqJPtou/p1ZXsK914 hLan8yBNqzn3f4goohx4N+N2nFMjaes6CnGu7ik9K2iMhjcJFYYxUXVLn6QhAfduRq93rgwgr dTkDCBgyDzuYjHE4bXB1GeGFdAkChMY7BbSk8oU1IBUW6gR1tQ2UnXl6mijPlG9rnIKI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and on sh, that goes through another indirection using the rtc_sh_get_time/rtc_sh_set_time functions. This changes the sh rtc-generic device to provide its rtc_class_ops directly, skipping one of the abstraction levels. Signed-off-by: Arnd Bergmann --- arch/sh/include/asm/rtc.h | 11 ----------- arch/sh/kernel/time.c | 33 ++++++++++++++++++++------------- drivers/rtc/rtc-generic.c | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) -- 2.7.0 diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index 52b0c2dba979..f7b010d48af7 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -6,17 +6,6 @@ extern void (*board_time_init)(void); extern void (*rtc_sh_get_time)(struct timespec *); extern int (*rtc_sh_set_time)(const time_t); -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -struct rtc_time; -unsigned int get_rtc_time(struct rtc_time *); -int set_rtc_time(struct rtc_time *); - #define RTC_CAP_4_DIGIT_YEAR (1 << 0) struct sh_rtc_platform_info { diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index d6d0a986c6e9..a4a7862b489a 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -50,27 +50,31 @@ int update_persistent_clock(struct timespec now) } #endif -unsigned int get_rtc_time(struct rtc_time *tm) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) { - if (rtc_sh_get_time != null_rtc_get_time) { - struct timespec tv; + struct timespec tv; - rtc_sh_get_time(&tv); - rtc_time_to_tm(tv.tv_sec, tm); - } - - return RTC_24H; + rtc_sh_get_time(&tv); + rtc_time_to_tm(tv.tv_sec, tm); + return 0; } -EXPORT_SYMBOL(get_rtc_time); -int set_rtc_time(struct rtc_time *tm) +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) { unsigned long secs; rtc_tm_to_time(tm, &secs); - return rtc_sh_set_time(secs); + if ((rtc_sh_set_time == null_rtc_set_time) || + (rtc_sh_set_time(secs) < 0)) + return -EOPNOTSUPP; + + return 0; } -EXPORT_SYMBOL(set_rtc_time); + +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_generic_init(void) { @@ -79,7 +83,10 @@ static int __init rtc_generic_init(void) if (rtc_sh_get_time == null_rtc_get_time) return -ENODEV; - 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); } diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index d726c6aa96a8..3958e87a05fa 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -10,7 +10,7 @@ #include #if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ - defined(CONFIG_PPC) || defined(CONFIG_SUPERH32) + defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm) From patchwork Mon May 30 18:57:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102281 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1554036qge; Mon, 30 May 2016 12:01:29 -0700 (PDT) X-Received: by 10.67.21.177 with SMTP id hl17mr48435749pad.39.1464634889805; Mon, 30 May 2016 12:01:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i185si20713273pfb.206.2016.05.30.12.01.29; Mon, 30 May 2016 12:01:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162086AbcE3TBJ (ORCPT + 30 others); Mon, 30 May 2016 15:01:09 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54814 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161878AbcE3S61 (ORCPT ); Mon, 30 May 2016 14:58:27 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MORLZ-1bB2kU04rl-005m55; Mon, 30 May 2016 20:57:59 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 05/16] char/genrtc: remove alpha support Date: Mon, 30 May 2016 20:57:53 +0200 Message-Id: <1464634684-1248135-6-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:FA5lK/Vru53r+6fNNVlwDLCxGSe1tN8F1/Tu+C8ttHBOeQQXVnm iQWrn0GAQE2tAuPv6kTMgHfY6Nqy6d0UJUIgvCR54Y/+mcHd7/aW4PPLX9mxNUU8R0CCaw4 0v54ycGhzHZ4PSOwSS6rzS6a2qUvtUJskDhvMjmGZMs+5RoF+isuBKIFHIMkqX2xsY5euL3 WOikTjKpVl5Q7M/UzMu0g== X-UI-Out-Filterresults: notjunk:1; V01:K0:NgN4yUKzOJM=:WxGeDUmemm6+DLCdzWdIRL +FJr6qh0mYUdAFi51X6ixKBkShKsee15rMb8mZHpHOYmt98BW+c5kk7sjzkdqeIaabIqZI5QS 3lXlfdVaDgC/9ufFOKMZxhg0p5QTNO+OfX//r8bP6luSbkdls8wPRwGO38kF/TT5ITvFS+SQn 5l7Rw0+UcU1dsy/ObckQ31O88BURZnpBE1RNffC4nnqdC6xo41ddT2ADmKvr8xQQ3mNjZoRML 40Xb5B+fumY9o9Flr7LipN1aKniN4Qq/c5DgWLzuqfpPs/fZQFC6NGAcdeNUt7rQG6vAc/zkA /mUXn04cY8da+SuXciY3CRSo89DIhF64aDfBFmrT2qLlb2Sk9Ll7Ay32VCCrJD/QLdyGGX3rQ /yxuDG7h1BuWd9zieDgRW53KJ/E/F5ANz5WRob62OS8bu2Qyqs2Tw6MTaeznM8H9mtN4sXWgZ cPMkMNQAxbi/uSkWSNwRPhVLeI5R/uTsSsCE4qOWI5SoInz+iMTvBQ1xWB3+7r5eMMQ7dbUZq zUunDPBo9Vz+KRB5ZUHQ//k4mF/bp9u+Fh8DLRPmzdpwApsEnUN0z7XKtet/FocAybYybnPZW Tx68Z0LPrIt/oXy8vh0dJvZSXI3R1P0Y4930fEnZmMtX00OtDDDURoA0maD9qlB64wbEElaJ8 g2P3vLcTLb9EpfL0Ll9UPj+bSLLjEIJ7YjT5wIkdmDVm78fq7zDNx3b5n+zHFVLGJl2g= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The genrtc driver serves no purpose on Alpha because it drives the same hardware as the original rtc.c driver, and the newer rtc-generic.c or rtc-cmos.c drivers on architectures that use the asm-generic/rtc.h header. The defconfig uses CONFIG_RTC=y, so this driver is not used by default. At one point it was used to abstract a quirk for the "Marvel" platform, but it does not do this any more after the code was moved into yet another driver in arch/alpha/kernel/rtc.c. Signed-off-by: Arnd Bergmann --- arch/alpha/include/asm/rtc.h | 1 - arch/alpha/kernel/core_marvel.c | 1 - drivers/char/Kconfig | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 arch/alpha/include/asm/rtc.h -- 2.7.0 diff --git a/arch/alpha/include/asm/rtc.h b/arch/alpha/include/asm/rtc.h deleted file mode 100644 index f71c3b0ed360..000000000000 --- a/arch/alpha/include/asm/rtc.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c index 53dd2f1a53aa..d5f0580746a5 100644 --- a/arch/alpha/kernel/core_marvel.c +++ b/arch/alpha/kernel/core_marvel.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "proto.h" diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 31b5861649ee..e3f2f3e293e5 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -328,7 +328,7 @@ config JS_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on ALPHA || M68K || MN10300 || PARISC || PPC + depends on M68K || MN10300 || PARISC || PPC ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you From patchwork Mon May 30 18:57:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102277 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1554586qge; Mon, 30 May 2016 12:02:37 -0700 (PDT) X-Received: by 10.98.97.67 with SMTP id v64mr48918453pfb.149.1464634957552; Mon, 30 May 2016 12:02:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26si38047901pfb.194.2016.05.30.12.02.37; Mon, 30 May 2016 12:02:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161933AbcE3TCe (ORCPT + 30 others); Mon, 30 May 2016 15:02:34 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53157 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161870AbcE3S60 (ORCPT ); Mon, 30 May 2016 14:58:26 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LxwDU-1bb8N92Cqy-015Kvi; Mon, 30 May 2016 20:57:59 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 06/16] char/genrtc: remove mn10300 support Date: Mon, 30 May 2016 20:57:54 +0200 Message-Id: <1464634684-1248135-7-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:CcVavVpLaF2wfezVOp2TS6EzaJeih6848b2VLgOmKryEwQxT8er CVMlbXNyde8gPZDmXNDuDC0cgvRR8+N3cp6MKVxxg5FKnXmp91L59HWSas/zfFsUUDQjD9F xaEe9ZOnfZpnRb0tcDsRvHOd9GdJmV08rHD/y19hhHCrWkpQEF/4y2fhFGZvT8dwaufuWeY zT07LbhkpMyV4f8DBBs0w== X-UI-Out-Filterresults: notjunk:1; V01:K0:vQgFTRKkg3E=:9NgRm2+3HYJrFm8QmyjOVZ oLStmGkX/Xc1Tn8A/rdgpCsREtRgG8Z+0eSSUOh+nDzLETYUDKlp9ynrVAeh0r81Ex+vDAmkk gkLXvLOylWlfDlrmjpKyD1KkjUVKMKxHnTUgUyYfthmRLAis/cz3xGb6m7A8r4EIL9URdr4Hf iOmyTcTi8f+ArZMQI3sbc/rREfvV5QpJeK8I9VWBaGi8zcA38kJiDgXw2e9ViZN0epYW5TDoj rcV4oHJi0ZKOvmXnyGH2V03UIU31vLTA2MSpLQoKkgbfWkutMz3kpH+pfHJN1EdnY0Xr8+wv1 igziDGdxN3y6Wg92R3U9hqILlSHjf9pIg1lpkJ9CtauUClsik23uhmuwHBgBrEkXRU49Scm+j UPdvnAdEhjkDExAK8iReKl6h7sIRwYAZfZbCl+5NDxZ6sKTyQlI8PHi3QAiPGCQo81clF2tnR U7PqSpkN/pqA8QooQjOszLV7Rz/dxkNWLKgvwR62OpG65/JfPBpXZZhCVervwbVXX8OEIbKOe P1ZTXjtvvtXxKhvn9apt2uQZuKM7pm3NmVsbatpJMbbhOrXPSJEJHVhRqCcDeo2j6ZXSQt/0+ DRiM20zdA0m69yHMq91RVc1sDTF3Vl5Ol3dHj4ELlHgGH2A8HcKrU4p9mJcoxnopFG9rmPq1e BfI26mZXsFP5jln9F2paYLxZr92lDpb7QMcK45WQFcVcdFUf9OelhOga4/qxmC4uwBdo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The genrtc driver serves no purpose on mn10300 because it drives the same hardware as the original rtc.c driver, and the newer rtc-generic.c or rtc-cmos.c drivers on architectures that use the asm-generic/rtc.h header. I assume it was initially only added for completeness when the mn10300 port was done, but the older rtc.c driver was always used instead. We can also stop include asm-generic/rtc.h now, because we just call mc146818_set_time() directly. It would be nice to change the architecture to use the rtc-cmos driver next, and remove support for the old rtc driver as well. Signed-off-by: Arnd Bergmann --- arch/mn10300/include/asm/rtc.h | 2 -- arch/mn10300/kernel/rtc.c | 2 +- arch/mn10300/proc-mn103e010/proc-init.c | 1 + arch/mn10300/proc-mn2ws0050/proc-init.c | 1 + drivers/char/Kconfig | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) -- 2.7.0 diff --git a/arch/mn10300/include/asm/rtc.h b/arch/mn10300/include/asm/rtc.h index 6c14bb1d0d9b..07dc87656197 100644 --- a/arch/mn10300/include/asm/rtc.h +++ b/arch/mn10300/include/asm/rtc.h @@ -25,6 +25,4 @@ static inline void calibrate_clock(void) #endif /* !CONFIG_MN10300_RTC */ -#include - #endif /* _ASM_RTC_H */ diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c index 48d7058b3295..77e0be4d92ea 100644 --- a/arch/mn10300/kernel/rtc.c +++ b/arch/mn10300/kernel/rtc.c @@ -27,7 +27,7 @@ void read_persistent_clock(struct timespec *ts) { struct rtc_time tm; - get_rtc_time(&tm); + mc146818_set_time(&tm); ts->tv_nsec = 0; ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, diff --git a/arch/mn10300/proc-mn103e010/proc-init.c b/arch/mn10300/proc-mn103e010/proc-init.c index 27b97980dca4..d4dcb0c56b35 100644 --- a/arch/mn10300/proc-mn103e010/proc-init.c +++ b/arch/mn10300/proc-mn103e010/proc-init.c @@ -9,6 +9,7 @@ * 2 of the Licence, or (at your option) any later version. */ #include +#include #include #include #include diff --git a/arch/mn10300/proc-mn2ws0050/proc-init.c b/arch/mn10300/proc-mn2ws0050/proc-init.c index ee6d03dbc8d8..950cc8dbb284 100644 --- a/arch/mn10300/proc-mn2ws0050/proc-init.c +++ b/arch/mn10300/proc-mn2ws0050/proc-init.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index e3f2f3e293e5..1d9e3063373b 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -328,7 +328,7 @@ config JS_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on M68K || MN10300 || PARISC || PPC + depends on M68K || PARISC || PPC ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you From patchwork Mon May 30 18:57:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102276 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1555069qge; Mon, 30 May 2016 12:03:34 -0700 (PDT) X-Received: by 10.66.132.103 with SMTP id ot7mr49761589pab.60.1464635014829; Mon, 30 May 2016 12:03:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e189si38067025pfa.193.2016.05.30.12.03.34; Mon, 30 May 2016 12:03:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161976AbcE3TDb (ORCPT + 30 others); Mon, 30 May 2016 15:03:31 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:54942 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161631AbcE3TD1 (ORCPT ); Mon, 30 May 2016 15:03:27 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M89Tt-1bTg890IhV-00vgHP; Mon, 30 May 2016 20:58:00 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 07/16] rtc: parisc: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:57:55 +0200 Message-Id: <1464634684-1248135-8-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:yodo/1pk8vzwHj4lmImtc35ZAFUmXsEYszlPovJFu+7YnpdIoGw RRs2Jab2wggrGMhbO+FYJ/L7P3XJgKI41OTcmsxhdhYEYLQ9erqAq1VB/7f64m2ztK1tTbZ 7jGN4UoUQF1UrOvtGGlgM908d6A5k+LGGyzuUhi8I4wcuWT6nBQuao75RX+AOmlI1KZTJT0 gRsmo4my8J/b6AJCAbR7g== X-UI-Out-Filterresults: notjunk:1; V01:K0:1sdl2ElRgMw=:xB81oP9/O44T/GTzHTsAaW cISQPIhy8S3Ojt+lcLfkgKc0WtsOa9TgG6AwPPnFUasDkWSonFuWfnMjMkprYaSjGsyWrMwzs MuKD1GarmPI0hekTLLpucpeGyr3sIR0SdAQ/fcaa76P1rUw3aCBK9Tx0KhfSPZHMlfgLqqVEB Lt2mjGylUmzGTtCgFMEpgPVQJ+tdtBXxzUgTqG1Iiu9oNv9J4jYBhk+XbxtasjF3Imnj0LTxf SQnFNQEQoxA7czM7RmMU1JJiDyeYOylLx6z6ZKamBEIIyUuoHl2VlUYI9WzI1nxrMr/U6FRnt ALStX1UKfM0kDJyvV7ClfGB2JAyK7BmVpWnGA6R6Oh2XYdaXUr4hG4cwEu3gKCDiNK2WOgsy1 aDG2pUK+1Rv80F1sza/BGlpmjVwMQzXGSE9DxRR2PgTYR4SMhuuDH343CkVxbEasmJ463VTGO kOztmPzc6BgynbXcI/cOkajs7OtALVu1lAI9XVAKjALt8hyKaoECIRwMmNwkPIUfnJEY52oqK cSHw66aQtfBQDRj0xraMdVcmnWFNRv/8lJGojPM27lLZOSq4wX1s1TtZuu6XeK1ro3vUZpOv/ YI+VImbKaX+H8Wpr6ZEFClUtut8cbXupP9PBb0MjgzinV4If9ai/69UseUeEhfCyCtbxaZH7Y z8GCg2eRVosl5jp72RFvkvyLDn0FGeLqJ18T5GgASjxA+NqftsTSvg9dqzFc9KlFo1aQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/parisc/kernel/time.c | 36 +++++++++++++++++++++++++++++++++++- drivers/rtc/rtc-generic.c | 3 +-- 2 files changed, 36 insertions(+), 3 deletions(-) -- 2.7.0 diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c index 58dd6801f5be..744878789752 100644 --- a/arch/parisc/kernel/time.c +++ b/arch/parisc/kernel/time.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include #include @@ -248,14 +249,47 @@ void __init start_cpu_itimer(void) per_cpu(cpu_data, cpu).it_value = next_tick; } +#if IS_ENABLED(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) { diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 3958e87a05fa..92b5e02a3750 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,8 +9,7 @@ #include #include -#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ - defined(CONFIG_PPC) +#if defined(CONFIG_M68K) || defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm) From patchwork Mon May 30 18:57:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102289 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553005qge; Mon, 30 May 2016 11:58:48 -0700 (PDT) X-Received: by 10.66.65.133 with SMTP id x5mr49462055pas.108.1464634728175; Mon, 30 May 2016 11:58:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xr1si52028720pab.95.2016.05.30.11.58.47; Mon, 30 May 2016 11:58:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161957AbcE3S6h (ORCPT + 30 others); Mon, 30 May 2016 14:58:37 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53100 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161928AbcE3S6c (ORCPT ); Mon, 30 May 2016 14:58:32 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Lucpk-1bXozY2Wh6-00zrHS; Mon, 30 May 2016 20:58:00 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 08/16] char/genrtc: remove parisc support Date: Mon, 30 May 2016 20:57:56 +0200 Message-Id: <1464634684-1248135-9-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:AL5xwo4nCQeYS44ibIFy8ueg5s1VBrkTzrMNpONlcyIUMpN30K+ c501o5i2sVnXV9j2YLRsNHO/0qp+LGuWZ7lfqGE3PkwfdJV7Rr35NLu5W3KOiXBpAg5o88O iQnyxeKsfxV4j5/Z7txp6h7R7FIfp6r3wiO9SiMBZ95sTWvavyx0cceYUnWYkGl1VL1oFsA h83NjeUOFt0W8e2CZY/kA== X-UI-Out-Filterresults: notjunk:1; V01:K0:e7u2vS/ZK48=:D8uwkaOQqxjg1WWyseCPOl UHylB7vGH9cen56Vcjs7zDDg8Fwp0LIjTwrtxrFcNuuDdDrzFm+CNz8SltsP1YQYKWQfEPvg/ 6p9vEwKjwxM6i+h7IcdSBiPl54j4+paYx+ynYMvDT8W8L3O02xsP27+y/RTjUoROUmfmao0n0 70n1SAHo+gU3cmqWiP0w2fTyDJvC294sjelghtP59vYsYb3ulazcmOx02AcmQQu1cyaa9bLHS osa6H0/MLUtT4Wlu+zchk+CDjn0ZUgB1rxytADRoAKXO92Scdd2oCKFYugjrq1SEkoOWfs66D U/z9vLSRThZYt1GFqj4+UcCmkulyCfyzKMQBeRHGyO8PFbuLt8nAcIMgmjm+s01FOsI9rjMDk 0rxogYQ4sbL0nQGciBj4uV18hX9W371Ks+0Jqx/5MBquJu4hviXS00ruvu8GngHt15QCautci M1ej9mVZ4/erNlvFjI1yqZ/QSVmhc+2OZiES/VlCFjTEekilYvoOo+s5AoXXd06XM6iRlR6SR fF1ZYi7Tq2m2+VNVsqpdIvE8ucE7r1hdbcPfFaD5Pwrne5qSURZOkxDopXvVo77ww6L5EB8Cc qmR3jPAH7DoIcHz1N8M19tJEQMvYYHmt4oUqTdTLeOPfPxeCsJw67KLfquiDh3MA7mnvS5e0F qmKj5OYgK3EnjKu0gWZMvI76Eqv8/XjkdnewL+/aub+UddJSs/0t0aMUhjxUV+KLpJsU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This architecture selects RTC_CLASS unconditionally, so the GEN_RTC has not worked here for a long time. Now we can remove both the asm/rtc.h header and the Kconfig dependency for CONFIG_GEN_RTC. Signed-off-by: Arnd Bergmann --- arch/parisc/include/asm/rtc.h | 131 ------------------------------------------ drivers/char/Kconfig | 2 +- 2 files changed, 1 insertion(+), 132 deletions(-) delete mode 100644 arch/parisc/include/asm/rtc.h -- 2.7.0 diff --git a/arch/parisc/include/asm/rtc.h b/arch/parisc/include/asm/rtc.h deleted file mode 100644 index 099d641a42c2..000000000000 --- a/arch/parisc/include/asm/rtc.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * include/asm-parisc/rtc.h - * - * Copyright 2002 Randolph CHung - * - * Based on: include/asm-ppc/rtc.h and the genrtc driver in the - * 2.4 parisc linux tree - */ - -#ifndef __ASM_RTC_H__ -#define __ASM_RTC_H__ - -#ifdef __KERNEL__ - -#include - -#include - -#define SECS_PER_HOUR (60 * 60) -#define SECS_PER_DAY (SECS_PER_HOUR * 24) - - -#define RTC_PIE 0x40 /* periodic interrupt enable */ -#define RTC_AIE 0x20 /* alarm interrupt enable */ -#define RTC_UIE 0x10 /* update-finished interrupt enable */ - -#define RTC_BATT_BAD 0x100 /* battery bad */ - -/* some dummy definitions */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -# define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) - -/* How many days come before each month (0-12). */ -static const unsigned short int __mon_yday[2][13] = -{ - /* Normal years. */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, - /* Leap years. */ - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } -}; - -static inline unsigned int get_rtc_time(struct rtc_time *wtime) -{ - struct pdc_tod tod_data; - long int days, rem, y; - const unsigned short int *ip; - - memset(wtime, 0, sizeof(*wtime)); - if (pdc_tod_read(&tod_data) < 0) - return RTC_24H | RTC_BATT_BAD; - - // most of the remainder of this function is: -// Copyright (C) 1991, 1993, 1997, 1998 Free Software Foundation, Inc. -// This was originally a part of the GNU C Library. -// It is distributed under the GPL, and was swiped from offtime.c - - - days = tod_data.tod_sec / SECS_PER_DAY; - rem = tod_data.tod_sec % SECS_PER_DAY; - - wtime->tm_hour = rem / SECS_PER_HOUR; - rem %= SECS_PER_HOUR; - wtime->tm_min = rem / 60; - wtime->tm_sec = rem % 60; - - y = 1970; - -#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0)) -#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) - - while (days < 0 || days >= (__isleap (y) ? 366 : 365)) - { - /* Guess a corrected year, assuming 365 days per year. */ - long int yg = y + days / 365 - (days % 365 < 0); - - /* Adjust DAYS and Y to match the guessed year. */ - days -= ((yg - y) * 365 - + LEAPS_THRU_END_OF (yg - 1) - - LEAPS_THRU_END_OF (y - 1)); - y = yg; - } - wtime->tm_year = y - 1900; - - ip = __mon_yday[__isleap(y)]; - for (y = 11; days < (long int) ip[y]; --y) - continue; - days -= ip[y]; - wtime->tm_mon = y; - wtime->tm_mday = days + 1; - - return RTC_24H; -} - -static int set_rtc_time(struct rtc_time *wtime) -{ - u_int32_t secs; - - secs = mktime(wtime->tm_year + 1900, wtime->tm_mon + 1, wtime->tm_mday, - wtime->tm_hour, wtime->tm_min, wtime->tm_sec); - - if(pdc_tod_set(secs, 0) < 0) - return -1; - else - return 0; - -} - -static inline unsigned int get_rtc_ss(void) -{ - struct rtc_time h; - - get_rtc_time(&h); - return h.tm_sec; -} - -static inline int get_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} -static inline int set_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} - -#endif /* __KERNEL__ */ -#endif /* __ASM_RTC_H__ */ diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 1d9e3063373b..074bc394e31b 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -328,7 +328,7 @@ config JS_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on M68K || PARISC || PPC + depends on M68K || PPC ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you From patchwork Mon May 30 18:57:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102279 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1554332qge; Mon, 30 May 2016 12:02:05 -0700 (PDT) X-Received: by 10.66.152.111 with SMTP id ux15mr46456561pab.43.1464634925328; Mon, 30 May 2016 12:02:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s207si38057787pfs.76.2016.05.30.12.02.05; Mon, 30 May 2016 12:02:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162110AbcE3TB7 (ORCPT + 30 others); Mon, 30 May 2016 15:01:59 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:61742 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161867AbcE3S60 (ORCPT ); Mon, 30 May 2016 14:58:26 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MIw6j-1b5WRU0k5R-002VMF; Mon, 30 May 2016 20:58:01 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 09/16] rtc: m68k: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:57:57 +0200 Message-Id: <1464634684-1248135-10-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:GpdV9CX3et8CgEEilZQzNTSmbFteTLkmNnYGPio9BG6FvbFr8L4 ORlgiVpNxl9BK/GoKVtBhRlaHHSglRQuAO6do/ICzdUda4mHvcIodmQYwA6PziVEMmyk3LA nFLwwKd9SY5GQIKi6pYuHIAap3N8GICy+FbrZFh/fCE/XfwuJgZUbMOyk65CVg7gGriUjIw R2xYzJNMHvVrV7RYtSCeA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Go4laOzoi2k=:Plhf3hhn3VHlwQQq3Kz8I1 qdYgA29Tzh3tkEnDrMTgFI0fOWvaBclGR9Vn9k83PURosx5hrD+0R+2e+kG3VSQIpxbcsqRE2 pqAjx9hKs+YvVL4mcdA4nqmWgA30h6K0lP4NxBLGDlca3klTPJvGIeODG69witNUdfzcoufr4 6LNxa1mIAVnRjKkHS6DYY/N1IaAa/bBlk90sWGtOz0cgxsDukTzVgNx1b8+qIzIuolsdQPS2H Li9Rb9IDYel8/7yDyjKvK/oRYZeAIQTmj8twzHt8AZ3r295KYZnhah59NTJZZkzz526giVfHm dFOYXQWqw0r3mdTVdfueiW86+RRieXB59G/lLbc1l6wntUqqudKDQpF8Zxyr7TPYqWOwIfTub cJffAAV74PiBigATWHF5yjDT/K0ISczK45air+AMBcoj92gRuAAIfaHdWVRz8FuXc47EHZ2uz lVdsSbiZo5pFpeKW7NnnOBM2LJZVciiySS1T4NGgTIYDp2HXQ00TfoYvC7Bqrx//rASs5O6dw hfEZ0yGeKjh/J4Z6GrKUHIaiCba/RSQY2Vwuti4QL6HwT26y//Y3foJnGqsp+uw7RnKDgBsKJ s57LGK3CiKXR614w2Onhs9i3Q+8Yow02xs4AXvrvq8dGG+plAOJY1UGG8G38fLB2Tj/InLJTo 6ows7LLUdIvRMKJsR5wi0qOxnsE1u+W4ACds7P8G8sFfxaBrh/H0FWBNmY10i/HnZpik= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and m68k has another abstraction on top, which is a bit silly. This changes the m68k rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/m68k/kernel/time.c | 23 +++++++++++++++++++++-- drivers/rtc/rtc-generic.c | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) -- 2.7.0 diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 3857737e3958..bd6417d38d5a 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c @@ -86,7 +86,24 @@ void read_persistent_clock(struct timespec *ts) } } -#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET +#if defined(CONFIG_ARCH_USES_GETTIMEOFFSET) && IS_ENABLED(CONFIG_RTC_DRV_GENERIC) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + mach_hwclk(0, tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (mach_hwclk(1, tm) < 0) + return -EOPNOTSUPP; + return 0; +} + +static const struct rtc_class_ops generic_rtc_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; static int __init rtc_init(void) { @@ -95,7 +112,9 @@ static int __init rtc_init(void) if (!mach_hwclk) return -ENODEV; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &generic_rtc_ops, + sizeof(generic_rtc_ops)); return PTR_ERR_OR_ZERO(pdev); } diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 92b5e02a3750..5c82bae73b9c 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,7 +9,7 @@ #include #include -#if defined(CONFIG_M68K) || defined(CONFIG_PPC) +#if defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm) From patchwork Mon May 30 18:57:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102290 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553001qge; Mon, 30 May 2016 11:58:47 -0700 (PDT) X-Received: by 10.66.26.16 with SMTP id h16mr48554832pag.154.1464634727834; Mon, 30 May 2016 11:58:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xr1si52028720pab.95.2016.05.30.11.58.47; Mon, 30 May 2016 11:58:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161937AbcE3S6b (ORCPT + 30 others); Mon, 30 May 2016 14:58:31 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60208 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161855AbcE3S6Z (ORCPT ); Mon, 30 May 2016 14:58:25 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MTxeT-1az2Cm3Bon-00QnVn; Mon, 30 May 2016 20:58:02 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 10/16] rtc: m68k: provide ioctl for q40 Date: Mon, 30 May 2016 20:57:58 +0200 Message-Id: <1464634684-1248135-11-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:gHIkoH1ulTlAW4drwalu3Aq1cX6DSBjBf4x1GaEqfDQV4MjZbxe BZ3FDqtKMgsvGpnq4rKSdZhGKQtAMWsosbgn/hsZgPHOvoWraZ0pO2zrHWGqD3CTw03WrQu xErDHmJTQwbWTC0FPUH4eXPXIx2b21hzQrTMHv4tRZITHQE1RN7/7PfdHGq02oFnDmFJrZX AtYz9i19TAFsSpENXnF8Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:ur4YYMqA46w=:ogt8yCwt4e3TtUvZWALOV5 +BbjIa/KG8/A4+iG/d1AGaiEdb3WZRC3P6HkqNpH6W31ZhIpyuqjQ+RwShXEO32pNYlUYQi+Y htXnViT1nTw9hVRon2ukNB8sR0RHG36rwXtKbmTDMH2zwTJyoh7wlMFqTnb4fRM+2qunPv4Gf wxAu5toVkgkHNieYzHIloZkRs4fwv+JJGTsK3HnRjaBRzdw0CplFwRUGExIn12jAsDgyFmLKI Py8Y+5Lrc0Xl8m6lMqnPjVOg3JQRCiYWnFV/08xojaJNSsknkjUSHTIY16Ck3+eu4NiKcjd19 sqpBIHSxKQmWrowHmnN+Eq5fcTmjJsVEeXIMfxjKNLcEMeh4ScG0RLaVC1wBGeGkQREz7tLx/ 5YFFSdHZ2G6Gzt10ZwPMz6i2SYEGEp0Jo/NWRBoTCBEVsprnrt6aPBQ59DVmwQeZTJ5RLysJn BzRpTe5TMUZtzWJilQnepuu5Ggg1Um8JmVifxh4IVfBuvTKCklqksY4Q1juwD5/oQga0ZjJrK fH1mYfK13vb1jB2QuHBE1EAQrcHnHjMhcVUes1cFv9ijaPiC2VSwaZlSVD0VqmYOOXDy0okRx LjWb0dJggvyVbTqxaBzEjg4UCuH6ahr7k40oTCZLUgNvZm0wr8R4PTq1m8GZAB332LQ4yUFGB DiNhdBON+KHLJI+bHeVAtfE2CjHuMdeMjaCQTnhZUyvopXa0ex3JRvW+IkXx6TtEW52Q= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/m68k/kernel/time.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.7.0 diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index bd6417d38d5a..4e5aa2f4f522 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, }; From patchwork Mon May 30 18:57:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102282 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553936qge; Mon, 30 May 2016 12:01:15 -0700 (PDT) X-Received: by 10.98.69.197 with SMTP id n66mr49351405pfi.75.1464634875758; Mon, 30 May 2016 12:01:15 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si38006546pfm.61.2016.05.30.12.01.15; Mon, 30 May 2016 12:01:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162100AbcE3TBL (ORCPT + 30 others); Mon, 30 May 2016 15:01:11 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:64493 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161880AbcE3S61 (ORCPT ); Mon, 30 May 2016 14:58:27 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Lxftz-1bar7h1FBT-017H8n; Mon, 30 May 2016 20:58:02 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 11/16] char/genrtc: remove m68k support Date: Mon, 30 May 2016 20:57:59 +0200 Message-Id: <1464634684-1248135-12-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:XszN0Xuo2cze9UvU0p0VHuozhDqnMMsMwtisub7pzRDz1Lg+lWg CGKgv9TA0g1lj2+Fii0zTZUSfLkN1NHmE0FoCA9FD2VIae1FGxc6pnG++8pvop3oyWEJzJq jH2aGQT/718PYnLX43Y7a+dARm4r7mcvaIHkdovbxk3B4/HZt025mLcqF02PTVT51iNLxZl 8eYQ+DMPspRBPikvt83Mg== X-UI-Out-Filterresults: notjunk:1; V01:K0:92W2hsKpUDI=:vslS1VeS1khPUAkIhcIDNP MPTgQo9r9E/XgqoxgP1L266/UIg8vg9H9nXoZPFuLJoq/Ykfb9dS7Mfvkbvkpu5ODkRDoEwYl jx4RZyrLTkFje3+a9yljXXH3YlHnvCa2hQY7qbGukuMvIkfHuBrVisS5P+YmFkkQzgbxA8D74 DyRXy3bnhJXg3eRf//M62mE3mojWum9kXTiEjN6xsi99GqjuFVFieKisInXRL1rnin2Lcj+ie IicADommCGwEIdSCzaCbNamekPnQ02G1kjiQlByElLlcqntGQnan6MTheZseI9s9HMJJi2e12 kJwlF6RmooC1W8ca0rj5RKuGy6S5aNIFA+KbkR8jt3NUJUqcZVRBnGAd5Nq5OpLr+qh1h0lNF nwYM/2zMucLpVAHi0PRRPIRPlA5IiQDFd0NXAvaOu6tK4R9Sjap6oNwG+ASVbmzCvDWKb9uQ8 J0SJ44zP5S1FTRUB/S+PQxbVlW2/iaOPLiyNZ8bsjRxzIRiwftyT2DhdOP/CQfNk3rdP7qJSE +akKAGlUPiCZ3GQbFqIIrx3Bd4sVtdDvrN5wfd4H4YvJFqiJl+i6vrShEvg+FS7hRnu3X16Se yDjZPS1I9jnrKQUzCr9pKP/YwR5gxhsKmY+znJnNQVyfybES6Rvs5Bhg98KzvaVAHubi8Pe+H C4L9skxOEQOsprF1NnnpISbqu0FLKFVTstBLY5r5gJFaU12Q/vzxL5lDURsCwEI4JRyc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The asm/rtc.h header is only used for the old gen_rtc driver that has been replaced by rtc-generic. According to Geert Uytterhoeven, nobody has used the old driver on m68k for a long time, so we can now just remove the header file and disallow the driver in Kconfig. All files that used to include asm/rtc.h are now changed so they include the headers that were used implicitly through asm/rtc.h. Signed-off-by: Arnd Bergmann --- arch/m68k/amiga/config.c | 1 - arch/m68k/apollo/config.c | 1 - arch/m68k/bvme6000/config.c | 1 - arch/m68k/hp300/config.c | 2 +- arch/m68k/include/asm/rtc.h | 79 --------------------------------------------- arch/m68k/mac/config.c | 3 +- arch/m68k/mac/misc.c | 1 - arch/m68k/mvme147/config.c | 1 - arch/m68k/mvme16x/config.c | 1 - arch/m68k/q40/config.c | 2 +- arch/m68k/sun3/config.c | 1 - arch/m68k/sun3/intersil.c | 2 +- arch/m68k/sun3x/time.c | 2 +- drivers/char/Kconfig | 2 +- 14 files changed, 7 insertions(+), 92 deletions(-) delete mode 100644 arch/m68k/include/asm/rtc.h -- 2.7.0 diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index 01693df7f2f6..ec9cc1fdd237 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c index 6e62d66c396e..432bc8bacfc2 100644 --- a/arch/m68k/apollo/config.c +++ b/arch/m68k/apollo/config.c @@ -15,7 +15,6 @@ #include #include #include -#include #include u_long sio01_physaddr; diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c index 478623dbb209..611d4d9ea2bd 100644 --- a/arch/m68k/bvme6000/config.c +++ b/arch/m68k/bvme6000/config.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/arch/m68k/hp300/config.c b/arch/m68k/hp300/config.c index a9befe65adc4..7cfab158fb61 100644 --- a/arch/m68k/hp300/config.c +++ b/arch/m68k/hp300/config.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -20,7 +21,6 @@ #include #include /* readb() and writeb() */ #include -#include #include "time.h" diff --git a/arch/m68k/include/asm/rtc.h b/arch/m68k/include/asm/rtc.h deleted file mode 100644 index a4d08ea122ee..000000000000 --- a/arch/m68k/include/asm/rtc.h +++ /dev/null @@ -1,79 +0,0 @@ -/* include/asm-m68k/rtc.h - * - * Copyright Richard Zidlicky - * implementation details for genrtc/q40rtc driver - */ -/* permission is hereby granted to copy, modify and redistribute this code - * in terms of the GNU Library General Public License, Version 2 or later, - * at your option. - */ - -#ifndef _ASM_RTC_H -#define _ASM_RTC_H - -#ifdef __KERNEL__ - -#include -#include -#include - -#define RTC_PIE 0x40 /* periodic interrupt enable */ -#define RTC_AIE 0x20 /* alarm interrupt enable */ -#define RTC_UIE 0x10 /* update-finished interrupt enable */ - -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -static inline unsigned int get_rtc_time(struct rtc_time *time) -{ - /* - * Only the values that we read from the RTC are set. We leave - * tm_wday, tm_yday and tm_isdst untouched. Even though the - * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated - * by the RTC when initially set to a non-zero value. - */ - if (mach_hwclk) - mach_hwclk(0, time); - return RTC_24H; -} - -static inline int set_rtc_time(struct rtc_time *time) -{ - if (mach_hwclk) - return mach_hwclk(1, time); - return -EINVAL; -} - -static inline unsigned int get_rtc_ss(void) -{ - if (mach_get_ss) - return mach_get_ss(); - else{ - struct rtc_time h; - - get_rtc_time(&h); - return h.tm_sec; - } -} - -static inline int get_rtc_pll(struct rtc_pll_info *pll) -{ - if (mach_get_rtc_pll) - return mach_get_rtc_pll(pll); - else - return -EINVAL; -} -static inline int set_rtc_pll(struct rtc_pll_info *pll) -{ - if (mach_set_rtc_pll) - return mach_set_rtc_pll(pll); - else - return -EINVAL; -} -#endif /* __KERNEL__ */ - -#endif /* _ASM__RTC_H */ diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 689b47d292ac..2f33a33001e5 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -10,6 +10,7 @@ * Miscellaneous linux stuff */ +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c index 707b61aea203..0fb54a90eac2 100644 --- a/arch/m68k/mac/misc.c +++ b/arch/m68k/mac/misc.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c index e6a3b56c6481..c11d38dfad08 100644 --- a/arch/m68k/mvme147/config.c +++ b/arch/m68k/mvme147/config.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index a53803cc66cd..58e240939d26 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c index e90fe903613e..fcb7f05b60b6 100644 --- a/arch/m68k/q40/config.c +++ b/arch/m68k/q40/config.c @@ -12,6 +12,7 @@ * for more details. */ +#include #include #include #include @@ -27,7 +28,6 @@ #include #include -#include #include #include #include diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c index 71884bf01d72..3af34fa3a344 100644 --- a/arch/m68k/sun3/config.c +++ b/arch/m68k/sun3/config.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/arch/m68k/sun3/intersil.c b/arch/m68k/sun3/intersil.c index 889829e11f1d..2cd0bcbe6f30 100644 --- a/arch/m68k/sun3/intersil.c +++ b/arch/m68k/sun3/intersil.c @@ -14,8 +14,8 @@ #include #include -#include #include +#include /* bits to set for start/run of the intersil */ diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c index c8eb08add6b0..431d3c4306dd 100644 --- a/arch/m68k/sun3x/time.c +++ b/arch/m68k/sun3x/time.c @@ -15,10 +15,10 @@ #include #include +#include #include #include #include -#include #include "time.h" diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 074bc394e31b..fccac76257c9 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -328,7 +328,7 @@ config JS_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on M68K || PPC + depends on PPC ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you From patchwork Mon May 30 18:58:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102278 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1554445qge; Mon, 30 May 2016 12:02:20 -0700 (PDT) X-Received: by 10.98.59.6 with SMTP id i6mr48624998pfa.45.1464634940236; Mon, 30 May 2016 12:02:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id as6si6316217pac.173.2016.05.30.12.02.19; Mon, 30 May 2016 12:02:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162023AbcE3TB6 (ORCPT + 30 others); Mon, 30 May 2016 15:01:58 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:60709 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161877AbcE3S60 (ORCPT ); Mon, 30 May 2016 14:58:26 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LdEZd-1bpcpH3e8f-00iSt5; Mon, 30 May 2016 20:58:03 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 12/16] rtc: powerpc: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:58:00 +0200 Message-Id: <1464634684-1248135-13-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:y9giqI9oWgAwg+FAFlGiUy9EsT2tk43+dnKBHuox8q3+0+aju8+ LQmSB6slNbf3i4Gx44ZOvtliVa5VBKQkaGgB37Klk/tRYsG+VK9gjwhmmDE5aJBacdCmrBU MEmg6Aoq7wVAAAgof+1WGVXGME53eSZeK8BQvhlUvslycdzhNwCk5vLKMpv+pHNAHUsjWbo FTEpC/kKvKqWLSMZZGetA== X-UI-Out-Filterresults: notjunk:1; V01:K0:yWWyvcKKDXU=:2oq+kNvSH8AMg3X7l5fe+w 2P16czcsLPuPjO+x5RJj42l732E87HE1GFWpF6SHXlVph83XXr3A3YZbdk+jzqFxgs0RBDKgn by/kuwL9ZvEHeqULjZ6gmNCNrFTLMPiKvtoRW3xtIx5Qh+tJ58BfxKVPs7zVM2/tM1jtEDA4k p0FAp7mMU26MJFBOUE6VqIOv4lJC1w0xgzFPRaoAwzHRm7eVMeaw65hKsUcr97kghJUVqbN6I ZQWn/IV5TywkXEyZpejZ4pkUjc9+7wFHgIleNSev8muEmWsNLpsBBKESClcLffW7a9eD/0o5e 4K6OJAXuilpoRnBLTpgy7lwazHll6eptD5gUG8S9lczOrZYRE7Dxw15vc6xNNiRaFmeKJ82by jzFHjSMQsojQjckEEcoJzXbJVo/XiPe6batV2MuqU8kT0qbQmwJq/Dz7Q9lvdfqzqfuXHU31J SHO/YxGxDUGFLcHCXrh5+1ArzHKzGBTmIMmy3VKOTG0wHBC2bKdvOzSVo3tcNuOa/3YLItYAE e+38eXc8hdx54J6cK9NtFHIHSh/rpXN2bv6CAZS4hXrvq5+7CiFpcC/MoQGn9+DSx7kJfXb52 tpqFkdq9eOk9l3Pcb0sZqvS5Hoon2RIZ3FJBejMcz7JPZALlN82jjROS97pfW9eLP2rb9gQq7 MItKy0v/N6fpwViuZtSpMJNojcGRDYPxLNpMeWN4VrEpdOl09kao5HG7JCU4fPHmOE0o= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and powerpc has another abstraction on top, which is a bit silly. This changes the powerpc rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/time.c | 29 ++++++++++++++++++++++++++++- drivers/rtc/rtc-generic.c | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) -- 2.7.0 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 3ed9a5a21d77..7a482a7f4d8d 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -1081,6 +1082,29 @@ void calibrate_delay(void) loops_per_jiffy = tb_ticks_per_jiffy; } +#if IS_ENABLED(CONFIG_RTC_DRV_GENERIC) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + ppc_md.get_rtc_time(tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (!ppc_md.set_rtc_time) + return -EOPNOTSUPP; + + if (ppc_md.set_rtc_time(tm) < 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; @@ -1088,9 +1112,12 @@ static int __init rtc_init(void) if (!ppc_md.get_rtc_time) return -ENODEV; - 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 diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 5c82bae73b9c..efcb9833cac8 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,7 +9,7 @@ #include #include -#if defined(CONFIG_PPC) +#if 0 #include static int generic_get_time(struct device *dev, struct rtc_time *tm) From patchwork Mon May 30 18:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102288 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553018qge; Mon, 30 May 2016 11:58:51 -0700 (PDT) X-Received: by 10.98.23.146 with SMTP id 140mr46065911pfx.122.1464634728608; Mon, 30 May 2016 11:58:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xr1si52028720pab.95.2016.05.30.11.58.48; Mon, 30 May 2016 11:58:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161977AbcE3S6l (ORCPT + 30 others); Mon, 30 May 2016 14:58:41 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:61309 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161855AbcE3S6h (ORCPT ); Mon, 30 May 2016 14:58:37 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Md4Bm-1aqTlZ1mhW-00IF3U; Mon, 30 May 2016 20:58:03 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 13/16] char/genrtc: remove powerpc support Date: Mon, 30 May 2016 20:58:01 +0200 Message-Id: <1464634684-1248135-14-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:mU+jsC6ft7y4jAN0AVZizPcSNB30ZOCxRoW1SFg9m2p85M0WnMD bd3TleJMa7p9z6BIXnuVuo+MmNYN/7ZQsv/k7kagbfmWqd+e+f7o5mEKd+7b0raIezfRAhg 4IWW1lBb1Sm0q3CGx44p7in96nkKYsSrh9QBSbaI9YDz/HHuMTScnjWUh9oTFZsQTvgORRQ aFNuQQJSXMGKbFRTOvxSA== X-UI-Out-Filterresults: notjunk:1; V01:K0:WlaCh9rzDXQ=:Y8+QjZEUSDj41sbOn0mc7q n6X380oa86j4mPRfxQNFrpR0Lhd1Y+VlrbqC1oS/J6PzOS4tVYSbvCDHgstV/RowvN4EnTP7L rENGTm9p9IKXsNJ4tyLZCbMb/lQPufskw7E6UiMALBpwimZSd0Z73sqV35VaivkVH6i9POFdM h0P2x19BjBM4BgNXAlcjnW13nn6r41vnudvzInIcWShdQXS0j9JKpZhADx39IjgFkQGMhBnCy 0VSHDDhZQULx5Ek27JTeOz0B3uJVqYjW3+LjTfIjqZ8T8WmhbI29EYq9A5Pylll3eKaAZGAzA Y9u0NYjiqnP2ulN4XQuxnAWfzACZ+mkAOXX6P8jn58XXqy/duqQuZ70NQYpqsEWGNUaXxW2yO hZRxiTdOofk2kXXeqGrIXxDulTqGPmESgjo6yvPw4q9vAEK9b/TPr0oSh2YhmsMNUfrev6ELL akmvr+a2PHUERbdWAukrOhvt9IrhzYQa4238KGOUSd0EcIGK978mdlMnnXyvoT3+Kv6MTe4xW 9FmXjC+Dn6Lgblqz7ZnCaABV4yh7uDbuswJ6FX/rnkGlJHSDxik8GlOylcJ7NPzr984BUeXO2 BbeNR5FTrlyxaqF2H0ygVZG89iTl2X/3FbVx8uoq3Qk6PtDXKxigmRVoGWcxqWs/DAhyvMy5c Sb3KLgUtF8EATWaf8e+r/j90lKgeu5iGD2z/LSIj0hMXCcl2KCu7zKH/fZVj8QsThnTI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PowerPC is the last architecture using the GEN_RTC driver on some machines, but we can migrate them all to using the RTC_DRV_GENERIC driver instead now. This moves over the CONFIG_GEN_RTC option from drivers/char into arch/powerpc/platforms/Kconfig and makes it just select the replacement driver instead, for the only reason of not breaking existing defconfig and .config files that users may have. Signed-off-by: Arnd Bergmann --- arch/powerpc/include/asm/rtc.h | 78 --------------------------------------- arch/powerpc/platforms/Kconfig | 11 ++++++ arch/powerpc/platforms/ps3/time.c | 2 +- drivers/char/Kconfig | 4 +- drivers/char/Makefile | 2 +- 5 files changed, 15 insertions(+), 82 deletions(-) delete mode 100644 arch/powerpc/include/asm/rtc.h -- 2.7.0 diff --git a/arch/powerpc/include/asm/rtc.h b/arch/powerpc/include/asm/rtc.h deleted file mode 100644 index f5802926b6c0..000000000000 --- a/arch/powerpc/include/asm/rtc.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Real-time clock definitions and interfaces - * - * Author: Tom Rini - * - * 2002 (c) MontaVista, Software, Inc. This file is licensed under - * the terms of the GNU General Public License version 2. This program - * is licensed "as is" without any warranty of any kind, whether express - * or implied. - * - * Based on: - * include/asm-m68k/rtc.h - * - * Copyright Richard Zidlicky - * implementation details for genrtc/q40rtc driver - * - * And the old drivers/macintosh/rtc.c which was heavily based on: - * Linux/SPARC Real Time Clock Driver - * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) - * - * With additional work by Paul Mackerras and Franz Sirl. - */ - -#ifndef __ASM_POWERPC_RTC_H__ -#define __ASM_POWERPC_RTC_H__ - -#ifdef __KERNEL__ - -#include - -#include -#include - -#define RTC_PIE 0x40 /* periodic interrupt enable */ -#define RTC_AIE 0x20 /* alarm interrupt enable */ -#define RTC_UIE 0x10 /* update-finished interrupt enable */ - -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -static inline unsigned int get_rtc_time(struct rtc_time *time) -{ - if (ppc_md.get_rtc_time) - ppc_md.get_rtc_time(time); - return RTC_24H; -} - -/* Set the current date and time in the real time clock. */ -static inline int set_rtc_time(struct rtc_time *time) -{ - if (ppc_md.set_rtc_time) - return ppc_md.set_rtc_time(time); - return -EINVAL; -} - -static inline unsigned int get_rtc_ss(void) -{ - struct rtc_time h; - - get_rtc_time(&h); - return h.tm_sec; -} - -static inline int get_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} -static inline int set_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} - -#endif /* __KERNEL__ */ -#endif /* __ASM_POWERPC_RTC_H__ */ diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index 46a3533d3acb..863aa4341390 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig @@ -321,6 +321,17 @@ config OF_RTC Uses information from the OF or flattened device tree to instantiate platform devices for direct mapped RTC chips like the DS1742 or DS1743. +config GEN_RTC + bool "Use the platform RTC operations from user space" + select RTC_CLASS + select RTC_DRV_GENERIC + help + This option provides backwards compatibility with the old gen_rtc.ko + module that was traditionally used for old PowerPC machines. + Platforms should migrate to enabling the RTC_DRV_GENERIC by hand + replacing their get_rtc_time/set_rtc_time callbacks with + a proper RTC device driver. + config SIMPLE_GPIO bool "Support for simple, memory-mapped GPIO controllers" depends on PPC diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c index 791c6142c4a7..11b45b58c81b 100644 --- a/arch/powerpc/platforms/ps3/time.c +++ b/arch/powerpc/platforms/ps3/time.c @@ -20,9 +20,9 @@ #include #include +#include #include -#include #include #include diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index fccac76257c9..153e90f8a445 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -325,10 +325,10 @@ config JS_RTC To compile this driver as a module, choose M here: the module will be called js-rtc. -config GEN_RTC +config OLD_GEN_RTC tristate "Generic /dev/rtc emulation" depends on RTC!=y - depends on PPC + depends on BROKEN ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you diff --git a/drivers/char/Makefile b/drivers/char/Makefile index d8a7579300d2..fc0905aa7373 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -25,7 +25,7 @@ obj-$(CONFIG_APPLICOM) += applicom.o obj-$(CONFIG_SONYPI) += sonypi.o obj-$(CONFIG_RTC) += rtc.o obj-$(CONFIG_HPET) += hpet.o -obj-$(CONFIG_GEN_RTC) += genrtc.o +obj-$(CONFIG_OLD_GEN_RTC) += genrtc.o obj-$(CONFIG_EFI_RTC) += efirtc.o obj-$(CONFIG_DS1302) += ds1302.o obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/ From patchwork Mon May 30 18:58:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102285 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553241qge; Mon, 30 May 2016 11:59:25 -0700 (PDT) X-Received: by 10.66.122.73 with SMTP id lq9mr48908091pab.124.1464634765229; Mon, 30 May 2016 11:59:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h192si38051782pfc.70.2016.05.30.11.59.24; Mon, 30 May 2016 11:59:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161999AbcE3S6q (ORCPT + 30 others); Mon, 30 May 2016 14:58:46 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:55982 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161970AbcE3S6m (ORCPT ); Mon, 30 May 2016 14:58:42 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MGi7V-1bKytu42U5-00DVrD; Mon, 30 May 2016 20:58:04 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 14/16] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Date: Mon, 30 May 2016 20:58:02 +0200 Message-Id: <1464634684-1248135-15-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:d16F59SijNbksyuQ9MMdWehXeFIk2HahpucBBFURdhCA3hbr/2L qqVm658rVHtTi7PJ/nJ5ntt7EKymqniqBqqJC49BHDN3gmrjvX7iPCL3pdALv4uAeIsPmMr XhwqlKHqPUXtBHWXA1cUbTo8Cm7yITXobldONVWrqlzb65E/3nCihZlkLSdVuuULqmzwmxu pPPfkqzkXueBcc3YUAEAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:UnTGTCebAv4=:mG/C0BsxLZYSzvhaYvteGI 5Ea9+kFJBRlI+NvaQetgZqc8HfRWRkLS76xpZDntxpNkCe/mNDTwJAFB9LFVelK2Y64JPBGUh lelq/nLd9WTIa1oSjk5sboohnZCCmSpaGsnFqD08Q+ryE6/9IPP0G3Vt5HsSNvKtAPSwiDI1a tL7BelqsWD9Sqd9TKfBggdcWdpYyj2/cw9jtcqV4hBMS0nBzuggwNDis+vGo6vLxB9lmXSTr8 7xJYAL4HBY++hoKzCdtTw6tPz+NwkK7sVm5mIkhMNL5t4u5mzlnbZC7EDtfnbtDxlDqvvkRcB U9Emi59boBPcrn0BKXjYZFnvUuplQZtp2SGs9NPiM9KEczTqPGsqi1XQY1CscwOisbF1HReYn GleDxrBmLwgI9VkD919WlcPhpYdzX2pNHbbpyZSk7qrzOZYkpDGtaqiV/cciWrzosJFgGCiiM LeYHHYvexXgTSWgPmdBPyVhh0NhiQ+lIACVvC4/SVxkrX7umT83G5Emhl5T6cITptsMaMvdcF zZiWqksbHNomi6bvL0DPedhFYXZuV7eCUwVJk/JRi1PCcpKSeX2HggLawMuldHQoE+gcGL5td J4XQ06gfhdg97re1YHVWGctMsZTl5oro0UxzP3N+7VjyJ5BZ5kKAnbVKVqEY80AC/bw5KvjGN gKg5PajnQ3jetvf20kL+uAZW6zaq7q8bX4vG+AJ8AOkqsLIUI9qet9IKfrVu4FCF1uHw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All architectures using this driver are now converted to provide their own operations, so this one can be turned into a trivial stub driver relying on its platform data. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-generic.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) -- 2.7.0 diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index efcb9833cac8..1bf5d2347928 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,43 +9,10 @@ #include #include -#if 0 -#include - -static int generic_get_time(struct device *dev, struct rtc_time *tm) -{ - unsigned int ret = get_rtc_time(tm); - - if (ret & RTC_BATT_BAD) - return -EOPNOTSUPP; - - return rtc_valid_tm(tm); -} - -static int generic_set_time(struct device *dev, struct rtc_time *tm) -{ - if (set_rtc_time(tm) < 0) - return -EOPNOTSUPP; - - return 0; -} - -static const struct rtc_class_ops generic_rtc_ops = { - .read_time = generic_get_time, - .set_time = generic_set_time, -}; -#else -#define generic_rtc_ops *(struct rtc_class_ops*)NULL -#endif - static int __init generic_rtc_probe(struct platform_device *dev) { struct rtc_device *rtc; - const struct rtc_class_ops *ops; - - ops = dev_get_platdata(&dev->dev); - if (!ops) - ops = &generic_rtc_ops; + const struct rtc_class_ops *ops = dev_get_platdata(&dev->dev); rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", ops, THIS_MODULE); From patchwork Mon May 30 18:58:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102283 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553729qge; Mon, 30 May 2016 12:00:46 -0700 (PDT) X-Received: by 10.66.11.67 with SMTP id o3mr41343390pab.95.1464634846630; Mon, 30 May 2016 12:00:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id re14si52031131pab.85.2016.05.30.12.00.46; Mon, 30 May 2016 12:00:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162059AbcE3TAf (ORCPT + 30 others); Mon, 30 May 2016 15:00:35 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:61951 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161886AbcE3TAa (ORCPT ); Mon, 30 May 2016 15:00:30 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M5gVc-1bRCDs2M6S-00xcDu; Mon, 30 May 2016 20:58:04 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 15/16] char/genrtc: remove asm-generic/rtc.h from mips Date: Mon, 30 May 2016 20:58:03 +0200 Message-Id: <1464634684-1248135-16-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:tZPrzye22a0S7LpPLbMGapXh3lIOMVMem2DHCSioOVepvSwClvA sWtswfy28ppF4b4LmNUXnYxBU0SCMszv9d/Z2Y8hQQ1jRKSfwLv56vw19hw4NCV3s5qX7b9 wrHTb8t1mb4fxg5BZ4CyjbLp+LdaiCwzAyZmdNuzJ09njpPJ7AZ6YBu26cSpS5Fuq98My3j 4e6rcfJifN2dMJEVkGYqA== X-UI-Out-Filterresults: notjunk:1; V01:K0:wBi0/f+PLZI=:kKR7Elz9aVIHPP9JDo3RZa 8G29JGafD+akq84fx6Hk5zyNv2q1diAB6emMwoFJ/Vp31Nh6X7iggdyCMuUjBVJrBa5jin2ba M10Wgepnmw16KlkTwe4nJV8EvYCn33Lw/jsM1seTH+I+Lhd/HNJmGvzTg5xPXdknm9yPjp8ry VjgYuF2bHTr8Jk/t+usZaZk7iYdEQpYQnOm1k8t8muldM3a7hV4jiO+VyKuQ/vNwds7miiC7O nVnghs8hjhWChESoV7CwqVujQnmowXZ8uMzkN9VdgHIoQr60wXuIXUZtjsk/yXkdtlQ9RxVk+ q8N1TSU3ohpSMUL0wPaI2PjpVbRBYfHtzjal34T5RpxhyCU+6L8SUylb25/T5cNYQxDEsSCIx rxPRyVbUtAiyIZdxBRlUaKjwdO+IA1SJYlJQYl5ni277cJhtW8Pd/Kz6iAFtEt5WgGYbm4yq/ 1WpCCMFvS8YoeQyRdzXrVIdSRJnv92Ck1I2N7T2oU3sJImFCmUTfUD6qvWfwatGkYedaCQ/v7 NqmzCBZTnuTAiwMO8r03CwvmWG62rDWKpOzG/ssu+sAa1UTo+DwvHu1A/6n6CyavsIdLiTfuA 2mJOkw8SxV9VzltOK2MWrk/j5QBU+J67TF3IxZDwHNXGcYMeeymdfFzQRE6IQPBhKvIRPqJez /5sD9/FZ9Z4UpvA0lgpAHAWH9KhRvt4AMhndyxlORG3TFh+HBC154ch/5SOUhhN0XaKI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org arch/mips/sni/time.c includes asm-generic/rtc.h for no apparent reason, and it works fine without that header, so lets remove the inclusion in preparation of deleting the file. Signed-off-by: Arnd Bergmann --- arch/mips/sni/time.c | 1 - 1 file changed, 1 deletion(-) -- 2.7.0 diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c index fb4b3520cdc6..7ee14f41fc25 100644 --- a/arch/mips/sni/time.c +++ b/arch/mips/sni/time.c @@ -8,7 +8,6 @@ #include #include -#include #define SNI_CLOCK_TICK_RATE 3686400 #define SNI_COUNTER2_DIV 64 From patchwork Mon May 30 18:58:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102287 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1553129qge; Mon, 30 May 2016 11:59:10 -0700 (PDT) X-Received: by 10.98.79.199 with SMTP id f68mr48945473pfj.44.1464634750214; Mon, 30 May 2016 11:59:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qz13si3614678pac.50.2016.05.30.11.59.09; Mon, 30 May 2016 11:59:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162018AbcE3S6t (ORCPT + 30 others); Mon, 30 May 2016 14:58:49 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:61117 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161967AbcE3S6m (ORCPT ); Mon, 30 May 2016 14:58:42 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Mf1KL-1asPR60fVp-00OYSF; Mon, 30 May 2016 20:58:05 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v4 16/16] char/genrtc: remove the rest of the driver Date: Mon, 30 May 2016 20:58:04 +0200 Message-Id: <1464634684-1248135-17-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:x0l6txtXosjETqN+yzz//JAlA2Lm1zP9/DQvRzJpmYtn2XMtBlA w0RG/WomyysmncKk1XSaLL0GY5HpOBAf3iL5hjLFJwiX9Xh2Nb6ry63WLVZnL7ph1c9LP+s //+Rc8lttVFlkAXhEKtrmBERCz9OuTwl2PFZotG64KqOwAypEr2mNV3ixZt/ZHvPCMTWRa0 3f8vYdsJ5yOjNEGAFKthA== X-UI-Out-Filterresults: notjunk:1; V01:K0:PiLhhKXy+ZA=:0y2sHqZY3GY1Y3CoBzsJE7 XEayRxO9LLJDyYyfNsN4vy/lRSnscpRQ69oHqgF0Xbmr5LW7C717c5h6eMnhMwC08reucvXfg aFY//KvFX6me+7qGpF7P3DXcfi8twknEraKXyOa/bA4MqwaCDOfaWZ1WykA9i3V2ROP2Svuzo 56nH90Hjwwn3ammxVcRjufqRRGkslzghxcEPmSIuO0HYLFlsiDSUflphnRfD7FetJJdQxKNrj an5HwelziQ6SyNGkkY5ONPUOe1fsKOXn7gmdFEsRBtnupsWA1krYd5/xDPlqBNN+pFnJ0TEBj 7sORYx/DFMvKVF8g5+RDIk7YhdftiTQfZ0J7PH/1x1b+mEJwRXNRab2HS1uxVjVtuwn7EcHJI bP5ReJbx7SXgropeRUZve4DgFpp+FKpBNcUDly7gfQZsxBH6MwzgvYAoL++5yjv4eTI06lFBa B09pq1CAfyDFA2YobNxtbFVNI2l5iI2cpJl1gst0XSznlGIzm6tYxaoTfP5uJukUoE7AL4Feg OHTbOPKHASaNhAUHwerLj50bsEeVYhBJO7VU3WbAk3R7oM+LNxM4WXmDBmXNPeruhA2w9RT+w C+FMK3X1HiEwq0Mf8UejdwJAgfr04jiwHPYhC5GNUlpCRkYoPBNguJWQicryjLzqp2if18c3i YnQsDNVZxW026Q/42X77aEzeUPTawqfHAlLHX7LGK73VkUpW2xwAgMvcUeErBI5CbiwY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No architecture uses the genrtc driver any more, so let's kill it off for good. This now also includes asm-generic/rtc.h, which is otherwise completely unused. Signed-off-by: Arnd Bergmann --- drivers/char/Kconfig | 26 --- drivers/char/Makefile | 1 - drivers/char/genrtc.c | 539 ---------------------------------------------- include/asm-generic/rtc.h | 51 ----- 4 files changed, 617 deletions(-) delete mode 100644 drivers/char/genrtc.c delete mode 100644 include/asm-generic/rtc.h -- 2.7.0 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 153e90f8a445..0ec91cc6c2fb 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -325,32 +325,6 @@ config JS_RTC To compile this driver as a module, choose M here: the module will be called js-rtc. -config OLD_GEN_RTC - tristate "Generic /dev/rtc emulation" - depends on RTC!=y - depends on BROKEN - ---help--- - If you say Y here and create a character special file /dev/rtc with - major number 10 and minor number 135 using mknod ("man mknod"), you - will get access to the real time clock (or hardware clock) built - into your computer. - - It reports status information via the file /proc/driver/rtc and its - behaviour is set by various ioctls on /dev/rtc. If you enable the - "extended RTC operation" below it will also provide an emulation - for RTC_UIE which is required by some programs and may improve - precision in some cases. - - To compile this driver as a module, choose M here: the - module will be called genrtc. - -config GEN_RTC_X - bool "Extended RTC operation" - depends on GEN_RTC - help - Provides an emulation for RTC_UIE which is required by some programs - and may improve precision of the generic RTC support in some cases. - config EFI_RTC bool "EFI Real Time Clock Services" depends on IA64 diff --git a/drivers/char/Makefile b/drivers/char/Makefile index fc0905aa7373..f33f5e35df9c 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -25,7 +25,6 @@ obj-$(CONFIG_APPLICOM) += applicom.o obj-$(CONFIG_SONYPI) += sonypi.o obj-$(CONFIG_RTC) += rtc.o obj-$(CONFIG_HPET) += hpet.o -obj-$(CONFIG_OLD_GEN_RTC) += genrtc.o obj-$(CONFIG_EFI_RTC) += efirtc.o obj-$(CONFIG_DS1302) += ds1302.o obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/ diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c deleted file mode 100644 index 4f943759d376..000000000000 --- a/drivers/char/genrtc.c +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Real Time Clock interface for - * - q40 and other m68k machines, - * - HP PARISC machines - * - PowerPC machines - * emulate some RTC irq capabilities in software - * - * Copyright (C) 1999 Richard Zidlicky - * - * based on Paul Gortmaker's rtc.c device and - * Sam Creasey Generic rtc driver - * - * This driver allows use of the real time clock (built into - * nearly all computers) from user space. It exports the /dev/rtc - * interface supporting various ioctl() and also the /proc/driver/rtc - * pseudo-file for status information. - * - * The ioctls can be used to set the interrupt behaviour where - * supported. - * - * The /dev/rtc interface will block on reads until an interrupt - * has been received. If a RTC interrupt has already happened, - * it will output an unsigned long and then block. The output value - * contains the interrupt status in the low byte and the number of - * interrupts since the last read in the remaining high bytes. The - * /dev/rtc interface can also be used with the select(2) call. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - - * 1.01 fix for 2.3.X rz@linux-m68k.org - * 1.02 merged with code from genrtc.c rz@linux-m68k.org - * 1.03 make it more portable zippel@linux-m68k.org - * 1.04 removed useless timer code rz@linux-m68k.org - * 1.05 portable RTC_UIE emulation rz@linux-m68k.org - * 1.06 set_rtc_time can return an error trini@kernel.crashing.org - * 1.07 ported to HP PARISC (hppa) Helge Deller - */ - -#define RTC_VERSION "1.07" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* - * We sponge a minor off of the misc major. No need slurping - * up another valuable major dev number for this. If you add - * an ioctl, make sure you don't conflict with SPARC's RTC - * ioctls. - */ - -static DEFINE_MUTEX(gen_rtc_mutex); -static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); - -/* - * Bits in gen_rtc_status. - */ - -#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ - -static unsigned char gen_rtc_status; /* bitmapped status byte. */ -static unsigned long gen_rtc_irq_data; /* our output to the world */ - -/* months start at 0 now */ -static unsigned char days_in_mo[] = -{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - -static int irq_active; - -#ifdef CONFIG_GEN_RTC_X -static struct work_struct genrtc_task; -static struct timer_list timer_task; - -static unsigned int oldsecs; -static int lostint; -static unsigned long tt_exp; - -static void gen_rtc_timer(unsigned long data); - -static volatile int stask_active; /* schedule_work */ -static volatile int ttask_active; /* timer_task */ -static int stop_rtc_timers; /* don't requeue tasks */ -static DEFINE_SPINLOCK(gen_rtc_lock); - -static void gen_rtc_interrupt(unsigned long arg); - -/* - * Routine to poll RTC seconds field for change as often as possible, - * after first RTC_UIE use timer to reduce polling - */ -static void genrtc_troutine(struct work_struct *work) -{ - unsigned int tmp = get_rtc_ss(); - - if (stop_rtc_timers) { - stask_active = 0; - return; - } - - if (oldsecs != tmp){ - oldsecs = tmp; - - timer_task.function = gen_rtc_timer; - timer_task.expires = jiffies + HZ - (HZ/10); - tt_exp=timer_task.expires; - ttask_active=1; - stask_active=0; - add_timer(&timer_task); - - gen_rtc_interrupt(0); - } else if (schedule_work(&genrtc_task) == 0) - stask_active = 0; -} - -static void gen_rtc_timer(unsigned long data) -{ - lostint = get_rtc_ss() - oldsecs ; - if (lostint<0) - lostint = 60 - lostint; - if (time_after(jiffies, tt_exp)) - printk(KERN_INFO "genrtc: timer task delayed by %ld jiffies\n", - jiffies-tt_exp); - ttask_active=0; - stask_active=1; - if ((schedule_work(&genrtc_task) == 0)) - stask_active = 0; -} - -/* - * call gen_rtc_interrupt function to signal an RTC_UIE, - * arg is unused. - * Could be invoked either from a real interrupt handler or - * from some routine that periodically (eg 100HZ) monitors - * whether RTC_SECS changed - */ -static void gen_rtc_interrupt(unsigned long arg) -{ - /* We store the status in the low byte and the number of - * interrupts received since the last read in the remainder - * of rtc_irq_data. */ - - gen_rtc_irq_data += 0x100; - gen_rtc_irq_data &= ~0xff; - gen_rtc_irq_data |= RTC_UIE; - - if (lostint){ - printk("genrtc: system delaying clock ticks?\n"); - /* increment count so that userspace knows something is wrong */ - gen_rtc_irq_data += ((lostint-1)<<8); - lostint = 0; - } - - wake_up_interruptible(&gen_rtc_wait); -} - -/* - * Now all the various file operations that we export. - */ -static ssize_t gen_rtc_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - unsigned long data; - ssize_t retval; - - if (count != sizeof (unsigned int) && count != sizeof (unsigned long)) - return -EINVAL; - - if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data) - return -EAGAIN; - - retval = wait_event_interruptible(gen_rtc_wait, - (data = xchg(&gen_rtc_irq_data, 0))); - if (retval) - goto out; - - /* first test allows optimizer to nuke this case for 32-bit machines */ - if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { - unsigned int uidata = data; - retval = put_user(uidata, (unsigned int __user *)buf) ?: - sizeof(unsigned int); - } - else { - retval = put_user(data, (unsigned long __user *)buf) ?: - sizeof(unsigned long); - } -out: - return retval; -} - -static unsigned int gen_rtc_poll(struct file *file, - struct poll_table_struct *wait) -{ - poll_wait(file, &gen_rtc_wait, wait); - if (gen_rtc_irq_data != 0) - return POLLIN | POLLRDNORM; - return 0; -} - -#endif - -/* - * Used to disable/enable interrupts, only RTC_UIE supported - * We also clear out any old irq data after an ioctl() that - * meddles with the interrupt enable/disable bits. - */ - -static inline void gen_clear_rtc_irq_bit(unsigned char bit) -{ -#ifdef CONFIG_GEN_RTC_X - stop_rtc_timers = 1; - if (ttask_active){ - del_timer_sync(&timer_task); - ttask_active = 0; - } - while (stask_active) - schedule(); - - spin_lock(&gen_rtc_lock); - irq_active = 0; - spin_unlock(&gen_rtc_lock); -#endif -} - -static inline int gen_set_rtc_irq_bit(unsigned char bit) -{ -#ifdef CONFIG_GEN_RTC_X - spin_lock(&gen_rtc_lock); - if ( !irq_active ) { - irq_active = 1; - stop_rtc_timers = 0; - lostint = 0; - INIT_WORK(&genrtc_task, genrtc_troutine); - oldsecs = get_rtc_ss(); - init_timer(&timer_task); - - stask_active = 1; - if (schedule_work(&genrtc_task) == 0){ - stask_active = 0; - } - } - spin_unlock(&gen_rtc_lock); - gen_rtc_irq_data = 0; - return 0; -#else - return -EINVAL; -#endif -} - -static int gen_rtc_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct rtc_time wtime; - struct rtc_pll_info pll; - void __user *argp = (void __user *)arg; - - switch (cmd) { - - case RTC_PLL_GET: - if (get_rtc_pll(&pll)) - return -EINVAL; - else - return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0; - - case RTC_PLL_SET: - if (!capable(CAP_SYS_TIME)) - return -EACCES; - if (copy_from_user(&pll, argp, sizeof(pll))) - return -EFAULT; - return set_rtc_pll(&pll); - - case RTC_UIE_OFF: /* disable ints from RTC updates. */ - gen_clear_rtc_irq_bit(RTC_UIE); - return 0; - - case RTC_UIE_ON: /* enable ints for RTC updates. */ - return gen_set_rtc_irq_bit(RTC_UIE); - - case RTC_RD_TIME: /* Read the time/date from RTC */ - /* this doesn't get week-day, who cares */ - memset(&wtime, 0, sizeof(wtime)); - get_rtc_time(&wtime); - - return copy_to_user(argp, &wtime, sizeof(wtime)) ? -EFAULT : 0; - - case RTC_SET_TIME: /* Set the RTC */ - { - int year; - unsigned char leap_yr; - - if (!capable(CAP_SYS_TIME)) - return -EACCES; - - if (copy_from_user(&wtime, argp, sizeof(wtime))) - return -EFAULT; - - year = wtime.tm_year + 1900; - leap_yr = ((!(year % 4) && (year % 100)) || - !(year % 400)); - - if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || (wtime.tm_mday < 1)) - return -EINVAL; - - if (wtime.tm_mday < 0 || wtime.tm_mday > - (days_in_mo[wtime.tm_mon] + ((wtime.tm_mon == 1) && leap_yr))) - return -EINVAL; - - if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || - wtime.tm_min < 0 || wtime.tm_min >= 60 || - wtime.tm_sec < 0 || wtime.tm_sec >= 60) - return -EINVAL; - - return set_rtc_time(&wtime); - } - } - - return -EINVAL; -} - -static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int ret; - - mutex_lock(&gen_rtc_mutex); - ret = gen_rtc_ioctl(file, cmd, arg); - mutex_unlock(&gen_rtc_mutex); - - return ret; -} - -/* - * We enforce only one user at a time here with the open/close. - * Also clear the previous interrupt data on an open, and clean - * up things on a close. - */ - -static int gen_rtc_open(struct inode *inode, struct file *file) -{ - mutex_lock(&gen_rtc_mutex); - if (gen_rtc_status & RTC_IS_OPEN) { - mutex_unlock(&gen_rtc_mutex); - return -EBUSY; - } - - gen_rtc_status |= RTC_IS_OPEN; - gen_rtc_irq_data = 0; - irq_active = 0; - mutex_unlock(&gen_rtc_mutex); - - return 0; -} - -static int gen_rtc_release(struct inode *inode, struct file *file) -{ - /* - * Turn off all interrupts once the device is no longer - * in use and clear the data. - */ - - gen_clear_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE); - - gen_rtc_status &= ~RTC_IS_OPEN; - return 0; -} - - -#ifdef CONFIG_PROC_FS - -/* - * Info exported via "/proc/driver/rtc". - */ - -static int gen_rtc_proc_show(struct seq_file *m, void *v) -{ - struct rtc_time tm; - unsigned int flags; - struct rtc_pll_info pll; - - flags = get_rtc_time(&tm); - - seq_printf(m, - "rtc_time\t: %02d:%02d:%02d\n" - "rtc_date\t: %04d-%02d-%02d\n" - "rtc_epoch\t: %04u\n", - tm.tm_hour, tm.tm_min, tm.tm_sec, - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 1900); - - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - - seq_puts(m, "alarm\t\t: "); - if (tm.tm_hour <= 24) - seq_printf(m, "%02d:", tm.tm_hour); - else - seq_puts(m, "**:"); - - if (tm.tm_min <= 59) - seq_printf(m, "%02d:", tm.tm_min); - else - seq_puts(m, "**:"); - - if (tm.tm_sec <= 59) - seq_printf(m, "%02d\n", tm.tm_sec); - else - seq_puts(m, "**\n"); - - seq_printf(m, - "DST_enable\t: %s\n" - "BCD\t\t: %s\n" - "24hr\t\t: %s\n" - "square_wave\t: %s\n" - "alarm_IRQ\t: %s\n" - "update_IRQ\t: %s\n" - "periodic_IRQ\t: %s\n" - "periodic_freq\t: %ld\n" - "batt_status\t: %s\n", - (flags & RTC_DST_EN) ? "yes" : "no", - (flags & RTC_DM_BINARY) ? "no" : "yes", - (flags & RTC_24H) ? "yes" : "no", - (flags & RTC_SQWE) ? "yes" : "no", - (flags & RTC_AIE) ? "yes" : "no", - irq_active ? "yes" : "no", - (flags & RTC_PIE) ? "yes" : "no", - 0L /* freq */, - (flags & RTC_BATT_BAD) ? "bad" : "okay"); - if (!get_rtc_pll(&pll)) - seq_printf(m, - "PLL adjustment\t: %d\n" - "PLL max +ve adjustment\t: %d\n" - "PLL max -ve adjustment\t: %d\n" - "PLL +ve adjustment factor\t: %d\n" - "PLL -ve adjustment factor\t: %d\n" - "PLL frequency\t: %ld\n", - pll.pll_value, - pll.pll_max, - pll.pll_min, - pll.pll_posmult, - pll.pll_negmult, - pll.pll_clock); - return 0; -} - -static int gen_rtc_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, gen_rtc_proc_show, NULL); -} - -static const struct file_operations gen_rtc_proc_fops = { - .open = gen_rtc_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int __init gen_rtc_proc_init(void) -{ - struct proc_dir_entry *r; - - r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops); - if (!r) - return -ENOMEM; - return 0; -} -#else -static inline int gen_rtc_proc_init(void) { return 0; } -#endif /* CONFIG_PROC_FS */ - - -/* - * The various file operations we support. - */ - -static const struct file_operations gen_rtc_fops = { - .owner = THIS_MODULE, -#ifdef CONFIG_GEN_RTC_X - .read = gen_rtc_read, - .poll = gen_rtc_poll, -#endif - .unlocked_ioctl = gen_rtc_unlocked_ioctl, - .open = gen_rtc_open, - .release = gen_rtc_release, - .llseek = noop_llseek, -}; - -static struct miscdevice rtc_gen_dev = -{ - .minor = RTC_MINOR, - .name = "rtc", - .fops = &gen_rtc_fops, -}; - -static int __init rtc_generic_init(void) -{ - int retval; - - printk(KERN_INFO "Generic RTC Driver v%s\n", RTC_VERSION); - - retval = misc_register(&rtc_gen_dev); - if (retval < 0) - return retval; - - retval = gen_rtc_proc_init(); - if (retval) { - misc_deregister(&rtc_gen_dev); - return retval; - } - - return 0; -} - -static void __exit rtc_generic_exit(void) -{ - remove_proc_entry ("driver/rtc", NULL); - misc_deregister(&rtc_gen_dev); -} - - -module_init(rtc_generic_init); -module_exit(rtc_generic_exit); - -MODULE_AUTHOR("Richard Zidlicky"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS_MISCDEV(RTC_MINOR); diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h deleted file mode 100644 index 4fcff22cd707..000000000000 --- a/include/asm-generic/rtc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * include/asm-generic/rtc.h - * - * Author: Tom Rini - * - * Based on: - * drivers/char/rtc.c - * - * Please read the COPYING file for all license details. - */ - -#ifndef __ASM_RTC_H__ -#define __ASM_RTC_H__ - -#include - -#ifndef get_rtc_time -#include -#define get_rtc_time mc146818_get_time -#define set_rtc_time mc146818_set_time -#endif - -#define RTC_PIE 0x40 /* periodic interrupt enable */ -#define RTC_AIE 0x20 /* alarm interrupt enable */ -#define RTC_UIE 0x10 /* update-finished interrupt enable */ - -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -static inline unsigned int get_rtc_ss(void) -{ - struct rtc_time h; - - get_rtc_time(&h); - return h.tm_sec; -} - -static inline int get_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} -static inline int set_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} - -#endif /* __ASM_RTC_H__ */