diff options
| author | Suzuki K Poulose <suzuki.poulose@arm.com> | 2019-07-23 18:18:36 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-07-30 07:07:42 -0400 |
| commit | 00500147cbd3fc51353d0d003eaa9d31c72c0d50 (patch) | |
| tree | f5bfceb950d69388c6323aca8fcc483853240684 /include/linux/device.h | |
| parent | 4495dfdd6193d9712b7b8f5d699d89d5996e6aaa (diff) | |
drivers: Introduce device lookup variants by ACPI_COMPANION device
Add a generic helper to match a device by the ACPI_COMPANION device
and provide wrappers for the device lookup APIs.
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-i2c@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C parts
Link: https://lore.kernel.org/r/20190723221838.12024-6-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 | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 93b2f55ef44e..7514ef3d3f1a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -168,6 +168,7 @@ 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 | int device_match_devt(struct device *dev, const void *pdevt); |
| 171 | int device_match_acpi_dev(struct device *dev, const void *adev); | ||
| 171 | 172 | ||
| 172 | int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, | 173 | int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, |
| 173 | int (*fn)(struct device *dev, void *data)); | 174 | int (*fn)(struct device *dev, void *data)); |
| @@ -224,6 +225,28 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus, | |||
| 224 | return bus_find_device(bus, NULL, &devt, device_match_devt); | 225 | return bus_find_device(bus, NULL, &devt, device_match_devt); |
| 225 | } | 226 | } |
| 226 | 227 | ||
| 228 | #ifdef CONFIG_ACPI | ||
| 229 | struct acpi_device; | ||
| 230 | |||
| 231 | /** | ||
| 232 | * bus_find_device_by_acpi_dev : device iterator for locating a particular device | ||
| 233 | * matching the ACPI COMPANION device. | ||
| 234 | * @bus: bus type | ||
| 235 | * @adev: ACPI COMPANION device to match. | ||
| 236 | */ | ||
| 237 | static inline struct device * | ||
| 238 | bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev) | ||
| 239 | { | ||
| 240 | return bus_find_device(bus, NULL, adev, device_match_acpi_dev); | ||
| 241 | } | ||
| 242 | #else | ||
| 243 | static inline struct device * | ||
| 244 | bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev) | ||
| 245 | { | ||
| 246 | return NULL; | ||
| 247 | } | ||
| 248 | #endif | ||
| 249 | |||
| 227 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, | 250 | struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, |
| 228 | struct device *hint); | 251 | struct device *hint); |
| 229 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, | 252 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
| @@ -442,6 +465,27 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr | |||
| 442 | return driver_find_device(drv, NULL, &devt, device_match_devt); | 465 | return driver_find_device(drv, NULL, &devt, device_match_devt); |
| 443 | } | 466 | } |
| 444 | 467 | ||
| 468 | #ifdef CONFIG_ACPI | ||
| 469 | /** | ||
| 470 | * driver_find_device_by_acpi_dev : device iterator for locating a particular | ||
| 471 | * device matching the ACPI_COMPANION device. | ||
| 472 | * @driver: the driver we're iterating | ||
| 473 | * @adev: ACPI_COMPANION device to match. | ||
| 474 | */ | ||
| 475 | static inline struct device * | ||
| 476 | driver_find_device_by_acpi_dev(struct device_driver *drv, | ||
| 477 | const struct acpi_device *adev) | ||
| 478 | { | ||
| 479 | return driver_find_device(drv, NULL, adev, device_match_acpi_dev); | ||
| 480 | } | ||
| 481 | #else | ||
| 482 | static inline struct device * | ||
| 483 | driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev) | ||
| 484 | { | ||
| 485 | return NULL; | ||
| 486 | } | ||
| 487 | #endif | ||
| 488 | |||
| 445 | void driver_deferred_probe_add(struct device *dev); | 489 | void driver_deferred_probe_add(struct device *dev); |
| 446 | int driver_deferred_probe_check_state(struct device *dev); | 490 | int driver_deferred_probe_check_state(struct device *dev); |
| 447 | int driver_deferred_probe_check_state_continue(struct device *dev); | 491 | int driver_deferred_probe_check_state_continue(struct device *dev); |
| @@ -620,6 +664,27 @@ static inline struct device *class_find_device_by_devt(struct class *class, | |||
| 620 | return class_find_device(class, NULL, &devt, device_match_devt); | 664 | return class_find_device(class, NULL, &devt, device_match_devt); |
| 621 | } | 665 | } |
| 622 | 666 | ||
| 667 | #ifdef CONFIG_ACPI | ||
| 668 | struct acpi_device; | ||
| 669 | /** | ||
| 670 | * class_find_device_by_acpi_dev : device iterator for locating a particular | ||
| 671 | * device matching the ACPI_COMPANION device. | ||
| 672 | * @class: class type | ||
| 673 | * @adev: ACPI_COMPANION device to match. | ||
| 674 | */ | ||
| 675 | static inline struct device * | ||
| 676 | class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev) | ||
| 677 | { | ||
| 678 | return class_find_device(class, NULL, adev, device_match_acpi_dev); | ||
| 679 | } | ||
| 680 | #else | ||
| 681 | static inline struct device * | ||
| 682 | class_find_device_by_acpi_dev(struct class *class, const void *adev) | ||
| 683 | { | ||
| 684 | return NULL; | ||
| 685 | } | ||
| 686 | #endif | ||
| 687 | |||
| 623 | struct class_attribute { | 688 | struct class_attribute { |
| 624 | struct attribute attr; | 689 | struct attribute attr; |
| 625 | ssize_t (*show)(struct class *class, struct class_attribute *attr, | 690 | ssize_t (*show)(struct class *class, struct class_attribute *attr, |
