aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorSaravana Kannan <saravanak@google.com>2019-07-31 15:17:14 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-01 16:04:13 +0200
commit5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886 (patch)
treef168591fba3257dc48e79814cd60c6d49052659f /include/linux/device.h
parentdrivers: Fix htmldocs warnings with bus_find_next_device() (diff)
downloadlinux-dev-5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886.tar.xz
linux-dev-5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886.zip
driver core: Add support for linking devices during device addition
When devices are added, the bus might want to create device links to track functional dependencies between supplier and consumer devices. This tracking of supplier-consumer relationship allows optimizing device probe order and tracking whether all consumers of a supplier are active. The add_links bus callback is added to support this. However, when consumer devices are added, they might not have a supplier device to link to despite needing mandatory resources/functionality from one or more suppliers. A waiting_for_suppliers list is created to track such consumers and retry linking them when new devices get added. Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20190731221721.187713-2-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index bff46ce3bc3b..1e05911325f0 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -78,6 +78,17 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
* -EPROBE_DEFER it will queue the device for deferred probing.
* @uevent: Called when a device is added, removed, or a few other things
* that generate uevents to add the environment variables.
+ * @add_links: Called, perhaps multiple times per device, after a device is
+ * added to this bus. The function is expected to create device
+ * links to all the suppliers of the input device that are
+ * available at the time this function is called. As in, the
+ * function should NOT stop at the first failed device link if
+ * other unlinked supplier devices are present in the system.
+ *
+ * Return 0 if device links have been successfully created to all
+ * the suppliers of this device. Return an error if some of the
+ * suppliers are not yet available and this function needs to be
+ * reattempted in the future.
* @probe: Called when a new device or driver add to this bus, and callback
* the specific driver's probe to initial the matched device.
* @remove: Called when a device removed from this bus.
@@ -122,6 +133,7 @@ struct bus_type {
int (*match)(struct device *dev, struct device_driver *drv);
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
+ int (*add_links)(struct device *dev);
int (*probe)(struct device *dev);
int (*remove)(struct device *dev);
void (*shutdown)(struct device *dev);
@@ -1128,11 +1140,13 @@ enum dl_dev_state {
* struct dev_links_info - Device data related to device links.
* @suppliers: List of links to supplier devices.
* @consumers: List of links to consumer devices.
+ * @needs_suppliers: Hook to global list of devices waiting for suppliers.
* @status: Driver status information.
*/
struct dev_links_info {
struct list_head suppliers;
struct list_head consumers;
+ struct list_head needs_suppliers;
enum dl_dev_state status;
};