Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68ff2a00 authored by Ming Lei's avatar Ming Lei Committed by Greg Kroah-Hartman
Browse files

firmware_loader: handle timeout via wait_for_completion_interruptible_timeout()



It is simpler to handle timeout by wait_for_completion_interruptible_timeout(),
so remove previous delay work for timeout.

Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0cb64249
Loading
Loading
Loading
Loading
+6 −24
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@ static int loading_timeout = 60; /* In seconds */


static inline long firmware_loading_timeout(void)
static inline long firmware_loading_timeout(void)
{
{
	return loading_timeout > 0 ? loading_timeout * HZ : MAX_SCHEDULE_TIMEOUT;
	return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET;
}
}


/* firmware behavior options */
/* firmware behavior options */
@@ -446,7 +446,6 @@ static int fw_add_devm_name(struct device *dev, const char *name)
 */
 */
#ifdef CONFIG_FW_LOADER_USER_HELPER
#ifdef CONFIG_FW_LOADER_USER_HELPER
struct firmware_priv {
struct firmware_priv {
	struct delayed_work timeout_work;
	bool nowait;
	bool nowait;
	struct device dev;
	struct device dev;
	struct firmware_buf *buf;
	struct firmware_buf *buf;
@@ -836,16 +835,6 @@ static struct bin_attribute firmware_attr_data = {
	.write = firmware_data_write,
	.write = firmware_data_write,
};
};


static void firmware_class_timeout_work(struct work_struct *work)
{
	struct firmware_priv *fw_priv = container_of(work,
			struct firmware_priv, timeout_work.work);

	mutex_lock(&fw_lock);
	fw_load_abort(fw_priv);
	mutex_unlock(&fw_lock);
}

static struct firmware_priv *
static struct firmware_priv *
fw_create_instance(struct firmware *firmware, const char *fw_name,
fw_create_instance(struct firmware *firmware, const char *fw_name,
		   struct device *device, unsigned int opt_flags)
		   struct device *device, unsigned int opt_flags)
@@ -862,9 +851,6 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,


	fw_priv->nowait = !!(opt_flags & FW_OPT_NOWAIT);
	fw_priv->nowait = !!(opt_flags & FW_OPT_NOWAIT);
	fw_priv->fw = firmware;
	fw_priv->fw = firmware;
	INIT_DELAYED_WORK(&fw_priv->timeout_work,
		firmware_class_timeout_work);

	f_dev = &fw_priv->dev;
	f_dev = &fw_priv->dev;


	device_initialize(f_dev);
	device_initialize(f_dev);
@@ -917,18 +903,14 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
		buf->need_uevent = true;
		buf->need_uevent = true;
		dev_set_uevent_suppress(f_dev, false);
		dev_set_uevent_suppress(f_dev, false);
		dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
		dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
		if (timeout != MAX_SCHEDULE_TIMEOUT)
			queue_delayed_work(system_power_efficient_wq,
					   &fw_priv->timeout_work, timeout);

		kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
		kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
	} else {
		timeout = MAX_JIFFY_OFFSET;
	}
	}


	retval = wait_for_completion_interruptible(&buf->completion);
	retval = wait_for_completion_interruptible_timeout(&buf->completion,

			timeout);
	cancel_delayed_work_sync(&fw_priv->timeout_work);
	if (retval == -ERESTARTSYS || !retval) {

	if (retval == -ERESTARTSYS) {
		mutex_lock(&fw_lock);
		mutex_lock(&fw_lock);
		fw_load_abort(fw_priv);
		fw_load_abort(fw_priv);
		mutex_unlock(&fw_lock);
		mutex_unlock(&fw_lock);