Skip to content

Commit e8a51e1

Browse files
ozbenhgregkh
authored andcommitted
device: Add dev_of_node() accessor
Suggested by Arnd Bergmann, this gives a practical accessor for the of_node field of struct device while instructing the compiler that it will be NULL if CONFIG_OF is not set. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ef518cc commit e8a51e1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/linux/device.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,13 @@ static inline void device_lock_assert(struct device *dev)
916916
lockdep_assert_held(&dev->mutex);
917917
}
918918

919+
static inline struct device_node *dev_of_node(struct device *dev)
920+
{
921+
if (!IS_ENABLED(CONFIG_OF))
922+
return NULL;
923+
return dev->of_node;
924+
}
925+
919926
void driver_init(void);
920927

921928
/*

0 commit comments

Comments
 (0)