LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Bernhard Walle <walle@corscience.de>
Cc: dbrownell@users.sourceforge.net,
	spi-devel-general@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	arnd@arndb.de
Subject: Re: [PATCH] spi: spidev: Add 32 bit compat ioctl()
Date: Wed, 2 Feb 2011 07:15:12 -0700	[thread overview]
Message-ID: <AANLkTikbXYxyUmBsPNO6mxB2x_4Qr49BQZTKrqvsiK8a@mail.gmail.com> (raw)
In-Reply-To: <1296646296-31843-1-git-send-email-walle@corscience.de>

On Wed, Feb 2, 2011 at 4:31 AM, Bernhard Walle <walle@corscience.de> wrote:
> Add the compat_ioctl for operations on /dev/spi* so that 32 bit
> userspace applications can access SPI. As far as I can see all data
> structure are already prepared for that, so no additional conversion has
> to be done.
>
> My use case is MIPS with N32 userspace ABI and toolchain, and that was
> also the platform where I tested it successfully (Cavium Octeon).
>
> Signed-off-by: Bernhard Walle <walle@corscience.de>
> ---
>  drivers/spi/spidev.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
> index 4e6245e..f80503b 100644
> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -30,6 +30,7 @@
>  #include <linux/errno.h>
>  #include <linux/mutex.h>
>  #include <linux/slab.h>
> +#include <linux/compat.h>
>
>  #include <linux/spi/spi.h>
>  #include <linux/spi/spidev.h>
> @@ -471,6 +472,14 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>        return retval;
>  }
>
> +#ifdef CONFIG_COMPAT
> +static long
> +spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> +{
> +       return spidev_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
> +}
> +#endif /* CONFIG_COMPAT */

If you do the following...
+#else /* CONFIG_COMPAT */
+#define spidev_compat_ioctl NULL
+#endif /* CONFIG_COMPAT */

> +
>  static int spidev_open(struct inode *inode, struct file *filp)
>  {
>        struct spidev_data      *spidev;
> @@ -543,6 +552,9 @@ static const struct file_operations spidev_fops = {
>        .write =        spidev_write,
>        .read =         spidev_read,
>        .unlocked_ioctl = spidev_ioctl,
> +#ifdef CONFIG_COMPAT
> +       .compat_ioctl = spidev_compat_ioctl,
> +#endif

Then the #ifdef/#endif can be dropped here which is tidier.

g.

>        .open =         spidev_open,
>        .release =      spidev_release,
>        .llseek =       no_llseek,
> --
> 1.7.1
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  parent reply	other threads:[~2011-02-02 14:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 11:31 Bernhard Walle
2011-02-02 12:18 ` Arnd Bergmann
2011-02-02 14:15 ` Grant Likely [this message]
2011-02-03  8:38   ` Bernhard Walle
  -- strict thread matches above, loose matches on Subject: below --
2011-02-03  8:37 Bernhard Walle
2011-02-03 16:56 ` Grant Likely
2011-02-02 11:30 Bernhard Walle
2011-02-02 10:57 Bernhard Walle
2011-02-02 11:15 ` Arnd Bergmann
2011-02-02 11:32   ` Bernhard Walle
2011-02-02 10:56 y
2011-02-01  9:02 Bernhard Walle
2011-02-02  4:39 ` Grant Likely
2011-02-02  9:37   ` Arnd Bergmann
2011-02-02 10:56     ` Bernhard Walle
2011-02-02 14:12     ` Grant Likely
2011-01-11 15:32 Bernhard Walle
2010-12-01 10:51 Bernhard Walle

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=AANLkTikbXYxyUmBsPNO6mxB2x_4Qr49BQZTKrqvsiK8a@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    --cc=walle@corscience.de \
    --subject='Re: [PATCH] spi: spidev: Add 32 bit compat ioctl()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).