Skip to contentSkip to conversation

regulator: renesas-usb-vbus-regulator: Fix module autoloading

PATCH In review Nhat Tran 2 participants 4 messages Nov 16 Voltage and current regulator framework

lore
Share & tools
lore

Nhat Tran

author
#0 lore raw

PATCH 1/1 regulator: renesas-usb-vbus-regulator: Fix module autoloading

The driver can be built as a module, and Kconfig makes it a module by default when RESET_RZG2L_USBPHY_CTRL is a module. However the driver has neither a platform_device_id table nor a MODULE_ALIAS(), so no module alias is generated and udev never loads it.

The device is created by the rzg2l-usbphy-ctrl reset driver with platform_device_set_of_node_from_dev(), which marks the OF node as reused, so the uevent carries the platform modalias "platform:rzg2l-usb-vbus-regulator" rather than an OF one.

Without the regulator, the USB0 PHY waits forever for its vbus supply, and the whole USB0 port stays unusable. On an RZ/G2L SMARC EVK:

  # cat /sys/kernel/debug/devices_deferred
  11c50100.usb    platform: supplier 11c50200.usb-phy not ready
  11c50000.usb    platform: supplier 11c50200.usb-phy not ready
  11c60000.usb    platform: supplier 11c50200.usb-phy not ready
  11c50200.usb-phy

Loading the module by hand makes all of them probe.

Add a platform_device_id table and export it with MODULE_DEVICE_TABLE() so that the module is loaded automatically.

Fixes 84fbd6198766 ("regulator: Add Renesas RZ/G2L USB VBUS regulator driver")
---
 drivers/regulator/renesas-usb-vbus-regulator.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/regulator/renesas-usb-vbus-regulator.c +7 -0
index 9ba791bd72ec..65a58bf5ffa4 100644
@@ -55,12 +55,19 @@ static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct platform_device_id rzg2l_usb_vbus_regulator_ids[] = {
+	{ .name = "rzg2l-usb-vbus-regulator" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, rzg2l_usb_vbus_regulator_ids);
+
 static struct platform_driver rzg2l_usb_vbus_regulator_driver = {
 	.probe = rzg2l_usb_vbus_regulator_probe,
 	.driver	= {
 		.name = "rzg2l-usb-vbus-regulator",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
+	.id_table = rzg2l_usb_vbus_regulator_ids,
 };
 module_platform_driver(rzg2l_usb_vbus_regulator_driver);
 
Signature · 1 line
2.25.1
#1 lore raw

Hi Nhat Tran,

Thanks for the patch.

Quoted 23 lines

-----Original Message-----
From: Nhat Tran <[email protected]>
Sent: 16 November 2026 08:44
Subject: [PATCH] regulator: renesas-usb-vbus-regulator: Fix module autoloading

The driver can be built as a module, and Kconfig makes it a module by default when RESET_RZG2L_USBPHY_CTRL is a module. However the driver has neither a platform_device_id table nor a MODULE_ALIAS(), so no module alias is generated and udev never loads it.

The device is created by the rzg2l-usbphy-ctrl reset driver with platform_device_set_of_node_from_dev(), which marks the OF node as reused, so the uevent carries the platform modalias "platform:rzg2l-usb-vbus-regulator" rather than an OF one.

Without the regulator, the USB0 PHY waits forever for its vbus supply, and the whole USB0 port stays unusable. On an RZ/G2L SMARC EVK:

  # cat /sys/kernel/debug/devices_deferred
  11c50100.usb    platform: supplier 11c50200.usb-phy not ready
  11c50000.usb    platform: supplier 11c50200.usb-phy not ready
  11c60000.usb    platform: supplier 11c50200.usb-phy not ready
  11c50200.usb-phy
Quoted 4 lines

Loading the module by hand makes all of them probe.

Add a platform_device_id table and export it with MODULE_DEVICE_TABLE() so that the module is loaded automatically.

A patch is already mainlined [1] with these changes as part of RZ/G3L regulator support.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e0d3ff3fe71b2773913c43e5f759473cd003c9af

Cheers,
Biju

Quoted 13 lines
Fixes 84fbd6198766 ("regulator: Add Renesas RZ/G2L USB VBUS regulator driver")
---
 drivers/regulator/renesas-usb-vbus-regulator.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/regulator/renesas-usb-vbus- renamed from drivers/regulator/renesas-usb-vbus-regulator.c +0 -0

regulator.c
index 9ba791bd72ec..65a58bf5ffa4 100644

drivers/regulator/renesas-usb-vbus-regulator.c static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev) · line 59

Quoted 5 lines
drivers/regulator/renesas-usb-vbus-regulator.c +2 -0
@@ -55,12 +55,19 @@ static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev)
        return 0;
 }
 
