Commit ea58c33d authored by Hanno Zulla's avatar Hanno Zulla Committed by Jiri Kosina

HID: hid-sony.c: Use devm_ api to simplify sc->output_report_dmabuf

HID: hid-sony.c: Use devm_ api to simplify sc->output_report_dmabuf

Using devm_ calls, the resources of the Sony game devices's features are
tied to the main device handle, making it easier to handle errors and
teardown inside the device driver. Altogether, this reduces complexity
of the driver source.
Signed-off-by: default avatarHanno Zulla <kontakt@hanno.de>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 8082d3f0
...@@ -2202,16 +2202,20 @@ static int sony_allocate_output_report(struct sony_sc *sc) ...@@ -2202,16 +2202,20 @@ static int sony_allocate_output_report(struct sony_sc *sc)
if ((sc->quirks & SIXAXIS_CONTROLLER) || if ((sc->quirks & SIXAXIS_CONTROLLER) ||
(sc->quirks & NAVIGATION_CONTROLLER)) (sc->quirks & NAVIGATION_CONTROLLER))
sc->output_report_dmabuf = sc->output_report_dmabuf =
kmalloc(sizeof(union sixaxis_output_report_01), devm_kmalloc(&sc->hdev->dev,
sizeof(union sixaxis_output_report_01),
GFP_KERNEL); GFP_KERNEL);
else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT)
sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x11_SIZE, sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev,
DS4_OUTPUT_REPORT_0x11_SIZE,
GFP_KERNEL); GFP_KERNEL);
else if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) else if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE))
sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x05_SIZE, sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev,
DS4_OUTPUT_REPORT_0x05_SIZE,
GFP_KERNEL); GFP_KERNEL);
else if (sc->quirks & MOTION_CONTROLLER) else if (sc->quirks & MOTION_CONTROLLER)
sc->output_report_dmabuf = kmalloc(MOTION_REPORT_0x02_SIZE, sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev,
MOTION_REPORT_0x02_SIZE,
GFP_KERNEL); GFP_KERNEL);
else else
return 0; return 0;
...@@ -2791,7 +2795,6 @@ static int sony_input_configured(struct hid_device *hdev, ...@@ -2791,7 +2795,6 @@ static int sony_input_configured(struct hid_device *hdev,
if (sc->hw_version) if (sc->hw_version)
device_remove_file(&sc->hdev->dev, &dev_attr_hardware_version); device_remove_file(&sc->hdev->dev, &dev_attr_hardware_version);
sony_cancel_work_sync(sc); sony_cancel_work_sync(sc);
kfree(sc->output_report_dmabuf);
sony_remove_dev_list(sc); sony_remove_dev_list(sc);
sony_release_device_id(sc); sony_release_device_id(sc);
hid_hw_stop(hdev); hid_hw_stop(hdev);
...@@ -2879,8 +2882,6 @@ static void sony_remove(struct hid_device *hdev) ...@@ -2879,8 +2882,6 @@ static void sony_remove(struct hid_device *hdev)
sony_cancel_work_sync(sc); sony_cancel_work_sync(sc);
kfree(sc->output_report_dmabuf);
sony_remove_dev_list(sc); sony_remove_dev_list(sc);
sony_release_device_id(sc); sony_release_device_id(sc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment