All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: Allocate firmware id dynamically
@ 2009-05-26 14:04 Samuel Ortiz
  2009-05-26 14:11 ` Kay Sievers
  2009-05-26 14:51 ` [PATCH] libertas: adapt for dynamic firmware id allocation John W. Linville
  0 siblings, 2 replies; 12+ messages in thread
From: Samuel Ortiz @ 2009-05-26 14:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Kay Sievers, Marcel Holtmann, Zhu, Yi, linux-kernel, linville

Hi Andrew,

Since the firmware loader is not maintained by anyone, I'm sending this one to
you, for the next merge window:

From: Samuel Ortiz <sameo@linux.intel.com>

The firmware loader has a statically allocated 30 bytes long string for the
firmware id (a.k.a. the firmware file name). There is no reason why we couldnt
allocate dynamically, and avoid having restrictions on the firmware names
lengths.
Please note that we have to keep the FIRMWARE_NAME_MAX definition around as
some drivers rely on it.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---

 drivers/base/firmware_class.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d3a59c6..1f0daf9 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -40,7 +40,7 @@ static int loading_timeout = 60;	/* In seconds */
 static DEFINE_MUTEX(fw_lock);
 
 struct firmware_priv {
-	char fw_id[FIRMWARE_NAME_MAX];
+	char *fw_id;
 	struct completion completion;
 	struct bin_attribute attr_data;
 	struct firmware *fw;
@@ -278,6 +278,7 @@ static void fw_dev_release(struct device *dev)
 {
 	struct firmware_priv *fw_priv = dev_get_drvdata(dev);
 
+	kfree(fw_priv->fw_id);
 	kfree(fw_priv);
 	kfree(dev);
 
@@ -309,7 +310,13 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 
 	init_completion(&fw_priv->completion);
 	fw_priv->attr_data = firmware_attr_data_tmpl;
-	strlcpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
+	fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL);
+	if (!fw_priv->fw_id) {
+		dev_err(device, "%s: Firmware name allocation failed\n",
+			__func__);
+		retval = -ENOMEM;
+		goto error_kfree;
+	}
 
 	fw_priv->timeout.function = firmware_class_timeout;
 	fw_priv->timeout.data = (u_long) fw_priv;
@@ -323,11 +330,14 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
 	retval = device_register(f_dev);
 	if (retval) {
 		dev_err(device, "%s: device_register failed\n", __func__);
-		goto error_kfree;
+		goto error_kfree_fw_id;
 	}
 	*dev_p = f_dev;
 	return 0;
 
+error_kfree_fw_id:
+	kfree(fw_priv->fw_id);
+
 error_kfree:
 	kfree(fw_priv);
 	kfree(f_dev);

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-27 15:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-26 14:04 [PATCH] firmware: Allocate firmware id dynamically Samuel Ortiz
2009-05-26 14:11 ` Kay Sievers
2009-05-26 20:23   ` Andrew Morton
2009-05-27  1:57     ` Stephen Rothwell
2009-05-27  8:17       ` Samuel Ortiz
2009-05-27  8:30         ` Kay Sievers
2009-05-27 15:04           ` Greg KH
2009-05-27  9:16         ` John W. Linville
2009-05-27  9:53           ` Samuel Ortiz
2009-05-27  6:19   ` Marcel Holtmann
2009-05-26 14:51 ` [PATCH] libertas: adapt for dynamic firmware id allocation John W. Linville
2009-05-26 17:02   ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.