aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 14:25:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 14:25:33 -0400
commitfa93669a1917f93b09142d4b2298329b82d7d36d (patch)
tree7f8d6dc9d1fbb086c59a799a3a7137c46fb9959e /drivers/base
parentb13bc8dda81c54a66a1c84e66f60b8feba659f28 (diff)
parent6791457a090d9a234a40b501c2536f0aefaeae4b (diff)
Merge tag 'driver-core-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core changes from Greg Kroah-Hartman: "Here's the big driver core pull request for 3.6-rc1. Unlike 3.5, this kernel should be a lot tamer, with the printk changes now settled down. All we have here is some extcon driver updates, w1 driver updates, a few printk cleanups that weren't needed for 3.5, but are good to have now, and some other minor fixes/changes in the driver core. All of these have been in the linux-next releases for a while now. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'driver-core-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (38 commits) printk: Export struct log size and member offsets through vmcoreinfo Drivers: hv: Change the hex constant to a decimal constant driver core: don't trigger uevent after failure extcon: MAX77693: Add extcon-max77693 driver to support Maxim MAX77693 MUIC device sysfs: fail dentry revalidation after namespace change fix sysfs: fail dentry revalidation after namespace change extcon: spelling of detach in function doc extcon: arizona: Stop microphone detection if we give up on it extcon: arizona: Update cable reporting calls and split headset PM / Runtime: Do not increment device usage counts before probing kmsg - do not flush partial lines when the console is busy kmsg - export "continuation record" flag to /dev/kmsg kmsg - avoid warning for CONFIG_PRINTK=n compilations kmsg - properly print over-long continuation lines driver-core: Use kobj_to_dev instead of re-implementing it driver-core: Move kobj_to_dev from genhd.h to device.h driver core: Move deferred devices to the end of dpm_list before probing driver core: move uevent call to driver_register driver core: fix shutdown races with probe/remove(v3) Extcon: Arizona: Add driver for Wolfson Arizona class devices ...
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c1
-rw-r--r--drivers/base/core.c71
-rw-r--r--drivers/base/dd.c20
-rw-r--r--drivers/base/dma-buf.c1
-rw-r--r--drivers/base/dma-coherent.c1
-rw-r--r--drivers/base/driver.c6
-rw-r--r--drivers/base/firmware_class.c6
7 files changed, 69 insertions, 37 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2bcef657a60c..181ed2660b33 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -743,7 +743,6 @@ int bus_add_driver(struct device_driver *drv)
743 } 743 }
744 } 744 }
745 745
746 kobject_uevent(&priv->kobj, KOBJ_ADD);
747 return 0; 746 return 0;
748 747
749out_unregister: 748out_unregister:
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 346be8b78b24..f338037a4f3d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -85,14 +85,13 @@ const char *dev_driver_string(const struct device *dev)
85} 85}
86EXPORT_SYMBOL(dev_driver_string); 86EXPORT_SYMBOL(dev_driver_string);
87 87
88#define to_dev(obj) container_of(obj, struct device, kobj)
89#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 88#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
90 89
91static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, 90static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
92 char *buf) 91 char *buf)
93{ 92{
94 struct device_attribute *dev_attr = to_dev_attr(attr); 93 struct device_attribute *dev_attr = to_dev_attr(attr);
95 struct device *dev = to_dev(kobj); 94 struct device *dev = kobj_to_dev(kobj);
96 ssize_t ret = -EIO; 95 ssize_t ret = -EIO;
97 96
98 if (dev_attr->show) 97 if (dev_attr->show)
@@ -108,7 +107,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr,
108 const char *buf, size_t count) 107 const char *buf, size_t count)
109{ 108{
110 struct device_attribute *dev_attr = to_dev_attr(attr); 109 struct device_attribute *dev_attr = to_dev_attr(attr);
111 struct device *dev = to_dev(kobj); 110 struct device *dev = kobj_to_dev(kobj);
112 ssize_t ret = -EIO; 111 ssize_t ret = -EIO;
113 112
114 if (dev_attr->store) 113 if (dev_attr->store)
@@ -182,7 +181,7 @@ EXPORT_SYMBOL_GPL(device_show_int);
182 */ 181 */
183static void device_release(struct kobject *kobj) 182static void device_release(struct kobject *kobj)
184{ 183{
185 struct device *dev = to_dev(kobj); 184 struct device *dev = kobj_to_dev(kobj);
186 struct device_private *p = dev->p; 185 struct device_private *p = dev->p;
187 186
188 if (dev->release) 187 if (dev->release)
@@ -200,7 +199,7 @@ static void device_release(struct kobject *kobj)
200 199
201static const void *device_namespace(struct kobject *kobj) 200static const void *device_namespace(struct kobject *kobj)
202{ 201{
203 struct device *dev = to_dev(kobj); 202 struct device *dev = kobj_to_dev(kobj);
204 const void *ns = NULL; 203 const void *ns = NULL;
205 204
206 if (dev->class && dev->class->ns_type) 205 if (dev->class && dev->class->ns_type)
@@ -221,7 +220,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
221 struct kobj_type *ktype = get_ktype(kobj); 220 struct kobj_type *ktype = get_ktype(kobj);
222 221
223 if (ktype == &device_ktype) { 222 if (ktype == &device_ktype) {
224 struct device *dev = to_dev(kobj); 223 struct device *dev = kobj_to_dev(kobj);
225 if (dev->bus) 224 if (dev->bus)
226 return 1; 225 return 1;
227 if (dev->class) 226 if (dev->class)
@@ -232,7 +231,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
232 231
233static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) 232static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj)
234{ 233{
235 struct device *dev = to_dev(kobj); 234 struct device *dev = kobj_to_dev(kobj);
236 235
237 if (dev->bus) 236 if (dev->bus)
238 return dev->bus->name; 237 return dev->bus->name;
@@ -244,7 +243,7 @@ static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj)
244static int dev_uevent(struct kset *kset, struct kobject *kobj, 243static int dev_uevent(struct kset *kset, struct kobject *kobj,
245 struct kobj_uevent_env *env) 244 struct kobj_uevent_env *env)
246{ 245{
247 struct device *dev = to_dev(kobj); 246 struct device *dev = kobj_to_dev(kobj);
248 int retval = 0; 247 int retval = 0;
249 248
250 /* add device node properties if present */ 249 /* add device node properties if present */
@@ -1132,7 +1131,7 @@ int device_register(struct device *dev)
1132 */ 1131 */
1133struct device *get_device(struct device *dev) 1132struct device *get_device(struct device *dev)
1134{ 1133{
1135 return dev ? to_dev(kobject_get(&dev->kobj)) : NULL; 1134 return dev ? kobj_to_dev(kobject_get(&dev->kobj)) : NULL;
1136} 1135}
1137 1136
1138/** 1137/**
@@ -1754,25 +1753,25 @@ int device_move(struct device *dev, struct device *new_parent,
1754 set_dev_node(dev, dev_to_node(new_parent)); 1753 set_dev_node(dev, dev_to_node(new_parent));
1755 } 1754 }
1756 1755
1757 if (!dev->class) 1756 if (dev->class) {
1758 goto out_put; 1757 error = device_move_class_links(dev, old_parent, new_parent);
1759 error = device_move_class_links(dev, old_parent, new_parent); 1758 if (error) {
1760 if (error) { 1759 /* We ignore errors on cleanup since we're hosed anyway... */
1761 /* We ignore errors on cleanup since we're hosed anyway... */ 1760 device_move_class_links(dev, new_parent, old_parent);
1762 device_move_class_links(dev, new_parent, old_parent); 1761 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1763 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1762 if (new_parent)
1764 if (new_parent) 1763 klist_remove(&dev->p->knode_parent);
1765 klist_remove(&dev->p->knode_parent); 1764 dev->parent = old_parent;
1766 dev->parent = old_parent; 1765 if (old_parent) {
1767 if (old_parent) { 1766 klist_add_tail(&dev->p->knode_parent,
1768 klist_add_tail(&dev->p->knode_parent, 1767 &old_parent->p->klist_children);
1769 &old_parent->p->klist_children); 1768 set_dev_node(dev, dev_to_node(old_parent));
1770 set_dev_node(dev, dev_to_node(old_parent)); 1769 }
1771 } 1770 }
1771 cleanup_glue_dir(dev, new_parent_kobj);
1772 put_device(new_parent);
1773 goto out;
1772 } 1774 }
1773 cleanup_glue_dir(dev, new_parent_kobj);
1774 put_device(new_parent);
1775 goto out;
1776 } 1775 }
1777 switch (dpm_order) { 1776 switch (dpm_order) {
1778 case DPM_ORDER_NONE: 1777 case DPM_ORDER_NONE:
@@ -1787,7 +1786,7 @@ int device_move(struct device *dev, struct device *new_parent,
1787 device_pm_move_last(dev); 1786 device_pm_move_last(dev);
1788 break; 1787 break;
1789 } 1788 }
1790out_put: 1789
1791 put_device(old_parent); 1790 put_device(old_parent);
1792out: 1791out:
1793 device_pm_unlock(); 1792 device_pm_unlock();
@@ -1812,6 +1811,13 @@ void device_shutdown(void)
1812 while (!list_empty(&devices_kset->list)) { 1811 while (!list_empty(&devices_kset->list)) {
1813 dev = list_entry(devices_kset->list.prev, struct device, 1812 dev = list_entry(devices_kset->list.prev, struct device,
1814 kobj.entry); 1813 kobj.entry);
1814
1815 /*
1816 * hold reference count of device's parent to
1817 * prevent it from being freed because parent's
1818 * lock is to be held
1819 */
1820 get_device(dev->parent);
1815 get_device(dev); 1821 get_device(dev);
1816 /* 1822 /*
1817 * Make sure the device is off the kset list, in the 1823 * Make sure the device is off the kset list, in the
@@ -1820,6 +1826,11 @@ void device_shutdown(void)
1820 list_del_init(&dev->kobj.entry); 1826 list_del_init(&dev->kobj.entry);
1821 spin_unlock(&devices_kset->list_lock); 1827 spin_unlock(&devices_kset->list_lock);
1822 1828
1829 /* hold lock to avoid race with probe/release */
1830 if (dev->parent)
1831 device_lock(dev->parent);
1832 device_lock(dev);
1833
1823 /* Don't allow any more runtime suspends */ 1834 /* Don't allow any more runtime suspends */
1824 pm_runtime_get_noresume(dev); 1835 pm_runtime_get_noresume(dev);
1825 pm_runtime_barrier(dev); 1836 pm_runtime_barrier(dev);
@@ -1831,7 +1842,13 @@ void device_shutdown(void)
1831 dev_dbg(dev, "shutdown\n"); 1842 dev_dbg(dev, "shutdown\n");
1832 dev->driver->shutdown(dev); 1843 dev->driver->shutdown(dev);
1833 } 1844 }
1845
1846 device_unlock(dev);
1847 if (dev->parent)
1848 device_unlock(dev->parent);
1849
1834 put_device(dev); 1850 put_device(dev);
1851 put_device(dev->parent);
1835 1852
1836 spin_lock(&devices_kset->list_lock); 1853 spin_lock(&devices_kset->list_lock);
1837 } 1854 }
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index dcb8a6e48692..e3bbed8a617c 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -85,8 +85,20 @@ static void deferred_probe_work_func(struct work_struct *work)
85 * manipulate the deferred list 85 * manipulate the deferred list
86 */ 86 */
87 mutex_unlock(&deferred_probe_mutex); 87 mutex_unlock(&deferred_probe_mutex);
88
89 /*
90 * Force the device to the end of the dpm_list since
91 * the PM code assumes that the order we add things to
92 * the list is a good order for suspend but deferred
93 * probe makes that very unsafe.
94 */
95 device_pm_lock();
96 device_pm_move_last(dev);
97 device_pm_unlock();
98
88 dev_dbg(dev, "Retrying from deferred list\n"); 99 dev_dbg(dev, "Retrying from deferred list\n");
89 bus_probe_device(dev); 100 bus_probe_device(dev);
101
90 mutex_lock(&deferred_probe_mutex); 102 mutex_lock(&deferred_probe_mutex);
91 103
92 put_device(dev); 104 put_device(dev);
@@ -283,6 +295,7 @@ probe_failed:
283 devres_release_all(dev); 295 devres_release_all(dev);
284 driver_sysfs_remove(dev); 296 driver_sysfs_remove(dev);
285 dev->driver = NULL; 297 dev->driver = NULL;
298 dev_set_drvdata(dev, NULL);
286 299
287 if (ret == -EPROBE_DEFER) { 300 if (ret == -EPROBE_DEFER) {
288 /* Driver requested deferred probing */ 301 /* Driver requested deferred probing */
@@ -356,10 +369,9 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
356 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 369 pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
357 drv->bus->name, __func__, dev_name(dev), drv->name); 370 drv->bus->name, __func__, dev_name(dev), drv->name);
358 371
359 pm_runtime_get_noresume(dev);
360 pm_runtime_barrier(dev); 372 pm_runtime_barrier(dev);
361 ret = really_probe(dev, drv); 373 ret = really_probe(dev, drv);
362 pm_runtime_put_sync(dev); 374 pm_runtime_idle(dev);
363 375
364 return ret; 376 return ret;
365} 377}
@@ -406,9 +418,8 @@ int device_attach(struct device *dev)
406 ret = 0; 418 ret = 0;
407 } 419 }
408 } else { 420 } else {
409 pm_runtime_get_noresume(dev);
410 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); 421 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
411 pm_runtime_put_sync(dev); 422 pm_runtime_idle(dev);
412 } 423 }
413out_unlock: 424out_unlock:
414 device_unlock(dev); 425 device_unlock(dev);
@@ -487,6 +498,7 @@ static void __device_release_driver(struct device *dev)
487 drv->remove(dev); 498 drv->remove(dev);
488 devres_release_all(dev); 499 devres_release_all(dev);
489 dev->driver = NULL; 500 dev->driver = NULL;
501 dev_set_drvdata(dev, NULL);
490 klist_remove(&dev->p->knode_driver); 502 klist_remove(&dev->p->knode_driver);
491 if (dev->bus) 503 if (dev->bus)
492 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 504 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 24e88fe29ec1..c30f3e1d0efc 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -493,6 +493,7 @@ EXPORT_SYMBOL_GPL(dma_buf_vmap);
493/** 493/**
494 * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap. 494 * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap.
495 * @dmabuf: [in] buffer to vunmap 495 * @dmabuf: [in] buffer to vunmap
496 * @vaddr: [in] vmap to vunmap
496 */ 497 */
497void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr) 498void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
498{ 499{
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 1b85949e3d2f..560a7173f810 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -186,6 +186,7 @@ EXPORT_SYMBOL(dma_release_from_coherent);
186 * @vma: vm_area for the userspace memory 186 * @vma: vm_area for the userspace memory
187 * @vaddr: cpu address returned by dma_alloc_from_coherent 187 * @vaddr: cpu address returned by dma_alloc_from_coherent
188 * @size: size of the memory buffer allocated by dma_alloc_from_coherent 188 * @size: size of the memory buffer allocated by dma_alloc_from_coherent
189 * @ret: result from remap_pfn_range()
189 * 190 *
190 * This checks whether the memory was allocated from the per-device 191 * This checks whether the memory was allocated from the per-device
191 * coherent memory pool and if so, maps that memory to the provided vma. 192 * coherent memory pool and if so, maps that memory to the provided vma.
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 207c27ddf828..974e301a1ef0 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,8 +185,12 @@ int driver_register(struct device_driver *drv)
185 if (ret) 185 if (ret)
186 return ret; 186 return ret;
187 ret = driver_add_groups(drv, drv->groups); 187 ret = driver_add_groups(drv, drv->groups);
188 if (ret) 188 if (ret) {
189 bus_remove_driver(drv); 189 bus_remove_driver(drv);
190 return ret;
191 }
192 kobject_uevent(&drv->p->kobj, KOBJ_ADD);
193
190 return ret; 194 return ret;
191} 195}
192EXPORT_SYMBOL_GPL(driver_register); 196EXPORT_SYMBOL_GPL(driver_register);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5401814c874d..803cfc1597a9 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -22,8 +22,6 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24 24
25#define to_dev(obj) container_of(obj, struct device, kobj)
26
27MODULE_AUTHOR("Manuel Estrada Sainz"); 25MODULE_AUTHOR("Manuel Estrada Sainz");
28MODULE_DESCRIPTION("Multi purpose firmware loading support"); 26MODULE_DESCRIPTION("Multi purpose firmware loading support");
29MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -290,7 +288,7 @@ static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,
290 struct bin_attribute *bin_attr, 288 struct bin_attribute *bin_attr,
291 char *buffer, loff_t offset, size_t count) 289 char *buffer, loff_t offset, size_t count)
292{ 290{
293 struct device *dev = to_dev(kobj); 291 struct device *dev = kobj_to_dev(kobj);
294 struct firmware_priv *fw_priv = to_firmware_priv(dev); 292 struct firmware_priv *fw_priv = to_firmware_priv(dev);
295 struct firmware *fw; 293 struct firmware *fw;
296 ssize_t ret_count; 294 ssize_t ret_count;
@@ -384,7 +382,7 @@ static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
384 struct bin_attribute *bin_attr, 382 struct bin_attribute *bin_attr,
385 char *buffer, loff_t offset, size_t count) 383 char *buffer, loff_t offset, size_t count)
386{ 384{
387 struct device *dev = to_dev(kobj); 385 struct device *dev = kobj_to_dev(kobj);
388 struct firmware_priv *fw_priv = to_firmware_priv(dev); 386 struct firmware_priv *fw_priv = to_firmware_priv(dev);
389 struct firmware *fw; 387 struct firmware *fw;
390 ssize_t retval; 388 ssize_t retval;