aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-12 18:49:37 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-12 18:49:37 -0400
commitefefc6eb38d43b8e5daef482f575d767b002004e (patch)
tree8a3933db1f8721f9bcc9912c800dc8406f4bdf94 /drivers/base
parent117494a1b65183f0e3fcc817b07944bc5c465050 (diff)
parentcd59abfcc441b2abb4cf2cd62c1eb0f02a60e8dd (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (75 commits) PM: merge device power-management source files sysfs: add copyrights kobject: update the copyrights kset: add some kerneldoc to help describe what these strange things are Driver core: rename ktype_edd and ktype_efivar Driver core: rename ktype_driver Driver core: rename ktype_device Driver core: rename ktype_class driver core: remove subsystem_init() sysfs: move sysfs file poll implementation to sysfs_open_dirent sysfs: implement sysfs_open_dirent sysfs: move sysfs_dirent->s_children into sysfs_dirent->s_dir sysfs: make sysfs_root a regular directory dirent sysfs: open code sysfs_attach_dentry() sysfs: make s_elem an anonymous union sysfs: make bin attr open get active reference of parent too sysfs: kill unnecessary NULL pointer check in sysfs_release() sysfs: kill unnecessary sysfs_get() in open paths sysfs: reposition sysfs_dirent->s_mode. sysfs: kill sysfs_update_file() ...
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Kconfig8
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c116
-rw-r--r--drivers/base/class.c60
-rw-r--r--drivers/base/core.c108
-rw-r--r--drivers/base/firmware_class.c14
-rw-r--r--drivers/base/memory.c3
-rw-r--r--drivers/base/platform.c26
-rw-r--r--drivers/base/power/Makefile2
-rw-r--r--drivers/base/power/main.c344
-rw-r--r--drivers/base/power/power.h38
-rw-r--r--drivers/base/power/resume.c149
-rw-r--r--drivers/base/power/suspend.c210
-rw-r--r--drivers/base/sys.c73
14 files changed, 503 insertions, 650 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 5d6312e33490..d7da109c24fd 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -1,5 +1,13 @@
1menu "Generic Driver Options" 1menu "Generic Driver Options"
2 2
3config UEVENT_HELPER_PATH
4 string "path to uevent helper"
5 depends on HOTPLUG
6 default "/sbin/hotplug"
7 help
8 Path to uevent helper program forked by the kernel for
9 every uevent.
10
3config STANDALONE 11config STANDALONE
4 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL 12 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
5 default y 13 default y
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 47eb02d9f1af..10b2fb6c9ce6 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -18,8 +18,6 @@ extern int attribute_container_init(void);
18extern int bus_add_device(struct device * dev); 18extern int bus_add_device(struct device * dev);
19extern void bus_attach_device(struct device * dev); 19extern void bus_attach_device(struct device * dev);
20extern void bus_remove_device(struct device * dev); 20extern void bus_remove_device(struct device * dev);
21extern struct bus_type *get_bus(struct bus_type * bus);
22extern void put_bus(struct bus_type * bus);
23 21
24extern int bus_add_driver(struct device_driver *); 22extern int bus_add_driver(struct device_driver *);
25extern void bus_remove_driver(struct device_driver *); 23extern void bus_remove_driver(struct device_driver *);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 61c67526a656..9a19b071c573 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -30,6 +30,17 @@
30static int __must_check bus_rescan_devices_helper(struct device *dev, 30static int __must_check bus_rescan_devices_helper(struct device *dev,
31 void *data); 31 void *data);
32 32
33static struct bus_type *bus_get(struct bus_type *bus)
34{
35 return bus ? container_of(kset_get(&bus->subsys),
36 struct bus_type, subsys) : NULL;
37}
38
39static void bus_put(struct bus_type *bus)
40{
41 kset_put(&bus->subsys);
42}
43
33static ssize_t 44static ssize_t
34drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 45drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
35{ 46{
@@ -78,7 +89,7 @@ static void driver_release(struct kobject * kobj)
78 */ 89 */
79} 90}
80 91
81static struct kobj_type ktype_driver = { 92static struct kobj_type driver_ktype = {
82 .sysfs_ops = &driver_sysfs_ops, 93 .sysfs_ops = &driver_sysfs_ops,
83 .release = driver_release, 94 .release = driver_release,
84}; 95};
@@ -122,9 +133,9 @@ static struct sysfs_ops bus_sysfs_ops = {
122int bus_create_file(struct bus_type * bus, struct bus_attribute * attr) 133int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
123{ 134{
124 int error; 135 int error;
125 if (get_bus(bus)) { 136 if (bus_get(bus)) {
126 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr); 137 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
127 put_bus(bus); 138 bus_put(bus);
128 } else 139 } else
129 error = -EINVAL; 140 error = -EINVAL;
130 return error; 141 return error;
@@ -132,9 +143,9 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
132 143
133void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) 144void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
134{ 145{
135 if (get_bus(bus)) { 146 if (bus_get(bus)) {
136 sysfs_remove_file(&bus->subsys.kobj, &attr->attr); 147 sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
137 put_bus(bus); 148 bus_put(bus);
138 } 149 }
139} 150}
140 151
@@ -172,7 +183,7 @@ static int driver_helper(struct device *dev, void *data)
172static ssize_t driver_unbind(struct device_driver *drv, 183static ssize_t driver_unbind(struct device_driver *drv,
173 const char *buf, size_t count) 184 const char *buf, size_t count)
174{ 185{
175 struct bus_type *bus = get_bus(drv->bus); 186 struct bus_type *bus = bus_get(drv->bus);
176 struct device *dev; 187 struct device *dev;
177 int err = -ENODEV; 188 int err = -ENODEV;
178 189
@@ -186,7 +197,7 @@ static ssize_t driver_unbind(struct device_driver *drv,
186 err = count; 197 err = count;
187 } 198 }
188 put_device(dev); 199 put_device(dev);
189 put_bus(bus); 200 bus_put(bus);
190 return err; 201 return err;
191} 202}
192static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind); 203static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
@@ -199,7 +210,7 @@ static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
199static ssize_t driver_bind(struct device_driver *drv, 210static ssize_t driver_bind(struct device_driver *drv,
200 const char *buf, size_t count) 211 const char *buf, size_t count)
201{ 212{
202 struct bus_type *bus = get_bus(drv->bus); 213 struct bus_type *bus = bus_get(drv->bus);
203 struct device *dev; 214 struct device *dev;
204 int err = -ENODEV; 215 int err = -ENODEV;
205 216
@@ -219,7 +230,7 @@ static ssize_t driver_bind(struct device_driver *drv,
219 err = -ENODEV; 230 err = -ENODEV;
220 } 231 }
221 put_device(dev); 232 put_device(dev);
222 put_bus(bus); 233 bus_put(bus);
223 return err; 234 return err;
224} 235}
225static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind); 236static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
@@ -430,7 +441,7 @@ static inline void remove_deprecated_bus_links(struct device *dev) { }
430 */ 441 */
431int bus_add_device(struct device * dev) 442int bus_add_device(struct device * dev)
432{ 443{
433 struct bus_type * bus = get_bus(dev->bus); 444 struct bus_type * bus = bus_get(dev->bus);
434 int error = 0; 445 int error = 0;
435 446
436 if (bus) { 447 if (bus) {
@@ -459,7 +470,7 @@ out_subsys:
459out_id: 470out_id:
460 device_remove_attrs(bus, dev); 471 device_remove_attrs(bus, dev);
461out_put: 472out_put:
462 put_bus(dev->bus); 473 bus_put(dev->bus);
463 return error; 474 return error;
464} 475}
465 476
@@ -509,7 +520,7 @@ void bus_remove_device(struct device * dev)
509 } 520 }
510 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 521 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
511 device_release_driver(dev); 522 device_release_driver(dev);
512 put_bus(dev->bus); 523 bus_put(dev->bus);
513 } 524 }
514} 525}
515 526
@@ -568,32 +579,29 @@ static void remove_bind_files(struct device_driver *drv)
568 driver_remove_file(drv, &driver_attr_unbind); 579 driver_remove_file(drv, &driver_attr_unbind);
569} 580}