mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
ANDROID: driver core: Allow a device to wait on optional suppliers
Before this change, if a device is waiting on suppliers, it's assumed that all those suppliers are needed for the device to probe successfully. This change allows marking a devices as waiting only on optional suppliers. This allows a device to wait on suppliers (and link to them as soon as they are available) without preventing the device from being probed. Signed-off-by: Saravana Kannan <saravanak@google.com> Bug: 142657042 Change-Id: I86a764b67804ed889f17c55632e25d46a72912a8
This commit is contained in:
@@ -479,13 +479,25 @@ EXPORT_SYMBOL_GPL(device_link_add);
|
||||
* This function is NOT meant to be called from the probe function of the
|
||||
* consumer but rather from code that creates/adds the consumer device.
|
||||
*/
|
||||
static void device_link_wait_for_supplier(struct device *consumer)
|
||||
static void device_link_wait_for_supplier(struct device *consumer,
|
||||
bool need_for_probe)
|
||||
{
|
||||
mutex_lock(&wfs_lock);
|
||||
list_add_tail(&consumer->links.needs_suppliers, &wait_for_suppliers);
|
||||
consumer->links.need_for_probe = need_for_probe;
|
||||
mutex_unlock(&wfs_lock);
|
||||
}
|
||||
|
||||
static void device_link_wait_for_mandatory_supplier(struct device *consumer)
|
||||
{
|
||||
device_link_wait_for_supplier(consumer, true);
|
||||
}
|
||||
|
||||
static void device_link_wait_for_optional_supplier(struct device *consumer)
|
||||
{
|
||||
device_link_wait_for_supplier(consumer, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* device_link_add_missing_supplier_links - Add links from consumer devices to
|
||||
* supplier devices, leaving any
|
||||
@@ -655,7 +667,8 @@ int device_links_check_suppliers(struct device *dev)
|
||||
* probe.
|
||||
*/
|
||||
mutex_lock(&wfs_lock);
|
||||
if (!list_empty(&dev->links.needs_suppliers)) {
|
||||
if (!list_empty(&dev->links.needs_suppliers) &&
|
||||
dev->links.need_for_probe) {
|
||||
mutex_unlock(&wfs_lock);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
@@ -759,6 +772,15 @@ void device_links_driver_bound(struct device *dev)
|
||||
{
|
||||
struct device_link *link;
|
||||
|
||||
/*
|
||||
* If a device probes successfully, it's expected to have created all
|
||||
* the device links it needs to or make new device links as it needs
|
||||
* them. So, it no longer needs to wait on any suppliers.
|
||||
*/
|
||||
mutex_lock(&wfs_lock);
|
||||
list_del_init(&dev->links.needs_suppliers);
|
||||
mutex_unlock(&wfs_lock);
|
||||
|
||||
device_links_write_lock();
|
||||
|
||||
list_for_each_entry(link, &dev->links.consumers, s_node) {
|
||||
@@ -2392,7 +2414,7 @@ int device_add(struct device *dev)
|
||||
|
||||
if (fwnode_has_op(dev->fwnode, add_links)
|
||||
&& fwnode_call_int_op(dev->fwnode, add_links, dev))
|
||||
device_link_wait_for_supplier(dev);
|
||||
device_link_wait_for_mandatory_supplier(dev, true);
|
||||
|
||||
bus_probe_device(dev);
|
||||
if (parent)
|
||||
|
||||
@@ -1155,6 +1155,8 @@ enum dl_dev_state {
|
||||
* @consumers: List of links to consumer devices.
|
||||
* @needs_suppliers: Hook to global list of devices waiting for suppliers.
|
||||
* @defer_sync: Hook to global list of devices that have deferred sync_state.
|
||||
* @need_for_probe: If needs_suppliers is on a list, this indicates if the
|
||||
* suppliers are needed for probe or not.
|
||||
* @status: Driver status information.
|
||||
*/
|
||||
struct dev_links_info {
|
||||
@@ -1162,6 +1164,7 @@ struct dev_links_info {
|
||||
struct list_head consumers;
|
||||
struct list_head needs_suppliers;
|
||||
struct list_head defer_sync;
|
||||
bool need_for_probe;
|
||||
enum dl_dev_state status;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user