aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-30 07:26:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-30 07:26:39 -0400
commitf87da58b797aa591f2e288c7012faf3ab1e54c55 (patch)
treec1c991fe1350515a7b5ca01818f66f677cc0e14e /include/linux/device.h
parentfb583c8eeeb1fd57e24ef41ed94c9112067aeac9 (diff)
parent36f3313d6bff91ab2a9e47698c27d15363640a4e (diff)
Merge branch 'generic_lookup_helpers' into driver-core-next
This was on a separate branch so that others can pull it in. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h237
1 files changed, 234 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index c1c489921e4c..23ef6eba7213 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -164,16 +164,100 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter,
164struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); 164struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
165void subsys_dev_iter_exit(struct subsys_dev_iter *iter); 165void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
166 166
167int device_match_name(struct device *dev, const void *name);
167int device_match_of_node(struct device *dev, const void *np); 168int device_match_of_node(struct device *dev, const void *np);
169int device_match_fwnode(struct device *dev, const void *fwnode);
170int device_match_devt(struct device *dev, const void *pdevt);
171int device_match_acpi_dev(struct device *dev, const void *adev);
172int device_match_any(struct device *dev, const void *unused);
168 173
169int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, 174int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
170 int (*fn)(struct device *dev, void *data)); 175 int (*fn)(struct device *dev, void *data));
171struct device *bus_find_device(struct bus_type *bus, struct device *start, 176struct device *bus_find_device(struct bus_type *bus, struct device *start,
172 const void *data, 177 const void *data,
173 int (*match)(struct device *dev, const void *data)); 178 int (*match)(struct device *dev, const void *data));
174struct device *bus_find_device_by_name(struct bus_type *bus, 179/**
175 struct device *start, 180 * bus_find_device_by_name - device iterator for locating a particular device
176 const char *name); 181 * of a specific name.
182 * @bus: bus type
183 * @start: Device to begin with
184 * @name: name of the device to match
185 */
186static inline struct device *bus_find_device_by_name(struct bus_type *bus,
187 struct device *start,
188 const char *name)
189{
190 return bus_find_device(bus, start, name, device_match_name);
191}
192
193/**
194 * bus_find_device_by_of_node : device iterator for locating a particular device
195 * matching the of_node.
196 * @bus: bus type
197 * @np: of_node of the device to match.
198 */
199static inline struct device *
200bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
201{
202 return bus_find_device(bus, NULL, np, device_match_of_node);
203}
204
205/**
206 * bus_find_device_by_fwnode : device iterator for locating a particular device
207 * matching the fwnode.
208 * @bus: bus type
209 * @fwnode: fwnode of the device to match.
210 */
211static inline struct device *
212bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
213{
214 return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
215}
216
217/**
218 * bus_find_device_by_devt : device iterator for locating a particular device
219 * matching the device type.
220 * @bus: bus type
221 * @devt: device type of the device to match.
222 */
223static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
224 dev_t devt)
225{
226 return bus_find_device(bus, NULL, &devt, device_match_devt);
227}
228
229/**
230 * bus_find_next_device - Find the next device after a given device in a
231 * given bus.
232 */
233static inline struct device *
234bus_find_next_device(struct bus_type *bus,struct device *cur)
235{
236 return bus_find_device(bus, cur, NULL, device_match_any);
237}
238
239#ifdef CONFIG_ACPI
240struct acpi_device;
241
242/**
243 * bus_find_device_by_acpi_dev : device iterator for locating a particular device
244 * matching the ACPI COMPANION device.
245 * @bus: bus type
246 * @adev: ACPI COMPANION device to match.
247 */
248static inline struct device *
249bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev)
250{
251 return bus_find_device(bus, NULL, adev, device_match_acpi_dev);
252}
253#else
254static inline struct device *
255bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
256{
257 return NULL;
258}
259#endif
260
177struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, 261struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
178 struct device *hint); 262 struct device *hint);
179int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, 263int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
@@ -342,6 +426,83 @@ struct device *driver_find_device(struct device_driver *drv,
342 struct device *start, const void *data, 426 struct device *start, const void *data,
343 int (*match)(struct device *dev, const void *data)); 427 int (*match)(struct device *dev, const void *data));
344 428
429/**
430 * driver_find_device_by_name - device iterator for locating a particular device
431 * of a specific name.
432 * @driver: the driver we're iterating
433 * @name: name of the device to match
434 */
435static inline struct device *driver_find_device_by_name(struct device_driver *drv,
436 const char *name)
437{
438 return driver_find_device(drv, NULL, name, device_match_name);
439}
440
441/**
442 * driver_find_device_by_of_node- device iterator for locating a particular device
443 * by of_node pointer.
444 * @driver: the driver we're iterating
445 * @np: of_node pointer to match.
446 */
447static inline struct device *
448driver_find_device_by_of_node(struct device_driver *drv,
449 const struct device_node *np)
450{
451 return driver_find_device(drv, NULL, np, device_match_of_node);
452}
453
454/**
455 * driver_find_device_by_fwnode- device iterator for locating a particular device
456 * by fwnode pointer.
457 * @driver: the driver we're iterating
458 * @fwnode: fwnode pointer to match.
459 */
460static inline struct device *
461driver_find_device_by_fwnode(struct device_driver *drv,
462 const struct fwnode_handle *fwnode)
463{
464 return driver_find_device(drv, NULL, fwnode, device_match_fwnode);
465}
466
467/**
468 * driver_find_device_by_devt- device iterator for locating a particular device
469 * by devt.
470 * @driver: the driver we're iterating
471 * @devt: devt pointer to match.
472 */
473static inline struct device *driver_find_device_by_devt(struct device_driver *drv,
474 dev_t devt)
475{
476 return driver_find_device(drv, NULL, &devt, device_match_devt);
477}
478
479static inline struct device *driver_find_next_device(struct device_driver *drv,
480 struct device *start)
481{
482 return driver_find_device(drv, start, NULL, device_match_any);
483}
484
485#ifdef CONFIG_ACPI
486/**
487 * driver_find_device_by_acpi_dev : device iterator for locating a particular
488 * device matching the ACPI_COMPANION device.
489 * @driver: the driver we're iterating
490 * @adev: ACPI_COMPANION device to match.
491 */
492static inline struct device *
493driver_find_device_by_acpi_dev(struct device_driver *drv,
494 const struct acpi_device *adev)
495{
496 return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
497}
498#else
499static inline struct device *
500driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
501{
502 return NULL;
503}
504#endif
505
345void driver_deferred_probe_add(struct device *dev); 506void driver_deferred_probe_add(struct device *dev);
346int driver_deferred_probe_check_state(struct device *dev); 507int driver_deferred_probe_check_state(struct device *dev);
347int driver_deferred_probe_check_state_continue(struct device *dev); 508int driver_deferred_probe_check_state_continue(struct device *dev);
@@ -471,6 +632,76 @@ extern struct device *class_find_device(struct class *class,
471 struct device *start, const void *data, 632 struct device *start, const void *data,
472 int (*match)(struct device *, const void *)); 633 int (*match)(struct device *, const void *));
473 634
635/**
636 * class_find_device_by_name - device iterator for locating a particular device
637 * of a specific name.
638 * @class: class type
639 * @name: name of the device to match
640 */
641static inline struct device *class_find_device_by_name(struct class *class,
642 const char *name)
643{
644 return class_find_device(class, NULL, name, device_match_name);
645}
646
647/**
648 * class_find_device_by_of_node : device iterator for locating a particular device
649 * matching the of_node.
650 * @class: class type
651 * @np: of_node of the device to match.
652 */
653static inline struct device *
654class_find_device_by_of_node(struct class *class, const struct device_node *np)
655{
656 return class_find_device(class, NULL, np, device_match_of_node);
657}
658
659/**
660 * class_find_device_by_fwnode : device iterator for locating a particular device
661 * matching the fwnode.
662 * @class: class type
663 * @fwnode: fwnode of the device to match.
664 */
665static inline struct device *
666class_find_device_by_fwnode(struct class *class,
667 const struct fwnode_handle *fwnode)
668{
669 return class_find_device(class, NULL, fwnode, device_match_fwnode);
670}
671
672/**
673 * class_find_device_by_devt : device iterator for locating a particular device
674 * matching the device type.
675 * @class: class type
676 * @devt: device type of the device to match.
677 */
678static inline struct device *class_find_device_by_devt(struct class *class,
679 dev_t devt)
680{
681 return class_find_device(class, NULL, &devt, device_match_devt);
682}
683
684#ifdef CONFIG_ACPI
685struct acpi_device;
686/**
687 * class_find_device_by_acpi_dev : device iterator for locating a particular
688 * device matching the ACPI_COMPANION device.
689 * @class: class type
690 * @adev: ACPI_COMPANION device to match.
691 */
692static inline struct device *
693class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev)
694{
695 return class_find_device(class, NULL, adev, device_match_acpi_dev);
696}
697#else
698static inline struct device *
699class_find_device_by_acpi_dev(struct class *class, const void *adev)
700{
701 return NULL;
702}
703#endif
704
474struct class_attribute { 705struct class_attribute {
475 struct attribute attr; 706 struct attribute attr;
476 ssize_t (*show)(struct class *class, struct class_attribute *attr, 707 ssize_t (*show)(struct class *class, struct class_attribute *attr,