+static const struct platform_device_id rzg2l_usb_vbus_regulator_ids[] = {
+       { .name = "rzg2l-usb-vbus-regulator" },

Have you tested this patch properly?

I had an issue in probing the device related to id_table match due to string length restriction in [2]

[2]https://elixir.bootlin.com/linux/v7.1.2/source/include/linux/mod_devicetable.h#L604

Cheers,
Biju

Quoted 16 lines
drivers/regulator/renesas-usb-vbus-regulator.c +5 -1
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, rzg2l_usb_vbus_regulator_ids);
+
 static struct platform_driver rzg2l_usb_vbus_regulator_driver = {
        .probe = rzg2l_usb_vbus_regulator_probe,
        .driver = {
                .name = "rzg2l-usb-vbus-regulator",
                .probe_type = PROBE_PREFER_ASYNCHRONOUS,
        },
+       .id_table = rzg2l_usb_vbus_regulator_ids,
 };
 module_platform_driver(rzg2l_usb_vbus_regulator_driver);
 
--

2.25.1

#2 lore raw
In reply to Nhat Tran

Hi Nhat Tran,

Thanks for the patch.

Quoted 40 lines

-----Original Message-----
From: Nhat Tran <[email protected]>
Sent: 16 November 2026 08:44
Subject: [PATCH] regulator: renesas-usb-vbus-regulator: Fix module autoloading

The driver can be built as a module, and Kconfig makes it a module by default when RESET_RZG2L_USBPHY_CTRL is a module. However the driver has neither a platform_device_id table nor a MODULE_ALIAS(), so no module alias is generated and udev never loads it.

The device is created by the rzg2l-usbphy-ctrl reset driver with platform_device_set_of_node_from_dev(), which marks the OF node as reused, so the uevent carries the platform modalias "platform:rzg2l-usb-vbus-regulator" rather than an OF one.

Without the regulator, the USB0 PHY waits forever for its vbus supply, and the whole USB0 port stays unusable. On an RZ/G2L SMARC EVK:

  # cat /sys/kernel/debug/devices_deferred
  11c50100.usb    platform: supplier 11c50200.usb-phy not ready
  11c50000.usb    platform: supplier 11c50200.usb-phy not ready
  11c60000.usb    platform: supplier 11c50200.usb-phy not ready
  11c50200.usb-phy

Loading the module by hand makes all of them probe.

Add a platform_device_id table and export it with MODULE_DEVICE_TABLE() so that the module is loaded automatically.

Fixes 84fbd6198766 ("regulator: Add Renesas RZ/G2L USB VBUS regulator driver")
---
 drivers/regulator/renesas-usb-vbus-regulator.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/regulator/renesas-usb-vbus- renamed from drivers/regulator/renesas-usb-vbus-regulator.c +0 -0

regulator.c
index 9ba791bd72ec..65a58bf5ffa4 100644

drivers/regulator/renesas-usb-vbus-regulator.c static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev) · line 60

Quoted 6 lines
drivers/regulator/renesas-usb-vbus-regulator.c +3 -0
@@ -55,12 +55,19 @@ static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev)
        return 0;
 }
 
+static const struct platform_device_id rzg2l_usb_vbus_regulator_ids[] = {
+       { .name = "rzg2l-usb-vbus-regulator" },
+       { /* sentinel */ }

Have you tested this patch properly?

I had an issue in probing the device related to id_table match due to string length restriction in [1].

So, to avoid ABI breakage a patch is introduced in [2] and Similar changes done in [3].

We cannot apply fixes due to ABI brakage.

So do you need this patch as [3] is already mainlined?

[1]https://elixir.bootlin.com/linux/v7.1.2/source/include/linux/mod_devicetable.h#L604 [2]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=26599cbf46fb1a72d4c7789d08a127a3d6bc59d0 [3]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e0d3ff3fe71b2773913c43e5f759473cd003c9af

Cheers,
Biju

author
#3 lore raw

Hi Biju,

Quoted 2 lines · Biju Das

A patch is already mainlined [1] with these changes as part of RZ/G3L regulator support.

Sorry, I missed that series. Please drop this patch.

Quoted 7 lines · Biju Das

drivers/regulator/renesas-usb-vbus-regulator.c static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev) · line 59

Quoted 2 lines
drivers/regulator/renesas-usb-vbus-regulator.c +2 -0
+static const struct platform_device_id rzg2l_usb_vbus_regulator_ids[] = {
+	{ .name = "rzg2l-usb-vbus-regulator" },

Have you tested this patch properly?

I had an issue in probing the device related to id_table match due to string length restriction in [2]

You are right. "rzg2l-usb-vbus-regulator" is 24 characters long, so it does not fit in name[PLATFORM_NAME_SIZE] together with its terminating NUL.

I tested it on an RZ/G2L SMARC EVK with the driver built as a module:
the module was loaded automatically and USB0 probed. But that only worked by luck: driver_data is 0 and directly follows name[], so strcmp() stops there. With a non-zero driver_data, as in your RZ/G3L patch, the match fails. Renaming the device, as you did, is the right fix.

Thanks for the review,
Nhat