diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2013-07-24 19:38:04 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-07-31 10:12:28 +0200 |
commit | abf832bfc349b54fd500f1e3b612f7f3cd9dfcc6 (patch) | |
tree | 4ece0e75cf3fd463be58376e3f900c1cfd60dd05 /drivers/hid/hid-sony.c | |
parent | 3366dd9fa887ebbda4872e9554f853eaeda764be (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-sony.c')
-rw-r--r-- | drivers/hid/hid-sony.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index ecbc74923d0..f9898aad72f 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -623,7 +623,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) struct sony_sc *sc; unsigned int connect_mask = HID_CONNECT_DEFAULT; - sc = kzalloc(sizeof(*sc), GFP_KERNEL); + sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL); if (sc == NULL) { hid_err(hdev, "can't alloc sony descriptor\n"); return -ENOMEM; @@ -635,7 +635,7 @@ static int sony_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; } if (sc->quirks & VAIO_RDESC_CONSTANT) @@ -648,7 +648,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) ret = hid_hw_start(hdev, connect_mask); if (ret) { hid_err(hdev, "hw start failed\n"); - goto err_free; + return ret; } if (sc->quirks & SIXAXIS_CONTROLLER_USB) { @@ -668,8 +668,6 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) return 0; err_stop: hid_hw_stop(hdev); -err_free: - kfree(sc); return ret; } @@ -681,7 +679,6 @@ static void sony_remove(struct hid_device *hdev) buzz_remove(hdev); hid_hw_stop(hdev); - kfree(sc); } static const struct hid_device_id sony_devices[] = { |