static void fw_devlink_link_device(struct device *dev)
{
	int fw_ret;

	if (!fw_devlink_flags)
		return;

	mutex_lock(&defer_fw_devlink_lock);
	if (!defer_fw_devlink_count)
		device_link_add_missing_supplier_links();

	/*
	 * The device's fwnode not having add_links() doesn't affect if other
	 * consumers can find this device as a supplier.  So, this check is
	 * intentionally placed after device_link_add_missing_supplier_links().
	 */
	if (!fwnode_has_op(dev->fwnode, add_links))
		goto out;

	/*
	 * If fw_devlink is being deferred, assume all devices have mandatory
	 * suppliers they need to link to later. Then, when the fw_devlink is
	 * resumed, all these devices will get a chance to try and link to any
	 * suppliers they have.
	 */
	if (!defer_fw_devlink_count) {
		fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
		if (fw_ret == -ENODEV && fw_devlink_is_permissive())
			fw_ret = -EAGAIN;
	} else {
		fw_ret = -ENODEV;
		/*
		 * defer_hook is not used to add device to deferred_sync list
		 * until device is bound. Since deferred fw devlink also blocks
		 * probing, same list hook can be used for deferred_fw_devlink.
		 */
		list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink);
	}

	if (fw_ret == -ENODEV)
		device_link_wait_for_mandatory_supplier(dev);
	else if (fw_ret)
		device_link_wait_for_optional_supplier(dev);

out:
	mutex_unlock(&defer_fw_devlink_lock);
}
static void fw_devlink_link_device(struct device *dev)
{
	int fw_ret;

	if (!fw_devlink_flags)
		return;

	mutex_lock(&defer_fw_devlink_lock);
	if (!defer_fw_devlink_count)
		device_link_add_missing_supplier_links();

	 
	if (!fwnode_has_op(dev->fwnode, add_links))
		goto out;

	 
	if (!defer_fw_devlink_count) {
		fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
		if (fw_ret == -ENODEV && fw_devlink_is_permissive())
			fw_ret = -EAGAIN;
	} else {
		fw_ret = -ENODEV;
		 
		list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink);
	}

	if (fw_ret == -ENODEV)
		device_link_wait_for_mandatory_supplier(dev);
	else if (fw_ret)
		device_link_wait_for_optional_supplier(dev);

out:
	mutex_unlock(&defer_fw_devlink_lock);
}