From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] firmware loader: rely on driver core to create class attribute
Date: Sat, 13 Mar 2010 23:49:13 -0800 [thread overview]
Message-ID: <20100314074913.27035.39475.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100314074330.27035.38765.stgit@localhost.localdomain>
Do not create 'timeout' attribute manually, let driver core do it for us.
This also ensures that attribute is cleaned up properly.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/base/firmware_class.c | 59 +++++++++++++++++------------------------
1 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 3f50b2e..5f9d906 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -97,9 +97,26 @@ firmware_timeout_store(struct class *class,
return count;
}
-static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
+static struct class_attribute firmware_class_attrs[] = {
+ __ATTR(timeout, S_IWUSR | S_IRUGO,
+ firmware_timeout_show, firmware_timeout_store),
+ __ATTR_NULL
+};
-static void fw_dev_release(struct device *dev);
+static void fw_dev_release(struct device *dev)
+{
+ struct firmware_priv *fw_priv = dev_get_drvdata(dev);
+ int i;
+
+ for (i = 0; i < fw_priv->nr_pages; i++)
+ __free_page(fw_priv->pages[i]);
+ kfree(fw_priv->pages);
+ kfree(fw_priv->fw_id);
+ kfree(fw_priv);
+ kfree(dev);
+
+ module_put(THIS_MODULE);
+}
static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
{
@@ -115,6 +132,7 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
static struct class firmware_class = {
.name = "firmware",
+ .class_attrs = firmware_class_attrs,
.dev_uevent = firmware_uevent,
.dev_release = fw_dev_release,
};
@@ -350,21 +368,6 @@ static struct bin_attribute firmware_attr_data = {
.write = firmware_data_write,
};
-static void fw_dev_release(struct device *dev)
-{
- struct firmware_priv *fw_priv = dev_get_drvdata(dev);
- int i;
-
- for (i = 0; i < fw_priv->nr_pages; i++)
- __free_page(fw_priv->pages[i]);
- kfree(fw_priv->pages);
- kfree(fw_priv->fw_id);
- kfree(fw_priv);
- kfree(dev);
-
- module_put(THIS_MODULE);
-}
-
static void
firmware_class_timeout(u_long data)
{
@@ -665,26 +668,12 @@ request_firmware_nowait(
return 0;
}
-static int __init
-firmware_class_init(void)
+static int __init firmware_class_init(void)
{
- int error;
- error = class_register(&firmware_class);
- if (error) {
- printk(KERN_ERR "%s: class_register failed\n", __func__);
- return error;
- }
- error = class_create_file(&firmware_class, &class_attr_timeout);
- if (error) {
- printk(KERN_ERR "%s: class_create_file failed\n",
- __func__);
- class_unregister(&firmware_class);
- }
- return error;
-
+ return class_register(&firmware_class);
}
-static void __exit
-firmware_class_exit(void)
+
+static void __exit firmware_class_exit(void)
{
class_unregister(&firmware_class);
}
next prev parent reply other threads:[~2010-03-14 7:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-14 7:49 [PATCH 0/5] Assorted patches for firmware loader Dmitry Torokhov
2010-03-14 7:49 ` [PATCH 1/5] firmware loader: use statically initialized data attribute Dmitry Torokhov
2010-04-22 23:51 ` Greg KH
2010-03-14 7:49 ` Dmitry Torokhov [this message]
2010-03-14 7:49 ` [PATCH 3/5] firmware loader: split out builtin firmware handling Dmitry Torokhov
2010-03-14 7:49 ` [PATCH 4/5] firmware loader: do not allocate firmare id separately Dmitry Torokhov
2010-03-14 7:49 ` [PATCH 5/5] firmware loader: embed device into firmware_priv structure Dmitry Torokhov
2010-04-23 0:01 ` Greg KH
2010-04-23 0:19 ` Dmitry Torokhov
2010-04-23 3:16 ` Greg KH
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=20100314074913.27035.39475.stgit@localhost.localdomain \
--to=dmitry.torokhov@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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 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.