[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a1rkdMXGOt90SDhBkVvFeNsqdoMKQAu4nLfk_Eg+_CB6g@mail.gmail.com>
Date: Mon, 31 Dec 2018 13:16:19 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Finn Thain <fthain@...egraphics.com.au>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-m68k <linux-m68k@...ts.linux-m68k.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: [PATCH v8 18/25] powerpc: Implement nvram sync ioctl
On Sun, Dec 30, 2018 at 8:25 AM Finn Thain <fthain@...egraphics.com.au> wrote:
>
> On Sat, 29 Dec 2018, Arnd Bergmann wrote:
>
> > > --- a/drivers/char/nvram.c
> > > +++ b/drivers/char/nvram.c
> > > @@ -48,6 +48,10 @@
> > > #include <linux/mutex.h>
> > > #include <linux/pagemap.h>
> > >
> > > +#ifdef CONFIG_PPC
> > > +#include <asm/nvram.h>
> > > +#include <asm/machdep.h>
> > > +#endif
> > >
> > > static DEFINE_MUTEX(nvram_mutex);
> > > static DEFINE_SPINLOCK(nvram_state_lock);
> > > @@ -331,6 +335,37 @@ static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
> > > long ret = -ENOTTY;
> > >
> > > switch (cmd) {
> > > +#ifdef CONFIG_PPC
> > > + case OBSOLETE_PMAC_NVRAM_GET_OFFSET:
> > > + pr_warn("nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n");
> > > + /* fall through */
> > > + case IOC_NVRAM_GET_OFFSET:
> > > + ret = -EINVAL;
> > > +#ifdef CONFIG_PPC_PMAC
> >
> > I think it would make be nicer here to keep the ppc bits in arch/ppc,
> > and instead add a .ioctl() callback to nvram_ops.
> >
>
> The problem with having an nvram_ops.ioctl() method is the code in the
> !PPC branch. That code would get duplicated because it's needed by both
> X86 and M68K, to implement the checksum ioctls.
I was thinking you'd just have a common ioctl function that falls
back to the .ioctl callback for any unhandled commands like
switch (cmd) {
case NVRAM_INIT:
...
break;
case ...:
break;
default:
if (ops->ioctl)
return ops->ioctl(...);
return -EINVAL;
}
Would that work?
Arnd
Powered by blists - more mailing lists