summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-zydacron.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2013-07-24 19:38:04 +0200
committerJiri Kosina <jkosina@suse.cz>2013-07-31 10:12:28 +0200
commitabf832bfc349b54fd500f1e3b612f7f3cd9dfcc6 (patch)
tree4ece0e75cf3fd463be58376e3f900c1cfd60dd05 /drivers/hid/hid-zydacron.c
parent3366dd9fa887ebbda4872e9554f853eaeda764be (diff)
HID: trivial devm conversion for special hid drivers
It is safe to use devres allocation within the hid subsystem: - the devres release is called _after_ the call to .remove(), meaning that no freed pointers will exists while removing the device - if a .probe() fails, devres releases all the allocated ressources before going to the next driver: there will not be ghost ressources attached to a hid device if several drivers are probed. Given that, we can clean up a little some of the HID drivers. These ones are trivial: - there is only one kzalloc in the driver - the .remove() callback contains only one kfree on top of hid_hw_stop() - the error path in the probe is easy enough to be manually checked Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-zydacron.c')
-rw-r--r--drivers/hid/hid-zydacron.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/hid/hid-zydacron.c b/drivers/hid/hid-zydacron.c
index e4cddeccd6b5..1a660bd97ab2 100644
--- a/drivers/hid/hid-zydacron.c
+++ b/drivers/hid/hid-zydacron.c
@@ -169,7 +169,7 @@ static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id)
int ret;
struct zc_device *zc;
- zc = kzalloc(sizeof(*zc), GFP_KERNEL);
+ zc = devm_kzalloc(&hdev->dev, sizeof(*zc), GFP_KERNEL);
if (zc == NULL) {
hid_err(hdev, "can't alloc descriptor\n");
return -ENOMEM;
@@ -180,28 +180,16 @@ static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id)
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
- goto err_free;
+ return ret;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret) {
hid_err(hdev, "hw start failed\n");
- goto err_free;
+ return ret;
}
return 0;
-err_free:
- kfree(zc);
-
- return ret;
-}
-
-static void zc_remove(struct hid_device *hdev)
-{
- struct zc_device *zc = hid_get_drvdata(hdev);
-
- hid_hw_stop(hdev);
- kfree(zc);
}
static const struct hid_device_id zc_devices[] = {
@@ -217,7 +205,6 @@ static struct hid_driver zc_driver = {
.input_mapping = zc_input_mapping,
.raw_event = zc_raw_event,
.probe = zc_probe,
- .remove = zc_remove,
};
module_hid_driver(zc_driver);