diff options
| author | Suzuki K Poulose <suzuki.poulose@arm.com> | 2019-07-23 18:18:33 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-30 07:07:41 -0400 |
| commit | cfba5de9b99f8bbb8b4ea11b3049784e78b8759b (patch) | |
| tree | 1c9f123ae5f350f61efa4d6c5730bba20601b74a /include/linux/device.h | |
| parent | 6cda08a20dbde45b021091230c8a359fa08c5103 (diff) | |
drivers: Introduce device lookup variants by of_node
Introduce wrappers for {bus/driver/class}_find_device() to
locate devices by its of_node.
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: devicetree@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Alan Tull <atull@kernel.org>
Cc: linux-fpga@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C part
Acked-by: Moritz Fischer <mdf@kernel.org> # For FPGA part
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20190723221838.12024-3-suzuki.poulose@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 3ba376b8b456..29d8d7ad41e6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -186,6 +186,18 @@ static inline struct device *bus_find_device_by_name(struct bus_type *bus, | |||
| 186 | return bus_find_device(bus, start, name, device_match_name); | 186 | return bus_find_device(bus, start, name, device_match_name); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | /** | ||
| 190 | * bus_find_device_by_of_node : device iterator for locating a particular device | ||
| 191 | * matching the of_node. | ||
| 192 | * @bus: bus type | ||
| 193 | * @np: of_node of the device to match. | ||
| 194 | */ | ||
| 195 | static inline struct device * | ||
| 196 | bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np) | ||
| 197 | { | ||
| 198 | return bus_find_device(bus, NULL, np, device_match_of_node); | ||
| 199 | } | ||
| 200 | |||
| 189 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, | 201 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, |
| 190 | struct device *hint); | 202 | struct device *hint); |
| 191 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, | 203 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
| @@ -366,6 +378,19 @@ static inline struct device *driver_find_device_by_name(struct device_driver *dr | |||
| 366 | return driver_find_device(drv, NULL, name, device_match_name); | 378 | return driver_find_device(drv, NULL, name, device_match_name); |
| 367 | } | 379 | } |
| 368 | 380 | ||
| 381 | /** | ||
| 382 | * driver_find_device_by_of_node- device iterator for locating a particular device | ||
| 383 | * by of_node pointer. | ||
| 384 | * @driver: the driver we're iterating | ||
| 385 | * @np: of_node pointer to match. | ||
| 386 | */ | ||
| 387 | static inline struct device * | ||
| 388 | driver_find_device_by_of_node(struct device_driver *drv, | ||
| 389 | const struct device_node *np) | ||
| 390 | { | ||
| 391 | return driver_find_device(drv, NULL, np, device_match_of_node); | ||
| 392 | } | ||
| 393 | |||
| 369 | void driver_deferred_probe_add(struct device *dev); | 394 | void driver_deferred_probe_add(struct device *dev); |
| 370 | int driver_deferred_probe_check_state(struct device *dev); | 395 | int driver_deferred_probe_check_state(struct device *dev); |
| 371 | int driver_deferred_probe_check_state_continue(struct device *dev); | 396 | int driver_deferred_probe_check_state_continue(struct device *dev); |
| @@ -507,6 +532,18 @@ static inline struct device *class_find_device_by_name(struct class *class, | |||
| 507 | return class_find_device(class, NULL, name, device_match_name); | 532 | return class_find_device(class, NULL, name, device_match_name); |
| 508 | } | 533 | } |
| 509 | 534 | ||
| 535 | /** | ||
| 536 | * class_find_device_by_of_node : device iterator for locating a particular device | ||
| 537 | * matching the of_node. | ||
| 538 | * @class: class type | ||
| 539 | * @np: of_node of the device to match. | ||
| 540 | */ | ||
| 541 | static inline struct device * | ||
| 542 | class_find_device_by_of_node(struct class *class, const struct device_node *np) | ||
| 543 | { | ||
| 544 | return class_find_device(class, NULL, np, device_match_of_node); | ||
| 545 | } | ||
| 546 | |||
| 510 | struct class_attribute { | 547 | struct class_attribute { |
| 511 | struct attribute attr; | 548 | struct attribute attr; |
| 512 | ssize_t (*show)(struct class *class, struct class_attribute *attr, | 549 | ssize_t (*show)(struct class *class, struct class_attribute *attr, |
