From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Allison Randal <allison@lohutok.net>,
Jilayne Lovejoy <opensource@jilayne.com>,
Steve Winslow <swinslow@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 13/22] Input: sgi_btns - switch to using managed resources
Date: Thu, 17 Oct 2019 13:42:07 -0700 [thread overview]
Message-ID: <20191017204217.106453-14-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com>
Switching to devm API allows to clean up error handling paths and drop
the remove() method.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/misc/sgi_btns.c | 37 ++++++++---------------------------
1 file 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",
},
--
2.23.0.866.gb869b98d4c-goog
next prev parent reply other threads:[~2019-10-17 20:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 20:41 [PATCH 00/22] Stop using input_polled_dev in polling drivers Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 01/22] Input: raspberrypi-ts - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 02/22] Input: sur40 " Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 03/22] Input: ts4800-ts " Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 04/22] Input: tsc6507x-ts " Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 05/22] Input: adc-keys " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 06/22] Input: clps711x-keypad " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 07/22] Input: jornada680_kbd " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 08/22] Input: gpio_keys_polled " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 09/22] Input: apanel " Dmitry Torokhov
2019-10-21 20:05 ` Sven Van Asbroeck
2019-10-21 21:27 ` Dmitry Torokhov
2019-10-22 13:21 ` Sven Van Asbroeck
2019-10-17 20:42 ` [PATCH 10/22] Input: wistron_btns " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 11/22] Input: cobalt_btns - convert to use managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 12/22] Input: cobalt_btns - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` Dmitry Torokhov [this message]
2019-10-17 20:42 ` [PATCH 14/22] Input: sgi_btns " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 15/22] Input: rb532_button - switch to using managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 16/22] Input: rb532_button - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 17/22] Input: gpio_decoder " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 18/22] Input: mma8450 " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 19/22] Input: bma150 - use managed resources helpers Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 20/22] Input: bma150 - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 21/22] Input: kxtj9 - switch to using managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 22/22] Input: kxtj9 - switch to using polled mode of input devices Dmitry Torokhov
2019-10-18 8:44 ` [PATCH 00/22] Stop using input_polled_dev in polling drivers Andy Shevchenko
2019-10-21 8:03 ` Marco Felsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191017204217.106453-14-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=allison@lohutok.net \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource@jilayne.com \
--cc=swinslow@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).