]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
PNP: Make dev_is_pnp() to be a function and export it for modules
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Tue, 28 May 2024 10:25:02 +0000 (13:25 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 28 May 2024 19:53:51 +0000 (21:53 +0200)
Since we have a dev_is_pnp() macro that utilises the address of the
pnp_bus_type variable, the users, which can be compiled as modules,
will fail to build. Convert the macro to be a function and export it
to the modules to prevent build breakage.

Reported-by: Woody Suwalski <terraluna977@gmail.com>
Closes: https://lore.kernel.org/r/cc8a93b2-2504-9754-e26c-5d5c3bd1265c@gmail.com
Fixes: 2a49b45cd0e7 ("PNP: Add dev_is_pnp() macro")
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pnp/driver.c
include/linux/pnp.h

index 0a5d0d8befa8408d02b3eaaf278d6a936a83e102..3483e52e3a81d13d6dbc3e68882fa8b7535e03bf 100644 (file)
@@ -266,6 +266,12 @@ const struct bus_type pnp_bus_type = {
        .dev_groups = pnp_dev_groups,
 };
 
+bool dev_is_pnp(const struct device *dev)
+{
+       return dev->bus == &pnp_bus_type;
+}
+EXPORT_SYMBOL_GPL(dev_is_pnp);
+
 int pnp_register_driver(struct pnp_driver *drv)
 {
        drv->driver.name = drv->name;
index 82561242cda4281a109bcef3bcba3a3e9739f5b7..a8def1cea32c00a97e01aa61624ad26d68344868 100644 (file)
@@ -469,7 +469,7 @@ int compare_pnp_id(struct pnp_id *pos, const char *id);
 int pnp_register_driver(struct pnp_driver *drv);
 void pnp_unregister_driver(struct pnp_driver *drv);
 
-#define dev_is_pnp(d) ((d)->bus == &pnp_bus_type)
+bool dev_is_pnp(const struct device *dev);
 
 #else
 
@@ -502,7 +502,7 @@ static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -E
 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
 
-#define dev_is_pnp(d) false
+static inline bool dev_is_pnp(const struct device *dev) { return false; }
 
 #endif /* CONFIG_PNP */