Browse Source

firmware class: export nowait to userspace

When we use request_firmware_nowait(), userspace may
not want to answer negatively right away when for
example it is answering from an initrd only, but
with request_firmware() it has to in order to not
delay the kernel boot until the request times out.

This allows userspace to differentiate between the
two in order to be able to reply negatively to async
requests only when all filesystems have been mounted
and have been checked for the requested firmware file.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Johannes Berg 15 years ago
parent
commit
e9045f9178
1 changed files with 11 additions and 5 deletions
  1. 11 5
      drivers/base/firmware_class.c

+ 11 - 5
drivers/base/firmware_class.c

@@ -50,6 +50,7 @@ struct firmware_priv {
 	int page_array_size;
 	int page_array_size;
 	const char *vdata;
 	const char *vdata;
 	struct timer_list timeout;
 	struct timer_list timeout;
+	bool nowait;
 };
 };
 
 
 #ifdef CONFIG_FW_LOADER
 #ifdef CONFIG_FW_LOADER
@@ -112,6 +113,8 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
 		return -ENOMEM;
 		return -ENOMEM;
 	if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
 	if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
 		return -ENOMEM;
 		return -ENOMEM;
+	if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait))
+		return -ENOMEM;
 
 
 	return 0;
 	return 0;
 }
 }
@@ -441,7 +444,7 @@ error_kfree:
 
 
 static int fw_setup_device(struct firmware *fw, struct device **dev_p,
 static int fw_setup_device(struct firmware *fw, struct device **dev_p,
 			   const char *fw_name, struct device *device,
 			   const char *fw_name, struct device *device,
-			   int uevent)
+			   int uevent, bool nowait)
 {
 {
 	struct device *f_dev;
 	struct device *f_dev;
 	struct firmware_priv *fw_priv;
 	struct firmware_priv *fw_priv;
@@ -457,6 +460,8 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
 
 
 	fw_priv = dev_get_drvdata(f_dev);
 	fw_priv = dev_get_drvdata(f_dev);
 
 
+	fw_priv->nowait = nowait;
+
 	fw_priv->fw = fw;
 	fw_priv->fw = fw;
 	sysfs_bin_attr_init(&fw_priv->attr_data);
 	sysfs_bin_attr_init(&fw_priv->attr_data);
 	retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
 	retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
@@ -484,7 +489,7 @@ out:
 
 
 static int
 static int
 _request_firmware(const struct firmware **firmware_p, const char *name,
 _request_firmware(const struct firmware **firmware_p, const char *name,
-		 struct device *device, int uevent)
+		 struct device *device, int uevent, bool nowait)
 {
 {
 	struct device *f_dev;
 	struct device *f_dev;
 	struct firmware_priv *fw_priv;
 	struct firmware_priv *fw_priv;
@@ -516,7 +521,8 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 	if (uevent)
 	if (uevent)
 		dev_dbg(device, "firmware: requesting %s\n", name);
 		dev_dbg(device, "firmware: requesting %s\n", name);
 
 
-	retval = fw_setup_device(firmware, &f_dev, name, device, uevent);
+	retval = fw_setup_device(firmware, &f_dev, name, device,
+				 uevent, nowait);
 	if (retval)
 	if (retval)
 		goto error_kfree_fw;
 		goto error_kfree_fw;
 
 
@@ -573,7 +579,7 @@ request_firmware(const struct firmware **firmware_p, const char *name,
                  struct device *device)
                  struct device *device)
 {
 {
         int uevent = 1;
         int uevent = 1;
-        return _request_firmware(firmware_p, name, device, uevent);
+        return _request_firmware(firmware_p, name, device, uevent, false);
 }
 }
 
 
 /**
 /**
@@ -619,7 +625,7 @@ request_firmware_work_func(void *arg)
 		return 0;
 		return 0;
 	}
 	}
 	ret = _request_firmware(&fw, fw_work->name, fw_work->device,
 	ret = _request_firmware(&fw, fw_work->name, fw_work->device,
-		fw_work->uevent);
+		fw_work->uevent, true);
 
 
 	fw_work->cont(fw, fw_work->context);
 	fw_work->cont(fw, fw_work->context);