Skip to content

Commit

Permalink
device: Add dev_of_node() accessor
Browse files Browse the repository at this point in the history
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 <benh@kernel.crashing.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Benjamin Herrenschmidt authored and Greg Kroah-Hartman committed Mar 25, 2015
1 parent ef518cc commit e8a51e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/linux/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,13 @@ static inline void device_lock_assert(struct device *dev)
lockdep_assert_held(&dev->mutex);
}

static inline struct device_node *dev_of_node(struct device *dev)
{
if (!IS_ENABLED(CONFIG_OF))
return NULL;
return dev->of_node;
}

void driver_init(void);

/*
Expand Down

0 comments on commit e8a51e1

Please sign in to comment.