[PATCH 22/26] Input: maplecontrol - convert to devm
From: Dmitry Torokhov
Date: Sat Jul 04 2026 - 02:04:03 EST
Convert the driver to use managed resources to simplify resource
lifecycle management.
This eliminates manual error handling in probe() and allows removing
the remove() callback entirely, as all cleanup is handled automatically.
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/input/joystick/maplecontrol.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c
index 6864243b0b4a..3ef6652d40cb 100644
--- a/drivers/input/joystick/maplecontrol.c
+++ b/drivers/input/joystick/maplecontrol.c
@@ -99,12 +99,13 @@ static int probe_maple_controller(struct maple_device *mdev)
struct input_dev *idev;
unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
- pad = kzalloc_obj(*pad);
- idev = input_allocate_device();
- if (!pad || !idev) {
- error = -ENOMEM;
- goto fail;
- }
+ pad = devm_kzalloc(&mdev->dev, sizeof(*pad), GFP_KERNEL);
+ if (!pad)
+ return -ENOMEM;
+
+ idev = devm_input_allocate_device(&mdev->dev);
+ if (!idev)
+ return -ENOMEM;
pad->dev = idev;
pad->mdev = mdev;
@@ -129,33 +130,20 @@ static int probe_maple_controller(struct maple_device *mdev)
if (idev->keybit[BIT_WORD(BTN_JOYSTICK)])
idev->evbit[0] |= BIT_MASK(EV_KEY);
- idev->dev.parent = &mdev->dev;
idev->name = mdev->product_name;
idev->id.bustype = BUS_HOST;
error = input_register_device(idev);
if (error)
- goto fail;
- return 0;
+ return error;
-fail:
- input_free_device(idev);
- kfree(pad);
- return error;
-}
-
-static void remove_maple_controller(struct maple_device *mdev)
-{
- struct dc_pad *pad = maple_get_drvdata(mdev);
+ return 0;
- input_unregister_device(pad->dev);
- kfree(pad);
}
static struct maple_driver dc_pad_driver = {
.function = MAPLE_FUNC_CONTROLLER,
.probe = probe_maple_controller,
- .remove = remove_maple_controller,
.drv = {
.name = "Dreamcast_controller",
},
--
2.55.0.rc0.799.gd6f94ed593-goog