Skip to content

Commit 1db73ae

Browse files
Geert Uytterhoevenrobherring
authored andcommitted
of/device: Nullify match table in of_match_device() for CONFIG_OF=n
If the of_device_id table inside a device driver is protected by #ifdef CONFIG_OF, the driver still has to provide a dummy declaration of the table, or wrap it inside of_match_ptr(), when calling of_match_device() in the CONFIG_OF=n case, else the driver fails to compile with e.g. drivers/spi/spi-rspi.c: In function 'rspi_probe': drivers/spi/spi-rspi.c:1203:26: error: 'rspi_of_match' undeclared (first use in this function) drivers/spi/spi-rspi.c:1203:26: note: each undeclared identifier is reported only once for each function it appears in Make of_match_device() nullify the table pointer if CONFIG_OF=n to fix this. Reported-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent e066755 commit 1db73ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/linux/of_device.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ static inline int of_device_uevent_modalias(struct device *dev,
7878

7979
static inline void of_device_node_put(struct device *dev) { }
8080

81-
static inline const struct of_device_id *of_match_device(
81+
static inline const struct of_device_id *__of_match_device(
8282
const struct of_device_id *matches, const struct device *dev)
8383
{
8484
return NULL;
8585
}
86+
#define of_match_device(matches, dev) \
87+
__of_match_device(of_match_ptr(matches), (dev))
8688

8789
static inline struct device_node *of_cpu_device_node_get(int cpu)
8890
{

0 commit comments

Comments
 (0)