All of lore.kernel.org
 help / color / mirror / Atom feed
* input.c: start on release
@ 2007-02-23  5:29 Pete Zaitcev
  2007-02-23 15:06 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Pete Zaitcev @ 2007-02-23  5:29 UTC (permalink / raw)
  To: dtor; +Cc: linux-kernel

Here's a curious code I found in drivers/input/input.c (2.6.21-rc1):

void input_release_device(struct input_handle *handle)
{
....
	if (handle->handler->start)
		handle->handler->start(handle);
}

Is the above supposed to be this way, or you meant ->stop here?

The commit comment says:
	Input: fix list iteration in input_release_device()
It says me precisely nothing about the way it's supposed ot be, sorry...

-- Pete

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: input.c: start on release
  2007-02-23  5:29 input.c: start on release Pete Zaitcev
@ 2007-02-23 15:06 ` Dmitry Torokhov
  2007-02-24  0:44   ` Pete Zaitcev
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2007-02-23 15:06 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel

On 2/23/07, Pete Zaitcev <zaitcev@redhat.com> wrote:
> Here's a curious code I found in drivers/input/input.c (2.6.21-rc1):
>
> void input_release_device(struct input_handle *handle)
> {
> ....
>        if (handle->handler->start)
>                handle->handler->start(handle);
> }
>
> Is the above supposed to be this way, or you meant ->stop here?

It should be ->start(). You are probably confused a little by the name
of the function. input_release_device() is called when userspace
issues ioctl(fd, EVIOCGRAB, 0) releasing (or ungrabbing) the device
(as opposed to xxx_release(file, inode) type functions that are called
when last user of a file drops off). In our case we want to give
handlers a chance to resume their control over device. Right now
standard keyboard driver uses start method do bring back in sync LED
state of a keyborad-like device after it was released (ungrabbed).

>
> The commit comment says:
>        Input: fix list iteration in input_release_device()
> It says me precisely nothing about the way it's supposed ot be, sorry...
>

It reason for ->start was explained in the patch it was introduced in,
the changeset you are referring to literally fixes issue with
iteration through list in this function.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: input.c: start on release
  2007-02-23 15:06 ` Dmitry Torokhov
@ 2007-02-24  0:44   ` Pete Zaitcev
  2007-02-24 16:57     ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Pete Zaitcev @ 2007-02-24  0:44 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, zaitcev

On Fri, 23 Feb 2007 10:06:14 -0500, "Dmitry Torokhov" <dmitry.torokhov@gmail.com> wrote:
> On 2/23/07, Pete Zaitcev <zaitcev@redhat.com> wrote:

> > void input_release_device(struct input_handle *handle)
> > {
> > ....
> >        if (handle->handler->start)
> >                handle->handler->start(handle);

> It should be ->start(). You are probably confused a little by the name
> of the function. input_release_device() is called when userspace
> issues ioctl(fd, EVIOCGRAB, 0) releasing (or ungrabbing) the device
> (as opposed to xxx_release(file, inode) type functions that are called
> when last user of a file drops off). In our case we want to give
> handlers a chance to resume their control over device. Right now
> standard keyboard driver uses start method do bring back in sync LED
> state of a keyborad-like device after it was released (ungrabbed).

Thanks for the explanation. I suspect people asked you 100 times before.
I can see why we would want to do this when a grab ends, but why do
we do this on every close of /dev/input/mice? The call path is:

 mousedev_release ->
 mixdev_release (optional for some majors)
 input_close_device ->
 input_release_device

Same thing happens upon disconnect, though this is probably harmless,
as the device is gone already anyway.

To tell you the truth, all I really want is to hold a static mutex
across a call to input_close_device(). Can I do that?

-- Pete

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: input.c: start on release
  2007-02-24  0:44   ` Pete Zaitcev
@ 2007-02-24 16:57     ` Dmitry Torokhov
  2007-02-24 19:27       ` Pete Zaitcev
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2007-02-24 16:57 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel

On Friday 23 February 2007 19:44, Pete Zaitcev wrote:
> On Fri, 23 Feb 2007 10:06:14 -0500, "Dmitry Torokhov" <dmitry.torokhov@gmail.com> wrote:
> > On 2/23/07, Pete Zaitcev <zaitcev@redhat.com> wrote:
> 
> > > void input_release_device(struct input_handle *handle)
> > > {
> > > ....
> > >        if (handle->handler->start)
> > >                handle->handler->start(handle);
> 
> > It should be ->start(). You are probably confused a little by the name
> > of the function. input_release_device() is called when userspace
> > issues ioctl(fd, EVIOCGRAB, 0) releasing (or ungrabbing) the device
> > (as opposed to xxx_release(file, inode) type functions that are called
> > when last user of a file drops off). In our case we want to give
> > handlers a chance to resume their control over device. Right now
> > standard keyboard driver uses start method do bring back in sync LED
> > state of a keyborad-like device after it was released (ungrabbed).
> 
> Thanks for the explanation. I suspect people asked you 100 times before.
> I can see why we would want to do this when a grab ends, but why do
> we do this on every close of /dev/input/mice? The call path is:
> 
>  mousedev_release ->
>  mixdev_release (optional for some majors)
>  input_close_device ->
>  input_release_device
>

The actual work withing input_release_device happens only when called
for handle that grabbed the device earlier. The reason why we call it
when closing a device so that device is not left in grabbed state if
userspace forgot to release it voluntarily.
 
> Same thing happens upon disconnect, though this is probably harmless,
> as the device is gone already anyway.
> 
> To tell you the truth, all I really want is to hold a static mutex
> across a call to input_close_device(). Can I do that?

Are you trying to fix locking in mousedev?

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: input.c: start on release
  2007-02-24 16:57     ` Dmitry Torokhov
@ 2007-02-24 19:27       ` Pete Zaitcev
  0 siblings, 0 replies; 5+ messages in thread
From: Pete Zaitcev @ 2007-02-24 19:27 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, zaitcev

On Sat, 24 Feb 2007 11:57:07 -0500, Dmitry Torokhov <dtor@insightbb.com> wrote:

> > To tell you the truth, all I really want is to hold a static mutex
> > across a call to input_close_device(). Can I do that?
> 
> Are you trying to fix locking in mousedev?

Yes.

-- Pete

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-02-24 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-23  5:29 input.c: start on release Pete Zaitcev
2007-02-23 15:06 ` Dmitry Torokhov
2007-02-24  0:44   ` Pete Zaitcev
2007-02-24 16:57     ` Dmitry Torokhov
2007-02-24 19:27       ` Pete Zaitcev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.