aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2017-03-17 14:48:11 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-21 01:44:32 -0400
commit358a89ca2c9680ceddc219ab25d1583619e9159f (patch)
treec080239726f49d6341d58163b7e2c5e2b6555b26 /drivers/input/evdev.c
parent92a3fa075d3d2716b9c662814540f1d660cbf2f5 (diff)
input: utilize new cdev_device_add helper function
Replace the open coded registration of the cdev and dev with the new device_add_cdev() helper in evdev, joydev and mousedev. The helper replaces a common pattern by taking the proper reference against the parent device and adding both the cdev and the device. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r--drivers/input/evdev.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e9ae3d500a55..925571475005 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -1354,8 +1354,6 @@ static void evdev_cleanup(struct evdev *evdev)
1354 evdev_mark_dead(evdev); 1354 evdev_mark_dead(evdev);
1355 evdev_hangup(evdev); 1355 evdev_hangup(evdev);
1356 1356
1357 cdev_del(&evdev->cdev);
1358
1359 /* evdev is marked dead so no one else accesses evdev->open */ 1357 /* evdev is marked dead so no one else accesses evdev->open */
1360 if (evdev->open) { 1358 if (evdev->open) {
1361 input_flush_device(handle, NULL); 1359 input_flush_device(handle, NULL);
@@ -1416,12 +1414,8 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
1416 goto err_free_evdev; 1414 goto err_free_evdev;
1417 1415
1418 cdev_init(&evdev->cdev, &evdev_fops); 1416 cdev_init(&evdev->cdev, &evdev_fops);
1419 evdev->cdev.kobj.parent = &evdev->dev.kobj;
1420 error = cdev_add(&evdev->cdev, evdev->dev.devt, 1);
1421 if (error)
1422 goto err_unregister_handle;
1423 1417
1424 error = device_add(&evdev->dev); 1418 error = cdev_device_add(&evdev->cdev, &evdev->dev);
1425 if (error) 1419 if (error)
1426 goto err_cleanup_evdev; 1420 goto err_cleanup_evdev;
1427 1421
@@ -1429,7 +1423,6 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
1429 1423
1430 err_cleanup_evdev: 1424 err_cleanup_evdev:
1431 evdev_cleanup(evdev); 1425 evdev_cleanup(evdev);
1432 err_unregister_handle:
1433 input_unregister_handle(&evdev->handle); 1426 input_unregister_handle(&evdev->handle);
1434 err_free_evdev: 1427 err_free_evdev:
1435 put_device(&evdev->dev); 1428 put_device(&evdev->dev);
@@ -1442,7 +1435,7 @@ static void evdev_disconnect(struct input_handle *handle)
1442{ 1435{
1443 struct evdev *evdev = handle->private; 1436 struct evdev *evdev = handle->private;
1444 1437
1445 device_del(&evdev->dev); 1438 cdev_device_del(&evdev->cdev, &evdev->dev);
1446 evdev_cleanup(evdev); 1439 evdev_cleanup(evdev);
1447 input_free_minor(MINOR(evdev->dev.devt)); 1440 input_free_minor(MINOR(evdev->dev.devt));
1448 input_unregister_handle(handle); 1441 input_unregister_handle(handle);