public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Paul Fulghum <paulkf@microgate.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tty add compat_ioctl method
Date: Wed, 2 May 2007 23:55:38 +0200	[thread overview]
Message-ID: <200705022355.38975.arnd@arndb.de> (raw)
In-Reply-To: <1178128321.9430.14.camel@amdx2.microgate.com>

On Wednesday 02 May 2007, Paul Fulghum wrote:
> Add compat_ioctl method for tty code to allow processing
> of 32 bit ioctl calls on 64 bit systems by tty core,
> tty drivers, and line disciplines.

Looks ok mostly. Just some details:

> --- a/include/linux/tty_driver.h	2006-11-29 15:57:37.000000000 -0600
> +++ b/include/linux/tty_driver.h	2007-04-30 14:05:02.000000000 -0500
> @@ -132,6 +132,10 @@ struct tty_operations {
>  	int  (*chars_in_buffer)(struct tty_struct *tty);
>  	int  (*ioctl)(struct tty_struct *tty, struct file * file,
>  		    unsigned int cmd, unsigned long arg);
> +#ifdef CONFIG_COMPAT
> +	long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
> +			     unsigned int cmd, unsigned long arg);
> +#endif
>  	void (*set_termios)(struct tty_struct *tty, struct termios * old);
>  	void (*throttle)(struct tty_struct * tty);
>  	void (*unthrottle)(struct tty_struct * tty);
> @@ -193,6 +197,10 @@ struct tty_driver {
>  	int  (*chars_in_buffer)(struct tty_struct *tty);
>  	int  (*ioctl)(struct tty_struct *tty, struct file * file,
>  		    unsigned int cmd, unsigned long arg);
> +#ifdef CONFIG_COMPAT
> +	long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
> +			     unsigned int cmd, unsigned long arg);
> +#endif
>  	void (*set_termios)(struct tty_struct *tty, struct termios * old);
>  	void (*throttle)(struct tty_struct * tty);
>  	void (*unthrottle)(struct tty_struct * tty);

I wouldn't hide this inside of an #ifdef. The structures are all static
and therefore a single field per driver doesn't add much bload, but
being able to always assign the .compat_ioctl pointer makes the code
somewhat nicer

> --- a/drivers/char/tty_io.c	2006-11-29 15:57:37.000000000 -0600
> +++ b/drivers/char/tty_io.c	2007-04-30 14:51:01.000000000 -0500
> @@ -151,6 +151,9 @@ static int tty_open(struct inode *, stru
>  static int tty_release(struct inode *, struct file *);
>  int tty_ioctl(struct inode * inode, struct file * file,
>  	      unsigned int cmd, unsigned long arg);
> +#ifdef CONFIG_COMPAT
> +long tty_compat_ioctl(struct file * file, unsigned int cmd, unsigned long arg);
> +#endif
>  static int tty_fasync(int fd, struct file * filp, int on);
>  static void release_mem(struct tty_struct *tty, int idx);

declarations should never be hidden inside of an #ifdef. If you want to be
extra clever here, you can do

#ifdef CONFIG_COMPAT
long tty_compat_ioctl(struct file * file, unsigned int cmd, unsigned long arg);
#else
#define tty_compat_ioctl NULL
#endif

then you don't need an #ifdef in the code setting the function pointers.

> @@ -3284,6 +3299,32 @@ int tty_ioctl(struct inode * inode, stru
>  	return retval;
>  }
>  
> +#ifdef CONFIG_COMPAT
> +long tty_compat_ioctl(struct file * file, unsigned int cmd, unsigned long arg)
> +{
> +	struct inode *inode = file->f_dentry->d_inode;
> +	struct tty_struct *tty;
> +	struct tty_ldisc *ld;
> +	int retval = -ENOIOCTLCMD;
> +
> +	tty = (struct tty_struct *)file->private_data;

no need for the cast, ->private_data is void*.

	Arnd <><

  reply	other threads:[~2007-05-02 21:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26 20:51 compat_ioctl question Paul Fulghum
2007-04-26 21:37 ` Arnd Bergmann
2007-04-26 22:42   ` Paul Fulghum
2007-04-26 22:08     ` Arnd Bergmann
2007-04-26 23:15       ` Paul Fulghum
2007-05-02 17:52       ` [PATCH] tty add compat_ioctl method Paul Fulghum
2007-05-02 21:55         ` Arnd Bergmann [this message]
2007-05-02 23:03           ` Paul Fulghum
2007-05-02 22:28             ` Arnd Bergmann
2007-04-27  0:38 ` compat_ioctl question Andi Kleen

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=200705022355.38975.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulkf@microgate.com \
    /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