diff options
-rw-r--r-- | Documentation/DocBook/device-drivers.tmpl | 1 | ||||
-rw-r--r-- | Documentation/filesystems/sysfs.txt | 46 | ||||
-rw-r--r-- | Documentation/firmware_class/hotplug-script | 17 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mv64x60_pci.c | 1 | ||||
-rw-r--r-- | drivers/base/bus.c | 2 | ||||
-rw-r--r-- | drivers/base/core.c | 2 | ||||
-rw-r--r-- | drivers/base/dd.c | 4 | ||||
-rw-r--r-- | drivers/base/dma-coherent.c | 2 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 262 | ||||
-rw-r--r-- | drivers/base/platform.c | 110 | ||||
-rw-r--r-- | drivers/firmware/dcdbas.c | 5 | ||||
-rw-r--r-- | drivers/firmware/dmi-id.c | 4 | ||||
-rw-r--r-- | drivers/leds/leds-bd2802.c | 4 | ||||
-rw-r--r-- | drivers/regulator/core.c | 1 | ||||
-rw-r--r-- | drivers/scsi/arcmsr/arcmsr_attr.c | 3 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 1 | ||||
-rw-r--r-- | drivers/uio/uio_cif.c | 2 | ||||
-rw-r--r-- | drivers/uio/uio_pdrv_genirq.c | 1 | ||||
-rw-r--r-- | drivers/uio/uio_sercos3.c | 2 | ||||
-rw-r--r-- | fs/sysfs/file.c | 3 | ||||
-rw-r--r-- | include/linux/device.h | 15 | ||||
-rw-r--r-- | include/linux/platform_device.h | 62 | ||||
-rw-r--r-- | include/linux/sysfs.h | 12 | ||||
-rw-r--r-- | kernel/cgroup.c | 13 | ||||
-rw-r--r-- | kernel/sysctl.c | 2 | ||||
-rw-r--r-- | lib/Kconfig.debug | 1 |
26 files changed, 288 insertions, 290 deletions
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl index 1b2dd4fc3db2..ecd35e9d4410 100644 --- a/Documentation/DocBook/device-drivers.tmpl +++ b/Documentation/DocBook/device-drivers.tmpl | |||
@@ -111,6 +111,7 @@ X!Edrivers/base/attribute_container.c | |||
111 | <!-- | 111 | <!-- |
112 | X!Edrivers/base/interface.c | 112 | X!Edrivers/base/interface.c |
113 | --> | 113 | --> |
114 | !Iinclude/linux/platform_device.h | ||
114 | !Edrivers/base/platform.c | 115 | !Edrivers/base/platform.c |
115 | !Edrivers/base/bus.c | 116 | !Edrivers/base/bus.c |
116 | </sect1> | 117 | </sect1> |
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index 931c806642c5..5d1335faec2d 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt | |||
@@ -4,7 +4,7 @@ sysfs - _The_ filesystem for exporting kernel objects. | |||
4 | Patrick Mochel <mochel@osdl.org> | 4 | Patrick Mochel <mochel@osdl.org> |
5 | Mike Murphy <mamurph@cs.clemson.edu> | 5 | Mike Murphy <mamurph@cs.clemson.edu> |
6 | 6 | ||
7 | Revised: 22 February 2009 | 7 | Revised: 15 July 2010 |
8 | Original: 10 January 2003 | 8 | Original: 10 January 2003 |
9 | 9 | ||
10 | 10 | ||
@@ -124,7 +124,7 @@ show and store methods of the attribute owners. | |||
124 | 124 | ||
125 | struct sysfs_ops { | 125 | struct sysfs_ops { |
126 | ssize_t (*show)(struct kobject *, struct attribute *, char *); | 126 | ssize_t (*show)(struct kobject *, struct attribute *, char *); |
127 | ssize_t (*store)(struct kobject *, struct attribute *, const char *); | 127 | ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); |
128 | }; | 128 | }; |
129 | 129 | ||
130 | [ Subsystems should have already defined a struct kobj_type as a | 130 | [ Subsystems should have already defined a struct kobj_type as a |
@@ -139,18 +139,22 @@ calls the associated methods. | |||
139 | 139 | ||
140 | To illustrate: | 140 | To illustrate: |
141 | 141 | ||
142 | #define to_dev(obj) container_of(obj, struct device, kobj) | ||
142 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) | 143 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
143 | #define to_dev(d) container_of(d, struct device, kobj) | ||
144 | 144 | ||
145 | static ssize_t | 145 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, |
146 | dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | 146 | char *buf) |
147 | { | 147 | { |
148 | struct device_attribute * dev_attr = to_dev_attr(attr); | 148 | struct device_attribute *dev_attr = to_dev_attr(attr); |
149 | struct device * dev = to_dev(kobj); | 149 | struct device *dev = to_dev(kobj); |
150 | ssize_t ret = 0; | 150 | ssize_t ret = -EIO; |
151 | 151 | ||
152 | if (dev_attr->show) | 152 | if (dev_attr->show) |
153 | ret = dev_attr->show(dev, buf); | 153 | ret = dev_attr->show(dev, dev_attr, buf); |
154 | if (ret >= (ssize_t)PAGE_SIZE) { | ||
155 | print_symbol("dev_attr_show: %s returned bad count\n", | ||
156 | (unsigned long)dev_attr->show); | ||
157 | } | ||
154 | return ret; | 158 | return ret; |
155 | } | 159 | } |
156 | 160 | ||
@@ -163,10 +167,9 @@ To read or write attributes, show() or store() methods must be | |||
163 | specified when declaring the attribute. The method types should be as | 167 | specified when declaring the attribute. The method types should be as |
164 | simple as those defined for device attributes: | 168 | simple as those defined for device attributes: |
165 | 169 | ||
166 | ssize_t (*show)(struct device * dev, struct device_attribute * attr, | 170 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf); |
167 | char * buf); | 171 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, |
168 | ssize_t (*store)(struct device * dev, struct device_attribute * attr, | 172 | const char *buf, size_t count); |
169 | const char * buf); | ||
170 | 173 | ||
171 | IOW, they should take only an object, an attribute, and a buffer as parameters. | 174 | IOW, they should take only an object, an attribute, and a buffer as parameters. |
172 | 175 | ||
@@ -209,8 +212,8 @@ Other notes: | |||
209 | 212 | ||
210 | - show() should always use snprintf(). | 213 | - show() should always use snprintf(). |
211 | 214 | ||
212 | - store() should return the number of bytes used from the buffer. This | 215 | - store() should return the number of bytes used from the buffer. If the |
213 | can be done using strlen(). | 216 | entire buffer has been used, just return the count argument. |
214 | 217 | ||
215 | - show() or store() can always return errors. If a bad value comes | 218 | - show() or store() can always return errors. If a bad value comes |
216 | through, be sure to return an error. | 219 | through, be sure to return an error. |
@@ -223,15 +226,18 @@ Other notes: | |||
223 | 226 | ||
224 | A very simple (and naive) implementation of a device attribute is: | 227 | A very simple (and naive) implementation of a device attribute is: |
225 | 228 | ||
226 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 229 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, |
230 | char *buf) | ||
227 | { | 231 | { |
228 | return snprintf(buf, PAGE_SIZE, "%s\n", dev->name); | 232 | return snprintf(buf, PAGE_SIZE, "%s\n", dev->name); |
229 | } | 233 | } |
230 | 234 | ||
231 | static ssize_t store_name(struct device * dev, const char * buf) | 235 | static ssize_t store_name(struct device *dev, struct device_attribute *attr, |
236 | const char *buf, size_t count) | ||
232 | { | 237 | { |
233 | sscanf(buf, "%20s", dev->name); | 238 | snprintf(dev->name, sizeof(dev->name), "%.*s", |
234 | return strnlen(buf, PAGE_SIZE); | 239 | (int)min(count, sizeof(dev->name) - 1), buf); |
240 | return count; | ||
235 | } | 241 | } |
236 | 242 | ||
237 | static DEVICE_ATTR(name, S_IRUGO, show_name, store_name); | 243 | static DEVICE_ATTR(name, S_IRUGO, show_name, store_name); |
@@ -327,7 +333,7 @@ Structure: | |||
327 | struct bus_attribute { | 333 | struct bus_attribute { |
328 | struct attribute attr; | 334 | struct attribute attr; |
329 | ssize_t (*show)(struct bus_type *, char * buf); | 335 | ssize_t (*show)(struct bus_type *, char * buf); |
330 | ssize_t (*store)(struct bus_type *, const char * buf); | 336 | ssize_t (*store)(struct bus_type *, const char * buf, size_t count); |
331 | }; | 337 | }; |
332 | 338 | ||
333 | Declaring: | 339 | Declaring: |
diff --git a/Documentation/firmware_class/hotplug-script b/Documentation/firmware_class/hotplug-script index 1990130f2ab1..8143a950b607 100644 --- a/Documentation/firmware_class/hotplug-script +++ b/Documentation/firmware_class/hotplug-script | |||
@@ -6,11 +6,12 @@ | |||
6 | 6 | ||
7 | HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/ | 7 | HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/ |
8 | 8 | ||
9 | echo 1 > /sys/$DEVPATH/loading | 9 | if [ "$SUBSYSTEM" == "firmware" -a "$ACTION" == "add" ]; then |
10 | cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data | 10 | if [ -f $HOTPLUG_FW_DIR/$FIRMWARE ]; then |
11 | echo 0 > /sys/$DEVPATH/loading | 11 | echo 1 > /sys/$DEVPATH/loading |
12 | 12 | cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data | |
13 | # To cancel the load in case of error: | 13 | echo 0 > /sys/$DEVPATH/loading |
14 | # | 14 | else |
15 | # echo -1 > /sys/$DEVPATH/loading | 15 | echo -1 > /sys/$DEVPATH/loading |
16 | # | 16 | fi |
17 | fi | ||
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c index 198f288570cc..77bb3f4d530a 100644 --- a/arch/powerpc/sysdev/mv64x60_pci.c +++ b/arch/powerpc/sysdev/mv64x60_pci.c | |||
@@ -73,7 +73,6 @@ static struct bin_attribute mv64x60_hs_reg_attr = { /* Hotswap register */ | |||
73 | .attr = { | 73 | .attr = { |
74 | .name = "hs_reg", | 74 | .name = "hs_reg", |
75 | .mode = S_IRUGO | S_IWUSR, | 75 | .mode = S_IRUGO | S_IWUSR, |
76 | .owner = THIS_MODULE, | ||
77 | }, | 76 | }, |
78 | .size = MV64X60_VAL_LEN_MAX, | 77 | .size = MV64X60_VAL_LEN_MAX, |
79 | .read = mv64x60_hs_reg_read, | 78 | .read = mv64x60_hs_reg_read, |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 12eec3f633b1..eb1b7fa20dce 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -945,8 +945,8 @@ bus_devices_fail: | |||
945 | bus_remove_file(bus, &bus_attr_uevent); | 945 | bus_remove_file(bus, &bus_attr_uevent); |
946 | bus_uevent_fail: | 946 | bus_uevent_fail: |
947 | kset_unregister(&bus->p->subsys); | 947 | kset_unregister(&bus->p->subsys); |
948 | kfree(bus->p); | ||
949 | out: | 948 | out: |
949 | kfree(bus->p); | ||
950 | bus->p = NULL; | 950 | bus->p = NULL; |
951 | return retval; | 951 | return retval; |
952 | } | 952 | } |
diff --git a/drivers/base/core.c b/drivers/base/core.c index f8e72724dd4b..d1b2c9adc271 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -1599,7 +1599,7 @@ EXPORT_SYMBOL_GPL(device_destroy); | |||
1599 | * on the same device to ensure that new_name is valid and | 1599 | * on the same device to ensure that new_name is valid and |
1600 | * won't conflict with other devices. | 1600 | * won't conflict with other devices. |
1601 | */ | 1601 | */ |
1602 | int device_rename(struct device *dev, char *new_name) | 1602 | int device_rename(struct device *dev, const char *new_name) |
1603 | { | 1603 | { |
1604 | char *old_class_name = NULL; | 1604 | char *old_class_name = NULL; |
1605 | char *new_class_name = NULL; | 1605 | char *new_class_name = NULL; |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 503c2620bbcc..da57ee9d63fe 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -51,6 +51,10 @@ static int driver_sysfs_add(struct device *dev) | |||
51 | { | 51 | { |
52 | int ret; | 52 | int ret; |
53 | 53 | ||
54 | if (dev->bus) | ||
55 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | ||
56 | BUS_NOTIFY_BIND_DRIVER, dev); | ||
57 | |||
54 | ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj, | 58 | ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj, |
55 | kobject_name(&dev->kobj)); | 59 | kobject_name(&dev->kobj)); |
56 | if (ret == 0) { | 60 | if (ret == 0) { |
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index d4d8ce53886a..f369e2795985 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | struct dma_coherent_mem { | 9 | struct dma_coherent_mem { |
10 | void *virt_base; | 10 | void *virt_base; |
11 | u32 device_base; | 11 | dma_addr_t device_base; |
12 | int size; | 12 | int size; |
13 | int flags; | 13 | int flags; |
14 | unsigned long *bitmap; | 14 | unsigned long *bitmap; |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 3f093b0dd217..c8a44f5e0584 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -87,29 +87,32 @@ static DEFINE_MUTEX(fw_lock); | |||
87 | 87 | ||
88 | struct firmware_priv { | 88 | struct firmware_priv { |
89 | struct completion completion; | 89 | struct completion completion; |
90 | struct bin_attribute attr_data; | ||
91 | struct firmware *fw; | 90 | struct firmware *fw; |
92 | unsigned long status; | 91 | unsigned long status; |
93 | struct page **pages; | 92 | struct page **pages; |
94 | int nr_pages; | 93 | int nr_pages; |
95 | int page_array_size; | 94 | int page_array_size; |
96 | struct timer_list timeout; | 95 | struct timer_list timeout; |
96 | struct device dev; | ||
97 | bool nowait; | 97 | bool nowait; |
98 | char fw_id[]; | 98 | char fw_id[]; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static void | 101 | static struct firmware_priv *to_firmware_priv(struct device *dev) |
102 | fw_load_abort(struct firmware_priv *fw_priv) | 102 | { |
103 | return container_of(dev, struct firmware_priv, dev); | ||
104 | } | ||
105 | |||
106 | static void fw_load_abort(struct firmware_priv *fw_priv) | ||
103 | { | 107 | { |
104 | set_bit(FW_STATUS_ABORT, &fw_priv->status); | 108 | set_bit(FW_STATUS_ABORT, &fw_priv->status); |
105 | wmb(); | 109 | wmb(); |
106 | complete(&fw_priv->completion); | 110 | complete(&fw_priv->completion); |
107 | } | 111 | } |
108 | 112 | ||
109 | static ssize_t | 113 | static ssize_t firmware_timeout_show(struct class *class, |
110 | firmware_timeout_show(struct class *class, | 114 | struct class_attribute *attr, |
111 | struct class_attribute *attr, | 115 | char *buf) |
112 | char *buf) | ||
113 | { | 116 | { |
114 | return sprintf(buf, "%d\n", loading_timeout); | 117 | return sprintf(buf, "%d\n", loading_timeout); |
115 | } | 118 | } |
@@ -127,14 +130,14 @@ firmware_timeout_show(struct class *class, | |||
127 | * | 130 | * |
128 | * Note: zero means 'wait forever'. | 131 | * Note: zero means 'wait forever'. |
129 | **/ | 132 | **/ |
130 | static ssize_t | 133 | static ssize_t firmware_timeout_store(struct class *class, |
131 | firmware_timeout_store(struct class *class, | 134 | struct class_attribute *attr, |
132 | struct class_attribute *attr, | 135 | const char *buf, size_t count) |
133 | const char *buf, size_t count) | ||
134 | { | 136 | { |
135 | loading_timeout = simple_strtol(buf, NULL, 10); | 137 | loading_timeout = simple_strtol(buf, NULL, 10); |
136 | if (loading_timeout < 0) | 138 | if (loading_timeout < 0) |
137 | loading_timeout = 0; | 139 | loading_timeout = 0; |
140 | |||
138 | return count; | 141 | return count; |
139 | } | 142 | } |
140 | 143 | ||
@@ -146,21 +149,20 @@ static struct class_attribute firmware_class_attrs[] = { | |||
146 | 149 | ||
147 | static void fw_dev_release(struct device *dev) | 150 | static void fw_dev_release(struct device *dev) |
148 | { | 151 | { |
149 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 152 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
150 | int i; | 153 | int i; |
151 | 154 | ||
152 | for (i = 0; i < fw_priv->nr_pages; i++) | 155 | for (i = 0; i < fw_priv->nr_pages; i++) |
153 | __free_page(fw_priv->pages[i]); | 156 | __free_page(fw_priv->pages[i]); |
154 | kfree(fw_priv->pages); | 157 | kfree(fw_priv->pages); |
155 | kfree(fw_priv); | 158 | kfree(fw_priv); |
156 | kfree(dev); | ||
157 | 159 | ||
158 | module_put(THIS_MODULE); | 160 | module_put(THIS_MODULE); |
159 | } | 161 | } |
160 | 162 | ||
161 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | 163 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) |
162 | { | 164 | { |
163 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 165 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
164 | 166 | ||
165 | if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id)) | 167 | if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id)) |
166 | return -ENOMEM; | 168 | return -ENOMEM; |
@@ -182,8 +184,9 @@ static struct class firmware_class = { | |||
182 | static ssize_t firmware_loading_show(struct device *dev, | 184 | static ssize_t firmware_loading_show(struct device *dev, |
183 | struct device_attribute *attr, char *buf) | 185 | struct device_attribute *attr, char *buf) |
184 | { | 186 | { |
185 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 187 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
186 | int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); | 188 | int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); |
189 | |||
187 | return sprintf(buf, "%d\n", loading); | 190 | return sprintf(buf, "%d\n", loading); |
188 | } | 191 | } |
189 | 192 | ||
@@ -219,7 +222,7 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
219 | struct device_attribute *attr, | 222 | struct device_attribute *attr, |
220 | const char *buf, size_t count) | 223 | const char *buf, size_t count) |
221 | { | 224 | { |
222 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 225 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
223 | int loading = simple_strtol(buf, NULL, 10); | 226 | int loading = simple_strtol(buf, NULL, 10); |
224 | int i; | 227 | int i; |
225 | 228 | ||
@@ -277,13 +280,12 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
277 | 280 | ||
278 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); | 281 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); |
279 | 282 | ||
280 | static ssize_t | 283 | static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj, |
281 | firmware_data_read(struct file *filp, struct kobject *kobj, | 284 | struct bin_attribute *bin_attr, |
282 | struct bin_attribute *bin_attr, char *buffer, loff_t offset, | 285 | char *buffer, loff_t offset, size_t count) |
283 | size_t count) | ||
284 | { | 286 | { |
285 | struct device *dev = to_dev(kobj); | 287 | struct device *dev = to_dev(kobj); |
286 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 288 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
287 | struct firmware *fw; | 289 | struct firmware *fw; |
288 | ssize_t ret_count; | 290 | ssize_t ret_count; |
289 | 291 | ||
@@ -322,8 +324,7 @@ out: | |||
322 | return ret_count; | 324 | return ret_count; |
323 | } | 325 | } |
324 | 326 | ||
325 | static int | 327 | static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) |
326 | fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | ||
327 | { | 328 | { |
328 | int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; | 329 | int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; |
329 | 330 | ||
@@ -373,13 +374,12 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
373 | * Data written to the 'data' attribute will be later handed to | 374 | * Data written to the 'data' attribute will be later handed to |
374 | * the driver as a firmware image. | 375 | * the driver as a firmware image. |
375 | **/ | 376 | **/ |
376 | static ssize_t | 377 | static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj, |
377 | firmware_data_write(struct file* filp, struct kobject *kobj, | 378 | struct bin_attribute *bin_attr, |
378 | struct bin_attribute *bin_attr, char *buffer, | 379 | char *buffer, loff_t offset, size_t count) |
379 | loff_t offset, size_t count) | ||
380 | { | 380 | { |
381 | struct device *dev = to_dev(kobj); | 381 | struct device *dev = to_dev(kobj); |
382 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 382 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
383 | struct firmware *fw; | 383 | struct firmware *fw; |
384 | ssize_t retval; | 384 | ssize_t retval; |
385 | 385 | ||
@@ -420,116 +420,103 @@ out: | |||
420 | return retval; | 420 | return retval; |
421 | } | 421 | } |
422 | 422 | ||
423 | static struct bin_attribute firmware_attr_data_tmpl = { | 423 | static struct bin_attribute firmware_attr_data = { |
424 | .attr = {.name = "data", .mode = 0644}, | 424 | .attr = { .name = "data", .mode = 0644 }, |
425 | .size = 0, | 425 | .size = 0, |
426 | .read = firmware_data_read, | 426 | .read = firmware_data_read, |
427 | .write = firmware_data_write, | 427 | .write = firmware_data_write, |
428 | }; | 428 | }; |
429 | 429 | ||
430 | static void | 430 | static void firmware_class_timeout(u_long data) |
431 | firmware_class_timeout(u_long data) | ||
432 | { | 431 | { |
433 | struct firmware_priv *fw_priv = (struct firmware_priv *) data; | 432 | struct firmware_priv *fw_priv = (struct firmware_priv *) data; |
433 | |||
434 | fw_load_abort(fw_priv); | 434 | fw_load_abort(fw_priv); |
435 | } | 435 | } |
436 | 436 | ||
437 | static int fw_register_device(struct device **dev_p, const char *fw_name, | 437 | static struct firmware_priv * |
438 | struct device *device) | 438 | fw_create_instance(struct firmware *firmware, const char *fw_name, |
439 | struct device *device, bool uevent, bool nowait) | ||
439 | { | 440 | { |
440 | int retval; | 441 | struct firmware_priv *fw_priv; |
441 | struct firmware_priv *fw_priv = | 442 | struct device *f_dev; |
442 | kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); | 443 | int error; |
443 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); | ||
444 | |||
445 | *dev_p = NULL; | ||
446 | 444 | ||
447 | if (!fw_priv || !f_dev) { | 445 | fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); |
446 | if (!fw_priv) { | ||
448 | dev_err(device, "%s: kmalloc failed\n", __func__); | 447 | dev_err(device, "%s: kmalloc failed\n", __func__); |
449 | retval = -ENOMEM; | 448 | error = -ENOMEM; |
450 | goto error_kfree; | 449 | goto err_out; |
451 | } | 450 | } |
452 | 451 | ||
452 | fw_priv->fw = firmware; | ||
453 | fw_priv->nowait = nowait; | ||
453 | strcpy(fw_priv->fw_id, fw_name); | 454 | strcpy(fw_priv->fw_id, fw_name); |
454 | init_completion(&fw_priv->completion); | 455 | init_completion(&fw_priv->completion); |
455 | fw_priv->attr_data = firmware_attr_data_tmpl; | 456 | setup_timer(&fw_priv->timeout, |
456 | fw_priv->timeout.function = firmware_class_timeout; | 457 | firmware_class_timeout, (u_long) fw_priv); |
457 | fw_priv->timeout.data = (u_long) fw_priv; | ||
458 | init_timer(&fw_priv->timeout); | ||
459 | 458 | ||
459 | f_dev = &fw_priv->dev; | ||
460 | |||
461 | device_initialize(f_dev); | ||
460 | dev_set_name(f_dev, "%s", dev_name(device)); | 462 | dev_set_name(f_dev, "%s", dev_name(device)); |
461 | f_dev->parent = device; | 463 | f_dev->parent = device; |
462 | f_dev->class = &firmware_class; | 464 | f_dev->class = &firmware_class; |
463 | dev_set_drvdata(f_dev, fw_priv); | ||
464 | dev_set_uevent_suppress(f_dev, 1); | ||
465 | retval = device_register(f_dev); | ||
466 | if (retval) { | ||
467 | dev_err(device, "%s: device_register failed\n", __func__); | ||
468 | put_device(f_dev); | ||
469 | return retval; | ||
470 | } | ||
471 | *dev_p = f_dev; | ||
472 | return 0; | ||
473 | |||
474 | error_kfree: | ||
475 | kfree(f_dev); | ||
476 | kfree(fw_priv); | ||
477 | return retval; | ||
478 | } | ||
479 | 465 | ||
480 | static int fw_setup_device(struct firmware *fw, struct device **dev_p, | 466 | dev_set_uevent_suppress(f_dev, true); |
481 | const char *fw_name, struct device *device, | ||
482 | int uevent, bool nowait) | ||
483 | { | ||
484 | struct device *f_dev; | ||
485 | struct firmware_priv *fw_priv; | ||
486 | int retval; | ||
487 | |||
488 | *dev_p = NULL; | ||
489 | retval = fw_register_device(&f_dev, fw_name, device); | ||
490 | if (retval) | ||
491 | goto out; | ||
492 | 467 | ||
493 | /* Need to pin this module until class device is destroyed */ | 468 | /* Need to pin this module until class device is destroyed */ |
494 | __module_get(THIS_MODULE); | 469 | __module_get(THIS_MODULE); |
495 | 470 | ||
496 | fw_priv = dev_get_drvdata(f_dev); | 471 | error = device_add(f_dev); |
497 | 472 | if (error) { | |
498 | fw_priv->nowait = nowait; | 473 | dev_err(device, "%s: device_register failed\n", __func__); |
474 | goto err_put_dev; | ||
475 | } | ||
499 | 476 | ||
500 | fw_priv->fw = fw; | 477 | error = device_create_bin_file(f_dev, &firmware_attr_data); |
501 | sysfs_bin_attr_init(&fw_priv->attr_data); | 478 | if (error) { |
502 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); | ||
503 | if (retval) { | ||
504 | dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); | 479 | dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); |
505 | goto error_unreg; | 480 | goto err_del_dev; |
506 | } | 481 | } |
507 | 482 | ||
508 | retval = device_create_file(f_dev, &dev_attr_loading); | 483 | error = device_create_file(f_dev, &dev_attr_loading); |
509 | if (retval) { | 484 | if (error) { |
510 | dev_err(device, "%s: device_create_file failed\n", __func__); | 485 | dev_err(device, "%s: device_create_file failed\n", __func__); |
511 | goto error_unreg; | 486 | goto err_del_bin_attr; |
512 | } | 487 | } |
513 | 488 | ||
514 | if (uevent) | 489 | if (uevent) |
515 | dev_set_uevent_suppress(f_dev, 0); | 490 | dev_set_uevent_suppress(f_dev, false); |
516 | *dev_p = f_dev; | 491 | |
517 | goto out; | 492 | return fw_priv; |
493 | |||
494 | err_del_bin_attr: | ||
495 | device_remove_bin_file(f_dev, &firmware_attr_data); | ||
496 | err_del_dev: | ||
497 | device_del(f_dev); | ||
498 | err_put_dev: | ||
499 | put_device(f_dev); | ||
500 | err_out: | ||
501 | return ERR_PTR(error); | ||
502 | } | ||
503 | |||
504 | static void fw_destroy_instance(struct firmware_priv *fw_priv) | ||
505 | { | ||
506 | struct device *f_dev = &fw_priv->dev; | ||
518 | 507 | ||
519 | error_unreg: | 508 | device_remove_file(f_dev, &dev_attr_loading); |
509 | device_remove_bin_file(f_dev, &firmware_attr_data); | ||
520 | device_unregister(f_dev); | 510 | device_unregister(f_dev); |
521 | out: | ||
522 | return retval; | ||
523 | } | 511 | } |
524 | 512 | ||
525 | static int | 513 | static int _request_firmware(const struct firmware **firmware_p, |
526 | _request_firmware(const struct firmware **firmware_p, const char *name, | 514 | const char *name, struct device *device, |
527 | struct device *device, int uevent, bool nowait) | 515 | bool uevent, bool nowait) |
528 | { | 516 | { |
529 | struct device *f_dev; | ||
530 | struct firmware_priv *fw_priv; | 517 | struct firmware_priv *fw_priv; |
531 | struct firmware *firmware; | 518 | struct firmware *firmware; |
532 | int retval; | 519 | int retval = 0; |
533 | 520 | ||
534 | if (!firmware_p) | 521 | if (!firmware_p) |
535 | return -EINVAL; | 522 | return -EINVAL; |
@@ -550,41 +537,40 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
550 | if (uevent) | 537 | if (uevent) |
551 | dev_dbg(device, "firmware: requesting %s\n", name); | 538 | dev_dbg(device, "firmware: requesting %s\n", name); |
552 | 539 | ||
553 | retval = fw_setup_device(firmware, &f_dev, name, device, | 540 | fw_priv = fw_create_instance(firmware, name, device, uevent, nowait); |
554 | uevent, nowait); | 541 | if (IS_ERR(fw_priv)) { |
555 | if (retval) | 542 | retval = PTR_ERR(fw_priv); |
556 | goto error_kfree_fw; | 543 | goto out; |
557 | 544 | } | |
558 | fw_priv = dev_get_drvdata(f_dev); | ||
559 | 545 | ||
560 | if (uevent) { | 546 | if (uevent) { |
561 | if (loading_timeout > 0) { | 547 | if (loading_timeout > 0) |
562 | fw_priv->timeout.expires = jiffies + loading_timeout * HZ; | 548 | mod_timer(&fw_priv->timeout, |
563 | add_timer(&fw_priv->timeout); | 549 | round_jiffies_up(jiffies + |
564 | } | 550 | loading_timeout * HZ)); |
551 | |||
552 | kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); | ||
553 | } | ||
554 | |||
555 | wait_for_completion(&fw_priv->completion); | ||
565 | 556 | ||
566 | kobject_uevent(&f_dev->kobj, KOBJ_ADD); | 557 | set_bit(FW_STATUS_DONE, &fw_priv->status); |
567 | wait_for_completion(&fw_priv->completion); | 558 | del_timer_sync(&fw_priv->timeout); |
568 | set_bit(FW_STATUS_DONE, &fw_priv->status); | ||
569 | del_timer_sync(&fw_priv->timeout); | ||
570 | } else | ||
571 | wait_for_completion(&fw_priv->completion); | ||
572 | 559 | ||
573 | mutex_lock(&fw_lock); | 560 | mutex_lock(&fw_lock); |
574 | if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) { | 561 | if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) |
575 | retval = -ENOENT; | 562 | retval = -ENOENT; |
576 | release_firmware(fw_priv->fw); | ||
577 | *firmware_p = NULL; | ||
578 | } | ||
579 | fw_priv->fw = NULL; | 563 | fw_priv->fw = NULL; |
580 | mutex_unlock(&fw_lock); | 564 | mutex_unlock(&fw_lock); |
581 | device_unregister(f_dev); | ||
582 | goto out; | ||
583 | 565 | ||
584 | error_kfree_fw: | 566 | fw_destroy_instance(fw_priv); |
585 | kfree(firmware); | 567 | |
586 | *firmware_p = NULL; | ||
587 | out: | 568 | out: |
569 | if (retval) { | ||
570 | release_firmware(firmware); | ||
571 | firmware_p = NULL; | ||
572 | } | ||
573 | |||
588 | return retval; | 574 | return retval; |
589 | } | 575 | } |
590 | 576 | ||
@@ -635,23 +621,24 @@ struct firmware_work { | |||
635 | int uevent; | 621 | int uevent; |
636 | }; | 622 | }; |
637 | 623 | ||
638 | static int | 624 | static int request_firmware_work_func(void *arg) |
639 | request_firmware_work_func(void *arg) | ||
640 | { | 625 | { |
641 | struct firmware_work *fw_work = arg; | 626 | struct firmware_work *fw_work = arg; |
642 | const struct firmware *fw; | 627 | const struct firmware *fw; |
643 | int ret; | 628 | int ret; |
629 | |||
644 | if (!arg) { | 630 | if (!arg) { |
645 | WARN_ON(1); | 631 | WARN_ON(1); |
646 | return 0; | 632 | return 0; |
647 | } | 633 | } |
648 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, | ||
649 | fw_work->uevent, true); | ||
650 | 634 | ||
635 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, | ||
636 | fw_work->uevent, true); | ||
651 | fw_work->cont(fw, fw_work->context); | 637 | fw_work->cont(fw, fw_work->context); |
652 | 638 | ||
653 | module_put(fw_work->module); | 639 | module_put(fw_work->module); |
654 | kfree(fw_work); | 640 | kfree(fw_work); |
641 | |||
655 | return ret; | 642 | return ret; |
656 | } | 643 | } |
657 | 644 | ||
@@ -679,34 +666,33 @@ request_firmware_nowait( | |||
679 | void (*cont)(const struct firmware *fw, void *context)) | 666 | void (*cont)(const struct firmware *fw, void *context)) |
680 | { | 667 | { |
681 | struct task_struct *task; | 668 | struct task_struct *task; |
682 | struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work), | 669 | struct firmware_work *fw_work; |
683 | gfp); | ||
684 | 670 | ||
671 | fw_work = kzalloc(sizeof (struct firmware_work), gfp); | ||
685 | if (!fw_work) | 672 | if (!fw_work) |
686 | return -ENOMEM; | 673 | return -ENOMEM; |
674 | |||
675 | fw_work->module = module; | ||
676 | fw_work->name = name; | ||
677 | fw_work->device = device; | ||
678 | fw_work->context = context; | ||
679 | fw_work->cont = cont; | ||
680 | fw_work->uevent = uevent; | ||
681 | |||
687 | if (!try_module_get(module)) { | 682 | if (!try_module_get(module)) { |
688 | kfree(fw_work); | 683 | kfree(fw_work); |
689 | return -EFAULT; | 684 | return -EFAULT; |
690 | } | 685 | } |
691 | 686 | ||
692 | *fw_work = (struct firmware_work) { | ||
693 | .module = module, | ||
694 | .name = name, | ||
695 | .device = device, | ||
696 | .context = context, | ||
697 | .cont = cont, | ||
698 | .uevent = uevent, | ||
699 | }; | ||
700 | |||
701 | task = kthread_run(request_firmware_work_func, fw_work, | 687 | task = kthread_run(request_firmware_work_func, fw_work, |
702 | "firmware/%s", name); | 688 | "firmware/%s", name); |
703 | |||
704 | if (IS_ERR(task)) { | 689 | if (IS_ERR(task)) { |
705 | fw_work->cont(NULL, fw_work->context); | 690 | fw_work->cont(NULL, fw_work->context); |
706 | module_put(fw_work->module); | 691 | module_put(fw_work->module); |
707 | kfree(fw_work); | 692 | kfree(fw_work); |
708 | return PTR_ERR(task); | 693 | return PTR_ERR(task); |
709 | } | 694 | } |
695 | |||
710 | return 0; | 696 | return 0; |
711 | } | 697 | } |
712 | 698 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index f699fabf403b..c6c933f58102 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -192,13 +192,13 @@ int platform_device_add_resources(struct platform_device *pdev, | |||
192 | { | 192 | { |
193 | struct resource *r; | 193 | struct resource *r; |
194 | 194 | ||
195 | r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL); | 195 | r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); |
196 | if (r) { | 196 | if (r) { |
197 | memcpy(r, res, sizeof(struct resource) * num); | ||
198 | pdev->resource = r; | 197 | pdev->resource = r; |
199 | pdev->num_resources = num; | 198 | pdev->num_resources = num; |
199 | return 0; | ||
200 | } | 200 | } |
201 | return r ? 0 : -ENOMEM; | 201 | return -ENOMEM; |
202 | } | 202 | } |
203 | EXPORT_SYMBOL_GPL(platform_device_add_resources); | 203 | EXPORT_SYMBOL_GPL(platform_device_add_resources); |
204 | 204 | ||
@@ -345,108 +345,56 @@ void platform_device_unregister(struct platform_device *pdev) | |||
345 | EXPORT_SYMBOL_GPL(platform_device_unregister); | 345 | EXPORT_SYMBOL_GPL(platform_device_unregister); |
346 | 346 | ||
347 | /** | 347 | /** |
348 | * platform_device_register_simple - add a platform-level device and its resources | 348 | * platform_device_register_resndata - add a platform-level device with |
349 | * @name: base name of the device we're adding | 349 | * resources and platform-specific data |
350 | * @id: instance id | ||
351 | * @res: set of resources that needs to be allocated for the device | ||
352 | * @num: number of resources | ||
353 | * | ||
354 | * This function creates a simple platform device that requires minimal | ||
355 | * resource and memory management. Canned release function freeing memory | ||
356 | * allocated for the device allows drivers using such devices to be | ||
357 | * unloaded without waiting for the last reference to the device to be | ||
358 | * dropped. | ||
359 | * | ||
360 | * This interface is primarily intended for use with legacy drivers which | ||
361 | * probe hardware directly. Because such drivers create sysfs device nodes | ||
362 | * themselves, rather than letting system infrastructure handle such device | ||
363 | * enumeration tasks, they don't fully conform to the Linux driver model. | ||
364 | * In particular, when such drivers are built as modules, they can't be | ||
365 | * "hotplugged". | ||
366 | * | 350 | * |
367 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
368 | */ | ||
369 | struct platform_device *platform_device_register_simple(const char *name, | ||
370 | int id, | ||
371 | const struct resource *res, | ||
372 | unsigned int num) | ||
373 | { | ||
374 | struct platform_device *pdev; | ||
375 | int retval; | ||
376 | |||
377 | pdev = platform_device_alloc(name, id); | ||
378 | if (!pdev) { | ||
379 | retval = -ENOMEM; | ||
380 | goto error; | ||
381 | } | ||
382 | |||
383 | if (num) { | ||
384 | retval = platform_device_add_resources(pdev, res, num); | ||
385 | if (retval) | ||
386 | goto error; | ||
387 | } | ||
388 | |||
389 | retval = platform_device_add(pdev); | ||
390 | if (retval) | ||
391 | goto error; | ||
392 | |||
393 | return pdev; | ||
394 | |||
395 | error: | ||
396 | platform_device_put(pdev); | ||
397 | return ERR_PTR(retval); | ||
398 | } | ||
399 | EXPORT_SYMBOL_GPL(platform_device_register_simple); | ||
400 | |||
401 | /** | ||
402 | * platform_device_register_data - add a platform-level device with platform-specific data | ||
403 | * @parent: parent device for the device we're adding | 351 | * @parent: parent device for the device we're adding |
404 | * @name: base name of the device we're adding | 352 | * @name: base name of the device we're adding |
405 | * @id: instance id | 353 | * @id: instance id |
354 | * @res: set of resources that needs to be allocated for the device | ||
355 | * @num: number of resources | ||
406 | * @data: platform specific data for this platform device | 356 | * @data: platform specific data for this platform device |
407 | * @size: size of platform specific data | 357 | * @size: size of platform specific data |
408 | * | 358 | * |
409 | * This function creates a simple platform device that requires minimal | ||
410 | * resource and memory management. Canned release function freeing memory | ||
411 | * allocated for the device allows drivers using such devices to be | ||
412 | * unloaded without waiting for the last reference to the device to be | ||
413 | * dropped. | ||
414 | * | ||
415 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | 359 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. |
416 | */ | 360 | */ |
417 | struct platform_device *platform_device_register_data( | 361 | struct platform_device *__init_or_module platform_device_register_resndata( |
418 | struct device *parent, | 362 | struct device *parent, |
419 | const char *name, int id, | 363 | const char *name, int id, |
364 | const struct resource *res, unsigned int num, | ||
420 | const void *data, size_t size) | 365 | const void *data, size_t size) |
421 | { | 366 | { |
367 | int ret = -ENOMEM; | ||
422 | struct platform_device *pdev; | 368 | struct platform_device *pdev; |
423 | int retval; | ||
424 | 369 | ||
425 | pdev = platform_device_alloc(name, id); | 370 | pdev = platform_device_alloc(name, id); |
426 | if (!pdev) { | 371 | if (!pdev) |
427 | retval = -ENOMEM; | 372 | goto err; |
428 | goto error; | ||
429 | } | ||
430 | 373 | ||
431 | pdev->dev.parent = parent; | 374 | pdev->dev.parent = parent; |
432 | 375 | ||
433 | if (size) { | 376 | if (res) { |
434 | retval = platform_device_add_data(pdev, data, size); | 377 | ret = platform_device_add_resources(pdev, res, num); |
435 | if (retval) | 378 | if (ret) |
436 | goto error; | 379 | goto err; |
437 | } | 380 | } |
438 | 381 | ||
439 | retval = platform_device_add(pdev); | 382 | if (data) { |
440 | if (retval) | 383 | ret = platform_device_add_data(pdev, data, size); |
441 | goto error; | 384 | if (ret) |
385 | goto err; | ||
386 | } | ||
442 | 387 | ||
443 | return pdev; | 388 | ret = platform_device_add(pdev); |
389 | if (ret) { | ||
390 | err: | ||
391 | platform_device_put(pdev); | ||
392 | return ERR_PTR(ret); | ||
393 | } | ||
444 | 394 | ||
445 | error: | 395 | return pdev; |
446 | platform_device_put(pdev); | ||
447 | return ERR_PTR(retval); | ||
448 | } | 396 | } |
449 | EXPORT_SYMBOL_GPL(platform_device_register_data); | 397 | EXPORT_SYMBOL_GPL(platform_device_register_resndata); |
450 | 398 | ||
451 | static int platform_drv_probe(struct device *_dev) | 399 | static int platform_drv_probe(struct device *_dev) |
452 | { | 400 | { |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index aa9bc9e980e1..69ad529d92fb 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -634,9 +634,6 @@ static void __exit dcdbas_exit(void) | |||
634 | * before platform_device_unregister | 634 | * before platform_device_unregister |
635 | */ | 635 | */ |
636 | unregister_reboot_notifier(&dcdbas_reboot_nb); | 636 | unregister_reboot_notifier(&dcdbas_reboot_nb); |
637 | smi_data_buf_free(); | ||
638 | platform_device_unregister(dcdbas_pdev); | ||
639 | platform_driver_unregister(&dcdbas_driver); | ||
640 | 637 | ||
641 | /* | 638 | /* |
642 | * We have to free the buffer here instead of dcdbas_remove | 639 | * We have to free the buffer here instead of dcdbas_remove |
@@ -645,6 +642,8 @@ static void __exit dcdbas_exit(void) | |||
645 | * released. | 642 | * released. |
646 | */ | 643 | */ |
647 | smi_data_buf_free(); | 644 | smi_data_buf_free(); |
645 | platform_device_unregister(dcdbas_pdev); | ||
646 | platform_driver_unregister(&dcdbas_driver); | ||
648 | } | 647 | } |
649 | 648 | ||
650 | module_init(dcdbas_init); | 649 | module_init(dcdbas_init); |
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index a777a35381d2..94a58a082b99 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c | |||
@@ -229,10 +229,12 @@ static int __init dmi_id_init(void) | |||
229 | 229 | ||
230 | ret = device_register(dmi_dev); | 230 | ret = device_register(dmi_dev); |
231 | if (ret) | 231 | if (ret) |
232 | goto fail_class_unregister; | 232 | goto fail_free_dmi_dev; |
233 | 233 | ||
234 | return 0; | 234 | return 0; |
235 | 235 | ||
236 | fail_free_dmi_dev: | ||
237 | kfree(dmi_dev); | ||
236 | fail_class_unregister: | 238 | fail_class_unregister: |
237 | 239 | ||
238 | class_unregister(&dmi_class); | 240 | class_unregister(&dmi_class); |
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c index 5dcdf9d69b3a..19dc4b61a105 100644 --- a/drivers/leds/leds-bd2802.c +++ b/drivers/leds/leds-bd2802.c | |||
@@ -351,7 +351,7 @@ static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ | |||
351 | return count; \ | 351 | return count; \ |
352 | } \ | 352 | } \ |
353 | static struct device_attribute bd2802_reg##reg_addr##_attr = { \ | 353 | static struct device_attribute bd2802_reg##reg_addr##_attr = { \ |
354 | .attr = {.name = reg_name, .mode = 0644, .owner = THIS_MODULE}, \ | 354 | .attr = {.name = reg_name, .mode = 0644}, \ |
355 | .store = bd2802_store_reg##reg_addr, \ | 355 | .store = bd2802_store_reg##reg_addr, \ |
356 | }; | 356 | }; |
357 | 357 | ||
@@ -482,7 +482,6 @@ static struct device_attribute bd2802_adv_conf_attr = { | |||
482 | .attr = { | 482 | .attr = { |
483 | .name = "advanced_configuration", | 483 | .name = "advanced_configuration", |
484 | .mode = 0644, | 484 | .mode = 0644, |
485 | .owner = THIS_MODULE | ||
486 | }, | 485 | }, |
487 | .show = bd2802_show_adv_conf, | 486 | .show = bd2802_show_adv_conf, |
488 | .store = bd2802_store_adv_conf, | 487 | .store = bd2802_store_adv_conf, |
@@ -519,7 +518,6 @@ static struct device_attribute bd2802_##attr_name##_attr = { \ | |||
519 | .attr = { \ | 518 | .attr = { \ |
520 | .name = name_str, \ | 519 | .name = name_str, \ |
521 | .mode = 0644, \ | 520 | .mode = 0644, \ |
522 | .owner = THIS_MODULE \ | ||
523 | }, \ | 521 | }, \ |
524 | .show = bd2802_show_##attr_name, \ | 522 | .show = bd2802_show_##attr_name, \ |
525 | .store = bd2802_store_##attr_name, \ | 523 | .store = bd2802_store_##attr_name, \ |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2248087b9be2..422a709d271d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1025,7 +1025,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, | |||
1025 | if (regulator->dev_attr.attr.name == NULL) | 1025 | if (regulator->dev_attr.attr.name == NULL) |
1026 | goto attr_name_err; | 1026 | goto attr_name_err; |
1027 | 1027 | ||
1028 | regulator->dev_attr.attr.owner = THIS_MODULE; | ||
1029 | regulator->dev_attr.attr.mode = 0444; | 1028 | regulator->dev_attr.attr.mode = 0444; |
1030 | regulator->dev_attr.show = device_requested_uA_show; | 1029 | regulator->dev_attr.show = device_requested_uA_show; |
1031 | err = device_create_file(dev, ®ulator->dev_attr); | 1030 | err = device_create_file(dev, ®ulator->dev_attr); |
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index 07fdfe57e38e..a4e04c50c436 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c | |||
@@ -192,7 +192,6 @@ static struct bin_attribute arcmsr_sysfs_message_read_attr = { | |||
192 | .attr = { | 192 | .attr = { |
193 | .name = "mu_read", | 193 | .name = "mu_read", |
194 | .mode = S_IRUSR , | 194 | .mode = S_IRUSR , |
195 | .owner = THIS_MODULE, | ||
196 | }, | 195 | }, |
197 | .size = 1032, | 196 | .size = 1032, |
198 | .read = arcmsr_sysfs_iop_message_read, | 197 | .read = arcmsr_sysfs_iop_message_read, |
@@ -202,7 +201,6 @@ static struct bin_attribute arcmsr_sysfs_message_write_attr = { | |||
202 | .attr = { | 201 | .attr = { |
203 | .name = "mu_write", | 202 | .name = "mu_write", |
204 | .mode = S_IWUSR, | 203 | .mode = S_IWUSR, |
205 | .owner = THIS_MODULE, | ||
206 | }, | 204 | }, |
207 | .size = 1032, | 205 | .size = 1032, |
208 | .write = arcmsr_sysfs_iop_message_write, | 206 | .write = arcmsr_sysfs_iop_message_write, |
@@ -212,7 +210,6 @@ static struct bin_attribute arcmsr_sysfs_message_clear_attr = { | |||
212 | .attr = { | 210 | .attr = { |
213 | .name = "mu_clear", | 211 | .name = "mu_clear", |
214 | .mode = S_IWUSR, | 212 | .mode = S_IWUSR, |
215 | .owner = THIS_MODULE, | ||
216 | }, | 213 | }, |
217 | .size = 1, | 214 | .size = 1, |
218 | .write = arcmsr_sysfs_iop_message_clear, | 215 | .write = arcmsr_sysfs_iop_message_clear, |
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 868874c28f99..162704cf6a96 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -2778,7 +2778,6 @@ static struct bin_attribute sysfs_drvr_stat_data_attr = { | |||
2778 | .attr = { | 2778 | .attr = { |
2779 | .name = "lpfc_drvr_stat_data", | 2779 | .name = "lpfc_drvr_stat_data", |
2780 | .mode = S_IRUSR, | 2780 | .mode = S_IRUSR, |
2781 | .owner = THIS_MODULE, | ||
2782 | }, | 2781 | }, |
2783 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, | 2782 | .size = LPFC_MAX_TARGET * MAX_STAT_DATA_SIZE_PER_TARGET, |
2784 | .read = sysfs_drvr_stat_data_read, | 2783 | .read = sysfs_drvr_stat_data_read, |
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c index 371f87f8bc22..a8ea2f19a0cc 100644 --- a/drivers/uio/uio_cif.c +++ b/drivers/uio/uio_cif.c | |||
@@ -79,7 +79,7 @@ static int __devinit hilscher_pci_probe(struct pci_dev *dev, | |||
79 | } | 79 | } |
80 | info->version = "0.0.1"; | 80 | info->version = "0.0.1"; |
81 | info->irq = dev->irq; | 81 | info->irq = dev->irq; |
82 | info->irq_flags = IRQF_DISABLED | IRQF_SHARED; | 82 | info->irq_flags = IRQF_SHARED; |
83 | info->handler = hilscher_handler; | 83 | info->handler = hilscher_handler; |
84 | 84 | ||
85 | if (uio_register_device(&dev->dev, info)) | 85 | if (uio_register_device(&dev->dev, info)) |
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c index 61e569df2bba..7174d518b8a6 100644 --- a/drivers/uio/uio_pdrv_genirq.c +++ b/drivers/uio/uio_pdrv_genirq.c | |||
@@ -155,7 +155,6 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev) | |||
155 | * Interrupt sharing is not supported. | 155 | * Interrupt sharing is not supported. |
156 | */ | 156 | */ |
157 | 157 | ||
158 | uioinfo->irq_flags |= IRQF_DISABLED; | ||
159 | uioinfo->handler = uio_pdrv_genirq_handler; | 158 | uioinfo->handler = uio_pdrv_genirq_handler; |
160 | uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol; | 159 | uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol; |
161 | uioinfo->open = uio_pdrv_genirq_open; | 160 | uioinfo->open = uio_pdrv_genirq_open; |
diff --git a/drivers/uio/uio_sercos3.c b/drivers/uio/uio_sercos3.c index 3d461cd73e6b..a187fa14c5c0 100644 --- a/drivers/uio/uio_sercos3.c +++ b/drivers/uio/uio_sercos3.c | |||
@@ -154,7 +154,7 @@ static int __devinit sercos3_pci_probe(struct pci_dev *dev, | |||
154 | info->name = "Sercos_III_PCI"; | 154 | info->name = "Sercos_III_PCI"; |
155 | info->version = "0.0.1"; | 155 | info->version = "0.0.1"; |
156 | info->irq = dev->irq; | 156 | info->irq = dev->irq; |
157 | info->irq_flags = IRQF_DISABLED | IRQF_SHARED; | 157 | info->irq_flags = IRQF_SHARED; |
158 | info->handler = sercos3_handler; | 158 | info->handler = sercos3_handler; |
159 | info->irqcontrol = sercos3_irqcontrol; | 159 | info->irqcontrol = sercos3_irqcontrol; |
160 | 160 | ||
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 1beaa739d0a6..1b27b5688f62 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -593,7 +593,8 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); | |||
593 | * @mode: file permissions. | 593 | * @mode: file permissions. |
594 | * | 594 | * |
595 | */ | 595 | */ |
596 | int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | 596 | int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, |
597 | mode_t mode) | ||
597 | { | 598 | { |
598 | struct sysfs_dirent *sd; | 599 | struct sysfs_dirent *sd; |
599 | struct iattr newattrs; | 600 | struct iattr newattrs; |
diff --git a/include/linux/device.h b/include/linux/device.h index 6a8276f683b6..516fecacf27b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -84,9 +84,8 @@ struct device *bus_find_device_by_name(struct bus_type *bus, | |||
84 | struct device *start, | 84 | struct device *start, |
85 | const char *name); | 85 | const char *name); |
86 | 86 | ||
87 | int __must_check bus_for_each_drv(struct bus_type *bus, | 87 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
88 | struct device_driver *start, void *data, | 88 | void *data, int (*fn)(struct device_driver *, void *)); |
89 | int (*fn)(struct device_driver *, void *)); | ||
90 | 89 | ||
91 | void bus_sort_breadthfirst(struct bus_type *bus, | 90 | void bus_sort_breadthfirst(struct bus_type *bus, |
92 | int (*compare)(const struct device *a, | 91 | int (*compare)(const struct device *a, |
@@ -110,10 +109,12 @@ extern int bus_unregister_notifier(struct bus_type *bus, | |||
110 | */ | 109 | */ |
111 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ | 110 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ |
112 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ | 111 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ |
113 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000003 /* driver bound to device */ | 112 | #define BUS_NOTIFY_BIND_DRIVER 0x00000003 /* driver about to be |
114 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be | 113 | bound */ |
114 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000004 /* driver bound to device */ | ||
115 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000005 /* driver about to be | ||
115 | unbound */ | 116 | unbound */ |
116 | #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000005 /* driver is unbound | 117 | #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006 /* driver is unbound |
117 | from the device */ | 118 | from the device */ |
118 | 119 | ||
119 | extern struct kset *bus_get_kset(struct bus_type *bus); | 120 | extern struct kset *bus_get_kset(struct bus_type *bus); |
@@ -551,7 +552,7 @@ extern int device_for_each_child(struct device *dev, void *data, | |||
551 | int (*fn)(struct device *dev, void *data)); | 552 | int (*fn)(struct device *dev, void *data)); |
552 | extern struct device *device_find_child(struct device *dev, void *data, | 553 | extern struct device *device_find_child(struct device *dev, void *data, |
553 | int (*match)(struct device *dev, void *data)); | 554 | int (*match)(struct device *dev, void *data)); |
554 | extern int device_rename(struct device *dev, char *new_name); | 555 | extern int device_rename(struct device *dev, const char *new_name); |
555 | extern int device_move(struct device *dev, struct device *new_parent, | 556 | extern int device_move(struct device *dev, struct device *new_parent, |
556 | enum dpm_order dpm_order); | 557 | enum dpm_order dpm_order); |
557 | extern const char *device_get_devnode(struct device *dev, | 558 | extern const char *device_get_devnode(struct device *dev, |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 5417944d3687..d7ecad0093bb 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -43,10 +43,64 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, u | |||
43 | extern int platform_get_irq_byname(struct platform_device *, const char *); | 43 | extern int platform_get_irq_byname(struct platform_device *, const char *); |
44 | extern int platform_add_devices(struct platform_device **, int); | 44 | extern int platform_add_devices(struct platform_device **, int); |
45 | 45 | ||
46 | extern struct platform_device *platform_device_register_simple(const char *, int id, | 46 | extern struct platform_device *platform_device_register_resndata( |
47 | const struct resource *, unsigned int); | 47 | struct device *parent, const char *name, int id, |
48 | extern struct platform_device *platform_device_register_data(struct device *, | 48 | const struct resource *res, unsigned int num, |
49 | const char *, int, const void *, size_t); | 49 | const void *data, size_t size); |
50 | |||
51 | /** | ||
52 | * platform_device_register_simple - add a platform-level device and its resources | ||
53 | * @name: base name of the device we're adding | ||
54 | * @id: instance id | ||
55 | * @res: set of resources that needs to be allocated for the device | ||
56 | * @num: number of resources | ||
57 | * | ||
58 | * This function creates a simple platform device that requires minimal | ||
59 | * resource and memory management. Canned release function freeing memory | ||
60 | * allocated for the device allows drivers using such devices to be | ||
61 | * unloaded without waiting for the last reference to the device to be | ||
62 | * dropped. | ||
63 | * | ||
64 | * This interface is primarily intended for use with legacy drivers which | ||
65 | * probe hardware directly. Because such drivers create sysfs device nodes | ||
66 | * themselves, rather than letting system infrastructure handle such device | ||
67 | * enumeration tasks, they don't fully conform to the Linux driver model. | ||
68 | * In particular, when such drivers are built as modules, they can't be | ||
69 | * "hotplugged". | ||
70 | * | ||
71 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
72 | */ | ||
73 | static inline struct platform_device *platform_device_register_simple( | ||
74 | const char *name, int id, | ||
75 | const struct resource *res, unsigned int num) | ||
76 | { | ||
77 | return platform_device_register_resndata(NULL, name, id, | ||
78 | res, num, NULL, 0); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * platform_device_register_data - add a platform-level device with platform-specific data | ||
83 | * @parent: parent device for the device we're adding | ||
84 | * @name: base name of the device we're adding | ||
85 | * @id: instance id | ||
86 | * @data: platform specific data for this platform device | ||
87 | * @size: size of platform specific data | ||
88 | * | ||
89 | * This function creates a simple platform device that requires minimal | ||
90 | * resource and memory management. Canned release function freeing memory | ||
91 | * allocated for the device allows drivers using such devices to be | ||
92 | * unloaded without waiting for the last reference to the device to be | ||
93 | * dropped. | ||
94 | * | ||
95 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
96 | */ | ||
97 | static inline struct platform_device *platform_device_register_data( | ||
98 | struct device *parent, const char *name, int id, | ||
99 | const void *data, size_t size) | ||
100 | { | ||
101 | return platform_device_register_resndata(parent, name, id, | ||
102 | NULL, 0, data, size); | ||
103 | } | ||
50 | 104 | ||
51 | extern struct platform_device *platform_device_alloc(const char *name, int id); | 105 | extern struct platform_device *platform_device_alloc(const char *name, int id); |
52 | extern int platform_device_add_resources(struct platform_device *pdev, | 106 | extern int platform_device_add_resources(struct platform_device *pdev, |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f2694eb4dd3d..3c92121ba9af 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
@@ -22,14 +22,8 @@ struct kobject; | |||
22 | struct module; | 22 | struct module; |
23 | enum kobj_ns_type; | 23 | enum kobj_ns_type; |
24 | 24 | ||
25 | /* FIXME | ||
26 | * The *owner field is no longer used. | ||
27 | * x86 tree has been cleaned up. The owner | ||
28 | * attribute is still left for other arches. | ||
29 | */ | ||
30 | struct attribute { | 25 | struct attribute { |
31 | const char *name; | 26 | const char *name; |
32 | struct module *owner; | ||
33 | mode_t mode; | 27 | mode_t mode; |
34 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 28 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
35 | struct lock_class_key *key; | 29 | struct lock_class_key *key; |
@@ -136,8 +130,8 @@ int __must_check sysfs_create_file(struct kobject *kobj, | |||
136 | const struct attribute *attr); | 130 | const struct attribute *attr); |
137 | int __must_check sysfs_create_files(struct kobject *kobj, | 131 | int __must_check sysfs_create_files(struct kobject *kobj, |
138 | const struct attribute **attr); | 132 | const struct attribute **attr); |
139 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, | 133 | int __must_check sysfs_chmod_file(struct kobject *kobj, |
140 | mode_t mode); | 134 | const struct attribute *attr, mode_t mode); |
141 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); | 135 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); |
142 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); | 136 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); |
143 | 137 | ||
@@ -225,7 +219,7 @@ static inline int sysfs_create_files(struct kobject *kobj, | |||
225 | } | 219 | } |
226 | 220 | ||
227 | static inline int sysfs_chmod_file(struct kobject *kobj, | 221 | static inline int sysfs_chmod_file(struct kobject *kobj, |
228 | struct attribute *attr, mode_t mode) | 222 | const struct attribute *attr, mode_t mode) |
229 | { | 223 | { |
230 | return 0; | 224 | return 0; |
231 | } | 225 | } |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a8ce09954404..d83cab06da87 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1623,6 +1623,8 @@ static struct file_system_type cgroup_fs_type = { | |||
1623 | .kill_sb = cgroup_kill_sb, | 1623 | .kill_sb = cgroup_kill_sb, |
1624 | }; | 1624 | }; |
1625 | 1625 | ||
1626 | static struct kobject *cgroup_kobj; | ||
1627 | |||
1626 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) | 1628 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) |
1627 | { | 1629 | { |
1628 | return dentry->d_fsdata; | 1630 | return dentry->d_fsdata; |
@@ -3894,9 +3896,18 @@ int __init cgroup_init(void) | |||
3894 | hhead = css_set_hash(init_css_set.subsys); | 3896 | hhead = css_set_hash(init_css_set.subsys); |
3895 | hlist_add_head(&init_css_set.hlist, hhead); | 3897 | hlist_add_head(&init_css_set.hlist, hhead); |
3896 | BUG_ON(!init_root_id(&rootnode)); | 3898 | BUG_ON(!init_root_id(&rootnode)); |
3899 | |||
3900 | cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj); | ||
3901 | if (!cgroup_kobj) { | ||
3902 | err = -ENOMEM; | ||
3903 | goto out; | ||
3904 | } | ||
3905 | |||
3897 | err = register_filesystem(&cgroup_fs_type); | 3906 | err = register_filesystem(&cgroup_fs_type); |
3898 | if (err < 0) | 3907 | if (err < 0) { |
3908 | kobject_put(cgroup_kobj); | ||
3899 | goto out; | 3909 | goto out; |
3910 | } | ||
3900 | 3911 | ||
3901 | proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations); | 3912 | proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations); |
3902 | 3913 | ||
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6f79c7f81c96..9acfce0cdfdb 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -566,7 +566,7 @@ static struct ctl_table kern_table[] = { | |||
566 | .extra2 = &one, | 566 | .extra2 = &one, |
567 | }, | 567 | }, |
568 | #endif | 568 | #endif |
569 | #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) | 569 | #ifdef CONFIG_HOTPLUG |
570 | { | 570 | { |
571 | .procname = "hotplug", | 571 | .procname = "hotplug", |
572 | .data = &uevent_helper, | 572 | .data = &uevent_helper, |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ff87ddc4cbd5..79e0dff1cdcb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -76,7 +76,6 @@ config UNUSED_SYMBOLS | |||
76 | 76 | ||
77 | config DEBUG_FS | 77 | config DEBUG_FS |
78 | bool "Debug Filesystem" | 78 | bool "Debug Filesystem" |
79 | depends on SYSFS | ||
80 | help | 79 | help |
81 | debugfs is a virtual file system that kernel developers use to put | 80 | debugfs is a virtual file system that kernel developers use to put |
82 | debugging files into. Enable this option to be able to read and | 81 | debugging files into. Enable this option to be able to read and |