From: Magnus Damm <magnus.damm@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
Randy Dunlap <rdunlap@xenotime.net>,
linux-doc@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>,
Dmitry Torokhov <dtor@mail.ru>,
Marcel Holtmann <marcel@holtmann.org>,
Magnus Damm <magnus.damm@gmail.com>,
Ming Lei <tom.leiming@gmail.com>
Subject: [PATCH] firmware: Update hotplug script, remove sysfs files
Date: Fri, 25 Jun 2010 17:55:11 +0900 [thread overview]
Message-ID: <20100625085511.30949.41045.sendpatchset@t400s> (raw)
From: Magnus Damm <damm@opensource.se>
Update the in-kernel hotplug example script to work
properly with recent kernels. Without this fix the
script may load the firmware twice - both at "add"
and "remove" time.
The second load only triggers in the case when multiple
firmware images are used. A good example is the b43
driver which does not work properly without this fix.
While at it, make sure sysfs files are removed.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Documentation/firmware_class/hotplug-script | 17 +++++++++--------
drivers/base/firmware_class.c | 6 +++++-
2 files changed, 14 insertions(+), 9 deletions(-)
--- 0001/Documentation/firmware_class/hotplug-script
+++ work/Documentation/firmware_class/hotplug-script 2010-06-25 14:46:17.000000000 +0900
@@ -6,11 +6,12 @@
HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/
-echo 1 > /sys/$DEVPATH/loading
-cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
-echo 0 > /sys/$DEVPATH/loading
-
-# To cancel the load in case of error:
-#
-# echo -1 > /sys/$DEVPATH/loading
-#
+if [ "$SUBSYSTEM" == "firmware" -a "$ACTION" == "add" ]; then
+ if [ -f $HOTPLUG_FW_DIR/$FIRMWARE ]; then
+ echo 1 > /sys/$DEVPATH/loading
+ cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data
+ echo 0 > /sys/$DEVPATH/loading
+ else
+ echo -1 > /sys/$DEVPATH/loading
+ fi
+fi
--- 0001/drivers/base/firmware_class.c
+++ work/drivers/base/firmware_class.c 2010-06-25 14:48:53.000000000 +0900
@@ -508,7 +508,7 @@ static int fw_setup_device(struct firmwa
retval = device_create_file(f_dev, &dev_attr_loading);
if (retval) {
dev_err(device, "%s: device_create_file failed\n", __func__);
- goto error_unreg;
+ goto error_unreg2;
}
if (uevent)
@@ -516,6 +516,8 @@ static int fw_setup_device(struct firmwa
*dev_p = f_dev;
goto out;
+error_unreg2:
+ sysfs_remove_bin_file(&f_dev->kobj, &fw_priv->attr_data);
error_unreg:
device_unregister(f_dev);
out:
@@ -578,6 +580,8 @@ _request_firmware(const struct firmware
}
fw_priv->fw = NULL;
mutex_unlock(&fw_lock);
+ sysfs_remove_bin_file(&f_dev->kobj, &fw_priv->attr_data);
+ device_remove_file(f_dev, &dev_attr_loading);
device_unregister(f_dev);
goto out;
next reply other threads:[~2010-06-25 8:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 8:55 Magnus Damm [this message]
2010-06-25 18:22 ` [PATCH] firmware: Update hotplug script, remove sysfs files Greg KH
2010-06-28 6:17 ` Magnus Damm
2010-06-28 7:56 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100625085511.30949.41045.sendpatchset@t400s \
--to=magnus.damm@gmail.com \
--cc=dtor@mail.ru \
--cc=gregkh@suse.de \
--cc=johannes.berg@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=rdunlap@xenotime.net \
--cc=tom.leiming@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox