diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-14 03:49:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-21 12:37:30 -0400 |
commit | 673fae90d5ee4ae2b6403f9d45af7ff640f06a60 (patch) | |
tree | 62b2782e9e6b9e02bd6048ec34b16b76001ed602 /drivers/base | |
parent | e9045f9178f3e3445a3a5b85206f8681b3869562 (diff) |
firmware loader: rely on driver core to create class attribute
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | 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 d45d1e1c40a4..d351e773f439 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -101,9 +101,26 @@ firmware_timeout_store(struct class *class, | |||
101 | return count; | 101 | return count; |
102 | } | 102 | } |
103 | 103 | ||
104 | static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); | 104 | static struct class_attribute firmware_class_attrs[] = { |
105 | __ATTR(timeout, S_IWUSR | S_IRUGO, | ||
106 | firmware_timeout_show, firmware_timeout_store), | ||
107 | __ATTR_NULL | ||
108 | }; | ||
105 | 109 | ||
106 | static void fw_dev_release(struct device *dev); | 110 | static void fw_dev_release(struct device *dev) |
111 | { | ||
112 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
113 | int i; | ||
114 | |||
115 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
116 | __free_page(fw_priv->pages[i]); | ||
117 | kfree(fw_priv->pages); | ||
118 | kfree(fw_priv->fw_id); | ||
119 | kfree(fw_priv); | ||
120 | kfree(dev); | ||
121 | |||
122 | module_put(THIS_MODULE); | ||
123 | } | ||
107 | 124 | ||
108 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | 125 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) |
109 | { | 126 | { |
@@ -121,6 +138,7 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
121 | 138 | ||
122 | static struct class firmware_class = { | 139 | static struct class firmware_class = { |
123 | .name = "firmware", | 140 | .name = "firmware", |
141 | .class_attrs = firmware_class_attrs, | ||
124 | .dev_uevent = firmware_uevent, | 142 | .dev_uevent = firmware_uevent, |
125 | .dev_release = fw_dev_release, | 143 | .dev_release = fw_dev_release, |
126 | }; | 144 | }; |
@@ -370,21 +388,6 @@ static struct bin_attribute firmware_attr_data_tmpl = { | |||
370 | .write = firmware_data_write, | 388 | .write = firmware_data_write, |
371 | }; | 389 | }; |
372 | 390 | ||
373 | static void fw_dev_release(struct device *dev) | ||
374 | { | ||
375 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
376 | int i; | ||
377 | |||
378 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
379 | __free_page(fw_priv->pages[i]); | ||
380 | kfree(fw_priv->pages); | ||
381 | kfree(fw_priv->fw_id); | ||
382 | kfree(fw_priv); | ||
383 | kfree(dev); | ||
384 | |||
385 | module_put(THIS_MODULE); | ||
386 | } | ||
387 | |||
388 | static void | 391 | static void |
389 | firmware_class_timeout(u_long data) | 392 | firmware_class_timeout(u_long data) |
390 | { | 393 | { |
@@ -689,26 +692,12 @@ request_firmware_nowait( | |||
689 | return 0; | 692 | return 0; |
690 | } | 693 | } |
691 | 694 | ||
692 | static int __init | 695 | static int __init firmware_class_init(void) |
693 | firmware_class_init(void) | ||
694 | { | 696 | { |
695 | int error; | 697 | return class_register(&firmware_class); |
696 | error = class_register(&firmware_class); | ||
697 | if (error) { | ||
698 | printk(KERN_ERR "%s: class_register failed\n", __func__); | ||
699 | return error; | ||
700 | } | ||
701 | error = class_create_file(&firmware_class, &class_attr_timeout); | ||
702 | if (error) { | ||
703 | printk(KERN_ERR "%s: class_create_file failed\n", | ||
704 | __func__); | ||
705 | class_unregister(&firmware_class); | ||
706 | } | ||
707 | return error; | ||
708 | |||
709 | } | 698 | } |
710 | static void __exit | 699 | |
711 | firmware_class_exit(void) | 700 | static void __exit firmware_class_exit(void) |
712 | { | 701 | { |
713 | class_unregister(&firmware_class); | 702 | class_unregister(&firmware_class); |
714 | } | 703 | } |