public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: linux-kernel@vger.kernel.org, John Kacur <jkacur@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/6] sound/oss: convert to unlocked_ioctl
Date: Sun, 4 Jul 2010 22:52:29 +0200	[thread overview]
Message-ID: <201007042252.29997.arnd@arndb.de> (raw)
In-Reply-To: <20100704110835.GA31920@merkur.ravnborg.org>

On Sunday 04 July 2010 13:08:35 Sam Ravnborg wrote:
>
> General comment...
> In several places you declare a local variable of type "int",
> but the function return a long.
> 
> I know that mixdev_ioctl() return an int so nothing is lost but
> it just looks wrong.

This is completely intentional and follows what we have done in
lots of other drivers that are already converted the same way.

The idea is that it was a bad choice to make the 'unlocked_ioctl'
operation return 'long' in the first place. I remember Al
ranting about this a few years ago. The ioctl syscall always
returns an 'int' to user space, the only reason we have a
'long' return code in the definition of sys_ioctl and most
other syscalls is to avoid problems for 32 bit emulation
on some architectures.
 
Maybe one day someone will rename all unlocked_ioctl calls
back to ioctl and change the return type back to int.

> > diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
> > index 3f3c3f7..b5464fb 100644
> > --- a/sound/oss/dmasound/dmasound_core.c
> > +++ b/sound/oss/dmasound/dmasound_core.c
> > @@ -337,8 +337,8 @@ static int mixer_release(struct inode *inode, struct file *file)
> >  	unlock_kernel();
> >  	return 0;
> >  }
> > -static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd,
> > -		       u_long arg)
> > +
> > +static long mixer_ioctl(struct file *file, u_int cmd, u_long arg)
> >  {
> >  	if (_SIOC_DIR(cmd) & _SIOC_WRITE)
> >  	    mixer.modify_counter++;
> > @@ -362,11 +362,22 @@ static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd,
> >  	return -EINVAL;
> >  }
> >  
> > +static long mixer_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
> > +{
> > +	int ret;
> > +
> > +	lock_kernel();
> > +	ret = mixer_ioctl(file, cmd, arg);
> > +	unlock_kernel();
> > +
> > +	return ret;
> > +}
> 
> Here it looks like a potential but.
> mixer_ioctl() return a long which is stored in an int and then we return a long.

Right. I should probably have left the return value of mixer_ioctl as an int
instead, to follow the scheme used in other drivers.

	Arnd

  reply	other threads:[~2010-07-04 20:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-03 22:15 [PATCH 0/6] kill .ioctl file_operation Arnd Bergmann
2010-07-03 22:15 ` [PATCH 1/6] ia64/perfmon: convert to unlocked_ioctl Arnd Bergmann
2010-07-21 23:16   ` Frederic Weisbecker
2010-07-03 22:15 ` [PATCH 2/6] sound/oss: " Arnd Bergmann
2010-07-04 11:08   ` Sam Ravnborg
2010-07-04 20:52     ` Arnd Bergmann [this message]
2010-07-03 22:15 ` [PATCH 3/6] autofs/autofs4: move compat_ioctl handling into fs Arnd Bergmann
2010-07-05 19:24   ` Frederic Weisbecker
2010-07-05 19:42     ` H. Peter Anvin
2010-07-05 19:48       ` Frederic Weisbecker
2010-07-05 19:52         ` Arnd Bergmann
2010-07-05 19:58           ` Frederic Weisbecker
2010-07-05 20:12             ` H. Peter Anvin
2010-07-06  1:11             ` Ian Kent
2010-07-06 11:35               ` Arnd Bergmann
2010-07-06 13:17                 ` Ian Kent
2010-07-16  0:14                   ` Frederic Weisbecker
2010-07-16  4:40                     ` Ian Kent
2010-07-16 11:05                       ` Arnd Bergmann
2010-07-16 12:09                         ` Frederic Weisbecker
2010-07-03 22:15 ` [PATCH 4/6] cris: Pushdown the bkl from ioctl Arnd Bergmann
2010-07-30 17:08   ` Jesper Nilsson
2010-07-03 22:15 ` [PATCH 5/6] v4l: convert v4l2-dev to unlocked_ioctl Arnd Bergmann
2010-07-05 19:27   ` Frederic Weisbecker
2010-07-03 22:15 ` [PATCH 6/6] bkl: remove locked .ioctl file operation Arnd Bergmann

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=201007042252.29997.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=fweisbec@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sam@ravnborg.org \
    --cc=tiwai@suse.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