From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Florian Fuchs <fuchsfl@gmail.com>,
Adrian McMenamin <adrianmcmenamin@gmail.com>,
linux-kernel@vger.kernel.org, Dmitry Torokhov <dtor@mail.ru>,
linux-input@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-sh@vger.kernel.org
Subject: [PATCH 17/26] sh: maple: implement bus-level probe/remove
Date: Fri, 03 Jul 2026 22:57:40 -0700 [thread overview]
Message-ID: <20260703-b4-maple-cleanup-v1-17-41e424964da5@gmail.com> (raw)
In-Reply-To: <20260703-b4-maple-cleanup-v1-0-41e424964da5@gmail.com>
Implement probe() and remove() methods for the maple bus, and update
struct maple_driver to have its own probe() and remove() members that
take struct maple_device * directly.
Adjust all maple drivers (keyboard, mouse, joystick, vmu-flash) to
use these new bus-level methods, simplifying their probe and remove
functions by removing the need to cast from struct device * using
to_maple_dev().
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/joystick/maplecontrol.c | 12 ++++--------
drivers/input/keyboard/maple_keyb.c | 14 +++++---------
drivers/input/mouse/maplemouse.c | 12 ++++--------
drivers/mtd/maps/vmu-flash.c | 13 ++++---------
drivers/sh/maple/maple.c | 27 ++++++++++++++++++++++++++-
include/linux/maple.h | 2 ++
6 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c
index 955e01bcfa0c..6864243b0b4a 100644
--- a/drivers/input/joystick/maplecontrol.c
+++ b/drivers/input/joystick/maplecontrol.c
@@ -78,7 +78,7 @@ static void dc_pad_close(struct input_dev *dev)
}
/* allow the controller to be used */
-static int probe_maple_controller(struct device *dev)
+static int probe_maple_controller(struct maple_device *mdev)
{
static const short btn_bit[32] = {
BTN_C, BTN_B, BTN_A, BTN_START, -1, -1, -1, -1,
@@ -94,7 +94,6 @@ static int probe_maple_controller(struct device *dev)
-1, -1, -1, -1, -1, -1, -1, -1,
};
- struct maple_device *mdev = to_maple_dev(dev);
int i, error;
struct dc_pad *pad;
struct input_dev *idev;
@@ -145,23 +144,20 @@ static int probe_maple_controller(struct device *dev)
return error;
}
-static int remove_maple_controller(struct device *dev)
+static void remove_maple_controller(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
struct dc_pad *pad = maple_get_drvdata(mdev);
input_unregister_device(pad->dev);
kfree(pad);
-
- return 0;
}
static struct maple_driver dc_pad_driver = {
.function = MAPLE_FUNC_CONTROLLER,
+ .probe = probe_maple_controller,
+ .remove = remove_maple_controller,
.drv = {
.name = "Dreamcast_controller",
- .probe = probe_maple_controller,
- .remove = remove_maple_controller,
},
};
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index e277b929a375..ab9257db7e03 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -158,15 +158,12 @@ static void dc_kbd_close(struct input_dev *dev)
maple_getcond_callback(mdev, NULL, 0, MAPLE_FUNC_KEYBOARD);
}
-static int probe_maple_kbd(struct device *dev)
+static int probe_maple_kbd(struct maple_device *mdev)
{
- struct maple_device *mdev;
int i, error;
struct dc_kbd *kbd;
struct input_dev *idev;
- mdev = to_maple_dev(dev);
-
kbd = kzalloc_obj(*kbd);
if (!kbd) {
error = -ENOMEM;
@@ -214,9 +211,8 @@ static int probe_maple_kbd(struct device *dev)
return error;
}
-static int remove_maple_kbd(struct device *dev)
+static void remove_maple_kbd(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
struct dc_kbd *kbd = maple_get_drvdata(mdev);
guard(mutex)(&maple_keyb_mutex);
@@ -224,15 +220,15 @@ static int remove_maple_kbd(struct device *dev)
input_unregister_device(kbd->dev);
kfree(kbd);
- return 0;
+
}
static struct maple_driver dc_kbd_driver = {
.function = MAPLE_FUNC_KEYBOARD,
+ .probe = probe_maple_kbd,
+ .remove = remove_maple_kbd,
.drv = {
.name = "Dreamcast_keyboard",
- .probe = probe_maple_kbd,
- .remove = remove_maple_kbd,
},
};
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
index f67e3eb5841b..03cb666d278d 100644
--- a/drivers/input/mouse/maplemouse.c
+++ b/drivers/input/mouse/maplemouse.c
@@ -64,9 +64,8 @@ static void dc_mouse_close(struct input_dev *dev)
}
/* allow the mouse to be used */
-static int probe_maple_mouse(struct device *dev)
+static int probe_maple_mouse(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
int error;
struct input_dev *input_dev;
struct dc_mouse *mse;
@@ -111,23 +110,20 @@ static int probe_maple_mouse(struct device *dev)
return error;
}
-static int remove_maple_mouse(struct device *dev)
+static void remove_maple_mouse(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
struct dc_mouse *mse = maple_get_drvdata(mdev);
input_unregister_device(mse->dev);
kfree(mse);
-
- return 0;
}
static struct maple_driver dc_mouse_driver = {
.function = MAPLE_FUNC_MOUSE,
+ .probe = probe_maple_mouse,
+ .remove = remove_maple_mouse,
.drv = {
.name = "Dreamcast_mouse",
- .probe = probe_maple_mouse,
- .remove = remove_maple_mouse,
},
};
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
index 8f7028ac1b56..c34c768dfb87 100644
--- a/drivers/mtd/maps/vmu-flash.c
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -769,30 +769,25 @@ static void vmu_file_error(struct maple_device *mdev, void *recvbuf)
}
-static int probe_maple_vmu(struct device *dev)
+static int probe_maple_vmu(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
-
mdev->can_unload = vmu_can_unload;
mdev->fileerr_handler = vmu_file_error;
return vmu_connect(mdev);
}
-static int remove_maple_vmu(struct device *dev)
+static void remove_maple_vmu(struct maple_device *mdev)
{
- struct maple_device *mdev = to_maple_dev(dev);
-
vmu_disconnect(mdev);
- return 0;
}
static struct maple_driver vmu_flash_driver = {
.function = MAPLE_FUNC_MEMCARD,
+ .probe = probe_maple_vmu,
+ .remove = remove_maple_vmu,
.drv = {
.name = "Dreamcast_visual_memory",
- .probe = probe_maple_vmu,
- .remove = remove_maple_vmu,
},
};
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 35aff2e57d2c..c0715e3ace6f 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -721,6 +721,11 @@ static irqreturn_t maple_vblank_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+/*
+ * We pass &maple_bus as dev_id for the shared interrupts because
+ * the kernel requires a unique non-NULL token for shared IRQs,
+ * even though the handlers themselves ignore it.
+ */
static int maple_set_dma_interrupt_handler(void)
{
return request_irq(HW_EVENT_MAPLE_DMA, maple_dma_interrupt,
@@ -765,9 +770,30 @@ static void maple_bus_release(struct device *dev)
/*
* maple_bus_type - core maple bus structure
*/
+static int maple_bus_probe(struct device *dev)
+{
+ struct maple_driver *maple_drv = to_maple_driver(dev->driver);
+ struct maple_device *maple_dev = to_maple_dev(dev);
+
+ if (maple_drv->probe)
+ return maple_drv->probe(maple_dev);
+ return -ENODEV;
+}
+
+static void maple_bus_remove(struct device *dev)
+{
+ struct maple_driver *maple_drv = to_maple_driver(dev->driver);
+ struct maple_device *maple_dev = to_maple_dev(dev);
+
+ if (maple_drv->remove)
+ maple_drv->remove(maple_dev);
+}
+
static const struct bus_type maple_bus_type = {
.name = "maple",
.match = maple_match_bus_driver,
+ .probe = maple_bus_probe,
+ .remove = maple_bus_remove,
};
static struct device maple_bus = {
@@ -790,7 +816,6 @@ static int __init maple_bus_init(void)
if (retval)
goto cleanup_device;
-
/* allocate memory for maple bus dma */
retval = maple_get_dma_buffer();
if (retval) {
diff --git a/include/linux/maple.h b/include/linux/maple.h
index 90c26c86e3ed..641cf3330409 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -80,6 +80,8 @@ struct maple_device {
struct maple_driver {
unsigned long function;
+ int (*probe)(struct maple_device *dev);
+ void (*remove)(struct maple_device *dev);
struct device_driver drv;
};
--
2.55.0.rc0.799.gd6f94ed593-goog
next prev parent reply other threads:[~2026-07-04 5:58 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 5:57 [PATCH 00/26] sh: maple: cleanup and modernize input drivers Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 01/26] sh: maple: include linux/device.h in linux/maple.h Dmitry Torokhov
2026-07-04 6:05 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 02/26] Input: maple_keyb - fix key press detection Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 03/26] Input: maplecontrol - only enable present axes Dmitry Torokhov
2026-07-04 6:10 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 04/26] Input: maplemouse - stop polling and clear callback on close Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 05/26] Input: maplecontrol " Dmitry Torokhov
2026-07-04 6:07 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 06/26] Input: maplecontrol - simplify maple_device retrieval in open/close Dmitry Torokhov
2026-07-04 6:10 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 07/26] Input: maple_keyb - implement open and close methods Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 08/26] Input: maplemouse - remove redundant drvdata resetting Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 09/26] Input: maple_keyb " Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 10/26] Input: maplecontrol " Dmitry Torokhov
2026-07-04 6:09 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 11/26] Input: maplemouse - remove unused mdev->driver assignment Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 12/26] Input: maplecontrol " Dmitry Torokhov
2026-07-04 6:06 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 13/26] Input: maple_keyb " Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 14/26] mtd: maps: vmu-flash: " Dmitry Torokhov
2026-07-04 6:08 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 15/26] sh: maple: remove not needed maple_unsupported_device driver Dmitry Torokhov
2026-07-04 6:11 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 16/26] sh: maple: remove unused driver field from struct maple_device Dmitry Torokhov
2026-07-04 6:09 ` sashiko-bot
2026-07-04 5:57 ` Dmitry Torokhov [this message]
2026-07-04 6:12 ` [PATCH 17/26] sh: maple: implement bus-level probe/remove sashiko-bot
2026-07-04 5:57 ` [PATCH 18/26] sh: maple: introduce callback_mutex in maple_device Dmitry Torokhov
2026-07-04 6:14 ` sashiko-bot
2026-07-04 15:48 ` Florian Fuchs
2026-07-04 23:50 ` Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 19/26] Input: maple_keyb - remove redundant mutex and remove method Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 20/26] Input: maple_keyb - convert to devm Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 21/26] Input: maplemouse " Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 22/26] Input: maplecontrol " Dmitry Torokhov
2026-07-04 6:13 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 23/26] Input: maple_keyb - fix style issues Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 24/26] Input: maplemouse " Dmitry Torokhov
2026-07-04 5:57 ` [PATCH 25/26] Input: maplecontrol " Dmitry Torokhov
2026-07-04 6:12 ` sashiko-bot
2026-07-04 5:57 ` [PATCH 26/26] Input: maple_keyb - remove redundant 'new' buffer from struct dc_kbd Dmitry Torokhov
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=20260703-b4-maple-cleanup-v1-17-41e424964da5@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=adrianmcmenamin@gmail.com \
--cc=dalias@libc.org \
--cc=dtor@mail.ru \
--cc=fuchsfl@gmail.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-sh@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
--cc=ysato@users.sourceforge.jp \
/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