[PATCH:xf86-input-keyboard] Close device fd when called with DEVICE_CLOSE

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 12 21:30:20 PDT 2010


On Thu, Aug 12, 2010 at 08:24:12PM -0700, Alan Coopersmith wrote:
> Peter Hutterer wrote:
> > On Wed, Aug 11, 2010 at 07:54:59PM -0700, Alan Coopersmith wrote:
> >> From: Aaron Zang <aaron.zang at sun.com>
> >>
> >> Fixes Solaris bug 6886424:
> >>  VT - keyboard and mouse do not work when switching to vt7
> >>  http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6886424
> >>
> >> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> >> ---
> >>  src/kbd.c |    8 ++++++++
> >>  1 files changed, 8 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/src/kbd.c b/src/kbd.c
> >> index 96409cf..991fe01 100644
> >> --- a/src/kbd.c
> >> +++ b/src/kbd.c
> >> @@ -464,6 +464,14 @@ KbdProc(DeviceIntPtr device, int what)
> >>        RemoveEnabledDevice(pInfo->fd);
> >>      pKbd->KbdOff(pInfo, what);
> >>      device->public.on = FALSE;
> >> +
> >> +    if (what == DEVICE_CLOSE) {
> >> +	xf86Msg(X_INFO, "%s: Close\n", pInfo->name);
> >> +	if (pInfo->fd != -1) {
> >> +	    close(pInfo->fd);
> >> +	    pInfo->fd = -1;
> >> +	}
> >> +    }
> >>      break;
> >>    }
> >>    return (Success);
> >> -- 
> >> 1.5.6.5
> > 
> > shouldn't this be DEVICE_OFF instead? DEVICE_CLOSE is called when the device
> > is removed, DEVICE_OFF when it is disabled (e.g. on VT switch).
> > Also, it looks like you could simply merge this into the DEVICE_OFF branch
> > and make DEVICE_CLOSE a noop.
> 
> On Solaris at least, the intent is to only close it on DEVICE_CLOSE, and just
> disable it on DEVICE_OFF, as that's the way our kernel VT interfaces expect us
> to handle it.   If that's not what other OS'es expect, then I can move this into
> sun_kbd.c instead.

Well, it looks messy enough as it is. AFAICT, the fd is never closed on any
OS. and since keyboard is essentially obsolete on linux, I'm happy enough
with your intent.

Acked-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter


More information about the xorg-devel mailing list