Skip to contentSkip to conversation

PNP: Export pnp_bus_type for modules

PATCH In review Andy Shevchenko 4 participants 9 messages May 27, 2024 – May 28, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PNP: Export pnp_bus_type for modules

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

Fixes 2a49b45cd0e7 ("PNP: Add dev_is_pnp() macro")
---
 drivers/pnp/driver.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pnp/driver.c +1 -0
index 0a5d0d8befa8..1394d17bd6f7 100644
@@ -265,6 +265,7 @@ const struct bus_type pnp_bus_type = {
 	.pm	 = &pnp_bus_dev_pm_ops,
 	.dev_groups = pnp_dev_groups,
 };
+EXPORT_SYMBOL(pnp_bus_type);
 
 int pnp_register_driver(struct pnp_driver *drv)
 {
Signature · 1 line
2.45.1
Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

Fixes 2a49b45cd0e7 ("PNP: Add dev_is_pnp() macro")
---
  drivers/pnp/driver.c | 1 +
  1 file changed, 1 insertion(+)
drivers/pnp/driver.c +0 -0
index 0a5d0d8befa8..1394d17bd6f7 100644

drivers/pnp/driver.c const struct bus_type pnp_bus_type = { · line 271

Quoted 7 lines
drivers/pnp/driver.c +1 -0
@@ -265,6 +265,7 @@ const struct bus_type pnp_bus_type = {
  	.pm	 = &pnp_bus_dev_pm_ops,
  	.dev_groups = pnp_dev_groups,
  };
+EXPORT_SYMBOL(pnp_bus_type);
 
  int pnp_register_driver(struct pnp_driver *drv)
  {

Confirm the patch works OK.

Thanks, Woody

#2 lore raw
In reply to Andy Shevchenko
Quoted 3 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

NAK. Please move dev_is_pnp out of line and export it (as EXPORT_SYMBOL_GPL), please. bus types should be private unless we have really good reasons for them not to be private.

#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

NAK. Please move dev_is_pnp out of line and export it (as EXPORT_SYMBOL_GPL), please. bus types should be private unless we have really good reasons for them not to be private.

Works for me, I'll redo it in the v2, thank you for the review.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

NAK. Please move dev_is_pnp out of line and export it (as EXPORT_SYMBOL_GPL), please. bus types should be private unless we have really good reasons for them not to be private.

FWIW, it's not private, it's just not exported to the modules. Are you suggesting to hide the bus type completely to make it static? If so, this is out of scope of this fix.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines

NAK. Please move dev_is_pnp out of line and export it (as EXPORT_SYMBOL_GPL), please. bus types should be private unless we have really good reasons for them not to be private.

FWIW, it's not private, it's just not exported to the modules. Are you suggesting to hide the bus type completely to make it static? If so, this is out of scope of this fix.

Not exporting it is the most important bit. Making it private would be even better of course.

#6 lore raw
In reply to Andy Shevchenko
Quoted 18 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

Fixes 2a49b45cd0e7 ("PNP: Add dev_is_pnp() macro")
---
 drivers/pnp/driver.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pnp/driver.c +0 -0
index 0a5d0d8befa8..1394d17bd6f7 100644

drivers/pnp/driver.c const struct bus_type pnp_bus_type = { · line 268

Quoted 4 lines
drivers/pnp/driver.c +1 -0
@@ -265,6 +265,7 @@ const struct bus_type pnp_bus_type = {
        .pm      = &pnp_bus_dev_pm_ops,
        .dev_groups = pnp_dev_groups,
 };
+EXPORT_SYMBOL(pnp_bus_type);

Why not EXPORT_SYMBOL_GPL()?

Quoted 6 lines
drivers/pnp/driver.c +0 -1
 int pnp_register_driver(struct pnp_driver *drv)
 {
--

2.45.1

#7 lore raw
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

...

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL(pnp_bus_type);

Why not EXPORT_SYMBOL_GPL()?

To be consistent with the rest, but in any case Christoph suggested something else, where _GPL is assumed to be.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Andy Shevchenko

Since we have dev_is_pnp() macro that utilises the address of pnp_bus_type variable, the users, which can be compiled as modules, will be failed to build. Export the variable to the modules to prevent build breakage.

Quoted 8 lines

...

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL(pnp_bus_type);

Why not EXPORT_SYMBOL_GPL()?

To be consistent with the rest, but in any case Christoph suggested something else, where _GPL is assumed to be.

Yes, that's even better.