From 358a89ca2c9680ceddc219ab25d1583619e9159f Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Fri, 17 Mar 2017 12:48:11 -0600 Subject: 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 Acked-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/evdev.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/input/evdev.c') 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) evdev_mark_dead(evdev); evdev_hangup(evdev); - cdev_del(&evdev->cdev); - /* evdev is marked dead so no one else accesses evdev->open */ if (evdev->open) { input_flush_device(handle, NULL); @@ -1416,12 +1414,8 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, goto err_free_evdev; cdev_init(&evdev->cdev, &evdev_fops); - evdev->cdev.kobj.parent = &evdev->dev.kobj; - error = cdev_add(&evdev->cdev, evdev->dev.devt, 1); - if (error) - goto err_unregister_handle; - error = device_add(&evdev->dev); + error = cdev_device_add(&evdev->cdev, &evdev->dev); if (error) goto err_cleanup_evdev; @@ -1429,7 +1423,6 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, err_cleanup_evdev: evdev_cleanup(evdev); - err_unregister_handle: input_unregister_handle(&evdev->handle); err_free_evdev: put_device(&evdev->dev); @@ -1442,7 +1435,7 @@ static void evdev_disconnect(struct input_handle *handle) { struct evdev *evdev = handle->private; - device_del(&evdev->dev); + cdev_device_del(&evdev->cdev, &evdev->dev); evdev_cleanup(evdev); input_free_minor(MINOR(evdev->dev.devt)); input_unregister_handle(handle); -- cgit