From patchwork Mon Aug 27 20:03:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145214 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp348656ljw; Mon, 27 Aug 2018 13:04:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYUBaK4jcMdZWFD4oADdTeZfyh1IyYQ/mOoUQ+VZ3u7+1GN1eb2FFCAIjbZXXD9geCbsQB2 X-Received: by 2002:a65:48c6:: with SMTP id o6-v6mr13122092pgs.99.1535400248580; Mon, 27 Aug 2018 13:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535400248; cv=none; d=google.com; s=arc-20160816; b=adgab8x8mNtKtl8RdkQzku/VBv7UywGkB6DhUEF623Wvm+et1FSIEfTQ3cDM3U8cVH f/sKX2Pvcz7EDyZbJxyQfEXEH/Ol4ij2t5SDHzZYdykiMXQPvdUjXlBy0VrFmpOgaql3 x8bvkB7idSHus9WvAYfQ/jqMCJuJ177PPcbf6LgvSc212Tr1c6L5uoy2K8zHQ893U9+b 3JfU6WztG6xD61GgNknkjN2Ea9L8Uuh2RTF9zFEGb2WF1EgN7FwMsHp/7UrEqvO8qbkS wDizLsq8STWfmGhrjQ7y1og+nafg85Udu24qIHnE6c0+/b94V3VMS+Eg68i/N7GWt+fF G2kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=T5ngOTA3vWknxD3rznw3E7fPINB8PcHeRHv6Xgbr0Hs=; b=vYHAh6yOPIyKval0ce+fcuJtsj5ovToKTNhyVWXlQlmSrRjFYEUnzX4JSraneNXz+g BUB9NPre+eiAPcxqz7nrBDQ+5qcQIdZLx9QTTHKlkQTe2Cu32Ex0LfgDQ3GOUr8YjmG4 VIOoabtyWMP6KdBkmTy4E61sd1z4SLIN5PwgMxPq1qHT2tP7VOBj7m1VXMZdd5BedMzy vwzsdyRRRshruXI4NAQRgjLrtSOmVoa6nCnQ1VMHPMNSe05ty9T9byARyhnvLpXfHNaT Ic00u34CRhQ3GRpcP3vRgvlaVYZN5p2VuMjxB8GtmWWOccxOkpP+NV5ztGC3UXR8e6uR uJoA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h62-v6si148126pge.298.2018.08.27.13.04.08; Mon, 27 Aug 2018 13:04:08 -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 S1727444AbeH0XwL (ORCPT + 32 others); Mon, 27 Aug 2018 19:52:11 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:47325 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbeH0XwK (ORCPT ); Mon, 27 Aug 2018 19:52:10 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0MMcW2-1g0Pbd0oHu-008GrQ; Mon, 27 Aug 2018 22:03:43 +0200 From: Arnd Bergmann To: linux-rtc@vger.kernel.org Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com, keguang.zhang@gmail.com, y2038@lists.linaro.org, Arnd Bergmann , Ralf Baechle , Paul Burton , James Hogan , Greg Kroah-Hartman , Masahiro Yamada , Matt Redfearn , David Daney , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] rtc: mips: default to rtc-cmos on mips Date: Mon, 27 Aug 2018 22:03:08 +0200 Message-Id: <20180827200338.220211-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:4+MfkGX8EpaKqKEPEiV8v+YbGtFRfp0teaMnyqe8y2PMHhf1Ki/ s9xlBiB8J+Jec+TxcvZIH0ClHYWNgG+jMuLWw0d0K7dr/TN8wbDgcWjcaNglLjksHaTqfGr tmFcwyiZjRM4Y6/qVgpURiZWz+xBvT2BSFGnOiPWCb9CdeKzSJrWahOXirntyIdDpU1xi8l gUFfGFm93+IlQrkX5cGfg== X-UI-Out-Filterresults: notjunk:1; V01:K0:haLpucbZYLU=:JJZ4zlHDF4o/52I49b/Q/B niujBBc5eyg5xVtJalJ6ReoBAK4OU3WIka+Yu7HFTmupJWVVPUcTOe1ADueYkXoPLNvkXiUCg nYKl+HzM5bMOMYBf1U8Zzbp2zaXGF5+twFpyqr2SRswC0Nl+dUWxXoZbVq+NsIKU11X/aPN4V TCTia0GTGYSApdwYD7vaSnhxFGryM9GFZ0DfmHKshw+NMpC18F2vmeu/YKDx6EEvQKaCLMKfk yoDUV3a1c5zuUebd6mnzXhbF3n4WFW8xwY3WzPTnuWXBzvQvxtpbjMDU8vsEwq8ldxKIO3cFv hsjeIyGo1jgeTT/cH7d9zOab8v/Iw668spaMw0frJk90l2xnlCzIhPAe+1CJRe2nH9poOdJyz Xa7Vg0z0y5wwGjm/lriy7Ioy2OufYmGSKXzGLYb3QND8B1JgYJ5BxzFwGccCXW5i2mUGLPua3 y1eADRPO62xbt1VB3pBtfJMb0khqepUibZz6N7dA/GWf000i22yHSeLvKgOqMfPpmtFIcILGK I3ZEOLKbFG+isuBBEy2WfcrzJ+4njbxYoZBI91xQZ+vr8kHp4t7XNJ5l1UlrcrKzWU4uF6m5l pXpXeV0nuAcKPRScE/HoxY7qaBlB6aTFoM9RhfI50HlRucJseP/DpEcuTHmIkCeFbKB9O2Ev+ vGi5HnyYdd4q6Va6uUPjEiAoXrAv3sHqyuJzGw6s3Jp4+HSxZ3A4Iqbbptr183Ycdlec= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The old rtc driver is getting in the way of some compat_ioctl simplification. Looking up the loongson64 git history, it seems that everyone uses the more modern but compatible RTC_CMOS driver anyway, so let's remove the special case for loongson64. Signed-off-by: Arnd Bergmann --- arch/mips/Kconfig | 2 +- drivers/char/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.18.0 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 35511999156a..c695825d9377 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -75,7 +75,7 @@ config MIPS select MODULES_USE_ELF_RELA if MODULES && 64BIT select MODULES_USE_ELF_REL if MODULES select PERF_USE_VMALLOC - select RTC_LIB if !MACH_LOONGSON64 + select RTC_LIB select SYSCTL_EXCEPTION_TRACE select VIRT_TO_BUS diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index ce277ee0a28a..131b4c300050 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -268,7 +268,7 @@ if RTC_LIB=n config RTC tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)" - depends on ALPHA || (MIPS && MACH_LOONGSON64) + depends on ALPHA ---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 Aug 27 20:03:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145215 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp348875ljw; Mon, 27 Aug 2018 13:04:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZY9dnP7AQxB1bKulubarbGI71706To1wOmRa8DnSaRwDzAJsbCCgbzjhqyT1antalPQE8r X-Received: by 2002:a62:7182:: with SMTP id m124-v6mr15652544pfc.73.1535400261215; Mon, 27 Aug 2018 13:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535400261; cv=none; d=google.com; s=arc-20160816; b=FBhDqkrWIysazxtyPm2LCFmUNrqge36nvDRj/Tn9Q1BS+YrY40vXFPwXmtQEDlgwjf I2B/pUjI1R+TKzGy1J3H6GIT1f7oZoyeG0M6h8/8j/3GmpS0NPK5EzN7vNgxNe5s8Bm3 +PI/jNfv08b4iDMrnlEJe/B5uNS++bMXKrx8GYKkcS+GgOaotJjru9akVcVMIBk+zJGK gtGiONB1qTAvfvpC8pid/ZmKEypESfBHximw2nGvtxiEJiCq8J46pzLcfPFUYxpXK546 fQSV9z4OgjoHFyKlt6jSteKszXoBBu3QjjtZBXNvaVmgw6ud7FRRT+IxO7b/Ki3Jto53 CjZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zzYntflC/2+sxiiqCawgtHVZxpkAgapCTnTjfWS9r8s=; b=GWGpdUJs/+LuhHGsJA/ABz9HqIXuad06++JZNL5cgbtjsahd6sv8jHgz0UwpyOU4SH tFqmSIVcyzAPUvro0XVw8SjSnpymNokqfCe7WBJoDrT+Etx+h0YPU++vLuOkxj8yZgqr bZi9+sFI6PHq6j6cF4ZBJTtPfQhIai0AUP1VNEcPZpyBchm9SjvJqAZwLqj/Th8JpoN5 5kD8DkXbLe8Ig8dXSviY0FezvGsOquCqVwbsQ9gQQ05s4i8qYHz5I2NHy8Xm8S7fi/Oh 2yGKutEDQoQ7+kS+9lt2VWb6yrnyLJMEr8V3tmTSW1JVYN+e68yS5NFqAA5dAiE6jbDT q/OQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h90-v6si160645plb.64.2018.08.27.13.04.20; Mon, 27 Aug 2018 13:04:21 -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 S1727479AbeH0XwX (ORCPT + 32 others); Mon, 27 Aug 2018 19:52:23 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:42364 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727011AbeH0XwX (ORCPT ); Mon, 27 Aug 2018 19:52:23 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0LthqL-1fkrfP30zt-011E7P; Mon, 27 Aug 2018 22:04:14 +0200 From: Arnd Bergmann To: linux-rtc@vger.kernel.org Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com, keguang.zhang@gmail.com, y2038@lists.linaro.org, Arnd Bergmann , Alexander Viro , Kees Cook , Andrew Morton , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] rtc: move compat_ioctl handling into rtc-dev.c Date: Mon, 27 Aug 2018 22:03:09 +0200 Message-Id: <20180827200338.220211-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827200338.220211-1-arnd@arndb.de> References: <20180827200338.220211-1-arnd@arndb.de> X-Provags-ID: V03:K1:HlLt/0RqtwSSa6ETfdZZQzZE1d5bBmV5dAbSM/dq1QQfDXuuMF2 8stp7k8tw8S5/k/NQwLZ7yOkdhfGh3pIUcAe5t7Lh4k+j7+5EGAdwejdCCrhJ6kJC7ODQGg BlQTGiMyPrlTSXgXgoem8/esWegzJ21AL7z7LVpDXj61zKbpigonx5zLeug1cG3GjyZKPQL zE1nD/LSgCZFtbpvqK9NQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:1HP3eqmnmJc=:1ylCxVqxTu2KYUNMU4XaDt /db9J0+fbprd+7vJCw6losvJDHeHcuK74mCt7dNCpj5W7o5AeTEEUWreU7IW2Q512LjsDqD1U wpbToOrJhYoBKw38cp8fqznnciUdPnV3tGCDMrY23wqYAAzPRmXuaN5Nh32poTHyOkY5Fkpo/ RybySZDKchF/RqvGjQ6ZF1fQmOpDDm7EAq7h+J6g9jO0gx1IDwl0unTXXNTGhh2hB43oBQnsY rPALXCZq0CHheSUKe5eaiqKbr8Mv1ssKp1G5DMfzolsFJtlEpMz71IjSrOiPa9oCynvdwHKZY h7Zdq8goEYWetQqHSVay50jHGBxXf3sHS7vOfTjCTln0UQFSRQXmY6MW4gecprDj6BGn2JucF ZB7FE+61UDuQzJXzzBZ3TY3d6oJAJxboJ1SMRzSVsKAhOTukGN4qGu25DYwRRXuSzOibaHOis UOuKCeBFd5lmN0fEfsQve5/6P/Aglr3yeSpyvy32xPJe7MeJ23e91v5Cd4pc2F59Vr0MQeUA0 actyj88ncbkddonRdsrXWjH+fDgqtW+Abk4MbY/BJDk3F5fBM7a3PimnrSd0yzyy8dIGZFCCe WsxJfvQVu2g8h5xOpFb9D3YVnXkOT2/n5HgXnu0H7HocrAXzdTOK1cdZrTV3hKotyi4lPF4SC bLBVVVZ3/1DeE6o6sAS+NNGpt6CtdILF3T3iFpJKLfqqOHeZo5f/aBXjZNphC2eFfIMM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We no longer need the rtc compat handling to be in common code, now that all drivers are either moved to the rtc-class framework, or (rarely) exist in drivers/char for architectures without compat mode (m68k, alpha and ia64, respectively). I checked the list of ioctl commands in drivers, and the ones that are not already handled are all compatible, again with the one exception of m68k driver, which implements RTC_PLL_GET and RTC_PLL_SET, but has no compat mode. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-dev.c | 50 +++++++++++++++++++++++++++++++++++++++ fs/compat_ioctl.c | 54 ------------------------------------------- 2 files changed, 50 insertions(+), 54 deletions(-) -- 2.18.0 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 43d962a9c210..50b03e175263 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c @@ -13,6 +13,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -405,6 +406,52 @@ static long rtc_dev_ioctl(struct file *file, return err; } +#ifdef CONFIG_COMPAT +#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) +#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) +#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) +#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) + +static long rtc_dev_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) +{ + unsigned long __user *valp; + compat_ulong_t __user *argp = compat_ptr(arg); + unsigned long val; + int ret; + + switch (cmd) { + /* pointer to 'long' needs translation. */ + case RTC_IRQP_READ32: + case RTC_EPOCH_READ32: { + valp = compat_alloc_user_space(sizeof(*valp)); + if (valp == NULL) + return -EFAULT; + ret = rtc_dev_ioctl(file, (cmd == RTC_IRQP_READ32) ? + RTC_IRQP_READ : RTC_EPOCH_READ, + (unsigned long)valp); + if (ret) + return ret; + if (get_user(val, valp) || put_user(val, argp)) + return -EFAULT; + return 0; + } + + /* arguments are compatible, command number is not */ + case RTC_IRQP_SET32: + return rtc_dev_ioctl(file, RTC_IRQP_SET, arg); + case RTC_EPOCH_SET32: + return rtc_dev_ioctl(file, RTC_EPOCH_SET, arg); + } + + /* + * all other rtc ioctls are compatible, or only + * exist on architectures without compat mode + */ + + return rtc_dev_ioctl(file, cmd, (unsigned long)argp); +} +#endif + static int rtc_dev_fasync(int fd, struct file *file, int on) { struct rtc_device *rtc = file->private_data; @@ -439,6 +486,9 @@ static const struct file_operations rtc_dev_fops = { .read = rtc_dev_read, .poll = rtc_dev_poll, .unlocked_ioctl = rtc_dev_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = rtc_dev_compat_ioctl, +#endif .open = rtc_dev_open, .release = rtc_dev_release, .fasync = rtc_dev_fasync, diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a9b00942e87d..a5c86a2fa8e6 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -623,37 +622,6 @@ static int serial_struct_ioctl(struct file *file, return err; } -#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) -#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) -#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) -#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) - -static int rtc_ioctl(struct file *file, - unsigned cmd, void __user *argp) -{ - unsigned long __user *valp = compat_alloc_user_space(sizeof(*valp)); - int ret; - - if (valp == NULL) - return -EFAULT; - switch (cmd) { - case RTC_IRQP_READ32: - case RTC_EPOCH_READ32: - ret = do_ioctl(file, (cmd == RTC_IRQP_READ32) ? - RTC_IRQP_READ : RTC_EPOCH_READ, - (unsigned long)valp); - if (ret) - return ret; - return convert_in_user(valp, (unsigned int __user *)argp); - case RTC_IRQP_SET32: - return do_ioctl(file, RTC_IRQP_SET, (unsigned long)argp); - case RTC_EPOCH_SET32: - return do_ioctl(file, RTC_EPOCH_SET, (unsigned long)argp); - } - - return -ENOIOCTLCMD; -} - /* on ia32 l_start is on a 32-bit boundary */ #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) struct space_resv_32 { @@ -806,21 +774,6 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) /* Big V (don't complain on serial console) */ IGNORE_IOCTL(VT_OPENQRY) IGNORE_IOCTL(VT_GETMODE) -/* Little p (/dev/rtc, /dev/envctrl, etc.) */ -COMPATIBLE_IOCTL(RTC_AIE_ON) -COMPATIBLE_IOCTL(RTC_AIE_OFF) -COMPATIBLE_IOCTL(RTC_UIE_ON) -COMPATIBLE_IOCTL(RTC_UIE_OFF) -COMPATIBLE_IOCTL(RTC_PIE_ON) -COMPATIBLE_IOCTL(RTC_PIE_OFF) -COMPATIBLE_IOCTL(RTC_WIE_ON) -COMPATIBLE_IOCTL(RTC_WIE_OFF) -COMPATIBLE_IOCTL(RTC_ALM_SET) -COMPATIBLE_IOCTL(RTC_ALM_READ) -COMPATIBLE_IOCTL(RTC_RD_TIME) -COMPATIBLE_IOCTL(RTC_SET_TIME) -COMPATIBLE_IOCTL(RTC_WKALM_SET) -COMPATIBLE_IOCTL(RTC_WKALM_RD) /* * These two are only for the sbus rtc driver, but * hwclock tries them on every rtc device first when @@ -1297,13 +1250,6 @@ static long do_ioctl_trans(unsigned int cmd, case TIOCGSERIAL: case TIOCSSERIAL: return serial_struct_ioctl(file, cmd, argp); - /* Not implemented in the native kernel */ - case RTC_IRQP_READ32: - case RTC_IRQP_SET32: - case RTC_EPOCH_READ32: - case RTC_EPOCH_SET32: - return rtc_ioctl(file, cmd, argp); - /* dvb */ case VIDEO_GET_EVENT: return do_video_get_event(file, cmd, argp);