aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/fan.c10
-rw-r--r--drivers/acpi/glue.c6
-rw-r--r--drivers/acpi/processor_core.c5
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/thermal.c4
-rw-r--r--drivers/acpi/video.c5
-rw-r--r--drivers/base/Kconfig3
-rw-r--r--drivers/base/base.h27
-rw-r--r--drivers/base/class.c153
-rw-r--r--drivers/base/core.c196
-rw-r--r--drivers/base/cpu.c10
-rw-r--r--drivers/base/memory.c12
-rw-r--r--drivers/base/node.c15
-rw-r--r--drivers/base/power/trace.c2
-rw-r--r--drivers/base/sys.c64
-rw-r--r--drivers/base/topology.c17
-rw-r--r--drivers/block/aoe/aoechr.c5
-rw-r--r--drivers/block/paride/pg.c5
-rw-r--r--drivers/block/paride/pt.c10
-rw-r--r--drivers/block/pktcdvd.c4
-rw-r--r--drivers/char/dsp56k.c3
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c2
-rw-r--r--drivers/char/istallion.c5
-rw-r--r--drivers/char/lp.c3
-rw-r--r--drivers/char/mem.c6
-rw-r--r--drivers/char/misc.c4
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c3
-rw-r--r--drivers/char/ppdev.c5
-rw-r--r--drivers/char/raw.c7
-rw-r--r--drivers/char/snsc.c3
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/tty_io.c12
-rw-r--r--drivers/char/vc_screen.c12
-rw-r--r--drivers/char/viotape.c8
-rw-r--r--drivers/char/vt.c14
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c5
-rw-r--r--drivers/cpuidle/sysfs.c10
-rw-r--r--drivers/dca/dca-sysfs.c8
-rw-r--r--drivers/eisa/Makefile2
-rw-r--r--drivers/eisa/eisa-bus.c4
-rw-r--r--drivers/hid/hidraw.c5
-rw-r--r--drivers/hwmon/hwmon.c3
-rw-r--r--drivers/i2c/i2c-core.c6
-rw-r--r--drivers/i2c/i2c-dev.c6
-rw-r--r--drivers/ide/ide-tape.c10
-rw-r--r--drivers/ieee1394/dv1394.c7
-rw-r--r--drivers/ieee1394/nodemgr.c23
-rw-r--r--drivers/ieee1394/raw1394.c4
-rw-r--r--drivers/ieee1394/video1394.c6
-rw-r--r--drivers/infiniband/core/cm.c72
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c2
-rw-r--r--drivers/isdn/capi/capi.c3
-rw-r--r--drivers/macintosh/adb.c3
-rw-r--r--drivers/mca/mca-bus.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c4
-rw-r--r--drivers/memstick/host/jmb38x_ms.c4
-rw-r--r--drivers/message/fusion/mptbase.c3
-rw-r--r--drivers/message/fusion/mptbase.h4
-rw-r--r--drivers/message/fusion/mptfc.c4
-rw-r--r--drivers/misc/Kconfig13
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/hpilo.c768
-rw-r--r--drivers/misc/hpilo.h189
-rw-r--r--drivers/misc/phantom.c5
-rw-r--r--drivers/mtd/devices/block2mtd.c8
-rw-r--r--drivers/mtd/mtdchar.c9
-rw-r--r--drivers/net/3c59x.c2
-rw-r--r--drivers/net/arm/at91_ether.c2
-rw-r--r--drivers/net/arm/ep93xx_eth.c2
-rw-r--r--drivers/net/arm/etherh.c6
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/wan/cosa.c6
-rw-r--r--drivers/pci/hotplug/acpiphp.h4
-rw-r--r--drivers/power/apm_power.c2
-rw-r--r--drivers/power/power_supply_core.c4
-rw-r--r--drivers/rtc/interface.c2
-rw-r--r--drivers/s390/char/raw3270.c14
-rw-r--r--drivers/s390/char/tape_class.c7
-rw-r--r--drivers/s390/char/vmur.c5
-rw-r--r--drivers/sbus/sbus.c6
-rw-r--r--drivers/scsi/dpt_i2o.c4
-rw-r--r--drivers/scsi/hosts.c7
-rw-r--r--drivers/scsi/scsi_transport_fc.c9
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c8
-rw-r--r--drivers/spi/spi.c2
-rw-r--r--drivers/spi/spidev.c4
-rw-r--r--drivers/uio/Kconfig10
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c26
-rw-r--r--drivers/uio/uio_pdrv.c118
-rw-r--r--drivers/usb/core/devio.c11
-rw-r--r--drivers/usb/core/file.c5
-rw-r--r--drivers/usb/gadget/printer.c4
-rw-r--r--drivers/usb/mon/mon_bin.c5
-rw-r--r--drivers/video/aty/aty128fb.c2
-rw-r--r--drivers/video/aty/radeonfb.h2
-rw-r--r--drivers/video/console/fbcon.c3
-rw-r--r--drivers/video/fbmem.c5
-rw-r--r--drivers/xen/balloon.c1
101 files changed, 1746 insertions, 399 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 55c17afbe669..2655bc1b4eeb 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -263,22 +263,22 @@ static int acpi_fan_add(struct acpi_device *device)
263 goto end; 263 goto end;
264 } 264 }
265 265
266 printk(KERN_INFO PREFIX 266 dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
267 "%s is registered as cooling_device%d\n",
268 device->dev.bus_id, cdev->id);
269 267
270 acpi_driver_data(device) = cdev; 268 acpi_driver_data(device) = cdev;
271 result = sysfs_create_link(&device->dev.kobj, 269 result = sysfs_create_link(&device->dev.kobj,
272 &cdev->device.kobj, 270 &cdev->device.kobj,
273 "thermal_cooling"); 271 "thermal_cooling");
274 if (result) 272 if (result)
275 printk(KERN_ERR PREFIX "Create sysfs link\n"); 273 dev_err(&device->dev, "Failed to create sysfs link "
274 "'thermal_cooling'\n");
276 275
277 result = sysfs_create_link(&cdev->device.kobj, 276 result = sysfs_create_link(&cdev->device.kobj,
278 &device->dev.kobj, 277 &device->dev.kobj,
279 "device"); 278 "device");
280 if (result) 279 if (result)
281 printk(KERN_ERR PREFIX "Create sysfs link\n"); 280 dev_err(&device->dev, "Failed to create sysfs link "
281 "'device'\n");
282 282
283 result = acpi_fan_add_fs(device); 283 result = acpi_fan_add_fs(device);
284 if (result) 284 if (result)
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 2f173e83f8a7..084109507c9f 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -146,8 +146,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
146 acpi_status status; 146 acpi_status status;
147 147
148 if (dev->archdata.acpi_handle) { 148 if (dev->archdata.acpi_handle) {
149 printk(KERN_WARNING PREFIX 149 dev_warn(dev, "Drivers changed 'acpi_handle'\n");
150 "Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
151 return -EINVAL; 150 return -EINVAL;
152 } 151 }
153 get_device(dev); 152 get_device(dev);
@@ -195,8 +194,7 @@ static int acpi_unbind_one(struct device *dev)
195 /* acpi_bind_one increase refcnt by one */ 194 /* acpi_bind_one increase refcnt by one */
196 put_device(dev); 195 put_device(dev);
197 } else { 196 } else {
198 printk(KERN_ERR PREFIX 197 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
199 "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
200 } 198 }
201 return 0; 199 return 0;
202} 200}
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index ec0f2d581ece..e36422a7122c 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -714,9 +714,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
714 goto end; 714 goto end;
715 } 715 }
716 716
717 printk(KERN_INFO PREFIX 717 dev_info(&device->dev, "registered as cooling_device%d\n",
718 "%s is registered as cooling_device%d\n", 718 pr->cdev->id);
719 device->dev.bus_id, pr->cdev->id);
720 719
721 result = sysfs_create_link(&device->dev.kobj, 720 result = sysfs_create_link(&device->dev.kobj,
722 &pr->cdev->device.kobj, 721 &pr->cdev->device.kobj,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f3132aa47a69..f6f52c1a2aba 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -471,7 +471,7 @@ static int acpi_device_register(struct acpi_device *device,
471 device->dev.release = &acpi_device_release; 471 device->dev.release = &acpi_device_release;
472 result = device_add(&device->dev); 472 result = device_add(&device->dev);
473 if(result) { 473 if(result) {
474 printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id); 474 dev_err(&device->dev, "Error adding device\n");
475 goto end; 475 goto end;
476 } 476 }
477 477
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 84c795fb9b1e..30a341337933 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1179,8 +1179,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
1179 1179
1180 tz->tz_enabled = 1; 1180 tz->tz_enabled = 1;
1181 1181
1182 printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n", 1182 dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
1183 tz->device->dev.bus_id, tz->thermal_zone->id); 1183 tz->thermal_zone->id);
1184 return 0; 1184 return 0;
1185} 1185}
1186 1186
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 64c889331f3b..37b9e16710d6 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -762,9 +762,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
762 if (IS_ERR(device->cdev)) 762 if (IS_ERR(device->cdev))
763 return; 763 return;
764 764
765 printk(KERN_INFO PREFIX 765 dev_info(&device->dev->dev, "registered as cooling_device%d\n",
766 "%s is registered as cooling_device%d\n", 766 device->cdev->id);
767 device->dev->dev.bus_id, device->cdev->id);
768 result = sysfs_create_link(&device->dev->dev.kobj, 767 result = sysfs_create_link(&device->dev->dev.kobj,
769 &device->cdev->device.kobj, 768 &device->cdev->device.kobj,
770 "thermal_cooling"); 769 "thermal_cooling");
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d47482fa1d21..6318f6b57360 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -27,8 +27,9 @@ config PREVENT_FIRMWARE_BUILD
27 If unsure say Y here. 27 If unsure say Y here.
28 28
29config FW_LOADER 29config FW_LOADER
30 tristate "Userspace firmware loading support" 30 tristate "Userspace firmware loading support" if EMBEDDED
31 depends on HOTPLUG 31 depends on HOTPLUG
32 default y
32 ---help--- 33 ---help---
33 This option is provided for the case where no in-kernel-tree modules 34 This option is provided for the case where no in-kernel-tree modules
34 require userspace firmware loading support, but a module built outside 35 require userspace firmware loading support, but a module built outside
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 2c9ae43e2219..31dc0cd84afa 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -36,6 +36,33 @@ struct driver_private {
36}; 36};
37#define to_driver(obj) container_of(obj, struct driver_private, kobj) 37#define to_driver(obj) container_of(obj, struct driver_private, kobj)
38 38
39
40/**
41 * struct class_private - structure to hold the private to the driver core portions of the class structure.
42 *
43 * @class_subsys - the struct kset that defines this class. This is the main kobject
44 * @class_devices - list of devices associated with this class
45 * @class_interfaces - list of class_interfaces associated with this class
46 * @class_dirs - "glue" directory for virtual devices associated with this class
47 * @class_mutex - mutex to protect the children, devices, and interfaces lists.
48 * @class - pointer back to the struct class that this structure is associated
49 * with.
50 *
51 * This structure is the one that is the actual kobject allowing struct
52 * class to be statically allocated safely. Nothing outside of the driver
53 * core should ever touch these fields.
54 */
55struct class_private {
56 struct kset class_subsys;
57 struct list_head class_devices;
58 struct list_head class_interfaces;
59 struct kset class_dirs;
60 struct mutex class_mutex;
61 struct class *class;
62};
63#define to_class(obj) \
64 container_of(obj, struct class_private, class_subsys.kobj)
65
39/* initialisation functions */ 66/* initialisation functions */
40extern int devices_init(void); 67extern int devices_init(void);
41extern int buses_init(void); 68extern int buses_init(void);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index e085af0ff94f..839d27cecb36 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -18,20 +18,20 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/genhd.h> 20#include <linux/genhd.h>
21#include <linux/mutex.h>
21#include "base.h" 22#include "base.h"
22 23
23#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 24#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
24#define to_class(obj) container_of(obj, struct class, subsys.kobj)
25 25
26static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr, 26static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
27 char *buf) 27 char *buf)
28{ 28{
29 struct class_attribute *class_attr = to_class_attr(attr); 29 struct class_attribute *class_attr = to_class_attr(attr);
30 struct class *dc = to_class(kobj); 30 struct class_private *cp = to_class(kobj);
31 ssize_t ret = -EIO; 31 ssize_t ret = -EIO;
32 32
33 if (class_attr->show) 33 if (class_attr->show)
34 ret = class_attr->show(dc, buf); 34 ret = class_attr->show(cp->class, buf);
35 return ret; 35 return ret;
36} 36}
37 37
@@ -39,17 +39,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
39 const char *buf, size_t count) 39 const char *buf, size_t count)
40{ 40{
41 struct class_attribute *class_attr = to_class_attr(attr); 41 struct class_attribute *class_attr = to_class_attr(attr);
42 struct class *dc = to_class(kobj); 42 struct class_private *cp = to_class(kobj);
43 ssize_t ret = -EIO; 43 ssize_t ret = -EIO;
44 44
45 if (class_attr->store) 45 if (class_attr->store)
46 ret = class_attr->store(dc, buf, count); 46 ret = class_attr->store(cp->class, buf, count);
47 return ret; 47 return ret;
48} 48}
49 49
50static void class_release(struct kobject *kobj) 50static void class_release(struct kobject *kobj)
51{ 51{
52 struct class *class = to_class(kobj); 52 struct class_private *cp = to_class(kobj);
53 struct class *class = cp->class;
53 54
54 pr_debug("class '%s': release.\n", class->name); 55 pr_debug("class '%s': release.\n", class->name);
55 56
@@ -70,7 +71,7 @@ static struct kobj_type class_ktype = {
70 .release = class_release, 71 .release = class_release,
71}; 72};
72 73
73/* Hotplug events for classes go to the class_obj subsys */ 74/* Hotplug events for classes go to the class class_subsys */
74static struct kset *class_kset; 75static struct kset *class_kset;
75 76
76 77
@@ -78,7 +79,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
78{ 79{
79 int error; 80 int error;
80 if (cls) 81 if (cls)
81 error = sysfs_create_file(&cls->subsys.kobj, &attr->attr); 82 error = sysfs_create_file(&cls->p->class_subsys.kobj,
83 &attr->attr);
82 else 84 else
83 error = -EINVAL; 85 error = -EINVAL;
84 return error; 86 return error;
@@ -87,21 +89,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
87void class_remove_file(struct class *cls, const struct class_attribute *attr) 89void class_remove_file(struct class *cls, const struct class_attribute *attr)
88{ 90{
89 if (cls) 91 if (cls)
90 sysfs_remove_file(&cls->subsys.kobj, &attr->attr); 92 sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
91} 93}
92 94
93static struct class *class_get(struct class *cls) 95static struct class *class_get(struct class *cls)
94{ 96{
95 if (cls) 97 if (cls)
96 return container_of(kset_get(&cls->subsys), 98 kset_get(&cls->p->class_subsys);
97 struct class, subsys); 99 return cls;
98 return NULL;
99} 100}
100 101
101static void class_put(struct class *cls) 102static void class_put(struct class *cls)
102{ 103{
103 if (cls) 104 if (cls)
104 kset_put(&cls->subsys); 105 kset_put(&cls->p->class_subsys);
105} 106}
106 107
107static int add_class_attrs(struct class *cls) 108static int add_class_attrs(struct class *cls)
@@ -134,42 +135,57 @@ static void remove_class_attrs(struct class *cls)
134 } 135 }
135} 136}
136 137
137int class_register(struct class *cls) 138int __class_register(struct class *cls, struct lock_class_key *key)
138{ 139{
140 struct class_private *cp;
139 int error; 141 int error;
140 142
141 pr_debug("device class '%s': registering\n", cls->name); 143 pr_debug("device class '%s': registering\n", cls->name);
142 144
143 INIT_LIST_HEAD(&cls->devices); 145 cp = kzalloc(sizeof(*cp), GFP_KERNEL);
144 INIT_LIST_HEAD(&cls->interfaces); 146 if (!cp)
145 kset_init(&cls->class_dirs); 147 return -ENOMEM;
146 init_MUTEX(&cls->sem); 148 INIT_LIST_HEAD(&cp->class_devices);
147 error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name); 149 INIT_LIST_HEAD(&cp->class_interfaces);
148 if (error) 150 kset_init(&cp->class_dirs);
151 __mutex_init(&cp->class_mutex, "struct class mutex", key);
152 error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
153 if (error) {
154 kfree(cp);
149 return error; 155 return error;
156 }
157
158 /* set the default /sys/dev directory for devices of this class */
159 if (!cls->dev_kobj)
160 cls->dev_kobj = sysfs_dev_char_kobj;
150 161
151#if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) 162#if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
152 /* let the block class directory show up in the root of sysfs */ 163 /* let the block class directory show up in the root of sysfs */
153 if (cls != &block_class) 164 if (cls != &block_class)
154 cls->subsys.kobj.kset = class_kset; 165 cp->class_subsys.kobj.kset = class_kset;
155#else 166#else
156 cls->subsys.kobj.kset = class_kset; 167 cp->class_subsys.kobj.kset = class_kset;
157#endif 168#endif
158 cls->subsys.kobj.ktype = &class_ktype; 169 cp->class_subsys.kobj.ktype = &class_ktype;
170 cp->class = cls;
171 cls->p = cp;
159 172
160 error = kset_register(&cls->subsys); 173 error = kset_register(&cp->class_subsys);
161 if (!error) { 174 if (error) {
162 error = add_class_attrs(class_get(cls)); 175 kfree(cp);
163 class_put(cls); 176 return error;
164 } 177 }
178 error = add_class_attrs(class_get(cls));
179 class_put(cls);
165 return error; 180 return error;
166} 181}
182EXPORT_SYMBOL_GPL(__class_register);
167 183
168void class_unregister(struct class *cls) 184void class_unregister(struct class *cls)
169{ 185{
170 pr_debug("device class '%s': unregistering\n", cls->name); 186 pr_debug("device class '%s': unregistering\n", cls->name);
171 remove_class_attrs(cls); 187 remove_class_attrs(cls);
172 kset_unregister(&cls->subsys); 188 kset_unregister(&cls->p->class_subsys);
173} 189}
174 190
175static void class_create_release(struct class *cls) 191static void class_create_release(struct class *cls)
@@ -189,7 +205,8 @@ static void class_create_release(struct class *cls)
189 * Note, the pointer created here is to be destroyed when finished by 205 * Note, the pointer created here is to be destroyed when finished by
190 * making a call to class_destroy(). 206 * making a call to class_destroy().
191 */ 207 */
192struct class *class_create(struct module *owner, const char *name) 208struct class *__class_create(struct module *owner, const char *name,
209 struct lock_class_key *key)
193{ 210{
194 struct class *cls; 211 struct class *cls;
195 int retval; 212 int retval;
@@ -204,7 +221,7 @@ struct class *class_create(struct module *owner, const char *name)
204 cls->owner = owner; 221 cls->owner = owner;
205 cls->class_release = class_create_release; 222 cls->class_release = class_create_release;
206 223
207 retval = class_register(cls); 224 retval = __class_register(cls, key);
208 if (retval) 225 if (retval)
209 goto error; 226 goto error;
210 227
@@ -214,6 +231,7 @@ error:
214 kfree(cls); 231 kfree(cls);
215 return ERR_PTR(retval); 232 return ERR_PTR(retval);
216} 233}
234EXPORT_SYMBOL_GPL(__class_create);
217 235
218/** 236/**
219 * class_destroy - destroys a struct class structure 237 * class_destroy - destroys a struct class structure
@@ -252,39 +270,44 @@ char *make_class_name(const char *name, struct kobject *kobj)
252/** 270/**
253 * class_for_each_device - device iterator 271 * class_for_each_device - device iterator
254 * @class: the class we're iterating 272 * @class: the class we're iterating
273 * @start: the device to start with in the list, if any.
255 * @data: data for the callback 274 * @data: data for the callback
256 * @fn: function to be called for each device 275 * @fn: function to be called for each device
257 * 276 *
258 * Iterate over @class's list of devices, and call @fn for each, 277 * Iterate over @class's list of devices, and call @fn for each,
259 * passing it @data. 278 * passing it @data. If @start is set, the list iteration will start
279 * there, otherwise if it is NULL, the iteration starts at the
280 * beginning of the list.
260 * 281 *
261 * We check the return of @fn each time. If it returns anything 282 * We check the return of @fn each time. If it returns anything
262 * other than 0, we break out and return that value. 283 * other than 0, we break out and return that value.
263 * 284 *
264 * Note, we hold class->sem in this function, so it can not be 285 * Note, we hold class->class_mutex in this function, so it can not be
265 * re-acquired in @fn, otherwise it will self-deadlocking. For 286 * re-acquired in @fn, otherwise it will self-deadlocking. For
266 * example, calls to add or remove class members would be verboten. 287 * example, calls to add or remove class members would be verboten.
267 */ 288 */
268int class_for_each_device(struct class *class, void *data, 289int class_for_each_device(struct class *class, struct device *start,
269 int (*fn)(struct device *, void *)) 290 void *data, int (*fn)(struct device *, void *))
270{ 291{
271 struct device *dev; 292 struct device *dev;
272 int error = 0; 293 int error = 0;
273 294
274 if (!class) 295 if (!class)
275 return -EINVAL; 296 return -EINVAL;
276 down(&class->sem); 297 mutex_lock(&class->p->class_mutex);
277 list_for_each_entry(dev, &class->devices, node) { 298 list_for_each_entry(dev, &class->p->class_devices, node) {
299 if (start) {
300 if (start == dev)
301 start = NULL;
302 continue;
303 }
278 dev = get_device(dev); 304 dev = get_device(dev);
279 if (dev) { 305 error = fn(dev, data);
280 error = fn(dev, data); 306 put_device(dev);
281 put_device(dev);
282 } else
283 error = -ENODEV;
284 if (error) 307 if (error)
285 break; 308 break;
286 } 309 }
287 up(&class->sem); 310 mutex_unlock(&class->p->class_mutex);
288 311
289 return error; 312 return error;
290} 313}
@@ -293,6 +316,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
293/** 316/**
294 * class_find_device - device iterator for locating a particular device 317 * class_find_device - device iterator for locating a particular device
295 * @class: the class we're iterating 318 * @class: the class we're iterating
319 * @start: Device to begin with
296 * @data: data for the match function 320 * @data: data for the match function
297 * @match: function to check device 321 * @match: function to check device
298 * 322 *
@@ -306,12 +330,13 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
306 * 330 *
307 * Note, you will need to drop the reference with put_device() after use. 331 * Note, you will need to drop the reference with put_device() after use.
308 * 332 *
309 * We hold class->sem in this function, so it can not be 333 * We hold class->class_mutex in this function, so it can not be
310 * re-acquired in @match, otherwise it will self-deadlocking. For 334 * re-acquired in @match, otherwise it will self-deadlocking. For
311 * example, calls to add or remove class members would be verboten. 335 * example, calls to add or remove class members would be verboten.
312 */ 336 */
313struct device *class_find_device(struct class *class, void *data, 337struct device *class_find_device(struct class *class, struct device *start,
314 int (*match)(struct device *, void *)) 338 void *data,
339 int (*match)(struct device *, void *))
315{ 340{
316 struct device *dev; 341 struct device *dev;
317 int found = 0; 342 int found = 0;
@@ -319,19 +344,21 @@ struct device *class_find_device(struct class *class, void *data,
319 if (!class) 344 if (!class)
320 return NULL; 345 return NULL;
321 346
322 down(&class->sem); 347 mutex_lock(&class->p->class_mutex);
323 list_for_each_entry(dev, &class->devices, node) { 348 list_for_each_entry(dev, &class->p->class_devices, node) {
349 if (start) {
350 if (start == dev)
351 start = NULL;
352 continue;
353 }
324 dev = get_device(dev); 354 dev = get_device(dev);
325 if (dev) { 355 if (match(dev, data)) {
326 if (match(dev, data)) { 356 found = 1;
327 found = 1;
328 break;
329 } else
330 put_device(dev);
331 } else
332 break; 357 break;
358 } else
359 put_device(dev);
333 } 360 }
334 up(&class->sem); 361 mutex_unlock(&class->p->class_mutex);
335 362
336 return found ? dev : NULL; 363 return found ? dev : NULL;
337} 364}
@@ -349,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf)
349 if (!parent) 376 if (!parent)
350 return -EINVAL; 377 return -EINVAL;
351 378
352 down(&parent->sem); 379 mutex_lock(&parent->p->class_mutex);
353 list_add_tail(&class_intf->node, &parent->interfaces); 380 list_add_tail(&class_intf->node, &parent->p->class_interfaces);
354 if (class_intf->add_dev) { 381 if (class_intf->add_dev) {
355 list_for_each_entry(dev, &parent->devices, node) 382 list_for_each_entry(dev, &parent->p->class_devices, node)
356 class_intf->add_dev(dev, class_intf); 383 class_intf->add_dev(dev, class_intf);
357 } 384 }
358 up(&parent->sem); 385 mutex_unlock(&parent->p->class_mutex);
359 386
360 return 0; 387 return 0;
361} 388}
@@ -368,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf)
368 if (!parent) 395 if (!parent)
369 return; 396 return;
370 397
371 down(&parent->sem); 398 mutex_lock(&parent->p->class_mutex);
372 list_del_init(&class_intf->node); 399 list_del_init(&class_intf->node);
373 if (class_intf->remove_dev) { 400 if (class_intf->remove_dev) {
374 list_for_each_entry(dev, &parent->devices, node) 401 list_for_each_entry(dev, &parent->p->class_devices, node)
375 class_intf->remove_dev(dev, class_intf); 402 class_intf->remove_dev(dev, class_intf);
376 } 403 }
377 up(&parent->sem); 404 mutex_unlock(&parent->p->class_mutex);
378 405
379 class_put(parent); 406 class_put(parent);
380} 407}
@@ -389,9 +416,7 @@ int __init classes_init(void)
389 416
390EXPORT_SYMBOL_GPL(class_create_file); 417EXPORT_SYMBOL_GPL(class_create_file);
391EXPORT_SYMBOL_GPL(class_remove_file); 418EXPORT_SYMBOL_GPL(class_remove_file);
392EXPORT_SYMBOL_GPL(class_register);
393EXPORT_SYMBOL_GPL(class_unregister); 419EXPORT_SYMBOL_GPL(class_unregister);
394EXPORT_SYMBOL_GPL(class_create);
395EXPORT_SYMBOL_GPL(class_destroy); 420EXPORT_SYMBOL_GPL(class_destroy);
396 421
397EXPORT_SYMBOL_GPL(class_interface_register); 422EXPORT_SYMBOL_GPL(class_interface_register);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index ee0a51a3a41d..7d5c63c81a59 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -21,12 +21,16 @@
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <linux/semaphore.h> 23#include <linux/semaphore.h>
24#include <linux/mutex.h>
24 25
25#include "base.h" 26#include "base.h"
26#include "power/power.h" 27#include "power/power.h"
27 28
28int (*platform_notify)(struct device *dev) = NULL; 29int (*platform_notify)(struct device *dev) = NULL;
29int (*platform_notify_remove)(struct device *dev) = NULL; 30int (*platform_notify_remove)(struct device *dev) = NULL;
31static struct kobject *dev_kobj;
32struct kobject *sysfs_dev_char_kobj;
33struct kobject *sysfs_dev_block_kobj;
30 34
31#ifdef CONFIG_BLOCK 35#ifdef CONFIG_BLOCK
32static inline int device_is_not_partition(struct device *dev) 36static inline int device_is_not_partition(struct device *dev)
@@ -548,7 +552,7 @@ static struct kobject *get_device_parent(struct device *dev,
548{ 552{
549 /* class devices without a parent live in /sys/class/<classname>/ */ 553 /* class devices without a parent live in /sys/class/<classname>/ */
550 if (dev->class && (!parent || parent->class != dev->class)) 554 if (dev->class && (!parent || parent->class != dev->class))
551 return &dev->class->subsys.kobj; 555 return &dev->class->p->class_subsys.kobj;
552 /* all other devices keep their parent */ 556 /* all other devices keep their parent */
553 else if (parent) 557 else if (parent)
554 return &parent->kobj; 558 return &parent->kobj;
@@ -594,13 +598,13 @@ static struct kobject *get_device_parent(struct device *dev,
594 parent_kobj = &parent->kobj; 598 parent_kobj = &parent->kobj;
595 599
596 /* find our class-directory at the parent and reference it */ 600 /* find our class-directory at the parent and reference it */
597 spin_lock(&dev->class->class_dirs.list_lock); 601 spin_lock(&dev->class->p->class_dirs.list_lock);
598 list_for_each_entry(k, &dev->class->class_dirs.list, entry) 602 list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
599 if (k->parent == parent_kobj) { 603 if (k->parent == parent_kobj) {
600 kobj = kobject_get(k); 604 kobj = kobject_get(k);
601 break; 605 break;
602 } 606 }
603 spin_unlock(&dev->class->class_dirs.list_lock); 607 spin_unlock(&dev->class->p->class_dirs.list_lock);
604 if (kobj) 608 if (kobj)
605 return kobj; 609 return kobj;
606 610
@@ -608,7 +612,7 @@ static struct kobject *get_device_parent(struct device *dev,
608 k = kobject_create(); 612 k = kobject_create();
609 if (!k) 613 if (!k)
610 return NULL; 614 return NULL;
611 k->kset = &dev->class->class_dirs; 615 k->kset = &dev->class->p->class_dirs;
612 retval = kobject_add(k, parent_kobj, "%s", dev->class->name); 616 retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
613 if (retval < 0) { 617 if (retval < 0) {
614 kobject_put(k); 618 kobject_put(k);
@@ -627,7 +631,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
627{ 631{
628 /* see if we live in a "glue" directory */ 632 /* see if we live in a "glue" directory */
629 if (!glue_dir || !dev->class || 633 if (!glue_dir || !dev->class ||
630 glue_dir->kset != &dev->class->class_dirs) 634 glue_dir->kset != &dev->class->p->class_dirs)
631 return; 635 return;
632 636
633 kobject_put(glue_dir); 637 kobject_put(glue_dir);
@@ -654,17 +658,18 @@ static int device_add_class_symlinks(struct device *dev)
654 if (!dev->class) 658 if (!dev->class)
655 return 0; 659 return 0;
656 660
657 error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj, 661 error = sysfs_create_link(&dev->kobj,
662 &dev->class->p->class_subsys.kobj,
658 "subsystem"); 663 "subsystem");
659 if (error) 664 if (error)
660 goto out; 665 goto out;
661 666
662#ifdef CONFIG_SYSFS_DEPRECATED 667#ifdef CONFIG_SYSFS_DEPRECATED
663 /* stacked class devices need a symlink in the class directory */ 668 /* stacked class devices need a symlink in the class directory */
664 if (dev->kobj.parent != &dev->class->subsys.kobj && 669 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
665 device_is_not_partition(dev)) { 670 device_is_not_partition(dev)) {
666 error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, 671 error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
667 dev->bus_id); 672 &dev->kobj, dev->bus_id);
668 if (error) 673 if (error)
669 goto out_subsys; 674 goto out_subsys;
670 } 675 }
@@ -701,13 +706,14 @@ out_device:
701 if (dev->parent && device_is_not_partition(dev)) 706 if (dev->parent && device_is_not_partition(dev))
702 sysfs_remove_link(&dev->kobj, "device"); 707 sysfs_remove_link(&dev->kobj, "device");
703out_busid: 708out_busid:
704 if (dev->kobj.parent != &dev->class->subsys.kobj && 709 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
705 device_is_not_partition(dev)) 710 device_is_not_partition(dev))
706 sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); 711 sysfs_remove_link(&dev->class->p->class_subsys.kobj,
712 dev->bus_id);
707#else 713#else
708 /* link in the class directory pointing to the device */ 714 /* link in the class directory pointing to the device */
709 error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, 715 error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
710 dev->bus_id); 716 &dev->kobj, dev->bus_id);
711 if (error) 717 if (error)
712 goto out_subsys; 718 goto out_subsys;
713 719
@@ -720,7 +726,7 @@ out_busid:
720 return 0; 726 return 0;
721 727
722out_busid: 728out_busid:
723 sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); 729 sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
724#endif 730#endif
725 731
726out_subsys: 732out_subsys:
@@ -746,14 +752,15 @@ static void device_remove_class_symlinks(struct device *dev)
746 sysfs_remove_link(&dev->kobj, "device"); 752 sysfs_remove_link(&dev->kobj, "device");
747 } 753 }
748 754
749 if (dev->kobj.parent != &dev->class->subsys.kobj && 755 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
750 device_is_not_partition(dev)) 756 device_is_not_partition(dev))
751 sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); 757 sysfs_remove_link(&dev->class->p->class_subsys.kobj,
758 dev->bus_id);
752#else 759#else
753 if (dev->parent && device_is_not_partition(dev)) 760 if (dev->parent && device_is_not_partition(dev))
754 sysfs_remove_link(&dev->kobj, "device"); 761 sysfs_remove_link(&dev->kobj, "device");
755 762
756 sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); 763 sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
757#endif 764#endif
758 765
759 sysfs_remove_link(&dev->kobj, "subsystem"); 766 sysfs_remove_link(&dev->kobj, "subsystem");
@@ -776,6 +783,54 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
776EXPORT_SYMBOL_GPL(dev_set_name); 783EXPORT_SYMBOL_GPL(dev_set_name);
777 784
778/** 785/**
786 * device_to_dev_kobj - select a /sys/dev/ directory for the device
787 * @dev: device
788 *
789 * By default we select char/ for new entries. Setting class->dev_obj
790 * to NULL prevents an entry from being created. class->dev_kobj must
791 * be set (or cleared) before any devices are registered to the class
792 * otherwise device_create_sys_dev_entry() and
793 * device_remove_sys_dev_entry() will disagree about the the presence
794 * of the link.
795 */
796static struct kobject *device_to_dev_kobj(struct device *dev)
797{
798 struct kobject *kobj;
799
800 if (dev->class)
801 kobj = dev->class->dev_kobj;
802 else
803 kobj = sysfs_dev_char_kobj;
804
805 return kobj;
806}
807
808static int device_create_sys_dev_entry(struct device *dev)
809{
810 struct kobject *kobj = device_to_dev_kobj(dev);
811 int error = 0;
812 char devt_str[15];
813
814 if (kobj) {
815 format_dev_t(devt_str, dev->devt);
816 error = sysfs_create_link(kobj, &dev->kobj, devt_str);
817 }
818
819 return error;
820}
821
822static void device_remove_sys_dev_entry(struct device *dev)
823{
824 struct kobject *kobj = device_to_dev_kobj(dev);
825 char devt_str[15];
826
827 if (kobj) {
828 format_dev_t(devt_str, dev->devt);
829 sysfs_remove_link(kobj, devt_str);
830 }
831}
832
833/**
779 * device_add - add device to device hierarchy. 834 * device_add - add device to device hierarchy.
780 * @dev: device. 835 * @dev: device.
781 * 836 *
@@ -829,6 +884,10 @@ int device_add(struct device *dev)
829 error = device_create_file(dev, &devt_attr); 884 error = device_create_file(dev, &devt_attr);
830 if (error) 885 if (error)
831 goto ueventattrError; 886 goto ueventattrError;
887
888 error = device_create_sys_dev_entry(dev);
889 if (error)
890 goto devtattrError;
832 } 891 }
833 892
834 error = device_add_class_symlinks(dev); 893 error = device_add_class_symlinks(dev);
@@ -849,15 +908,16 @@ int device_add(struct device *dev)
849 klist_add_tail(&dev->knode_parent, &parent->klist_children); 908 klist_add_tail(&dev->knode_parent, &parent->klist_children);
850 909
851 if (dev->class) { 910 if (dev->class) {
852 down(&dev->class->sem); 911 mutex_lock(&dev->class->p->class_mutex);
853 /* tie the class to the device */ 912 /* tie the class to the device */
854 list_add_tail(&dev->node, &dev->class->devices); 913 list_add_tail(&dev->node, &dev->class->p->class_devices);
855 914
856 /* notify any interfaces that the device is here */ 915 /* notify any interfaces that the device is here */
857 list_for_each_entry(class_intf, &dev->class->interfaces, node) 916 list_for_each_entry(class_intf,
917 &dev->class->p->class_interfaces, node)
858 if (class_intf->add_dev) 918 if (class_intf->add_dev)
859 class_intf->add_dev(dev, class_intf); 919 class_intf->add_dev(dev, class_intf);
860 up(&dev->class->sem); 920 mutex_unlock(&dev->class->p->class_mutex);
861 } 921 }
862 Done: 922 Done:
863 put_device(dev); 923 put_device(dev);
@@ -873,6 +933,9 @@ int device_add(struct device *dev)
873 device_remove_class_symlinks(dev); 933 device_remove_class_symlinks(dev);
874 SymlinkError: 934 SymlinkError:
875 if (MAJOR(dev->devt)) 935 if (MAJOR(dev->devt))
936 device_remove_sys_dev_entry(dev);
937 devtattrError:
938 if (MAJOR(dev->devt))
876 device_remove_file(dev, &devt_attr); 939 device_remove_file(dev, &devt_attr);
877 ueventattrError: 940 ueventattrError:
878 device_remove_file(dev, &uevent_attr); 941 device_remove_file(dev, &uevent_attr);
@@ -948,19 +1011,22 @@ void device_del(struct device *dev)
948 device_pm_remove(dev); 1011 device_pm_remove(dev);
949 if (parent) 1012 if (parent)
950 klist_del(&dev->knode_parent); 1013 klist_del(&dev->knode_parent);
951 if (MAJOR(dev->devt)) 1014 if (MAJOR(dev->devt)) {
1015 device_remove_sys_dev_entry(dev);
952 device_remove_file(dev, &devt_attr); 1016 device_remove_file(dev, &devt_attr);
1017 }
953 if (dev->class) { 1018 if (dev->class) {
954 device_remove_class_symlinks(dev); 1019 device_remove_class_symlinks(dev);
955 1020
956 down(&dev->class->sem); 1021 mutex_lock(&dev->class->p->class_mutex);
957 /* notify any interfaces that the device is now gone */ 1022 /* notify any interfaces that the device is now gone */
958 list_for_each_entry(class_intf, &dev->class->interfaces, node) 1023 list_for_each_entry(class_intf,
1024 &dev->class->p->class_interfaces, node)
959 if (class_intf->remove_dev) 1025 if (class_intf->remove_dev)
960 class_intf->remove_dev(dev, class_intf); 1026 class_intf->remove_dev(dev, class_intf);
961 /* remove the device from the class list */ 1027 /* remove the device from the class list */
962 list_del_init(&dev->node); 1028 list_del_init(&dev->node);
963 up(&dev->class->sem); 1029 mutex_unlock(&dev->class->p->class_mutex);
964 } 1030 }
965 device_remove_file(dev, &uevent_attr); 1031 device_remove_file(dev, &uevent_attr);
966 device_remove_attrs(dev); 1032 device_remove_attrs(dev);
@@ -1074,7 +1140,25 @@ int __init devices_init(void)
1074 devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL); 1140 devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
1075 if (!devices_kset) 1141 if (!devices_kset)
1076 return -ENOMEM; 1142 return -ENOMEM;
1143 dev_kobj = kobject_create_and_add("dev", NULL);
1144 if (!dev_kobj)
1145 goto dev_kobj_err;
1146 sysfs_dev_block_kobj = kobject_create_and_add("block", dev_kobj);
1147 if (!sysfs_dev_block_kobj)
1148 goto block_kobj_err;
1149 sysfs_dev_char_kobj = kobject_create_and_add("char", dev_kobj);
1150 if (!sysfs_dev_char_kobj)
1151 goto char_kobj_err;
1152
1077 return 0; 1153 return 0;
1154
1155 char_kobj_err:
1156 kobject_put(sysfs_dev_block_kobj);
1157 block_kobj_err:
1158 kobject_put(dev_kobj);
1159 dev_kobj_err:
1160 kset_unregister(devices_kset);
1161 return -ENOMEM;
1078} 1162}
1079 1163
1080EXPORT_SYMBOL_GPL(device_for_each_child); 1164EXPORT_SYMBOL_GPL(device_for_each_child);
@@ -1158,48 +1242,11 @@ error:
1158EXPORT_SYMBOL_GPL(device_create_vargs); 1242EXPORT_SYMBOL_GPL(device_create_vargs);
1159 1243
1160/** 1244/**
1161 * device_create_drvdata - creates a device and registers it with sysfs
1162 * @class: pointer to the struct class that this device should be registered to
1163 * @parent: pointer to the parent struct device of this new device, if any
1164 * @devt: the dev_t for the char device to be added
1165 * @drvdata: the data to be added to the device for callbacks
1166 * @fmt: string for the device's name
1167 *
1168 * This function can be used by char device classes. A struct device
1169 * will be created in sysfs, registered to the specified class.
1170 *
1171 * A "dev" file will be created, showing the dev_t for the device, if
1172 * the dev_t is not 0,0.
1173 * If a pointer to a parent struct device is passed in, the newly created
1174 * struct device will be a child of that device in sysfs.
1175 * The pointer to the struct device will be returned from the call.
1176 * Any further sysfs files that might be required can be created using this
1177 * pointer.
1178 *
1179 * Note: the struct class passed to this function must have previously
1180 * been created with a call to class_create().
1181 */
1182struct device *device_create_drvdata(struct class *class,
1183 struct device *parent,
1184 dev_t devt,
1185 void *drvdata,
1186 const char *fmt, ...)
1187{
1188 va_list vargs;
1189 struct device *dev;
1190
1191 va_start(vargs, fmt);
1192 dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
1193 va_end(vargs);
1194 return dev;
1195}
1196EXPORT_SYMBOL_GPL(device_create_drvdata);
1197
1198/**
1199 * device_create - creates a device and registers it with sysfs 1245 * device_create - creates a device and registers it with sysfs
1200 * @class: pointer to the struct class that this device should be registered to 1246 * @class: pointer to the struct class that this device should be registered to
1201 * @parent: pointer to the parent struct device of this new device, if any 1247 * @parent: pointer to the parent struct device of this new device, if any
1202 * @devt: the dev_t for the char device to be added 1248 * @devt: the dev_t for the char device to be added
1249 * @drvdata: the data to be added to the device for callbacks
1203 * @fmt: string for the device's name 1250 * @fmt: string for the device's name
1204 * 1251 *
1205 * This function can be used by char device classes. A struct device 1252 * This function can be used by char device classes. A struct device
@@ -1217,13 +1264,13 @@ EXPORT_SYMBOL_GPL(device_create_drvdata);
1217 * been created with a call to class_create(). 1264 * been created with a call to class_create().
1218 */ 1265 */
1219struct device *device_create(struct class *class, struct device *parent, 1266struct device *device_create(struct class *class, struct device *parent,
1220 dev_t devt, const char *fmt, ...) 1267 dev_t devt, void *drvdata, const char *fmt, ...)
1221{ 1268{
1222 va_list vargs; 1269 va_list vargs;
1223 struct device *dev; 1270 struct device *dev;
1224 1271
1225 va_start(vargs, fmt); 1272 va_start(vargs, fmt);
1226 dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs); 1273 dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
1227 va_end(vargs); 1274 va_end(vargs);
1228 return dev; 1275 return dev;
1229} 1276}
@@ -1248,7 +1295,7 @@ void device_destroy(struct class *class, dev_t devt)
1248{ 1295{
1249 struct device *dev; 1296 struct device *dev;
1250 1297
1251 dev = class_find_device(class, &devt, __match_devt); 1298 dev = class_find_device(class, NULL, &devt, __match_devt);
1252 if (dev) { 1299 if (dev) {
1253 put_device(dev); 1300 put_device(dev);
1254 device_unregister(dev); 1301 device_unregister(dev);
@@ -1298,8 +1345,9 @@ int device_rename(struct device *dev, char *new_name)
1298 if (old_class_name) { 1345 if (old_class_name) {
1299 new_class_name = make_class_name(dev->class->name, &dev->kobj); 1346 new_class_name = make_class_name(dev->class->name, &dev->kobj);
1300 if (new_class_name) { 1347 if (new_class_name) {
1301 error = sysfs_create_link(&dev->parent->kobj, 1348 error = sysfs_create_link_nowarn(&dev->parent->kobj,
1302 &dev->kobj, new_class_name); 1349 &dev->kobj,
1350 new_class_name);
1303 if (error) 1351 if (error)
1304 goto out; 1352 goto out;
1305 sysfs_remove_link(&dev->parent->kobj, old_class_name); 1353 sysfs_remove_link(&dev->parent->kobj, old_class_name);
@@ -1307,11 +1355,12 @@ int device_rename(struct device *dev, char *new_name)
1307 } 1355 }
1308#else 1356#else
1309 if (dev->class) { 1357 if (dev->class) {
1310 error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, 1358 error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
1311 dev->bus_id); 1359 &dev->kobj, dev->bus_id);
1312 if (error) 1360 if (error)
1313 goto out; 1361 goto out;
1314 sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); 1362 sysfs_remove_link(&dev->class->p->class_subsys.kobj,
1363 old_device_name);
1315 } 1364 }
1316#endif 1365#endif
1317 1366
@@ -1447,4 +1496,7 @@ void device_shutdown(void)
1447 dev->driver->shutdown(dev); 1496 dev->driver->shutdown(dev);
1448 } 1497 }
1449 } 1498 }
1499 kobject_put(sysfs_dev_char_kobj);
1500 kobject_put(sysfs_dev_block_kobj);
1501 kobject_put(dev_kobj);
1450} 1502}
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index e38dfed41d80..20537d507909 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -21,15 +21,16 @@ EXPORT_SYMBOL(cpu_sysdev_class);
21static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); 21static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices);
22 22
23#ifdef CONFIG_HOTPLUG_CPU 23#ifdef CONFIG_HOTPLUG_CPU
24static ssize_t show_online(struct sys_device *dev, char *buf) 24static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr,
25 char *buf)
25{ 26{
26 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 27 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
27 28
28 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); 29 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
29} 30}
30 31
31static ssize_t __ref store_online(struct sys_device *dev, const char *buf, 32static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr,
32 size_t count) 33 const char *buf, size_t count)
33{ 34{
34 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 35 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
35 ssize_t ret; 36 ssize_t ret;
@@ -80,7 +81,8 @@ static inline void register_cpu_control(struct cpu *cpu)
80#ifdef CONFIG_KEXEC 81#ifdef CONFIG_KEXEC
81#include <linux/kexec.h> 82#include <linux/kexec.h>
82 83
83static ssize_t show_crash_notes(struct sys_device *dev, char *buf) 84static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr,
85 char *buf)
84{ 86{
85 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 87 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
86 ssize_t rc; 88 ssize_t rc;
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 937e8258981d..4d4e0e7b6e92 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -92,7 +92,8 @@ unregister_memory(struct memory_block *memory, struct mem_section *section)
92 * uses. 92 * uses.
93 */ 93 */
94 94
95static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) 95static ssize_t show_mem_phys_index(struct sys_device *dev,
96 struct sysdev_attribute *attr, char *buf)
96{ 97{
97 struct memory_block *mem = 98 struct memory_block *mem =
98 container_of(dev, struct memory_block, sysdev); 99 container_of(dev, struct memory_block, sysdev);
@@ -102,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
102/* 103/*
103 * online, offline, going offline, etc. 104 * online, offline, going offline, etc.
104 */ 105 */
105static ssize_t show_mem_state(struct sys_device *dev, char *buf) 106static ssize_t show_mem_state(struct sys_device *dev,
107 struct sysdev_attribute *attr, char *buf)
106{ 108{
107 struct memory_block *mem = 109 struct memory_block *mem =
108 container_of(dev, struct memory_block, sysdev); 110 container_of(dev, struct memory_block, sysdev);
@@ -217,7 +219,8 @@ out:
217} 219}
218 220
219static ssize_t 221static ssize_t
220store_mem_state(struct sys_device *dev, const char *buf, size_t count) 222store_mem_state(struct sys_device *dev,
223 struct sysdev_attribute *attr, const char *buf, size_t count)
221{ 224{
222 struct memory_block *mem; 225 struct memory_block *mem;
223 unsigned int phys_section_nr; 226 unsigned int phys_section_nr;
@@ -248,7 +251,8 @@ out:
248 * s.t. if I offline all of these sections I can then 251 * s.t. if I offline all of these sections I can then
249 * remove the physical device? 252 * remove the physical device?
250 */ 253 */
251static ssize_t show_phys_device(struct sys_device *dev, char *buf) 254static ssize_t show_phys_device(struct sys_device *dev,
255 struct sysdev_attribute *attr, char *buf)
252{ 256{
253 struct memory_block *mem = 257 struct memory_block *mem =
254 container_of(dev, struct memory_block, sysdev); 258 container_of(dev, struct memory_block, sysdev);
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 0f867a083338..5116b78c6325 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -36,11 +36,13 @@ static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf)
36 return len; 36 return len;
37} 37}
38 38
39static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf) 39static inline ssize_t node_read_cpumask(struct sys_device *dev,
40 struct sysdev_attribute *attr, char *buf)
40{ 41{
41 return node_read_cpumap(dev, 0, buf); 42 return node_read_cpumap(dev, 0, buf);
42} 43}
43static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf) 44static inline ssize_t node_read_cpulist(struct sys_device *dev,
45 struct sysdev_attribute *attr, char *buf)
44{ 46{
45 return node_read_cpumap(dev, 1, buf); 47 return node_read_cpumap(dev, 1, buf);
46} 48}
@@ -49,7 +51,8 @@ static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
49static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); 51static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
50 52
51#define K(x) ((x) << (PAGE_SHIFT - 10)) 53#define K(x) ((x) << (PAGE_SHIFT - 10))
52static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 54static ssize_t node_read_meminfo(struct sys_device * dev,
55 struct sysdev_attribute *attr, char * buf)
53{ 56{
54 int n; 57 int n;
55 int nid = dev->id; 58 int nid = dev->id;
@@ -112,7 +115,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
112#undef K 115#undef K
113static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); 116static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
114 117
115static ssize_t node_read_numastat(struct sys_device * dev, char * buf) 118static ssize_t node_read_numastat(struct sys_device * dev,
119 struct sysdev_attribute *attr, char * buf)
116{ 120{
117 return sprintf(buf, 121 return sprintf(buf,
118 "numa_hit %lu\n" 122 "numa_hit %lu\n"
@@ -130,7 +134,8 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
130} 134}
131static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 135static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
132 136
133static ssize_t node_read_distance(struct sys_device * dev, char * buf) 137static ssize_t node_read_distance(struct sys_device * dev,
138 struct sysdev_attribute *attr, char * buf)
134{ 139{
135 int nid = dev->id; 140 int nid = dev->id;
136 int len = 0; 141 int len = 0;
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index 9b1b20b59e0a..2aa6e8fc4def 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -194,7 +194,7 @@ static int show_dev_hash(unsigned int value)
194 struct device * dev = to_device(entry); 194 struct device * dev = to_device(entry);
195 unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); 195 unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH);
196 if (hash == value) { 196 if (hash == value) {
197 printk(" hash matches device %s\n", dev->bus_id); 197 dev_info(dev, "hash matches\n");
198 match++; 198 match++;
199 } 199 }
200 entry = entry->prev; 200 entry = entry->prev;
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 358bb0be3c08..40fc14f03540 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -36,7 +36,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
36 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 36 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
37 37
38 if (sysdev_attr->show) 38 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, buffer); 39 return sysdev_attr->show(sysdev, sysdev_attr, buffer);
40 return -EIO; 40 return -EIO;
41} 41}
42 42
@@ -49,7 +49,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr,
49 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 49 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
50 50
51 if (sysdev_attr->store) 51 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, buffer, count); 52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
53 return -EIO; 53 return -EIO;
54} 54}
55 55
@@ -130,8 +130,8 @@ static struct kset *system_kset;
130 130
131int sysdev_class_register(struct sysdev_class * cls) 131int sysdev_class_register(struct sysdev_class * cls)
132{ 132{
133 pr_debug("Registering sysdev class '%s'\n", 133 pr_debug("Registering sysdev class '%s'\n", cls->name);
134 kobject_name(&cls->kset.kobj)); 134
135 INIT_LIST_HEAD(&cls->drivers); 135 INIT_LIST_HEAD(&cls->drivers);
136 memset(&cls->kset.kobj, 0x00, sizeof(struct kobject)); 136 memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
137 cls->kset.kobj.parent = &system_kset->kobj; 137 cls->kset.kobj.parent = &system_kset->kobj;
@@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev)
241 if (!cls) 241 if (!cls)
242 return -EINVAL; 242 return -EINVAL;
243 243
244 pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj)); 244 pr_debug("Registering sys device of class '%s'\n",
245 kobject_name(&cls->kset.kobj));
245 246
246 /* initialize the kobject to 0, in case it had previously been used */ 247 /* initialize the kobject to 0, in case it had previously been used */
247 memset(&sysdev->kobj, 0x00, sizeof(struct kobject)); 248 memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
@@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev)
257 if (!error) { 258 if (!error) {
258 struct sysdev_driver * drv; 259 struct sysdev_driver * drv;
259 260
261 pr_debug("Registering sys device '%s'\n",
262 kobject_name(&sysdev->kobj));
263
260 mutex_lock(&sysdev_drivers_lock); 264 mutex_lock(&sysdev_drivers_lock);
261 /* Generic notification is implicit, because it's that 265 /* Generic notification is implicit, because it's that
262 * code that should have called us. 266 * code that should have called us.
@@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev)
269 } 273 }
270 mutex_unlock(&sysdev_drivers_lock); 274 mutex_unlock(&sysdev_drivers_lock);
271 } 275 }
276
272 kobject_uevent(&sysdev->kobj, KOBJ_ADD); 277 kobject_uevent(&sysdev->kobj, KOBJ_ADD);
273 return error; 278 return error;
274} 279}
@@ -474,3 +479,52 @@ int __init system_bus_init(void)
474 479
475EXPORT_SYMBOL_GPL(sysdev_register); 480EXPORT_SYMBOL_GPL(sysdev_register);
476EXPORT_SYMBOL_GPL(sysdev_unregister); 481EXPORT_SYMBOL_GPL(sysdev_unregister);
482
483#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
484
485ssize_t sysdev_store_ulong(struct sys_device *sysdev,
486 struct sysdev_attribute *attr,
487 const char *buf, size_t size)
488{
489 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
490 char *end;
491 unsigned long new = simple_strtoul(buf, &end, 0);
492 if (end == buf)
493 return -EINVAL;
494 *(unsigned long *)(ea->var) = new;
495 return end - buf;
496}
497EXPORT_SYMBOL_GPL(sysdev_store_ulong);
498
499ssize_t sysdev_show_ulong(struct sys_device *sysdev,
500 struct sysdev_attribute *attr,
501 char *buf)
502{
503 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
504 return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
505}
506EXPORT_SYMBOL_GPL(sysdev_show_ulong);
507
508ssize_t sysdev_store_int(struct sys_device *sysdev,
509 struct sysdev_attribute *attr,
510 const char *buf, size_t size)
511{
512 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
513 char *end;
514 long new = simple_strtol(buf, &end, 0);
515 if (end == buf || new > INT_MAX || new < INT_MIN)
516 return -EINVAL;
517 *(int *)(ea->var) = new;
518 return end - buf;
519}
520EXPORT_SYMBOL_GPL(sysdev_store_int);
521
522ssize_t sysdev_show_int(struct sys_device *sysdev,
523 struct sysdev_attribute *attr,
524 char *buf)
525{
526 struct sysdev_ext_attribute *ea = to_ext_attr(attr);
527 return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
528}
529EXPORT_SYMBOL_GPL(sysdev_show_int);
530
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3f6d9b0a6abe..199cd97e32e6 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -34,7 +34,8 @@
34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) 34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
35 35
36#define define_id_show_func(name) \ 36#define define_id_show_func(name) \
37static ssize_t show_##name(struct sys_device *dev, char *buf) \ 37static ssize_t show_##name(struct sys_device *dev, \
38 struct sysdev_attribute *attr, char *buf) \
38{ \ 39{ \
39 unsigned int cpu = dev->id; \ 40 unsigned int cpu = dev->id; \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 41 return sprintf(buf, "%d\n", topology_##name(cpu)); \
@@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
59 60
60#ifdef arch_provides_topology_pointers 61#ifdef arch_provides_topology_pointers
61#define define_siblings_show_map(name) \ 62#define define_siblings_show_map(name) \
62static ssize_t show_##name(struct sys_device *dev, char *buf) \ 63static ssize_t show_##name(struct sys_device *dev, \
64 struct sysdev_attribute *attr, char *buf) \
63{ \ 65{ \
64 unsigned int cpu = dev->id; \ 66 unsigned int cpu = dev->id; \
65 return show_cpumap(0, &(topology_##name(cpu)), buf); \ 67 return show_cpumap(0, &(topology_##name(cpu)), buf); \
66} 68}
67 69
68#define define_siblings_show_list(name) \ 70#define define_siblings_show_list(name) \
69static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 71static ssize_t show_##name##_list(struct sys_device *dev, \
72 struct sysdev_attribute *attr, \
73 char *buf) \
70{ \ 74{ \
71 unsigned int cpu = dev->id; \ 75 unsigned int cpu = dev->id; \
72 return show_cpumap(1, &(topology_##name(cpu)), buf); \ 76 return show_cpumap(1, &(topology_##name(cpu)), buf); \
@@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
74 78
75#else 79#else
76#define define_siblings_show_map(name) \ 80#define define_siblings_show_map(name) \
77static ssize_t show_##name(struct sys_device *dev, char *buf) \ 81static ssize_t show_##name(struct sys_device *dev, \
82 struct sysdev_attribute *attr, char *buf) \
78{ \ 83{ \
79 unsigned int cpu = dev->id; \ 84 unsigned int cpu = dev->id; \
80 cpumask_t mask = topology_##name(cpu); \ 85 cpumask_t mask = topology_##name(cpu); \
@@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
82} 87}
83 88
84#define define_siblings_show_list(name) \ 89#define define_siblings_show_list(name) \
85static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 90static ssize_t show_##name##_list(struct sys_device *dev, \
91 struct sysdev_attribute *attr, \
92 char *buf) \
86{ \ 93{ \
87 unsigned int cpu = dev->id; \ 94 unsigned int cpu = dev->id; \
88 cpumask_t mask = topology_##name(cpu); \ 95 cpumask_t mask = topology_##name(cpu); \
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index d1de68a31920..c04440cd6a32 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -277,8 +277,9 @@ aoechr_init(void)
277 return PTR_ERR(aoe_class); 277 return PTR_ERR(aoe_class);
278 } 278 }
279 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 279 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
280 device_create(aoe_class, NULL, 280 device_create_drvdata(aoe_class, NULL,
281 MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name); 281 MKDEV(AOE_MAJOR, chardevs[i].minor),
282 NULL, chardevs[i].name);
282 283
283 return 0; 284 return 0;
284} 285}
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 9d92636350e5..d731ca42f802 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -686,8 +686,9 @@ static int __init pg_init(void)
686 for (unit = 0; unit < PG_UNITS; unit++) { 686 for (unit = 0; unit < PG_UNITS; unit++) {
687 struct pg *dev = &devices[unit]; 687 struct pg *dev = &devices[unit];
688 if (dev->present) 688 if (dev->present)
689 device_create(pg_class, NULL, MKDEV(major, unit), 689 device_create_drvdata(pg_class, NULL,
690 "pg%u", unit); 690 MKDEV(major, unit), NULL,
691 "pg%u", unit);
691 } 692 }
692 err = 0; 693 err = 0;
693 goto out; 694 goto out;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 5c74c3574a5a..673b8b2fd337 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -979,10 +979,12 @@ static int __init pt_init(void)
979 979
980 for (unit = 0; unit < PT_UNITS; unit++) 980 for (unit = 0; unit < PT_UNITS; unit++)
981 if (pt[unit].present) { 981 if (pt[unit].present) {
982 device_create(pt_class, NULL, MKDEV(major, unit), 982 device_create_drvdata(pt_class, NULL,
983 "pt%d", unit); 983 MKDEV(major, unit), NULL,
984 device_create(pt_class, NULL, MKDEV(major, unit + 128), 984 "pt%d", unit);
985 "pt%dn", unit); 985 device_create_drvdata(pt_class, NULL,
986 MKDEV(major, unit + 128), NULL,
987 "pt%dn", unit);
986 } 988 }
987 goto out; 989 goto out;
988 990
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 45bee918c46a..158eed4d5161 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -303,7 +303,9 @@ static struct kobj_type kobj_pkt_type_wqueue = {
303static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 303static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
304{ 304{
305 if (class_pktcdvd) { 305 if (class_pktcdvd) {
306 pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name); 306 pd->dev = device_create_drvdata(class_pktcdvd, NULL,
307 pd->pkt_dev, NULL,
308 "%s", pd->name);
307 if (IS_ERR(pd->dev)) 309 if (IS_ERR(pd->dev))
308 pd->dev = NULL; 310 pd->dev = NULL;
309 } 311 }
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index b9a30c30e2b8..33c466a4888f 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void)
500 err = PTR_ERR(dsp56k_class); 500 err = PTR_ERR(dsp56k_class);
501 goto out_chrdev; 501 goto out_chrdev;
502 } 502 }
503 device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k"); 503 device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
504 NULL, "dsp56k");
504 505
505 printk(banner); 506 printk(banner);
506 goto out; 507 goto out;
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 5dc74404058f..9cb48fcd316c 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp)
718 } 718 }
719 719
720 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { 720 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
721 device_create(ip2_class, NULL, 721 device_create_drvdata(ip2_class, NULL,
722 MKDEV(IP2_IPL_MAJOR, 4 * i), 722 MKDEV(IP2_IPL_MAJOR, 4 * i),
723 "ipl%d", i); 723 NULL, "ipl%d", i);
724 device_create(ip2_class, NULL, 724 device_create_drvdata(ip2_class, NULL,
725 MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 725 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
726 "stat%d", i); 726 NULL, "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 c11a40483459..64e1c169e826 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
871 entry->dev = dev; 871 entry->dev = dev;
872 872
873 mutex_lock(&reg_list_mutex); 873 mutex_lock(&reg_list_mutex);
874 device_create(ipmi_class, device, dev, "ipmi%d", if_num); 874 device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
875 list_add(&entry->link, &reg_list); 875 list_add(&entry->link, &reg_list);
876 mutex_unlock(&reg_list_mutex); 876 mutex_unlock(&reg_list_mutex);
877} 877}
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index f9ebcd41d8e5..843a2afaf204 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void)
4599 4599
4600 istallion_class = class_create(THIS_MODULE, "staliomem"); 4600 istallion_class = class_create(THIS_MODULE, "staliomem");
4601 for (i = 0; i < 4; i++) 4601 for (i = 0; i < 4; i++)
4602 device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4602 device_create_drvdata(istallion_class, NULL,
4603 "staliomem%d", i); 4603 MKDEV(STL_SIOMEMMAJOR, i),
4604 NULL, "staliomem%d", i);
4604 4605
4605 return 0; 4606 return 0;
4606err_deinit: 4607err_deinit:
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 71abb4c33aa2..3f2719b9f77b 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port)
813 if (reset) 813 if (reset)
814 lp_reset(nr); 814 lp_reset(nr);
815 815
816 device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr); 816 device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817 "lp%d", nr);
817 818
818 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
819 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); 820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index b6772d657547..c2dba82eb5f7 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -989,9 +989,9 @@ static int __init chr_dev_init(void)
989 989
990 mem_class = class_create(THIS_MODULE, "mem"); 990 mem_class = class_create(THIS_MODULE, "mem");
991 for (i = 0; i < ARRAY_SIZE(devlist); i++) 991 for (i = 0; i < ARRAY_SIZE(devlist); i++)
992 device_create(mem_class, NULL, 992 device_create_drvdata(mem_class, NULL,
993 MKDEV(MEM_MAJOR, devlist[i].minor), 993 MKDEV(MEM_MAJOR, devlist[i].minor),
994 devlist[i].name); 994 NULL, devlist[i].name);
995 995
996 return 0; 996 return 0;
997} 997}
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 6e1563c3d30a..999aa779c08a 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
218 dev = MKDEV(MISC_MAJOR, misc->minor); 218 dev = MKDEV(MISC_MAJOR, misc->minor);
219 219
220 misc->this_device = device_create(misc_class, misc->parent, dev, 220 misc->this_device = device_create_drvdata(misc_class, misc->parent,
221 "%s", misc->name); 221 dev, NULL, "%s", misc->name);
222 if (IS_ERR(misc->this_device)) { 222 if (IS_ERR(misc->this_device)) {
223 err = PTR_ERR(misc->this_device); 223 err = PTR_ERR(misc->this_device);
224 goto out; 224 goto out;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index e4a4fbd37d7a..f070ae7bd91a 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link)
1896 return ret; 1896 return ret;
1897 } 1897 }
1898 1898
1899 device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i); 1899 device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
1900 1900
1901 return 0; 1901 return 0;
1902} 1902}
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 6181f8a9b0bd..0b5934bef7a4 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link)
653 return ret; 653 return ret;
654 } 654 }
655 655
656 device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i); 656 device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
657 "cmx%d", i);
657 658
658 return 0; 659 return 0;
659} 660}
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index f6e6acadd9a0..7af7a7e6b9c2 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = {
752 752
753static void pp_attach(struct parport *port) 753static void pp_attach(struct parport *port)
754{ 754{
755 device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), 755 device_create_drvdata(ppdev_class, port->dev,
756 "parport%d", port->number); 756 MKDEV(PP_MAJOR, port->number),
757 NULL, "parport%d", port->number);
757} 758}
758 759
759static void pp_detach(struct parport *port) 760static void pp_detach(struct parport *port)
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 505fcbe884a4..47b8cf281d4a 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
131static void bind_device(struct raw_config_request *rq) 131static void bind_device(struct raw_config_request *rq)
132{ 132{
133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
134 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 134 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
135 "raw%d", rq->raw_minor); 135 NULL, "raw%d", rq->raw_minor);
136} 136}
137 137
138/* 138/*
@@ -283,7 +283,8 @@ static int __init raw_init(void)
283 ret = PTR_ERR(raw_class); 283 ret = PTR_ERR(raw_class);
284 goto error_region; 284 goto error_region;
285 } 285 }
286 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl"); 286 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
287 "rawctl");
287 288
288 return 0; 289 return 0;
289 290
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 0b799ac1b049..3ce60df14c0a 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -444,7 +444,8 @@ scdrv_init(void)
444 continue; 444 continue;
445 } 445 }
446 446
447 device_create(snsc_class, NULL, dev, "%s", devname); 447 device_create_drvdata(snsc_class, NULL, dev, NULL,
448 "%s", devname);
448 449
449 ia64_sn_irtr_intr_enable(scd->scd_nasid, 450 ia64_sn_irtr_intr_enable(scd->scd_nasid,
450 0 /*ignored */ , 451 0 /*ignored */ ,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index de5a725c3cc0..b976248e1072 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4755,8 +4755,8 @@ static int __init stallion_module_init(void)
4755 if (IS_ERR(stallion_class)) 4755 if (IS_ERR(stallion_class))
4756 printk("STALLION: failed to create class\n"); 4756 printk("STALLION: failed to create class\n");
4757 for (i = 0; i < 4; i++) 4757 for (i = 0; i < 4; i++)
4758 device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4758 device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4759 "staliomem%d", i); 4759 NULL, "staliomem%d", i);
4760 4760
4761 return 0; 4761 return 0;
4762err_unrtty: 4762err_unrtty:
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index d94cd8410c53..15e597d03002 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3412,7 +3412,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3412 else 3412 else
3413 tty_line_name(driver, index, name); 3413 tty_line_name(driver, index, name);
3414 3414
3415 return device_create(tty_class, device, dev, name); 3415 return device_create_drvdata(tty_class, device, dev, NULL, name);
3416} 3416}
3417 3417
3418/** 3418/**
@@ -3690,20 +3690,22 @@ static int __init tty_init(void)
3690 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3690 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3691 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3691 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3692 panic("Couldn't register /dev/tty driver\n"); 3692 panic("Couldn't register /dev/tty driver\n");
3693 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty"); 3693 device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
3694 "tty");
3694 3695
3695 cdev_init(&console_cdev, &console_fops); 3696 cdev_init(&console_cdev, &console_fops);
3696 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3697 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3697 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3698 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3698 panic("Couldn't register /dev/console driver\n"); 3699 panic("Couldn't register /dev/console driver\n");
3699 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console"); 3700 device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
3701 "console");
3700 3702
3701#ifdef CONFIG_UNIX98_PTYS 3703#ifdef CONFIG_UNIX98_PTYS
3702 cdev_init(&ptmx_cdev, &ptmx_fops); 3704 cdev_init(&ptmx_cdev, &ptmx_fops);
3703 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || 3705 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
3704 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 3706 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
3705 panic("Couldn't register /dev/ptmx driver\n"); 3707 panic("Couldn't register /dev/ptmx driver\n");
3706 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx"); 3708 device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
3707#endif 3709#endif
3708 3710
3709#ifdef CONFIG_VT 3711#ifdef CONFIG_VT
@@ -3711,7 +3713,7 @@ static int __init tty_init(void)
3711 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || 3713 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
3712 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 3714 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3713 panic("Couldn't register /dev/tty0 driver\n"); 3715 panic("Couldn't register /dev/tty0 driver\n");
3714 device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0"); 3716 device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
3715 3717
3716 vty_init(); 3718 vty_init();
3717#endif 3719#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index eebfad2777d2..c2ae52dd53d1 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -481,10 +481,10 @@ static struct class *vc_class;
481 481
482void vcs_make_sysfs(struct tty_struct *tty) 482void vcs_make_sysfs(struct tty_struct *tty)
483{ 483{
484 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 484 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
485 "vcs%u", tty->index + 1); 485 NULL, "vcs%u", tty->index + 1);
486 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 486 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
487 "vcsa%u", tty->index + 1); 487 NULL, "vcsa%u", tty->index + 1);
488} 488}
489 489
490void vcs_remove_sysfs(struct tty_struct *tty) 490void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void)
499 panic("unable to get major %d for vcs device", VCS_MAJOR); 499 panic("unable to get major %d for vcs device", VCS_MAJOR);
500 vc_class = class_create(THIS_MODULE, "vc"); 500 vc_class = class_create(THIS_MODULE, "vc");
501 501
502 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs"); 502 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
503 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa"); 503 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
504 return 0; 504 return 0;
505} 505}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index e5da98d8f9cd..7a70a40ad639 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
886 state[i].cur_part = 0; 886 state[i].cur_part = 0;
887 for (j = 0; j < MAX_PARTITIONS; ++j) 887 for (j = 0; j < MAX_PARTITIONS; ++j)
888 state[i].part_stat_rwi[j] = VIOT_IDLE; 888 state[i].part_stat_rwi[j] = VIOT_IDLE;
889 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), 889 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
890 "iseries!vt%d", i); 890 NULL, "iseries!vt%d", i);
891 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 891 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
892 "iseries!nvt%d", i); 892 NULL, "iseries!nvt%d", i);
893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " 893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
894 "resource %10.10s type %4.4s, model %3.3s\n", 894 "resource %10.10s type %4.4s, model %3.3s\n",
895 i, viotape_unitinfo[i].rsrcname, 895 i, viotape_unitinfo[i].rsrcname,
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 935f1c207a1f..e32a076d5f1f 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last)
3425 if (retval) 3425 if (retval)
3426 goto err; 3426 goto err;
3427 3427
3428 con_driver->dev = device_create(vtconsole_class, NULL, 3428 con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
3429 MKDEV(0, con_driver->node), 3429 MKDEV(0, con_driver->node),
3430 "vtcon%i", con_driver->node); 3430 NULL, "vtcon%i",
3431 con_driver->node);
3431 3432
3432 if (IS_ERR(con_driver->dev)) { 3433 if (IS_ERR(con_driver->dev)) {
3433 printk(KERN_WARNING "Unable to create device for %s; " 3434 printk(KERN_WARNING "Unable to create device for %s; "
@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void)
3535 struct con_driver *con = &registered_con_driver[i]; 3536 struct con_driver *con = &registered_con_driver[i];
3536 3537
3537 if (con->con && !con->dev) { 3538 if (con->con && !con->dev) {
3538 con->dev = device_create(vtconsole_class, NULL, 3539 con->dev = device_create_drvdata(vtconsole_class, NULL,
3539 MKDEV(0, con->node), 3540 MKDEV(0, con->node),
3540 "vtcon%i", con->node); 3541 NULL, "vtcon%i",
3542 con->node);
3541 3543
3542 if (IS_ERR(con->dev)) { 3544 if (IS_ERR(con->dev)) {
3543 printk(KERN_WARNING "Unable to create " 3545 printk(KERN_WARNING "Unable to create "
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 1e1b81e57cdc..51966ccf4ea3 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id,
658 dev_err(dev, "cdev_add() failed\n"); 658 dev_err(dev, "cdev_add() failed\n");
659 goto failed3; 659 goto failed3;
660 } 660 }
661 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */ 661
662 device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id); 662 device_create_drvdata(icap_class, dev, devt, NULL,
663 "%s%d", DRIVER_NAME, id);
663 return 0; /* success */ 664 return 0; /* success */
664 665
665 failed3: 666 failed3:
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index e949618b9be0..31a0e0b455b6 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -21,7 +21,8 @@ static int __init cpuidle_sysfs_setup(char *unused)
21} 21}
22__setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); 22__setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
23 23
24static ssize_t show_available_governors(struct sys_device *dev, char *buf) 24static ssize_t show_available_governors(struct sys_device *dev,
25 struct sysdev_attribute *attr, char *buf)
25{ 26{
26 ssize_t i = 0; 27 ssize_t i = 0;
27 struct cpuidle_governor *tmp; 28 struct cpuidle_governor *tmp;
@@ -39,7 +40,8 @@ out:
39 return i; 40 return i;
40} 41}
41 42
42static ssize_t show_current_driver(struct sys_device *dev, char *buf) 43static ssize_t show_current_driver(struct sys_device *dev,
44 struct sysdev_attribute *attr, char *buf)
43{ 45{
44 ssize_t ret; 46 ssize_t ret;
45 47
@@ -53,7 +55,8 @@ static ssize_t show_current_driver(struct sys_device *dev, char *buf)
53 return ret; 55 return ret;
54} 56}
55 57
56static ssize_t show_current_governor(struct sys_device *dev, char *buf) 58static ssize_t show_current_governor(struct sys_device *dev,
59 struct sysdev_attribute *attr, char *buf)
57{ 60{
58 ssize_t ret; 61 ssize_t ret;
59 62
@@ -68,6 +71,7 @@ static ssize_t show_current_governor(struct sys_device *dev, char *buf)
68} 71}
69 72
70static ssize_t store_current_governor(struct sys_device *dev, 73static ssize_t store_current_governor(struct sys_device *dev,
74 struct sysdev_attribute *attr,
71 const char *buf, size_t count) 75 const char *buf, size_t count)
72{ 76{
73 char gov_name[CPUIDLE_NAME_LEN]; 77 char gov_name[CPUIDLE_NAME_LEN];
diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 011328faa5f2..9a70377bfb34 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -14,8 +14,9 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
14{ 14{
15 struct device *cd; 15 struct device *cd;
16 16
17 cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), 17 cd = device_create_drvdata(dca_class, dca->cd,
18 "requester%d", slot); 18 MKDEV(0, slot + 1), NULL,
19 "requester%d", slot);
19 if (IS_ERR(cd)) 20 if (IS_ERR(cd))
20 return PTR_ERR(cd); 21 return PTR_ERR(cd);
21 return 0; 22 return 0;
@@ -46,7 +47,8 @@ idr_try_again:
46 return err; 47 return err;
47 } 48 }
48 49
49 cd = device_create(dca_class, dev, MKDEV(0, 0), "dca%d", dca->id); 50 cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL,
51 "dca%d", dca->id);
50 if (IS_ERR(cd)) { 52 if (IS_ERR(cd)) {
51 spin_lock(&dca_idr_lock); 53 spin_lock(&dca_idr_lock);
52 idr_remove(&dca_idr, dca->id); 54 idr_remove(&dca_idr, dca->id);
diff --git a/drivers/eisa/Makefile b/drivers/eisa/Makefile
index 70abf93fe6b0..5369ce957c6d 100644
--- a/drivers/eisa/Makefile
+++ b/drivers/eisa/Makefile
@@ -9,7 +9,7 @@ obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o
9 9
10 10
11# Ugly hack to get DEVICE_NAME_SIZE value... 11# Ugly hack to get DEVICE_NAME_SIZE value...
12DEVICE_NAME_SIZE =$(shell awk '$$1=="\#define" && $$2=="DEVICE_NAME_SIZE" {print $$3-1}' $(srctree)/include/linux/device.h) 12DEVICE_NAME_SIZE = 50
13 13
14$(obj)/eisa-bus.o: $(obj)/devlist.h 14$(obj)/eisa-bus.o: $(obj)/devlist.h
15 15
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 65dcf0432653..c950bf8606d9 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -22,7 +22,7 @@
22 22
23struct eisa_device_info { 23struct eisa_device_info {
24 struct eisa_device_id id; 24 struct eisa_device_id id;
25 char name[DEVICE_NAME_SIZE]; 25 char name[50];
26}; 26};
27 27
28#ifdef CONFIG_EISA_NAMES 28#ifdef CONFIG_EISA_NAMES
@@ -63,7 +63,7 @@ static void __init eisa_name_device (struct eisa_device *edev)
63 if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) { 63 if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) {
64 strlcpy (edev->pretty_name, 64 strlcpy (edev->pretty_name,
65 eisa_table[i].name, 65 eisa_table[i].name,
66 DEVICE_NAME_SIZE); 66 sizeof(edev->pretty_name));
67 return; 67 return;
68 } 68 }
69 } 69 }
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 2fde6c63f47d..0c6b4d4e7e27 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -322,8 +322,9 @@ int hidraw_connect(struct hid_device *hid)
322 goto out; 322 goto out;
323 } 323 }
324 324
325 dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), 325 dev->dev = device_create_drvdata(hidraw_class, NULL,
326 "%s%d", "hidraw", minor); 326 MKDEV(hidraw_major, minor), NULL,
327 "%s%d", "hidraw", minor);
327 328
328 if (IS_ERR(dev->dev)) { 329 if (IS_ERR(dev->dev)) {
329 spin_lock(&minors_lock); 330 spin_lock(&minors_lock);
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 3db28450a3b3..7321a88a5112 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -55,7 +55,8 @@ again:
55 return ERR_PTR(err); 55 return ERR_PTR(err);
56 56
57 id = id & MAX_ID_MASK; 57 id = id & MAX_ID_MASK;
58 hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id); 58 hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
59 HWMON_ID_FORMAT, id);
59 60
60 if (IS_ERR(hwdev)) { 61 if (IS_ERR(hwdev)) {
61 spin_lock(&idr_lock); 62 spin_lock(&idr_lock);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7608df83d6d1..7bf38c418086 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -722,7 +722,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
722 722
723 INIT_LIST_HEAD(&driver->clients); 723 INIT_LIST_HEAD(&driver->clients);
724 /* Walk the adapters that are already present */ 724 /* Walk the adapters that are already present */
725 class_for_each_device(&i2c_adapter_class, driver, __attach_adapter); 725 class_for_each_device(&i2c_adapter_class, NULL, driver,
726 __attach_adapter);
726 727
727 mutex_unlock(&core_lock); 728 mutex_unlock(&core_lock);
728 return 0; 729 return 0;
@@ -782,7 +783,8 @@ void i2c_del_driver(struct i2c_driver *driver)
782{ 783{
783 mutex_lock(&core_lock); 784 mutex_lock(&core_lock);
784 785
785 class_for_each_device(&i2c_adapter_class, driver, __detach_adapter); 786 class_for_each_device(&i2c_adapter_class, NULL, driver,
787 __detach_adapter);
786 788
787 driver_unregister(&driver->driver); 789 driver_unregister(&driver->driver);
788 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 790 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 86727fa8858f..9d55c6383b23 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
521 return PTR_ERR(i2c_dev); 521 return PTR_ERR(i2c_dev);
522 522
523 /* register this i2c device with the driver core */ 523 /* register this i2c device with the driver core */
524 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, 524 i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev,
525 MKDEV(I2C_MAJOR, adap->nr), 525 MKDEV(I2C_MAJOR, adap->nr),
526 "i2c-%d", adap->nr); 526 NULL, "i2c-%d", adap->nr);
527 if (IS_ERR(i2c_dev->dev)) { 527 if (IS_ERR(i2c_dev->dev)) {
528 res = PTR_ERR(i2c_dev->dev); 528 res = PTR_ERR(i2c_dev->dev);
529 goto error; 529 goto error;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index b711ab96e287..353dd11b9283 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2697,10 +2697,12 @@ static int ide_tape_probe(ide_drive_t *drive)
2697 2697
2698 idetape_setup(drive, tape, minor); 2698 idetape_setup(drive, tape, minor);
2699 2699
2700 device_create(idetape_sysfs_class, &drive->gendev, 2700 device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2701 MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name); 2701 MKDEV(IDETAPE_MAJOR, minor), NULL,
2702 device_create(idetape_sysfs_class, &drive->gendev, 2702 "%s", tape->name);
2703 MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name); 2703 device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2704 MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2705 "n%s", tape->name);
2704 2706
2705 g->fops = &idetape_block_ops; 2707 g->fops = &idetape_block_ops;
2706 ide_register_region(g); 2708 ide_register_region(g);
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 9d19aec5820a..b6eb2cf25914 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2296,9 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host)
2296 2296
2297 ohci = (struct ti_ohci *)host->hostdata; 2297 ohci = (struct ti_ohci *)host->hostdata;
2298 2298
2299 device_create(hpsb_protocol_class, NULL, MKDEV( 2299 device_create_drvdata(hpsb_protocol_class, NULL,
2300 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2300 MKDEV(IEEE1394_MAJOR,
2301 "dv1394-%d", id); 2301 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
2302 "dv1394-%d", id);
2302 2303
2303 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); 2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
2304 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); 2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 05710c7c1220..994a21e5a0aa 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne)
754 */ 754 */
755 mutex_lock(&nodemgr_serialize_remove_uds); 755 mutex_lock(&nodemgr_serialize_remove_uds);
756 for (;;) { 756 for (;;) {
757 dev = class_find_device(&nodemgr_ud_class, ne, __match_ne); 757 dev = class_find_device(&nodemgr_ud_class, NULL, ne,
758 __match_ne);
758 if (!dev) 759 if (!dev)
759 break; 760 break;
760 ud = container_of(dev, struct unit_directory, unit_dev); 761 ud = container_of(dev, struct unit_directory, unit_dev);
@@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid)
901 struct device *dev; 902 struct device *dev;
902 struct node_entry *ne; 903 struct node_entry *ne;
903 904
904 dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid); 905 dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
906 __match_ne_guid);
905 if (!dev) 907 if (!dev)
906 return NULL; 908 return NULL;
907 ne = container_of(dev, struct node_entry, node_dev); 909 ne = container_of(dev, struct node_entry, node_dev);
@@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
940 param.host = host; 942 param.host = host;
941 param.nodeid = nodeid; 943 param.nodeid = nodeid;
942 944
943 dev = class_find_device(&nodemgr_ne_class, &param, __match_ne_nodeid); 945 dev = class_find_device(&nodemgr_ne_class, NULL, &param,
946 __match_ne_nodeid);
944 if (!dev) 947 if (!dev)
945 return NULL; 948 return NULL;
946 ne = container_of(dev, struct node_entry, node_dev); 949 ne = container_of(dev, struct node_entry, node_dev);
@@ -1453,7 +1456,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1453 ne->in_limbo = 1; 1456 ne->in_limbo = 1;
1454 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); 1457 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
1455 1458
1456 class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_suspend); 1459 class_for_each_device(&nodemgr_ud_class, NULL, ne,
1460 __nodemgr_driver_suspend);
1457} 1461}
1458 1462
1459 1463
@@ -1462,7 +1466,8 @@ static void nodemgr_resume_ne(struct node_entry *ne)
1462 ne->in_limbo = 0; 1466 ne->in_limbo = 0;
1463 device_remove_file(&ne->device, &dev_attr_ne_in_limbo); 1467 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1464 1468
1465 class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_resume); 1469 class_for_each_device(&nodemgr_ud_class, NULL, ne,
1470 __nodemgr_driver_resume);
1466 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 1471 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1467 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 1472 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1468} 1473}
@@ -1498,7 +1503,8 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data)
1498 1503
1499static void nodemgr_update_pdrv(struct node_entry *ne) 1504static void nodemgr_update_pdrv(struct node_entry *ne)
1500{ 1505{
1501 class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_update_pdrv); 1506 class_for_each_device(&nodemgr_ud_class, NULL, ne,
1507 __nodemgr_update_pdrv);
1502} 1508}
1503 1509
1504 1510
@@ -1591,7 +1597,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1591 * while probes are time-consuming. (Well, those probes need some 1597 * while probes are time-consuming. (Well, those probes need some
1592 * improvement...) */ 1598 * improvement...) */
1593 1599
1594 class_for_each_device(&nodemgr_ne_class, &param, __nodemgr_node_probe); 1600 class_for_each_device(&nodemgr_ne_class, NULL, &param,
1601 __nodemgr_node_probe);
1595 1602
1596 /* If we had a bus reset while we were scanning the bus, it is 1603 /* If we had a bus reset while we were scanning the bus, it is
1597 * possible that we did not probe all nodes. In that case, we 1604 * possible that we did not probe all nodes. In that case, we
@@ -1826,7 +1833,7 @@ int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *))
1826 1833
1827 hip.cb = cb; 1834 hip.cb = cb;
1828 hip.data = data; 1835 hip.data = data;
1829 error = class_for_each_device(&hpsb_host_class, &hip, 1836 error = class_for_each_device(&hpsb_host_class, NULL, &hip,
1830 __nodemgr_for_each_host); 1837 __nodemgr_for_each_host);
1831 1838
1832 return error; 1839 return error;
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 96f2847b0405..6fa9e4a21840 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -3010,10 +3010,10 @@ static int __init init_raw1394(void)
3010 hpsb_register_highlevel(&raw1394_highlevel); 3010 hpsb_register_highlevel(&raw1394_highlevel);
3011 3011
3012 if (IS_ERR 3012 if (IS_ERR
3013 (device_create( 3013 (device_create_drvdata(
3014 hpsb_protocol_class, NULL, 3014 hpsb_protocol_class, NULL,
3015 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3015 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016 RAW1394_DEVICE_NAME))) { 3016 NULL, RAW1394_DEVICE_NAME))) {
3017 ret = -EFAULT; 3017 ret = -EFAULT;
3018 goto out_unreg; 3018 goto out_unreg;
3019 } 3019 }
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 069b9f6bf16d..25db6e67fa4e 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1341,9 +1341,9 @@ static void video1394_add_host (struct hpsb_host *host)
1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
1342 1342
1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1344 device_create(hpsb_protocol_class, NULL, 1344 device_create_drvdata(hpsb_protocol_class, NULL,
1345 MKDEV(IEEE1394_MAJOR, minor), 1345 MKDEV(IEEE1394_MAJOR, minor), NULL,
1346 "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1346 "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1347} 1347}
1348 1348
1349 1349
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 55738eead3bf..922d35f4fc08 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -44,6 +44,7 @@
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/sysfs.h> 45#include <linux/sysfs.h>
46#include <linux/workqueue.h> 46#include <linux/workqueue.h>
47#include <linux/kdev_t.h>
47 48
48#include <rdma/ib_cache.h> 49#include <rdma/ib_cache.h>
49#include <rdma/ib_cm.h> 50#include <rdma/ib_cm.h>
@@ -162,8 +163,8 @@ struct cm_port {
162 163
163struct cm_device { 164struct cm_device {
164 struct list_head list; 165 struct list_head list;
165 struct ib_device *device; 166 struct ib_device *ib_device;
166 struct kobject dev_obj; 167 struct device *device;
167 u8 ack_delay; 168 u8 ack_delay;
168 struct cm_port *port[0]; 169 struct cm_port *port[0];
169}; 170};
@@ -339,7 +340,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
339{ 340{
340 av->port = port; 341 av->port = port;
341 av->pkey_index = wc->pkey_index; 342 av->pkey_index = wc->pkey_index;
342 ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc, 343 ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
343 grh, &av->ah_attr); 344 grh, &av->ah_attr);
344} 345}
345 346
@@ -353,7 +354,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
353 354
354 read_lock_irqsave(&cm.device_lock, flags); 355 read_lock_irqsave(&cm.device_lock, flags);
355 list_for_each_entry(cm_dev, &cm.device_list, list) { 356 list_for_each_entry(cm_dev, &cm.device_list, list) {
356 if (!ib_find_cached_gid(cm_dev->device, &path->sgid, 357 if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
357 &p, NULL)) { 358 &p, NULL)) {
358 port = cm_dev->port[p-1]; 359 port = cm_dev->port[p-1];
359 break; 360 break;
@@ -364,13 +365,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
364 if (!port) 365 if (!port)
365 return -EINVAL; 366 return -EINVAL;
366 367
367 ret = ib_find_cached_pkey(cm_dev->device, port->port_num, 368 ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
368 be16_to_cpu(path->pkey), &av->pkey_index); 369 be16_to_cpu(path->pkey), &av->pkey_index);
369 if (ret) 370 if (ret)
370 return ret; 371 return ret;
371 372
372 av->port = port; 373 av->port = port;
373 ib_init_ah_from_path(cm_dev->device, port->port_num, path, 374 ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
374 &av->ah_attr); 375 &av->ah_attr);
375 av->timeout = path->packet_life_time + 1; 376 av->timeout = path->packet_life_time + 1;
376 return 0; 377 return 0;
@@ -1515,7 +1516,7 @@ static int cm_req_handler(struct cm_work *work)
1515 1516
1516 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1517 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
1517 1518
1518 cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL); 1519 cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
1519 if (IS_ERR(cm_id)) 1520 if (IS_ERR(cm_id))
1520 return PTR_ERR(cm_id); 1521 return PTR_ERR(cm_id);
1521 1522
@@ -1550,7 +1551,7 @@ static int cm_req_handler(struct cm_work *work)
1550 cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]); 1551 cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
1551 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); 1552 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
1552 if (ret) { 1553 if (ret) {
1553 ib_get_cached_gid(work->port->cm_dev->device, 1554 ib_get_cached_gid(work->port->cm_dev->ib_device,
1554 work->port->port_num, 0, &work->path[0].sgid); 1555 work->port->port_num, 0, &work->path[0].sgid);
1555 ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID, 1556 ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
1556 &work->path[0].sgid, sizeof work->path[0].sgid, 1557 &work->path[0].sgid, sizeof work->path[0].sgid,
@@ -2950,7 +2951,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
2950 struct cm_sidr_req_msg *sidr_req_msg; 2951 struct cm_sidr_req_msg *sidr_req_msg;
2951 struct ib_wc *wc; 2952 struct ib_wc *wc;
2952 2953
2953 cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL); 2954 cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
2954 if (IS_ERR(cm_id)) 2955 if (IS_ERR(cm_id))
2955 return PTR_ERR(cm_id); 2956 return PTR_ERR(cm_id);
2956 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 2957 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
@@ -3578,7 +3579,7 @@ static void cm_get_ack_delay(struct cm_device *cm_dev)
3578{ 3579{
3579 struct ib_device_attr attr; 3580 struct ib_device_attr attr;
3580 3581
3581 if (ib_query_device(cm_dev->device, &attr)) 3582 if (ib_query_device(cm_dev->ib_device, &attr))
3582 cm_dev->ack_delay = 0; /* acks will rely on packet life time */ 3583 cm_dev->ack_delay = 0; /* acks will rely on packet life time */
3583 else 3584 else
3584 cm_dev->ack_delay = attr.local_ca_ack_delay; 3585 cm_dev->ack_delay = attr.local_ca_ack_delay;
@@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = {
3618 .release = cm_release_port_obj 3619 .release = cm_release_port_obj
3619}; 3620};
3620 3621
3621static void cm_release_dev_obj(struct kobject *obj)
3622{
3623 struct cm_device *cm_dev;
3624
3625 cm_dev = container_of(obj, struct cm_device, dev_obj);
3626 kfree(cm_dev);
3627}
3628
3629static struct kobj_type cm_dev_obj_type = {
3630 .release = cm_release_dev_obj
3631};
3632
3633struct class cm_class = { 3622struct class cm_class = {
3634 .name = "infiniband_cm", 3623 .name = "infiniband_cm",
3635}; 3624};
@@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port)
3640 int i, ret; 3629 int i, ret;
3641 3630
3642 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, 3631 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
3643 &port->cm_dev->dev_obj, 3632 &port->cm_dev->device->kobj,
3644 "%d", port->port_num); 3633 "%d", port->port_num);
3645 if (ret) { 3634 if (ret) {
3646 kfree(port); 3635 kfree(port);
@@ -3676,7 +3665,7 @@ static void cm_remove_port_fs(struct cm_port *port)
3676 kobject_put(&port->port_obj); 3665 kobject_put(&port->port_obj);
3677} 3666}
3678 3667
3679static void cm_add_one(struct ib_device *device) 3668static void cm_add_one(struct ib_device *ib_device)
3680{ 3669{
3681 struct cm_device *cm_dev; 3670 struct cm_device *cm_dev;
3682 struct cm_port *port; 3671 struct cm_port *port;
@@ -3691,26 +3680,27 @@ static void cm_add_one(struct ib_device *device)
3691 int ret; 3680 int ret;
3692 u8 i; 3681 u8 i;
3693 3682
3694 if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) 3683 if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
3695 return; 3684 return;
3696 3685
3697 cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) * 3686 cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
3698 device->phys_port_cnt, GFP_KERNEL); 3687 ib_device->phys_port_cnt, GFP_KERNEL);
3699 if (!cm_dev) 3688 if (!cm_dev)
3700 return; 3689 return;
3701 3690
3702 cm_dev->device = device; 3691 cm_dev->ib_device = ib_device;
3703 cm_get_ack_delay(cm_dev); 3692 cm_get_ack_delay(cm_dev);
3704 3693
3705 ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type, 3694 cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
3706 &cm_class.subsys.kobj, "%s", device->name); 3695 MKDEV(0, 0), NULL,
3707 if (ret) { 3696 "%s", ib_device->name);
3697 if (!cm_dev->device) {
3708 kfree(cm_dev); 3698 kfree(cm_dev);
3709 return; 3699 return;
3710 } 3700 }
3711 3701
3712 set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); 3702 set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
3713 for (i = 1; i <= device->phys_port_cnt; i++) { 3703 for (i = 1; i <= ib_device->phys_port_cnt; i++) {
3714 port = kzalloc(sizeof *port, GFP_KERNEL); 3704 port = kzalloc(sizeof *port, GFP_KERNEL);
3715 if (!port) 3705 if (!port)
3716 goto error1; 3706 goto error1;
@@ -3723,7 +3713,7 @@ static void cm_add_one(struct ib_device *device)
3723 if (ret) 3713 if (ret)
3724 goto error1; 3714 goto error1;
3725 3715
3726 port->mad_agent = ib_register_mad_agent(device, i, 3716 port->mad_agent = ib_register_mad_agent(ib_device, i,
3727 IB_QPT_GSI, 3717 IB_QPT_GSI,
3728 &reg_req, 3718 &reg_req,
3729 0, 3719 0,
@@ -3733,11 +3723,11 @@ static void cm_add_one(struct ib_device *device)
3733 if (IS_ERR(port->mad_agent)) 3723 if (IS_ERR(port->mad_agent))
3734 goto error2; 3724 goto error2;
3735 3725
3736 ret = ib_modify_port(device, i, 0, &port_modify); 3726 ret = ib_modify_port(ib_device, i, 0, &port_modify);
3737 if (ret) 3727 if (ret)
3738 goto error3; 3728 goto error3;
3739 } 3729 }
3740 ib_set_client_data(device, &cm_client, cm_dev); 3730 ib_set_client_data(ib_device, &cm_client, cm_dev);
3741 3731
3742 write_lock_irqsave(&cm.device_lock, flags); 3732 write_lock_irqsave(&cm.device_lock, flags);
3743 list_add_tail(&cm_dev->list, &cm.device_list); 3733 list_add_tail(&cm_dev->list, &cm.device_list);
@@ -3753,14 +3743,14 @@ error1:
3753 port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; 3743 port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
3754 while (--i) { 3744 while (--i) {
3755 port = cm_dev->port[i-1]; 3745 port = cm_dev->port[i-1];
3756 ib_modify_port(device, port->port_num, 0, &port_modify); 3746 ib_modify_port(ib_device, port->port_num, 0, &port_modify);
3757 ib_unregister_mad_agent(port->mad_agent); 3747 ib_unregister_mad_agent(port->mad_agent);
3758 cm_remove_port_fs(port); 3748 cm_remove_port_fs(port);
3759 } 3749 }
3760 kobject_put(&cm_dev->dev_obj); 3750 device_unregister(cm_dev->device);
3761} 3751}
3762 3752
3763static void cm_remove_one(struct ib_device *device) 3753static void cm_remove_one(struct ib_device *ib_device)
3764{ 3754{
3765 struct cm_device *cm_dev; 3755 struct cm_device *cm_dev;
3766 struct cm_port *port; 3756 struct cm_port *port;
@@ -3770,7 +3760,7 @@ static void cm_remove_one(struct ib_device *device)
3770 unsigned long flags; 3760 unsigned long flags;
3771 int i; 3761 int i;
3772 3762
3773 cm_dev = ib_get_client_data(device, &cm_client); 3763 cm_dev = ib_get_client_data(ib_device, &cm_client);
3774 if (!cm_dev) 3764 if (!cm_dev)
3775 return; 3765 return;
3776 3766
@@ -3778,14 +3768,14 @@ static void cm_remove_one(struct ib_device *device)
3778 list_del(&cm_dev->list); 3768 list_del(&cm_dev->list);
3779 write_unlock_irqrestore(&cm.device_lock, flags); 3769 write_unlock_irqrestore(&cm.device_lock, flags);
3780 3770
3781 for (i = 1; i <= device->phys_port_cnt; i++) { 3771 for (i = 1; i <= ib_device->phys_port_cnt; i++) {
3782 port = cm_dev->port[i-1]; 3772 port = cm_dev->port[i-1];
3783 ib_modify_port(device, port->port_num, 0, &port_modify); 3773 ib_modify_port(ib_device, port->port_num, 0, &port_modify);
3784 ib_unregister_mad_agent(port->mad_agent); 3774 ib_unregister_mad_agent(port->mad_agent);
3785 flush_workqueue(cm.wq); 3775 flush_workqueue(cm.wq);
3786 cm_remove_port_fs(port); 3776 cm_remove_port_fs(port);
3787 } 3777 }
3788 kobject_put(&cm_dev->dev_obj); 3778 device_unregister(cm_dev->device);
3789} 3779}
3790 3780
3791static int __init ib_cm_init(void) 3781static int __init ib_cm_init(void)
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 35f301c88b57..56c0eda3c077 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
2455 goto err_cdev; 2455 goto err_cdev;
2456 } 2456 }
2457 2457
2458 device = device_create(ipath_class, NULL, dev, name); 2458 device = device_create_drvdata(ipath_class, NULL, dev, NULL, name);
2459 2459
2460 if (IS_ERR(device)) { 2460 if (IS_ERR(device)) {
2461 ret = PTR_ERR(device); 2461 ret = PTR_ERR(device);
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 19e005e81fef..871b0cbca5e4 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1553,7 +1553,8 @@ static int __init capi_init(void)
1553 return PTR_ERR(capi_class); 1553 return PTR_ERR(capi_class);
1554 } 1554 }
1555 1555
1556 device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi"); 1556 device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL,
1557 "capi");
1557 1558
1558#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1559#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1559 if (capinc_tty_init() < 0) { 1560 if (capinc_tty_init() < 0) {
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index e5d446804d32..cae52485208a 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -862,7 +862,8 @@ adbdev_init(void)
862 adb_dev_class = class_create(THIS_MODULE, "adb"); 862 adb_dev_class = class_create(THIS_MODULE, "adb");
863 if (IS_ERR(adb_dev_class)) 863 if (IS_ERR(adb_dev_class))
864 return; 864 return;
865 device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb"); 865 device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL,
866 "adb");
866 867
867 platform_device_register(&adb_pfdev); 868 platform_device_register(&adb_pfdev);
868 platform_driver_probe(&adb_pfdrv, adb_dummy_probe); 869 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index 67b8e9453b19..ef2dbfe74714 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -40,7 +40,7 @@ static struct mca_bus *mca_root_busses[MAX_MCA_BUSSES];
40 40
41struct mca_device_info { 41struct mca_device_info {
42 short pos_id; /* the 2 byte pos id for this card */ 42 short pos_id; /* the 2 byte pos id for this card */
43 char name[DEVICE_NAME_SIZE]; 43 char name[50];
44}; 44};
45 45
46static int mca_bus_match (struct device *dev, struct device_driver *drv) 46static int mca_bus_match (struct device *dev, struct device_driver *drv)
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index e208a60c048a..e7132770a3bf 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -233,9 +233,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
233 233
234 mutex_unlock(&dvbdev_register_lock); 234 mutex_unlock(&dvbdev_register_lock);
235 235
236 clsdev = device_create(dvb_class, adap->device, 236 clsdev = device_create_drvdata(dvb_class, adap->device,
237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
238 "dvb%d.%s%d", adap->num, dnames[type], id); 238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
239 if (IS_ERR(clsdev)) { 239 if (IS_ERR(clsdev)) {
240 printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n", 240 printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
241 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); 241 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index a054668eda16..4e3bfbcdf155 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -51,7 +51,7 @@ struct jmb38x_ms_host {
51 void __iomem *addr; 51 void __iomem *addr;
52 spinlock_t lock; 52 spinlock_t lock;
53 int id; 53 int id;
54 char host_id[DEVICE_ID_SIZE]; 54 char host_id[32];
55 int irq; 55 int irq;
56 unsigned int block_pos; 56 unsigned int block_pos;
57 unsigned long timeout_jiffies; 57 unsigned long timeout_jiffies;
@@ -781,7 +781,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
781 781
782 spin_lock_init(&host->lock); 782 spin_lock_init(&host->lock);
783 host->id = cnt; 783 host->id = cnt;
784 snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d", 784 snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d",
785 host->id); 785 host->id);
786 host->irq = jm->pdev->irq; 786 host->irq = jm->pdev->irq;
787 host->timeout_jiffies = msecs_to_jiffies(1000); 787 host->timeout_jiffies = msecs_to_jiffies(1000);
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 75e599b85b64..34402c47027e 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1670 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); 1670 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
1671 spin_lock_init(&ioc->fault_reset_work_lock); 1671 spin_lock_init(&ioc->fault_reset_work_lock);
1672 1672
1673 snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id); 1673 snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name),
1674 "mpt_poll_%d", ioc->id);
1674 ioc->reset_work_q = 1675 ioc->reset_work_q =
1675 create_singlethread_workqueue(ioc->reset_work_q_name); 1676 create_singlethread_workqueue(ioc->reset_work_q_name);
1676 if (!ioc->reset_work_q) { 1677 if (!ioc->reset_work_q) {
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 6adab648dbb9..dff048cfa101 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER
707 u8 fc_link_speed[2]; 707 u8 fc_link_speed[2];
708 spinlock_t fc_rescan_work_lock; 708 spinlock_t fc_rescan_work_lock;
709 struct work_struct fc_rescan_work; 709 struct work_struct fc_rescan_work;
710 char fc_rescan_work_q_name[KOBJ_NAME_LEN]; 710 char fc_rescan_work_q_name[20];
711 struct workqueue_struct *fc_rescan_work_q; 711 struct workqueue_struct *fc_rescan_work_q;
712 struct scsi_cmnd **ScsiLookup; 712 struct scsi_cmnd **ScsiLookup;
713 spinlock_t scsi_lookup_lock; 713 spinlock_t scsi_lookup_lock;
714 714
715 char reset_work_q_name[KOBJ_NAME_LEN]; 715 char reset_work_q_name[20];
716 struct workqueue_struct *reset_work_q; 716 struct workqueue_struct *reset_work_q;
717 struct delayed_work fault_reset_work; 717 struct delayed_work fault_reset_work;
718 spinlock_t fault_reset_work_lock; 718 spinlock_t fault_reset_work_lock;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index fc31ca6829d8..b36cae9ec6db 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1326 1326
1327 /* initialize workqueue */ 1327 /* initialize workqueue */
1328 1328
1329 snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d", 1329 snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
1330 sh->host_no); 1330 "mptfc_wq_%d", sh->host_no);
1331 ioc->fc_rescan_work_q = 1331 ioc->fc_rescan_work_q =
1332 create_singlethread_workqueue(ioc->fc_rescan_work_q_name); 1332 create_singlethread_workqueue(ioc->fc_rescan_work_q_name);
1333 if (!ioc->fc_rescan_work_q) 1333 if (!ioc->fc_rescan_work_q)
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 1921b8dbb242..ce67d973d349 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -420,4 +420,17 @@ config SGI_XP
420 this feature will allow for direct communication between SSIs 420 this feature will allow for direct communication between SSIs
421 based on a network adapter and DMA messaging. 421 based on a network adapter and DMA messaging.
422 422
423config HP_ILO
424 tristate "Channel interface driver for HP iLO/iLO2 processor"
425 default n
426 help
427 The channel interface driver allows applications to communicate
428 with iLO/iLO2 management processors present on HP ProLiant
429 servers. Upon loading, the driver creates /dev/hpilo/dXccbN files,
430 which can be used to gather data from the management processor,
431 via read and write system calls.
432
433 To compile this driver as a module, choose M here: the
434 module will be called hpilo.
435
423endif # MISC_DEVICES 436endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index a6dac6a2e7e5..688fe76135e0 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -27,3 +27,4 @@ obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o
27obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o 27obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
28obj-$(CONFIG_KGDB_TESTS) += kgdbts.o 28obj-$(CONFIG_KGDB_TESTS) += kgdbts.o
29obj-$(CONFIG_SGI_XP) += sgi-xp/ 29obj-$(CONFIG_SGI_XP) += sgi-xp/
30obj-$(CONFIG_HP_ILO) += hpilo.o
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
new file mode 100644
index 000000000000..05e298289238
--- /dev/null
+++ b/drivers/misc/hpilo.c
@@ -0,0 +1,768 @@
1/*
2 * Driver for HP iLO/iLO2 management processor.
3 *
4 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5 * David Altobelli <david.altobelli@hp.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/module.h>
14#include <linux/fs.h>
15#include <linux/pci.h>
16#include <linux/ioport.h>
17#include <linux/device.h>
18#include <linux/file.h>
19#include <linux/cdev.h>
20#include <linux/spinlock.h>
21#include <linux/delay.h>
22#include <linux/uaccess.h>
23#include <linux/io.h>
24#include "hpilo.h"
25
26static struct class *ilo_class;
27static unsigned int ilo_major;
28static char ilo_hwdev[MAX_ILO_DEV];
29
30static inline int get_entry_id(int entry)
31{
32 return (entry & ENTRY_MASK_DESCRIPTOR) >> ENTRY_BITPOS_DESCRIPTOR;
33}
34
35static inline int get_entry_len(int entry)
36{
37 return ((entry & ENTRY_MASK_QWORDS) >> ENTRY_BITPOS_QWORDS) << 3;
38}
39
40static inline int mk_entry(int id, int len)
41{
42 int qlen = len & 7 ? (len >> 3) + 1 : len >> 3;
43 return id << ENTRY_BITPOS_DESCRIPTOR | qlen << ENTRY_BITPOS_QWORDS;
44}
45
46static inline int desc_mem_sz(int nr_entry)
47{
48 return nr_entry << L2_QENTRY_SZ;
49}
50
51/*
52 * FIFO queues, shared with hardware.
53 *
54 * If a queue has empty slots, an entry is added to the queue tail,
55 * and that entry is marked as occupied.
56 * Entries can be dequeued from the head of the list, when the device
57 * has marked the entry as consumed.
58 *
59 * Returns true on successful queue/dequeue, false on failure.
60 */
61static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
62{
63 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
64 int ret = 0;
65
66 spin_lock(&hw->fifo_lock);
67 if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask]
68 & ENTRY_MASK_O)) {
69 fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |=
70 (entry & ENTRY_MASK_NOSTATE) | fifo_q->merge;
71 fifo_q->tail += 1;
72 ret = 1;
73 }
74 spin_unlock(&hw->fifo_lock);
75
76 return ret;
77}
78
79static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
80{
81 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
82 int ret = 0;
83 u64 c;
84
85 spin_lock(&hw->fifo_lock);
86 c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
87 if (c & ENTRY_MASK_C) {
88 if (entry)
89 *entry = c & ENTRY_MASK_NOSTATE;
90
91 fifo_q->fifobar[fifo_q->head & fifo_q->imask] =
92 (c | ENTRY_MASK) + 1;
93 fifo_q->head += 1;
94 ret = 1;
95 }
96 spin_unlock(&hw->fifo_lock);
97
98 return ret;
99}
100
101static int ilo_pkt_enqueue(struct ilo_hwinfo *hw, struct ccb *ccb,
102 int dir, int id, int len)
103{
104 char *fifobar;
105 int entry;
106
107 if (dir == SENDQ)
108 fifobar = ccb->ccb_u1.send_fifobar;
109 else
110 fifobar = ccb->ccb_u3.recv_fifobar;
111
112 entry = mk_entry(id, len);
113 return fifo_enqueue(hw, fifobar, entry);
114}
115
116static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb,
117 int dir, int *id, int *len, void **pkt)
118{
119 char *fifobar, *desc;
120 int entry = 0, pkt_id = 0;
121 int ret;
122
123 if (dir == SENDQ) {
124 fifobar = ccb->ccb_u1.send_fifobar;
125 desc = ccb->ccb_u2.send_desc;
126 } else {
127 fifobar = ccb->ccb_u3.recv_fifobar;
128 desc = ccb->ccb_u4.recv_desc;
129 }
130
131 ret = fifo_dequeue(hw, fifobar, &entry);
132 if (ret) {
133 pkt_id = get_entry_id(entry);
134 if (id)
135 *id = pkt_id;
136 if (len)
137 *len = get_entry_len(entry);
138 if (pkt)
139 *pkt = (void *)(desc + desc_mem_sz(pkt_id));
140 }
141
142 return ret;
143}
144
145static inline void doorbell_set(struct ccb *ccb)
146{
147 iowrite8(1, ccb->ccb_u5.db_base);
148}
149
150static inline void doorbell_clr(struct ccb *ccb)
151{
152 iowrite8(2, ccb->ccb_u5.db_base);
153}
154static inline int ctrl_set(int l2sz, int idxmask, int desclim)
155{
156 int active = 0, go = 1;
157 return l2sz << CTRL_BITPOS_L2SZ |
158 idxmask << CTRL_BITPOS_FIFOINDEXMASK |
159 desclim << CTRL_BITPOS_DESCLIMIT |
160 active << CTRL_BITPOS_A |
161 go << CTRL_BITPOS_G;
162}
163static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz)
164{
165 /* for simplicity, use the same parameters for send and recv ctrls */
166 ccb->send_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
167 ccb->recv_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
168}
169
170static inline int fifo_sz(int nr_entry)
171{
172 /* size of a fifo is determined by the number of entries it contains */
173 return (nr_entry * sizeof(u64)) + FIFOHANDLESIZE;
174}
175
176static void fifo_setup(void *base_addr, int nr_entry)
177{
178 struct fifo *fifo_q = base_addr;
179 int i;
180
181 /* set up an empty fifo */
182 fifo_q->head = 0;
183 fifo_q->tail = 0;
184 fifo_q->reset = 0;
185 fifo_q->nrents = nr_entry;
186 fifo_q->imask = nr_entry - 1;
187 fifo_q->merge = ENTRY_MASK_O;
188
189 for (i = 0; i < nr_entry; i++)
190 fifo_q->fifobar[i] = 0;
191}
192
193static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
194{
195 struct ccb *driver_ccb;
196 struct ccb __iomem *device_ccb;
197 int retries;
198
199 driver_ccb = &data->driver_ccb;
200 device_ccb = data->mapped_ccb;
201
202 /* complicated dance to tell the hw we are stopping */
203 doorbell_clr(driver_ccb);
204 iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G),
205 &device_ccb->send_ctrl);
206 iowrite32(ioread32(&device_ccb->recv_ctrl) & ~(1 << CTRL_BITPOS_G),
207 &device_ccb->recv_ctrl);
208
209 /* give iLO some time to process stop request */
210 for (retries = 1000; retries > 0; retries--) {
211 doorbell_set(driver_ccb);
212 udelay(1);
213 if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A))
214 &&
215 !(ioread32(&device_ccb->recv_ctrl) & (1 << CTRL_BITPOS_A)))
216 break;
217 }
218 if (retries == 0)
219 dev_err(&pdev->dev, "Closing, but controller still active\n");
220
221 /* clear the hw ccb */
222 memset_io(device_ccb, 0, sizeof(struct ccb));
223
224 /* free resources used to back send/recv queues */
225 pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
226}
227
228static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
229{
230 char *dma_va, *dma_pa;
231 int pkt_id, pkt_sz, i, error;
232 struct ccb *driver_ccb, *ilo_ccb;
233 struct pci_dev *pdev;
234
235 driver_ccb = &data->driver_ccb;
236 ilo_ccb = &data->ilo_ccb;
237 pdev = hw->ilo_dev;
238
239 data->dma_size = 2 * fifo_sz(NR_QENTRY) +
240 2 * desc_mem_sz(NR_QENTRY) +
241 ILO_START_ALIGN + ILO_CACHE_SZ;
242
243 error = -ENOMEM;
244 data->dma_va = pci_alloc_consistent(pdev, data->dma_size,
245 &data->dma_pa);
246 if (!data->dma_va)
247 goto out;
248
249 dma_va = (char *)data->dma_va;
250 dma_pa = (char *)data->dma_pa;
251
252 memset(dma_va, 0, data->dma_size);
253
254 dma_va = (char *)roundup((unsigned long)dma_va, ILO_START_ALIGN);
255 dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_START_ALIGN);
256
257 /*
258 * Create two ccb's, one with virt addrs, one with phys addrs.
259 * Copy the phys addr ccb to device shared mem.
260 */
261 ctrl_setup(driver_ccb, NR_QENTRY, L2_QENTRY_SZ);
262 ctrl_setup(ilo_ccb, NR_QENTRY, L2_QENTRY_SZ);
263
264 fifo_setup(dma_va, NR_QENTRY);
265 driver_ccb->ccb_u1.send_fifobar = dma_va + FIFOHANDLESIZE;
266 ilo_ccb->ccb_u1.send_fifobar = dma_pa + FIFOHANDLESIZE;
267 dma_va += fifo_sz(NR_QENTRY);
268 dma_pa += fifo_sz(NR_QENTRY);
269
270 dma_va = (char *)roundup((unsigned long)dma_va, ILO_CACHE_SZ);
271 dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_CACHE_SZ);
272
273 fifo_setup(dma_va, NR_QENTRY);
274 driver_ccb->ccb_u3.recv_fifobar = dma_va + FIFOHANDLESIZE;
275 ilo_ccb->ccb_u3.recv_fifobar = dma_pa + FIFOHANDLESIZE;
276 dma_va += fifo_sz(NR_QENTRY);
277 dma_pa += fifo_sz(NR_QENTRY);
278
279 driver_ccb->ccb_u2.send_desc = dma_va;
280 ilo_ccb->ccb_u2.send_desc = dma_pa;
281 dma_pa += desc_mem_sz(NR_QENTRY);
282 dma_va += desc_mem_sz(NR_QENTRY);
283
284 driver_ccb->ccb_u4.recv_desc = dma_va;
285 ilo_ccb->ccb_u4.recv_desc = dma_pa;
286
287 driver_ccb->channel = slot;
288 ilo_ccb->channel = slot;
289
290 driver_ccb->ccb_u5.db_base = hw->db_vaddr + (slot << L2_DB_SIZE);
291 ilo_ccb->ccb_u5.db_base = NULL; /* hw ccb's doorbell is not used */
292
293 /* copy the ccb with physical addrs to device memory */
294 data->mapped_ccb = (struct ccb __iomem *)
295 (hw->ram_vaddr + (slot * ILOHW_CCB_SZ));
296 memcpy_toio(data->mapped_ccb, ilo_ccb, sizeof(struct ccb));
297
298 /* put packets on the send and receive queues */
299 pkt_sz = 0;
300 for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) {
301 ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, pkt_sz);
302 doorbell_set(driver_ccb);
303 }
304
305 pkt_sz = desc_mem_sz(1);
306 for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++)
307 ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz);
308
309 doorbell_clr(driver_ccb);
310
311 /* make sure iLO is really handling requests */
312 for (i = 1000; i > 0; i--) {
313 if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL))
314 break;
315 udelay(1);
316 }
317
318 if (i) {
319 ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0);
320 doorbell_set(driver_ccb);
321 } else {
322 dev_err(&pdev->dev, "Open could not dequeue a packet\n");
323 error = -EBUSY;
324 goto free;
325 }
326
327 return 0;
328free:
329 pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
330out:
331 return error;
332}
333
334static inline int is_channel_reset(struct ccb *ccb)
335{
336 /* check for this particular channel needing a reset */
337 return FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset;
338}
339
340static inline void set_channel_reset(struct ccb *ccb)
341{
342 /* set a flag indicating this channel needs a reset */
343 FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1;
344}
345
346static inline int is_device_reset(struct ilo_hwinfo *hw)
347{
348 /* check for global reset condition */
349 return ioread32(&hw->mmio_vaddr[DB_OUT]) & (1 << DB_RESET);
350}
351
352static inline void clear_device(struct ilo_hwinfo *hw)
353{
354 /* clear the device (reset bits, pending channel entries) */
355 iowrite32(-1, &hw->mmio_vaddr[DB_OUT]);
356}
357
358static void ilo_locked_reset(struct ilo_hwinfo *hw)
359{
360 int slot;
361
362 /*
363 * Mapped memory is zeroed on ilo reset, so set a per ccb flag
364 * to indicate that this ccb needs to be closed and reopened.
365 */
366 for (slot = 0; slot < MAX_CCB; slot++) {
367 if (!hw->ccb_alloc[slot])
368 continue;
369 set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb);
370 }
371
372 clear_device(hw);
373}
374
375static void ilo_reset(struct ilo_hwinfo *hw)
376{
377 spin_lock(&hw->alloc_lock);
378
379 /* reset might have been handled after lock was taken */
380 if (is_device_reset(hw))
381 ilo_locked_reset(hw);
382
383 spin_unlock(&hw->alloc_lock);
384}
385
386static ssize_t ilo_read(struct file *fp, char __user *buf,
387 size_t len, loff_t *off)
388{
389 int err, found, cnt, pkt_id, pkt_len;
390 struct ccb_data *data;
391 struct ccb *driver_ccb;
392 struct ilo_hwinfo *hw;
393 void *pkt;
394
395 data = fp->private_data;
396 driver_ccb = &data->driver_ccb;
397 hw = data->ilo_hw;
398
399 if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
400 /*
401 * If the device has been reset, applications
402 * need to close and reopen all ccbs.
403 */
404 ilo_reset(hw);
405 return -ENODEV;
406 }
407
408 /*
409 * This function is to be called when data is expected
410 * in the channel, and will return an error if no packet is found
411 * during the loop below. The sleep/retry logic is to allow
412 * applications to call read() immediately post write(),
413 * and give iLO some time to process the sent packet.
414 */
415 cnt = 20;
416 do {
417 /* look for a received packet */
418 found = ilo_pkt_dequeue(hw, driver_ccb, RECVQ, &pkt_id,
419 &pkt_len, &pkt);
420 if (found)
421 break;
422 cnt--;
423 msleep(100);
424 } while (!found && cnt);
425
426 if (!found)
427 return -EAGAIN;
428
429 /* only copy the length of the received packet */
430 if (pkt_len < len)
431 len = pkt_len;
432
433 err = copy_to_user(buf, pkt, len);
434
435 /* return the received packet to the queue */
436 ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1));
437
438 return err ? -EFAULT : len;
439}
440
441static ssize_t ilo_write(struct file *fp, const char __user *buf,
442 size_t len, loff_t *off)
443{
444 int err, pkt_id, pkt_len;
445 struct ccb_data *data;
446 struct ccb *driver_ccb;
447 struct ilo_hwinfo *hw;
448 void *pkt;
449
450 data = fp->private_data;
451 driver_ccb = &data->driver_ccb;
452 hw = data->ilo_hw;
453
454 if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
455 /*
456 * If the device has been reset, applications
457 * need to close and reopen all ccbs.
458 */
459 ilo_reset(hw);
460 return -ENODEV;
461 }
462
463 /* get a packet to send the user command */
464 if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt))
465 return -EBUSY;
466
467 /* limit the length to the length of the packet */
468 if (pkt_len < len)
469 len = pkt_len;
470
471 /* on failure, set the len to 0 to return empty packet to the device */
472 err = copy_from_user(pkt, buf, len);
473 if (err)
474 len = 0;
475
476 /* send the packet */
477 ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, len);
478 doorbell_set(driver_ccb);
479
480 return err ? -EFAULT : len;
481}
482
483static int ilo_close(struct inode *ip, struct file *fp)
484{
485 int slot;
486 struct ccb_data *data;
487 struct ilo_hwinfo *hw;
488
489 slot = iminor(ip) % MAX_CCB;
490 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
491
492 spin_lock(&hw->alloc_lock);
493
494 if (is_device_reset(hw))
495 ilo_locked_reset(hw);
496
497 if (hw->ccb_alloc[slot]->ccb_cnt == 1) {
498
499 data = fp->private_data;
500
501 ilo_ccb_close(hw->ilo_dev, data);
502
503 kfree(data);
504 hw->ccb_alloc[slot] = NULL;
505 } else
506 hw->ccb_alloc[slot]->ccb_cnt--;
507
508 spin_unlock(&hw->alloc_lock);
509
510 return 0;
511}
512
513static int ilo_open(struct inode *ip, struct file *fp)
514{
515 int slot, error;
516 struct ccb_data *data;
517 struct ilo_hwinfo *hw;
518
519 slot = iminor(ip) % MAX_CCB;
520 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
521
522 /* new ccb allocation */
523 data = kzalloc(sizeof(*data), GFP_KERNEL);
524 if (!data)
525 return -ENOMEM;
526
527 spin_lock(&hw->alloc_lock);
528
529 if (is_device_reset(hw))
530 ilo_locked_reset(hw);
531
532 /* each fd private_data holds sw/hw view of ccb */
533 if (hw->ccb_alloc[slot] == NULL) {
534 /* create a channel control block for this minor */
535 error = ilo_ccb_open(hw, data, slot);
536 if (!error) {
537 hw->ccb_alloc[slot] = data;
538 hw->ccb_alloc[slot]->ccb_cnt = 1;
539 hw->ccb_alloc[slot]->ccb_excl = fp->f_flags & O_EXCL;
540 hw->ccb_alloc[slot]->ilo_hw = hw;
541 } else
542 kfree(data);
543 } else {
544 kfree(data);
545 if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) {
546 /*
547 * The channel exists, and either this open
548 * or a previous open of this channel wants
549 * exclusive access.
550 */
551 error = -EBUSY;
552 } else {
553 hw->ccb_alloc[slot]->ccb_cnt++;
554 error = 0;
555 }
556 }
557 spin_unlock(&hw->alloc_lock);
558
559 if (!error)
560 fp->private_data = hw->ccb_alloc[slot];
561
562 return error;
563}
564
565static const struct file_operations ilo_fops = {
566 .owner = THIS_MODULE,
567 .read = ilo_read,
568 .write = ilo_write,
569 .open = ilo_open,
570 .release = ilo_close,
571};
572
573static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
574{
575 pci_iounmap(pdev, hw->db_vaddr);
576 pci_iounmap(pdev, hw->ram_vaddr);
577 pci_iounmap(pdev, hw->mmio_vaddr);
578}
579
580static int __devinit ilo_map_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
581{
582 int error = -ENOMEM;
583
584 /* map the memory mapped i/o registers */
585 hw->mmio_vaddr = pci_iomap(pdev, 1, 0);
586 if (hw->mmio_vaddr == NULL) {
587 dev_err(&pdev->dev, "Error mapping mmio\n");
588 goto out;
589 }
590
591 /* map the adapter shared memory region */
592 hw->ram_vaddr = pci_iomap(pdev, 2, MAX_CCB * ILOHW_CCB_SZ);
593 if (hw->ram_vaddr == NULL) {
594 dev_err(&pdev->dev, "Error mapping shared mem\n");
595 goto mmio_free;
596 }
597
598 /* map the doorbell aperture */
599 hw->db_vaddr = pci_iomap(pdev, 3, MAX_CCB * ONE_DB_SIZE);
600 if (hw->db_vaddr == NULL) {
601 dev_err(&pdev->dev, "Error mapping doorbell\n");
602 goto ram_free;
603 }
604
605 return 0;
606ram_free:
607 pci_iounmap(pdev, hw->ram_vaddr);
608mmio_free:
609 pci_iounmap(pdev, hw->mmio_vaddr);
610out:
611 return error;
612}
613
614static void ilo_remove(struct pci_dev *pdev)
615{
616 int i, minor;
617 struct ilo_hwinfo *ilo_hw = pci_get_drvdata(pdev);
618
619 clear_device(ilo_hw);
620
621 minor = MINOR(ilo_hw->cdev.dev);
622 for (i = minor; i < minor + MAX_CCB; i++)
623 device_destroy(ilo_class, MKDEV(ilo_major, i));
624
625 cdev_del(&ilo_hw->cdev);
626 ilo_unmap_device(pdev, ilo_hw);
627 pci_release_regions(pdev);
628 pci_disable_device(pdev);
629 kfree(ilo_hw);
630 ilo_hwdev[(minor / MAX_CCB)] = 0;
631}
632
633static int __devinit ilo_probe(struct pci_dev *pdev,
634 const struct pci_device_id *ent)
635{
636 int devnum, minor, start, error;
637 struct ilo_hwinfo *ilo_hw;
638
639 /* find a free range for device files */
640 for (devnum = 0; devnum < MAX_ILO_DEV; devnum++) {
641 if (ilo_hwdev[devnum] == 0) {
642 ilo_hwdev[devnum] = 1;
643 break;
644 }
645 }
646
647 if (devnum == MAX_ILO_DEV) {
648 dev_err(&pdev->dev, "Error finding free device\n");
649 return -ENODEV;
650 }
651
652 /* track global allocations for this device */
653 error = -ENOMEM;
654 ilo_hw = kzalloc(sizeof(*ilo_hw), GFP_KERNEL);
655 if (!ilo_hw)
656 goto out;
657
658 ilo_hw->ilo_dev = pdev;
659 spin_lock_init(&ilo_hw->alloc_lock);
660 spin_lock_init(&ilo_hw->fifo_lock);
661
662 error = pci_enable_device(pdev);
663 if (error)
664 goto free;
665
666 pci_set_master(pdev);
667
668 error = pci_request_regions(pdev, ILO_NAME);
669 if (error)
670 goto disable;
671
672 error = ilo_map_device(pdev, ilo_hw);
673 if (error)
674 goto free_regions;
675
676 pci_set_drvdata(pdev, ilo_hw);
677 clear_device(ilo_hw);
678
679 cdev_init(&ilo_hw->cdev, &ilo_fops);
680 ilo_hw->cdev.owner = THIS_MODULE;
681 start = devnum * MAX_CCB;
682 error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB);
683 if (error) {
684 dev_err(&pdev->dev, "Could not add cdev\n");
685 goto unmap;
686 }
687
688 for (minor = 0 ; minor < MAX_CCB; minor++) {
689 struct device *dev;
690 dev = device_create(ilo_class, &pdev->dev,
691 MKDEV(ilo_major, minor), NULL,
692 "hpilo!d%dccb%d", devnum, minor);
693 if (IS_ERR(dev))
694 dev_err(&pdev->dev, "Could not create files\n");
695 }
696
697 return 0;
698unmap:
699 ilo_unmap_device(pdev, ilo_hw);
700free_regions:
701 pci_release_regions(pdev);
702disable:
703 pci_disable_device(pdev);
704free:
705 kfree(ilo_hw);
706out:
707 ilo_hwdev[devnum] = 0;
708 return error;
709}
710
711static struct pci_device_id ilo_devices[] = {
712 { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
713 { }
714};
715MODULE_DEVICE_TABLE(pci, ilo_devices);
716
717static struct pci_driver ilo_driver = {
718 .name = ILO_NAME,
719 .id_table = ilo_devices,
720 .probe = ilo_probe,
721 .remove = __devexit_p(ilo_remove),
722};
723
724static int __init ilo_init(void)
725{
726 int error;
727 dev_t dev;
728
729 ilo_class = class_create(THIS_MODULE, "iLO");
730 if (IS_ERR(ilo_class)) {
731 error = PTR_ERR(ilo_class);
732 goto out;
733 }
734
735 error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME);
736 if (error)
737 goto class_destroy;
738
739 ilo_major = MAJOR(dev);
740
741 error = pci_register_driver(&ilo_driver);
742 if (error)
743 goto chr_remove;
744
745 return 0;
746chr_remove:
747 unregister_chrdev_region(dev, MAX_OPEN);
748class_destroy:
749 class_destroy(ilo_class);
750out:
751 return error;
752}
753
754static void __exit ilo_exit(void)
755{
756 pci_unregister_driver(&ilo_driver);
757 unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN);
758 class_destroy(ilo_class);
759}
760
761MODULE_VERSION("0.05");
762MODULE_ALIAS(ILO_NAME);
763MODULE_DESCRIPTION(ILO_NAME);
764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
765MODULE_LICENSE("GPL v2");
766
767module_init(ilo_init);
768module_exit(ilo_exit);
diff --git a/drivers/misc/hpilo.h b/drivers/misc/hpilo.h
new file mode 100644
index 000000000000..a281207696c1
--- /dev/null
+++ b/drivers/misc/hpilo.h
@@ -0,0 +1,189 @@
1/*
2 * linux/drivers/char/hpilo.h
3 *
4 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5 * David Altobelli <david.altobelli@hp.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __HPILO_H
12#define __HPILO_H
13
14#define ILO_NAME "hpilo"
15
16/* max number of open channel control blocks per device, hw limited to 32 */
17#define MAX_CCB 8
18/* max number of supported devices */
19#define MAX_ILO_DEV 1
20/* max number of files */
21#define MAX_OPEN (MAX_CCB * MAX_ILO_DEV)
22
23/*
24 * Per device, used to track global memory allocations.
25 */
26struct ilo_hwinfo {
27 /* mmio registers on device */
28 char __iomem *mmio_vaddr;
29
30 /* doorbell registers on device */
31 char __iomem *db_vaddr;
32
33 /* shared memory on device used for channel control blocks */
34 char __iomem *ram_vaddr;
35
36 /* files corresponding to this device */
37 struct ccb_data *ccb_alloc[MAX_CCB];
38
39 struct pci_dev *ilo_dev;
40
41 spinlock_t alloc_lock;
42 spinlock_t fifo_lock;
43
44 struct cdev cdev;
45};
46
47/* offset from mmio_vaddr */
48#define DB_OUT 0xD4
49/* DB_OUT reset bit */
50#define DB_RESET 26
51
52/*
53 * Channel control block. Used to manage hardware queues.
54 * The format must match hw's version. The hw ccb is 128 bytes,
55 * but the context area shouldn't be touched by the driver.
56 */
57#define ILOSW_CCB_SZ 64
58#define ILOHW_CCB_SZ 128
59struct ccb {
60 union {
61 char *send_fifobar;
62 u64 padding1;
63 } ccb_u1;
64 union {
65 char *send_desc;
66 u64 padding2;
67 } ccb_u2;
68 u64 send_ctrl;
69
70 union {
71 char *recv_fifobar;
72 u64 padding3;
73 } ccb_u3;
74 union {
75 char *recv_desc;
76 u64 padding4;
77 } ccb_u4;
78 u64 recv_ctrl;
79
80 union {
81 char __iomem *db_base;
82 u64 padding5;
83 } ccb_u5;
84
85 u64 channel;
86
87 /* unused context area (64 bytes) */
88};
89
90/* ccb queue parameters */
91#define SENDQ 1
92#define RECVQ 2
93#define NR_QENTRY 4
94#define L2_QENTRY_SZ 12
95
96/* ccb ctrl bitfields */
97#define CTRL_BITPOS_L2SZ 0
98#define CTRL_BITPOS_FIFOINDEXMASK 4
99#define CTRL_BITPOS_DESCLIMIT 18
100#define CTRL_BITPOS_A 30
101#define CTRL_BITPOS_G 31
102
103/* ccb doorbell macros */
104#define L2_DB_SIZE 14
105#define ONE_DB_SIZE (1 << L2_DB_SIZE)
106
107/*
108 * Per fd structure used to track the ccb allocated to that dev file.
109 */
110struct ccb_data {
111 /* software version of ccb, using virtual addrs */
112 struct ccb driver_ccb;
113
114 /* hardware version of ccb, using physical addrs */
115 struct ccb ilo_ccb;
116
117 /* hardware ccb is written to this shared mapped device memory */
118 struct ccb __iomem *mapped_ccb;
119
120 /* dma'able memory used for send/recv queues */
121 void *dma_va;
122 dma_addr_t dma_pa;
123 size_t dma_size;
124
125 /* pointer to hardware device info */
126 struct ilo_hwinfo *ilo_hw;
127
128 /* usage count, to allow for shared ccb's */
129 int ccb_cnt;
130
131 /* open wanted exclusive access to this ccb */
132 int ccb_excl;
133};
134
135/*
136 * FIFO queue structure, shared with hw.
137 */
138#define ILO_START_ALIGN 4096
139#define ILO_CACHE_SZ 128
140struct fifo {
141 u64 nrents; /* user requested number of fifo entries */
142 u64 imask; /* mask to extract valid fifo index */
143 u64 merge; /* O/C bits to merge in during enqueue operation */
144 u64 reset; /* set to non-zero when the target device resets */
145 u8 pad_0[ILO_CACHE_SZ - (sizeof(u64) * 4)];
146
147 u64 head;
148 u8 pad_1[ILO_CACHE_SZ - (sizeof(u64))];
149
150 u64 tail;
151 u8 pad_2[ILO_CACHE_SZ - (sizeof(u64))];
152
153 u64 fifobar[1];
154};
155
156/* convert between struct fifo, and the fifobar, which is saved in the ccb */
157#define FIFOHANDLESIZE (sizeof(struct fifo) - sizeof(u64))
158#define FIFOBARTOHANDLE(_fifo) \
159 ((struct fifo *)(((char *)(_fifo)) - FIFOHANDLESIZE))
160
161/* the number of qwords to consume from the entry descriptor */
162#define ENTRY_BITPOS_QWORDS 0
163/* descriptor index number (within a specified queue) */
164#define ENTRY_BITPOS_DESCRIPTOR 10
165/* state bit, fifo entry consumed by consumer */
166#define ENTRY_BITPOS_C 22
167/* state bit, fifo entry is occupied */
168#define ENTRY_BITPOS_O 23
169
170#define ENTRY_BITS_QWORDS 10
171#define ENTRY_BITS_DESCRIPTOR 12
172#define ENTRY_BITS_C 1
173#define ENTRY_BITS_O 1
174#define ENTRY_BITS_TOTAL \
175 (ENTRY_BITS_C + ENTRY_BITS_O + \
176 ENTRY_BITS_QWORDS + ENTRY_BITS_DESCRIPTOR)
177
178/* extract various entry fields */
179#define ENTRY_MASK ((1 << ENTRY_BITS_TOTAL) - 1)
180#define ENTRY_MASK_C (((1 << ENTRY_BITS_C) - 1) << ENTRY_BITPOS_C)
181#define ENTRY_MASK_O (((1 << ENTRY_BITS_O) - 1) << ENTRY_BITPOS_O)
182#define ENTRY_MASK_QWORDS \
183 (((1 << ENTRY_BITS_QWORDS) - 1) << ENTRY_BITPOS_QWORDS)
184#define ENTRY_MASK_DESCRIPTOR \
185 (((1 << ENTRY_BITS_DESCRIPTOR) - 1) << ENTRY_BITPOS_DESCRIPTOR)
186
187#define ENTRY_MASK_NOSTATE (ENTRY_MASK >> (ENTRY_BITS_C + ENTRY_BITS_O))
188
189#endif /* __HPILO_H */
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index 186162470090..4ce3bdc2f959 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -399,8 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev,
399 goto err_irq; 399 goto err_irq;
400 } 400 }
401 401
402 if (IS_ERR(device_create(phantom_class, &pdev->dev, MKDEV(phantom_major, 402 if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev,
403 minor), "phantom%u", minor))) 403 MKDEV(phantom_major, minor),
404 NULL, "phantom%u", minor)))
404 dev_err(&pdev->dev, "can't create device\n"); 405 dev_err(&pdev->dev, "can't create device\n");
405 406
406 pci_set_drvdata(pdev, pht); 407 pci_set_drvdata(pdev, pht);
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 519d942e7940..7b72a1b36115 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
241{ 241{
242 struct block_device *bdev; 242 struct block_device *bdev;
243 struct block2mtd_dev *dev; 243 struct block2mtd_dev *dev;
244 char *name;
244 245
245 if (!devname) 246 if (!devname)
246 return NULL; 247 return NULL;
@@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
279 280
280 /* Setup the MTD structure */ 281 /* Setup the MTD structure */
281 /* make the name contain the block device in */ 282 /* make the name contain the block device in */
282 dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname), 283 name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
283 GFP_KERNEL); 284 GFP_KERNEL);
284 if (!dev->mtd.name) 285 if (!name)
285 goto devinit_err; 286 goto devinit_err;
286 287
287 sprintf(dev->mtd.name, "block2mtd: %s", devname); 288 sprintf(name, "block2mtd: %s", devname);
289 dev->mtd.name = name;
288 290
289 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; 291 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
290 dev->mtd.erasesize = erase_size; 292 dev->mtd.erasesize = erase_size;
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 129d429cd2da..aef9f4b687c9 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -28,10 +28,13 @@ static void mtd_notify_add(struct mtd_info* mtd)
28 if (!mtd) 28 if (!mtd)
29 return; 29 return;
30 30
31 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), "mtd%d", mtd->index); 31 device_create_drvdata(mtd_class, NULL,
32 MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
33 NULL, "mtd%d", mtd->index);
32 34
33 device_create(mtd_class, NULL, 35 device_create_drvdata(mtd_class, NULL,
34 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), "mtd%dro", mtd->index); 36 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
37 NULL, "mtd%dro", mtd->index);
35} 38}
36 39
37static void mtd_notify_remove(struct mtd_info* mtd) 40static void mtd_notify_remove(struct mtd_info* mtd)
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index aabad8ce7458..8db4e6b89482 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1010,7 +1010,7 @@ static int __devinit vortex_probe1(struct device *gendev,
1010 static int printed_version; 1010 static int printed_version;
1011 int retval, print_info; 1011 int retval, print_info;
1012 struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx]; 1012 struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx];
1013 char *print_name = "3c59x"; 1013 const char *print_name = "3c59x";
1014 struct pci_dev *pdev = NULL; 1014 struct pci_dev *pdev = NULL;
1015 struct eisa_device *edev = NULL; 1015 struct eisa_device *edev = NULL;
1016 DECLARE_MAC_BUF(mac); 1016 DECLARE_MAC_BUF(mac);
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 1e39e78f1778..71f7cec30911 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -677,7 +677,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
677{ 677{
678 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 678 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
679 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 679 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
680 strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info)); 680 strlcpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
681} 681}
682 682
683static const struct ethtool_ops at91ether_ethtool_ops = { 683static const struct ethtool_ops at91ether_ethtool_ops = {
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index ecd8fc6146e9..7a14980f3472 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -848,7 +848,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
848 848
849 ep->res = request_mem_region(pdev->resource[0].start, 849 ep->res = request_mem_region(pdev->resource[0].start,
850 pdev->resource[0].end - pdev->resource[0].start + 1, 850 pdev->resource[0].end - pdev->resource[0].start + 1,
851 pdev->dev.bus_id); 851 dev_name(&pdev->dev));
852 if (ep->res == NULL) { 852 if (ep->res == NULL) {
853 dev_err(&pdev->dev, "Could not reserve memory region\n"); 853 dev_err(&pdev->dev, "Could not reserve memory region\n");
854 err = -ENOMEM; 854 err = -ENOMEM;
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index e9d15eccad08..5c5f1e470d3c 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -535,7 +535,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec)
535 535
536 if (!ecard_readchunk(&cd, ec, 0xf5, 0)) { 536 if (!ecard_readchunk(&cd, ec, 0xf5, 0)) {
537 printk(KERN_ERR "%s: unable to read podule description string\n", 537 printk(KERN_ERR "%s: unable to read podule description string\n",
538 ec->dev.bus_id); 538 dev_name(&ec->dev));
539 goto no_addr; 539 goto no_addr;
540 } 540 }
541 541
@@ -554,7 +554,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec)
554 } 554 }
555 555
556 printk(KERN_ERR "%s: unable to parse MAC address: %s\n", 556 printk(KERN_ERR "%s: unable to parse MAC address: %s\n",
557 ec->dev.bus_id, cd.d.string); 557 dev_name(&ec->dev), cd.d.string);
558 558
559 no_addr: 559 no_addr:
560 return -ENODEV; 560 return -ENODEV;
@@ -585,7 +585,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
585{ 585{
586 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 586 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
587 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 587 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
588 strlcpy(info->bus_info, dev->dev.parent->bus_id, 588 strlcpy(info->bus_info, dev_name(dev->dev.parent),
589 sizeof(info->bus_info)); 589 sizeof(info->bus_info));
590} 590}
591 591
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 6b1d7a8edf15..739b3ab7bccc 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -866,7 +866,8 @@ static int __init ppp_init(void)
866 err = PTR_ERR(ppp_class); 866 err = PTR_ERR(ppp_class);
867 goto out_chrdev; 867 goto out_chrdev;
868 } 868 }
869 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp"); 869 device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0),
870 NULL, "ppp");
870 } 871 }
871 872
872out: 873out:
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 5827324e9d9f..f7d3349dc3ec 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -397,9 +397,9 @@ static int __init cosa_init(void)
397 err = PTR_ERR(cosa_class); 397 err = PTR_ERR(cosa_class);
398 goto out_chrdev; 398 goto out_chrdev;
399 } 399 }
400 for (i=0; i<nr_cards; i++) { 400 for (i = 0; i < nr_cards; i++)
401 device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i); 401 device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i),
402 } 402 NULL, "cosa%d", i);
403 err = 0; 403 err = 0;
404 goto out; 404 goto out;
405 405
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index eecf7cbf4139..5a58b075dd8d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -36,7 +36,7 @@
36#define _ACPIPHP_H 36#define _ACPIPHP_H
37 37
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/kobject.h> /* for KOBJ_NAME_LEN */ 39#include <linux/kobject.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/pci_hotplug.h> 41#include <linux/pci_hotplug.h>
42 42
@@ -51,7 +51,7 @@
51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
52 52
53/* name size which is used for entries in pcihpfs */ 53/* name size which is used for entries in pcihpfs */
54#define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */ 54#define SLOT_NAME_SIZE 20 /* {_SUN} */
55 55
56struct acpiphp_bridge; 56struct acpiphp_bridge;
57struct acpiphp_slot; 57struct acpiphp_slot;
diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c
index a4892275659d..936bae560fa1 100644
--- a/drivers/power/apm_power.c
+++ b/drivers/power/apm_power.c
@@ -78,7 +78,7 @@ static void find_main_battery(void)
78 main_battery = NULL; 78 main_battery = NULL;
79 bp.main = main_battery; 79 bp.main = main_battery;
80 80
81 error = class_for_each_device(power_supply_class, &bp, 81 error = class_for_each_device(power_supply_class, NULL, &bp,
82 __find_main_battery); 82 __find_main_battery);
83 if (error) { 83 if (error) {
84 main_battery = bp.main; 84 main_battery = bp.main;
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index af1633eb3b70..cb1ccb472921 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -41,7 +41,7 @@ static void power_supply_changed_work(struct work_struct *work)
41 41
42 dev_dbg(psy->dev, "%s\n", __func__); 42 dev_dbg(psy->dev, "%s\n", __func__);
43 43
44 class_for_each_device(power_supply_class, psy, 44 class_for_each_device(power_supply_class, NULL, psy,
45 __power_supply_changed_work); 45 __power_supply_changed_work);
46 46
47 power_supply_update_leds(psy); 47 power_supply_update_leds(psy);
@@ -79,7 +79,7 @@ int power_supply_am_i_supplied(struct power_supply *psy)
79{ 79{
80 int error; 80 int error;
81 81
82 error = class_for_each_device(power_supply_class, psy, 82 error = class_for_each_device(power_supply_class, NULL, psy,
83 __power_supply_am_i_supplied); 83 __power_supply_am_i_supplied);
84 84
85 dev_dbg(psy->dev, "%s %d\n", __func__, error); 85 dev_dbg(psy->dev, "%s %d\n", __func__, error);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 58b7336640ff..d397fa5f3a91 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name)
345 struct device *dev; 345 struct device *dev;
346 struct rtc_device *rtc = NULL; 346 struct rtc_device *rtc = NULL;
347 347
348 dev = class_find_device(rtc_class, name, __rtc_match); 348 dev = class_find_device(rtc_class, NULL, name, __rtc_match);
349 if (dev) 349 if (dev)
350 rtc = to_rtc_device(dev); 350 rtc = to_rtc_device(dev);
351 351
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 81a96e019080..c3dee900a5c8 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1168,17 +1168,19 @@ static int raw3270_create_attributes(struct raw3270 *rp)
1168 if (rc) 1168 if (rc)
1169 goto out; 1169 goto out;
1170 1170
1171 rp->clttydev = device_create(class3270, &rp->cdev->dev, 1171 rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev,
1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor), 1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor),
1173 "tty%s", rp->cdev->dev.bus_id); 1173 NULL,
1174 "tty%s", rp->cdev->dev.bus_id);
1174 if (IS_ERR(rp->clttydev)) { 1175 if (IS_ERR(rp->clttydev)) {
1175 rc = PTR_ERR(rp->clttydev); 1176 rc = PTR_ERR(rp->clttydev);
1176 goto out_ttydev; 1177 goto out_ttydev;
1177 } 1178 }
1178 1179
1179 rp->cltubdev = device_create(class3270, &rp->cdev->dev, 1180 rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev,
1180 MKDEV(IBM_FS3270_MAJOR, rp->minor), 1181 MKDEV(IBM_FS3270_MAJOR, rp->minor),
1181 "tub%s", rp->cdev->dev.bus_id); 1182 NULL,
1183 "tub%s", rp->cdev->dev.bus_id);
1182 if (!IS_ERR(rp->cltubdev)) 1184 if (!IS_ERR(rp->cltubdev))
1183 goto out; 1185 goto out;
1184 1186
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index 6dfdb7c17981..12c2a5aaf31b 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -69,10 +69,9 @@ struct tape_class_device *register_tape_dev(
69 if (rc) 69 if (rc)
70 goto fail_with_cdev; 70 goto fail_with_cdev;
71 71
72 tcd->class_device = device_create(tape_class, device, 72 tcd->class_device = device_create_drvdata(tape_class, device,
73 tcd->char_device->dev, 73 tcd->char_device->dev,
74 "%s", tcd->device_name 74 NULL, "%s", tcd->device_name);
75 );
76 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0; 75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
77 if (rc) 76 if (rc)
78 goto fail_with_cdev; 77 goto fail_with_cdev;
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index b0ac44b27127..c1f352b84868 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -896,8 +896,9 @@ static int ur_set_online(struct ccw_device *cdev)
896 goto fail_free_cdev; 896 goto fail_free_cdev;
897 } 897 }
898 898
899 urd->device = device_create(vmur_class, NULL, urd->char_device->dev, 899 urd->device = device_create_drvdata(vmur_class, NULL,
900 "%s", node_id); 900 urd->char_device->dev, NULL,
901 "%s", node_id);
901 if (IS_ERR(urd->device)) { 902 if (IS_ERR(urd->device)) {
902 rc = PTR_ERR(urd->device); 903 rc = PTR_ERR(urd->device);
903 TRACE("ur_set_online: device_create rc=%d\n", rc); 904 TRACE("ur_set_online: device_create rc=%d\n", rc);
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index c37d7c2587ff..73a86d09bba8 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -78,7 +78,7 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
78 else 78 else
79 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; 79 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
80 sdev->ofdev.dev.bus = &sbus_bus_type; 80 sdev->ofdev.dev.bus = &sbus_bus_type;
81 sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node); 81 dev_set_name(&sdev->ofdev.dev, "sbus[%08x]", dp->node);
82 82
83 if (of_device_register(&sdev->ofdev) != 0) 83 if (of_device_register(&sdev->ofdev) != 0)
84 printk(KERN_DEBUG "sbus: device registration error for %s!\n", 84 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
@@ -257,11 +257,11 @@ static void __init build_one_sbus(struct device_node *dp, int num_sbus)
257 sbus->ofdev.node = dp; 257 sbus->ofdev.node = dp;
258 sbus->ofdev.dev.parent = NULL; 258 sbus->ofdev.dev.parent = NULL;
259 sbus->ofdev.dev.bus = &sbus_bus_type; 259 sbus->ofdev.dev.bus = &sbus_bus_type;
260 sprintf(sbus->ofdev.dev.bus_id, "sbus%d", num_sbus); 260 dev_set_name(&sbus->ofdev.dev, "sbus%d", num_sbus);
261 261
262 if (of_device_register(&sbus->ofdev) != 0) 262 if (of_device_register(&sbus->ofdev) != 0)
263 printk(KERN_DEBUG "sbus: device registration error for %s!\n", 263 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
264 sbus->ofdev.dev.bus_id); 264 dev_name(&sbus->ofdev.dev));
265 265
266 dev_dp = dp->child; 266 dev_dp = dp->child;
267 while (dev_dp) { 267 while (dev_dp) {
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 2bc30e32b67a..1fe0901e8119 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -271,8 +271,8 @@ rebuild_sys_tab:
271 pHba->initialized = TRUE; 271 pHba->initialized = TRUE;
272 pHba->state &= ~DPTI_STATE_RESET; 272 pHba->state &= ~DPTI_STATE_RESET;
273 if (adpt_sysfs_class) { 273 if (adpt_sysfs_class) {
274 struct device *dev = device_create(adpt_sysfs_class, 274 struct device *dev = device_create_drvdata(adpt_sysfs_class,
275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), 275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
276 "dpti%d", pHba->unit); 276 "dpti%d", pHba->unit);
277 if (IS_ERR(dev)) { 277 if (IS_ERR(dev)) {
278 printk(KERN_WARNING"dpti%d: unable to " 278 printk(KERN_WARNING"dpti%d: unable to "
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 35cd892dce04..fed0b02ebc1d 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -232,8 +232,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
232 } 232 }
233 233
234 if (shost->transportt->create_work_queue) { 234 if (shost->transportt->create_work_queue) {
235 snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d", 235 snprintf(shost->work_q_name, sizeof(shost->work_q_name),
236 shost->host_no); 236 "scsi_wq_%d", shost->host_no);
237 shost->work_q = create_singlethread_workqueue( 237 shost->work_q = create_singlethread_workqueue(
238 shost->work_q_name); 238 shost->work_q_name);
239 if (!shost->work_q) { 239 if (!shost->work_q) {
@@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
466 struct device *cdev; 466 struct device *cdev;
467 struct Scsi_Host *shost = ERR_PTR(-ENXIO); 467 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
468 468
469 cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); 469 cdev = class_find_device(&shost_class, NULL, &hostnum,
470 __scsi_host_match);
470 if (cdev) { 471 if (cdev) {
471 shost = scsi_host_get(class_to_shost(cdev)); 472 shost = scsi_host_get(class_to_shost(cdev));
472 put_device(cdev); 473 put_device(cdev);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 5fd64e70029d..a272b9a2c869 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -417,15 +417,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
417 fc_host->next_vport_number = 0; 417 fc_host->next_vport_number = 0;
418 fc_host->npiv_vports_inuse = 0; 418 fc_host->npiv_vports_inuse = 0;
419 419
420 snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d", 420 snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
421 shost->host_no); 421 "fc_wq_%d", shost->host_no);
422 fc_host->work_q = create_singlethread_workqueue( 422 fc_host->work_q = create_singlethread_workqueue(
423 fc_host->work_q_name); 423 fc_host->work_q_name);
424 if (!fc_host->work_q) 424 if (!fc_host->work_q)
425 return -ENOMEM; 425 return -ENOMEM;
426 426
427 snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d", 427 snprintf(fc_host->devloss_work_q_name,
428 shost->host_no); 428 sizeof(fc_host->devloss_work_q_name),
429 "fc_dl_%d", shost->host_no);
429 fc_host->devloss_work_q = create_singlethread_workqueue( 430 fc_host->devloss_work_q = create_singlethread_workqueue(
430 fc_host->devloss_work_q_name); 431 fc_host->devloss_work_q_name);
431 if (!fc_host->devloss_work_q) { 432 if (!fc_host->devloss_work_q) {
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 3af7cbcc5c5d..043c3921164f 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size)
170 int err; 170 int err;
171 171
172 for (id = 1; id < ISCSI_MAX_EPID; id++) { 172 for (id = 1; id < ISCSI_MAX_EPID; id++) {
173 dev = class_find_device(&iscsi_endpoint_class, &id, 173 dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
174 iscsi_match_epid); 174 iscsi_match_epid);
175 if (!dev) 175 if (!dev)
176 break; 176 break;
@@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
222 struct iscsi_endpoint *ep; 222 struct iscsi_endpoint *ep;
223 struct device *dev; 223 struct device *dev;
224 224
225 dev = class_find_device(&iscsi_endpoint_class, &handle, 225 dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
226 iscsi_match_epid); 226 iscsi_match_epid);
227 if (!dev) 227 if (!dev)
228 return NULL; 228 return NULL;
@@ -247,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
247 atomic_set(&ihost->nr_scans, 0); 247 atomic_set(&ihost->nr_scans, 0);
248 mutex_init(&ihost->mutex); 248 mutex_init(&ihost->mutex);
249 249
250 snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d", 250 snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name),
251 shost->host_no); 251 "iscsi_scan_%d", shost->host_no);
252 ihost->scan_workq = create_singlethread_workqueue( 252 ihost->scan_workq = create_singlethread_workqueue(
253 ihost->scan_workq_name); 253 ihost->scan_workq_name);
254 if (!ihost->scan_workq) 254 if (!ihost->scan_workq)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 1ad12afc6ba0..1771b2456bfa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
502 struct device *dev; 502 struct device *dev;
503 struct spi_master *master = NULL; 503 struct spi_master *master = NULL;
504 504
505 dev = class_find_device(&spi_master_class, &bus_num, 505 dev = class_find_device(&spi_master_class, NULL, &bus_num,
506 __spi_master_match); 506 __spi_master_match);
507 if (dev) 507 if (dev)
508 master = container_of(dev, struct spi_master, dev); 508 master = container_of(dev, struct spi_master, dev);
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index ddbe1a5e970e..2833fd772a24 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -576,7 +576,8 @@ static int spidev_probe(struct spi_device *spi)
576 struct device *dev; 576 struct device *dev;
577 577
578 spidev->devt = MKDEV(SPIDEV_MAJOR, minor); 578 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
579 dev = device_create(spidev_class, &spi->dev, spidev->devt, 579 dev = device_create_drvdata(spidev_class, &spi->dev,
580 spidev->devt, spidev,
580 "spidev%d.%d", 581 "spidev%d.%d",
581 spi->master->bus_num, spi->chip_select); 582 spi->master->bus_num, spi->chip_select);
582 status = IS_ERR(dev) ? PTR_ERR(dev) : 0; 583 status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
@@ -586,7 +587,6 @@ static int spidev_probe(struct spi_device *spi)
586 } 587 }
587 if (status == 0) { 588 if (status == 0) {
588 set_bit(minor, minors); 589 set_bit(minor, minors);
589 spi_set_drvdata(spi, spidev);
590 list_add(&spidev->device_entry, &device_list); 590 list_add(&spidev->device_entry, &device_list);
591 } 591 }
592 mutex_unlock(&device_list_lock); 592 mutex_unlock(&device_list_lock);
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index a4aaab9c7ddc..2e9079df26b3 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -15,7 +15,7 @@ if UIO
15 15
16config UIO_CIF 16config UIO_CIF
17 tristate "generic Hilscher CIF Card driver" 17 tristate "generic Hilscher CIF Card driver"
18 depends on UIO && PCI 18 depends on PCI
19 default n 19 default n
20 help 20 help
21 Driver for Hilscher CIF DeviceNet and Profibus cards. This 21 Driver for Hilscher CIF DeviceNet and Profibus cards. This
@@ -26,9 +26,15 @@ config UIO_CIF
26 To compile this driver as a module, choose M here: the module 26 To compile this driver as a module, choose M here: the module
27 will be called uio_cif. 27 will be called uio_cif.
28 28
29config UIO_PDRV
30 tristate "Userspace I/O platform driver"
31 help
32 Generic platform driver for Userspace I/O devices.
33
34 If you don't know what to do here, say N.
35
29config UIO_SMX 36config UIO_SMX
30 tristate "SMX cryptengine UIO interface" 37 tristate "SMX cryptengine UIO interface"
31 depends on UIO
32 default n 38 default n
33 help 39 help
34 Userspace IO interface to the Cryptography engine found on the 40 Userspace IO interface to the Cryptography engine found on the
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 18c45662431e..e00ce0def1a0 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_UIO) += uio.o 1obj-$(CONFIG_UIO) += uio.o
2obj-$(CONFIG_UIO_CIF) += uio_cif.o 2obj-$(CONFIG_UIO_CIF) += uio_cif.o
3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
3obj-$(CONFIG_UIO_SMX) += uio_smx.o 4obj-$(CONFIG_UIO_SMX) += uio_smx.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 5a7ca2e6094d..3a6934bf7131 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -427,6 +427,31 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
427 return retval; 427 return retval;
428} 428}
429 429
430static ssize_t uio_write(struct file *filep, const char __user *buf,
431 size_t count, loff_t *ppos)
432{
433 struct uio_listener *listener = filep->private_data;
434 struct uio_device *idev = listener->dev;
435 ssize_t retval;
436 s32 irq_on;
437
438 if (idev->info->irq == UIO_IRQ_NONE)
439 return -EIO;
440
441 if (count != sizeof(s32))
442 return -EINVAL;
443
444 if (!idev->info->irqcontrol)
445 return -ENOSYS;
446
447 if (copy_from_user(&irq_on, buf, count))
448 return -EFAULT;
449
450 retval = idev->info->irqcontrol(idev->info, irq_on);
451
452 return retval ? retval : sizeof(s32);
453}
454
430static int uio_find_mem_index(struct vm_area_struct *vma) 455static int uio_find_mem_index(struct vm_area_struct *vma)
431{ 456{
432 int mi; 457 int mi;
@@ -546,6 +571,7 @@ static const struct file_operations uio_fops = {
546 .open = uio_open, 571 .open = uio_open,
547 .release = uio_release, 572 .release = uio_release,
548 .read = uio_read, 573 .read = uio_read,
574 .write = uio_write,
549 .mmap = uio_mmap, 575 .mmap = uio_mmap,
550 .poll = uio_poll, 576 .poll = uio_poll,
551 .fasync = uio_fasync, 577 .fasync = uio_fasync,
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c
new file mode 100644
index 000000000000..5d0d2e85d982
--- /dev/null
+++ b/drivers/uio/uio_pdrv.c
@@ -0,0 +1,118 @@
1/*
2 * drivers/uio/uio_pdrv.c
3 *
4 * Copyright (C) 2008 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11#include <linux/platform_device.h>
12#include <linux/uio_driver.h>
13#include <linux/stringify.h>
14
15#define DRIVER_NAME "uio"
16
17struct uio_platdata {
18 struct uio_info *uioinfo;
19};
20
21static int uio_pdrv_probe(struct platform_device *pdev)
22{
23 struct uio_info *uioinfo = pdev->dev.platform_data;
24 struct uio_platdata *pdata;
25 struct uio_mem *uiomem;
26 int ret = -ENODEV;
27 int i;
28
29 if (!uioinfo || !uioinfo->name || !uioinfo->version) {
30 dev_dbg(&pdev->dev, "%s: err_uioinfo\n", __func__);
31 goto err_uioinfo;
32 }
33
34 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
35 if (!pdata) {
36 ret = -ENOMEM;
37 dev_dbg(&pdev->dev, "%s: err_alloc_pdata\n", __func__);
38 goto err_alloc_pdata;
39 }
40
41 pdata->uioinfo = uioinfo;
42
43 uiomem = &uioinfo->mem[0];
44
45 for (i = 0; i < pdev->num_resources; ++i) {
46 struct resource *r = &pdev->resource[i];
47
48 if (r->flags != IORESOURCE_MEM)
49 continue;
50
51 if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) {
52 dev_warn(&pdev->dev, "device has more than "
53 __stringify(MAX_UIO_MAPS)
54 " I/O memory resources.\n");
55 break;
56 }
57
58 uiomem->memtype = UIO_MEM_PHYS;
59 uiomem->addr = r->start;
60 uiomem->size = r->end - r->start + 1;
61 ++uiomem;
62 }
63
64 while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) {
65 uiomem->size = 0;
66 ++uiomem;
67 }
68
69 pdata->uioinfo->priv = pdata;
70
71 ret = uio_register_device(&pdev->dev, pdata->uioinfo);
72
73 if (ret) {
74 kfree(pdata);
75err_alloc_pdata:
76err_uioinfo:
77 return ret;
78 }
79
80 platform_set_drvdata(pdev, pdata);
81
82 return 0;
83}
84
85static int uio_pdrv_remove(struct platform_device *pdev)
86{
87 struct uio_platdata *pdata = platform_get_drvdata(pdev);
88
89 uio_unregister_device(pdata->uioinfo);
90
91 return 0;
92}
93
94static struct platform_driver uio_pdrv = {
95 .probe = uio_pdrv_probe,
96 .remove = uio_pdrv_remove,
97 .driver = {
98 .name = DRIVER_NAME,
99 .owner = THIS_MODULE,
100 },
101};
102
103static int __init uio_pdrv_init(void)
104{
105 return platform_driver_register(&uio_pdrv);
106}
107
108static void __exit uio_pdrv_exit(void)
109{
110 platform_driver_unregister(&uio_pdrv);
111}
112module_init(uio_pdrv_init);
113module_exit(uio_pdrv_exit);
114
115MODULE_AUTHOR("Uwe Kleine-Koenig");
116MODULE_DESCRIPTION("Userspace I/O platform driver");
117MODULE_LICENSE("GPL");
118MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 54a350ccd033..20290c5b1562 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev)
1729{ 1729{
1730 struct device *cldev; 1730 struct device *cldev;
1731 1731
1732 cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, 1732 cldev = device_create_drvdata(usb_classdev_class, &dev->dev,
1733 "usbdev%d.%d", dev->bus->busnum, 1733 dev->dev.devt, NULL, "usbdev%d.%d",
1734 dev->devnum); 1734 dev->bus->busnum, dev->devnum);
1735 if (IS_ERR(cldev)) 1735 if (IS_ERR(cldev))
1736 return PTR_ERR(cldev); 1736 return PTR_ERR(cldev);
1737 dev->usb_classdev = cldev; 1737 dev->usb_classdev = cldev;
@@ -1792,6 +1792,11 @@ int __init usb_devio_init(void)
1792 usb_classdev_class = NULL; 1792 usb_classdev_class = NULL;
1793 goto out; 1793 goto out;
1794 } 1794 }
1795 /* devices of this class shadow the major:minor of their parent
1796 * device, so clear ->dev_kobj to prevent adding duplicate entries
1797 * to /sys/dev
1798 */
1799 usb_classdev_class->dev_kobj = NULL;
1795 1800
1796 usb_register_notify(&usbdev_nb); 1801 usb_register_notify(&usbdev_nb);
1797#endif 1802#endif
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 913fb8667899..6b1b229e38cd 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -196,8 +196,9 @@ int usb_register_dev(struct usb_interface *intf,
196 ++temp; 196 ++temp;
197 else 197 else
198 temp = name; 198 temp = name;
199 intf->usb_dev = device_create(usb_class->class, &intf->dev, 199 intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev,
200 MKDEV(USB_MAJOR, minor), "%s", temp); 200 MKDEV(USB_MAJOR, minor), NULL,
201 "%s", temp);
201 if (IS_ERR(intf->usb_dev)) { 202 if (IS_ERR(intf->usb_dev)) {
202 down_write(&minor_rwsem); 203 down_write(&minor_rwsem);
203 usb_minors[intf->minor] = NULL; 204 usb_minors[intf->minor] = NULL;
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 9caaec3ae9a3..49cd9e145a9b 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -1360,8 +1360,8 @@ printer_bind(struct usb_gadget *gadget)
1360 1360
1361 1361
1362 /* Setup the sysfs files for the printer gadget. */ 1362 /* Setup the sysfs files for the printer gadget. */
1363 dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, 1363 dev->pdev = device_create_drvdata(usb_gadget_class, NULL,
1364 "g_printer"); 1364 g_printer_devno, NULL, "g_printer");
1365 if (IS_ERR(dev->pdev)) { 1365 if (IS_ERR(dev->pdev)) {
1366 ERROR(dev, "Failed to create device: g_printer\n"); 1366 ERROR(dev, "Failed to create device: g_printer\n");
1367 goto fail; 1367 goto fail;
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 293a46247c3b..6566fc0a3228 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1162,8 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
1162 if (minor >= MON_BIN_MAX_MINOR) 1162 if (minor >= MON_BIN_MAX_MINOR)
1163 return 0; 1163 return 0;
1164 1164
1165 dev = device_create(mon_bin_class, ubus? ubus->controller: NULL, 1165 dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL,
1166 MKDEV(MAJOR(mon_bin_dev0), minor), "usbmon%d", minor); 1166 MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167 "usbmon%d", minor);
1167 if (IS_ERR(dev)) 1168 if (IS_ERR(dev))
1168 return 0; 1169 return 0;
1169 1170
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 24ee96c4e9e9..07b6addbb3c1 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1872,7 +1872,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
1872 struct fb_info *info = pci_get_drvdata(pdev); 1872 struct fb_info *info = pci_get_drvdata(pdev);
1873 struct aty128fb_par *par = info->par; 1873 struct aty128fb_par *par = info->par;
1874 struct fb_var_screeninfo var; 1874 struct fb_var_screeninfo var;
1875 char video_card[DEVICE_NAME_SIZE]; 1875 char video_card[50];
1876 u8 chip_rev; 1876 u8 chip_rev;
1877 u32 dac; 1877 u32 dac;
1878 1878
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index c347e38cd0b0..ccbfffd12805 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -289,7 +289,7 @@ struct radeonfb_info {
289 struct radeon_regs state; 289 struct radeon_regs state;
290 struct radeon_regs init_state; 290 struct radeon_regs init_state;
291 291
292 char name[DEVICE_NAME_SIZE]; 292 char name[50];
293 293
294 unsigned long mmio_base_phys; 294 unsigned long mmio_base_phys;
295 unsigned long fb_base_phys; 295 unsigned long fb_base_phys;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 97aff8db10bf..4be3b46c069b 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -3586,7 +3586,8 @@ static int __init fb_console_init(void)
3586 3586
3587 acquire_console_sem(); 3587 acquire_console_sem();
3588 fb_register_client(&fbcon_event_notifier); 3588 fb_register_client(&fbcon_event_notifier);
3589 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon"); 3589 fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0),
3590 NULL, "fbcon");
3590 3591
3591 if (IS_ERR(fbcon_device)) { 3592 if (IS_ERR(fbcon_device)) {
3592 printk(KERN_WARNING "Unable to create device " 3593 printk(KERN_WARNING "Unable to create device "
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 33ebdb198daf..1cd5071e5362 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1439,8 +1439,9 @@ register_framebuffer(struct fb_info *fb_info)
1439 break; 1439 break;
1440 fb_info->node = i; 1440 fb_info->node = i;
1441 1441
1442 fb_info->dev = device_create(fb_class, fb_info->device, 1442 fb_info->dev = device_create_drvdata(fb_class, fb_info->device,
1443 MKDEV(FB_MAJOR, i), "fb%d", i); 1443 MKDEV(FB_MAJOR, i), NULL,
1444 "fb%d", i);
1444 if (IS_ERR(fb_info->dev)) { 1445 if (IS_ERR(fb_info->dev)) {
1445 /* Not fatal */ 1446 /* Not fatal */
1446 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev)); 1447 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 591bc29b55f5..d4427cb86979 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -610,6 +610,7 @@ static ssize_t show_target_kb(struct sys_device *dev, char *buf)
610} 610}
611 611
612static ssize_t store_target_kb(struct sys_device *dev, 612static ssize_t store_target_kb(struct sys_device *dev,
613 struct sysdev_attribute *attr,
613 const char *buf, 614 const char *buf,
614 size_t count) 615 size_t count)
615{ 616{