diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-10-29 17:04:10 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-10-29 17:14:18 -0700 |
commit | 9e085dd069d5d868cca7ae92b610c678c170ac92 (patch) | |
tree | 96ae6fc4bc6eaa45204490d141c3b5c2b6eef85a /drivers/input | |
parent | 5d96738d9a74ec774bc7408288b44a7db6321c47 (diff) |
Input: sgi_btns - switch to using managed resources
Switching to devm API allows to clean up error handling paths and drop
the remove() method.
Link: https://lore.kernel.org/r/20191017204217.106453-14-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/misc/sgi_btns.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c index 0fee6ddf3602..829277b4271f 100644 --- a/drivers/input/misc/sgi_btns.c +++ b/drivers/input/misc/sgi_btns.c @@ -45,7 +45,6 @@ static const unsigned short sgi_map[] = { }; struct buttons_dev { - struct input_polled_dev *poll_dev; unsigned short keymap[ARRAY_SIZE(sgi_map)]; int count[ARRAY_SIZE(sgi_map)]; }; @@ -84,12 +83,13 @@ static int sgi_buttons_probe(struct platform_device *pdev) struct input_dev *input; int error, i; - bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL); - poll_dev = input_allocate_polled_device(); - if (!bdev || !poll_dev) { - error = -ENOMEM; - goto err_free_mem; - } + bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); + if (!bdev) + return -ENOMEM; + + poll_dev = devm_input_allocate_polled_device(&pdev->dev); + if (!poll_dev) + return -ENOMEM; memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap)); @@ -101,7 +101,6 @@ static int sgi_buttons_probe(struct platform_device *pdev) input->name = "SGI buttons"; input->phys = "sgi/input0"; input->id.bustype = BUS_HOST; - input->dev.parent = &pdev->dev; input->keycode = bdev->keymap; input->keycodemax = ARRAY_SIZE(bdev->keymap); @@ -113,35 +112,15 @@ static int sgi_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - bdev->poll_dev = poll_dev; - platform_set_drvdata(pdev, bdev); - error = input_register_polled_device(poll_dev); if (error) - goto err_free_mem; - - return 0; - - err_free_mem: - input_free_polled_device(poll_dev); - kfree(bdev); - return error; -} - -static int sgi_buttons_remove(struct platform_device *pdev) -{ - struct buttons_dev *bdev = platform_get_drvdata(pdev); - - input_unregister_polled_device(bdev->poll_dev); - input_free_polled_device(bdev->poll_dev); - kfree(bdev); + return error; return 0; } static struct platform_driver sgi_buttons_driver = { .probe = sgi_buttons_probe, - .remove = sgi_buttons_remove, .driver = { .name = "sgibtns", }, |