Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/dtor/input

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: make sure input interfaces pin parent input devices
  Input: apm-power - fix crash when unloading modules
  Input: pxa27x - fix keypad KPC macros
  • Loading branch information
torvalds committed Apr 1, 2008
2 parents 7731ce6 + a7097ff commit 3344203
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
7 changes: 2 additions & 5 deletions drivers/input/apm-power.c
Expand Up @@ -63,8 +63,6 @@ static int apmpower_connect(struct input_handler *handler,
handle->handler = handler;
handle->name = "apm-power";

handler->private = handle;

error = input_register_handle(handle);
if (error) {
printk(KERN_ERR
Expand All @@ -87,11 +85,10 @@ static int apmpower_connect(struct input_handler *handler,
return 0;
}

static void apmpower_disconnect(struct input_handle *handler)
static void apmpower_disconnect(struct input_handle *handle)
{
struct input_handle *handle = handler->private;

input_close_device(handle);
input_unregister_handle(handle);
kfree(handle);
}

Expand Down
6 changes: 2 additions & 4 deletions drivers/input/evdev.c
Expand Up @@ -124,6 +124,7 @@ static void evdev_free(struct device *dev)
{
struct evdev *evdev = container_of(dev, struct evdev, dev);

input_put_device(evdev->handle.dev);
kfree(evdev);
}

Expand Down Expand Up @@ -853,9 +854,6 @@ static void evdev_cleanup(struct evdev *evdev)
evdev_hangup(evdev);
evdev_remove_chrdev(evdev);

if (evdev->grab)
evdev_ungrab(evdev, evdev->grab);

/* evdev is marked dead so no one else accesses evdev->open */
if (evdev->open) {
input_flush_device(handle, NULL);
Expand Down Expand Up @@ -896,7 +894,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
evdev->exist = 1;
evdev->minor = minor;

evdev->handle.dev = dev;
evdev->handle.dev = input_get_device(dev);
evdev->handle.name = evdev->name;
evdev->handle.handler = handler;
evdev->handle.private = evdev;
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/joydev.c
Expand Up @@ -171,6 +171,7 @@ static void joydev_free(struct device *dev)
{
struct joydev *joydev = container_of(dev, struct joydev, dev);

input_put_device(joydev->handle.dev);
kfree(joydev);
}

Expand Down Expand Up @@ -750,7 +751,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
joydev->minor = minor;

joydev->exist = 1;
joydev->handle.dev = dev;
joydev->handle.dev = input_get_device(dev);
joydev->handle.name = joydev->name;
joydev->handle.handler = handler;
joydev->handle.private = joydev;
Expand Down
6 changes: 3 additions & 3 deletions drivers/input/keyboard/pxa27x_keypad.c
Expand Up @@ -50,9 +50,9 @@
#define KPKDI 0x0048

/* bit definitions */
#define KPC_MKRN(n) ((((n) & 0x7) - 1) << 26) /* matrix key row number */
#define KPC_MKCN(n) ((((n) & 0x7) - 1) << 23) /* matrix key column number */
#define KPC_DKN(n) ((((n) & 0x7) - 1) << 6) /* direct key number */
#define KPC_MKRN(n) ((((n) - 1) & 0x7) << 26) /* matrix key row number */
#define KPC_MKCN(n) ((((n) - 1) & 0x7) << 23) /* matrix key column number */
#define KPC_DKN(n) ((((n) - 1) & 0x7) << 6) /* direct key number */

#define KPC_AS (0x1 << 30) /* Automatic Scan bit */
#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/mousedev.c
Expand Up @@ -414,6 +414,7 @@ static void mousedev_free(struct device *dev)
{
struct mousedev *mousedev = container_of(dev, struct mousedev, dev);

input_put_device(mousedev->handle.dev);
kfree(mousedev);
}

Expand Down Expand Up @@ -865,7 +866,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,

mousedev->minor = minor;
mousedev->exist = 1;
mousedev->handle.dev = dev;
mousedev->handle.dev = input_get_device(dev);
mousedev->handle.name = mousedev->name;
mousedev->handle.handler = handler;
mousedev->handle.private = mousedev;
Expand Down
5 changes: 3 additions & 2 deletions include/linux/input.h
Expand Up @@ -1227,12 +1227,13 @@ void input_free_device(struct input_dev *dev);

static inline struct input_dev *input_get_device(struct input_dev *dev)
{
return to_input_dev(get_device(&dev->dev));
return dev ? to_input_dev(get_device(&dev->dev)) : NULL;
}

static inline void input_put_device(struct input_dev *dev)
{
put_device(&dev->dev);
if (dev)
put_device(&dev->dev);
}

static inline void *input_get_drvdata(struct input_dev *dev)
Expand Down

0 comments on commit 3344203

Please sign in to comment.