diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 57 | ||||
-rw-r--r-- | drivers/base/dd.c | 6 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 27 | ||||
-rw-r--r-- | drivers/base/node.c | 4 | ||||
-rw-r--r-- | drivers/base/platform.c | 7 | ||||
-rw-r--r-- | drivers/base/sys.c | 8 |
6 files changed, 89 insertions, 20 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 1977d4beb89e..7ecb1938e590 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
23 | #include <linux/semaphore.h> | 23 | #include <linux/semaphore.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/async.h> | ||
25 | 26 | ||
26 | #include "base.h" | 27 | #include "base.h" |
27 | #include "power/power.h" | 28 | #include "power/power.h" |
@@ -161,10 +162,18 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
161 | struct device *dev = to_dev(kobj); | 162 | struct device *dev = to_dev(kobj); |
162 | int retval = 0; | 163 | int retval = 0; |
163 | 164 | ||
164 | /* add the major/minor if present */ | 165 | /* add device node properties if present */ |
165 | if (MAJOR(dev->devt)) { | 166 | if (MAJOR(dev->devt)) { |
167 | const char *tmp; | ||
168 | const char *name; | ||
169 | |||
166 | add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt)); | 170 | add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt)); |
167 | add_uevent_var(env, "MINOR=%u", MINOR(dev->devt)); | 171 | add_uevent_var(env, "MINOR=%u", MINOR(dev->devt)); |
172 | name = device_get_nodename(dev, &tmp); | ||
173 | if (name) { | ||
174 | add_uevent_var(env, "DEVNAME=%s", name); | ||
175 | kfree(tmp); | ||
176 | } | ||
168 | } | 177 | } |
169 | 178 | ||
170 | if (dev->type && dev->type->name) | 179 | if (dev->type && dev->type->name) |
@@ -874,7 +883,7 @@ int device_add(struct device *dev) | |||
874 | * the name, and force the use of dev_name() | 883 | * the name, and force the use of dev_name() |
875 | */ | 884 | */ |
876 | if (dev->init_name) { | 885 | if (dev->init_name) { |
877 | dev_set_name(dev, dev->init_name); | 886 | dev_set_name(dev, "%s", dev->init_name); |
878 | dev->init_name = NULL; | 887 | dev->init_name = NULL; |
879 | } | 888 | } |
880 | 889 | ||
@@ -1128,6 +1137,47 @@ static struct device *next_device(struct klist_iter *i) | |||
1128 | } | 1137 | } |
1129 | 1138 | ||
1130 | /** | 1139 | /** |
1140 | * device_get_nodename - path of device node file | ||
1141 | * @dev: device | ||
1142 | * @tmp: possibly allocated string | ||
1143 | * | ||
1144 | * Return the relative path of a possible device node. | ||
1145 | * Non-default names may need to allocate a memory to compose | ||
1146 | * a name. This memory is returned in tmp and needs to be | ||
1147 | * freed by the caller. | ||
1148 | */ | ||
1149 | const char *device_get_nodename(struct device *dev, const char **tmp) | ||
1150 | { | ||
1151 | char *s; | ||
1152 | |||
1153 | *tmp = NULL; | ||
1154 | |||
1155 | /* the device type may provide a specific name */ | ||
1156 | if (dev->type && dev->type->nodename) | ||
1157 | *tmp = dev->type->nodename(dev); | ||
1158 | if (*tmp) | ||
1159 | return *tmp; | ||
1160 | |||
1161 | /* the class may provide a specific name */ | ||
1162 | if (dev->class && dev->class->nodename) | ||
1163 | *tmp = dev->class->nodename(dev); | ||
1164 | if (*tmp) | ||
1165 | return *tmp; | ||
1166 | |||
1167 | /* return name without allocation, tmp == NULL */ | ||
1168 | if (strchr(dev_name(dev), '!') == NULL) | ||
1169 | return dev_name(dev); | ||
1170 | |||
1171 | /* replace '!' in the name with '/' */ | ||
1172 | *tmp = kstrdup(dev_name(dev), GFP_KERNEL); | ||
1173 | if (!*tmp) | ||
1174 | return NULL; | ||
1175 | while ((s = strchr(*tmp, '!'))) | ||
1176 | s[0] = '/'; | ||
1177 | return *tmp; | ||
1178 | } | ||
1179 | |||
1180 | /** | ||
1131 | * device_for_each_child - device child iterator. | 1181 | * device_for_each_child - device child iterator. |
1132 | * @parent: parent struct device. | 1182 | * @parent: parent struct device. |
1133 | * @data: data for the callback. | 1183 | * @data: data for the callback. |
@@ -1271,7 +1321,7 @@ struct device *__root_device_register(const char *name, struct module *owner) | |||
1271 | if (!root) | 1321 | if (!root) |
1272 | return ERR_PTR(err); | 1322 | return ERR_PTR(err); |
1273 | 1323 | ||
1274 | err = dev_set_name(&root->dev, name); | 1324 | err = dev_set_name(&root->dev, "%s", name); |
1275 | if (err) { | 1325 | if (err) { |
1276 | kfree(root); | 1326 | kfree(root); |
1277 | return ERR_PTR(err); | 1327 | return ERR_PTR(err); |
@@ -1665,4 +1715,5 @@ void device_shutdown(void) | |||
1665 | kobject_put(sysfs_dev_char_kobj); | 1715 | kobject_put(sysfs_dev_char_kobj); |
1666 | kobject_put(sysfs_dev_block_kobj); | 1716 | kobject_put(sysfs_dev_block_kobj); |
1667 | kobject_put(dev_kobj); | 1717 | kobject_put(dev_kobj); |
1718 | async_synchronize_full(); | ||
1668 | } | 1719 | } |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 742cbe6b042b..f0106875f01d 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -226,7 +226,7 @@ static int __device_attach(struct device_driver *drv, void *data) | |||
226 | * pair is found, break out and return. | 226 | * pair is found, break out and return. |
227 | * | 227 | * |
228 | * Returns 1 if the device was bound to a driver; | 228 | * Returns 1 if the device was bound to a driver; |
229 | * 0 if no matching device was found; | 229 | * 0 if no matching driver was found; |
230 | * -ENODEV if the device is not registered. | 230 | * -ENODEV if the device is not registered. |
231 | * | 231 | * |
232 | * When called for a USB interface, @dev->parent->sem must be held. | 232 | * When called for a USB interface, @dev->parent->sem must be held. |
@@ -320,6 +320,10 @@ static void __device_release_driver(struct device *dev) | |||
320 | devres_release_all(dev); | 320 | devres_release_all(dev); |
321 | dev->driver = NULL; | 321 | dev->driver = NULL; |
322 | klist_remove(&dev->p->knode_driver); | 322 | klist_remove(&dev->p->knode_driver); |
323 | if (dev->bus) | ||
324 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | ||
325 | BUS_NOTIFY_UNBOUND_DRIVER, | ||
326 | dev); | ||
323 | } | 327 | } |
324 | } | 328 | } |
325 | 329 | ||
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 8a267c427629..ddeb819c8f87 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -40,7 +40,7 @@ static int loading_timeout = 60; /* In seconds */ | |||
40 | static DEFINE_MUTEX(fw_lock); | 40 | static DEFINE_MUTEX(fw_lock); |
41 | 41 | ||
42 | struct firmware_priv { | 42 | struct firmware_priv { |
43 | char fw_id[FIRMWARE_NAME_MAX]; | 43 | char *fw_id; |
44 | struct completion completion; | 44 | struct completion completion; |
45 | struct bin_attribute attr_data; | 45 | struct bin_attribute attr_data; |
46 | struct firmware *fw; | 46 | struct firmware *fw; |
@@ -355,8 +355,9 @@ static void fw_dev_release(struct device *dev) | |||
355 | for (i = 0; i < fw_priv->nr_pages; i++) | 355 | for (i = 0; i < fw_priv->nr_pages; i++) |
356 | __free_page(fw_priv->pages[i]); | 356 | __free_page(fw_priv->pages[i]); |
357 | kfree(fw_priv->pages); | 357 | kfree(fw_priv->pages); |
358 | kfree(fw_priv->fw_id); | ||
358 | kfree(fw_priv); | 359 | kfree(fw_priv); |
359 | kfree(dev); | 360 | put_device(dev); |
360 | 361 | ||
361 | module_put(THIS_MODULE); | 362 | module_put(THIS_MODULE); |
362 | } | 363 | } |
@@ -386,13 +387,19 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
386 | 387 | ||
387 | init_completion(&fw_priv->completion); | 388 | init_completion(&fw_priv->completion); |
388 | fw_priv->attr_data = firmware_attr_data_tmpl; | 389 | fw_priv->attr_data = firmware_attr_data_tmpl; |
389 | strlcpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX); | 390 | fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); |
391 | if (!fw_priv->fw_id) { | ||
392 | dev_err(device, "%s: Firmware name allocation failed\n", | ||
393 | __func__); | ||
394 | retval = -ENOMEM; | ||
395 | goto error_kfree; | ||
396 | } | ||
390 | 397 | ||
391 | fw_priv->timeout.function = firmware_class_timeout; | 398 | fw_priv->timeout.function = firmware_class_timeout; |
392 | fw_priv->timeout.data = (u_long) fw_priv; | 399 | fw_priv->timeout.data = (u_long) fw_priv; |
393 | init_timer(&fw_priv->timeout); | 400 | init_timer(&fw_priv->timeout); |
394 | 401 | ||
395 | dev_set_name(f_dev, dev_name(device)); | 402 | dev_set_name(f_dev, "%s", dev_name(device)); |
396 | f_dev->parent = device; | 403 | f_dev->parent = device; |
397 | f_dev->class = &firmware_class; | 404 | f_dev->class = &firmware_class; |
398 | dev_set_drvdata(f_dev, fw_priv); | 405 | dev_set_drvdata(f_dev, fw_priv); |
@@ -400,14 +407,17 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
400 | retval = device_register(f_dev); | 407 | retval = device_register(f_dev); |
401 | if (retval) { | 408 | if (retval) { |
402 | dev_err(device, "%s: device_register failed\n", __func__); | 409 | dev_err(device, "%s: device_register failed\n", __func__); |
403 | goto error_kfree; | 410 | put_device(f_dev); |
411 | goto error_kfree_fw_id; | ||
404 | } | 412 | } |
405 | *dev_p = f_dev; | 413 | *dev_p = f_dev; |
406 | return 0; | 414 | return 0; |
407 | 415 | ||
416 | error_kfree_fw_id: | ||
417 | kfree(fw_priv->fw_id); | ||
408 | error_kfree: | 418 | error_kfree: |
409 | kfree(fw_priv); | ||
410 | kfree(f_dev); | 419 | kfree(f_dev); |
420 | kfree(fw_priv); | ||
411 | return retval; | 421 | return retval; |
412 | } | 422 | } |
413 | 423 | ||
@@ -615,8 +625,9 @@ request_firmware_work_func(void *arg) | |||
615 | * @cont: function will be called asynchronously when the firmware | 625 | * @cont: function will be called asynchronously when the firmware |
616 | * request is over. | 626 | * request is over. |
617 | * | 627 | * |
618 | * Asynchronous variant of request_firmware() for contexts where | 628 | * Asynchronous variant of request_firmware() for user contexts where |
619 | * it is not possible to sleep. | 629 | * it is not possible to sleep for long time. It can't be called |
630 | * in atomic contexts. | ||
620 | **/ | 631 | **/ |
621 | int | 632 | int |
622 | request_firmware_nowait( | 633 | request_firmware_nowait( |
diff --git a/drivers/base/node.c b/drivers/base/node.c index 40b809742a1c..91d4087b4039 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -72,10 +72,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, | |||
72 | "Node %d Inactive(anon): %8lu kB\n" | 72 | "Node %d Inactive(anon): %8lu kB\n" |
73 | "Node %d Active(file): %8lu kB\n" | 73 | "Node %d Active(file): %8lu kB\n" |
74 | "Node %d Inactive(file): %8lu kB\n" | 74 | "Node %d Inactive(file): %8lu kB\n" |
75 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
76 | "Node %d Unevictable: %8lu kB\n" | 75 | "Node %d Unevictable: %8lu kB\n" |
77 | "Node %d Mlocked: %8lu kB\n" | 76 | "Node %d Mlocked: %8lu kB\n" |
78 | #endif | ||
79 | #ifdef CONFIG_HIGHMEM | 77 | #ifdef CONFIG_HIGHMEM |
80 | "Node %d HighTotal: %8lu kB\n" | 78 | "Node %d HighTotal: %8lu kB\n" |
81 | "Node %d HighFree: %8lu kB\n" | 79 | "Node %d HighFree: %8lu kB\n" |
@@ -105,10 +103,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, | |||
105 | nid, K(node_page_state(nid, NR_INACTIVE_ANON)), | 103 | nid, K(node_page_state(nid, NR_INACTIVE_ANON)), |
106 | nid, K(node_page_state(nid, NR_ACTIVE_FILE)), | 104 | nid, K(node_page_state(nid, NR_ACTIVE_FILE)), |
107 | nid, K(node_page_state(nid, NR_INACTIVE_FILE)), | 105 | nid, K(node_page_state(nid, NR_INACTIVE_FILE)), |
108 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
109 | nid, K(node_page_state(nid, NR_UNEVICTABLE)), | 106 | nid, K(node_page_state(nid, NR_UNEVICTABLE)), |
110 | nid, K(node_page_state(nid, NR_MLOCK)), | 107 | nid, K(node_page_state(nid, NR_MLOCK)), |
111 | #endif | ||
112 | #ifdef CONFIG_HIGHMEM | 108 | #ifdef CONFIG_HIGHMEM |
113 | nid, K(i.totalhigh), | 109 | nid, K(i.totalhigh), |
114 | nid, K(i.freehigh), | 110 | nid, K(i.freehigh), |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ead3f64c41d0..81cb01bfc356 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -69,7 +69,8 @@ EXPORT_SYMBOL_GPL(platform_get_irq); | |||
69 | * @name: resource name | 69 | * @name: resource name |
70 | */ | 70 | */ |
71 | struct resource *platform_get_resource_byname(struct platform_device *dev, | 71 | struct resource *platform_get_resource_byname(struct platform_device *dev, |
72 | unsigned int type, char *name) | 72 | unsigned int type, |
73 | const char *name) | ||
73 | { | 74 | { |
74 | int i; | 75 | int i; |
75 | 76 | ||
@@ -88,7 +89,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname); | |||
88 | * @dev: platform device | 89 | * @dev: platform device |
89 | * @name: IRQ name | 90 | * @name: IRQ name |
90 | */ | 91 | */ |
91 | int platform_get_irq_byname(struct platform_device *dev, char *name) | 92 | int platform_get_irq_byname(struct platform_device *dev, const char *name) |
92 | { | 93 | { |
93 | struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, | 94 | struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, |
94 | name); | 95 | name); |
@@ -244,7 +245,7 @@ int platform_device_add(struct platform_device *pdev) | |||
244 | if (pdev->id != -1) | 245 | if (pdev->id != -1) |
245 | dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); | 246 | dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); |
246 | else | 247 | else |
247 | dev_set_name(&pdev->dev, pdev->name); | 248 | dev_set_name(&pdev->dev, "%s", pdev->name); |
248 | 249 | ||
249 | for (i = 0; i < pdev->num_resources; i++) { | 250 | for (i = 0; i < pdev->num_resources; i++) { |
250 | struct resource *p, *r = &pdev->resource[i]; | 251 | struct resource *p, *r = &pdev->resource[i]; |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 9742a78c9fe4..79a9ae5238ac 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -131,6 +131,8 @@ static struct kset *system_kset; | |||
131 | 131 | ||
132 | int sysdev_class_register(struct sysdev_class *cls) | 132 | int sysdev_class_register(struct sysdev_class *cls) |
133 | { | 133 | { |
134 | int retval; | ||
135 | |||
134 | pr_debug("Registering sysdev class '%s'\n", cls->name); | 136 | pr_debug("Registering sysdev class '%s'\n", cls->name); |
135 | 137 | ||
136 | INIT_LIST_HEAD(&cls->drivers); | 138 | INIT_LIST_HEAD(&cls->drivers); |
@@ -138,7 +140,11 @@ int sysdev_class_register(struct sysdev_class *cls) | |||
138 | cls->kset.kobj.parent = &system_kset->kobj; | 140 | cls->kset.kobj.parent = &system_kset->kobj; |
139 | cls->kset.kobj.ktype = &ktype_sysdev_class; | 141 | cls->kset.kobj.ktype = &ktype_sysdev_class; |
140 | cls->kset.kobj.kset = system_kset; | 142 | cls->kset.kobj.kset = system_kset; |
141 | kobject_set_name(&cls->kset.kobj, cls->name); | 143 | |
144 | retval = kobject_set_name(&cls->kset.kobj, "%s", cls->name); | ||
145 | if (retval) | ||
146 | return retval; | ||
147 | |||
142 | return kset_register(&cls->kset); | 148 | return kset_register(&cls->kset); |
143 | } | 149 | } |
144 | 150 | ||