From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Arnd Bergmann <arnd@arndb.de>,
ALan Cox <alan@lxorguk.ukuu.org.uk>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [patch 2/7] m68k: Remove BKL from rtc implementations
Date: Sun, 7 Mar 2010 13:40:27 +0100 [thread overview]
Message-ID: <10f740e81003070440q3697c089o72ff9f3abcf9d293@mail.gmail.com> (raw)
In-Reply-To: <20091015083933.815963538@linutronix.de>
On Thu, Oct 15, 2009 at 09:42, Thomas Gleixner <tglx@linutronix.de> wrote:
> m68k does not support SMP. The access to the rtc is already serialized
> with local_irq_save/restore which is sufficient on UP.
>
> The open() protection in arch/m68k/mvme16x/rtc.c is not pretty but
> sufficient on UP and safe w/o the BKL.
>
> open() in arch/m68k/bvme6000/rtc.c can do with the same atomic logic
> as arch/m68k/mvme16x/rtc.c
Thx, applied.
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> arch/m68k/bvme6000/rtc.c | 29 +++++++++--------------------
> arch/m68k/mvme16x/rtc.c | 19 +++++--------------
> 2 files changed, 14 insertions(+), 34 deletions(-)
>
> Index: linux-2.6-tip/arch/m68k/bvme6000/rtc.c
> ===================================================================
> --- linux-2.6-tip.orig/arch/m68k/bvme6000/rtc.c
> +++ linux-2.6-tip/arch/m68k/bvme6000/rtc.c
> @@ -10,7 +10,6 @@
> #include <linux/errno.h>
> #include <linux/miscdevice.h>
> #include <linux/slab.h>
> -#include <linux/smp_lock.h>
> #include <linux/ioport.h>
> #include <linux/capability.h>
> #include <linux/fcntl.h>
> @@ -36,10 +35,9 @@
> static unsigned char days_in_mo[] =
> {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
>
> -static char rtc_status;
> +static atomic_t rtc_status = ATOMIC_INIT(1);
>
> -static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
> - unsigned long arg)
> +static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> {
> volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE;
> unsigned char msr;
> @@ -133,29 +131,20 @@ static int rtc_ioctl(struct inode *inode
> }
>
> /*
> - * 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.
> + * We enforce only one user at a time here with the open/close.
> */
> -
> static int rtc_open(struct inode *inode, struct file *file)
> {
> - lock_kernel();
> - if(rtc_status) {
> - unlock_kernel();
> + if (!atomic_dec_and_test(&rtc_status)) {
> + atomic_inc(&rtc_status);
> return -EBUSY;
> }
> -
> - rtc_status = 1;
> - unlock_kernel();
> return 0;
> }
>
> static int rtc_release(struct inode *inode, struct file *file)
> {
> - lock_kernel();
> - rtc_status = 0;
> - unlock_kernel();
> + atomic_inc(&rtc_status);
> return 0;
> }
>
> @@ -164,9 +153,9 @@ static int rtc_release(struct inode *ino
> */
>
> static const struct file_operations rtc_fops = {
> - .ioctl = rtc_ioctl,
> - .open = rtc_open,
> - .release = rtc_release,
> + .unlocked_ioctl = rtc_ioctl,
> + .open = rtc_open,
> + .release = rtc_release,
> };
>
> static struct miscdevice rtc_dev = {
> Index: linux-2.6-tip/arch/m68k/mvme16x/rtc.c
> ===================================================================
> --- linux-2.6-tip.orig/arch/m68k/mvme16x/rtc.c
> +++ linux-2.6-tip/arch/m68k/mvme16x/rtc.c
> @@ -10,7 +10,6 @@
> #include <linux/errno.h>
> #include <linux/miscdevice.h>
> #include <linux/slab.h>
> -#include <linux/smp_lock.h>
> #include <linux/ioport.h>
> #include <linux/capability.h>
> #include <linux/fcntl.h>
> @@ -37,8 +36,7 @@ static const unsigned char days_in_mo[]
>
> static atomic_t rtc_ready = ATOMIC_INIT(1);
>
> -static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
> - unsigned long arg)
> +static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> {
> volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE;
> unsigned long flags;
> @@ -121,22 +119,15 @@ static int rtc_ioctl(struct inode *inode
> }
>
> /*
> - * 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.
> + * We enforce only one user at a time here with the open/close.
> */
> -
> static int rtc_open(struct inode *inode, struct file *file)
> {
> - lock_kernel();
> if( !atomic_dec_and_test(&rtc_ready) )
> {
> atomic_inc( &rtc_ready );
> - unlock_kernel();
> return -EBUSY;
> }
> - unlock_kernel();
> -
> return 0;
> }
>
> @@ -151,9 +142,9 @@ static int rtc_release(struct inode *ino
> */
>
> static const struct file_operations rtc_fops = {
> - .ioctl = rtc_ioctl,
> - .open = rtc_open,
> - .release = rtc_release,
> + .unlocked_ioctl = rtc_ioctl,
> + .open = rtc_open,
> + .release = rtc_release,
> };
>
> static struct miscdevice rtc_dev=
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2010-03-07 12:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 8:42 [patch 0/7] BKL the next lot Thomas Gleixner
2009-10-15 8:42 ` [patch 1/7] ia64: Remove the BKL from perfmon Thomas Gleixner
2009-10-15 8:42 ` [patch 2/7] m68k: Remove BKL from rtc implementations Thomas Gleixner
2010-03-07 12:40 ` Geert Uytterhoeven [this message]
2009-10-15 8:42 ` [patch 3/7] powerpc: Use unlocked ioctl in nvram_64 Thomas Gleixner
2009-10-15 8:42 ` [patch 4/7] sh: Remove BKL from landisk gio Thomas Gleixner
2009-10-16 6:18 ` Paul Mundt
2009-10-15 8:42 ` [patch 5/7] um: Convert hostaudio to unlocked ioctl Thomas Gleixner
2009-10-15 8:42 ` [patch 6/7] um: Convert mmapper to unlocked_ioctl Thomas Gleixner
2009-10-15 13:00 ` Arnd Bergmann
2009-10-15 14:50 ` Thomas Gleixner
2009-10-15 15:29 ` Alan Cox
2009-10-16 19:42 ` Arnd Bergmann
2009-10-17 2:58 ` Thomas Gleixner
2009-10-15 8:42 ` [patch 7/7] um: Remove BKL from harddog Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10f740e81003070440q3697c089o72ff9f3abcf9d293@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arnd@arndb.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®