aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/acpi/scan.c16
-rw-r--r--drivers/acpi/video.c4
-rw-r--r--drivers/amba/bus.c9
-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
-rw-r--r--drivers/char/dsp56k.c4
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c6
-rw-r--r--drivers/char/istallion.c8
-rw-r--r--drivers/char/lp.c5
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c5
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c5
-rw-r--r--drivers/char/pty.c9
-rw-r--r--drivers/char/raw.c5
-rw-r--r--drivers/char/snsc.c3
-rw-r--r--drivers/char/stallion.c7
-rw-r--r--drivers/char/tipar.c6
-rw-r--r--drivers/char/viotape.c10
-rw-r--r--drivers/cpufreq/cpufreq.c2
-rw-r--r--drivers/edac/edac_mc_sysfs.c3
-rw-r--r--drivers/eisa/eisa-bus.c9
-rw-r--r--drivers/firewire/fw-device.c11
-rw-r--r--drivers/firmware/dmi-id.c62
-rw-r--r--drivers/firmware/edd.c4
-rw-r--r--drivers/firmware/efivars.c4
-rw-r--r--drivers/i2c/i2c-core.c8
-rw-r--r--drivers/ide/ide.c17
-rw-r--r--drivers/ieee1394/nodemgr.c17
-rw-r--r--drivers/infiniband/core/sysfs.c9
-rw-r--r--drivers/input/input.c62
-rw-r--r--drivers/input/misc/pcspkr.c1
-rw-r--r--drivers/input/serio/serio.c11
-rw-r--r--drivers/md/md.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c4
-rw-r--r--drivers/misc/tifm_core.c9
-rw-r--r--drivers/mmc/core/bus.c21
-rw-r--r--drivers/net/ibmveth.c2
-rw-r--r--drivers/pci/hotplug.c28
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c60
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c6
-rw-r--r--drivers/pci/pci-driver.c3
-rw-r--r--drivers/pci/pci.h3
-rw-r--r--drivers/pci/setup-irq.c2
-rw-r--r--drivers/pcmcia/cs.c10
-rw-r--r--drivers/pcmcia/ds.c26
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c2
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c2
-rw-r--r--drivers/power/power_supply.h3
-rw-r--r--drivers/power/power_supply_sysfs.c17
-rw-r--r--drivers/s390/cio/ccwgroup.c3
-rw-r--r--drivers/s390/cio/device.c25
-rw-r--r--drivers/s390/crypto/ap_bus.c14
-rw-r--r--drivers/scsi/scsi_sysfs.c9
-rw-r--r--drivers/spi/spi.c7
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/driver.c29
-rw-r--r--drivers/usb/core/message.c28
-rw-r--r--drivers/video/output.c29
-rw-r--r--drivers/w1/w1.c19
73 files changed, 743 insertions, 1121 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index feab124d8e05..cbfc81579c9a 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -194,7 +194,7 @@ int acpi_bus_set_power(acpi_handle handle, int state)
194 194
195 if (!device->flags.power_manageable) { 195 if (!device->flags.power_manageable) {
196 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable\n", 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable\n",
197 device->dev.kobj.name)); 197 kobject_name(&device->dev.kobj)));
198 return -ENODEV; 198 return -ENODEV;
199 } 199 }
200 /* 200 /*
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 64620d668742..5b4d462117cf 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -319,16 +319,18 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
319 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); 319 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
320} 320}
321 321
322static int acpi_device_uevent(struct device *dev, char **envp, int num_envp, 322static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
323 char *buffer, int buffer_size)
324{ 323{
325 struct acpi_device *acpi_dev = to_acpi_device(dev); 324 struct acpi_device *acpi_dev = to_acpi_device(dev);
325 int len;
326 326
327 strcpy(buffer, "MODALIAS="); 327 if (add_uevent_var(env, "MODALIAS="))
328 if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) { 328 return -ENOMEM;
329 envp[0] = buffer; 329 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
330 envp[1] = NULL; 330 sizeof(env->buf) - env->buflen);
331 } 331 if (len >= (sizeof(env->buf) - env->buflen))
332 return -ENOMEM;
333 env->buflen += len;
332 return 0; 334 return 0;
333} 335}
334 336
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d05891f16282..b8a2095cb5ee 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -316,7 +316,7 @@ static int acpi_video_output_get(struct output_device *od)
316{ 316{
317 unsigned long state; 317 unsigned long state;
318 struct acpi_video_device *vd = 318 struct acpi_video_device *vd =
319 (struct acpi_video_device *)class_get_devdata(&od->class_dev); 319 (struct acpi_video_device *)dev_get_drvdata(&od->dev);
320 acpi_video_device_get_state(vd, &state); 320 acpi_video_device_get_state(vd, &state);
321 return (int)state; 321 return (int)state;
322} 322}
@@ -325,7 +325,7 @@ static int acpi_video_output_set(struct output_device *od)
325{ 325{
326 unsigned long state = od->request_state; 326 unsigned long state = od->request_state;
327 struct acpi_video_device *vd= 327 struct acpi_video_device *vd=
328 (struct acpi_video_device *)class_get_devdata(&od->class_dev); 328 (struct acpi_video_device *)dev_get_drvdata(&od->dev);
329 return acpi_video_device_set_state(vd, state); 329 return acpi_video_device_set_state(vd, state);
330} 330}
331 331
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 268e301775fc..6b94fb7be5f2 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -44,15 +44,12 @@ static int amba_match(struct device *dev, struct device_driver *drv)
44} 44}
45 45
46#ifdef CONFIG_HOTPLUG 46#ifdef CONFIG_HOTPLUG
47static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) 47static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
48{ 48{
49 struct amba_device *pcdev = to_amba_device(dev); 49 struct amba_device *pcdev = to_amba_device(dev);
50 int retval = 0, i = 0, len = 0; 50 int retval = 0;
51 51
52 retval = add_uevent_var(envp, nr_env, &i, 52 retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid);
53 buf, bufsz, &len,
54 "AMBA_ID=%08x", pcdev->periphid);
55 envp[i] = NULL;
56 return retval; 53 return retval;
57} 54}
58#else 55#else
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}
570 581
582static BUS_ATTR(drivers_probe, S_IWUSR, NULL, store_drivers_probe);
583static BUS_ATTR(drivers_autoprobe, S_IWUSR | S_IRUGO,
584 show_drivers_autoprobe, store_drivers_autoprobe);
585
571static int add_probe_files(struct bus_type *bus) 586static int add_probe_files(struct bus_type *bus)
572{ 587{
573 int retval; 588 int retval;
574 589
575 bus->drivers_probe_attr.attr.name = "drivers_probe"; 590 retval = bus_create_file(bus, &bus_attr_drivers_probe);
576 bus->drivers_probe_attr.attr.mode = S_IWUSR;
577 bus->drivers_probe_attr.store = store_drivers_probe;
578 retval = bus_create_file(bus, &bus->drivers_probe_attr);
579 if (retval) 591 if (retval)
580 goto out; 592 goto out;
581 593
582 bus->drivers_autoprobe_attr.attr.name = "drivers_autoprobe"; 594 retval = bus_create_file(bus, &bus_attr_drivers_autoprobe);
583 bus->drivers_autoprobe_attr.attr.mode = S_IWUSR | S_IRUGO;
584 bus->drivers_autoprobe_attr.show = show_drivers_autoprobe;
585 bus->drivers_autoprobe_attr.store = store_drivers_autoprobe;
586 retval = bus_create_file(bus, &bus->drivers_autoprobe_attr);
587 if (retval) 595 if (retval)
588 bus_remove_file(bus, &bus->drivers_probe_attr); 596 bus_remove_file(bus, &bus_attr_drivers_probe);
589out: 597out:
590 return retval; 598 return retval;
591} 599}
592 600
593static void remove_probe_files(struct bus_type *bus) 601static void remove_probe_files(struct bus_type *bus)
594{ 602{
595 bus_remove_file(bus, &bus->drivers_autoprobe_attr); 603 bus_remove_file(bus, &bus_attr_drivers_autoprobe);
596 bus_remove_file(bus, &bus->drivers_probe_attr); 604 bus_remove_file(bus, &bus_attr_drivers_probe);
597} 605}
598#else 606#else
599static inline int add_bind_files(struct device_driver *drv) { return 0; } 607static inline int add_bind_files(struct device_driver *drv) { return 0; }
@@ -602,6 +610,17 @@ static inline int add_probe_files(struct bus_type *bus) { return 0; }
602static inline void remove_probe_files(struct bus_type *bus) {} 610static inline void remove_probe_files(struct bus_type *bus) {}
603#endif 611#endif
604 612
613static ssize_t driver_uevent_store(struct device_driver *drv,
614 const char *buf, size_t count)
615{
616 enum kobject_action action;
617
618 if (kobject_action_type(buf, count, &action) == 0)
619 kobject_uevent(&drv->kobj, action);
620 return count;
621}
622static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store);
623
605/** 624/**
606 * bus_add_driver - Add a driver to the bus. 625 * bus_add_driver - Add a driver to the bus.
607 * @drv: driver. 626 * @drv: driver.
@@ -609,7 +628,7 @@ static inline void remove_probe_files(struct bus_type *bus) {}
609 */ 628 */
610int bus_add_driver(struct device_driver *drv) 629int bus_add_driver(struct device_driver *drv)
611{ 630{
612 struct bus_type * bus = get_bus(drv->bus); 631 struct bus_type * bus = bus_get(drv->bus);
613 int error = 0; 632 int error = 0;
614 633
615 if (!bus) 634 if (!bus)
@@ -632,6 +651,11 @@ int bus_add_driver(struct device_driver *drv)
632 klist_add_tail(&drv->knode_bus, &bus->klist_drivers); 651 klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
633 module_add_driver(drv->owner, drv); 652 module_add_driver(drv->owner, drv);
634 653
654 error = driver_create_file(drv, &driver_attr_uevent);
655 if (error) {
656 printk(KERN_ERR "%s: uevent attr (%s) failed\n",
657 __FUNCTION__, drv->name);
658 }
635 error = driver_add_attrs(bus, drv); 659 error = driver_add_attrs(bus, drv);
636 if (error) { 660 if (error) {
637 /* How the hell do we get out of this pickle? Give up */ 661 /* How the hell do we get out of this pickle? Give up */
@@ -649,7 +673,7 @@ int bus_add_driver(struct device_driver *drv)
649out_unregister: 673out_unregister:
650 kobject_unregister(&drv->kobj); 674 kobject_unregister(&drv->kobj);
651out_put_bus: 675out_put_bus:
652 put_bus(bus); 676 bus_put(bus);
653 return error; 677 return error;
654} 678}
655 679
@@ -669,12 +693,13 @@ void bus_remove_driver(struct device_driver * drv)
669 693
670 remove_bind_files(drv); 694 remove_bind_files(drv);
671 driver_remove_attrs(drv->bus, drv); 695 driver_remove_attrs(drv->bus, drv);
696 driver_remove_file(drv, &driver_attr_uevent);
672 klist_remove(&drv->knode_bus); 697 klist_remove(&drv->knode_bus);
673 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 698 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
674 driver_detach(drv); 699 driver_detach(drv);
675 module_remove_driver(drv); 700 module_remove_driver(drv);
676 kobject_unregister(&drv->kobj); 701 kobject_unregister(&drv->kobj);
677 put_bus(drv->bus); 702 bus_put(drv->bus);
678} 703}
679 704
680 705
@@ -729,18 +754,6 @@ int device_reprobe(struct device *dev)
729} 754}
730EXPORT_SYMBOL_GPL(device_reprobe); 755EXPORT_SYMBOL_GPL(device_reprobe);
731 756
732struct bus_type *get_bus(struct bus_type *bus)
733{
734 return bus ? container_of(subsys_get(&bus->subsys),
735 struct bus_type, subsys) : NULL;
736}
737
738void put_bus(struct bus_type * bus)
739{
740 subsys_put(&bus->subsys);
741}
742
743
744/** 757/**
745 * find_bus - locate bus by name. 758 * find_bus - locate bus by name.
746 * @name: name of bus. 759 * @name: name of bus.
@@ -808,6 +821,17 @@ static void klist_devices_put(struct klist_node *n)
808 put_device(dev); 821 put_device(dev);
809} 822}
810 823
824static ssize_t bus_uevent_store(struct bus_type *bus,
825 const char *buf, size_t count)
826{
827 enum kobject_action action;
828
829 if (kobject_action_type(buf, count, &action) == 0)
830 kobject_uevent(&bus->subsys.kobj, action);
831 return count;
832}
833static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
834
811/** 835/**
812 * bus_register - register a bus with the system. 836 * bus_register - register a bus with the system.
813 * @bus: bus. 837 * @bus: bus.
@@ -826,11 +850,16 @@ int bus_register(struct bus_type * bus)
826 if (retval) 850 if (retval)
827 goto out; 851 goto out;
828 852
829 subsys_set_kset(bus, bus_subsys); 853 bus->subsys.kobj.kset = &bus_subsys;
854
830 retval = subsystem_register(&bus->subsys); 855 retval = subsystem_register(&bus->subsys);
831 if (retval) 856 if (retval)
832 goto out; 857 goto out;
833 858
859 retval = bus_create_file(bus, &bus_attr_uevent);
860 if (retval)
861 goto bus_uevent_fail;
862
834 kobject_set_name(&bus->devices.kobj, "devices"); 863 kobject_set_name(&bus->devices.kobj, "devices");
835 bus->devices.kobj.parent = &bus->subsys.kobj; 864 bus->devices.kobj.parent = &bus->subsys.kobj;
836 retval = kset_register(&bus->devices); 865 retval = kset_register(&bus->devices);
@@ -839,7 +868,7 @@ int bus_register(struct bus_type * bus)
839 868
840 kobject_set_name(&bus->drivers.kobj, "drivers"); 869 kobject_set_name(&bus->drivers.kobj, "drivers");
841 bus->drivers.kobj.parent = &bus->subsys.kobj; 870 bus->drivers.kobj.parent = &bus->subsys.kobj;
842 bus->drivers.ktype = &ktype_driver; 871 bus->drivers.ktype = &driver_ktype;
843 retval = kset_register(&bus->drivers); 872 retval = kset_register(&bus->drivers);
844 if (retval) 873 if (retval)
845 goto bus_drivers_fail; 874 goto bus_drivers_fail;
@@ -866,6 +895,8 @@ bus_probe_files_fail:
866bus_drivers_fail: 895bus_drivers_fail:
867 kset_unregister(&bus->devices); 896 kset_unregister(&bus->devices);
868bus_devices_fail: 897bus_devices_fail:
898 bus_remove_file(bus, &bus_attr_uevent);
899bus_uevent_fail:
869 subsystem_unregister(&bus->subsys); 900 subsystem_unregister(&bus->subsys);
870out: 901out:
871 return retval; 902 return retval;
@@ -876,7 +907,7 @@ out:
876 * @bus: bus. 907 * @bus: bus.
877 * 908 *
878 * Unregister the child subsystems and the bus itself. 909 * Unregister the child subsystems and the bus itself.
879 * Finally, we call put_bus() to release the refcount 910 * Finally, we call bus_put() to release the refcount
880 */ 911 */
881void bus_unregister(struct bus_type * bus) 912void bus_unregister(struct bus_type * bus)
882{ 913{
@@ -885,6 +916,7 @@ void bus_unregister(struct bus_type * bus)
885 remove_probe_files(bus); 916 remove_probe_files(bus);
886 kset_unregister(&bus->drivers); 917 kset_unregister(&bus->drivers);
887 kset_unregister(&bus->devices); 918 kset_unregister(&bus->devices);
919 bus_remove_file(bus, &bus_attr_uevent);
888 subsystem_unregister(&bus->subsys); 920 subsystem_unregister(&bus->subsys);
889} 921}
890 922
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 4d2222618b78..a863bb091e11 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -65,13 +65,13 @@ static struct sysfs_ops class_sysfs_ops = {
65 .store = class_attr_store, 65 .store = class_attr_store,
66}; 66};
67 67
68static struct kobj_type ktype_class = { 68static struct kobj_type class_ktype = {
69 .sysfs_ops = &class_sysfs_ops, 69 .sysfs_ops = &class_sysfs_ops,
70 .release = class_release, 70 .release = class_release,
71}; 71};
72 72
73/* Hotplug events for classes go to the class_obj subsys */ 73/* Hotplug events for classes go to the class_obj subsys */
74static decl_subsys(class, &ktype_class, NULL); 74static decl_subsys(class, &class_ktype, NULL);
75 75
76 76
77int class_create_file(struct class * cls, const struct class_attribute * attr) 77int class_create_file(struct class * cls, const struct class_attribute * attr)
@@ -93,14 +93,14 @@ void class_remove_file(struct class * cls, const struct class_attribute * attr)
93static struct class *class_get(struct class *cls) 93static struct class *class_get(struct class *cls)
94{ 94{
95 if (cls) 95 if (cls)
96 return container_of(subsys_get(&cls->subsys), struct class, subsys); 96 return container_of(kset_get(&cls->subsys), struct class, subsys);
97 return NULL; 97 return NULL;
98} 98}
99 99
100static void class_put(struct class * cls) 100static void class_put(struct class * cls)
101{ 101{
102 if (cls) 102 if (cls)
103 subsys_put(&cls->subsys); 103 kset_put(&cls->subsys);
104} 104}
105 105
106 106
@@ -149,7 +149,7 @@ int class_register(struct class * cls)
149 if (error) 149 if (error)
150 return error; 150 return error;
151 151
152 subsys_set_kset(cls, class_subsys); 152 cls->subsys.kobj.kset = &class_subsys;
153 153
154 error = subsystem_register(&cls->subsys); 154 error = subsystem_register(&cls->subsys);
155 if (!error) { 155 if (!error) {
@@ -180,8 +180,7 @@ static void class_device_create_release(struct class_device *class_dev)
180 180
181/* needed to allow these devices to have parent class devices */ 181/* needed to allow these devices to have parent class devices */
182static int class_device_create_uevent(struct class_device *class_dev, 182static int class_device_create_uevent(struct class_device *class_dev,
183 char **envp, int num_envp, 183 struct kobj_uevent_env *env)
184 char *buffer, int buffer_size)
185{ 184{
186 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); 185 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
187 return 0; 186 return 0;
@@ -324,7 +323,7 @@ static void class_dev_release(struct kobject * kobj)
324 } 323 }
325} 324}
326 325
327static struct kobj_type ktype_class_device = { 326static struct kobj_type class_device_ktype = {
328 .sysfs_ops = &class_dev_sysfs_ops, 327 .sysfs_ops = &class_dev_sysfs_ops,
329 .release = class_dev_release, 328 .release = class_dev_release,
330}; 329};
@@ -333,7 +332,7 @@ static int class_uevent_filter(struct kset *kset, struct kobject *kobj)
333{ 332{
334 struct kobj_type *ktype = get_ktype(kobj); 333 struct kobj_type *ktype = get_ktype(kobj);
335 334
336 if (ktype == &ktype_class_device) { 335 if (ktype == &class_device_ktype) {
337 struct class_device *class_dev = to_class_dev(kobj); 336 struct class_device *class_dev = to_class_dev(kobj);
338 if (class_dev->class) 337 if (class_dev->class)
339 return 1; 338 return 1;
@@ -403,64 +402,43 @@ static void remove_deprecated_class_device_links(struct class_device *cd)
403{ } 402{ }
404#endif 403#endif
405 404
406static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp, 405static int class_uevent(struct kset *kset, struct kobject *kobj,
407 int num_envp, char *buffer, int buffer_size) 406 struct kobj_uevent_env *env)
408{ 407{
409 struct class_device *class_dev = to_class_dev(kobj); 408 struct class_device *class_dev = to_class_dev(kobj);
410 struct device *dev = class_dev->dev; 409 struct device *dev = class_dev->dev;
411 int i = 0;
412 int length = 0;
413 int retval = 0; 410 int retval = 0;
414 411
415 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 412 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
416 413
417 if (MAJOR(class_dev->devt)) { 414 if (MAJOR(class_dev->devt)) {
418 add_uevent_var(envp, num_envp, &i, 415 add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt));
419 buffer, buffer_size, &length,
420 "MAJOR=%u", MAJOR(class_dev->devt));
421 416
422 add_uevent_var(envp, num_envp, &i, 417 add_uevent_var(env, "MINOR=%u", MINOR(class_dev->devt));
423 buffer, buffer_size, &length,
424 "MINOR=%u", MINOR(class_dev->devt));
425 } 418 }
426 419
427 if (dev) { 420 if (dev) {
428 const char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); 421 const char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
429 if (path) { 422 if (path) {
430 add_uevent_var(envp, num_envp, &i, 423 add_uevent_var(env, "PHYSDEVPATH=%s", path);
431 buffer, buffer_size, &length,
432 "PHYSDEVPATH=%s", path);
433 kfree(path); 424 kfree(path);
434 } 425 }
435 426
436 if (dev->bus) 427 if (dev->bus)
437 add_uevent_var(envp, num_envp, &i, 428 add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name);
438 buffer, buffer_size, &length,
439 "PHYSDEVBUS=%s", dev->bus->name);
440 429
441 if (dev->driver) 430 if (dev->driver)
442 add_uevent_var(envp, num_envp, &i, 431 add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name);
443 buffer, buffer_size, &length,
444 "PHYSDEVDRIVER=%s", dev->driver->name);
445 } 432 }
446 433
447 /* terminate, set to next free slot, shrink available space */
448 envp[i] = NULL;
449 envp = &envp[i];
450 num_envp -= i;
451 buffer = &buffer[length];
452 buffer_size -= length;
453
454 if (class_dev->uevent) { 434 if (class_dev->uevent) {
455 /* have the class device specific function add its stuff */ 435 /* have the class device specific function add its stuff */
456 retval = class_dev->uevent(class_dev, envp, num_envp, 436 retval = class_dev->uevent(class_dev, env);
457 buffer, buffer_size);
458 if (retval) 437 if (retval)
459 pr_debug("class_dev->uevent() returned %d\n", retval); 438 pr_debug("class_dev->uevent() returned %d\n", retval);
460 } else if (class_dev->class->uevent) { 439 } else if (class_dev->class->uevent) {
461 /* have the class specific function add its stuff */ 440 /* have the class specific function add its stuff */
462 retval = class_dev->class->uevent(class_dev, envp, num_envp, 441 retval = class_dev->class->uevent(class_dev, env);
463 buffer, buffer_size);
464 if (retval) 442 if (retval)
465 pr_debug("class->uevent() returned %d\n", retval); 443 pr_debug("class->uevent() returned %d\n", retval);
466 } 444 }
@@ -474,7 +452,7 @@ static struct kset_uevent_ops class_uevent_ops = {
474 .uevent = class_uevent, 452 .uevent = class_uevent,
475}; 453};
476 454
477static decl_subsys(class_obj, &ktype_class_device, &class_uevent_ops); 455static decl_subsys(class_obj, &class_device_ktype, &class_uevent_ops);
478 456
479 457
480static int class_device_add_attrs(struct class_device * cd) 458static int class_device_add_attrs(struct class_device * cd)
@@ -883,7 +861,7 @@ int __init classes_init(void)
883 861
884 /* ick, this is ugly, the things we go through to keep from showing up 862 /* ick, this is ugly, the things we go through to keep from showing up
885 * in sysfs... */ 863 * in sysfs... */
886 subsystem_init(&class_obj_subsys); 864 kset_init(&class_obj_subsys);
887 if (!class_obj_subsys.kobj.parent) 865 if (!class_obj_subsys.kobj.parent)
888 class_obj_subsys.kobj.parent = &class_obj_subsys.kobj; 866 class_obj_subsys.kobj.parent = &class_obj_subsys.kobj;
889 return 0; 867 return 0;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index ec86d6fc2360..c1343414d285 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -108,7 +108,7 @@ static void device_release(struct kobject * kobj)
108 } 108 }
109} 109}
110 110
111static struct kobj_type ktype_device = { 111static struct kobj_type device_ktype = {
112 .release = device_release, 112 .release = device_release,
113 .sysfs_ops = &dev_sysfs_ops, 113 .sysfs_ops = &dev_sysfs_ops,
114}; 114};
@@ -118,7 +118,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
118{ 118{
119 struct kobj_type *ktype = get_ktype(kobj); 119 struct kobj_type *ktype = get_ktype(kobj);
120 120
121 if (ktype == &ktype_device) { 121 if (ktype == &device_ktype) {
122 struct device *dev = to_dev(kobj); 122 struct device *dev = to_dev(kobj);
123 if (dev->uevent_suppress) 123 if (dev->uevent_suppress)
124 return 0; 124 return 0;
@@ -141,33 +141,23 @@ static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj)
141 return NULL; 141 return NULL;
142} 142}
143 143
144static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp, 144static int dev_uevent(struct kset *kset, struct kobject *kobj,
145 int num_envp, char *buffer, int buffer_size) 145 struct kobj_uevent_env *env)
146{ 146{
147 struct device *dev = to_dev(kobj); 147 struct device *dev = to_dev(kobj);
148 int i = 0;
149 int length = 0;
150 int retval = 0; 148 int retval = 0;
151 149
152 /* add the major/minor if present */ 150 /* add the major/minor if present */
153 if (MAJOR(dev->devt)) { 151 if (MAJOR(dev->devt)) {
154 add_uevent_var(envp, num_envp, &i, 152 add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt));
155 buffer, buffer_size, &length, 153 add_uevent_var(env, "MINOR=%u", MINOR(dev->devt));
156 "MAJOR=%u", MAJOR(dev->devt));
157 add_uevent_var(envp, num_envp, &i,
158 buffer, buffer_size, &length,
159 "MINOR=%u", MINOR(dev->devt));
160 } 154 }
161 155
162 if (dev->type && dev->type->name) 156 if (dev->type && dev->type->name)
163 add_uevent_var(envp, num_envp, &i, 157 add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
164 buffer, buffer_size, &length,
165 "DEVTYPE=%s", dev->type->name);
166 158
167 if (dev->driver) 159 if (dev->driver)
168 add_uevent_var(envp, num_envp, &i, 160 add_uevent_var(env, "DRIVER=%s", dev->driver->name);
169 buffer, buffer_size, &length,
170 "DRIVER=%s", dev->driver->name);
171 161
172#ifdef CONFIG_SYSFS_DEPRECATED 162#ifdef CONFIG_SYSFS_DEPRECATED
173 if (dev->class) { 163 if (dev->class) {
@@ -181,59 +171,43 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
181 171
182 path = kobject_get_path(&parent->kobj, GFP_KERNEL); 172 path = kobject_get_path(&parent->kobj, GFP_KERNEL);
183 if (path) { 173 if (path) {
184 add_uevent_var(envp, num_envp, &i, 174 add_uevent_var(env, "PHYSDEVPATH=%s", path);
185 buffer, buffer_size, &length,
186 "PHYSDEVPATH=%s", path);
187 kfree(path); 175 kfree(path);
188 } 176 }
189 177
190 add_uevent_var(envp, num_envp, &i, 178 add_uevent_var(env, "PHYSDEVBUS=%s", parent->bus->name);
191 buffer, buffer_size, &length,
192 "PHYSDEVBUS=%s", parent->bus->name);
193 179
194 if (parent->driver) 180 if (parent->driver)
195 add_uevent_var(envp, num_envp, &i, 181 add_uevent_var(env, "PHYSDEVDRIVER=%s",
196 buffer, buffer_size, &length, 182 parent->driver->name);
197 "PHYSDEVDRIVER=%s", parent->driver->name);
198 } 183 }
199 } else if (dev->bus) { 184 } else if (dev->bus) {
200 add_uevent_var(envp, num_envp, &i, 185 add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name);
201 buffer, buffer_size, &length,
202 "PHYSDEVBUS=%s", dev->bus->name);
203 186
204 if (dev->driver) 187 if (dev->driver)
205 add_uevent_var(envp, num_envp, &i, 188 add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name);
206 buffer, buffer_size, &length,
207 "PHYSDEVDRIVER=%s", dev->driver->name);
208 } 189 }
209#endif 190#endif
210 191
211 /* terminate, set to next free slot, shrink available space */ 192 /* have the bus specific function add its stuff */
212 envp[i] = NULL;
213 envp = &envp[i];
214 num_envp -= i;
215 buffer = &buffer[length];
216 buffer_size -= length;
217
218 if (dev->bus && dev->bus->uevent) { 193 if (dev->bus && dev->bus->uevent) {
219 /* have the bus specific function add its stuff */ 194 retval = dev->bus->uevent(dev, env);
220 retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size);
221 if (retval) 195 if (retval)
222 pr_debug ("%s: bus uevent() returned %d\n", 196 pr_debug ("%s: bus uevent() returned %d\n",
223 __FUNCTION__, retval); 197 __FUNCTION__, retval);
224 } 198 }
225 199
200 /* have the class specific function add its stuff */
226 if (dev->class && dev->class->dev_uevent) { 201 if (dev->class && dev->class->dev_uevent) {
227 /* have the class specific function add its stuff */ 202 retval = dev->class->dev_uevent(dev, env);
228 retval = dev->class->dev_uevent(dev, envp, num_envp, buffer, buffer_size);
229 if (retval) 203 if (retval)
230 pr_debug("%s: class uevent() returned %d\n", 204 pr_debug("%s: class uevent() returned %d\n",
231 __FUNCTION__, retval); 205 __FUNCTION__, retval);
232 } 206 }
233 207
208 /* have the device type specific fuction add its stuff */
234 if (dev->type && dev->type->uevent) { 209 if (dev->type && dev->type->uevent) {
235 /* have the device type specific fuction add its stuff */ 210 retval = dev->type->uevent(dev, env);
236 retval = dev->type->uevent(dev, envp, num_envp, buffer, buffer_size);
237 if (retval) 211 if (retval)
238 pr_debug("%s: dev_type uevent() returned %d\n", 212 pr_debug("%s: dev_type uevent() returned %d\n",
239 __FUNCTION__, retval); 213 __FUNCTION__, retval);
@@ -253,22 +227,18 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
253{ 227{
254 struct kobject *top_kobj; 228 struct kobject *top_kobj;
255 struct kset *kset; 229 struct kset *kset;
256 char *envp[32]; 230 struct kobj_uevent_env *env = NULL;
257 char *data = NULL;
258 char *pos;
259 int i; 231 int i;
260 size_t count = 0; 232 size_t count = 0;
261 int retval; 233 int retval;
262 234
263 /* search the kset, the device belongs to */ 235 /* search the kset, the device belongs to */
264 top_kobj = &dev->kobj; 236 top_kobj = &dev->kobj;
265 if (!top_kobj->kset && top_kobj->parent) { 237 while (!top_kobj->kset && top_kobj->parent)
266 do { 238 top_kobj = top_kobj->parent;
267 top_kobj = top_kobj->parent;
268 } while (!top_kobj->kset && top_kobj->parent);
269 }
270 if (!top_kobj->kset) 239 if (!top_kobj->kset)
271 goto out; 240 goto out;
241
272 kset = top_kobj->kset; 242 kset = top_kobj->kset;
273 if (!kset->uevent_ops || !kset->uevent_ops->uevent) 243 if (!kset->uevent_ops || !kset->uevent_ops->uevent)
274 goto out; 244 goto out;
@@ -278,43 +248,29 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
278 if (!kset->uevent_ops->filter(kset, &dev->kobj)) 248 if (!kset->uevent_ops->filter(kset, &dev->kobj))
279 goto out; 249 goto out;
280 250
281 data = (char *)get_zeroed_page(GFP_KERNEL); 251 env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
282 if (!data) 252 if (!env)
283 return -ENOMEM; 253 return -ENOMEM;
284 254
285 /* let the kset specific function add its keys */ 255 /* let the kset specific function add its keys */
286 pos = data; 256 retval = kset->uevent_ops->uevent(kset, &dev->kobj, env);
287 memset(envp, 0, sizeof(envp));
288 retval = kset->uevent_ops->uevent(kset, &dev->kobj,
289 envp, ARRAY_SIZE(envp),
290 pos, PAGE_SIZE);
291 if (retval) 257 if (retval)
292 goto out; 258 goto out;
293 259
294 /* copy keys to file */ 260 /* copy keys to file */
295 for (i = 0; envp[i]; i++) { 261 for (i = 0; i < env->envp_idx; i++)
296 pos = &buf[count]; 262 count += sprintf(&buf[count], "%s\n", env->envp[i]);
297 count += sprintf(pos, "%s\n", envp[i]);
298 }
299out: 263out:
300 free_page((unsigned long)data); 264 kfree(env);
301 return count; 265 return count;
302} 266}
303 267
304static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, 268static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
305 const char *buf, size_t count) 269 const char *buf, size_t count)
306{ 270{
307 size_t len = count;
308 enum kobject_action action; 271 enum kobject_action action;
309 272
310 if (len && buf[len-1] == '\n') 273 if (kobject_action_type(buf, count, &action) == 0) {
311 len--;
312
313 for (action = 0; action < KOBJ_MAX; action++) {
314 if (strncmp(kobject_actions[action], buf, len) != 0)
315 continue;
316 if (kobject_actions[action][len] != '\0')
317 continue;
318 kobject_uevent(&dev->kobj, action); 274 kobject_uevent(&dev->kobj, action);
319 goto out; 275 goto out;
320 } 276 }
@@ -449,7 +405,7 @@ static struct device_attribute devt_attr =
449 * devices_subsys - structure to be registered with kobject core. 405 * devices_subsys - structure to be registered with kobject core.
450 */ 406 */
451 407
452decl_subsys(devices, &ktype_device, &device_uevent_ops); 408decl_subsys(devices, &device_ktype, &device_uevent_ops);
453 409
454 410
455/** 411/**
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index b24efd4e3e3d..0295855a3eef 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -88,19 +88,14 @@ static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
88 88
89static void fw_dev_release(struct device *dev); 89static void fw_dev_release(struct device *dev);
90 90
91static int firmware_uevent(struct device *dev, char **envp, int num_envp, 91static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
92 char *buffer, int buffer_size)
93{ 92{
94 struct firmware_priv *fw_priv = dev_get_drvdata(dev); 93 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
95 int i = 0, len = 0;
96 94
97 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 95 if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id))
98 "FIRMWARE=%s", fw_priv->fw_id))
99 return -ENOMEM; 96 return -ENOMEM;
100 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 97 if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
101 "TIMEOUT=%i", loading_timeout))
102 return -ENOMEM; 98 return -ENOMEM;
103 envp[i] = NULL;
104 99
105 return 0; 100 return 0;
106} 101}
@@ -297,8 +292,7 @@ firmware_class_timeout(u_long data)
297 292
298static inline void fw_setup_device_id(struct device *f_dev, struct device *dev) 293static inline void fw_setup_device_id(struct device *f_dev, struct device *dev)
299{ 294{
300 /* XXX warning we should watch out for name collisions */ 295 snprintf(f_dev->bus_id, BUS_ID_SIZE, "firmware-%s", dev->bus_id);
301 strlcpy(f_dev->bus_id, dev->bus_id, BUS_ID_SIZE);
302} 296}
303 297
304static int fw_register_device(struct device **dev_p, const char *fw_name, 298static int fw_register_device(struct device **dev_p, const char *fw_name,
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 74b96795d2f5..cb99daeae936 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -34,8 +34,7 @@ static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj)
34 return MEMORY_CLASS_NAME; 34 return MEMORY_CLASS_NAME;
35} 35}
36 36
37static int memory_uevent(struct kset *kset, struct kobject *kobj, char **envp, 37static int memory_uevent(struct kset *kset, struct kobj_uevent_env *env)
38 int num_envp, char *buffer, int buffer_size)
39{ 38{
40 int retval = 0; 39 int retval = 0;
41 40
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 869ff8c00146..fb5609241482 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -160,13 +160,8 @@ static void platform_device_release(struct device *dev)
160 * 160 *
161 * Create a platform device object which can have other objects attached 161 * Create a platform device object which can have other objects attached
162 * to it, and which will have attached objects freed when it is released. 162 * to it, and which will have attached objects freed when it is released.
163 *
164 * This device will be marked as not supporting hotpluggable drivers; no
165 * device add/remove uevents will be generated. In the unusual case that
166 * the device isn't being dynamically allocated as a legacy "probe the
167 * hardware" driver, infrastructure code should reverse this marking.
168 */ 163 */
169struct platform_device *platform_device_alloc(const char *name, unsigned int id) 164struct platform_device *platform_device_alloc(const char *name, int id)
170{ 165{
171 struct platform_object *pa; 166 struct platform_object *pa;
172 167
@@ -177,12 +172,6 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id)
177 pa->pdev.id = id; 172 pa->pdev.id = id;
178 device_initialize(&pa->pdev.dev); 173 device_initialize(&pa->pdev.dev);
179 pa->pdev.dev.release = platform_device_release; 174 pa->pdev.dev.release = platform_device_release;
180
181 /* prevent hotplug "modprobe $(MODALIAS)" from causing trouble in
182 * legacy probe-the-hardware drivers, which don't properly split
183 * out device enumeration logic from drivers.
184 */
185 pa->pdev.dev.uevent_suppress = 1;
186 } 175 }
187 176
188 return pa ? &pa->pdev : NULL; 177 return pa ? &pa->pdev : NULL;
@@ -256,7 +245,8 @@ int platform_device_add(struct platform_device *pdev)
256 pdev->dev.bus = &platform_bus_type; 245 pdev->dev.bus = &platform_bus_type;
257 246
258 if (pdev->id != -1) 247 if (pdev->id != -1)
259 snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%u", pdev->name, pdev->id); 248 snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%d", pdev->name,
249 pdev->id);
260 else 250 else
261 strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); 251 strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE);
262 252
@@ -370,7 +360,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister);
370 * the Linux driver model. In particular, when such drivers are built 360 * the Linux driver model. In particular, when such drivers are built
371 * as modules, they can't be "hotplugged". 361 * as modules, they can't be "hotplugged".
372 */ 362 */
373struct platform_device *platform_device_register_simple(char *name, unsigned int id, 363struct platform_device *platform_device_register_simple(char *name, int id,
374 struct resource *res, unsigned int num) 364 struct resource *res, unsigned int num)
375{ 365{
376 struct platform_device *pdev; 366 struct platform_device *pdev;
@@ -530,7 +520,7 @@ static ssize_t
530modalias_show(struct device *dev, struct device_attribute *a, char *buf) 520modalias_show(struct device *dev, struct device_attribute *a, char *buf)
531{ 521{
532 struct platform_device *pdev = to_platform_device(dev); 522 struct platform_device *pdev = to_platform_device(dev);
533 int len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->name); 523 int len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
534 524
535 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 525 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
536} 526}
@@ -540,13 +530,11 @@ static struct device_attribute platform_dev_attrs[] = {
540 __ATTR_NULL, 530 __ATTR_NULL,
541}; 531};
542 532
543static int platform_uevent(struct device *dev, char **envp, int num_envp, 533static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
544 char *buffer, int buffer_size)
545{ 534{
546 struct platform_device *pdev = to_platform_device(dev); 535 struct platform_device *pdev = to_platform_device(dev);
547 536
548 envp[0] = buffer; 537 add_uevent_var(env, "MODALIAS=platform:%s", pdev->name);
549 snprintf(buffer, buffer_size, "MODALIAS=%s", pdev->name);
550 return 0; 538 return 0;
551} 539}
552 540
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 9caeaea753a3..a803733c839e 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,5 +1,5 @@
1obj-y := shutdown.o 1obj-y := shutdown.o
2obj-$(CONFIG_PM_SLEEP) += main.o suspend.o resume.o sysfs.o 2obj-$(CONFIG_PM_SLEEP) += main.o sysfs.o
3obj-$(CONFIG_PM_TRACE) += trace.o 3obj-$(CONFIG_PM_TRACE) += trace.o
4 4
5ifeq ($(CONFIG_DEBUG_DRIVER),y) 5ifeq ($(CONFIG_DEBUG_DRIVER),y)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index eb9f38d0aa58..0ab4ab21f564 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -20,19 +20,24 @@
20 */ 20 */
21 21
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/kallsyms.h>
23#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/pm.h>
26#include <linux/resume-trace.h>
24 27
28#include "../base.h"
25#include "power.h" 29#include "power.h"
26 30
27LIST_HEAD(dpm_active); 31LIST_HEAD(dpm_active);
28LIST_HEAD(dpm_off); 32static LIST_HEAD(dpm_off);
29LIST_HEAD(dpm_off_irq); 33static LIST_HEAD(dpm_off_irq);
30 34
31DEFINE_MUTEX(dpm_mtx); 35static DEFINE_MUTEX(dpm_mtx);
32DEFINE_MUTEX(dpm_list_mtx); 36static DEFINE_MUTEX(dpm_list_mtx);
33 37
34int (*platform_enable_wakeup)(struct device *dev, int is_on); 38int (*platform_enable_wakeup)(struct device *dev, int is_on);
35 39
40
36int device_pm_add(struct device *dev) 41int device_pm_add(struct device *dev)
37{ 42{
38 int error; 43 int error;
@@ -61,3 +66,334 @@ void device_pm_remove(struct device *dev)
61} 66}
62 67
63 68
69/*------------------------- Resume routines -------------------------*/
70
71/**
72 * resume_device - Restore state for one device.
73 * @dev: Device.
74 *
75 */
76
77static int resume_device(struct device * dev)
78{
79 int error = 0;
80
81 TRACE_DEVICE(dev);
82 TRACE_RESUME(0);
83
84 down(&dev->sem);
85
86 if (dev->bus && dev->bus->resume) {
87 dev_dbg(dev,"resuming\n");
88 error = dev->bus->resume(dev);
89 }
90
91 if (!error && dev->type && dev->type->resume) {
92 dev_dbg(dev,"resuming\n");
93 error = dev->type->resume(dev);
94 }
95
96 if (!error && dev->class && dev->class->resume) {
97 dev_dbg(dev,"class resume\n");
98 error = dev->class->resume(dev);
99 }
100
101 up(&dev->sem);
102
103 TRACE_RESUME(error);
104 return error;
105}
106
107
108static int resume_device_early(struct device * dev)
109{
110 int error = 0;
111
112 TRACE_DEVICE(dev);
113 TRACE_RESUME(0);
114 if (dev->bus && dev->bus->resume_early) {
115 dev_dbg(dev,"EARLY resume\n");
116 error = dev->bus->resume_early(dev);
117 }
118 TRACE_RESUME(error);
119 return error;
120}
121
122/*
123 * Resume the devices that have either not gone through
124 * the late suspend, or that did go through it but also
125 * went through the early resume
126 */
127static void dpm_resume(void)
128{
129 mutex_lock(&dpm_list_mtx);
130 while(!list_empty(&dpm_off)) {
131 struct list_head * entry = dpm_off.next;
132 struct device * dev = to_device(entry);
133
134 get_device(dev);
135 list_move_tail(entry, &dpm_active);
136
137 mutex_unlock(&dpm_list_mtx);
138 resume_device(dev);
139 mutex_lock(&dpm_list_mtx);
140 put_device(dev);
141 }
142 mutex_unlock(&dpm_list_mtx);
143}
144
145
146/**
147 * device_resume - Restore state of each device in system.
148 *
149 * Walk the dpm_off list, remove each entry, resume the device,
150 * then add it to the dpm_active list.
151 */
152
153void device_resume(void)
154{
155 might_sleep();
156 mutex_lock(&dpm_mtx);
157 dpm_resume();
158 mutex_unlock(&dpm_mtx);
159}
160
161EXPORT_SYMBOL_GPL(device_resume);
162
163
164/**
165 * dpm_power_up - Power on some devices.
166 *
167 * Walk the dpm_off_irq list and power each device up. This
168 * is used for devices that required they be powered down with
169 * interrupts disabled. As devices are powered on, they are moved
170 * to the dpm_active list.
171 *
172 * Interrupts must be disabled when calling this.
173 */
174
175static void dpm_power_up(void)
176{
177 while(!list_empty(&dpm_off_irq)) {
178 struct list_head * entry = dpm_off_irq.next;
179 struct device * dev = to_device(entry);
180
181 list_move_tail(entry, &dpm_off);
182 resume_device_early(dev);
183 }
184}
185
186
187/**
188 * device_power_up - Turn on all devices that need special attention.
189 *
190 * Power on system devices then devices that required we shut them down
191 * with interrupts disabled.
192 * Called with interrupts disabled.
193 */
194
195void device_power_up(void)
196{
197 sysdev_resume();
198 dpm_power_up();
199}
200
201EXPORT_SYMBOL_GPL(device_power_up);
202
203
204/*------------------------- Suspend routines -------------------------*/
205
206/*
207 * The entries in the dpm_active list are in a depth first order, simply
208 * because children are guaranteed to be discovered after parents, and
209 * are inserted at the back of the list on discovery.
210 *
211 * All list on the suspend path are done in reverse order, so we operate
212 * on the leaves of the device tree (or forests, depending on how you want
213 * to look at it ;) first. As nodes are removed from the back of the list,
214 * they are inserted into the front of their destintation lists.
215 *
216 * Things are the reverse on the resume path - iterations are done in
217 * forward order, and nodes are inserted at the back of their destination
218 * lists. This way, the ancestors will be accessed before their descendents.
219 */
220
221static inline char *suspend_verb(u32 event)
222{
223 switch (event) {
224 case PM_EVENT_SUSPEND: return "suspend";
225 case PM_EVENT_FREEZE: return "freeze";
226 case PM_EVENT_PRETHAW: return "prethaw";
227 default: return "(unknown suspend event)";
228 }
229}
230
231
232static void
233suspend_device_dbg(struct device *dev, pm_message_t state, char *info)
234{
235 dev_dbg(dev, "%s%s%s\n", info, suspend_verb(state.event),
236 ((state.event == PM_EVENT_SUSPEND) && device_may_wakeup(dev)) ?
237 ", may wakeup" : "");
238}
239
240/**
241 * suspend_device - Save state of one device.
242 * @dev: Device.
243 * @state: Power state device is entering.
244 */
245
246static int suspend_device(struct device * dev, pm_message_t state)
247{
248 int error = 0;
249
250 down(&dev->sem);
251 if (dev->power.power_state.event) {
252 dev_dbg(dev, "PM: suspend %d-->%d\n",
253 dev->power.power_state.event, state.event);
254 }
255
256 if (dev->class && dev->class->suspend) {
257 suspend_device_dbg(dev, state, "class ");
258 error = dev->class->suspend(dev, state);
259 suspend_report_result(dev->class->suspend, error);
260 }
261
262 if (!error && dev->type && dev->type->suspend) {
263 suspend_device_dbg(dev, state, "type ");
264 error = dev->type->suspend(dev, state);
265 suspend_report_result(dev->type->suspend, error);
266 }
267
268 if (!error && dev->bus && dev->bus->suspend) {
269 suspend_device_dbg(dev, state, "");
270 error = dev->bus->suspend(dev, state);
271 suspend_report_result(dev->bus->suspend, error);
272 }
273 up(&dev->sem);
274 return error;
275}
276
277
278/*
279 * This is called with interrupts off, only a single CPU
280 * running. We can't acquire a mutex or semaphore (and we don't
281 * need the protection)
282 */
283static int suspend_device_late(struct device *dev, pm_message_t state)
284{
285 int error = 0;
286
287 if (dev->bus && dev->bus->suspend_late) {
288 suspend_device_dbg(dev, state, "LATE ");
289 error = dev->bus->suspend_late(dev, state);
290 suspend_report_result(dev->bus->suspend_late, error);
291 }
292 return error;
293}
294
295/**
296 * device_suspend - Save state and stop all devices in system.
297 * @state: Power state to put each device in.
298 *
299 * Walk the dpm_active list, call ->suspend() for each device, and move
300 * it to the dpm_off list.
301 *
302 * (For historical reasons, if it returns -EAGAIN, that used to mean
303 * that the device would be called again with interrupts disabled.
304 * These days, we use the "suspend_late()" callback for that, so we
305 * print a warning and consider it an error).
306 *
307 * If we get a different error, try and back out.
308 *
309 * If we hit a failure with any of the devices, call device_resume()
310 * above to bring the suspended devices back to life.
311 *
312 */
313
314int device_suspend(pm_message_t state)
315{
316 int error = 0;
317
318 might_sleep();
319 mutex_lock(&dpm_mtx);
320 mutex_lock(&dpm_list_mtx);
321 while (!list_empty(&dpm_active) && error == 0) {
322 struct list_head * entry = dpm_active.prev;
323 struct device * dev = to_device(entry);
324
325 get_device(dev);
326 mutex_unlock(&dpm_list_mtx);
327
328 error = suspend_device(dev, state);
329
330 mutex_lock(&dpm_list_mtx);
331
332 /* Check if the device got removed */
333 if (!list_empty(&dev->power.entry)) {
334 /* Move it to the dpm_off list */
335 if (!error)
336 list_move(&dev->power.entry, &dpm_off);
337 }
338 if (error)
339 printk(KERN_ERR "Could not suspend device %s: "
340 "error %d%s\n",
341 kobject_name(&dev->kobj), error,
342 error == -EAGAIN ? " (please convert to suspend_late)" : "");
343 put_device(dev);
344 }
345 mutex_unlock(&dpm_list_mtx);
346 if (error)
347 dpm_resume();
348
349 mutex_unlock(&dpm_mtx);
350 return error;
351}
352
353EXPORT_SYMBOL_GPL(device_suspend);
354
355/**
356 * device_power_down - Shut down special devices.
357 * @state: Power state to enter.
358 *
359 * Walk the dpm_off_irq list, calling ->power_down() for each device that
360 * couldn't power down the device with interrupts enabled. When we're
361 * done, power down system devices.
362 */
363
364int device_power_down(pm_message_t state)
365{
366 int error = 0;
367 struct device * dev;
368
369 while (!list_empty(&dpm_off)) {
370 struct list_head * entry = dpm_off.prev;
371
372 dev = to_device(entry);
373 error = suspend_device_late(dev, state);
374 if (error)
375 goto Error;
376 list_move(&dev->power.entry, &dpm_off_irq);
377 }
378
379 error = sysdev_suspend(state);
380 Done:
381 return error;
382 Error:
383 printk(KERN_ERR "Could not power down device %s: "
384 "error %d\n", kobject_name(&dev->kobj), error);
385 dpm_power_up();
386 goto Done;
387}
388
389EXPORT_SYMBOL_GPL(device_power_down);
390
391void __suspend_report_result(const char *function, void *fn, int ret)
392{
393 if (ret) {
394 printk(KERN_ERR "%s(): ", function);
395 print_fn_descriptor_symbol("%s() returns ", (unsigned long)fn);
396 printk("%d\n", ret);
397 }
398}
399EXPORT_SYMBOL_GPL(__suspend_report_result);
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 8ba0830cbc03..5c4efd493fa5 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -11,32 +11,11 @@ extern void device_shutdown(void);
11 * main.c 11 * main.c
12 */ 12 */
13 13
14/* 14extern struct list_head dpm_active; /* The active device list */
15 * Used to synchronize global power management operations.
16 */
17extern struct mutex dpm_mtx;
18
19/*
20 * Used to serialize changes to the dpm_* lists.
21 */
22extern struct mutex dpm_list_mtx;
23
24/*
25 * The PM lists.
26 */
27extern struct list_head dpm_active;
28extern struct list_head dpm_off;
29extern struct list_head dpm_off_irq;
30
31
32static inline struct dev_pm_info * to_pm_info(struct list_head * entry)
33{
34 return container_of(entry, struct dev_pm_info, entry);
35}
36 15
37static inline struct device * to_device(struct list_head * entry) 16static inline struct device * to_device(struct list_head * entry)
38{ 17{
39 return container_of(to_pm_info(entry), struct device, power); 18 return container_of(entry, struct device, power.entry);
40} 19}
41 20
42extern int device_pm_add(struct device *); 21extern int device_pm_add(struct device *);
@@ -49,19 +28,6 @@ extern void device_pm_remove(struct device *);
49extern int dpm_sysfs_add(struct device *); 28extern int dpm_sysfs_add(struct device *);
50extern void dpm_sysfs_remove(struct device *); 29extern void dpm_sysfs_remove(struct device *);
51 30
52/*
53 * resume.c
54 */
55
56extern void dpm_resume(void);
57extern void dpm_power_up(void);
58extern int resume_device(struct device *);
59
60/*
61 * suspend.c
62 */
63extern int suspend_device(struct device *, pm_message_t);
64
65#else /* CONFIG_PM_SLEEP */ 31#else /* CONFIG_PM_SLEEP */
66 32
67 33
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
deleted file mode 100644
index 00fd84ae6e66..000000000000
--- a/drivers/base/power/resume.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * resume.c - Functions for waking devices up.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Labs
6 *
7 * This file is released under the GPLv2
8 *
9 */
10
11#include <linux/device.h>
12#include <linux/resume-trace.h>
13#include "../base.h"
14#include "power.h"
15
16
17/**
18 * resume_device - Restore state for one device.
19 * @dev: Device.
20 *
21 */
22
23int resume_device(struct device * dev)
24{
25 int error = 0;
26
27 TRACE_DEVICE(dev);
28 TRACE_RESUME(0);
29
30 down(&dev->sem);
31
32 if (dev->bus && dev->bus->resume) {
33 dev_dbg(dev,"resuming\n");
34 error = dev->bus->resume(dev);
35 }
36
37 if (!error && dev->type && dev->type->resume) {
38 dev_dbg(dev,"resuming\n");
39 error = dev->type->resume(dev);
40 }
41
42 if (!error && dev->class && dev->class->resume) {
43 dev_dbg(dev,"class resume\n");
44 error = dev->class->resume(dev);
45 }
46
47 up(&dev->sem);
48
49 TRACE_RESUME(error);
50 return error;
51}
52
53
54static int resume_device_early(struct device * dev)
55{
56 int error = 0;
57
58 TRACE_DEVICE(dev);
59 TRACE_RESUME(0);
60 if (dev->bus && dev->bus->resume_early) {
61 dev_dbg(dev,"EARLY resume\n");
62 error = dev->bus->resume_early(dev);
63 }
64 TRACE_RESUME(error);
65 return error;
66}
67
68/*
69 * Resume the devices that have either not gone through
70 * the late suspend, or that did go through it but also
71 * went through the early resume
72 */
73void dpm_resume(void)
74{
75 mutex_lock(&dpm_list_mtx);
76 while(!list_empty(&dpm_off)) {
77 struct list_head * entry = dpm_off.next;
78 struct device * dev = to_device(entry);
79
80 get_device(dev);
81 list_move_tail(entry, &dpm_active);
82
83 mutex_unlock(&dpm_list_mtx);
84 resume_device(dev);
85 mutex_lock(&dpm_list_mtx);
86 put_device(dev);
87 }
88 mutex_unlock(&dpm_list_mtx);
89}
90
91
92/**
93 * device_resume - Restore state of each device in system.
94 *
95 * Walk the dpm_off list, remove each entry, resume the device,
96 * then add it to the dpm_active list.
97 */
98
99void device_resume(void)
100{
101 might_sleep();
102 mutex_lock(&dpm_mtx);
103 dpm_resume();
104 mutex_unlock(&dpm_mtx);
105}
106
107EXPORT_SYMBOL_GPL(device_resume);
108
109
110/**
111 * dpm_power_up - Power on some devices.
112 *
113 * Walk the dpm_off_irq list and power each device up. This
114 * is used for devices that required they be powered down with
115 * interrupts disabled. As devices are powered on, they are moved
116 * to the dpm_active list.
117 *
118 * Interrupts must be disabled when calling this.
119 */
120
121void dpm_power_up(void)
122{
123 while(!list_empty(&dpm_off_irq)) {
124 struct list_head * entry = dpm_off_irq.next;
125 struct device * dev = to_device(entry);
126
127 list_move_tail(entry, &dpm_off);
128 resume_device_early(dev);
129 }
130}
131
132
133/**
134 * device_power_up - Turn on all devices that need special attention.
135 *
136 * Power on system devices then devices that required we shut them down
137 * with interrupts disabled.
138 * Called with interrupts disabled.
139 */
140
141void device_power_up(void)
142{
143 sysdev_resume();
144 dpm_power_up();
145}
146
147EXPORT_SYMBOL_GPL(device_power_up);
148
149
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
deleted file mode 100644
index 26df9b231737..000000000000
--- a/drivers/base/power/suspend.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/*
2 * suspend.c - Functions for putting devices to sleep.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Labs
6 *
7 * This file is released under the GPLv2
8 *
9 */
10
11#include <linux/device.h>
12#include <linux/kallsyms.h>
13#include <linux/pm.h>
14#include "../base.h"
15#include "power.h"
16
17/*
18 * The entries in the dpm_active list are in a depth first order, simply
19 * because children are guaranteed to be discovered after parents, and
20 * are inserted at the back of the list on discovery.
21 *
22 * All list on the suspend path are done in reverse order, so we operate
23 * on the leaves of the device tree (or forests, depending on how you want
24 * to look at it ;) first. As nodes are removed from the back of the list,
25 * they are inserted into the front of their destintation lists.
26 *
27 * Things are the reverse on the resume path - iterations are done in
28 * forward order, and nodes are inserted at the back of their destination
29 * lists. This way, the ancestors will be accessed before their descendents.
30 */
31
32static inline char *suspend_verb(u32 event)
33{
34 switch (event) {
35 case PM_EVENT_SUSPEND: return "suspend";
36 case PM_EVENT_FREEZE: return "freeze";
37 case PM_EVENT_PRETHAW: return "prethaw";
38 default: return "(unknown suspend event)";
39 }
40}
41
42
43static void
44suspend_device_dbg(struct device *dev, pm_message_t state, char *info)
45{
46 dev_dbg(dev, "%s%s%s\n", info, suspend_verb(state.event),
47 ((state.event == PM_EVENT_SUSPEND) && device_may_wakeup(dev)) ?
48 ", may wakeup" : "");
49}
50
51/**
52 * suspend_device - Save state of one device.
53 * @dev: Device.
54 * @state: Power state device is entering.
55 */
56
57int suspend_device(struct device * dev, pm_message_t state)
58{
59 int error = 0;
60
61 down(&dev->sem);
62 if (dev->power.power_state.event) {
63 dev_dbg(dev, "PM: suspend %d-->%d\n",
64 dev->power.power_state.event, state.event);
65 }
66
67 if (dev->class && dev->class->suspend) {
68 suspend_device_dbg(dev, state, "class ");
69 error = dev->class->suspend(dev, state);
70 suspend_report_result(dev->class->suspend, error);
71 }
72
73 if (!error && dev->type && dev->type->suspend) {
74 suspend_device_dbg(dev, state, "type ");
75 error = dev->type->suspend(dev, state);
76 suspend_report_result(dev->type->suspend, error);
77 }
78
79 if (!error && dev->bus && dev->bus->suspend) {
80 suspend_device_dbg(dev, state, "");
81 error = dev->bus->suspend(dev, state);
82 suspend_report_result(dev->bus->suspend, error);
83 }
84 up(&dev->sem);
85 return error;
86}
87
88
89/*
90 * This is called with interrupts off, only a single CPU
91 * running. We can't acquire a mutex or semaphore (and we don't
92 * need the protection)
93 */
94static int suspend_device_late(struct device *dev, pm_message_t state)
95{
96 int error = 0;
97
98 if (dev->bus && dev->bus->suspend_late) {
99 suspend_device_dbg(dev, state, "LATE ");
100 error = dev->bus->suspend_late(dev, state);
101 suspend_report_result(dev->bus->suspend_late, error);
102 }
103 return error;
104}
105
106/**
107 * device_suspend - Save state and stop all devices in system.
108 * @state: Power state to put each device in.
109 *
110 * Walk the dpm_active list, call ->suspend() for each device, and move
111 * it to the dpm_off list.
112 *
113 * (For historical reasons, if it returns -EAGAIN, that used to mean
114 * that the device would be called again with interrupts disabled.
115 * These days, we use the "suspend_late()" callback for that, so we
116 * print a warning and consider it an error).
117 *
118 * If we get a different error, try and back out.
119 *
120 * If we hit a failure with any of the devices, call device_resume()
121 * above to bring the suspended devices back to life.
122 *
123 */
124
125int device_suspend(pm_message_t state)
126{
127 int error = 0;
128
129 might_sleep();
130 mutex_lock(&dpm_mtx);
131 mutex_lock(&dpm_list_mtx);
132 while (!list_empty(&dpm_active) && error == 0) {
133 struct list_head * entry = dpm_active.prev;
134 struct device * dev = to_device(entry);
135
136 get_device(dev);
137 mutex_unlock(&dpm_list_mtx);
138
139 error = suspend_device(dev, state);
140
141 mutex_lock(&dpm_list_mtx);
142
143 /* Check if the device got removed */
144 if (!list_empty(&dev->power.entry)) {
145 /* Move it to the dpm_off list */
146 if (!error)
147 list_move(&dev->power.entry, &dpm_off);
148 }
149 if (error)
150 printk(KERN_ERR "Could not suspend device %s: "
151 "error %d%s\n",
152 kobject_name(&dev->kobj), error,
153 error == -EAGAIN ? " (please convert to suspend_late)" : "");
154 put_device(dev);
155 }
156 mutex_unlock(&dpm_list_mtx);
157 if (error)
158 dpm_resume();
159
160 mutex_unlock(&dpm_mtx);
161 return error;
162}
163
164EXPORT_SYMBOL_GPL(device_suspend);
165
166/**
167 * device_power_down - Shut down special devices.
168 * @state: Power state to enter.
169 *
170 * Walk the dpm_off_irq list, calling ->power_down() for each device that
171 * couldn't power down the device with interrupts enabled. When we're
172 * done, power down system devices.
173 */
174
175int device_power_down(pm_message_t state)
176{
177 int error = 0;
178 struct device * dev;
179
180 while (!list_empty(&dpm_off)) {
181 struct list_head * entry = dpm_off.prev;
182
183 dev = to_device(entry);
184 error = suspend_device_late(dev, state);
185 if (error)
186 goto Error;
187 list_move(&dev->power.entry, &dpm_off_irq);
188 }
189
190 error = sysdev_suspend(state);
191 Done:
192 return error;
193 Error:
194 printk(KERN_ERR "Could not power down device %s: "
195 "error %d\n", kobject_name(&dev->kobj), error);
196 dpm_power_up();
197 goto Done;
198}
199
200EXPORT_SYMBOL_GPL(device_power_down);
201
202void __suspend_report_result(const char *function, void *fn, int ret)
203{
204 if (ret) {
205 printk(KERN_ERR "%s(): ", function);
206 print_fn_descriptor_symbol("%s() returns ", (unsigned long)fn);
207 printk("%d\n", ret);
208 }
209}
210EXPORT_SYMBOL_GPL(__suspend_report_result);
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 18febe26caa1..ac7ff6d0c6e5 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -139,7 +139,7 @@ int sysdev_class_register(struct sysdev_class * cls)
139 kobject_name(&cls->kset.kobj)); 139 kobject_name(&cls->kset.kobj));
140 INIT_LIST_HEAD(&cls->drivers); 140 INIT_LIST_HEAD(&cls->drivers);
141 cls->kset.kobj.parent = &system_subsys.kobj; 141 cls->kset.kobj.parent = &system_subsys.kobj;
142 kset_set_kset_s(cls, system_subsys); 142 cls->kset.kobj.kset = &system_subsys;
143 return kset_register(&cls->kset); 143 return kset_register(&cls->kset);
144} 144}
145 145
@@ -153,25 +153,22 @@ void sysdev_class_unregister(struct sysdev_class * cls)
153EXPORT_SYMBOL_GPL(sysdev_class_register); 153EXPORT_SYMBOL_GPL(sysdev_class_register);
154EXPORT_SYMBOL_GPL(sysdev_class_unregister); 154EXPORT_SYMBOL_GPL(sysdev_class_unregister);
155 155
156
157static LIST_HEAD(sysdev_drivers);
158static DEFINE_MUTEX(sysdev_drivers_lock); 156static DEFINE_MUTEX(sysdev_drivers_lock);
159 157
160/** 158/**
161 * sysdev_driver_register - Register auxillary driver 159 * sysdev_driver_register - Register auxillary driver
162 * @cls: Device class driver belongs to. 160 * @cls: Device class driver belongs to.
163 * @drv: Driver. 161 * @drv: Driver.
164 * 162 *
165 * If @cls is valid, then @drv is inserted into @cls->drivers to be 163 * @drv is inserted into @cls->drivers to be
166 * called on each operation on devices of that class. The refcount 164 * called on each operation on devices of that class. The refcount
167 * of @cls is incremented. 165 * of @cls is incremented.
168 * Otherwise, @drv is inserted into sysdev_drivers, and called for
169 * each device.
170 */ 166 */
171 167
172int sysdev_driver_register(struct sysdev_class * cls, 168int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
173 struct sysdev_driver * drv)
174{ 169{
170 int err = 0;
171
175 mutex_lock(&sysdev_drivers_lock); 172 mutex_lock(&sysdev_drivers_lock);
176 if (cls && kset_get(&cls->kset)) { 173 if (cls && kset_get(&cls->kset)) {
177 list_add_tail(&drv->entry, &cls->drivers); 174 list_add_tail(&drv->entry, &cls->drivers);
@@ -182,10 +179,13 @@ int sysdev_driver_register(struct sysdev_class * cls,
182 list_for_each_entry(dev, &cls->kset.list, kobj.entry) 179 list_for_each_entry(dev, &cls->kset.list, kobj.entry)
183 drv->add(dev); 180 drv->add(dev);
184 } 181 }
185 } else 182 } else {
186 list_add_tail(&drv->entry, &sysdev_drivers); 183 err = -EINVAL;
184 printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__);
185 WARN_ON(1);
186 }
187 mutex_unlock(&sysdev_drivers_lock); 187 mutex_unlock(&sysdev_drivers_lock);
188 return 0; 188 return err;
189} 189}
190 190
191 191
@@ -251,12 +251,6 @@ int sysdev_register(struct sys_device * sysdev)
251 * code that should have called us. 251 * code that should have called us.
252 */ 252 */
253 253
254 /* Notify global drivers */
255 list_for_each_entry(drv, &sysdev_drivers, entry) {
256 if (drv->add)
257 drv->add(sysdev);
258 }
259
260 /* Notify class auxillary drivers */ 254 /* Notify class auxillary drivers */
261 list_for_each_entry(drv, &cls->drivers, entry) { 255 list_for_each_entry(drv, &cls->drivers, entry) {
262 if (drv->add) 256 if (drv->add)
@@ -272,11 +266,6 @@ void sysdev_unregister(struct sys_device * sysdev)
272 struct sysdev_driver * drv; 266 struct sysdev_driver * drv;
273 267
274 mutex_lock(&sysdev_drivers_lock); 268 mutex_lock(&sysdev_drivers_lock);
275 list_for_each_entry(drv, &sysdev_drivers, entry) {
276 if (drv->remove)
277 drv->remove(sysdev);
278 }
279
280 list_for_each_entry(drv, &sysdev->cls->drivers, entry) { 269 list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
281 if (drv->remove) 270 if (drv->remove)
282 drv->remove(sysdev); 271 drv->remove(sysdev);
@@ -293,7 +282,7 @@ void sysdev_unregister(struct sys_device * sysdev)
293 * 282 *
294 * Loop over each class of system devices, and the devices in each 283 * Loop over each class of system devices, and the devices in each
295 * of those classes. For each device, we call the shutdown method for 284 * of those classes. For each device, we call the shutdown method for
296 * each driver registered for the device - the globals, the auxillaries, 285 * each driver registered for the device - the auxillaries,
297 * and the class driver. 286 * and the class driver.
298 * 287 *
299 * Note: The list is iterated in reverse order, so that we shut down 288 * Note: The list is iterated in reverse order, so that we shut down
@@ -320,13 +309,7 @@ void sysdev_shutdown(void)
320 struct sysdev_driver * drv; 309 struct sysdev_driver * drv;
321 pr_debug(" %s\n", kobject_name(&sysdev->kobj)); 310 pr_debug(" %s\n", kobject_name(&sysdev->kobj));
322 311
323 /* Call global drivers first. */ 312 /* Call auxillary drivers first */
324 list_for_each_entry(drv, &sysdev_drivers, entry) {
325 if (drv->shutdown)
326 drv->shutdown(sysdev);
327 }
328
329 /* Call auxillary drivers next. */
330 list_for_each_entry(drv, &cls->drivers, entry) { 313 list_for_each_entry(drv, &cls->drivers, entry) {
331 if (drv->shutdown) 314 if (drv->shutdown)
332 drv->shutdown(sysdev); 315 drv->shutdown(sysdev);
@@ -354,12 +337,6 @@ static void __sysdev_resume(struct sys_device *dev)
354 if (drv->resume) 337 if (drv->resume)
355 drv->resume(dev); 338 drv->resume(dev);
356 } 339 }
357
358 /* Call global drivers. */
359 list_for_each_entry(drv, &sysdev_drivers, entry) {
360 if (drv->resume)
361 drv->resume(dev);
362 }
363} 340}
364 341
365/** 342/**
@@ -393,16 +370,7 @@ int sysdev_suspend(pm_message_t state)
393 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) { 370 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
394 pr_debug(" %s\n", kobject_name(&sysdev->kobj)); 371 pr_debug(" %s\n", kobject_name(&sysdev->kobj));
395 372
396 /* Call global drivers first. */ 373 /* Call auxillary drivers first */
397 list_for_each_entry(drv, &sysdev_drivers, entry) {
398 if (drv->suspend) {
399 ret = drv->suspend(sysdev, state);
400 if (ret)
401 goto gbl_driver;
402 }
403 }
404
405 /* Call auxillary drivers next. */
406 list_for_each_entry(drv, &cls->drivers, entry) { 374 list_for_each_entry(drv, &cls->drivers, entry) {
407 if (drv->suspend) { 375 if (drv->suspend) {
408 ret = drv->suspend(sysdev, state); 376 ret = drv->suspend(sysdev, state);
@@ -436,18 +404,7 @@ aux_driver:
436 if (err_drv->resume) 404 if (err_drv->resume)
437 err_drv->resume(sysdev); 405 err_drv->resume(sysdev);
438 } 406 }
439 drv = NULL;
440 407
441gbl_driver:
442 if (drv)
443 printk(KERN_ERR "sysdev driver suspend failed for %s\n",
444 kobject_name(&sysdev->kobj));
445 list_for_each_entry(err_drv, &sysdev_drivers, entry) {
446 if (err_drv == drv)
447 break;
448 if (err_drv->resume)
449 err_drv->resume(sysdev);
450 }
451 /* resume other sysdevs in current class */ 408 /* resume other sysdevs in current class */
452 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) { 409 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
453 if (err_dev == sysdev) 410 if (err_dev == sysdev)
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 9b8278e1f4f8..acbfe1c49b4d 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -513,7 +513,7 @@ static int __init dsp56k_init_driver(void)
513 err = PTR_ERR(dsp56k_class); 513 err = PTR_ERR(dsp56k_class);
514 goto out_chrdev; 514 goto out_chrdev;
515 } 515 }
516 class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); 516 device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
517 517
518 printk(banner); 518 printk(banner);
519 goto out; 519 goto out;
@@ -527,7 +527,7 @@ module_init(dsp56k_init_driver);
527 527
528static void __exit dsp56k_cleanup_driver(void) 528static void __exit dsp56k_cleanup_driver(void)
529{ 529{
530 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); 530 device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
531 class_destroy(dsp56k_class); 531 class_destroy(dsp56k_class);
532 unregister_chrdev(DSP56K_MAJOR, "dsp56k"); 532 unregister_chrdev(DSP56K_MAJOR, "dsp56k");
533} 533}
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 8d74b8745e60..bd94d5f9e62b 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -411,8 +411,8 @@ cleanup_module(void)
411 iiResetDelay( i2BoardPtrTable[i] ); 411 iiResetDelay( i2BoardPtrTable[i] );
412 /* free io addresses and Tibet */ 412 /* free io addresses and Tibet */
413 release_region( ip2config.addr[i], 8 ); 413 release_region( ip2config.addr[i], 8 );
414 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i)); 414 device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
415 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1)); 415 device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
416 } 416 }
417 /* Disable and remove interrupt handler. */ 417 /* Disable and remove interrupt handler. */
418 if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) { 418 if ( (ip2config.irq[i] > 0) && have_requested_irq(ip2config.irq[i]) ) {
@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
718 } 718 }
719 719
720 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { 720 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
721 class_device_create(ip2_class, NULL, 721 device_create(ip2_class, NULL,
722 MKDEV(IP2_IPL_MAJOR, 4 * i), 722 MKDEV(IP2_IPL_MAJOR, 4 * i),
723 NULL, "ipl%d", i); 723 "ipl%d", i);
724 class_device_create(ip2_class, NULL, 724 device_create(ip2_class, NULL,
725 MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 725 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
726 NULL, "stat%d", i); 726 "stat%d", i);
727 727
728 for ( box = 0; box < ABS_MAX_BOXES; ++box ) 728 for ( box = 0; box < ABS_MAX_BOXES; ++box )
729 { 729 {
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index c2aa44ee6eb6..0246a2b8ce48 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -865,7 +865,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
865 entry->dev = dev; 865 entry->dev = dev;
866 866
867 mutex_lock(&reg_list_mutex); 867 mutex_lock(&reg_list_mutex);
868 class_device_create(ipmi_class, NULL, dev, device, "ipmi%d", if_num); 868 device_create(ipmi_class, device, dev, "ipmi%d", if_num);
869 list_add(&entry->link, &reg_list); 869 list_add(&entry->link, &reg_list);
870 mutex_unlock(&reg_list_mutex); 870 mutex_unlock(&reg_list_mutex);
871} 871}
@@ -883,7 +883,7 @@ static void ipmi_smi_gone(int if_num)
883 break; 883 break;
884 } 884 }
885 } 885 }
886 class_device_destroy(ipmi_class, dev); 886 device_destroy(ipmi_class, dev);
887 mutex_unlock(&reg_list_mutex); 887 mutex_unlock(&reg_list_mutex);
888} 888}
889 889
@@ -938,7 +938,7 @@ static __exit void cleanup_ipmi(void)
938 mutex_lock(&reg_list_mutex); 938 mutex_lock(&reg_list_mutex);
939 list_for_each_entry_safe(entry, entry2, &reg_list, link) { 939 list_for_each_entry_safe(entry, entry2, &reg_list, link) {
940 list_del(&entry->link); 940 list_del(&entry->link);
941 class_device_destroy(ipmi_class, entry->dev); 941 device_destroy(ipmi_class, entry->dev);
942 kfree(entry); 942 kfree(entry);
943 } 943 }
944 mutex_unlock(&reg_list_mutex); 944 mutex_unlock(&reg_list_mutex);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 3c66f402f9d7..1f27be1ec3d4 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -4624,9 +4624,8 @@ static int __init istallion_module_init(void)
4624 4624
4625 istallion_class = class_create(THIS_MODULE, "staliomem"); 4625 istallion_class = class_create(THIS_MODULE, "staliomem");
4626 for (i = 0; i < 4; i++) 4626 for (i = 0; i < 4; i++)
4627 class_device_create(istallion_class, NULL, 4627 device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4628 MKDEV(STL_SIOMEMMAJOR, i), 4628 "staliomem%d", i);
4629 NULL, "staliomem%d", i);
4630 4629
4631 return 0; 4630 return 0;
4632err_deinit: 4631err_deinit:
@@ -4659,8 +4658,7 @@ static void __exit istallion_module_exit(void)
4659 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"); 4658 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4660 4659
4661 for (j = 0; j < 4; j++) 4660 for (j = 0; j < 4; j++)
4662 class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, 4661 device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, j));
4663 j));
4664 class_destroy(istallion_class); 4662 class_destroy(istallion_class);
4665 4663
4666 pci_unregister_driver(&stli_pcidriver); 4664 pci_unregister_driver(&stli_pcidriver);
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 62051f8b0910..c59e2a0996cc 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -799,8 +799,7 @@ static int lp_register(int nr, struct parport *port)
799 if (reset) 799 if (reset)
800 lp_reset(nr); 800 lp_reset(nr);
801 801
802 class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), port->dev, 802 device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
803 "lp%d", nr);
804 803
805 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 804 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
806 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); 805 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
@@ -971,7 +970,7 @@ static void lp_cleanup_module (void)
971 if (lp_table[offset].dev == NULL) 970 if (lp_table[offset].dev == NULL)
972 continue; 971 continue;
973 parport_unregister_device(lp_table[offset].dev); 972 parport_unregister_device(lp_table[offset].dev);
974 class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); 973 device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
975 } 974 }
976 class_destroy(lp_class); 975 class_destroy(lp_class);
977} 976}
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 4177f6db83e9..cc5d77797def 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1863,8 +1863,7 @@ static int cm4000_probe(struct pcmcia_device *link)
1863 return ret; 1863 return ret;
1864 } 1864 }
1865 1865
1866 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, 1866 device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i);
1867 "cmm%d", i);
1868 1867
1869 return 0; 1868 return 0;
1870} 1869}
@@ -1888,7 +1887,7 @@ static void cm4000_detach(struct pcmcia_device *link)
1888 dev_table[devno] = NULL; 1887 dev_table[devno] = NULL;
1889 kfree(dev); 1888 kfree(dev);
1890 1889
1891 class_device_destroy(cmm_class, MKDEV(major, devno)); 1890 device_destroy(cmm_class, MKDEV(major, devno));
1892 1891
1893 return; 1892 return;
1894} 1893}
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index b24a3e7bbb9f..a0b9c8728d56 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -642,8 +642,7 @@ static int reader_probe(struct pcmcia_device *link)
642 return ret; 642 return ret;
643 } 643 }
644 644
645 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, 645 device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i);
646 "cmx%d", i);
647 646
648 return 0; 647 return 0;
649} 648}
@@ -666,7 +665,7 @@ static void reader_detach(struct pcmcia_device *link)
666 dev_table[devno] = NULL; 665 dev_table[devno] = NULL;
667 kfree(dev); 666 kfree(dev);
668 667
669 class_device_destroy(cmx_class, MKDEV(major, devno)); 668 device_destroy(cmx_class, MKDEV(major, devno));
670 669
671 return; 670 return;
672} 671}
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index de14aea34e11..73de77105fea 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -248,14 +248,19 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
248 return -ENOIOCTLCMD; 248 return -ENOIOCTLCMD;
249} 249}
250 250
251static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
252module_param(legacy_count, int, 0);
253
251static void __init legacy_pty_init(void) 254static void __init legacy_pty_init(void)
252{ 255{
256 if (legacy_count <= 0)
257 return;
253 258
254 pty_driver = alloc_tty_driver(NR_PTYS); 259 pty_driver = alloc_tty_driver(legacy_count);
255 if (!pty_driver) 260 if (!pty_driver)
256 panic("Couldn't allocate pty driver"); 261 panic("Couldn't allocate pty driver");
257 262
258 pty_slave_driver = alloc_tty_driver(NR_PTYS); 263 pty_slave_driver = alloc_tty_driver(legacy_count);
259 if (!pty_slave_driver) 264 if (!pty_slave_driver)
260 panic("Couldn't allocate pty slave driver"); 265 panic("Couldn't allocate pty slave driver");
261 266
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 1f0d7c60c944..bbfa0e241cba 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -255,10 +255,7 @@ static const struct file_operations raw_ctl_fops = {
255 .owner = THIS_MODULE, 255 .owner = THIS_MODULE,
256}; 256};
257 257
258static struct cdev raw_cdev = { 258static struct cdev raw_cdev;
259 .kobj = {.name = "raw", },
260 .owner = THIS_MODULE,
261};
262 259
263static int __init raw_init(void) 260static int __init raw_init(void)
264{ 261{
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 52753e723eaa..b9c1dba6bd01 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -441,8 +441,7 @@ scdrv_init(void)
441 continue; 441 continue;
442 } 442 }
443 443
444 class_device_create(snsc_class, NULL, dev, NULL, 444 device_create(snsc_class, NULL, dev, "%s", devname);
445 "%s", devname);
446 445
447 ia64_sn_irtr_intr_enable(scd->scd_nasid, 446 ia64_sn_irtr_intr_enable(scd->scd_nasid,
448 0 /*ignored */ , 447 0 /*ignored */ ,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 4a80b2f864e0..45758d5b56ef 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4778,9 +4778,8 @@ static int __init stallion_module_init(void)
4778 if (IS_ERR(stallion_class)) 4778 if (IS_ERR(stallion_class))
4779 printk("STALLION: failed to create class\n"); 4779 printk("STALLION: failed to create class\n");
4780 for (i = 0; i < 4; i++) 4780 for (i = 0; i < 4; i++)
4781 class_device_create(stallion_class, NULL, 4781 device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4782 MKDEV(STL_SIOMEMMAJOR, i), NULL, 4782 "staliomem%d", i);
4783 "staliomem%d", i);
4784 4783
4785 return 0; 4784 return 0;
4786err_unrtty: 4785err_unrtty:
@@ -4816,7 +4815,7 @@ static void __exit stallion_module_exit(void)
4816 } 4815 }
4817 4816
4818 for (i = 0; i < 4; i++) 4817 for (i = 0; i < 4; i++)
4819 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4818 device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
4820 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"); 4819 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4821 class_destroy(stallion_class); 4820 class_destroy(stallion_class);
4822 4821
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index 35b40b996534..cef55c40654f 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -441,8 +441,8 @@ tipar_register(int nr, struct parport *port)
441 goto out; 441 goto out;
442 } 442 }
443 443
444 class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR, 444 device_create(tipar_class, port->dev, MKDEV(TIPAR_MAJOR,
445 TIPAR_MINOR + nr), port->dev, "par%d", nr); 445 TIPAR_MINOR + nr), "par%d", nr);
446 446
447 /* Display informations */ 447 /* Display informations */
448 pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq == 448 pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq ==
@@ -534,7 +534,7 @@ tipar_cleanup_module(void)
534 if (table[i].dev == NULL) 534 if (table[i].dev == NULL)
535 continue; 535 continue;
536 parport_unregister_device(table[i].dev); 536 parport_unregister_device(table[i].dev);
537 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i)); 537 device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i));
538 } 538 }
539 class_destroy(tipar_class); 539 class_destroy(tipar_class);
540 540
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index f1d60f0cef8f..db7a731e2362 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -871,10 +871,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
871 state[i].cur_part = 0; 871 state[i].cur_part = 0;
872 for (j = 0; j < MAX_PARTITIONS; ++j) 872 for (j = 0; j < MAX_PARTITIONS; ++j)
873 state[i].part_stat_rwi[j] = VIOT_IDLE; 873 state[i].part_stat_rwi[j] = VIOT_IDLE;
874 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL, 874 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
875 "iseries!vt%d", i); 875 "iseries!vt%d", i);
876 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 876 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
877 NULL, "iseries!nvt%d", i); 877 "iseries!nvt%d", i);
878 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " 878 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
879 "resource %10.10s type %4.4s, model %3.3s\n", 879 "resource %10.10s type %4.4s, model %3.3s\n",
880 i, viotape_unitinfo[i].rsrcname, 880 i, viotape_unitinfo[i].rsrcname,
@@ -886,8 +886,8 @@ static int viotape_remove(struct vio_dev *vdev)
886{ 886{
887 int i = vdev->unit_address; 887 int i = vdev->unit_address;
888 888
889 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80)); 889 device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80));
890 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i)); 890 device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i));
891 return 0; 891 return 0;
892} 892}
893 893
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f7b9d6fce123..5e626b12b97e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -830,7 +830,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
830 /* prepare interface data */ 830 /* prepare interface data */
831 policy->kobj.parent = &sys_dev->kobj; 831 policy->kobj.parent = &sys_dev->kobj;
832 policy->kobj.ktype = &ktype_cpufreq; 832 policy->kobj.ktype = &ktype_cpufreq;
833 strlcpy(policy->kobj.name, "cpufreq", KOBJ_NAME_LEN); 833 kobject_set_name(&policy->kobj, "cpufreq");
834 834
835 ret = kobject_register(&policy->kobj); 835 ret = kobject_register(&policy->kobj);
836 if (ret) { 836 if (ret) {
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 4a0576bd06fc..3706b2bc0987 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -743,7 +743,7 @@ static struct kobj_type ktype_mc_set_attribs = {
743 * /sys/devices/system/edac/mc 743 * /sys/devices/system/edac/mc
744 */ 744 */
745static struct kset mc_kset = { 745static struct kset mc_kset = {
746 .kobj = {.name = "mc", .ktype = &ktype_mc_set_attribs }, 746 .kobj = {.ktype = &ktype_mc_set_attribs },
747 .ktype = &ktype_mci, 747 .ktype = &ktype_mci,
748}; 748};
749 749
@@ -1010,6 +1010,7 @@ int edac_sysfs_setup_mc_kset(void)
1010 } 1010 }
1011 1011
1012 /* Init the MC's kobject */ 1012 /* Init the MC's kobject */
1013 kobject_set_name(&mc_kset.kobj, "mc");
1013 mc_kset.kobj.parent = &edac_class->kset.kobj; 1014 mc_kset.kobj.parent = &edac_class->kset.kobj;
1014 1015
1015 /* register the mc_kset */ 1016 /* register the mc_kset */
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index d944647c82c2..4d4a47393909 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -128,16 +128,11 @@ static int eisa_bus_match (struct device *dev, struct device_driver *drv)
128 return 0; 128 return 0;
129} 129}
130 130
131static int eisa_bus_uevent(struct device *dev, char **envp, int num_envp, 131static int eisa_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
132 char *buffer, int buffer_size)
133{ 132{
134 struct eisa_device *edev = to_eisa_device(dev); 133 struct eisa_device *edev = to_eisa_device(dev);
135 int i = 0;
136 int length = 0;
137 134
138 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 135 add_uevent_var(env, "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
139 "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
140 envp[i] = NULL;
141 return 0; 136 return 0;
142} 137}
143 138
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2b6586341635..56681b3b297b 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -130,23 +130,16 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
130} 130}
131 131
132static int 132static int
133fw_unit_uevent(struct device *dev, char **envp, int num_envp, 133fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
134 char *buffer, int buffer_size)
135{ 134{
136 struct fw_unit *unit = fw_unit(dev); 135 struct fw_unit *unit = fw_unit(dev);
137 char modalias[64]; 136 char modalias[64];
138 int length = 0;
139 int i = 0;
140 137
141 get_modalias(unit, modalias, sizeof(modalias)); 138 get_modalias(unit, modalias, sizeof(modalias));
142 139
143 if (add_uevent_var(envp, num_envp, &i, 140 if (add_uevent_var(env, "MODALIAS=%s", modalias))
144 buffer, buffer_size, &length,
145 "MODALIAS=%s", modalias))
146 return -ENOMEM; 141 return -ENOMEM;
147 142
148 envp[i] = NULL;
149
150 return 0; 143 return 0;
151} 144}
152 145
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 59c3b5aa89f4..b6e1eb77d148 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -13,21 +13,31 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/autoconf.h> 14#include <linux/autoconf.h>
15 15
16#define DEFINE_DMI_ATTR(_name, _mode, _show) \ 16struct dmi_device_attribute{
17static struct device_attribute sys_dmi_##_name##_attr = \ 17 struct device_attribute dev_attr;
18 __ATTR(_name, _mode, _show, NULL); 18 int field;
19 19};
20#define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \ 20#define to_dmi_dev_attr(_dev_attr) \
21static ssize_t sys_dmi_##_name##_show(struct device *dev, \ 21 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
22 struct device_attribute *attr, \ 22
23 char *page) \ 23static ssize_t sys_dmi_field_show(struct device *dev,
24{ \ 24 struct device_attribute *attr,
25 ssize_t len; \ 25 char *page)
26 len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(_field)); \ 26{
27 page[len-1] = '\n'; \ 27 int field = to_dmi_dev_attr(attr)->field;
28 return len; \ 28 ssize_t len;
29} \ 29 len = scnprintf(page, PAGE_SIZE, "%s\n", dmi_get_system_info(field));
30DEFINE_DMI_ATTR(_name, _mode, sys_dmi_##_name##_show); 30 page[len-1] = '\n';
31 return len;
32}
33
34#define DMI_ATTR(_name, _mode, _show, _field) \
35 { .dev_attr = __ATTR(_name, _mode, _show, NULL), \
36 .field = _field }
37
38#define DEFINE_DMI_ATTR_WITH_SHOW(_name, _mode, _field) \
39static struct dmi_device_attribute sys_dmi_##_name##_attr = \
40 DMI_ATTR(_name, _mode, sys_dmi_field_show, _field);
31 41
32DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR); 42DEFINE_DMI_ATTR_WITH_SHOW(bios_vendor, 0444, DMI_BIOS_VENDOR);
33DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION); 43DEFINE_DMI_ATTR_WITH_SHOW(bios_version, 0444, DMI_BIOS_VERSION);
@@ -121,7 +131,8 @@ static ssize_t sys_dmi_modalias_show(struct device *dev,
121 return r+1; 131 return r+1;
122} 132}
123 133
124DEFINE_DMI_ATTR(modalias, 0444, sys_dmi_modalias_show); 134static struct device_attribute sys_dmi_modalias_attr =
135 __ATTR(modalias, 0444, sys_dmi_modalias_show, NULL);
125 136
126static struct attribute *sys_dmi_attributes[DMI_STRING_MAX+2]; 137static struct attribute *sys_dmi_attributes[DMI_STRING_MAX+2];
127 138
@@ -134,14 +145,17 @@ static struct attribute_group* sys_dmi_attribute_groups[] = {
134 NULL 145 NULL
135}; 146};
136 147
137static int dmi_dev_uevent(struct device *dev, char **envp, 148static int dmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
138 int num_envp, char *buffer, int buffer_size)
139{ 149{
140 strcpy(buffer, "MODALIAS="); 150 ssize_t len;
141 get_modalias(buffer+9, buffer_size-9); 151
142 envp[0] = buffer; 152 if (add_uevent_var(env, "MODALIAS="))
143 envp[1] = NULL; 153 return -ENOMEM;
144 154 len = get_modalias(&env->buf[env->buflen - 1],
155 sizeof(env->buf) - env->buflen);
156 if (len >= (sizeof(env->buf) - env->buflen))
157 return -ENOMEM;
158 env->buflen += len;
145 return 0; 159 return 0;
146} 160}
147 161
@@ -157,7 +171,7 @@ static struct device *dmi_dev;
157 171
158#define ADD_DMI_ATTR(_name, _field) \ 172#define ADD_DMI_ATTR(_name, _field) \
159 if (dmi_get_system_info(_field)) \ 173 if (dmi_get_system_info(_field)) \
160 sys_dmi_attributes[i++] = & sys_dmi_##_name##_attr.attr; 174 sys_dmi_attributes[i++] = &sys_dmi_##_name##_attr.dev_attr.attr;
161 175
162extern int dmi_available; 176extern int dmi_available;
163 177
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 0fb730ee1da8..6942e065e609 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -625,13 +625,13 @@ static void edd_release(struct kobject * kobj)
625 kfree(dev); 625 kfree(dev);
626} 626}
627 627
628static struct kobj_type ktype_edd = { 628static struct kobj_type edd_ktype = {
629 .release = edd_release, 629 .release = edd_release,
630 .sysfs_ops = &edd_attr_ops, 630 .sysfs_ops = &edd_attr_ops,
631 .default_attrs = def_attrs, 631 .default_attrs = def_attrs,
632}; 632};
633 633
634static decl_subsys(edd,&ktype_edd,NULL); 634static decl_subsys(edd, &edd_ktype, NULL);
635 635
636 636
637/** 637/**
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index bfd2d67df689..858a7b95933b 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -402,7 +402,7 @@ static struct attribute *def_attrs[] = {
402 NULL, 402 NULL,
403}; 403};
404 404
405static struct kobj_type ktype_efivar = { 405static struct kobj_type efivar_ktype = {
406 .release = efivar_release, 406 .release = efivar_release,
407 .sysfs_ops = &efivar_attr_ops, 407 .sysfs_ops = &efivar_attr_ops,
408 .default_attrs = def_attrs, 408 .default_attrs = def_attrs,
@@ -583,7 +583,7 @@ static struct subsys_attribute *efi_subsys_attrs[] = {
583 NULL, /* maybe more in the future? */ 583 NULL, /* maybe more in the future? */
584}; 584};
585 585
586static decl_subsys(vars, &ktype_efivar, NULL); 586static decl_subsys(vars, &efivar_ktype, NULL);
587static decl_subsys(efi, NULL, NULL); 587static decl_subsys(efi, NULL, NULL);
588 588
589/* 589/*
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index d663e6960d93..910a62de190d 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -67,20 +67,16 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
67#ifdef CONFIG_HOTPLUG 67#ifdef CONFIG_HOTPLUG
68 68
69/* uevent helps with hotplug: modprobe -q $(MODALIAS) */ 69/* uevent helps with hotplug: modprobe -q $(MODALIAS) */
70static int i2c_device_uevent(struct device *dev, char **envp, int num_envp, 70static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
71 char *buffer, int buffer_size)
72{ 71{
73 struct i2c_client *client = to_i2c_client(dev); 72 struct i2c_client *client = to_i2c_client(dev);
74 int i = 0, length = 0;
75 73
76 /* by definition, legacy drivers can't hotplug */ 74 /* by definition, legacy drivers can't hotplug */
77 if (dev->driver || !client->driver_name) 75 if (dev->driver || !client->driver_name)
78 return 0; 76 return 0;
79 77
80 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 78 if (add_uevent_var(env, "MODALIAS=%s", client->driver_name))
81 "MODALIAS=%s", client->driver_name))
82 return -ENOMEM; 79 return -ENOMEM;
83 envp[i] = NULL;
84 dev_dbg(dev, "uevent\n"); 80 dev_dbg(dev, "uevent\n");
85 return 0; 81 return 0;
86} 82}
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index e96212ce5729..a96a8b1b3539 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1663,20 +1663,13 @@ static struct device_attribute ide_dev_attrs[] = {
1663 __ATTR_NULL 1663 __ATTR_NULL
1664}; 1664};
1665 1665
1666static int ide_uevent(struct device *dev, char **envp, int num_envp, 1666static int ide_uevent(struct device *dev, struct kobj_uevent_env *env)
1667 char *buffer, int buffer_size)
1668{ 1667{
1669 ide_drive_t *drive = to_ide_device(dev); 1668 ide_drive_t *drive = to_ide_device(dev);
1670 int i = 0; 1669
1671 int length = 0; 1670 add_uevent_var(env, "MEDIA=%s", media_string(drive));
1672 1671 add_uevent_var(env, "DRIVENAME=%s", drive->name);
1673 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 1672 add_uevent_var(env, "MODALIAS=ide:m-%s", media_string(drive));
1674 "MEDIA=%s", media_string(drive));
1675 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1676 "DRIVENAME=%s", drive->name);
1677 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1678 "MODALIAS=ide:m-%s", media_string(drive));
1679 envp[i] = NULL;
1680 return 0; 1673 return 0;
1681} 1674}
1682 1675
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 2ffd53461db6..1939fee616ec 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -153,8 +153,7 @@ struct host_info {
153}; 153};
154 154
155static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 155static int nodemgr_bus_match(struct device * dev, struct device_driver * drv);
156static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 156static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env);
157 char *buffer, int buffer_size);
158static void nodemgr_resume_ne(struct node_entry *ne); 157static void nodemgr_resume_ne(struct node_entry *ne);
159static void nodemgr_remove_ne(struct node_entry *ne); 158static void nodemgr_remove_ne(struct node_entry *ne);
160static struct node_entry *find_entry_by_guid(u64 guid); 159static struct node_entry *find_entry_by_guid(u64 guid);
@@ -1160,12 +1159,9 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1160 1159
1161#ifdef CONFIG_HOTPLUG 1160#ifdef CONFIG_HOTPLUG
1162 1161
1163static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 1162static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env)
1164 char *buffer, int buffer_size)
1165{ 1163{
1166 struct unit_directory *ud; 1164 struct unit_directory *ud;
1167 int i = 0;
1168 int length = 0;
1169 int retval = 0; 1165 int retval = 0;
1170 /* ieee1394:venNmoNspNverN */ 1166 /* ieee1394:venNmoNspNverN */
1171 char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; 1167 char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1];
@@ -1180,9 +1176,7 @@ static int nodemgr_uevent(struct device *dev, char **envp, int num_envp,
1180 1176
1181#define PUT_ENVP(fmt,val) \ 1177#define PUT_ENVP(fmt,val) \
1182do { \ 1178do { \
1183 retval = add_uevent_var(envp, num_envp, &i, \ 1179 retval = add_uevent_var(env, fmt, val); \
1184 buffer, buffer_size, &length, \
1185 fmt, val); \
1186 if (retval) \ 1180 if (retval) \
1187 return retval; \ 1181 return retval; \
1188} while (0) 1182} while (0)
@@ -1201,15 +1195,12 @@ do { \
1201 1195
1202#undef PUT_ENVP 1196#undef PUT_ENVP
1203 1197
1204 envp[i] = NULL;
1205
1206 return 0; 1198 return 0;
1207} 1199}
1208 1200
1209#else 1201#else
1210 1202
1211static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 1203static int nodemgr_uevent(struct device *dev, struct kobj_uevent_env *env)
1212 char *buffer, int buffer_size)
1213{ 1204{
1214 return -ENODEV; 1205 return -ENODEV;
1215} 1206}
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 70b77ae67422..3d4050681325 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -434,21 +434,18 @@ static void ib_device_release(struct class_device *cdev)
434 kfree(dev); 434 kfree(dev);
435} 435}
436 436
437static int ib_device_uevent(struct class_device *cdev, char **envp, 437static int ib_device_uevent(struct class_device *cdev,
438 int num_envp, char *buf, int size) 438 struct kobj_uevent_env *env)
439{ 439{
440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
441 int i = 0, len = 0;
442 441
443 if (add_uevent_var(envp, num_envp, &i, buf, size, &len, 442 if (add_uevent_var(env, "NAME=%s", dev->name))
444 "NAME=%s", dev->name))
445 return -ENOMEM; 443 return -ENOMEM;
446 444
447 /* 445 /*
448 * It would be nice to pass the node GUID with the event... 446 * It would be nice to pass the node GUID with the event...
449 */ 447 */
450 448
451 envp[i] = NULL;
452 return 0; 449 return 0;
453} 450}
454 451
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 5fe755586623..5dc361c954e2 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -859,87 +859,66 @@ static void input_dev_release(struct device *device)
859 * Input uevent interface - loading event handlers based on 859 * Input uevent interface - loading event handlers based on
860 * device bitfields. 860 * device bitfields.
861 */ 861 */
862static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index, 862static int input_add_uevent_bm_var(struct kobj_uevent_env *env,
863 char *buffer, int buffer_size, int *cur_len,
864 const char *name, unsigned long *bitmap, int max) 863 const char *name, unsigned long *bitmap, int max)
865{ 864{
866 if (*cur_index >= num_envp - 1) 865 int len;
867 return -ENOMEM;
868
869 envp[*cur_index] = buffer + *cur_len;
870 866
871 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name); 867 if (add_uevent_var(env, "%s=", name))
872 if (*cur_len >= buffer_size)
873 return -ENOMEM; 868 return -ENOMEM;
874 869
875 *cur_len += input_print_bitmap(buffer + *cur_len, 870 len = input_print_bitmap(&env->buf[env->buflen - 1],
876 max(buffer_size - *cur_len, 0), 871 sizeof(env->buf) - env->buflen,
877 bitmap, max, 0) + 1; 872 bitmap, max, 0);
878 if (*cur_len > buffer_size) 873 if (len >= (sizeof(env->buf) - env->buflen))
879 return -ENOMEM; 874 return -ENOMEM;
880 875
881 (*cur_index)++; 876 env->buflen += len;
882 return 0; 877 return 0;
883} 878}
884 879
885static int input_add_uevent_modalias_var(char **envp, int num_envp, int *cur_index, 880static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,
886 char *buffer, int buffer_size, int *cur_len,
887 struct input_dev *dev) 881 struct input_dev *dev)
888{ 882{
889 if (*cur_index >= num_envp - 1) 883 int len;
890 return -ENOMEM;
891
892 envp[*cur_index] = buffer + *cur_len;
893 884
894 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), 885 if (add_uevent_var(env, "MODALIAS="))
895 "MODALIAS=");
896 if (*cur_len >= buffer_size)
897 return -ENOMEM; 886 return -ENOMEM;
898 887
899 *cur_len += input_print_modalias(buffer + *cur_len, 888 len = input_print_modalias(&env->buf[env->buflen - 1],
900 max(buffer_size - *cur_len, 0), 889 sizeof(env->buf) - env->buflen,
901 dev, 0) + 1; 890 dev, 0);
902 if (*cur_len > buffer_size) 891 if (len >= (sizeof(env->buf) - env->buflen))
903 return -ENOMEM; 892 return -ENOMEM;
904 893
905 (*cur_index)++; 894 env->buflen += len;
906 return 0; 895 return 0;
907} 896}
908 897
909#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ 898#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
910 do { \ 899 do { \
911 int err = add_uevent_var(envp, num_envp, &i, \ 900 int err = add_uevent_var(env, fmt, val); \
912 buffer, buffer_size, &len, \
913 fmt, val); \
914 if (err) \ 901 if (err) \
915 return err; \ 902 return err; \
916 } while (0) 903 } while (0)
917 904
918#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ 905#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \
919 do { \ 906 do { \
920 int err = input_add_uevent_bm_var(envp, num_envp, &i, \ 907 int err = input_add_uevent_bm_var(env, name, bm, max); \
921 buffer, buffer_size, &len, \
922 name, bm, max); \
923 if (err) \ 908 if (err) \
924 return err; \ 909 return err; \
925 } while (0) 910 } while (0)
926 911
927#define INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev) \ 912#define INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev) \
928 do { \ 913 do { \
929 int err = input_add_uevent_modalias_var(envp, \ 914 int err = input_add_uevent_modalias_var(env, dev); \
930 num_envp, &i, \
931 buffer, buffer_size, &len, \
932 dev); \
933 if (err) \ 915 if (err) \
934 return err; \ 916 return err; \
935 } while (0) 917 } while (0)
936 918
937static int input_dev_uevent(struct device *device, char **envp, 919static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env)
938 int num_envp, char *buffer, int buffer_size)
939{ 920{
940 struct input_dev *dev = to_input_dev(device); 921 struct input_dev *dev = to_input_dev(device);
941 int i = 0;
942 int len = 0;
943 922
944 INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", 923 INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x",
945 dev->id.bustype, dev->id.vendor, 924 dev->id.bustype, dev->id.vendor,
@@ -971,7 +950,6 @@ static int input_dev_uevent(struct device *device, char **envp,
971 950
972 INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev); 951 INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev);
973 952
974 envp[i] = NULL;
975 return 0; 953 return 0;
976} 954}
977 955
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 4e2ca6f0ab18..c19f77fbaf2a 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -22,6 +22,7 @@
22MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 22MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
23MODULE_DESCRIPTION("PC Speaker beeper driver"); 23MODULE_DESCRIPTION("PC Speaker beeper driver");
24MODULE_LICENSE("GPL"); 24MODULE_LICENSE("GPL");
25MODULE_ALIAS("platform:pcspkr");
25 26
26#ifdef CONFIG_X86 27#ifdef CONFIG_X86
27/* Use the global PIT lock ! */ 28/* Use the global PIT lock ! */
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 372ca4931194..b3bc15acd3f5 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -876,18 +876,14 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv)
876 876
877#define SERIO_ADD_UEVENT_VAR(fmt, val...) \ 877#define SERIO_ADD_UEVENT_VAR(fmt, val...) \
878 do { \ 878 do { \
879 int err = add_uevent_var(envp, num_envp, &i, \ 879 int err = add_uevent_var(env, fmt, val); \
880 buffer, buffer_size, &len, \
881 fmt, val); \
882 if (err) \ 880 if (err) \
883 return err; \ 881 return err; \
884 } while (0) 882 } while (0)
885 883
886static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 884static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
887{ 885{
888 struct serio *serio; 886 struct serio *serio;
889 int i = 0;
890 int len = 0;
891 887
892 if (!dev) 888 if (!dev)
893 return -ENODEV; 889 return -ENODEV;
@@ -900,7 +896,6 @@ static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buf
900 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); 896 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra);
901 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", 897 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X",
902 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); 898 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
903 envp[i] = NULL;
904 899
905 return 0; 900 return 0;
906} 901}
@@ -908,7 +903,7 @@ static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buf
908 903
909#else 904#else
910 905
911static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 906static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
912{ 907{
913 return -ENODEV; 908 return -ENODEV;
914} 909}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e8f102ea9b03..acf1b81b47cb 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3076,8 +3076,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
3076 mddev->gendisk = disk; 3076 mddev->gendisk = disk;
3077 mutex_unlock(&disks_mutex); 3077 mutex_unlock(&disks_mutex);
3078 mddev->kobj.parent = &disk->kobj; 3078 mddev->kobj.parent = &disk->kobj;
3079 mddev->kobj.k_name = NULL; 3079 kobject_set_name(&mddev->kobj, "%s", "md");
3080 snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");
3081 mddev->kobj.ktype = &md_ktype; 3080 mddev->kobj.ktype = &md_ktype;
3082 if (kobject_register(&mddev->kobj)) 3081 if (kobject_register(&mddev->kobj))
3083 printk(KERN_WARNING "md: cannot register %s/md - name in use\n", 3082 printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 56231d8edc07..18738faecbbc 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -103,10 +103,7 @@ static struct file_operations dvb_device_fops =
103 .open = dvb_device_open, 103 .open = dvb_device_open,
104}; 104};
105 105
106static struct cdev dvb_device_cdev = { 106static struct cdev dvb_device_cdev;
107 .kobj = {.name = "dvb", },
108 .owner = THIS_MODULE,
109};
110 107
111int dvb_generic_open(struct inode *inode, struct file *file) 108int dvb_generic_open(struct inode *inode, struct file *file)
112{ 109{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 7a78d6b34738..2ee3c3049e8f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -905,8 +905,8 @@ struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *mp,
905} 905}
906 906
907 907
908static int pvr2_sysfs_hotplug(struct device *cd,char **envp, 908static int pvr2_sysfs_hotplug(struct device *d,
909 int numenvp,char *buf,int size) 909 struct kobj_uevent_env *env)
910{ 910{
911 /* Even though we don't do anything here, we still need this function 911 /* Even though we don't do anything here, we still need this function
912 because sysfs will still try to call it. */ 912 because sysfs will still try to call it. */
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index d195fb088f4a..8f77949f93dd 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -57,16 +57,11 @@ static int tifm_bus_match(struct device *dev, struct device_driver *drv)
57 return 0; 57 return 0;
58} 58}
59 59
60static int tifm_uevent(struct device *dev, char **envp, int num_envp, 60static int tifm_uevent(struct device *dev, struct kobj_uevent_env *env)
61 char *buffer, int buffer_size)
62{ 61{
63 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev); 62 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
64 int i = 0;
65 int length = 0;
66 63
67 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 64 if (add_uevent_var(env, "TIFM_CARD_TYPE=%s", tifm_media_type_name(sock->type, 1)))
68 "TIFM_CARD_TYPE=%s",
69 tifm_media_type_name(sock->type, 1)))
70 return -ENOMEM; 65 return -ENOMEM;
71 66
72 return 0; 67 return 0;
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 8d6f6014870f..b0c22cad9423 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -58,12 +58,11 @@ static int mmc_bus_match(struct device *dev, struct device_driver *drv)
58} 58}
59 59
60static int 60static int
61mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf, 61mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
62 int buf_size)
63{ 62{
64 struct mmc_card *card = dev_to_mmc_card(dev); 63 struct mmc_card *card = dev_to_mmc_card(dev);
65 const char *type; 64 const char *type;
66 int i = 0, length = 0; 65 int retval = 0;
67 66
68 switch (card->type) { 67 switch (card->type) {
69 case MMC_TYPE_MMC: 68 case MMC_TYPE_MMC:
@@ -80,20 +79,14 @@ mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf,
80 } 79 }
81 80
82 if (type) { 81 if (type) {
83 if (add_uevent_var(envp, num_envp, &i, 82 retval = add_uevent_var(env, "MMC_TYPE=%s", type);
84 buf, buf_size, &length, 83 if (retval)
85 "MMC_TYPE=%s", type)) 84 return retval;
86 return -ENOMEM;
87 } 85 }
88 86
89 if (add_uevent_var(envp, num_envp, &i, 87 retval = add_uevent_var(env, "MMC_NAME=%s", mmc_card_name(card));
90 buf, buf_size, &length,
91 "MMC_NAME=%s", mmc_card_name(card)))
92 return -ENOMEM;
93 88
94 envp[i] = NULL; 89 return retval;
95
96 return 0;
97} 90}
98 91
99static int mmc_bus_probe(struct device *dev) 92static int mmc_bus_probe(struct device *dev)
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 4ac161e1ca12..7d7758f3ad8c 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1183,7 +1183,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1183 pool_count[i], pool_size[i], 1183 pool_count[i], pool_size[i],
1184 pool_active[i]); 1184 pool_active[i]);
1185 kobj->parent = &dev->dev.kobj; 1185 kobj->parent = &dev->dev.kobj;
1186 sprintf(kobj->name, "pool%d", i); 1186 kobject_set_name(kobj, "pool%d", i);
1187 kobj->ktype = &ktype_veth_pool; 1187 kobj->ktype = &ktype_veth_pool;
1188 kobject_register(kobj); 1188 kobject_register(kobj);
1189 } 1189 }
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index 1c97e7dd130b..2b5352a7dffc 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -3,12 +3,9 @@
3#include <linux/module.h> 3#include <linux/module.h>
4#include "pci.h" 4#include "pci.h"
5 5
6int pci_uevent(struct device *dev, char **envp, int num_envp, 6int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
7 char *buffer, int buffer_size)
8{ 7{
9 struct pci_dev *pdev; 8 struct pci_dev *pdev;
10 int i = 0;
11 int length = 0;
12 9
13 if (!dev) 10 if (!dev)
14 return -ENODEV; 11 return -ENODEV;
@@ -17,37 +14,24 @@ int pci_uevent(struct device *dev, char **envp, int num_envp,
17 if (!pdev) 14 if (!pdev)
18 return -ENODEV; 15 return -ENODEV;
19 16
20 if (add_uevent_var(envp, num_envp, &i, 17 if (add_uevent_var(env, "PCI_CLASS=%04X", pdev->class))
21 buffer, buffer_size, &length,
22 "PCI_CLASS=%04X", pdev->class))
23 return -ENOMEM; 18 return -ENOMEM;
24 19
25 if (add_uevent_var(envp, num_envp, &i, 20 if (add_uevent_var(env, "PCI_ID=%04X:%04X", pdev->vendor, pdev->device))
26 buffer, buffer_size, &length,
27 "PCI_ID=%04X:%04X", pdev->vendor, pdev->device))
28 return -ENOMEM; 21 return -ENOMEM;
29 22
30 if (add_uevent_var(envp, num_envp, &i, 23 if (add_uevent_var(env, "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor,
31 buffer, buffer_size, &length,
32 "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor,
33 pdev->subsystem_device)) 24 pdev->subsystem_device))
34 return -ENOMEM; 25 return -ENOMEM;
35 26
36 if (add_uevent_var(envp, num_envp, &i, 27 if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev)))
37 buffer, buffer_size, &length,
38 "PCI_SLOT_NAME=%s", pci_name(pdev)))
39 return -ENOMEM; 28 return -ENOMEM;
40 29
41 if (add_uevent_var(envp, num_envp, &i, 30 if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
42 buffer, buffer_size, &length,
43 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
44 pdev->vendor, pdev->device, 31 pdev->vendor, pdev->device,
45 pdev->subsystem_vendor, pdev->subsystem_device, 32 pdev->subsystem_vendor, pdev->subsystem_device,
46 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 33 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
47 (u8)(pdev->class))) 34 (u8)(pdev->class)))
48 return -ENOMEM; 35 return -ENOMEM;
49
50 envp[i] = NULL;
51
52 return 0; 36 return 0;
53} 37}
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index bd433ef6bfc6..f0eba534f805 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -694,66 +694,6 @@ int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot,
694 if ((slot == NULL) || (info == NULL)) 694 if ((slot == NULL) || (info == NULL))
695 return -ENODEV; 695 return -ENODEV;
696 696
697 /*
698 * check all fields in the info structure, and update timestamps
699 * for the files referring to the fields that have now changed.
700 */
701 if ((has_power_file(slot) == 0) &&
702 (slot->info->power_status != info->power_status)) {
703 retval = sysfs_update_file(&slot->kobj,
704 &hotplug_slot_attr_power.attr);
705 if (retval)
706 return retval;
707 }
708
709 if ((has_attention_file(slot) == 0) &&
710 (slot->info->attention_status != info->attention_status)) {
711 retval = sysfs_update_file(&slot->kobj,
712 &hotplug_slot_attr_attention.attr);
713 if (retval)
714 return retval;
715 }
716
717 if ((has_latch_file(slot) == 0) &&
718 (slot->info->latch_status != info->latch_status)) {
719 retval = sysfs_update_file(&slot->kobj,
720 &hotplug_slot_attr_latch.attr);
721 if (retval)
722 return retval;
723 }
724
725 if ((has_adapter_file(slot) == 0) &&
726 (slot->info->adapter_status != info->adapter_status)) {
727 retval = sysfs_update_file(&slot->kobj,
728 &hotplug_slot_attr_presence.attr);
729 if (retval)
730 return retval;
731 }
732
733 if ((has_address_file(slot) == 0) &&
734 (slot->info->address != info->address)) {
735 retval = sysfs_update_file(&slot->kobj,
736 &hotplug_slot_attr_address.attr);
737 if (retval)
738 return retval;
739 }
740
741 if ((has_max_bus_speed_file(slot) == 0) &&
742 (slot->info->max_bus_speed != info->max_bus_speed)) {
743 retval = sysfs_update_file(&slot->kobj,
744 &hotplug_slot_attr_max_bus_speed.attr);
745 if (retval)
746 return retval;
747 }
748
749 if ((has_cur_bus_speed_file(slot) == 0) &&
750 (slot->info->cur_bus_speed != info->cur_bus_speed)) {
751 retval = sysfs_update_file(&slot->kobj,
752 &hotplug_slot_attr_cur_bus_speed.attr);
753 if (retval)
754 return retval;
755 }
756
757 memcpy (slot->info, info, sizeof (struct hotplug_slot_info)); 697 memcpy (slot->info, info, sizeof (struct hotplug_slot_info));
758 698
759 return 0; 699 return 0;
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index df076064a3e0..a080fedf0332 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -129,17 +129,17 @@ struct kobj_type ktype_dlpar_io = {
129}; 129};
130 130
131struct kset dlpar_io_kset = { 131struct kset dlpar_io_kset = {
132 .kobj = {.name = DLPAR_KOBJ_NAME, 132 .kobj = {.ktype = &ktype_dlpar_io,
133 .ktype = &ktype_dlpar_io,
134 .parent = &pci_hotplug_slots_subsys.kobj}, 133 .parent = &pci_hotplug_slots_subsys.kobj},
135 .ktype = &ktype_dlpar_io, 134 .ktype = &ktype_dlpar_io,
136}; 135};
137 136
138int dlpar_sysfs_init(void) 137int dlpar_sysfs_init(void)
139{ 138{
139 kobject_set_name(&dlpar_io_kset.kobj, DLPAR_KOBJ_NAME);
140 if (kset_register(&dlpar_io_kset)) { 140 if (kset_register(&dlpar_io_kset)) {
141 printk(KERN_ERR "rpadlpar_io: cannot register kset for %s\n", 141 printk(KERN_ERR "rpadlpar_io: cannot register kset for %s\n",
142 dlpar_io_kset.kobj.name); 142 kobject_name(&dlpar_io_kset.kobj));
143 return -EINVAL; 143 return -EINVAL;
144 } 144 }
145 145
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 004bc2487270..f61be3abfdca 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -532,8 +532,7 @@ void pci_dev_put(struct pci_dev *dev)
532} 532}
533 533
534#ifndef CONFIG_HOTPLUG 534#ifndef CONFIG_HOTPLUG
535int pci_uevent(struct device *dev, char **envp, int num_envp, 535int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
536 char *buffer, int buffer_size)
537{ 536{
538 return -ENODEV; 537 return -ENODEV;
539} 538}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4c36e80f6d26..b3a7d5b0f936 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,7 +1,6 @@
1/* Functions internal to the PCI core code */ 1/* Functions internal to the PCI core code */
2 2
3extern int pci_uevent(struct device *dev, char **envp, int num_envp, 3extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
4 char *buffer, int buffer_size);
5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 4extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 5extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
7extern void pci_cleanup_rom(struct pci_dev *dev); 6extern void pci_cleanup_rom(struct pci_dev *dev);
diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
index 568f1877315c..05ca2ed9eb51 100644
--- a/drivers/pci/setup-irq.c
+++ b/drivers/pci/setup-irq.c
@@ -48,7 +48,7 @@ pdev_fixup_irq(struct pci_dev *dev,
48 dev->irq = irq; 48 dev->irq = irq;
49 49
50 pr_debug("PCI: fixup irq: (%s) got %d\n", 50 pr_debug("PCI: fixup irq: (%s) got %d\n",
51 dev->dev.kobj.name, dev->irq); 51 kobject_name(&dev->dev.kobj), dev->irq);
52 52
53 /* Always tell the device, so the driver knows what is 53 /* Always tell the device, so the driver knows what is
54 the real IRQ to use; the device does not use it. */ 54 the real IRQ to use; the device does not use it. */
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f8b13f0270d7..a0aca46ce877 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -907,18 +907,14 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
907EXPORT_SYMBOL(pcmcia_insert_card); 907EXPORT_SYMBOL(pcmcia_insert_card);
908 908
909 909
910static int pcmcia_socket_uevent(struct device *dev, char **envp, 910static int pcmcia_socket_uevent(struct device *dev,
911 int num_envp, char *buffer, int buffer_size) 911 struct kobj_uevent_env *env)
912{ 912{
913 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); 913 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
914 int i = 0, length = 0;
915 914
916 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 915 if (add_uevent_var(env, "SOCKET_NO=%u", s->sock))
917 &length, "SOCKET_NO=%u", s->sock))
918 return -ENOMEM; 916 return -ENOMEM;
919 917
920 envp[i] = NULL;
921
922 return 0; 918 return 0;
923} 919}
924 920
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index a99607142fc8..55baa1f0fcbb 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1064,11 +1064,10 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
1064 1064
1065#ifdef CONFIG_HOTPLUG 1065#ifdef CONFIG_HOTPLUG
1066 1066
1067static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 1067static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
1068 char *buffer, int buffer_size)
1069{ 1068{
1070 struct pcmcia_device *p_dev; 1069 struct pcmcia_device *p_dev;
1071 int i, length = 0; 1070 int i;
1072 u32 hash[4] = { 0, 0, 0, 0}; 1071 u32 hash[4] = { 0, 0, 0, 0};
1073 1072
1074 if (!dev) 1073 if (!dev)
@@ -1083,23 +1082,13 @@ static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
1083 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i])); 1082 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i]));
1084 } 1083 }
1085 1084
1086 i = 0; 1085 if (add_uevent_var(env, "SOCKET_NO=%u", p_dev->socket->sock))
1087
1088 if (add_uevent_var(envp, num_envp, &i,
1089 buffer, buffer_size, &length,
1090 "SOCKET_NO=%u",
1091 p_dev->socket->sock))
1092 return -ENOMEM; 1086 return -ENOMEM;
1093 1087
1094 if (add_uevent_var(envp, num_envp, &i, 1088 if (add_uevent_var(env, "DEVICE_NO=%02X", p_dev->device_no))
1095 buffer, buffer_size, &length,
1096 "DEVICE_NO=%02X",
1097 p_dev->device_no))
1098 return -ENOMEM; 1089 return -ENOMEM;
1099 1090
1100 if (add_uevent_var(envp, num_envp, &i, 1091 if (add_uevent_var(env, "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
1101 buffer, buffer_size, &length,
1102 "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
1103 "pa%08Xpb%08Xpc%08Xpd%08X", 1092 "pa%08Xpb%08Xpc%08Xpd%08X",
1104 p_dev->has_manf_id ? p_dev->manf_id : 0, 1093 p_dev->has_manf_id ? p_dev->manf_id : 0,
1105 p_dev->has_card_id ? p_dev->card_id : 0, 1094 p_dev->has_card_id ? p_dev->card_id : 0,
@@ -1112,15 +1101,12 @@ static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
1112 hash[3])) 1101 hash[3]))
1113 return -ENOMEM; 1102 return -ENOMEM;
1114 1103
1115 envp[i] = NULL;
1116
1117 return 0; 1104 return 0;
1118} 1105}
1119 1106
1120#else 1107#else
1121 1108
1122static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 1109static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
1123 char *buffer, int buffer_size)
1124{ 1110{
1125 return -ENODEV; 1111 return -ENODEV;
1126} 1112}
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index 383107ba4bd3..f6722ba0dd1e 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -175,7 +175,6 @@ static int __init mst_pcmcia_init(void)
175 if (!mst_pcmcia_device) 175 if (!mst_pcmcia_device)
176 return -ENOMEM; 176 return -ENOMEM;
177 177
178 mst_pcmcia_device->dev.uevent_suppress = 0;
179 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 178 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops;
180 179
181 ret = platform_device_add(mst_pcmcia_device); 180 ret = platform_device_add(mst_pcmcia_device);
@@ -195,3 +194,4 @@ fs_initcall(mst_pcmcia_init);
195module_exit(mst_pcmcia_exit); 194module_exit(mst_pcmcia_exit);
196 195
197MODULE_LICENSE("GPL"); 196MODULE_LICENSE("GPL");
197MODULE_ALIAS("platform:pxa2xx-pcmcia");
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index a2daa3f531b2..d5c33bd78d68 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -261,7 +261,6 @@ static int __init sharpsl_pcmcia_init(void)
261 if (!sharpsl_pcmcia_device) 261 if (!sharpsl_pcmcia_device)
262 return -ENOMEM; 262 return -ENOMEM;
263 263
264 sharpsl_pcmcia_device->dev.uevent_suppress = 0;
265 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 264 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
266 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev; 265 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
267 266
@@ -284,3 +283,4 @@ module_exit(sharpsl_pcmcia_exit);
284 283
285MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support"); 284MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support");
286MODULE_LICENSE("GPL"); 285MODULE_LICENSE("GPL");
286MODULE_ALIAS("platform:pxa2xx-pcmcia");
diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
index a9880d468ee4..f38ba482be75 100644
--- a/drivers/power/power_supply.h
+++ b/drivers/power/power_supply.h
@@ -14,8 +14,7 @@
14 14
15extern int power_supply_create_attrs(struct power_supply *psy); 15extern int power_supply_create_attrs(struct power_supply *psy);
16extern void power_supply_remove_attrs(struct power_supply *psy); 16extern void power_supply_remove_attrs(struct power_supply *psy);
17extern int power_supply_uevent(struct device *dev, char **envp, int num_envp, 17extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
18 char *buffer, int buffer_size);
19 18
20#else 19#else
21 20
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index de3155b21285..249f61bae639 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -195,11 +195,10 @@ static char *kstruprdup(const char *str, gfp_t gfp)
195 return ret; 195 return ret;
196} 196}
197 197
198int power_supply_uevent(struct device *dev, char **envp, int num_envp, 198int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env)
199 char *buffer, int buffer_size)
200{ 199{
201 struct power_supply *psy = dev_get_drvdata(dev); 200 struct power_supply *psy = dev_get_drvdata(dev);
202 int i = 0, length = 0, ret = 0, j; 201 int ret = 0, j;
203 char *prop_buf; 202 char *prop_buf;
204 char *attrname; 203 char *attrname;
205 204
@@ -212,8 +211,7 @@ int power_supply_uevent(struct device *dev, char **envp, int num_envp,
212 211
213 dev_dbg(dev, "POWER_SUPPLY_NAME=%s\n", psy->name); 212 dev_dbg(dev, "POWER_SUPPLY_NAME=%s\n", psy->name);
214 213
215 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 214 ret = add_uevent_var(env, "POWER_SUPPLY_NAME=%s", psy->name);
216 &length, "POWER_SUPPLY_NAME=%s", psy->name);
217 if (ret) 215 if (ret)
218 return ret; 216 return ret;
219 217
@@ -243,9 +241,7 @@ int power_supply_uevent(struct device *dev, char **envp, int num_envp,
243 241
244 dev_dbg(dev, "Static prop %s=%s\n", attrname, prop_buf); 242 dev_dbg(dev, "Static prop %s=%s\n", attrname, prop_buf);
245 243
246 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 244 ret = add_uevent_var(env, "POWER_SUPPLY_%s=%s", attrname, prop_buf);
247 &length, "POWER_SUPPLY_%s=%s",
248 attrname, prop_buf);
249 kfree(attrname); 245 kfree(attrname);
250 if (ret) 246 if (ret)
251 goto out; 247 goto out;
@@ -282,14 +278,11 @@ int power_supply_uevent(struct device *dev, char **envp, int num_envp,
282 278
283 dev_dbg(dev, "prop %s=%s\n", attrname, prop_buf); 279 dev_dbg(dev, "prop %s=%s\n", attrname, prop_buf);
284 280
285 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 281 ret = add_uevent_var(env, "POWER_SUPPLY_%s=%s", attrname, prop_buf);
286 &length, "POWER_SUPPLY_%s=%s",
287 attrname, prop_buf);
288 kfree(attrname); 282 kfree(attrname);
289 if (ret) 283 if (ret)
290 goto out; 284 goto out;
291 } 285 }
292 envp[i] = NULL;
293 286
294out: 287out:
295 free_page((unsigned long)prop_buf); 288 free_page((unsigned long)prop_buf);
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 9c3b9ea1e66f..5baa517c3b66 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -44,8 +44,7 @@ ccwgroup_bus_match (struct device * dev, struct device_driver * drv)
44 return 0; 44 return 0;
45} 45}
46static int 46static int
47ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer, 47ccwgroup_uevent (struct device *dev, struct kobj_uevent_env *env)
48 int buffer_size)
49{ 48{
50 /* TODO */ 49 /* TODO */
51 return 0; 50 return 0;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 39f02b48e4c7..7ee57f084a89 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -79,49 +79,38 @@ static int snprint_alias(char *buf, size_t size,
79 79
80/* Set up environment variables for ccw device uevent. Return 0 on success, 80/* Set up environment variables for ccw device uevent. Return 0 on success,
81 * non-zero otherwise. */ 81 * non-zero otherwise. */
82static int ccw_uevent(struct device *dev, char **envp, int num_envp, 82static int ccw_uevent(struct device *dev, struct kobj_uevent_env *env)
83 char *buffer, int buffer_size)
84{ 83{
85 struct ccw_device *cdev = to_ccwdev(dev); 84 struct ccw_device *cdev = to_ccwdev(dev);
86 struct ccw_device_id *id = &(cdev->id); 85 struct ccw_device_id *id = &(cdev->id);
87 int i = 0;
88 int len = 0;
89 int ret; 86 int ret;
90 char modalias_buf[30]; 87 char modalias_buf[30];
91 88
92 /* CU_TYPE= */ 89 /* CU_TYPE= */
93 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 90 ret = add_uevent_var(env, "CU_TYPE=%04X", id->cu_type);
94 "CU_TYPE=%04X", id->cu_type);
95 if (ret) 91 if (ret)
96 return ret; 92 return ret;
97 93
98 /* CU_MODEL= */ 94 /* CU_MODEL= */
99 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 95 ret = add_uevent_var(env, "CU_MODEL=%02X", id->cu_model);
100 "CU_MODEL=%02X", id->cu_model);
101 if (ret) 96 if (ret)
102 return ret; 97 return ret;
103 98
104 /* The next two can be zero, that's ok for us */ 99 /* The next two can be zero, that's ok for us */
105 /* DEV_TYPE= */ 100 /* DEV_TYPE= */
106 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 101 ret = add_uevent_var(env, "DEV_TYPE=%04X", id->dev_type);
107 "DEV_TYPE=%04X", id->dev_type);
108 if (ret) 102 if (ret)
109 return ret; 103 return ret;
110 104
111 /* DEV_MODEL= */ 105 /* DEV_MODEL= */
112 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 106 ret = add_uevent_var(env, "DEV_MODEL=%02X", id->dev_model);
113 "DEV_MODEL=%02X", id->dev_model);
114 if (ret) 107 if (ret)
115 return ret; 108 return ret;
116 109
117 /* MODALIAS= */ 110 /* MODALIAS= */
118 snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); 111 snprint_alias(modalias_buf, sizeof(modalias_buf), id, "");
119 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 112 ret = add_uevent_var(env, "MODALIAS=%s", modalias_buf);
120 "MODALIAS=%s", modalias_buf); 113 return ret;
121 if (ret)
122 return ret;
123 envp[i] = NULL;
124 return 0;
125} 114}
126 115
127struct bus_type ccw_bus_type; 116struct bus_type ccw_bus_type;
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index d334b0f7a1ec..67aaff3e668d 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -458,28 +458,22 @@ static int ap_bus_match(struct device *dev, struct device_driver *drv)
458 * uevent function for AP devices. It sets up a single environment 458 * uevent function for AP devices. It sets up a single environment
459 * variable DEV_TYPE which contains the hardware device type. 459 * variable DEV_TYPE which contains the hardware device type.
460 */ 460 */
461static int ap_uevent (struct device *dev, char **envp, int num_envp, 461static int ap_uevent (struct device *dev, struct kobj_uevent_env *env)
462 char *buffer, int buffer_size)
463{ 462{
464 struct ap_device *ap_dev = to_ap_dev(dev); 463 struct ap_device *ap_dev = to_ap_dev(dev);
465 int retval = 0, length = 0, i = 0; 464 int retval = 0;
466 465
467 if (!ap_dev) 466 if (!ap_dev)
468 return -ENODEV; 467 return -ENODEV;
469 468
470 /* Set up DEV_TYPE environment variable. */ 469 /* Set up DEV_TYPE environment variable. */
471 retval = add_uevent_var(envp, num_envp, &i, 470 retval = add_uevent_var(env, "DEV_TYPE=%04X", ap_dev->device_type);
472 buffer, buffer_size, &length,
473 "DEV_TYPE=%04X", ap_dev->device_type);
474 if (retval) 471 if (retval)
475 return retval; 472 return retval;
476 473
477 /* Add MODALIAS= */ 474 /* Add MODALIAS= */
478 retval = add_uevent_var(envp, num_envp, &i, 475 retval = add_uevent_var(env, "MODALIAS=ap:t%02X", ap_dev->device_type);
479 buffer, buffer_size, &length,
480 "MODALIAS=ap:t%02X", ap_dev->device_type);
481 476
482 envp[i] = NULL;
483 return retval; 477 return retval;
484} 478}
485 479
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 34cdce6738a6..ede9986d349a 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -277,16 +277,11 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
277 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 277 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
278} 278}
279 279
280static int scsi_bus_uevent(struct device *dev, char **envp, int num_envp, 280static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
281 char *buffer, int buffer_size)
282{ 281{
283 struct scsi_device *sdev = to_scsi_device(dev); 282 struct scsi_device *sdev = to_scsi_device(dev);
284 int i = 0;
285 int length = 0;
286 283
287 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 284 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
288 "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
289 envp[i] = NULL;
290 return 0; 285 return 0;
291} 286}
292 287
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index e84d21597943..bcb8dd5fb0b4 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -67,14 +67,11 @@ static int spi_match_device(struct device *dev, struct device_driver *drv)
67 return strncmp(spi->modalias, drv->name, BUS_ID_SIZE) == 0; 67 return strncmp(spi->modalias, drv->name, BUS_ID_SIZE) == 0;
68} 68}
69 69
70static int spi_uevent(struct device *dev, char **envp, int num_envp, 70static int spi_uevent(struct device *dev, struct kobj_uevent_env *env)
71 char *buffer, int buffer_size)
72{ 71{
73 const struct spi_device *spi = to_spi_device(dev); 72 const struct spi_device *spi = to_spi_device(dev);
74 73
75 envp[0] = buffer; 74 add_uevent_var(env, "MODALIAS=%s", spi->modalias);
76 snprintf(buffer, buffer_size, "MODALIAS=%s", spi->modalias);
77 envp[1] = NULL;
78 return 0; 75 return 0;
79} 76}
80 77
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index e5ad76b4a738..f013b4012c9a 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1591,6 +1591,7 @@ static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wai
1591} 1591}
1592 1592
1593const struct file_operations usbdev_file_operations = { 1593const struct file_operations usbdev_file_operations = {
1594 .owner = THIS_MODULE,
1594 .llseek = usbdev_lseek, 1595 .llseek = usbdev_lseek,
1595 .read = usbdev_read, 1596 .read = usbdev_read,
1596 .poll = usbdev_poll, 1597 .poll = usbdev_poll,
@@ -1640,10 +1641,7 @@ static struct notifier_block usbdev_nb = {
1640}; 1641};
1641#endif 1642#endif
1642 1643
1643static struct cdev usb_device_cdev = { 1644static struct cdev usb_device_cdev;
1644 .kobj = {.name = "usb_device", },
1645 .owner = THIS_MODULE,
1646};
1647 1645
1648int __init usb_devio_init(void) 1646int __init usb_devio_init(void)
1649{ 1647{
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index c27bc080d84e..8586817698ad 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -581,12 +581,9 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
581} 581}
582 582
583#ifdef CONFIG_HOTPLUG 583#ifdef CONFIG_HOTPLUG
584static int usb_uevent(struct device *dev, char **envp, int num_envp, 584static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
585 char *buffer, int buffer_size)
586{ 585{
587 struct usb_device *usb_dev; 586 struct usb_device *usb_dev;
588 int i = 0;
589 int length = 0;
590 587
591 if (!dev) 588 if (!dev)
592 return -ENODEV; 589 return -ENODEV;
@@ -615,51 +612,39 @@ static int usb_uevent(struct device *dev, char **envp, int num_envp,
615 * all the device descriptors we don't tell them about. Or 612 * all the device descriptors we don't tell them about. Or
616 * act as usermode drivers. 613 * act as usermode drivers.
617 */ 614 */
618 if (add_uevent_var(envp, num_envp, &i, 615 if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d",
619 buffer, buffer_size, &length,
620 "DEVICE=/proc/bus/usb/%03d/%03d",
621 usb_dev->bus->busnum, usb_dev->devnum)) 616 usb_dev->bus->busnum, usb_dev->devnum))
622 return -ENOMEM; 617 return -ENOMEM;
623#endif 618#endif
624 619
625 /* per-device configurations are common */ 620 /* per-device configurations are common */
626 if (add_uevent_var(envp, num_envp, &i, 621 if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
627 buffer, buffer_size, &length,
628 "PRODUCT=%x/%x/%x",
629 le16_to_cpu(usb_dev->descriptor.idVendor), 622 le16_to_cpu(usb_dev->descriptor.idVendor),
630 le16_to_cpu(usb_dev->descriptor.idProduct), 623 le16_to_cpu(usb_dev->descriptor.idProduct),
631 le16_to_cpu(usb_dev->descriptor.bcdDevice))) 624 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
632 return -ENOMEM; 625 return -ENOMEM;
633 626
634 /* class-based driver binding models */ 627 /* class-based driver binding models */
635 if (add_uevent_var(envp, num_envp, &i, 628 if (add_uevent_var(env, "TYPE=%d/%d/%d",
636 buffer, buffer_size, &length,
637 "TYPE=%d/%d/%d",
638 usb_dev->descriptor.bDeviceClass, 629 usb_dev->descriptor.bDeviceClass,
639 usb_dev->descriptor.bDeviceSubClass, 630 usb_dev->descriptor.bDeviceSubClass,
640 usb_dev->descriptor.bDeviceProtocol)) 631 usb_dev->descriptor.bDeviceProtocol))
641 return -ENOMEM; 632 return -ENOMEM;
642 633
643 if (add_uevent_var(envp, num_envp, &i, 634 if (add_uevent_var(env, "BUSNUM=%03d",
644 buffer, buffer_size, &length,
645 "BUSNUM=%03d",
646 usb_dev->bus->busnum)) 635 usb_dev->bus->busnum))
647 return -ENOMEM; 636 return -ENOMEM;
648 637
649 if (add_uevent_var(envp, num_envp, &i, 638 if (add_uevent_var(env, "DEVNUM=%03d",
650 buffer, buffer_size, &length,
651 "DEVNUM=%03d",
652 usb_dev->devnum)) 639 usb_dev->devnum))
653 return -ENOMEM; 640 return -ENOMEM;
654 641
655 envp[i] = NULL;
656 return 0; 642 return 0;
657} 643}
658 644
659#else 645#else
660 646
661static int usb_uevent(struct device *dev, char **envp, 647static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
662 int num_envp, char *buffer, int buffer_size)
663{ 648{
664 return -ENODEV; 649 return -ENODEV;
665} 650}
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 98fcddba6908..c021af390372 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1344,14 +1344,11 @@ static void usb_release_interface(struct device *dev)
1344} 1344}
1345 1345
1346#ifdef CONFIG_HOTPLUG 1346#ifdef CONFIG_HOTPLUG
1347static int usb_if_uevent(struct device *dev, char **envp, int num_envp, 1347static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1348 char *buffer, int buffer_size)
1349{ 1348{
1350 struct usb_device *usb_dev; 1349 struct usb_device *usb_dev;
1351 struct usb_interface *intf; 1350 struct usb_interface *intf;
1352 struct usb_host_interface *alt; 1351 struct usb_host_interface *alt;
1353 int i = 0;
1354 int length = 0;
1355 1352
1356 if (!dev) 1353 if (!dev)
1357 return -ENODEV; 1354 return -ENODEV;
@@ -1364,39 +1361,30 @@ static int usb_if_uevent(struct device *dev, char **envp, int num_envp,
1364 alt = intf->cur_altsetting; 1361 alt = intf->cur_altsetting;
1365 1362
1366#ifdef CONFIG_USB_DEVICEFS 1363#ifdef CONFIG_USB_DEVICEFS
1367 if (add_uevent_var(envp, num_envp, &i, 1364 if (add_uevent_var(env, "DEVICE=/proc/bus/usb/%03d/%03d",
1368 buffer, buffer_size, &length,
1369 "DEVICE=/proc/bus/usb/%03d/%03d",
1370 usb_dev->bus->busnum, usb_dev->devnum)) 1365 usb_dev->bus->busnum, usb_dev->devnum))
1371 return -ENOMEM; 1366 return -ENOMEM;
1372#endif 1367#endif
1373 1368
1374 if (add_uevent_var(envp, num_envp, &i, 1369 if (add_uevent_var(env, "PRODUCT=%x/%x/%x",
1375 buffer, buffer_size, &length,
1376 "PRODUCT=%x/%x/%x",
1377 le16_to_cpu(usb_dev->descriptor.idVendor), 1370 le16_to_cpu(usb_dev->descriptor.idVendor),
1378 le16_to_cpu(usb_dev->descriptor.idProduct), 1371 le16_to_cpu(usb_dev->descriptor.idProduct),
1379 le16_to_cpu(usb_dev->descriptor.bcdDevice))) 1372 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
1380 return -ENOMEM; 1373 return -ENOMEM;
1381 1374
1382 if (add_uevent_var(envp, num_envp, &i, 1375 if (add_uevent_var(env, "TYPE=%d/%d/%d",
1383 buffer, buffer_size, &length,
1384 "TYPE=%d/%d/%d",
1385 usb_dev->descriptor.bDeviceClass, 1376 usb_dev->descriptor.bDeviceClass,
1386 usb_dev->descriptor.bDeviceSubClass, 1377 usb_dev->descriptor.bDeviceSubClass,
1387 usb_dev->descriptor.bDeviceProtocol)) 1378 usb_dev->descriptor.bDeviceProtocol))
1388 return -ENOMEM; 1379 return -ENOMEM;
1389 1380
1390 if (add_uevent_var(envp, num_envp, &i, 1381 if (add_uevent_var(env, "INTERFACE=%d/%d/%d",
1391 buffer, buffer_size, &length,
1392 "INTERFACE=%d/%d/%d",
1393 alt->desc.bInterfaceClass, 1382 alt->desc.bInterfaceClass,
1394 alt->desc.bInterfaceSubClass, 1383 alt->desc.bInterfaceSubClass,
1395 alt->desc.bInterfaceProtocol)) 1384 alt->desc.bInterfaceProtocol))
1396 return -ENOMEM; 1385 return -ENOMEM;
1397 1386
1398 if (add_uevent_var(envp, num_envp, &i, 1387 if (add_uevent_var(env,
1399 buffer, buffer_size, &length,
1400 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 1388 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
1401 le16_to_cpu(usb_dev->descriptor.idVendor), 1389 le16_to_cpu(usb_dev->descriptor.idVendor),
1402 le16_to_cpu(usb_dev->descriptor.idProduct), 1390 le16_to_cpu(usb_dev->descriptor.idProduct),
@@ -1409,14 +1397,12 @@ static int usb_if_uevent(struct device *dev, char **envp, int num_envp,
1409 alt->desc.bInterfaceProtocol)) 1397 alt->desc.bInterfaceProtocol))
1410 return -ENOMEM; 1398 return -ENOMEM;
1411 1399
1412 envp[i] = NULL;
1413 return 0; 1400 return 0;
1414} 1401}
1415 1402
1416#else 1403#else
1417 1404
1418static int usb_if_uevent(struct device *dev, char **envp, 1405static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
1419 int num_envp, char *buffer, int buffer_size)
1420{ 1406{
1421 return -ENODEV; 1407 return -ENODEV;
1422} 1408}
diff --git a/drivers/video/output.c b/drivers/video/output.c
index 1473f2c892d2..f2df5519c9c4 100644
--- a/drivers/video/output.c
+++ b/drivers/video/output.c
@@ -31,7 +31,8 @@ MODULE_DESCRIPTION("Display Output Switcher Lowlevel Control Abstraction");
31MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
32MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>"); 32MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>");
33 33
34static ssize_t video_output_show_state(struct class_device *dev,char *buf) 34static ssize_t video_output_show_state(struct device *dev,
35 struct device_attribute *attr, char *buf)
35{ 36{
36 ssize_t ret_size = 0; 37 ssize_t ret_size = 0;
37 struct output_device *od = to_output_device(dev); 38 struct output_device *od = to_output_device(dev);
@@ -40,8 +41,9 @@ static ssize_t video_output_show_state(struct class_device *dev,char *buf)
40 return ret_size; 41 return ret_size;
41} 42}
42 43
43static ssize_t video_output_store_state(struct class_device *dev, 44static ssize_t video_output_store_state(struct device *dev,
44 const char *buf,size_t count) 45 struct device_attribute *attr,
46 const char *buf,size_t count)
45{ 47{
46 char *endp; 48 char *endp;
47 struct output_device *od = to_output_device(dev); 49 struct output_device *od = to_output_device(dev);
@@ -60,21 +62,22 @@ static ssize_t video_output_store_state(struct class_device *dev,
60 return count; 62 return count;
61} 63}
62 64
63static void video_output_class_release(struct class_device *dev) 65static void video_output_release(struct device *dev)
64{ 66{
65 struct output_device *od = to_output_device(dev); 67 struct output_device *od = to_output_device(dev);
66 kfree(od); 68 kfree(od);
67} 69}
68 70
69static struct class_device_attribute video_output_attributes[] = { 71static struct device_attribute video_output_attributes[] = {
70 __ATTR(state, 0644, video_output_show_state, video_output_store_state), 72 __ATTR(state, 0644, video_output_show_state, video_output_store_state),
71 __ATTR_NULL, 73 __ATTR_NULL,
72}; 74};
73 75
76
74static struct class video_output_class = { 77static struct class video_output_class = {
75 .name = "video_output", 78 .name = "video_output",
76 .release = video_output_class_release, 79 .dev_release = video_output_release,
77 .class_dev_attrs = video_output_attributes, 80 .dev_attrs = video_output_attributes,
78}; 81};
79 82
80struct output_device *video_output_register(const char *name, 83struct output_device *video_output_register(const char *name,
@@ -91,11 +94,11 @@ struct output_device *video_output_register(const char *name,
91 goto error_return; 94 goto error_return;
92 } 95 }
93 new_dev->props = op; 96 new_dev->props = op;
94 new_dev->class_dev.class = &video_output_class; 97 new_dev->dev.class = &video_output_class;
95 new_dev->class_dev.dev = dev; 98 new_dev->dev.parent = dev;
96 strlcpy(new_dev->class_dev.class_id,name,KOBJ_NAME_LEN); 99 strlcpy(new_dev->dev.bus_id,name, BUS_ID_SIZE);
97 class_set_devdata(&new_dev->class_dev,devdata); 100 dev_set_drvdata(&new_dev->dev, devdata);
98 ret_code = class_device_register(&new_dev->class_dev); 101 ret_code = device_register(&new_dev->dev);
99 if (ret_code) { 102 if (ret_code) {
100 kfree(new_dev); 103 kfree(new_dev);
101 goto error_return; 104 goto error_return;
@@ -111,7 +114,7 @@ void video_output_unregister(struct output_device *dev)
111{ 114{
112 if (!dev) 115 if (!dev)
113 return; 116 return;
114 class_device_unregister(&dev->class_dev); 117 device_unregister(&dev->dev);
115} 118}
116EXPORT_SYMBOL(video_output_unregister); 119EXPORT_SYMBOL(video_output_unregister);
117 120
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index a593f900eff4..070217322c9f 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -197,7 +197,7 @@ static struct w1_family w1_default_family = {
197 .fops = &w1_default_fops, 197 .fops = &w1_default_fops,
198}; 198};
199 199
200static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); 200static int w1_uevent(struct device *dev, struct kobj_uevent_env *env);
201 201
202static struct bus_type w1_bus_type = { 202static struct bus_type w1_bus_type = {
203 .name = "w1", 203 .name = "w1",
@@ -396,13 +396,12 @@ static void w1_destroy_master_attributes(struct w1_master *master)
396} 396}
397 397
398#ifdef CONFIG_HOTPLUG 398#ifdef CONFIG_HOTPLUG
399static int w1_uevent(struct device *dev, char **envp, int num_envp, 399static int w1_uevent(struct device *dev, struct kobj_uevent_env *env)
400 char *buffer, int buffer_size)
401{ 400{
402 struct w1_master *md = NULL; 401 struct w1_master *md = NULL;
403 struct w1_slave *sl = NULL; 402 struct w1_slave *sl = NULL;
404 char *event_owner, *name; 403 char *event_owner, *name;
405 int err, cur_index=0, cur_len=0; 404 int err;
406 405
407 if (dev->driver == &w1_master_driver) { 406 if (dev->driver == &w1_master_driver) {
408 md = container_of(dev, struct w1_master, dev); 407 md = container_of(dev, struct w1_master, dev);
@@ -423,23 +422,19 @@ static int w1_uevent(struct device *dev, char **envp, int num_envp,
423 if (dev->driver != &w1_slave_driver || !sl) 422 if (dev->driver != &w1_slave_driver || !sl)
424 return 0; 423 return 0;
425 424
426 err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, 425 err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family);
427 &cur_len, "W1_FID=%02X", sl->reg_num.family);
428 if (err) 426 if (err)
429 return err; 427 return err;
430 428
431 err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, 429 err = add_uevent_var(env, "W1_SLAVE_ID=%024LX",
432 &cur_len, "W1_SLAVE_ID=%024LX", 430 (unsigned long long)sl->reg_num.id);
433 (unsigned long long)sl->reg_num.id);
434 envp[cur_index] = NULL;
435 if (err) 431 if (err)
436 return err; 432 return err;
437 433
438 return 0; 434 return 0;
439}; 435};
440#else 436#else
441static int w1_uevent(struct device *dev, char **envp, int num_envp, 437static int w1_uevent(struct device *dev, struct kobj_uevent_env *env)
442 char *buffer, int buffer_size)
443{ 438{
444 return 0; 439 return 0;
445} 440}