Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c7a5096

Browse files
andy-shevrafaeljw
authored andcommitted
PNP: Make dev_is_pnp() to be a function and export it for modules
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: 2a49b45 ("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>
1 parent 1613e60 commit c7a5096

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/pnp/driver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ const struct bus_type pnp_bus_type = {
266266
.dev_groups = pnp_dev_groups,
267267
};
268268

269+
bool dev_is_pnp(const struct device *dev)
270+
{
271+
return dev->bus == &pnp_bus_type;
272+
}
273+
EXPORT_SYMBOL_GPL(dev_is_pnp);
274+
269275
int pnp_register_driver(struct pnp_driver *drv)
270276
{
271277
drv->driver.name = drv->name;

include/linux/pnp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ int compare_pnp_id(struct pnp_id *pos, const char *id);
469469
int pnp_register_driver(struct pnp_driver *drv);
470470
void pnp_unregister_driver(struct pnp_driver *drv);
471471

472-
#define dev_is_pnp(d) ((d)->bus == &pnp_bus_type)
472+
bool dev_is_pnp(const struct device *dev);
473473

474474
#else
475475

@@ -502,7 +502,7 @@ static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -E
502502
static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
503503
static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
504504

505-
#define dev_is_pnp(d) false
505+
static inline bool dev_is_pnp(const struct device *dev) { return false; }
506506

507507
#endif /* CONFIG_PNP */
508508

0 commit comments

Comments
 (0)