diff options
| author | Suzuki K Poulose <suzuki.poulose@arm.com> | 2019-07-23 18:18:35 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-30 07:07:42 -0400 |
| commit | 4495dfdd6193d9712b7b8f5d699d89d5996e6aaa (patch) | |
| tree | aa15b229fd464d03088a71c613fdf0b445c2e89b /include/linux/device.h | |
| parent | 67843bbaf36eb087714f40e783ee78e99e9e4b86 (diff) | |
drivers: Introduce device lookup variants by device type
Add a helper to match a device by its type and provide wrappers
for {bus/class/driver}_find_device() APIs.
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-usb@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20190723221838.12024-5-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 7133fc1c285d..93b2f55ef44e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -167,6 +167,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter); | |||
| 167 | int device_match_name(struct device *dev, const void *name); | 167 | int device_match_name(struct device *dev, const void *name); |
| 168 | int device_match_of_node(struct device *dev, const void *np); | 168 | int device_match_of_node(struct device *dev, const void *np); |
| 169 | int device_match_fwnode(struct device *dev, const void *fwnode); | 169 | int device_match_fwnode(struct device *dev, const void *fwnode); |
| 170 | int device_match_devt(struct device *dev, const void *pdevt); | ||
| 170 | 171 | ||
| 171 | int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, | 172 | int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, |
| 172 | int (*fn)(struct device *dev, void *data)); | 173 | int (*fn)(struct device *dev, void *data)); |
| @@ -211,6 +212,18 @@ bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwno | |||
| 211 | return bus_find_device(bus, NULL, fwnode, device_match_fwnode); | 212 | return bus_find_device(bus, NULL, fwnode, device_match_fwnode); |
| 212 | } | 213 | } |
| 213 | 214 | ||
| 215 | /** | ||
| 216 | * bus_find_device_by_devt : device iterator for locating a particular device | ||
| 217 | * matching the device type. | ||
| 218 | * @bus: bus type | ||
| 219 | * @devt: device type of the device to match. | ||
| 220 | */ | ||
| 221 | static inline struct device *bus_find_device_by_devt(struct bus_type *bus, | ||
| 222 | dev_t devt) | ||
| 223 | { | ||
| 224 | return bus_find_device(bus, NULL, &devt, device_match_devt); | ||
| 225 | } | ||
| 226 | |||
| 214 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, | 227 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, |
| 215 | struct device *hint); | 228 | struct device *hint); |
| 216 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, | 229 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
| @@ -417,6 +430,18 @@ driver_find_device_by_fwnode(struct device_driver *drv, | |||
| 417 | return driver_find_device(drv, NULL, fwnode, device_match_fwnode); | 430 | return driver_find_device(drv, NULL, fwnode, device_match_fwnode); |
| 418 | } | 431 | } |
| 419 | 432 | ||
| 433 | /** | ||
| 434 | * driver_find_device_by_devt- device iterator for locating a particular device | ||
| 435 | * by devt. | ||
| 436 | * @driver: the driver we're iterating | ||
| 437 | * @devt: devt pointer to match. | ||
| 438 | */ | ||
| 439 | static inline struct device *driver_find_device_by_devt(struct device_driver *drv, | ||
| 440 | dev_t devt) | ||
| 441 | { | ||
| 442 | return driver_find_device(drv, NULL, &devt, device_match_devt); | ||
| 443 | } | ||
| 444 | |||
| 420 | void driver_deferred_probe_add(struct device *dev); | 445 | void driver_deferred_probe_add(struct device *dev); |
| 421 | int driver_deferred_probe_check_state(struct device *dev); | 446 | int driver_deferred_probe_check_state(struct device *dev); |
| 422 | int driver_deferred_probe_check_state_continue(struct device *dev); | 447 | int driver_deferred_probe_check_state_continue(struct device *dev); |
| @@ -583,6 +608,18 @@ class_find_device_by_fwnode(struct class *class, | |||
| 583 | return class_find_device(class, NULL, fwnode, device_match_fwnode); | 608 | return class_find_device(class, NULL, fwnode, device_match_fwnode); |
| 584 | } | 609 | } |
| 585 | 610 | ||
| 611 | /** | ||
| 612 | * class_find_device_by_devt : device iterator for locating a particular device | ||
| 613 | * matching the device type. | ||
| 614 | * @class: class type | ||
| 615 | * @devt: device type of the device to match. | ||
| 616 | */ | ||
| 617 | static inline struct device *class_find_device_by_devt(struct class *class, | ||
| 618 | dev_t devt) | ||
| 619 | { | ||
| 620 | return class_find_device(class, NULL, &devt, device_match_devt); | ||
| 621 | } | ||
| 622 | |||
| 586 | struct class_attribute { | 623 | struct class_attribute { |
| 587 | struct attribute attr; | 624 | struct attribute attr; |
| 588 | ssize_t (*show)(struct class *class, struct class_attribute *attr, | 625 | ssize_t (*show)(struct class *class, struct class_attribute *attr, |
