aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/HOWTO1
-rw-r--r--drivers/base/class.c21
-rw-r--r--drivers/base/core.c203
-rw-r--r--drivers/base/dd.c21
-rw-r--r--drivers/base/firmware_class.c2
-rw-r--r--drivers/base/platform.c11
-rw-r--r--drivers/ide/setup-pci.c7
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c33
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c11
-rw-r--r--drivers/input/serio/serio.c6
-rw-r--r--drivers/net/arm/at91_ether.c2
-rw-r--r--drivers/net/arm/etherh.c2
-rw-r--r--drivers/net/bonding/bond_sysfs.c287
-rw-r--r--drivers/net/iseries_veth.c2
-rw-r--r--drivers/net/macb.c36
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/net/smc91x.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c2
-rw-r--r--drivers/net/wireless/orinoco.c4
-rw-r--r--drivers/net/wireless/orinoco_cs.c2
-rw-r--r--drivers/net/wireless/spectrum_cs.c2
-rw-r--r--drivers/pci/pci-driver.c4
-rw-r--r--drivers/pcmcia/cs.c34
-rw-r--r--drivers/pcmcia/cs_internal.h4
-rw-r--r--drivers/pcmcia/ds.c14
-rw-r--r--drivers/pcmcia/i82092.c2
-rw-r--r--drivers/pcmcia/i82365.c2
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c1
-rw-r--r--drivers/pcmcia/pcmcia_resource.c1
-rw-r--r--drivers/pcmcia/pd6729.c2
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c56
-rw-r--r--drivers/pcmcia/soc_common.c6
-rw-r--r--drivers/pcmcia/socket_sysfs.c104
-rw-r--r--drivers/pcmcia/tcic.c2
-rw-r--r--drivers/pcmcia/yenta_socket.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/spi.c32
-rw-r--r--drivers/spi/spi_bitbang.c6
-rw-r--r--drivers/spi/spi_butterfly.c4
-rw-r--r--drivers/usb/core/driver.c4
-rw-r--r--drivers/usb/input/hid-lgff.c4
-rw-r--r--fs/sysfs/bin.c6
-rw-r--r--fs/sysfs/dir.c214
-rw-r--r--fs/sysfs/file.c82
-rw-r--r--fs/sysfs/group.c2
-rw-r--r--fs/sysfs/inode.c36
-rw-r--r--fs/sysfs/mount.c11
-rw-r--r--fs/sysfs/symlink.c1
-rw-r--r--fs/sysfs/sysfs.h21
-rw-r--r--include/linux/device.h12
-rw-r--r--include/linux/ide.h4
-rw-r--r--include/linux/kobject.h4
-rw-r--r--include/linux/module.h3
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--include/linux/pci.h5
-rw-r--r--include/linux/serio.h5
-rw-r--r--include/linux/spi/spi.h10
-rw-r--r--include/linux/sysfs.h24
-rw-r--r--include/linux/usb.h5
-rw-r--r--include/pcmcia/ss.h2
-rw-r--r--kernel/module.c76
-rw-r--r--kernel/params.c28
-rw-r--r--lib/kobject.c73
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/bridge/br_sysfs_br.c234
-rw-r--r--net/bridge/br_sysfs_if.c2
-rw-r--r--net/core/dev.c6
-rw-r--r--net/core/net-sysfs.c175
-rw-r--r--net/core/skbuff.c2
69 files changed, 1286 insertions, 709 deletions
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 8d51c148f721..48123dba5e6a 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -30,6 +30,7 @@ are not a good substitute for a solid C education and/or years of
30experience, the following books are good for, if anything, reference: 30experience, the following books are good for, if anything, reference:
31 - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall] 31 - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall]
32 - "Practical C Programming" by Steve Oualline [O'Reilly] 32 - "Practical C Programming" by Steve Oualline [O'Reilly]
33 - "C: A Reference Manual" by Harbison and Steele [Prentice Hall]
33 34
34The kernel is written using GNU C and the GNU toolchain. While it 35The kernel is written using GNU C and the GNU toolchain. While it
35adheres to the ISO C89 standard, it uses a number of extensions that are 36adheres to the ISO C89 standard, it uses a number of extensions that are
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 8bf2ca2e56b5..96def1ddba19 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -364,7 +364,7 @@ char *make_class_name(const char *name, struct kobject *kobj)
364 364
365 class_name = kmalloc(size, GFP_KERNEL); 365 class_name = kmalloc(size, GFP_KERNEL);
366 if (!class_name) 366 if (!class_name)
367 return ERR_PTR(-ENOMEM); 367 return NULL;
368 368
369 strcpy(class_name, name); 369 strcpy(class_name, name);
370 strcat(class_name, ":"); 370 strcat(class_name, ":");
@@ -411,8 +411,11 @@ static int make_deprecated_class_device_links(struct class_device *class_dev)
411 return 0; 411 return 0;
412 412
413 class_name = make_class_name(class_dev->class->name, &class_dev->kobj); 413 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
414 error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, 414 if (class_name)
415 class_name); 415 error = sysfs_create_link(&class_dev->dev->kobj,
416 &class_dev->kobj, class_name);
417 else
418 error = -ENOMEM;
416 kfree(class_name); 419 kfree(class_name);
417 return error; 420 return error;
418} 421}
@@ -425,7 +428,8 @@ static void remove_deprecated_class_device_links(struct class_device *class_dev)
425 return; 428 return;
426 429
427 class_name = make_class_name(class_dev->class->name, &class_dev->kobj); 430 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
428 sysfs_remove_link(&class_dev->dev->kobj, class_name); 431 if (class_name)
432 sysfs_remove_link(&class_dev->dev->kobj, class_name);
429 kfree(class_name); 433 kfree(class_name);
430} 434}
431#else 435#else
@@ -863,9 +867,12 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
863 if (class_dev->dev) { 867 if (class_dev->dev) {
864 new_class_name = make_class_name(class_dev->class->name, 868 new_class_name = make_class_name(class_dev->class->name,
865 &class_dev->kobj); 869 &class_dev->kobj);
866 sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, 870 if (new_class_name)
867 new_class_name); 871 sysfs_create_link(&class_dev->dev->kobj,
868 sysfs_remove_link(&class_dev->dev->kobj, old_class_name); 872 &class_dev->kobj, new_class_name);
873 if (old_class_name)
874 sysfs_remove_link(&class_dev->dev->kobj,
875 old_class_name);
869 } 876 }
870#endif 877#endif
871 class_device_put(class_dev); 878 class_device_put(class_dev);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 67b79a7592a9..e13614241c9e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -95,6 +95,8 @@ static void device_release(struct kobject * kobj)
95 95
96 if (dev->release) 96 if (dev->release)
97 dev->release(dev); 97 dev->release(dev);
98 else if (dev->type && dev->type->release)
99 dev->type->release(dev);
98 else if (dev->class && dev->class->dev_release) 100 else if (dev->class && dev->class->dev_release)
99 dev->class->dev_release(dev); 101 dev->class->dev_release(dev);
100 else { 102 else {
@@ -154,25 +156,47 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
154 "MINOR=%u", MINOR(dev->devt)); 156 "MINOR=%u", MINOR(dev->devt));
155 } 157 }
156 158
157#ifdef CONFIG_SYSFS_DEPRECATED 159 if (dev->driver)
158 /* add bus name (same as SUBSYSTEM, deprecated) */
159 if (dev->bus)
160 add_uevent_var(envp, num_envp, &i,
161 buffer, buffer_size, &length,
162 "PHYSDEVBUS=%s", dev->bus->name);
163#endif
164
165 /* add driver name (PHYSDEV* values are deprecated)*/
166 if (dev->driver) {
167 add_uevent_var(envp, num_envp, &i, 160 add_uevent_var(envp, num_envp, &i,
168 buffer, buffer_size, &length, 161 buffer, buffer_size, &length,
169 "DRIVER=%s", dev->driver->name); 162 "DRIVER=%s", dev->driver->name);
163
170#ifdef CONFIG_SYSFS_DEPRECATED 164#ifdef CONFIG_SYSFS_DEPRECATED
165 if (dev->class) {
166 struct device *parent = dev->parent;
167
168 /* find first bus device in parent chain */
169 while (parent && !parent->bus)
170 parent = parent->parent;
171 if (parent && parent->bus) {
172 const char *path;
173
174 path = kobject_get_path(&parent->kobj, GFP_KERNEL);
175 add_uevent_var(envp, num_envp, &i,
176 buffer, buffer_size, &length,
177 "PHYSDEVPATH=%s", path);
178 kfree(path);
179
180 add_uevent_var(envp, num_envp, &i,
181 buffer, buffer_size, &length,
182 "PHYSDEVBUS=%s", parent->bus->name);
183
184 if (parent->driver)
185 add_uevent_var(envp, num_envp, &i,
186 buffer, buffer_size, &length,
187 "PHYSDEVDRIVER=%s", parent->driver->name);
188 }
189 } else if (dev->bus) {
171 add_uevent_var(envp, num_envp, &i, 190 add_uevent_var(envp, num_envp, &i,
172 buffer, buffer_size, &length, 191 buffer, buffer_size, &length,
173 "PHYSDEVDRIVER=%s", dev->driver->name); 192 "PHYSDEVBUS=%s", dev->bus->name);
174#endif 193
194 if (dev->driver)
195 add_uevent_var(envp, num_envp, &i,
196 buffer, buffer_size, &length,
197 "PHYSDEVDRIVER=%s", dev->driver->name);
175 } 198 }
199#endif
176 200
177 /* terminate, set to next free slot, shrink available space */ 201 /* terminate, set to next free slot, shrink available space */
178 envp[i] = NULL; 202 envp[i] = NULL;
@@ -184,19 +208,25 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
184 if (dev->bus && dev->bus->uevent) { 208 if (dev->bus && dev->bus->uevent) {
185 /* have the bus specific function add its stuff */ 209 /* have the bus specific function add its stuff */
186 retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size); 210 retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size);
187 if (retval) { 211 if (retval)
188 pr_debug ("%s - uevent() returned %d\n", 212 pr_debug ("%s: bus uevent() returned %d\n",
189 __FUNCTION__, retval); 213 __FUNCTION__, retval);
190 }
191 } 214 }
192 215
193 if (dev->class && dev->class->dev_uevent) { 216 if (dev->class && dev->class->dev_uevent) {
194 /* have the class specific function add its stuff */ 217 /* have the class specific function add its stuff */
195 retval = dev->class->dev_uevent(dev, envp, num_envp, buffer, buffer_size); 218 retval = dev->class->dev_uevent(dev, envp, num_envp, buffer, buffer_size);
196 if (retval) { 219 if (retval)
197 pr_debug("%s - dev_uevent() returned %d\n", 220 pr_debug("%s: class uevent() returned %d\n",
198 __FUNCTION__, retval); 221 __FUNCTION__, retval);
199 } 222 }
223
224 if (dev->type && dev->type->uevent) {
225 /* have the device type specific fuction add its stuff */
226 retval = dev->type->uevent(dev, envp, num_envp, buffer, buffer_size);
227 if (retval)
228 pr_debug("%s: dev_type uevent() returned %d\n",
229 __FUNCTION__, retval);
200 } 230 }
201 231
202 return retval; 232 return retval;
@@ -247,37 +277,50 @@ static void device_remove_groups(struct device *dev)
247static int device_add_attrs(struct device *dev) 277static int device_add_attrs(struct device *dev)
248{ 278{
249 struct class *class = dev->class; 279 struct class *class = dev->class;
280 struct device_type *type = dev->type;
250 int error = 0; 281 int error = 0;
251 int i; 282 int i;
252 283
253 if (!class) 284 if (class && class->dev_attrs) {
254 return 0;
255
256 if (class->dev_attrs) {
257 for (i = 0; attr_name(class->dev_attrs[i]); i++) { 285 for (i = 0; attr_name(class->dev_attrs[i]); i++) {
258 error = device_create_file(dev, &class->dev_attrs[i]); 286 error = device_create_file(dev, &class->dev_attrs[i]);
259 if (error) 287 if (error)
260 break; 288 break;
261 } 289 }
290 if (error)
291 while (--i >= 0)
292 device_remove_file(dev, &class->dev_attrs[i]);
262 } 293 }
263 if (error) 294
264 while (--i >= 0) 295 if (type && type->attrs) {
265 device_remove_file(dev, &class->dev_attrs[i]); 296 for (i = 0; attr_name(type->attrs[i]); i++) {
297 error = device_create_file(dev, &type->attrs[i]);
298 if (error)
299 break;
300 }
301 if (error)
302 while (--i >= 0)
303 device_remove_file(dev, &type->attrs[i]);
304 }
305
266 return error; 306 return error;
267} 307}
268 308
269static void device_remove_attrs(struct device *dev) 309static void device_remove_attrs(struct device *dev)
270{ 310{
271 struct class *class = dev->class; 311 struct class *class = dev->class;
312 struct device_type *type = dev->type;
272 int i; 313 int i;
273 314
274 if (!class) 315 if (class && class->dev_attrs) {
275 return;
276
277 if (class->dev_attrs) {
278 for (i = 0; attr_name(class->dev_attrs[i]); i++) 316 for (i = 0; attr_name(class->dev_attrs[i]); i++)
279 device_remove_file(dev, &class->dev_attrs[i]); 317 device_remove_file(dev, &class->dev_attrs[i]);
280 } 318 }
319
320 if (type && type->attrs) {
321 for (i = 0; attr_name(type->attrs[i]); i++)
322 device_remove_file(dev, &type->attrs[i]);
323 }
281} 324}
282 325
283 326
@@ -390,22 +433,23 @@ void device_initialize(struct device *dev)
390} 433}
391 434
392#ifdef CONFIG_SYSFS_DEPRECATED 435#ifdef CONFIG_SYSFS_DEPRECATED
393static int setup_parent(struct device *dev, struct device *parent) 436static struct kobject * get_device_parent(struct device *dev,
437 struct device *parent)
394{ 438{
395 /* Set the parent to the class, not the parent device */ 439 /* Set the parent to the class, not the parent device */
396 /* this keeps sysfs from having a symlink to make old udevs happy */ 440 /* this keeps sysfs from having a symlink to make old udevs happy */
397 if (dev->class) 441 if (dev->class)
398 dev->kobj.parent = &dev->class->subsys.kset.kobj; 442 return &dev->class->subsys.kset.kobj;
399 else if (parent) 443 else if (parent)
400 dev->kobj.parent = &parent->kobj; 444 return &parent->kobj;
401 445
402 return 0; 446 return NULL;
403} 447}
404#else 448#else
405static int virtual_device_parent(struct device *dev) 449static struct kobject * virtual_device_parent(struct device *dev)
406{ 450{
407 if (!dev->class) 451 if (!dev->class)
408 return -ENODEV; 452 return ERR_PTR(-ENODEV);
409 453
410 if (!dev->class->virtual_dir) { 454 if (!dev->class->virtual_dir) {
411 static struct kobject *virtual_dir = NULL; 455 static struct kobject *virtual_dir = NULL;
@@ -415,25 +459,31 @@ static int virtual_device_parent(struct device *dev)
415 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name); 459 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
416 } 460 }
417 461
418 dev->kobj.parent = dev->class->virtual_dir; 462 return dev->class->virtual_dir;
419 return 0;
420} 463}
421 464
422static int setup_parent(struct device *dev, struct device *parent) 465static struct kobject * get_device_parent(struct device *dev,
466 struct device *parent)
423{ 467{
424 int error;
425
426 /* if this is a class device, and has no parent, create one */ 468 /* if this is a class device, and has no parent, create one */
427 if ((dev->class) && (parent == NULL)) { 469 if ((dev->class) && (parent == NULL)) {
428 error = virtual_device_parent(dev); 470 return virtual_device_parent(dev);
429 if (error)
430 return error;
431 } else if (parent) 471 } else if (parent)
432 dev->kobj.parent = &parent->kobj; 472 return &parent->kobj;
473 return NULL;
474}
433 475
476#endif
477static int setup_parent(struct device *dev, struct device *parent)
478{
479 struct kobject *kobj;
480 kobj = get_device_parent(dev, parent);
481 if (IS_ERR(kobj))
482 return PTR_ERR(kobj);
483 if (kobj)
484 dev->kobj.parent = kobj;
434 return 0; 485 return 0;
435} 486}
436#endif
437 487
438/** 488/**
439 * device_add - add device to device hierarchy. 489 * device_add - add device to device hierarchy.
@@ -520,9 +570,13 @@ int device_add(struct device *dev)
520 &dev->kobj, dev->bus_id); 570 &dev->kobj, dev->bus_id);
521#ifdef CONFIG_SYSFS_DEPRECATED 571#ifdef CONFIG_SYSFS_DEPRECATED
522 if (parent) { 572 if (parent) {
523 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); 573 sysfs_create_link(&dev->kobj, &dev->parent->kobj,
524 class_name = make_class_name(dev->class->name, &dev->kobj); 574 "device");
525 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); 575 class_name = make_class_name(dev->class->name,
576 &dev->kobj);
577 if (class_name)
578 sysfs_create_link(&dev->parent->kobj,
579 &dev->kobj, class_name);
526 } 580 }
527#endif 581#endif
528 } 582 }
@@ -535,7 +589,8 @@ int device_add(struct device *dev)
535 goto PMError; 589 goto PMError;
536 if ((error = bus_add_device(dev))) 590 if ((error = bus_add_device(dev)))
537 goto BusError; 591 goto BusError;
538 kobject_uevent(&dev->kobj, KOBJ_ADD); 592 if (!dev->uevent_suppress)
593 kobject_uevent(&dev->kobj, KOBJ_ADD);
539 if ((error = bus_attach_device(dev))) 594 if ((error = bus_attach_device(dev)))
540 goto AttachError; 595 goto AttachError;
541 if (parent) 596 if (parent)
@@ -665,7 +720,9 @@ void device_del(struct device * dev)
665 if (parent) { 720 if (parent) {
666 char *class_name = make_class_name(dev->class->name, 721 char *class_name = make_class_name(dev->class->name,
667 &dev->kobj); 722 &dev->kobj);
668 sysfs_remove_link(&dev->parent->kobj, class_name); 723 if (class_name)
724 sysfs_remove_link(&dev->parent->kobj,
725 class_name);
669 kfree(class_name); 726 kfree(class_name);
670 sysfs_remove_link(&dev->kobj, "device"); 727 sysfs_remove_link(&dev->kobj, "device");
671 } 728 }
@@ -968,20 +1025,25 @@ static int device_move_class_links(struct device *dev,
968 1025
969 class_name = make_class_name(dev->class->name, &dev->kobj); 1026 class_name = make_class_name(dev->class->name, &dev->kobj);
970 if (!class_name) { 1027 if (!class_name) {
971 error = PTR_ERR(class_name); 1028 error = -ENOMEM;
972 class_name = NULL;
973 goto out; 1029 goto out;
974 } 1030 }
975 if (old_parent) { 1031 if (old_parent) {
976 sysfs_remove_link(&dev->kobj, "device"); 1032 sysfs_remove_link(&dev->kobj, "device");
977 sysfs_remove_link(&old_parent->kobj, class_name); 1033 sysfs_remove_link(&old_parent->kobj, class_name);
978 } 1034 }
979 error = sysfs_create_link(&dev->kobj, &new_parent->kobj, "device"); 1035 if (new_parent) {
980 if (error) 1036 error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
981 goto out; 1037 "device");
982 error = sysfs_create_link(&new_parent->kobj, &dev->kobj, class_name); 1038 if (error)
983 if (error) 1039 goto out;
984 sysfs_remove_link(&dev->kobj, "device"); 1040 error = sysfs_create_link(&new_parent->kobj, &dev->kobj,
1041 class_name);
1042 if (error)
1043 sysfs_remove_link(&dev->kobj, "device");
1044 }
1045 else
1046 error = 0;
985out: 1047out:
986 kfree(class_name); 1048 kfree(class_name);
987 return error; 1049 return error;
@@ -993,29 +1055,28 @@ out:
993/** 1055/**
994 * device_move - moves a device to a new parent 1056 * device_move - moves a device to a new parent
995 * @dev: the pointer to the struct device to be moved 1057 * @dev: the pointer to the struct device to be moved
996 * @new_parent: the new parent of the device 1058 * @new_parent: the new parent of the device (can by NULL)
997 */ 1059 */
998int device_move(struct device *dev, struct device *new_parent) 1060int device_move(struct device *dev, struct device *new_parent)
999{ 1061{
1000 int error; 1062 int error;
1001 struct device *old_parent; 1063 struct device *old_parent;
1064 struct kobject *new_parent_kobj;
1002 1065
1003 dev = get_device(dev); 1066 dev = get_device(dev);
1004 if (!dev) 1067 if (!dev)
1005 return -EINVAL; 1068 return -EINVAL;
1006 1069
1007 if (!device_is_registered(dev)) {
1008 error = -EINVAL;
1009 goto out;
1010 }
1011 new_parent = get_device(new_parent); 1070 new_parent = get_device(new_parent);
1012 if (!new_parent) { 1071 new_parent_kobj = get_device_parent (dev, new_parent);
1013 error = -EINVAL; 1072 if (IS_ERR(new_parent_kobj)) {
1073 error = PTR_ERR(new_parent_kobj);
1074 put_device(new_parent);
1014 goto out; 1075 goto out;
1015 } 1076 }
1016 pr_debug("DEVICE: moving '%s' to '%s'\n", dev->bus_id, 1077 pr_debug("DEVICE: moving '%s' to '%s'\n", dev->bus_id,
1017 new_parent->bus_id); 1078 new_parent ? new_parent->bus_id : "<NULL>");
1018 error = kobject_move(&dev->kobj, &new_parent->kobj); 1079 error = kobject_move(&dev->kobj, new_parent_kobj);
1019 if (error) { 1080 if (error) {
1020 put_device(new_parent); 1081 put_device(new_parent);
1021 goto out; 1082 goto out;
@@ -1024,7 +1085,8 @@ int device_move(struct device *dev, struct device *new_parent)
1024 dev->parent = new_parent; 1085 dev->parent = new_parent;
1025 if (old_parent) 1086 if (old_parent)
1026 klist_remove(&dev->knode_parent); 1087 klist_remove(&dev->knode_parent);
1027 klist_add_tail(&dev->knode_parent, &new_parent->klist_children); 1088 if (new_parent)
1089 klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
1028 if (!dev->class) 1090 if (!dev->class)
1029 goto out_put; 1091 goto out_put;
1030 error = device_move_class_links(dev, old_parent, new_parent); 1092 error = device_move_class_links(dev, old_parent, new_parent);
@@ -1032,7 +1094,8 @@ int device_move(struct device *dev, struct device *new_parent)
1032 /* We ignore errors on cleanup since we're hosed anyway... */ 1094 /* We ignore errors on cleanup since we're hosed anyway... */
1033 device_move_class_links(dev, new_parent, old_parent); 1095 device_move_class_links(dev, new_parent, old_parent);
1034 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1096 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1035 klist_remove(&dev->knode_parent); 1097 if (new_parent)
1098 klist_remove(&dev->knode_parent);
1036 if (old_parent) 1099 if (old_parent)
1037 klist_add_tail(&dev->knode_parent, 1100 klist_add_tail(&dev->knode_parent,
1038 &old_parent->klist_children); 1101 &old_parent->klist_children);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 510e7884975f..b5bf243d9cd6 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -86,8 +86,12 @@ static void driver_sysfs_remove(struct device *dev)
86 */ 86 */
87int device_bind_driver(struct device *dev) 87int device_bind_driver(struct device *dev)
88{ 88{
89 driver_bound(dev); 89 int ret;
90 return driver_sysfs_add(dev); 90
91 ret = driver_sysfs_add(dev);
92 if (!ret)
93 driver_bound(dev);
94 return ret;
91} 95}
92 96
93struct stupid_thread_structure { 97struct stupid_thread_structure {
@@ -136,18 +140,17 @@ probe_failed:
136 driver_sysfs_remove(dev); 140 driver_sysfs_remove(dev);
137 dev->driver = NULL; 141 dev->driver = NULL;
138 142
139 if (ret == -ENODEV || ret == -ENXIO) { 143 if (ret != -ENODEV && ret != -ENXIO) {
140 /* Driver matched, but didn't support device
141 * or device not found.
142 * Not an error; keep going.
143 */
144 ret = 0;
145 } else {
146 /* driver matched but the probe failed */ 144 /* driver matched but the probe failed */
147 printk(KERN_WARNING 145 printk(KERN_WARNING
148 "%s: probe of %s failed with error %d\n", 146 "%s: probe of %s failed with error %d\n",
149 drv->name, dev->bus_id, ret); 147 drv->name, dev->bus_id, ret);
150 } 148 }
149 /*
150 * Ignore errors returned by ->probe so that the next driver can try
151 * its luck.
152 */
153 ret = 0;
151done: 154done:
152 kfree(data); 155 kfree(data);
153 atomic_dec(&probe_count); 156 atomic_dec(&probe_count);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 64558f45e6bc..c0a979a5074b 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -35,7 +35,7 @@ enum {
35 FW_STATUS_READY_NOHOTPLUG, 35 FW_STATUS_READY_NOHOTPLUG,
36}; 36};
37 37
38static int loading_timeout = 10; /* In seconds */ 38static int loading_timeout = 60; /* In seconds */
39 39
40/* fw_lock could be moved to 'struct firmware_priv' but since it is just 40/* fw_lock could be moved to 'struct firmware_priv' but since it is just
41 * guarding for corner cases a global lock should be OK */ 41 * guarding for corner cases a global lock should be OK */
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f9c903ba9fcd..30480f6f2af2 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -611,8 +611,15 @@ EXPORT_SYMBOL_GPL(platform_bus_type);
611 611
612int __init platform_bus_init(void) 612int __init platform_bus_init(void)
613{ 613{
614 device_register(&platform_bus); 614 int error;
615 return bus_register(&platform_bus_type); 615
616 error = device_register(&platform_bus);
617 if (error)
618 return error;
619 error = bus_register(&platform_bus_type);
620 if (error)
621 device_unregister(&platform_bus);
622 return error;
616} 623}
617 624
618#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK 625#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 695e23904d30..a52c80fe7d3e 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -783,10 +783,11 @@ static LIST_HEAD(ide_pci_drivers);
783 * Returns are the same as for pci_register_driver 783 * Returns are the same as for pci_register_driver
784 */ 784 */
785 785
786int __ide_pci_register_driver(struct pci_driver *driver, struct module *module) 786int __ide_pci_register_driver(struct pci_driver *driver, struct module *module,
787 const char *mod_name)
787{ 788{
788 if(!pre_init) 789 if(!pre_init)
789 return __pci_register_driver(driver, module); 790 return __pci_register_driver(driver, module, mod_name);
790 driver->driver.owner = module; 791 driver->driver.owner = module;
791 list_add_tail(&driver->node, &ide_pci_drivers); 792 list_add_tail(&driver->node, &ide_pci_drivers);
792 return 0; 793 return 0;
@@ -862,6 +863,6 @@ void __init ide_scan_pcibus (int scan_direction)
862 { 863 {
863 list_del(l); 864 list_del(l);
864 d = list_entry(l, struct pci_driver, node); 865 d = list_entry(l, struct pci_driver, node);
865 __pci_register_driver(d, d->driver.owner); 866 __pci_register_driver(d, d->driver.owner, d->driver.mod_name);
866 } 867 }
867} 868}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 705eb1d0e554..af5ee2ec4499 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -958,16 +958,17 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
958 return netdev_priv(dev); 958 return netdev_priv(dev);
959} 959}
960 960
961static ssize_t show_pkey(struct class_device *cdev, char *buf) 961static ssize_t show_pkey(struct device *dev,
962 struct device_attribute *attr, char *buf)
962{ 963{
963 struct ipoib_dev_priv *priv = 964 struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
964 netdev_priv(container_of(cdev, struct net_device, class_dev));
965 965
966 return sprintf(buf, "0x%04x\n", priv->pkey); 966 return sprintf(buf, "0x%04x\n", priv->pkey);
967} 967}
968static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 968static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
969 969
970static ssize_t create_child(struct class_device *cdev, 970static ssize_t create_child(struct device *dev,
971 struct device_attribute *attr,
971 const char *buf, size_t count) 972 const char *buf, size_t count)
972{ 973{
973 int pkey; 974 int pkey;
@@ -985,14 +986,14 @@ static ssize_t create_child(struct class_device *cdev,
985 */ 986 */
986 pkey |= 0x8000; 987 pkey |= 0x8000;
987 988
988 ret = ipoib_vlan_add(container_of(cdev, struct net_device, class_dev), 989 ret = ipoib_vlan_add(to_net_dev(dev), pkey);
989 pkey);
990 990
991 return ret ? ret : count; 991 return ret ? ret : count;
992} 992}
993static CLASS_DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child); 993static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child);
994 994
995static ssize_t delete_child(struct class_device *cdev, 995static ssize_t delete_child(struct device *dev,
996 struct device_attribute *attr,
996 const char *buf, size_t count) 997 const char *buf, size_t count)
997{ 998{
998 int pkey; 999 int pkey;
@@ -1004,18 +1005,16 @@ static ssize_t delete_child(struct class_device *cdev,
1004 if (pkey < 0 || pkey > 0xffff) 1005 if (pkey < 0 || pkey > 0xffff)
1005 return -EINVAL; 1006 return -EINVAL;
1006 1007
1007 ret = ipoib_vlan_delete(container_of(cdev, struct net_device, class_dev), 1008 ret = ipoib_vlan_delete(to_net_dev(dev), pkey);
1008 pkey);
1009 1009
1010 return ret ? ret : count; 1010 return ret ? ret : count;
1011 1011
1012} 1012}
1013static CLASS_DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child); 1013static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child);
1014 1014
1015int ipoib_add_pkey_attr(struct net_device *dev) 1015int ipoib_add_pkey_attr(struct net_device *dev)
1016{ 1016{
1017 return class_device_create_file(&dev->class_dev, 1017 return device_create_file(&dev->dev, &dev_attr_pkey);
1018 &class_device_attr_pkey);
1019} 1018}
1020 1019
1021static struct net_device *ipoib_add_port(const char *format, 1020static struct net_device *ipoib_add_port(const char *format,
@@ -1083,11 +1082,9 @@ static struct net_device *ipoib_add_port(const char *format,
1083 1082
1084 if (ipoib_add_pkey_attr(priv->dev)) 1083 if (ipoib_add_pkey_attr(priv->dev))
1085 goto sysfs_failed; 1084 goto sysfs_failed;
1086 if (class_device_create_file(&priv->dev->class_dev, 1085 if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
1087 &class_device_attr_create_child))
1088 goto sysfs_failed; 1086 goto sysfs_failed;
1089 if (class_device_create_file(&priv->dev->class_dev, 1087 if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
1090 &class_device_attr_delete_child))
1091 goto sysfs_failed; 1088 goto sysfs_failed;
1092 1089
1093 return priv->dev; 1090 return priv->dev;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index f887780e8093..085eafe6667c 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -42,15 +42,15 @@
42 42
43#include "ipoib.h" 43#include "ipoib.h"
44 44
45static ssize_t show_parent(struct class_device *class_dev, char *buf) 45static ssize_t show_parent(struct device *d, struct device_attribute *attr,
46 char *buf)
46{ 47{
47 struct net_device *dev = 48 struct net_device *dev = to_net_dev(d);
48 container_of(class_dev, struct net_device, class_dev);
49 struct ipoib_dev_priv *priv = netdev_priv(dev); 49 struct ipoib_dev_priv *priv = netdev_priv(dev);
50 50
51 return sprintf(buf, "%s\n", priv->parent->name); 51 return sprintf(buf, "%s\n", priv->parent->name);
52} 52}
53static CLASS_DEVICE_ATTR(parent, S_IRUGO, show_parent, NULL); 53static DEVICE_ATTR(parent, S_IRUGO, show_parent, NULL);
54 54
55int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) 55int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
56{ 56{
@@ -118,8 +118,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
118 if (ipoib_add_pkey_attr(priv->dev)) 118 if (ipoib_add_pkey_attr(priv->dev))
119 goto sysfs_failed; 119 goto sysfs_failed;
120 120
121 if (class_device_create_file(&priv->dev->class_dev, 121 if (device_create_file(&priv->dev->dev, &dev_attr_parent))
122 &class_device_attr_parent))
123 goto sysfs_failed; 122 goto sysfs_failed;
124 123
125 list_add_tail(&priv->list, &ppriv->child_intfs); 124 list_add_tail(&priv->list, &ppriv->child_intfs);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index f0ce822c1028..17c8c63cbe1a 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -45,7 +45,7 @@ EXPORT_SYMBOL(serio_interrupt);
45EXPORT_SYMBOL(__serio_register_port); 45EXPORT_SYMBOL(__serio_register_port);
46EXPORT_SYMBOL(serio_unregister_port); 46EXPORT_SYMBOL(serio_unregister_port);
47EXPORT_SYMBOL(serio_unregister_child_port); 47EXPORT_SYMBOL(serio_unregister_child_port);
48EXPORT_SYMBOL(serio_register_driver); 48EXPORT_SYMBOL(__serio_register_driver);
49EXPORT_SYMBOL(serio_unregister_driver); 49EXPORT_SYMBOL(serio_unregister_driver);
50EXPORT_SYMBOL(serio_open); 50EXPORT_SYMBOL(serio_open);
51EXPORT_SYMBOL(serio_close); 51EXPORT_SYMBOL(serio_close);
@@ -789,12 +789,14 @@ static void serio_attach_driver(struct serio_driver *drv)
789 drv->driver.name, error); 789 drv->driver.name, error);
790} 790}
791 791
792int serio_register_driver(struct serio_driver *drv) 792int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
793{ 793{
794 int manual_bind = drv->manual_bind; 794 int manual_bind = drv->manual_bind;
795 int error; 795 int error;
796 796
797 drv->driver.bus = &serio_bus; 797 drv->driver.bus = &serio_bus;
798 drv->driver.owner = owner;
799 drv->driver.mod_name = mod_name;
798 800
799 /* 801 /*
800 * Temporarily disable automatic binding because probing 802 * Temporarily disable automatic binding because probing
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index fada15d959de..1621b8fe35cf 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -641,7 +641,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
641{ 641{
642 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 642 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
643 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 643 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
644 strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); 644 strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
645} 645}
646 646
647static const struct ethtool_ops at91ether_ethtool_ops = { 647static const struct ethtool_ops at91ether_ethtool_ops = {
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index f3faa4fe58e7..72c41f5907f2 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -587,7 +587,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
587{ 587{
588 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 588 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
589 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 589 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
590 strlcpy(info->bus_info, dev->class_dev.dev->bus_id, 590 strlcpy(info->bus_info, dev->dev.parent->bus_id,
591 sizeof(info->bus_info)); 591 sizeof(info->bus_info));
592} 592}
593 593
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 8e317e115532..878f7aabeeac 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -39,8 +39,7 @@
39 39
40/* #define BONDING_DEBUG 1 */ 40/* #define BONDING_DEBUG 1 */
41#include "bonding.h" 41#include "bonding.h"
42#define to_class_dev(obj) container_of(obj,struct class_device,kobj) 42#define to_dev(obj) container_of(obj,struct device,kobj)
43#define to_net_dev(class) container_of(class, struct net_device, class_dev)
44#define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) 43#define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv))
45 44
46/*---------------------------- Declarations -------------------------------*/ 45/*---------------------------- Declarations -------------------------------*/
@@ -154,7 +153,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
154 * If it's > expected, then there's a file open, 153 * If it's > expected, then there's a file open,
155 * and we have to fail. 154 * and we have to fail.
156 */ 155 */
157 if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount) 156 if (atomic_read(&bond->dev->dev.kobj.kref.refcount)
158 > expected_refcount){ 157 > expected_refcount){
159 rtnl_unlock(); 158 rtnl_unlock();
160 printk(KERN_INFO DRV_NAME 159 printk(KERN_INFO DRV_NAME
@@ -201,13 +200,13 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla
201 int ret = 0; 200 int ret = 0;
202 201
203 /* first, create a link from the slave back to the master */ 202 /* first, create a link from the slave back to the master */
204 ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj), 203 ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj),
205 "master"); 204 "master");
206 if (ret) 205 if (ret)
207 return ret; 206 return ret;
208 /* next, create a link from the master to the slave */ 207 /* next, create a link from the master to the slave */
209 sprintf(linkname,"slave_%s",slave->name); 208 sprintf(linkname,"slave_%s",slave->name);
210 ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj), 209 ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
211 linkname); 210 linkname);
212 return ret; 211 return ret;
213 212
@@ -217,20 +216,21 @@ void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *s
217{ 216{
218 char linkname[IFNAMSIZ+7]; 217 char linkname[IFNAMSIZ+7];
219 218
220 sysfs_remove_link(&(slave->class_dev.kobj), "master"); 219 sysfs_remove_link(&(slave->dev.kobj), "master");
221 sprintf(linkname,"slave_%s",slave->name); 220 sprintf(linkname,"slave_%s",slave->name);
222 sysfs_remove_link(&(master->class_dev.kobj), linkname); 221 sysfs_remove_link(&(master->dev.kobj), linkname);
223} 222}
224 223
225 224
226/* 225/*
227 * Show the slaves in the current bond. 226 * Show the slaves in the current bond.
228 */ 227 */
229static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) 228static ssize_t bonding_show_slaves(struct device *d,
229 struct device_attribute *attr, char *buf)
230{ 230{
231 struct slave *slave; 231 struct slave *slave;
232 int i, res = 0; 232 int i, res = 0;
233 struct bonding *bond = to_bond(cd); 233 struct bonding *bond = to_bond(d);
234 234
235 read_lock_bh(&bond->lock); 235 read_lock_bh(&bond->lock);
236 bond_for_each_slave(bond, slave, i) { 236 bond_for_each_slave(bond, slave, i) {
@@ -254,14 +254,16 @@ static ssize_t bonding_show_slaves(struct class_device *cd, char *buf)
254 * up for this to succeed. 254 * up for this to succeed.
255 * This function is largely the same flow as bonding_update_bonds(). 255 * This function is largely the same flow as bonding_update_bonds().
256 */ 256 */
257static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count) 257static ssize_t bonding_store_slaves(struct device *d,
258 struct device_attribute *attr,
259 const char *buffer, size_t count)
258{ 260{
259 char command[IFNAMSIZ + 1] = { 0, }; 261 char command[IFNAMSIZ + 1] = { 0, };
260 char *ifname; 262 char *ifname;
261 int i, res, found, ret = count; 263 int i, res, found, ret = count;
262 struct slave *slave; 264 struct slave *slave;
263 struct net_device *dev = NULL; 265 struct net_device *dev = NULL;
264 struct bonding *bond = to_bond(cd); 266 struct bonding *bond = to_bond(d);
265 267
266 /* Quick sanity check -- is the bond interface up? */ 268 /* Quick sanity check -- is the bond interface up? */
267 if (!(bond->dev->flags & IFF_UP)) { 269 if (!(bond->dev->flags & IFF_UP)) {
@@ -387,25 +389,28 @@ out:
387 return ret; 389 return ret;
388} 390}
389 391
390static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); 392static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves);
391 393
392/* 394/*
393 * Show and set the bonding mode. The bond interface must be down to 395 * Show and set the bonding mode. The bond interface must be down to
394 * change the mode. 396 * change the mode.
395 */ 397 */
396static ssize_t bonding_show_mode(struct class_device *cd, char *buf) 398static ssize_t bonding_show_mode(struct device *d,
399 struct device_attribute *attr, char *buf)
397{ 400{
398 struct bonding *bond = to_bond(cd); 401 struct bonding *bond = to_bond(d);
399 402
400 return sprintf(buf, "%s %d\n", 403 return sprintf(buf, "%s %d\n",
401 bond_mode_tbl[bond->params.mode].modename, 404 bond_mode_tbl[bond->params.mode].modename,
402 bond->params.mode) + 1; 405 bond->params.mode) + 1;
403} 406}
404 407
405static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count) 408static ssize_t bonding_store_mode(struct device *d,
409 struct device_attribute *attr,
410 const char *buf, size_t count)
406{ 411{
407 int new_value, ret = count; 412 int new_value, ret = count;
408 struct bonding *bond = to_bond(cd); 413 struct bonding *bond = to_bond(d);
409 414
410 if (bond->dev->flags & IFF_UP) { 415 if (bond->dev->flags & IFF_UP) {
411 printk(KERN_ERR DRV_NAME 416 printk(KERN_ERR DRV_NAME
@@ -438,16 +443,18 @@ static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size
438out: 443out:
439 return ret; 444 return ret;
440} 445}
441static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); 446static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode);
442 447
443/* 448/*
444 * Show and set the bonding transmit hash method. The bond interface must be down to 449 * Show and set the bonding transmit hash method. The bond interface must be down to
445 * change the xmit hash policy. 450 * change the xmit hash policy.
446 */ 451 */
447static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) 452static ssize_t bonding_show_xmit_hash(struct device *d,
453 struct device_attribute *attr,
454 char *buf)
448{ 455{
449 int count; 456 int count;
450 struct bonding *bond = to_bond(cd); 457 struct bonding *bond = to_bond(d);
451 458
452 if ((bond->params.mode != BOND_MODE_XOR) && 459 if ((bond->params.mode != BOND_MODE_XOR) &&
453 (bond->params.mode != BOND_MODE_8023AD)) { 460 (bond->params.mode != BOND_MODE_8023AD)) {
@@ -462,10 +469,12 @@ static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf)
462 return count; 469 return count;
463} 470}
464 471
465static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count) 472static ssize_t bonding_store_xmit_hash(struct device *d,
473 struct device_attribute *attr,
474 const char *buf, size_t count)
466{ 475{
467 int new_value, ret = count; 476 int new_value, ret = count;
468 struct bonding *bond = to_bond(cd); 477 struct bonding *bond = to_bond(d);
469 478
470 if (bond->dev->flags & IFF_UP) { 479 if (bond->dev->flags & IFF_UP) {
471 printk(KERN_ERR DRV_NAME 480 printk(KERN_ERR DRV_NAME
@@ -501,24 +510,28 @@ static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf,
501out: 510out:
502 return ret; 511 return ret;
503} 512}
504static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); 513static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash);
505 514
506/* 515/*
507 * Show and set arp_validate. 516 * Show and set arp_validate.
508 */ 517 */
509static ssize_t bonding_show_arp_validate(struct class_device *cd, char *buf) 518static ssize_t bonding_show_arp_validate(struct device *d,
519 struct device_attribute *attr,
520 char *buf)
510{ 521{
511 struct bonding *bond = to_bond(cd); 522 struct bonding *bond = to_bond(d);
512 523
513 return sprintf(buf, "%s %d\n", 524 return sprintf(buf, "%s %d\n",
514 arp_validate_tbl[bond->params.arp_validate].modename, 525 arp_validate_tbl[bond->params.arp_validate].modename,
515 bond->params.arp_validate) + 1; 526 bond->params.arp_validate) + 1;
516} 527}
517 528
518static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *buf, size_t count) 529static ssize_t bonding_store_arp_validate(struct device *d,
530 struct device_attribute *attr,
531 const char *buf, size_t count)
519{ 532{
520 int new_value; 533 int new_value;
521 struct bonding *bond = to_bond(cd); 534 struct bonding *bond = to_bond(d);
522 535
523 new_value = bond_parse_parm((char *)buf, arp_validate_tbl); 536 new_value = bond_parse_parm((char *)buf, arp_validate_tbl);
524 if (new_value < 0) { 537 if (new_value < 0) {
@@ -548,7 +561,7 @@ static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *b
548 return count; 561 return count;
549} 562}
550 563
551static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); 564static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate);
552 565
553/* 566/*
554 * Show and set the arp timer interval. There are two tricky bits 567 * Show and set the arp timer interval. There are two tricky bits
@@ -556,17 +569,21 @@ static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_valid
556 * MII monitoring. Second, if the ARP timer isn't running, we must 569 * MII monitoring. Second, if the ARP timer isn't running, we must
557 * start it. 570 * start it.
558 */ 571 */
559static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf) 572static ssize_t bonding_show_arp_interval(struct device *d,
573 struct device_attribute *attr,
574 char *buf)
560{ 575{
561 struct bonding *bond = to_bond(cd); 576 struct bonding *bond = to_bond(d);
562 577
563 return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; 578 return sprintf(buf, "%d\n", bond->params.arp_interval) + 1;
564} 579}
565 580
566static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count) 581static ssize_t bonding_store_arp_interval(struct device *d,
582 struct device_attribute *attr,
583 const char *buf, size_t count)
567{ 584{
568 int new_value, ret = count; 585 int new_value, ret = count;
569 struct bonding *bond = to_bond(cd); 586 struct bonding *bond = to_bond(d);
570 587
571 if (sscanf(buf, "%d", &new_value) != 1) { 588 if (sscanf(buf, "%d", &new_value) != 1) {
572 printk(KERN_ERR DRV_NAME 589 printk(KERN_ERR DRV_NAME
@@ -638,15 +655,17 @@ static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *b
638out: 655out:
639 return ret; 656 return ret;
640} 657}
641static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); 658static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval);
642 659
643/* 660/*
644 * Show and set the arp targets. 661 * Show and set the arp targets.
645 */ 662 */
646static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) 663static ssize_t bonding_show_arp_targets(struct device *d,
664 struct device_attribute *attr,
665 char *buf)
647{ 666{
648 int i, res = 0; 667 int i, res = 0;
649 struct bonding *bond = to_bond(cd); 668 struct bonding *bond = to_bond(d);
650 669
651 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { 670 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
652 if (bond->params.arp_targets[i]) 671 if (bond->params.arp_targets[i])
@@ -660,11 +679,13 @@ static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf)
660 return res; 679 return res;
661} 680}
662 681
663static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count) 682static ssize_t bonding_store_arp_targets(struct device *d,
683 struct device_attribute *attr,
684 const char *buf, size_t count)
664{ 685{
665 u32 newtarget; 686 u32 newtarget;
666 int i = 0, done = 0, ret = count; 687 int i = 0, done = 0, ret = count;
667 struct bonding *bond = to_bond(cd); 688 struct bonding *bond = to_bond(d);
668 u32 *targets; 689 u32 *targets;
669 690
670 targets = bond->params.arp_targets; 691 targets = bond->params.arp_targets;
@@ -742,24 +763,28 @@ static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *bu
742out: 763out:
743 return ret; 764 return ret;
744} 765}
745static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); 766static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets);
746 767
747/* 768/*
748 * Show and set the up and down delays. These must be multiples of the 769 * Show and set the up and down delays. These must be multiples of the
749 * MII monitoring value, and are stored internally as the multiplier. 770 * MII monitoring value, and are stored internally as the multiplier.
750 * Thus, we must translate to MS for the real world. 771 * Thus, we must translate to MS for the real world.
751 */ 772 */
752static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf) 773static ssize_t bonding_show_downdelay(struct device *d,
774 struct device_attribute *attr,
775 char *buf)
753{ 776{
754 struct bonding *bond = to_bond(cd); 777 struct bonding *bond = to_bond(d);
755 778
756 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; 779 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1;
757} 780}
758 781
759static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count) 782static ssize_t bonding_store_downdelay(struct device *d,
783 struct device_attribute *attr,
784 const char *buf, size_t count)
760{ 785{
761 int new_value, ret = count; 786 int new_value, ret = count;
762 struct bonding *bond = to_bond(cd); 787 struct bonding *bond = to_bond(d);
763 788
764 if (!(bond->params.miimon)) { 789 if (!(bond->params.miimon)) {
765 printk(KERN_ERR DRV_NAME 790 printk(KERN_ERR DRV_NAME
@@ -800,20 +825,24 @@ static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf,
800out: 825out:
801 return ret; 826 return ret;
802} 827}
803static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); 828static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay);
804 829
805static ssize_t bonding_show_updelay(struct class_device *cd, char *buf) 830static ssize_t bonding_show_updelay(struct device *d,
831 struct device_attribute *attr,
832 char *buf)
806{ 833{
807 struct bonding *bond = to_bond(cd); 834 struct bonding *bond = to_bond(d);
808 835
809 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; 836 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1;
810 837
811} 838}
812 839
813static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count) 840static ssize_t bonding_store_updelay(struct device *d,
841 struct device_attribute *attr,
842 const char *buf, size_t count)
814{ 843{
815 int new_value, ret = count; 844 int new_value, ret = count;
816 struct bonding *bond = to_bond(cd); 845 struct bonding *bond = to_bond(d);
817 846
818 if (!(bond->params.miimon)) { 847 if (!(bond->params.miimon)) {
819 printk(KERN_ERR DRV_NAME 848 printk(KERN_ERR DRV_NAME
@@ -854,25 +883,29 @@ static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, s
854out: 883out:
855 return ret; 884 return ret;
856} 885}
857static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); 886static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay);
858 887
859/* 888/*
860 * Show and set the LACP interval. Interface must be down, and the mode 889 * Show and set the LACP interval. Interface must be down, and the mode
861 * must be set to 802.3ad mode. 890 * must be set to 802.3ad mode.
862 */ 891 */
863static ssize_t bonding_show_lacp(struct class_device *cd, char *buf) 892static ssize_t bonding_show_lacp(struct device *d,
893 struct device_attribute *attr,
894 char *buf)
864{ 895{
865 struct bonding *bond = to_bond(cd); 896 struct bonding *bond = to_bond(d);
866 897
867 return sprintf(buf, "%s %d\n", 898 return sprintf(buf, "%s %d\n",
868 bond_lacp_tbl[bond->params.lacp_fast].modename, 899 bond_lacp_tbl[bond->params.lacp_fast].modename,
869 bond->params.lacp_fast) + 1; 900 bond->params.lacp_fast) + 1;
870} 901}
871 902
872static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count) 903static ssize_t bonding_store_lacp(struct device *d,
904 struct device_attribute *attr,
905 const char *buf, size_t count)
873{ 906{
874 int new_value, ret = count; 907 int new_value, ret = count;
875 struct bonding *bond = to_bond(cd); 908 struct bonding *bond = to_bond(d);
876 909
877 if (bond->dev->flags & IFF_UP) { 910 if (bond->dev->flags & IFF_UP) {
878 printk(KERN_ERR DRV_NAME 911 printk(KERN_ERR DRV_NAME
@@ -906,7 +939,7 @@ static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size
906out: 939out:
907 return ret; 940 return ret;
908} 941}
909static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); 942static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp);
910 943
911/* 944/*
912 * Show and set the MII monitor interval. There are two tricky bits 945 * Show and set the MII monitor interval. There are two tricky bits
@@ -914,17 +947,21 @@ static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bondin
914 * ARP monitoring. Second, if the timer isn't running, we must 947 * ARP monitoring. Second, if the timer isn't running, we must
915 * start it. 948 * start it.
916 */ 949 */
917static ssize_t bonding_show_miimon(struct class_device *cd, char *buf) 950static ssize_t bonding_show_miimon(struct device *d,
951 struct device_attribute *attr,
952 char *buf)
918{ 953{
919 struct bonding *bond = to_bond(cd); 954 struct bonding *bond = to_bond(d);
920 955
921 return sprintf(buf, "%d\n", bond->params.miimon) + 1; 956 return sprintf(buf, "%d\n", bond->params.miimon) + 1;
922} 957}
923 958
924static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count) 959static ssize_t bonding_store_miimon(struct device *d,
960 struct device_attribute *attr,
961 const char *buf, size_t count)
925{ 962{
926 int new_value, ret = count; 963 int new_value, ret = count;
927 struct bonding *bond = to_bond(cd); 964 struct bonding *bond = to_bond(d);
928 965
929 if (sscanf(buf, "%d", &new_value) != 1) { 966 if (sscanf(buf, "%d", &new_value) != 1) {
930 printk(KERN_ERR DRV_NAME 967 printk(KERN_ERR DRV_NAME
@@ -1000,7 +1037,7 @@ static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, si
1000out: 1037out:
1001 return ret; 1038 return ret;
1002} 1039}
1003static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); 1040static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon);
1004 1041
1005/* 1042/*
1006 * Show and set the primary slave. The store function is much 1043 * Show and set the primary slave. The store function is much
@@ -1009,10 +1046,12 @@ static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding
1009 * The bond must be a mode that supports a primary for this be 1046 * The bond must be a mode that supports a primary for this be
1010 * set. 1047 * set.
1011 */ 1048 */
1012static ssize_t bonding_show_primary(struct class_device *cd, char *buf) 1049static ssize_t bonding_show_primary(struct device *d,
1050 struct device_attribute *attr,
1051 char *buf)
1013{ 1052{
1014 int count = 0; 1053 int count = 0;
1015 struct bonding *bond = to_bond(cd); 1054 struct bonding *bond = to_bond(d);
1016 1055
1017 if (bond->primary_slave) 1056 if (bond->primary_slave)
1018 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; 1057 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1;
@@ -1022,11 +1061,13 @@ static ssize_t bonding_show_primary(struct class_device *cd, char *buf)
1022 return count; 1061 return count;
1023} 1062}
1024 1063
1025static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count) 1064static ssize_t bonding_store_primary(struct device *d,
1065 struct device_attribute *attr,
1066 const char *buf, size_t count)
1026{ 1067{
1027 int i; 1068 int i;
1028 struct slave *slave; 1069 struct slave *slave;
1029 struct bonding *bond = to_bond(cd); 1070 struct bonding *bond = to_bond(d);
1030 1071
1031 write_lock_bh(&bond->lock); 1072 write_lock_bh(&bond->lock);
1032 if (!USES_PRIMARY(bond->params.mode)) { 1073 if (!USES_PRIMARY(bond->params.mode)) {
@@ -1065,22 +1106,26 @@ out:
1065 write_unlock_bh(&bond->lock); 1106 write_unlock_bh(&bond->lock);
1066 return count; 1107 return count;
1067} 1108}
1068static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); 1109static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary);
1069 1110
1070/* 1111/*
1071 * Show and set the use_carrier flag. 1112 * Show and set the use_carrier flag.
1072 */ 1113 */
1073static ssize_t bonding_show_carrier(struct class_device *cd, char *buf) 1114static ssize_t bonding_show_carrier(struct device *d,
1115 struct device_attribute *attr,
1116 char *buf)
1074{ 1117{
1075 struct bonding *bond = to_bond(cd); 1118 struct bonding *bond = to_bond(d);
1076 1119
1077 return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; 1120 return sprintf(buf, "%d\n", bond->params.use_carrier) + 1;
1078} 1121}
1079 1122
1080static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count) 1123static ssize_t bonding_store_carrier(struct device *d,
1124 struct device_attribute *attr,
1125 const char *buf, size_t count)
1081{ 1126{
1082 int new_value, ret = count; 1127 int new_value, ret = count;
1083 struct bonding *bond = to_bond(cd); 1128 struct bonding *bond = to_bond(d);
1084 1129
1085 1130
1086 if (sscanf(buf, "%d", &new_value) != 1) { 1131 if (sscanf(buf, "%d", &new_value) != 1) {
@@ -1102,16 +1147,18 @@ static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, s
1102out: 1147out:
1103 return count; 1148 return count;
1104} 1149}
1105static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); 1150static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier);
1106 1151
1107 1152
1108/* 1153/*
1109 * Show and set currently active_slave. 1154 * Show and set currently active_slave.
1110 */ 1155 */
1111static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) 1156static ssize_t bonding_show_active_slave(struct device *d,
1157 struct device_attribute *attr,
1158 char *buf)
1112{ 1159{
1113 struct slave *curr; 1160 struct slave *curr;
1114 struct bonding *bond = to_bond(cd); 1161 struct bonding *bond = to_bond(d);
1115 int count; 1162 int count;
1116 1163
1117 1164
@@ -1126,13 +1173,15 @@ static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf)
1126 return count; 1173 return count;
1127} 1174}
1128 1175
1129static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count) 1176static ssize_t bonding_store_active_slave(struct device *d,
1177 struct device_attribute *attr,
1178 const char *buf, size_t count)
1130{ 1179{
1131 int i; 1180 int i;
1132 struct slave *slave; 1181 struct slave *slave;
1133 struct slave *old_active = NULL; 1182 struct slave *old_active = NULL;
1134 struct slave *new_active = NULL; 1183 struct slave *new_active = NULL;
1135 struct bonding *bond = to_bond(cd); 1184 struct bonding *bond = to_bond(d);
1136 1185
1137 write_lock_bh(&bond->lock); 1186 write_lock_bh(&bond->lock);
1138 if (!USES_PRIMARY(bond->params.mode)) { 1187 if (!USES_PRIMARY(bond->params.mode)) {
@@ -1194,16 +1243,18 @@ out:
1194 return count; 1243 return count;
1195 1244
1196} 1245}
1197static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); 1246static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave);
1198 1247
1199 1248
1200/* 1249/*
1201 * Show link status of the bond interface. 1250 * Show link status of the bond interface.
1202 */ 1251 */
1203static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) 1252static ssize_t bonding_show_mii_status(struct device *d,
1253 struct device_attribute *attr,
1254 char *buf)
1204{ 1255{
1205 struct slave *curr; 1256 struct slave *curr;
1206 struct bonding *bond = to_bond(cd); 1257 struct bonding *bond = to_bond(d);
1207 1258
1208 read_lock(&bond->curr_slave_lock); 1259 read_lock(&bond->curr_slave_lock);
1209 curr = bond->curr_active_slave; 1260 curr = bond->curr_active_slave;
@@ -1211,16 +1262,18 @@ static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf)
1211 1262
1212 return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; 1263 return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1;
1213} 1264}
1214static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); 1265static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
1215 1266
1216 1267
1217/* 1268/*
1218 * Show current 802.3ad aggregator ID. 1269 * Show current 802.3ad aggregator ID.
1219 */ 1270 */
1220static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) 1271static ssize_t bonding_show_ad_aggregator(struct device *d,
1272 struct device_attribute *attr,
1273 char *buf)
1221{ 1274{
1222 int count = 0; 1275 int count = 0;
1223 struct bonding *bond = to_bond(cd); 1276 struct bonding *bond = to_bond(d);
1224 1277
1225 if (bond->params.mode == BOND_MODE_8023AD) { 1278 if (bond->params.mode == BOND_MODE_8023AD) {
1226 struct ad_info ad_info; 1279 struct ad_info ad_info;
@@ -1231,16 +1284,18 @@ static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf)
1231 1284
1232 return count; 1285 return count;
1233} 1286}
1234static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); 1287static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL);
1235 1288
1236 1289
1237/* 1290/*
1238 * Show number of active 802.3ad ports. 1291 * Show number of active 802.3ad ports.
1239 */ 1292 */
1240static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) 1293static ssize_t bonding_show_ad_num_ports(struct device *d,
1294 struct device_attribute *attr,
1295 char *buf)
1241{ 1296{
1242 int count = 0; 1297 int count = 0;
1243 struct bonding *bond = to_bond(cd); 1298 struct bonding *bond = to_bond(d);
1244 1299
1245 if (bond->params.mode == BOND_MODE_8023AD) { 1300 if (bond->params.mode == BOND_MODE_8023AD) {
1246 struct ad_info ad_info; 1301 struct ad_info ad_info;
@@ -1251,16 +1306,18 @@ static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf)
1251 1306
1252 return count; 1307 return count;
1253} 1308}
1254static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); 1309static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL);
1255 1310
1256 1311
1257/* 1312/*
1258 * Show current 802.3ad actor key. 1313 * Show current 802.3ad actor key.
1259 */ 1314 */
1260static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) 1315static ssize_t bonding_show_ad_actor_key(struct device *d,
1316 struct device_attribute *attr,
1317 char *buf)
1261{ 1318{
1262 int count = 0; 1319 int count = 0;
1263 struct bonding *bond = to_bond(cd); 1320 struct bonding *bond = to_bond(d);
1264 1321
1265 if (bond->params.mode == BOND_MODE_8023AD) { 1322 if (bond->params.mode == BOND_MODE_8023AD) {
1266 struct ad_info ad_info; 1323 struct ad_info ad_info;
@@ -1271,16 +1328,18 @@ static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf)
1271 1328
1272 return count; 1329 return count;
1273} 1330}
1274static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); 1331static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL);
1275 1332
1276 1333
1277/* 1334/*
1278 * Show current 802.3ad partner key. 1335 * Show current 802.3ad partner key.
1279 */ 1336 */
1280static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) 1337static ssize_t bonding_show_ad_partner_key(struct device *d,
1338 struct device_attribute *attr,
1339 char *buf)
1281{ 1340{
1282 int count = 0; 1341 int count = 0;
1283 struct bonding *bond = to_bond(cd); 1342 struct bonding *bond = to_bond(d);
1284 1343
1285 if (bond->params.mode == BOND_MODE_8023AD) { 1344 if (bond->params.mode == BOND_MODE_8023AD) {
1286 struct ad_info ad_info; 1345 struct ad_info ad_info;
@@ -1291,16 +1350,18 @@ static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf)
1291 1350
1292 return count; 1351 return count;
1293} 1352}
1294static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); 1353static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL);
1295 1354
1296 1355
1297/* 1356/*
1298 * Show current 802.3ad partner mac. 1357 * Show current 802.3ad partner mac.
1299 */ 1358 */
1300static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) 1359static ssize_t bonding_show_ad_partner_mac(struct device *d,
1360 struct device_attribute *attr,
1361 char *buf)
1301{ 1362{
1302 int count = 0; 1363 int count = 0;
1303 struct bonding *bond = to_bond(cd); 1364 struct bonding *bond = to_bond(d);
1304 1365
1305 if (bond->params.mode == BOND_MODE_8023AD) { 1366 if (bond->params.mode == BOND_MODE_8023AD) {
1306 struct ad_info ad_info; 1367 struct ad_info ad_info;
@@ -1319,30 +1380,30 @@ static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf)
1319 1380
1320 return count; 1381 return count;
1321} 1382}
1322static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); 1383static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
1323 1384
1324 1385
1325 1386
1326static struct attribute *per_bond_attrs[] = { 1387static struct attribute *per_bond_attrs[] = {
1327 &class_device_attr_slaves.attr, 1388 &dev_attr_slaves.attr,
1328 &class_device_attr_mode.attr, 1389 &dev_attr_mode.attr,
1329 &class_device_attr_arp_validate.attr, 1390 &dev_attr_arp_validate.attr,
1330 &class_device_attr_arp_interval.attr, 1391 &dev_attr_arp_interval.attr,
1331 &class_device_attr_arp_ip_target.attr, 1392 &dev_attr_arp_ip_target.attr,
1332 &class_device_attr_downdelay.attr, 1393 &dev_attr_downdelay.attr,
1333 &class_device_attr_updelay.attr, 1394 &dev_attr_updelay.attr,
1334 &class_device_attr_lacp_rate.attr, 1395 &dev_attr_lacp_rate.attr,
1335 &class_device_attr_xmit_hash_policy.attr, 1396 &dev_attr_xmit_hash_policy.attr,
1336 &class_device_attr_miimon.attr, 1397 &dev_attr_miimon.attr,
1337 &class_device_attr_primary.attr, 1398 &dev_attr_primary.attr,
1338 &class_device_attr_use_carrier.attr, 1399 &dev_attr_use_carrier.attr,
1339 &class_device_attr_active_slave.attr, 1400 &dev_attr_active_slave.attr,
1340 &class_device_attr_mii_status.attr, 1401 &dev_attr_mii_status.attr,
1341 &class_device_attr_ad_aggregator.attr, 1402 &dev_attr_ad_aggregator.attr,
1342 &class_device_attr_ad_num_ports.attr, 1403 &dev_attr_ad_num_ports.attr,
1343 &class_device_attr_ad_actor_key.attr, 1404 &dev_attr_ad_actor_key.attr,
1344 &class_device_attr_ad_partner_key.attr, 1405 &dev_attr_ad_partner_key.attr,
1345 &class_device_attr_ad_partner_mac.attr, 1406 &dev_attr_ad_partner_mac.attr,
1346 NULL, 1407 NULL,
1347}; 1408};
1348 1409
@@ -1367,7 +1428,7 @@ int bond_create_sysfs(void)
1367 if (!firstbond) 1428 if (!firstbond)
1368 return -ENODEV; 1429 return -ENODEV;
1369 1430
1370 netdev_class = firstbond->dev->class_dev.class; 1431 netdev_class = firstbond->dev->dev.class;
1371 if (!netdev_class) 1432 if (!netdev_class)
1372 return -ENODEV; 1433 return -ENODEV;
1373 1434
@@ -1410,13 +1471,13 @@ int bond_create_sysfs_entry(struct bonding *bond)
1410 struct net_device *dev = bond->dev; 1471 struct net_device *dev = bond->dev;
1411 int err; 1472 int err;
1412 1473
1413 err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group); 1474 err = sysfs_create_group(&(dev->dev.kobj), &bonding_group);
1414 if (err) { 1475 if (err) {
1415 printk(KERN_EMERG "eek! didn't create group!\n"); 1476 printk(KERN_EMERG "eek! didn't create group!\n");
1416 } 1477 }
1417 1478
1418 if (expected_refcount < 1) 1479 if (expected_refcount < 1)
1419 expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount); 1480 expected_refcount = atomic_read(&bond->dev->dev.kobj.kref.refcount);
1420 1481
1421 return err; 1482 return err;
1422} 1483}
@@ -1427,6 +1488,6 @@ void bond_destroy_sysfs_entry(struct bonding *bond)
1427{ 1488{
1428 struct net_device *dev = bond->dev; 1489 struct net_device *dev = bond->dev;
1429 1490
1430 sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group); 1491 sysfs_remove_group(&(dev->dev.kobj), &bonding_group);
1431} 1492}
1432 1493
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 2194b567239f..0e9ba3c3faf7 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -1102,7 +1102,7 @@ static struct net_device * __init veth_probe_one(int vlan,
1102 } 1102 }
1103 1103
1104 kobject_init(&port->kobject); 1104 kobject_init(&port->kobject);
1105 port->kobject.parent = &dev->class_dev.kobj; 1105 port->kobject.parent = &dev->dev.kobj;
1106 port->kobject.ktype = &veth_port_ktype; 1106 port->kobject.ktype = &veth_port_ktype;
1107 kobject_set_name(&port->kobject, "veth_port"); 1107 kobject_set_name(&port->kobject, "veth_port");
1108 if (0 != kobject_add(&port->kobject)) 1108 if (0 != kobject_add(&port->kobject))
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 5eb7a3536f29..e67361e2bf5d 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -27,8 +27,6 @@
27 27
28#include "macb.h" 28#include "macb.h"
29 29
30#define to_net_dev(class) container_of(class, struct net_device, class_dev)
31
32#define RX_BUFFER_SIZE 128 30#define RX_BUFFER_SIZE 128
33#define RX_RING_SIZE 512 31#define RX_RING_SIZE 512
34#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE) 32#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE)
@@ -945,10 +943,10 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
945 return ret; 943 return ret;
946} 944}
947 945
948static ssize_t macb_mii_show(const struct class_device *cd, char *buf, 946static ssize_t macb_mii_show(const struct device *_dev, char *buf,
949 unsigned long addr) 947 unsigned long addr)
950{ 948{
951 struct net_device *dev = to_net_dev(cd); 949 struct net_device *dev = to_net_dev(_dev);
952 struct macb *bp = netdev_priv(dev); 950 struct macb *bp = netdev_priv(dev);
953 ssize_t ret = -EINVAL; 951 ssize_t ret = -EINVAL;
954 952
@@ -962,11 +960,13 @@ static ssize_t macb_mii_show(const struct class_device *cd, char *buf,
962} 960}
963 961
964#define MII_ENTRY(name, addr) \ 962#define MII_ENTRY(name, addr) \
965static ssize_t show_##name(struct class_device *cd, char *buf) \ 963static ssize_t show_##name(struct device *_dev, \
964 struct device_attribute *attr, \
965 char *buf) \
966{ \ 966{ \
967 return macb_mii_show(cd, buf, addr); \ 967 return macb_mii_show(_dev, buf, addr); \
968} \ 968} \
969static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) 969static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
970 970
971MII_ENTRY(bmcr, MII_BMCR); 971MII_ENTRY(bmcr, MII_BMCR);
972MII_ENTRY(bmsr, MII_BMSR); 972MII_ENTRY(bmsr, MII_BMSR);
@@ -977,13 +977,13 @@ MII_ENTRY(lpa, MII_LPA);
977MII_ENTRY(expansion, MII_EXPANSION); 977MII_ENTRY(expansion, MII_EXPANSION);
978 978
979static struct attribute *macb_mii_attrs[] = { 979static struct attribute *macb_mii_attrs[] = {
980 &class_device_attr_bmcr.attr, 980 &dev_attr_bmcr.attr,
981 &class_device_attr_bmsr.attr, 981 &dev_attr_bmsr.attr,
982 &class_device_attr_physid1.attr, 982 &dev_attr_physid1.attr,
983 &class_device_attr_physid2.attr, 983 &dev_attr_physid2.attr,
984 &class_device_attr_advertise.attr, 984 &dev_attr_advertise.attr,
985 &class_device_attr_lpa.attr, 985 &dev_attr_lpa.attr,
986 &class_device_attr_expansion.attr, 986 &dev_attr_expansion.attr,
987 NULL, 987 NULL,
988}; 988};
989 989
@@ -994,17 +994,17 @@ static struct attribute_group macb_mii_group = {
994 994
995static void macb_unregister_sysfs(struct net_device *net) 995static void macb_unregister_sysfs(struct net_device *net)
996{ 996{
997 struct class_device *class_dev = &net->class_dev; 997 struct device *_dev = &net->dev;
998 998
999 sysfs_remove_group(&class_dev->kobj, &macb_mii_group); 999 sysfs_remove_group(&_dev->kobj, &macb_mii_group);
1000} 1000}
1001 1001
1002static int macb_register_sysfs(struct net_device *net) 1002static int macb_register_sysfs(struct net_device *net)
1003{ 1003{
1004 struct class_device *class_dev = &net->class_dev; 1004 struct device *_dev = &net->dev;
1005 int ret; 1005 int ret;
1006 1006
1007 ret = sysfs_create_group(&class_dev->kobj, &macb_mii_group); 1007 ret = sysfs_create_group(&_dev->kobj, &macb_mii_group);
1008 if (ret) 1008 if (ret)
1009 printk(KERN_WARNING 1009 printk(KERN_WARNING
1010 "%s: sysfs mii attribute registration failed: %d\n", 1010 "%s: sysfs mii attribute registration failed: %d\n",
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 43af61438449..c95614131980 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -1659,7 +1659,7 @@ smc911x_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1659{ 1659{
1660 strncpy(info->driver, CARDNAME, sizeof(info->driver)); 1660 strncpy(info->driver, CARDNAME, sizeof(info->driver));
1661 strncpy(info->version, version, sizeof(info->version)); 1661 strncpy(info->version, version, sizeof(info->version));
1662 strncpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); 1662 strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
1663} 1663}
1664 1664
1665static int smc911x_ethtool_nwayreset(struct net_device *dev) 1665static int smc911x_ethtool_nwayreset(struct net_device *dev)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index e62a9586fb95..49f4b7712ebf 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -1712,7 +1712,7 @@ smc_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1712{ 1712{
1713 strncpy(info->driver, CARDNAME, sizeof(info->driver)); 1713 strncpy(info->driver, CARDNAME, sizeof(info->driver));
1714 strncpy(info->version, version, sizeof(info->version)); 1714 strncpy(info->version, version, sizeof(info->version));
1715 strncpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); 1715 strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
1716} 1716}
1717 1717
1718static int smc_ethtool_nwayreset(struct net_device *dev) 1718static int smc_ethtool_nwayreset(struct net_device *dev)
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 04c19cefa1da..9077e6edde34 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -84,7 +84,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
84 if (strchr(dev->name, '%')) 84 if (strchr(dev->name, '%'))
85 ret = dev_alloc_name(dev, dev->name); 85 ret = dev_alloc_name(dev, dev->name);
86 86
87 SET_NETDEV_DEV(dev, mdev->class_dev.dev); 87 SET_NETDEV_DEV(dev, mdev->dev.parent);
88 if (ret >= 0) 88 if (ret >= 0)
89 ret = register_netdevice(dev); 89 ret = register_netdevice(dev);
90 90
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 2a65bb93de26..4e7f6cf51436 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -4293,8 +4293,8 @@ static void orinoco_get_drvinfo(struct net_device *dev,
4293 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); 4293 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
4294 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); 4294 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
4295 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1); 4295 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
4296 if (dev->class_dev.dev) 4296 if (dev->dev.parent)
4297 strncpy(info->bus_info, dev->class_dev.dev->bus_id, 4297 strncpy(info->bus_info, dev->dev.parent->bus_id,
4298 sizeof(info->bus_info) - 1); 4298 sizeof(info->bus_info) - 1);
4299 else 4299 else
4300 snprintf(info->bus_info, sizeof(info->bus_info) - 1, 4300 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index d08ae8d2726c..d1e502236b2a 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -332,7 +332,7 @@ orinoco_cs_config(struct pcmcia_device *link)
332 332
333 /* Finally, report what we've done */ 333 /* Finally, report what we've done */
334 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 334 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
335 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, 335 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
336 link->irq.AssignedIRQ, link->io.BasePort1, 336 link->irq.AssignedIRQ, link->io.BasePort1,
337 link->io.BasePort1 + link->io.NumPorts1 - 1); 337 link->io.BasePort1 + link->io.NumPorts1 - 1);
338 338
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index cf2d1486b01d..af70460f008a 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -806,7 +806,7 @@ spectrum_cs_config(struct pcmcia_device *link)
806 806
807 /* Finally, report what we've done */ 807 /* Finally, report what we've done */
808 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 808 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
809 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, 809 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
810 link->irq.AssignedIRQ, link->io.BasePort1, 810 link->irq.AssignedIRQ, link->io.BasePort1,
811 link->io.BasePort1 + link->io.NumPorts1 - 1); 811 link->io.BasePort1 + link->io.NumPorts1 - 1);
812 812
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 92d5e8db0de7..358766885260 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -422,7 +422,8 @@ static struct kobj_type pci_driver_kobj_type = {
422 * If no error occurred, the driver remains registered even if 422 * If no error occurred, the driver remains registered even if
423 * no device was claimed during registration. 423 * no device was claimed during registration.
424 */ 424 */
425int __pci_register_driver(struct pci_driver *drv, struct module *owner) 425int __pci_register_driver(struct pci_driver *drv, struct module *owner,
426 const char *mod_name)
426{ 427{
427 int error; 428 int error;
428 429
@@ -430,6 +431,7 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
430 drv->driver.name = drv->name; 431 drv->driver.name = drv->name;
431 drv->driver.bus = &pci_bus_type; 432 drv->driver.bus = &pci_bus_type;
432 drv->driver.owner = owner; 433 drv->driver.owner = owner;
434 drv->driver.mod_name = mod_name;
433 drv->driver.kobj.ktype = &pci_driver_kobj_type; 435 drv->driver.kobj.ktype = &pci_driver_kobj_type;
434 436
435 if (pci_multithread_probe) 437 if (pci_multithread_probe)
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 606a46740338..ac004248324a 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -110,7 +110,7 @@ int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state)
110 110
111 down_read(&pcmcia_socket_list_rwsem); 111 down_read(&pcmcia_socket_list_rwsem);
112 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 112 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
113 if (socket->dev.dev != dev) 113 if (socket->dev.parent != dev)
114 continue; 114 continue;
115 mutex_lock(&socket->skt_mutex); 115 mutex_lock(&socket->skt_mutex);
116 socket_suspend(socket); 116 socket_suspend(socket);
@@ -128,7 +128,7 @@ int pcmcia_socket_dev_resume(struct device *dev)
128 128
129 down_read(&pcmcia_socket_list_rwsem); 129 down_read(&pcmcia_socket_list_rwsem);
130 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 130 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
131 if (socket->dev.dev != dev) 131 if (socket->dev.parent != dev)
132 continue; 132 continue;
133 mutex_lock(&socket->skt_mutex); 133 mutex_lock(&socket->skt_mutex);
134 socket_resume(socket); 134 socket_resume(socket);
@@ -143,12 +143,12 @@ EXPORT_SYMBOL(pcmcia_socket_dev_resume);
143 143
144struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt) 144struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt)
145{ 145{
146 struct class_device *cl_dev = class_device_get(&skt->dev); 146 struct device *dev = get_device(&skt->dev);
147 if (!cl_dev) 147 if (!dev)
148 return NULL; 148 return NULL;
149 skt = class_get_devdata(cl_dev); 149 skt = dev_get_drvdata(dev);
150 if (!try_module_get(skt->owner)) { 150 if (!try_module_get(skt->owner)) {
151 class_device_put(&skt->dev); 151 put_device(&skt->dev);
152 return NULL; 152 return NULL;
153 } 153 }
154 return (skt); 154 return (skt);
@@ -159,14 +159,14 @@ EXPORT_SYMBOL(pcmcia_get_socket);
159void pcmcia_put_socket(struct pcmcia_socket *skt) 159void pcmcia_put_socket(struct pcmcia_socket *skt)
160{ 160{
161 module_put(skt->owner); 161 module_put(skt->owner);
162 class_device_put(&skt->dev); 162 put_device(&skt->dev);
163} 163}
164EXPORT_SYMBOL(pcmcia_put_socket); 164EXPORT_SYMBOL(pcmcia_put_socket);
165 165
166 166
167static void pcmcia_release_socket(struct class_device *class_dev) 167static void pcmcia_release_socket(struct device *dev)
168{ 168{
169 struct pcmcia_socket *socket = class_get_devdata(class_dev); 169 struct pcmcia_socket *socket = dev_get_drvdata(dev);
170 170
171 complete(&socket->socket_released); 171 complete(&socket->socket_released);
172} 172}
@@ -181,7 +181,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
181 struct task_struct *tsk; 181 struct task_struct *tsk;
182 int ret; 182 int ret;
183 183
184 if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops) 184 if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops)
185 return -EINVAL; 185 return -EINVAL;
186 186
187 cs_dbg(socket, 0, "pcmcia_register_socket(0x%p)\n", socket->ops); 187 cs_dbg(socket, 0, "pcmcia_register_socket(0x%p)\n", socket->ops);
@@ -226,9 +226,9 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
226#endif 226#endif
227 227
228 /* set proper values in socket->dev */ 228 /* set proper values in socket->dev */
229 socket->dev.class_data = socket; 229 dev_set_drvdata(&socket->dev, socket);
230 socket->dev.class = &pcmcia_socket_class; 230 socket->dev.class = &pcmcia_socket_class;
231 snprintf(socket->dev.class_id, BUS_ID_SIZE, "pcmcia_socket%u", socket->sock); 231 snprintf(socket->dev.bus_id, BUS_ID_SIZE, "pcmcia_socket%u", socket->sock);
232 232
233 /* base address = 0, map = 0 */ 233 /* base address = 0, map = 0 */
234 socket->cis_mem.flags = 0; 234 socket->cis_mem.flags = 0;
@@ -640,7 +640,7 @@ static int pccardd(void *__skt)
640 skt->ops->set_socket(skt, &skt->socket); 640 skt->ops->set_socket(skt, &skt->socket);
641 641
642 /* register with the device core */ 642 /* register with the device core */
643 ret = class_device_register(&skt->dev); 643 ret = device_register(&skt->dev);
644 if (ret) { 644 if (ret) {
645 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", 645 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
646 skt); 646 skt);
@@ -689,7 +689,7 @@ static int pccardd(void *__skt)
689 remove_wait_queue(&skt->thread_wait, &wait); 689 remove_wait_queue(&skt->thread_wait, &wait);
690 690
691 /* remove from the device core */ 691 /* remove from the device core */
692 class_device_unregister(&skt->dev); 692 device_unregister(&skt->dev);
693 693
694 return 0; 694 return 0;
695} 695}
@@ -904,7 +904,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
904EXPORT_SYMBOL(pcmcia_insert_card); 904EXPORT_SYMBOL(pcmcia_insert_card);
905 905
906 906
907static int pcmcia_socket_uevent(struct class_device *dev, char **envp, 907static int pcmcia_socket_uevent(struct device *dev, char **envp,
908 int num_envp, char *buffer, int buffer_size) 908 int num_envp, char *buffer, int buffer_size)
909{ 909{
910 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); 910 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
@@ -930,8 +930,8 @@ static void pcmcia_release_socket_class(struct class *data)
930 930
931struct class pcmcia_socket_class = { 931struct class pcmcia_socket_class = {
932 .name = "pcmcia_socket", 932 .name = "pcmcia_socket",
933 .uevent = pcmcia_socket_uevent, 933 .dev_uevent = pcmcia_socket_uevent,
934 .release = pcmcia_release_socket, 934 .dev_release = pcmcia_release_socket,
935 .class_release = pcmcia_release_socket_class, 935 .class_release = pcmcia_release_socket_class,
936}; 936};
937EXPORT_SYMBOL(pcmcia_socket_class); 937EXPORT_SYMBOL(pcmcia_socket_class);
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index f573ea04db6f..9fa207e3c7b3 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -142,7 +142,7 @@ struct pcmcia_callback{
142 142
143int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); 143int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
144 144
145#define cs_socket_name(skt) ((skt)->dev.class_id) 145#define cs_socket_name(skt) ((skt)->dev.bus_id)
146 146
147#ifdef DEBUG 147#ifdef DEBUG
148extern int cs_debug_level(int); 148extern int cs_debug_level(int);
@@ -158,6 +158,6 @@ extern int cs_debug_level(int);
158#endif 158#endif
159 159
160#define cs_err(skt, fmt, arg...) \ 160#define cs_err(skt, fmt, arg...) \
161 printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.class_id , ## arg) 161 printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.bus_id , ## arg)
162 162
163#endif /* _LINUX_CS_INTERNAL_H */ 163#endif /* _LINUX_CS_INTERNAL_H */
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 7355eb455a88..18e111e12339 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -572,7 +572,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
572 p_dev->func = function; 572 p_dev->func = function;
573 573
574 p_dev->dev.bus = &pcmcia_bus_type; 574 p_dev->dev.bus = &pcmcia_bus_type;
575 p_dev->dev.parent = s->dev.dev; 575 p_dev->dev.parent = s->dev.parent;
576 p_dev->dev.release = pcmcia_release_dev; 576 p_dev->dev.release = pcmcia_release_dev;
577 bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); 577 bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no);
578 578
@@ -1328,10 +1328,10 @@ static struct pcmcia_callback pcmcia_bus_callback = {
1328 .resume = pcmcia_bus_resume, 1328 .resume = pcmcia_bus_resume,
1329}; 1329};
1330 1330
1331static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev, 1331static int __devinit pcmcia_bus_add_socket(struct device *dev,
1332 struct class_interface *class_intf) 1332 struct class_interface *class_intf)
1333{ 1333{
1334 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1334 struct pcmcia_socket *socket = dev_get_drvdata(dev);
1335 int ret; 1335 int ret;
1336 1336
1337 socket = pcmcia_get_socket(socket); 1337 socket = pcmcia_get_socket(socket);
@@ -1364,10 +1364,10 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1364 return 0; 1364 return 0;
1365} 1365}
1366 1366
1367static void pcmcia_bus_remove_socket(struct class_device *class_dev, 1367static void pcmcia_bus_remove_socket(struct device *dev,
1368 struct class_interface *class_intf) 1368 struct class_interface *class_intf)
1369{ 1369{
1370 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1370 struct pcmcia_socket *socket = dev_get_drvdata(dev);
1371 1371
1372 if (!socket) 1372 if (!socket)
1373 return; 1373 return;
@@ -1389,8 +1389,8 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1389/* the pcmcia_bus_interface is used to handle pcmcia socket devices */ 1389/* the pcmcia_bus_interface is used to handle pcmcia socket devices */
1390static struct class_interface pcmcia_bus_interface = { 1390static struct class_interface pcmcia_bus_interface = {
1391 .class = &pcmcia_socket_class, 1391 .class = &pcmcia_socket_class,
1392 .add = &pcmcia_bus_add_socket, 1392 .add_dev = &pcmcia_bus_add_socket,
1393 .remove = &pcmcia_bus_remove_socket, 1393 .remove_dev = &pcmcia_bus_remove_socket,
1394}; 1394};
1395 1395
1396 1396
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index c2ea07aa7a12..df21e2d16f87 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -161,7 +161,7 @@ static int __devinit i82092aa_pci_probe(struct pci_dev *dev, const struct pci_de
161 pci_set_drvdata(dev, &sockets[i].socket); 161 pci_set_drvdata(dev, &sockets[i].socket);
162 162
163 for (i = 0; i<socket_count; i++) { 163 for (i = 0; i<socket_count; i++) {
164 sockets[i].socket.dev.dev = &dev->dev; 164 sockets[i].socket.dev.parent = &dev->dev;
165 sockets[i].socket.ops = &i82092aa_operations; 165 sockets[i].socket.ops = &i82092aa_operations;
166 sockets[i].socket.resource_ops = &pccard_nonstatic_ops; 166 sockets[i].socket.resource_ops = &pccard_nonstatic_ops;
167 ret = pcmcia_register_socket(&sockets[i].socket); 167 ret = pcmcia_register_socket(&sockets[i].socket);
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index ea74f98a7350..72ff2f615b33 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1298,7 +1298,7 @@ static int __init init_i82365(void)
1298 1298
1299 /* register sockets with the pcmcia core */ 1299 /* register sockets with the pcmcia core */
1300 for (i = 0; i < sockets; i++) { 1300 for (i = 0; i < sockets; i++) {
1301 socket[i].socket.dev.dev = &i82365_device->dev; 1301 socket[i].socket.dev.parent = &i82365_device->dev;
1302 socket[i].socket.ops = &pcic_operations; 1302 socket[i].socket.ops = &pcic_operations;
1303 socket[i].socket.resource_ops = &pccard_nonstatic_ops; 1303 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
1304 socket[i].socket.owner = THIS_MODULE; 1304 socket[i].socket.owner = THIS_MODULE;
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 327372b7a54e..88494149e910 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -59,7 +59,6 @@ typedef struct user_info_t {
59 59
60#ifdef DEBUG 60#ifdef DEBUG
61extern int ds_pc_debug; 61extern int ds_pc_debug;
62#define cs_socket_name(skt) ((skt)->dev.class_id)
63 62
64#define ds_dbg(lvl, fmt, arg...) do { \ 63#define ds_dbg(lvl, fmt, arg...) do { \
65 if (ds_pc_debug >= lvl) \ 64 if (ds_pc_debug >= lvl) \
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index b9201c2ec38b..0ce39de834c4 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -48,7 +48,6 @@ static u8 pcmcia_used_irq[NR_IRQS];
48 48
49#ifdef DEBUG 49#ifdef DEBUG
50extern int ds_pc_debug; 50extern int ds_pc_debug;
51#define cs_socket_name(skt) ((skt)->dev.class_id)
52 51
53#define ds_dbg(skt, lvl, fmt, arg...) do { \ 52#define ds_dbg(skt, lvl, fmt, arg...) do { \
54 if (ds_pc_debug >= lvl) \ 53 if (ds_pc_debug >= lvl) \
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 360c24896548..dd0ddf19ee57 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -682,7 +682,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
682 682
683 socket[i].socket.ops = &pd6729_operations; 683 socket[i].socket.ops = &pd6729_operations;
684 socket[i].socket.resource_ops = &pccard_nonstatic_ops; 684 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
685 socket[i].socket.dev.dev = &dev->dev; 685 socket[i].socket.dev.parent = &dev->dev;
686 socket[i].socket.driver_data = &socket[i]; 686 socket[i].socket.driver_data = &socket[i];
687 } 687 }
688 688
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index c3176b16b7be..bfcaad6021cf 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -616,7 +616,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star
616static struct resource *nonstatic_find_io_region(unsigned long base, int num, 616static struct resource *nonstatic_find_io_region(unsigned long base, int num,
617 unsigned long align, struct pcmcia_socket *s) 617 unsigned long align, struct pcmcia_socket *s)
618{ 618{
619 struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.class_id); 619 struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.bus_id);
620 struct socket_data *s_data = s->resource_data; 620 struct socket_data *s_data = s->resource_data;
621 struct pcmcia_align_data data; 621 struct pcmcia_align_data data;
622 unsigned long min = base; 622 unsigned long min = base;
@@ -650,7 +650,7 @@ static struct resource *nonstatic_find_io_region(unsigned long base, int num,
650static struct resource * nonstatic_find_mem_region(u_long base, u_long num, 650static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
651 u_long align, int low, struct pcmcia_socket *s) 651 u_long align, int low, struct pcmcia_socket *s)
652{ 652{
653 struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.class_id); 653 struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.bus_id);
654 struct socket_data *s_data = s->resource_data; 654 struct socket_data *s_data = s->resource_data;
655 struct pcmcia_align_data data; 655 struct pcmcia_align_data data;
656 unsigned long min, max; 656 unsigned long min, max;
@@ -897,9 +897,10 @@ EXPORT_SYMBOL(pccard_nonstatic_ops);
897 897
898/* sysfs interface to the resource database */ 898/* sysfs interface to the resource database */
899 899
900static ssize_t show_io_db(struct class_device *class_dev, char *buf) 900static ssize_t show_io_db(struct device *dev,
901 struct device_attribute *attr, char *buf)
901{ 902{
902 struct pcmcia_socket *s = class_get_devdata(class_dev); 903 struct pcmcia_socket *s = dev_get_drvdata(dev);
903 struct socket_data *data; 904 struct socket_data *data;
904 struct resource_map *p; 905 struct resource_map *p;
905 ssize_t ret = 0; 906 ssize_t ret = 0;
@@ -920,9 +921,11 @@ static ssize_t show_io_db(struct class_device *class_dev, char *buf)
920 return (ret); 921 return (ret);
921} 922}
922 923
923static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size_t count) 924static ssize_t store_io_db(struct device *dev,
925 struct device_attribute *attr,
926 const char *buf, size_t count)
924{ 927{
925 struct pcmcia_socket *s = class_get_devdata(class_dev); 928 struct pcmcia_socket *s = dev_get_drvdata(dev);
926 unsigned long start_addr, end_addr; 929 unsigned long start_addr, end_addr;
927 unsigned int add = ADD_MANAGED_RESOURCE; 930 unsigned int add = ADD_MANAGED_RESOURCE;
928 ssize_t ret = 0; 931 ssize_t ret = 0;
@@ -947,11 +950,12 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size
947 950
948 return ret ? ret : count; 951 return ret ? ret : count;
949} 952}
950static CLASS_DEVICE_ATTR(available_resources_io, 0600, show_io_db, store_io_db); 953static DEVICE_ATTR(available_resources_io, 0600, show_io_db, store_io_db);
951 954
952static ssize_t show_mem_db(struct class_device *class_dev, char *buf) 955static ssize_t show_mem_db(struct device *dev,
956 struct device_attribute *attr, char *buf)
953{ 957{
954 struct pcmcia_socket *s = class_get_devdata(class_dev); 958 struct pcmcia_socket *s = dev_get_drvdata(dev);
955 struct socket_data *data; 959 struct socket_data *data;
956 struct resource_map *p; 960 struct resource_map *p;
957 ssize_t ret = 0; 961 ssize_t ret = 0;
@@ -972,9 +976,11 @@ static ssize_t show_mem_db(struct class_device *class_dev, char *buf)
972 return (ret); 976 return (ret);
973} 977}
974 978
975static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, size_t count) 979static ssize_t store_mem_db(struct device *dev,
980 struct device_attribute *attr,
981 const char *buf, size_t count)
976{ 982{
977 struct pcmcia_socket *s = class_get_devdata(class_dev); 983 struct pcmcia_socket *s = dev_get_drvdata(dev);
978 unsigned long start_addr, end_addr; 984 unsigned long start_addr, end_addr;
979 unsigned int add = ADD_MANAGED_RESOURCE; 985 unsigned int add = ADD_MANAGED_RESOURCE;
980 ssize_t ret = 0; 986 ssize_t ret = 0;
@@ -999,25 +1005,25 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz
999 1005
1000 return ret ? ret : count; 1006 return ret ? ret : count;
1001} 1007}
1002static CLASS_DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db); 1008static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db);
1003 1009
1004static struct class_device_attribute *pccard_rsrc_attributes[] = { 1010static struct device_attribute *pccard_rsrc_attributes[] = {
1005 &class_device_attr_available_resources_io, 1011 &dev_attr_available_resources_io,
1006 &class_device_attr_available_resources_mem, 1012 &dev_attr_available_resources_mem,
1007 NULL, 1013 NULL,
1008}; 1014};
1009 1015
1010static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev, 1016static int __devinit pccard_sysfs_add_rsrc(struct device *dev,
1011 struct class_interface *class_intf) 1017 struct class_interface *class_intf)
1012{ 1018{
1013 struct pcmcia_socket *s = class_get_devdata(class_dev); 1019 struct pcmcia_socket *s = dev_get_drvdata(dev);
1014 struct class_device_attribute **attr; 1020 struct device_attribute **attr;
1015 int ret = 0; 1021 int ret = 0;
1016 if (s->resource_ops != &pccard_nonstatic_ops) 1022 if (s->resource_ops != &pccard_nonstatic_ops)
1017 return 0; 1023 return 0;
1018 1024
1019 for (attr = pccard_rsrc_attributes; *attr; attr++) { 1025 for (attr = pccard_rsrc_attributes; *attr; attr++) {
1020 ret = class_device_create_file(class_dev, *attr); 1026 ret = device_create_file(dev, *attr);
1021 if (ret) 1027 if (ret)
1022 break; 1028 break;
1023 } 1029 }
@@ -1025,23 +1031,23 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev,
1025 return ret; 1031 return ret;
1026} 1032}
1027 1033
1028static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev, 1034static void __devexit pccard_sysfs_remove_rsrc(struct device *dev,
1029 struct class_interface *class_intf) 1035 struct class_interface *class_intf)
1030{ 1036{
1031 struct pcmcia_socket *s = class_get_devdata(class_dev); 1037 struct pcmcia_socket *s = dev_get_drvdata(dev);
1032 struct class_device_attribute **attr; 1038 struct device_attribute **attr;
1033 1039
1034 if (s->resource_ops != &pccard_nonstatic_ops) 1040 if (s->resource_ops != &pccard_nonstatic_ops)
1035 return; 1041 return;
1036 1042
1037 for (attr = pccard_rsrc_attributes; *attr; attr++) 1043 for (attr = pccard_rsrc_attributes; *attr; attr++)
1038 class_device_remove_file(class_dev, *attr); 1044 device_remove_file(dev, *attr);
1039} 1045}
1040 1046
1041static struct class_interface pccard_rsrc_interface = { 1047static struct class_interface pccard_rsrc_interface = {
1042 .class = &pcmcia_socket_class, 1048 .class = &pcmcia_socket_class,
1043 .add = &pccard_sysfs_add_rsrc, 1049 .add_dev = &pccard_sysfs_add_rsrc,
1044 .remove = __devexit_p(&pccard_sysfs_remove_rsrc), 1050 .remove_dev = __devexit_p(&pccard_sysfs_remove_rsrc),
1045}; 1051};
1046 1052
1047static int __init nonstatic_sysfs_init(void) 1053static int __init nonstatic_sysfs_init(void)
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index e433704e026a..d2a3bea55de2 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -478,10 +478,10 @@ dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, i
478 * 478 *
479 * Returns: the number of characters added to the buffer 479 * Returns: the number of characters added to the buffer
480 */ 480 */
481static ssize_t show_status(struct class_device *class_dev, char *buf) 481static ssize_t show_status(struct device *dev, char *buf)
482{ 482{
483 struct soc_pcmcia_socket *skt = 483 struct soc_pcmcia_socket *skt =
484 container_of(class_dev, struct soc_pcmcia_socket, socket.dev); 484 container_of(dev, struct soc_pcmcia_socket, socket.dev);
485 char *p = buf; 485 char *p = buf;
486 486
487 p+=sprintf(p, "slot : %d\n", skt->nr); 487 p+=sprintf(p, "slot : %d\n", skt->nr);
@@ -747,7 +747,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
747 747
748 add_timer(&skt->poll_timer); 748 add_timer(&skt->poll_timer);
749 749
750 class_device_create_file(&skt->socket.dev, &class_device_attr_status); 750 device_create_file(&skt->socket.dev, &device_attr_status);
751 } 751 }
752 752
753 dev_set_drvdata(dev, sinfo); 753 dev_set_drvdata(dev, sinfo);
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index b005602d6b53..ea5765c3bdc0 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -40,7 +40,8 @@
40 40
41#define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev) 41#define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev)
42 42
43static ssize_t pccard_show_type(struct class_device *dev, char *buf) 43static ssize_t pccard_show_type(struct device *dev, struct device_attribute *attr,
44 char *buf)
44{ 45{
45 struct pcmcia_socket *s = to_socket(dev); 46 struct pcmcia_socket *s = to_socket(dev);
46 47
@@ -50,9 +51,10 @@ static ssize_t pccard_show_type(struct class_device *dev, char *buf)
50 return sprintf(buf, "32-bit\n"); 51 return sprintf(buf, "32-bit\n");
51 return sprintf(buf, "16-bit\n"); 52 return sprintf(buf, "16-bit\n");
52} 53}
53static CLASS_DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); 54static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
54 55
55static ssize_t pccard_show_voltage(struct class_device *dev, char *buf) 56static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *attr,
57 char *buf)
56{ 58{
57 struct pcmcia_socket *s = to_socket(dev); 59 struct pcmcia_socket *s = to_socket(dev);
58 60
@@ -63,28 +65,31 @@ static ssize_t pccard_show_voltage(struct class_device *dev, char *buf)
63 s->socket.Vcc % 10); 65 s->socket.Vcc % 10);
64 return sprintf(buf, "X.XV\n"); 66 return sprintf(buf, "X.XV\n");
65} 67}
66static CLASS_DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL); 68static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
67 69
68static ssize_t pccard_show_vpp(struct class_device *dev, char *buf) 70static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr,
71 char *buf)
69{ 72{
70 struct pcmcia_socket *s = to_socket(dev); 73 struct pcmcia_socket *s = to_socket(dev);
71 if (!(s->state & SOCKET_PRESENT)) 74 if (!(s->state & SOCKET_PRESENT))
72 return -ENODEV; 75 return -ENODEV;
73 return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10); 76 return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
74} 77}
75static CLASS_DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL); 78static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
76 79
77static ssize_t pccard_show_vcc(struct class_device *dev, char *buf) 80static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr,
81 char *buf)
78{ 82{
79 struct pcmcia_socket *s = to_socket(dev); 83 struct pcmcia_socket *s = to_socket(dev);
80 if (!(s->state & SOCKET_PRESENT)) 84 if (!(s->state & SOCKET_PRESENT))
81 return -ENODEV; 85 return -ENODEV;
82 return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10); 86 return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
83} 87}
84static CLASS_DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL); 88static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
85 89
86 90
87static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count) 91static ssize_t pccard_store_insert(struct device *dev, struct device_attribute *attr,
92 const char *buf, size_t count)
88{ 93{
89 ssize_t ret; 94 ssize_t ret;
90 struct pcmcia_socket *s = to_socket(dev); 95 struct pcmcia_socket *s = to_socket(dev);
@@ -96,16 +101,20 @@ static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, si
96 101
97 return ret ? ret : count; 102 return ret ? ret : count;
98} 103}
99static CLASS_DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert); 104static DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert);
100 105
101 106
102static ssize_t pccard_show_card_pm_state(struct class_device *dev, char *buf) 107static ssize_t pccard_show_card_pm_state(struct device *dev,
108 struct device_attribute *attr,
109 char *buf)
103{ 110{
104 struct pcmcia_socket *s = to_socket(dev); 111 struct pcmcia_socket *s = to_socket(dev);
105 return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on"); 112 return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on");
106} 113}
107 114
108static ssize_t pccard_store_card_pm_state(struct class_device *dev, const char *buf, size_t count) 115static ssize_t pccard_store_card_pm_state(struct device *dev,
116 struct device_attribute *attr,
117 const char *buf, size_t count)
109{ 118{
110 ssize_t ret = -EINVAL; 119 ssize_t ret = -EINVAL;
111 struct pcmcia_socket *s = to_socket(dev); 120 struct pcmcia_socket *s = to_socket(dev);
@@ -120,9 +129,11 @@ static ssize_t pccard_store_card_pm_state(struct class_device *dev, const char *
120 129
121 return ret ? -ENODEV : count; 130 return ret ? -ENODEV : count;
122} 131}
123static CLASS_DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state); 132static DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state);
124 133
125static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, size_t count) 134static ssize_t pccard_store_eject(struct device *dev,
135 struct device_attribute *attr,
136 const char *buf, size_t count)
126{ 137{
127 ssize_t ret; 138 ssize_t ret;
128 struct pcmcia_socket *s = to_socket(dev); 139 struct pcmcia_socket *s = to_socket(dev);
@@ -134,16 +145,20 @@ static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, siz
134 145
135 return ret ? ret : count; 146 return ret ? ret : count;
136} 147}
137static CLASS_DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject); 148static DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject);
138 149
139 150
140static ssize_t pccard_show_irq_mask(struct class_device *dev, char *buf) 151static ssize_t pccard_show_irq_mask(struct device *dev,
152 struct device_attribute *attr,
153 char *buf)
141{ 154{
142 struct pcmcia_socket *s = to_socket(dev); 155 struct pcmcia_socket *s = to_socket(dev);
143 return sprintf(buf, "0x%04x\n", s->irq_mask); 156 return sprintf(buf, "0x%04x\n", s->irq_mask);
144} 157}
145 158
146static ssize_t pccard_store_irq_mask(struct class_device *dev, const char *buf, size_t count) 159static ssize_t pccard_store_irq_mask(struct device *dev,
160 struct device_attribute *attr,
161 const char *buf, size_t count)
147{ 162{
148 ssize_t ret; 163 ssize_t ret;
149 struct pcmcia_socket *s = to_socket(dev); 164 struct pcmcia_socket *s = to_socket(dev);
@@ -161,16 +176,19 @@ static ssize_t pccard_store_irq_mask(struct class_device *dev, const char *buf,
161 176
162 return ret ? ret : count; 177 return ret ? ret : count;
163} 178}
164static CLASS_DEVICE_ATTR(card_irq_mask, 0600, pccard_show_irq_mask, pccard_store_irq_mask); 179static DEVICE_ATTR(card_irq_mask, 0600, pccard_show_irq_mask, pccard_store_irq_mask);
165 180
166 181
167static ssize_t pccard_show_resource(struct class_device *dev, char *buf) 182static ssize_t pccard_show_resource(struct device *dev,
183 struct device_attribute *attr, char *buf)
168{ 184{
169 struct pcmcia_socket *s = to_socket(dev); 185 struct pcmcia_socket *s = to_socket(dev);
170 return sprintf(buf, "%s\n", s->resource_setup_done ? "yes" : "no"); 186 return sprintf(buf, "%s\n", s->resource_setup_done ? "yes" : "no");
171} 187}
172 188
173static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, size_t count) 189static ssize_t pccard_store_resource(struct device *dev,
190 struct device_attribute *attr,
191 const char *buf, size_t count)
174{ 192{
175 unsigned long flags; 193 unsigned long flags;
176 struct pcmcia_socket *s = to_socket(dev); 194 struct pcmcia_socket *s = to_socket(dev);
@@ -196,7 +214,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf,
196 214
197 return count; 215 return count;
198} 216}
199static CLASS_DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource); 217static DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource);
200 218
201 219
202static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off, size_t count) 220static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off, size_t count)
@@ -279,7 +297,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size
279 if (off + count > size) 297 if (off + count > size)
280 count = size - off; 298 count = size - off;
281 299
282 s = to_socket(container_of(kobj, struct class_device, kobj)); 300 s = to_socket(container_of(kobj, struct device, kobj));
283 301
284 if (!(s->state & SOCKET_PRESENT)) 302 if (!(s->state & SOCKET_PRESENT))
285 return -ENODEV; 303 return -ENODEV;
@@ -296,7 +314,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size
296 314
297static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, size_t count) 315static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, size_t count)
298{ 316{
299 struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj)); 317 struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj));
300 cisdump_t *cis; 318 cisdump_t *cis;
301 int error; 319 int error;
302 320
@@ -335,16 +353,16 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
335} 353}
336 354
337 355
338static struct class_device_attribute *pccard_socket_attributes[] = { 356static struct device_attribute *pccard_socket_attributes[] = {
339 &class_device_attr_card_type, 357 &dev_attr_card_type,
340 &class_device_attr_card_voltage, 358 &dev_attr_card_voltage,
341 &class_device_attr_card_vpp, 359 &dev_attr_card_vpp,
342 &class_device_attr_card_vcc, 360 &dev_attr_card_vcc,
343 &class_device_attr_card_insert, 361 &dev_attr_card_insert,
344 &class_device_attr_card_pm_state, 362 &dev_attr_card_pm_state,
345 &class_device_attr_card_eject, 363 &dev_attr_card_eject,
346 &class_device_attr_card_irq_mask, 364 &dev_attr_card_irq_mask,
347 &class_device_attr_available_resources_setup_done, 365 &dev_attr_available_resources_setup_done,
348 NULL, 366 NULL,
349}; 367};
350 368
@@ -355,35 +373,35 @@ static struct bin_attribute pccard_cis_attr = {
355 .write = pccard_store_cis, 373 .write = pccard_store_cis,
356}; 374};
357 375
358static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev, 376static int __devinit pccard_sysfs_add_socket(struct device *dev,
359 struct class_interface *class_intf) 377 struct class_interface *class_intf)
360{ 378{
361 struct class_device_attribute **attr; 379 struct device_attribute **attr;
362 int ret = 0; 380 int ret = 0;
363 381
364 for (attr = pccard_socket_attributes; *attr; attr++) { 382 for (attr = pccard_socket_attributes; *attr; attr++) {
365 ret = class_device_create_file(class_dev, *attr); 383 ret = device_create_file(dev, *attr);
366 if (ret) 384 if (ret)
367 break; 385 break;
368 } 386 }
369 if (!ret) 387 if (!ret)
370 ret = sysfs_create_bin_file(&class_dev->kobj, &pccard_cis_attr); 388 ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
371 389
372 return ret; 390 return ret;
373} 391}
374 392
375static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev, 393static void __devexit pccard_sysfs_remove_socket(struct device *dev,
376 struct class_interface *class_intf) 394 struct class_interface *class_intf)
377{ 395{
378 struct class_device_attribute **attr; 396 struct device_attribute **attr;
379 397
380 sysfs_remove_bin_file(&class_dev->kobj, &pccard_cis_attr); 398 sysfs_remove_bin_file(&dev->kobj, &pccard_cis_attr);
381 for (attr = pccard_socket_attributes; *attr; attr++) 399 for (attr = pccard_socket_attributes; *attr; attr++)
382 class_device_remove_file(class_dev, *attr); 400 device_remove_file(dev, *attr);
383} 401}
384 402
385struct class_interface pccard_sysfs_interface = { 403struct class_interface pccard_sysfs_interface = {
386 .class = &pcmcia_socket_class, 404 .class = &pcmcia_socket_class,
387 .add = &pccard_sysfs_add_socket, 405 .add_dev = &pccard_sysfs_add_socket,
388 .remove = __devexit_p(&pccard_sysfs_remove_socket), 406 .remove_dev = __devexit_p(&pccard_sysfs_remove_socket),
389}; 407};
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 2d2f415f80a8..c158cf38b9dd 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -512,7 +512,7 @@ static int __init init_tcic(void)
512 for (i = 0; i < sockets; i++) { 512 for (i = 0; i < sockets; i++) {
513 socket_table[i].socket.ops = &tcic_operations; 513 socket_table[i].socket.ops = &tcic_operations;
514 socket_table[i].socket.resource_ops = &pccard_nonstatic_ops; 514 socket_table[i].socket.resource_ops = &pccard_nonstatic_ops;
515 socket_table[i].socket.dev.dev = &tcic_device.dev; 515 socket_table[i].socket.dev.parent = &tcic_device.dev;
516 ret = pcmcia_register_socket(&socket_table[i].socket); 516 ret = pcmcia_register_socket(&socket_table[i].socket);
517 if (ret && i) 517 if (ret && i)
518 pcmcia_unregister_socket(&socket_table[0].socket); 518 pcmcia_unregister_socket(&socket_table[0].socket);
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index da471bddc972..a61d768f6e0e 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -1104,7 +1104,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1104 /* prepare pcmcia_socket */ 1104 /* prepare pcmcia_socket */
1105 socket->socket.ops = &yenta_socket_operations; 1105 socket->socket.ops = &yenta_socket_operations;
1106 socket->socket.resource_ops = &pccard_nonstatic_ops; 1106 socket->socket.resource_ops = &pccard_nonstatic_ops;
1107 socket->socket.dev.dev = &dev->dev; 1107 socket->socket.dev.parent = &dev->dev;
1108 socket->socket.driver_data = socket; 1108 socket->socket.driver_data = socket;
1109 socket->socket.owner = THIS_MODULE; 1109 socket->socket.owner = THIS_MODULE;
1110 socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD; 1110 socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 8b41f9cc2560..dccdc50b0296 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1234,7 +1234,7 @@ static int init_queue(struct driver_data *drv_data)
1234 1234
1235 INIT_WORK(&drv_data->pump_messages, pump_messages); 1235 INIT_WORK(&drv_data->pump_messages, pump_messages);
1236 drv_data->workqueue = create_singlethread_workqueue( 1236 drv_data->workqueue = create_singlethread_workqueue(
1237 drv_data->master->cdev.dev->bus_id); 1237 drv_data->master->dev.parent->bus_id);
1238 if (drv_data->workqueue == NULL) 1238 if (drv_data->workqueue == NULL)
1239 return -EBUSY; 1239 return -EBUSY;
1240 1240
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 6307428d2c94..35d8c01b42ac 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -193,7 +193,7 @@ struct spi_device *__init_or_module
193spi_new_device(struct spi_master *master, struct spi_board_info *chip) 193spi_new_device(struct spi_master *master, struct spi_board_info *chip)
194{ 194{
195 struct spi_device *proxy; 195 struct spi_device *proxy;
196 struct device *dev = master->cdev.dev; 196 struct device *dev = &master->dev;
197 int status; 197 int status;
198 198
199 /* NOTE: caller did any chip->bus_num checks necessary */ 199 /* NOTE: caller did any chip->bus_num checks necessary */
@@ -215,7 +215,7 @@ spi_new_device(struct spi_master *master, struct spi_board_info *chip)
215 proxy->modalias = chip->modalias; 215 proxy->modalias = chip->modalias;
216 216
217 snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, 217 snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
218 "%s.%u", master->cdev.class_id, 218 "%s.%u", master->dev.bus_id,
219 chip->chip_select); 219 chip->chip_select);
220 proxy->dev.parent = dev; 220 proxy->dev.parent = dev;
221 proxy->dev.bus = &spi_bus_type; 221 proxy->dev.bus = &spi_bus_type;
@@ -290,7 +290,7 @@ static void __init_or_module
290scan_boardinfo(struct spi_master *master) 290scan_boardinfo(struct spi_master *master)
291{ 291{
292 struct boardinfo *bi; 292 struct boardinfo *bi;
293 struct device *dev = master->cdev.dev; 293 struct device *dev = master->dev.parent;
294 294
295 down(&board_lock); 295 down(&board_lock);
296 list_for_each_entry(bi, &board_list, list) { 296 list_for_each_entry(bi, &board_list, list) {
@@ -319,18 +319,18 @@ scan_boardinfo(struct spi_master *master)
319 319
320/*-------------------------------------------------------------------------*/ 320/*-------------------------------------------------------------------------*/
321 321
322static void spi_master_release(struct class_device *cdev) 322static void spi_master_release(struct device *dev)
323{ 323{
324 struct spi_master *master; 324 struct spi_master *master;
325 325
326 master = container_of(cdev, struct spi_master, cdev); 326 master = container_of(dev, struct spi_master, dev);
327 kfree(master); 327 kfree(master);
328} 328}
329 329
330static struct class spi_master_class = { 330static struct class spi_master_class = {
331 .name = "spi_master", 331 .name = "spi_master",
332 .owner = THIS_MODULE, 332 .owner = THIS_MODULE,
333 .release = spi_master_release, 333 .dev_release = spi_master_release,
334}; 334};
335 335
336 336
@@ -364,9 +364,9 @@ spi_alloc_master(struct device *dev, unsigned size)
364 if (!master) 364 if (!master)
365 return NULL; 365 return NULL;
366 366
367 class_device_initialize(&master->cdev); 367 device_initialize(&master->dev);
368 master->cdev.class = &spi_master_class; 368 master->dev.class = &spi_master_class;
369 master->cdev.dev = get_device(dev); 369 master->dev.parent = get_device(dev);
370 spi_master_set_devdata(master, &master[1]); 370 spi_master_set_devdata(master, &master[1]);
371 371
372 return master; 372 return master;
@@ -396,7 +396,7 @@ int __init_or_module
396spi_register_master(struct spi_master *master) 396spi_register_master(struct spi_master *master)
397{ 397{
398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1); 398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
399 struct device *dev = master->cdev.dev; 399 struct device *dev = master->dev.parent;
400 int status = -ENODEV; 400 int status = -ENODEV;
401 int dynamic = 0; 401 int dynamic = 0;
402 402
@@ -412,12 +412,12 @@ spi_register_master(struct spi_master *master)
412 /* register the device, then userspace will see it. 412 /* register the device, then userspace will see it.
413 * registration fails if the bus ID is in use. 413 * registration fails if the bus ID is in use.
414 */ 414 */
415 snprintf(master->cdev.class_id, sizeof master->cdev.class_id, 415 snprintf(master->dev.bus_id, sizeof master->dev.bus_id,
416 "spi%u", master->bus_num); 416 "spi%u", master->bus_num);
417 status = class_device_add(&master->cdev); 417 status = device_add(&master->dev);
418 if (status < 0) 418 if (status < 0)
419 goto done; 419 goto done;
420 dev_dbg(dev, "registered master %s%s\n", master->cdev.class_id, 420 dev_dbg(dev, "registered master %s%s\n", master->dev.bus_id,
421 dynamic ? " (dynamic)" : ""); 421 dynamic ? " (dynamic)" : "");
422 422
423 /* populate children from any spi device tables */ 423 /* populate children from any spi device tables */
@@ -449,8 +449,8 @@ void spi_unregister_master(struct spi_master *master)
449{ 449{
450 int dummy; 450 int dummy;
451 451
452 dummy = device_for_each_child(master->cdev.dev, NULL, __unregister); 452 dummy = device_for_each_child(&master->dev, NULL, __unregister);
453 class_device_unregister(&master->cdev); 453 device_unregister(&master->dev);
454} 454}
455EXPORT_SYMBOL_GPL(spi_unregister_master); 455EXPORT_SYMBOL_GPL(spi_unregister_master);
456 456
@@ -471,7 +471,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
471 471
472 down(&spi_master_class.sem); 472 down(&spi_master_class.sem);
473 list_for_each_entry(cdev, &spi_master_class.children, node) { 473 list_for_each_entry(cdev, &spi_master_class.children, node) {
474 m = container_of(cdev, struct spi_master, cdev); 474 m = container_of(cdev, struct spi_master, dev.kobj);
475 if (m->bus_num == bus_num) { 475 if (m->bus_num == bus_num) {
476 master = spi_master_get(m); 476 master = spi_master_get(m);
477 break; 477 break;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 57289b61d0be..4638e6c83715 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -479,7 +479,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
479 /* this task is the only thing to touch the SPI bits */ 479 /* this task is the only thing to touch the SPI bits */
480 bitbang->busy = 0; 480 bitbang->busy = 0;
481 bitbang->workqueue = create_singlethread_workqueue( 481 bitbang->workqueue = create_singlethread_workqueue(
482 bitbang->master->cdev.dev->bus_id); 482 bitbang->master->dev.parent->bus_id);
483 if (bitbang->workqueue == NULL) { 483 if (bitbang->workqueue == NULL) {
484 status = -EBUSY; 484 status = -EBUSY;
485 goto err1; 485 goto err1;
@@ -513,14 +513,14 @@ int spi_bitbang_stop(struct spi_bitbang *bitbang)
513 while (!list_empty(&bitbang->queue) && limit--) { 513 while (!list_empty(&bitbang->queue) && limit--) {
514 spin_unlock_irq(&bitbang->lock); 514 spin_unlock_irq(&bitbang->lock);
515 515
516 dev_dbg(bitbang->master->cdev.dev, "wait for queue\n"); 516 dev_dbg(&bitbang->master->dev, "wait for queue\n");
517 msleep(10); 517 msleep(10);
518 518
519 spin_lock_irq(&bitbang->lock); 519 spin_lock_irq(&bitbang->lock);
520 } 520 }
521 spin_unlock_irq(&bitbang->lock); 521 spin_unlock_irq(&bitbang->lock);
522 if (!list_empty(&bitbang->queue)) { 522 if (!list_empty(&bitbang->queue)) {
523 dev_err(bitbang->master->cdev.dev, "queue didn't empty\n"); 523 dev_err(&bitbang->master->dev, "queue didn't empty\n");
524 return -EBUSY; 524 return -EBUSY;
525 } 525 }
526 526
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index 312987a03210..31b7970ae463 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -246,7 +246,7 @@ static void butterfly_attach(struct parport *p)
246 * and no way to be selective about what it binds to. 246 * and no way to be selective about what it binds to.
247 */ 247 */
248 248
249 /* FIXME where should master->cdev.dev come from? 249 /* FIXME where should master->dev.parent come from?
250 * e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc 250 * e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc
251 * setting up a platform device like this is an ugly kluge... 251 * setting up a platform device like this is an ugly kluge...
252 */ 252 */
@@ -386,7 +386,7 @@ static void butterfly_detach(struct parport *p)
386 butterfly = NULL; 386 butterfly = NULL;
387 387
388 /* stop() unregisters child devices too */ 388 /* stop() unregisters child devices too */
389 pdev = to_platform_device(pp->bitbang.master->cdev.dev); 389 pdev = to_platform_device(pp->bitbang.master->dev.parent);
390 status = spi_bitbang_stop(&pp->bitbang); 390 status = spi_bitbang_stop(&pp->bitbang);
391 391
392 /* turn off VCC */ 392 /* turn off VCC */
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d6eb5ce1dd1d..d505926aa9cc 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -750,7 +750,8 @@ EXPORT_SYMBOL_GPL(usb_deregister_device_driver);
750 * usb_register_dev() to enable that functionality. This function no longer 750 * usb_register_dev() to enable that functionality. This function no longer
751 * takes care of that. 751 * takes care of that.
752 */ 752 */
753int usb_register_driver(struct usb_driver *new_driver, struct module *owner) 753int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
754 const char *mod_name)
754{ 755{
755 int retval = 0; 756 int retval = 0;
756 757
@@ -763,6 +764,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
763 new_driver->drvwrap.driver.probe = usb_probe_interface; 764 new_driver->drvwrap.driver.probe = usb_probe_interface;
764 new_driver->drvwrap.driver.remove = usb_unbind_interface; 765 new_driver->drvwrap.driver.remove = usb_unbind_interface;
765 new_driver->drvwrap.driver.owner = owner; 766 new_driver->drvwrap.driver.owner = owner;
767 new_driver->drvwrap.driver.mod_name = mod_name;
766 spin_lock_init(&new_driver->dynids.lock); 768 spin_lock_init(&new_driver->dynids.lock);
767 INIT_LIST_HEAD(&new_driver->dynids.list); 769 INIT_LIST_HEAD(&new_driver->dynids.list);
768 770
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c
index e47466268565..4f4fc3be192e 100644
--- a/drivers/usb/input/hid-lgff.c
+++ b/drivers/usb/input/hid-lgff.c
@@ -32,7 +32,7 @@
32#include <linux/hid.h> 32#include <linux/hid.h>
33#include "usbhid.h" 33#include "usbhid.h"
34 34
35struct device_type { 35struct dev_type {
36 u16 idVendor; 36 u16 idVendor;
37 u16 idProduct; 37 u16 idProduct;
38 const signed short *ff; 38 const signed short *ff;
@@ -48,7 +48,7 @@ static const signed short ff_joystick[] = {
48 -1 48 -1
49}; 49};
50 50
51static const struct device_type devices[] = { 51static const struct dev_type devices[] = {
52 { 0x046d, 0xc211, ff_rumble }, 52 { 0x046d, 0xc211, ff_rumble },
53 { 0x046d, 0xc219, ff_rumble }, 53 { 0x046d, 0xc219, ff_rumble },
54 { 0x046d, 0xc283, ff_joystick }, 54 { 0x046d, 0xc283, ff_joystick },
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index e8f540d38d48..d3b9f5f07db1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17 17
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <asm/semaphore.h>
19 20
20#include "sysfs.h" 21#include "sysfs.h"
21 22
@@ -146,7 +147,7 @@ static int open(struct inode * inode, struct file * file)
146 Error: 147 Error:
147 module_put(attr->attr.owner); 148 module_put(attr->attr.owner);
148 Done: 149 Done:
149 if (error && kobj) 150 if (error)
150 kobject_put(kobj); 151 kobject_put(kobj);
151 return error; 152 return error;
152} 153}
@@ -157,8 +158,7 @@ static int release(struct inode * inode, struct file * file)
157 struct bin_attribute * attr = to_bin_attr(file->f_path.dentry); 158 struct bin_attribute * attr = to_bin_attr(file->f_path.dentry);
158 u8 * buffer = file->private_data; 159 u8 * buffer = file->private_data;
159 160
160 if (kobj) 161 kobject_put(kobj);
161 kobject_put(kobj);
162 module_put(attr->attr.owner); 162 module_put(attr->attr.owner);
163 kfree(buffer); 163 kfree(buffer);
164 return 0; 164 return 0;
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 511edef8b321..9dcdf556c99c 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -9,6 +9,7 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kobject.h> 10#include <linux/kobject.h>
11#include <linux/namei.h> 11#include <linux/namei.h>
12#include <asm/semaphore.h>
12#include "sysfs.h" 13#include "sysfs.h"
13 14
14DECLARE_RWSEM(sysfs_rename_sem); 15DECLARE_RWSEM(sysfs_rename_sem);
@@ -32,8 +33,7 @@ static struct dentry_operations sysfs_dentry_ops = {
32/* 33/*
33 * Allocates a new sysfs_dirent and links it to the parent sysfs_dirent 34 * Allocates a new sysfs_dirent and links it to the parent sysfs_dirent
34 */ 35 */
35static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd, 36static struct sysfs_dirent * __sysfs_new_dirent(void * element)
36 void * element)
37{ 37{
38 struct sysfs_dirent * sd; 38 struct sysfs_dirent * sd;
39 39
@@ -45,12 +45,28 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
45 atomic_set(&sd->s_count, 1); 45 atomic_set(&sd->s_count, 1);
46 atomic_set(&sd->s_event, 1); 46 atomic_set(&sd->s_event, 1);
47 INIT_LIST_HEAD(&sd->s_children); 47 INIT_LIST_HEAD(&sd->s_children);
48 list_add(&sd->s_sibling, &parent_sd->s_children); 48 INIT_LIST_HEAD(&sd->s_sibling);
49 sd->s_element = element; 49 sd->s_element = element;
50 50
51 return sd; 51 return sd;
52} 52}
53 53
54static void __sysfs_list_dirent(struct sysfs_dirent *parent_sd,
55 struct sysfs_dirent *sd)
56{
57 if (sd)
58 list_add(&sd->s_sibling, &parent_sd->s_children);
59}
60
61static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent *parent_sd,
62 void * element)
63{
64 struct sysfs_dirent *sd;
65 sd = __sysfs_new_dirent(element);
66 __sysfs_list_dirent(parent_sd, sd);
67 return sd;
68}
69
54/* 70/*
55 * 71 *
56 * Return -EEXIST if there is already a sysfs element with the same name for 72 * Return -EEXIST if there is already a sysfs element with the same name for
@@ -77,14 +93,14 @@ int sysfs_dirent_exist(struct sysfs_dirent *parent_sd,
77} 93}
78 94
79 95
80int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry, 96static struct sysfs_dirent *
81 void * element, umode_t mode, int type) 97__sysfs_make_dirent(struct dentry *dentry, void *element, mode_t mode, int type)
82{ 98{
83 struct sysfs_dirent * sd; 99 struct sysfs_dirent * sd;
84 100
85 sd = sysfs_new_dirent(parent_sd, element); 101 sd = __sysfs_new_dirent(element);
86 if (!sd) 102 if (!sd)
87 return -ENOMEM; 103 goto out;
88 104
89 sd->s_mode = mode; 105 sd->s_mode = mode;
90 sd->s_type = type; 106 sd->s_type = type;
@@ -94,7 +110,19 @@ int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry,
94 dentry->d_op = &sysfs_dentry_ops; 110 dentry->d_op = &sysfs_dentry_ops;
95 } 111 }
96 112
97 return 0; 113out:
114 return sd;
115}
116
117int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry,
118 void * element, umode_t mode, int type)
119{
120 struct sysfs_dirent *sd;
121
122 sd = __sysfs_make_dirent(dentry, element, mode, type);
123 __sysfs_list_dirent(parent_sd, sd);
124
125 return sd ? 0 : -ENOMEM;
98} 126}
99 127
100static int init_dir(struct inode * inode) 128static int init_dir(struct inode * inode)
@@ -165,11 +193,11 @@ int sysfs_create_subdir(struct kobject * k, const char * n, struct dentry ** d)
165 193
166/** 194/**
167 * sysfs_create_dir - create a directory for an object. 195 * sysfs_create_dir - create a directory for an object.
168 * @parent: parent parent object.
169 * @kobj: object we're creating directory for. 196 * @kobj: object we're creating directory for.
197 * @shadow_parent: parent parent object.
170 */ 198 */
171 199
172int sysfs_create_dir(struct kobject * kobj) 200int sysfs_create_dir(struct kobject * kobj, struct dentry *shadow_parent)
173{ 201{
174 struct dentry * dentry = NULL; 202 struct dentry * dentry = NULL;
175 struct dentry * parent; 203 struct dentry * parent;
@@ -177,7 +205,9 @@ int sysfs_create_dir(struct kobject * kobj)
177 205
178 BUG_ON(!kobj); 206 BUG_ON(!kobj);
179 207
180 if (kobj->parent) 208 if (shadow_parent)
209 parent = shadow_parent;
210 else if (kobj->parent)
181 parent = kobj->parent->dentry; 211 parent = kobj->parent->dentry;
182 else if (sysfs_mount && sysfs_mount->mnt_sb) 212 else if (sysfs_mount && sysfs_mount->mnt_sb)
183 parent = sysfs_mount->mnt_sb->s_root; 213 parent = sysfs_mount->mnt_sb->s_root;
@@ -298,21 +328,12 @@ void sysfs_remove_subdir(struct dentry * d)
298} 328}
299 329
300 330
301/** 331static void __sysfs_remove_dir(struct dentry *dentry)
302 * sysfs_remove_dir - remove an object's directory.
303 * @kobj: object.
304 *
305 * The only thing special about this is that we remove any files in
306 * the directory before we remove the directory, and we've inlined
307 * what used to be sysfs_rmdir() below, instead of calling separately.
308 */
309
310void sysfs_remove_dir(struct kobject * kobj)
311{ 332{
312 struct dentry * dentry = dget(kobj->dentry);
313 struct sysfs_dirent * parent_sd; 333 struct sysfs_dirent * parent_sd;
314 struct sysfs_dirent * sd, * tmp; 334 struct sysfs_dirent * sd, * tmp;
315 335
336 dget(dentry);
316 if (!dentry) 337 if (!dentry)
317 return; 338 return;
318 339
@@ -333,32 +354,60 @@ void sysfs_remove_dir(struct kobject * kobj)
333 * Drop reference from dget() on entrance. 354 * Drop reference from dget() on entrance.
334 */ 355 */
335 dput(dentry); 356 dput(dentry);
357}
358
359/**
360 * sysfs_remove_dir - remove an object's directory.
361 * @kobj: object.
362 *
363 * The only thing special about this is that we remove any files in
364 * the directory before we remove the directory, and we've inlined
365 * what used to be sysfs_rmdir() below, instead of calling separately.
366 */
367
368void sysfs_remove_dir(struct kobject * kobj)
369{
370 __sysfs_remove_dir(kobj->dentry);
336 kobj->dentry = NULL; 371 kobj->dentry = NULL;
337} 372}
338 373
339int sysfs_rename_dir(struct kobject * kobj, const char *new_name) 374int sysfs_rename_dir(struct kobject * kobj, struct dentry *new_parent,
375 const char *new_name)
340{ 376{
341 int error = 0; 377 int error = 0;
342 struct dentry * new_dentry, * parent; 378 struct dentry * new_dentry;
343
344 if (!strcmp(kobject_name(kobj), new_name))
345 return -EINVAL;
346 379
347 if (!kobj->parent) 380 if (!new_parent)
348 return -EINVAL; 381 return -EFAULT;
349 382
350 down_write(&sysfs_rename_sem); 383 down_write(&sysfs_rename_sem);
351 parent = kobj->parent->dentry; 384 mutex_lock(&new_parent->d_inode->i_mutex);
352
353 mutex_lock(&parent->d_inode->i_mutex);
354 385
355 new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); 386 new_dentry = lookup_one_len(new_name, new_parent, strlen(new_name));
356 if (!IS_ERR(new_dentry)) { 387 if (!IS_ERR(new_dentry)) {
357 if (!new_dentry->d_inode) { 388 /* By allowing two different directories with the
389 * same d_parent we allow this routine to move
390 * between different shadows of the same directory
391 */
392 if (kobj->dentry->d_parent->d_inode != new_parent->d_inode)
393 return -EINVAL;
394 else if (new_dentry->d_parent->d_inode != new_parent->d_inode)
395 error = -EINVAL;
396 else if (new_dentry == kobj->dentry)
397 error = -EINVAL;
398 else if (!new_dentry->d_inode) {
358 error = kobject_set_name(kobj, "%s", new_name); 399 error = kobject_set_name(kobj, "%s", new_name);
359 if (!error) { 400 if (!error) {
401 struct sysfs_dirent *sd, *parent_sd;
402
360 d_add(new_dentry, NULL); 403 d_add(new_dentry, NULL);
361 d_move(kobj->dentry, new_dentry); 404 d_move(kobj->dentry, new_dentry);
405
406 sd = kobj->dentry->d_fsdata;
407 parent_sd = new_parent->d_fsdata;
408
409 list_del_init(&sd->s_sibling);
410 list_add(&sd->s_sibling, &parent_sd->s_children);
362 } 411 }
363 else 412 else
364 d_drop(new_dentry); 413 d_drop(new_dentry);
@@ -366,7 +415,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
366 error = -EEXIST; 415 error = -EEXIST;
367 dput(new_dentry); 416 dput(new_dentry);
368 } 417 }
369 mutex_unlock(&parent->d_inode->i_mutex); 418 mutex_unlock(&new_parent->d_inode->i_mutex);
370 up_write(&sysfs_rename_sem); 419 up_write(&sysfs_rename_sem);
371 420
372 return error; 421 return error;
@@ -378,12 +427,10 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent)
378 struct sysfs_dirent *new_parent_sd, *sd; 427 struct sysfs_dirent *new_parent_sd, *sd;
379 int error; 428 int error;
380 429
381 if (!new_parent)
382 return -EINVAL;
383
384 old_parent_dentry = kobj->parent ? 430 old_parent_dentry = kobj->parent ?
385 kobj->parent->dentry : sysfs_mount->mnt_sb->s_root; 431 kobj->parent->dentry : sysfs_mount->mnt_sb->s_root;
386 new_parent_dentry = new_parent->dentry; 432 new_parent_dentry = new_parent ?
433 new_parent->dentry : sysfs_mount->mnt_sb->s_root;
387 434
388again: 435again:
389 mutex_lock(&old_parent_dentry->d_inode->i_mutex); 436 mutex_lock(&old_parent_dentry->d_inode->i_mutex);
@@ -547,6 +594,95 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
547 return offset; 594 return offset;
548} 595}
549 596
597
598/**
599 * sysfs_make_shadowed_dir - Setup so a directory can be shadowed
600 * @kobj: object we're creating shadow of.
601 */
602
603int sysfs_make_shadowed_dir(struct kobject *kobj,
604 void * (*follow_link)(struct dentry *, struct nameidata *))
605{
606 struct inode *inode;
607 struct inode_operations *i_op;
608
609 inode = kobj->dentry->d_inode;
610 if (inode->i_op != &sysfs_dir_inode_operations)
611 return -EINVAL;
612
613 i_op = kmalloc(sizeof(*i_op), GFP_KERNEL);
614 if (!i_op)
615 return -ENOMEM;
616
617 memcpy(i_op, &sysfs_dir_inode_operations, sizeof(*i_op));
618 i_op->follow_link = follow_link;
619
620 /* Locking of inode->i_op?
621 * Since setting i_op is a single word write and they
622 * are atomic we should be ok here.
623 */
624 inode->i_op = i_op;
625 return 0;
626}
627
628/**
629 * sysfs_create_shadow_dir - create a shadow directory for an object.
630 * @kobj: object we're creating directory for.
631 *
632 * sysfs_make_shadowed_dir must already have been called on this
633 * directory.
634 */
635
636struct dentry *sysfs_create_shadow_dir(struct kobject *kobj)
637{
638 struct sysfs_dirent *sd;
639 struct dentry *parent, *dir, *shadow;
640 struct inode *inode;
641
642 dir = kobj->dentry;
643 inode = dir->d_inode;
644 parent = dir->d_parent;
645 shadow = ERR_PTR(-EINVAL);
646 if (!sysfs_is_shadowed_inode(inode))
647 goto out;
648
649 shadow = d_alloc(parent, &dir->d_name);
650 if (!shadow)
651 goto nomem;
652
653 sd = __sysfs_make_dirent(shadow, kobj, inode->i_mode, SYSFS_DIR);
654 if (!sd)
655 goto nomem;
656
657 d_instantiate(shadow, igrab(inode));
658 inc_nlink(inode);
659 inc_nlink(parent->d_inode);
660 shadow->d_op = &sysfs_dentry_ops;
661
662 dget(shadow); /* Extra count - pin the dentry in core */
663
664out:
665 return shadow;
666nomem:
667 dput(shadow);
668 shadow = ERR_PTR(-ENOMEM);
669 goto out;
670}
671
672/**
673 * sysfs_remove_shadow_dir - remove an object's directory.
674 * @shadow: dentry of shadow directory
675 *
676 * The only thing special about this is that we remove any files in
677 * the directory before we remove the directory, and we've inlined
678 * what used to be sysfs_rmdir() below, instead of calling separately.
679 */
680
681void sysfs_remove_shadow_dir(struct dentry *shadow)
682{
683 __sysfs_remove_dir(shadow);
684}
685
550const struct file_operations sysfs_dir_operations = { 686const struct file_operations sysfs_dir_operations = {
551 .open = sysfs_dir_open, 687 .open = sysfs_dir_open,
552 .release = sysfs_dir_close, 688 .release = sysfs_dir_close,
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 9cfe53e1e00d..c0e117649a4d 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -7,6 +7,7 @@
7#include <linux/kobject.h> 7#include <linux/kobject.h>
8#include <linux/namei.h> 8#include <linux/namei.h>
9#include <linux/poll.h> 9#include <linux/poll.h>
10#include <linux/list.h>
10#include <asm/uaccess.h> 11#include <asm/uaccess.h>
11#include <asm/semaphore.h> 12#include <asm/semaphore.h>
12 13
@@ -50,17 +51,29 @@ static struct sysfs_ops subsys_sysfs_ops = {
50 .store = subsys_attr_store, 51 .store = subsys_attr_store,
51}; 52};
52 53
54/**
55 * add_to_collection - add buffer to a collection
56 * @buffer: buffer to be added
57 * @node inode of set to add to
58 */
53 59
54struct sysfs_buffer { 60static inline void
55 size_t count; 61add_to_collection(struct sysfs_buffer *buffer, struct inode *node)
56 loff_t pos; 62{
57 char * page; 63 struct sysfs_buffer_collection *set = node->i_private;
58 struct sysfs_ops * ops;
59 struct semaphore sem;
60 int needs_read_fill;
61 int event;
62};
63 64
65 mutex_lock(&node->i_mutex);
66 list_add(&buffer->associates, &set->associates);
67 mutex_unlock(&node->i_mutex);
68}
69
70static inline void
71remove_from_collection(struct sysfs_buffer *buffer, struct inode *node)
72{
73 mutex_lock(&node->i_mutex);
74 list_del(&buffer->associates);
75 mutex_unlock(&node->i_mutex);
76}
64 77
65/** 78/**
66 * fill_read_buffer - allocate and fill buffer from object. 79 * fill_read_buffer - allocate and fill buffer from object.
@@ -70,7 +83,8 @@ struct sysfs_buffer {
70 * Allocate @buffer->page, if it hasn't been already, then call the 83 * Allocate @buffer->page, if it hasn't been already, then call the
71 * kobject's show() method to fill the buffer with this attribute's 84 * kobject's show() method to fill the buffer with this attribute's
72 * data. 85 * data.
73 * This is called only once, on the file's first read. 86 * This is called only once, on the file's first read unless an error
87 * is returned.
74 */ 88 */
75static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer) 89static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer)
76{ 90{
@@ -88,12 +102,13 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
88 102
89 buffer->event = atomic_read(&sd->s_event); 103 buffer->event = atomic_read(&sd->s_event);
90 count = ops->show(kobj,attr,buffer->page); 104 count = ops->show(kobj,attr,buffer->page);
91 buffer->needs_read_fill = 0;
92 BUG_ON(count > (ssize_t)PAGE_SIZE); 105 BUG_ON(count > (ssize_t)PAGE_SIZE);
93 if (count >= 0) 106 if (count >= 0) {
107 buffer->needs_read_fill = 0;
94 buffer->count = count; 108 buffer->count = count;
95 else 109 } else {
96 ret = count; 110 ret = count;
111 }
97 return ret; 112 return ret;
98} 113}
99 114
@@ -153,6 +168,10 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
153 ssize_t retval = 0; 168 ssize_t retval = 0;
154 169
155 down(&buffer->sem); 170 down(&buffer->sem);
171 if (buffer->orphaned) {
172 retval = -ENODEV;
173 goto out;
174 }
156 if (buffer->needs_read_fill) { 175 if (buffer->needs_read_fill) {
157 if ((retval = fill_read_buffer(file->f_path.dentry,buffer))) 176 if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))
158 goto out; 177 goto out;
@@ -165,7 +184,6 @@ out:
165 return retval; 184 return retval;
166} 185}
167 186
168
169/** 187/**
170 * fill_write_buffer - copy buffer from userspace. 188 * fill_write_buffer - copy buffer from userspace.
171 * @buffer: data buffer for file. 189 * @buffer: data buffer for file.
@@ -243,19 +261,25 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
243 ssize_t len; 261 ssize_t len;
244 262
245 down(&buffer->sem); 263 down(&buffer->sem);
264 if (buffer->orphaned) {
265 len = -ENODEV;
266 goto out;
267 }
246 len = fill_write_buffer(buffer, buf, count); 268 len = fill_write_buffer(buffer, buf, count);
247 if (len > 0) 269 if (len > 0)
248 len = flush_write_buffer(file->f_path.dentry, buffer, len); 270 len = flush_write_buffer(file->f_path.dentry, buffer, len);
249 if (len > 0) 271 if (len > 0)
250 *ppos += len; 272 *ppos += len;
273out:
251 up(&buffer->sem); 274 up(&buffer->sem);
252 return len; 275 return len;
253} 276}
254 277
255static int check_perm(struct inode * inode, struct file * file) 278static int sysfs_open_file(struct inode *inode, struct file *file)
256{ 279{
257 struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent); 280 struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent);
258 struct attribute * attr = to_attr(file->f_path.dentry); 281 struct attribute * attr = to_attr(file->f_path.dentry);
282 struct sysfs_buffer_collection *set;
259 struct sysfs_buffer * buffer; 283 struct sysfs_buffer * buffer;
260 struct sysfs_ops * ops = NULL; 284 struct sysfs_ops * ops = NULL;
261 int error = 0; 285 int error = 0;
@@ -285,6 +309,18 @@ static int check_perm(struct inode * inode, struct file * file)
285 if (!ops) 309 if (!ops)
286 goto Eaccess; 310 goto Eaccess;
287 311
312 /* make sure we have a collection to add our buffers to */
313 mutex_lock(&inode->i_mutex);
314 if (!(set = inode->i_private)) {
315 if (!(set = inode->i_private = kmalloc(sizeof(struct sysfs_buffer_collection), GFP_KERNEL))) {
316 error = -ENOMEM;
317 goto Done;
318 } else {
319 INIT_LIST_HEAD(&set->associates);
320 }
321 }
322 mutex_unlock(&inode->i_mutex);
323
288 /* File needs write support. 324 /* File needs write support.
289 * The inode's perms must say it's ok, 325 * The inode's perms must say it's ok,
290 * and we must have a store method. 326 * and we must have a store method.
@@ -310,9 +346,11 @@ static int check_perm(struct inode * inode, struct file * file)
310 */ 346 */
311 buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL); 347 buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL);
312 if (buffer) { 348 if (buffer) {
349 INIT_LIST_HEAD(&buffer->associates);
313 init_MUTEX(&buffer->sem); 350 init_MUTEX(&buffer->sem);
314 buffer->needs_read_fill = 1; 351 buffer->needs_read_fill = 1;
315 buffer->ops = ops; 352 buffer->ops = ops;
353 add_to_collection(buffer, inode);
316 file->private_data = buffer; 354 file->private_data = buffer;
317 } else 355 } else
318 error = -ENOMEM; 356 error = -ENOMEM;
@@ -325,16 +363,11 @@ static int check_perm(struct inode * inode, struct file * file)
325 error = -EACCES; 363 error = -EACCES;
326 module_put(attr->owner); 364 module_put(attr->owner);
327 Done: 365 Done:
328 if (error && kobj) 366 if (error)
329 kobject_put(kobj); 367 kobject_put(kobj);
330 return error; 368 return error;
331} 369}
332 370
333static int sysfs_open_file(struct inode * inode, struct file * filp)
334{
335 return check_perm(inode,filp);
336}
337
338static int sysfs_release(struct inode * inode, struct file * filp) 371static int sysfs_release(struct inode * inode, struct file * filp)
339{ 372{
340 struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent); 373 struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent);
@@ -342,8 +375,9 @@ static int sysfs_release(struct inode * inode, struct file * filp)
342 struct module * owner = attr->owner; 375 struct module * owner = attr->owner;
343 struct sysfs_buffer * buffer = filp->private_data; 376 struct sysfs_buffer * buffer = filp->private_data;
344 377
345 if (kobj) 378 if (buffer)
346 kobject_put(kobj); 379 remove_from_collection(buffer, inode);
380 kobject_put(kobj);
347 /* After this point, attr should not be accessed. */ 381 /* After this point, attr should not be accessed. */
348 module_put(owner); 382 module_put(owner);
349 383
@@ -548,7 +582,7 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file);
548 582
549void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) 583void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr)
550{ 584{
551 sysfs_hash_and_remove(kobj->dentry,attr->name); 585 sysfs_hash_and_remove(kobj->dentry, attr->name);
552} 586}
553 587
554 588
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 122145b0895c..b20951c93761 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -13,6 +13,8 @@
13#include <linux/dcache.h> 13#include <linux/dcache.h>
14#include <linux/namei.h> 14#include <linux/namei.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/fs.h>
17#include <asm/semaphore.h>
16#include "sysfs.h" 18#include "sysfs.h"
17 19
18 20
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index e79e38d52c00..542d2bcc73df 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -13,6 +13,7 @@
13#include <linux/backing-dev.h> 13#include <linux/backing-dev.h>
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <asm/semaphore.h>
16#include "sysfs.h" 17#include "sysfs.h"
17 18
18extern struct super_block * sysfs_sb; 19extern struct super_block * sysfs_sb;
@@ -32,6 +33,16 @@ static struct inode_operations sysfs_inode_operations ={
32 .setattr = sysfs_setattr, 33 .setattr = sysfs_setattr,
33}; 34};
34 35
36void sysfs_delete_inode(struct inode *inode)
37{
38 /* Free the shadowed directory inode operations */
39 if (sysfs_is_shadowed_inode(inode)) {
40 kfree(inode->i_op);
41 inode->i_op = NULL;
42 }
43 return generic_delete_inode(inode);
44}
45
35int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) 46int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
36{ 47{
37 struct inode * inode = dentry->d_inode; 48 struct inode * inode = dentry->d_inode;
@@ -209,6 +220,22 @@ const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
209 return NULL; 220 return NULL;
210} 221}
211 222
223static inline void orphan_all_buffers(struct inode *node)
224{
225 struct sysfs_buffer_collection *set = node->i_private;
226 struct sysfs_buffer *buf;
227
228 mutex_lock_nested(&node->i_mutex, I_MUTEX_CHILD);
229 if (node->i_private) {
230 list_for_each_entry(buf, &set->associates, associates) {
231 down(&buf->sem);
232 buf->orphaned = 1;
233 up(&buf->sem);
234 }
235 }
236 mutex_unlock(&node->i_mutex);
237}
238
212 239
213/* 240/*
214 * Unhashes the dentry corresponding to given sysfs_dirent 241 * Unhashes the dentry corresponding to given sysfs_dirent
@@ -217,16 +244,23 @@ const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
217void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent) 244void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
218{ 245{
219 struct dentry * dentry = sd->s_dentry; 246 struct dentry * dentry = sd->s_dentry;
247 struct inode *inode;
220 248
221 if (dentry) { 249 if (dentry) {
222 spin_lock(&dcache_lock); 250 spin_lock(&dcache_lock);
223 spin_lock(&dentry->d_lock); 251 spin_lock(&dentry->d_lock);
224 if (!(d_unhashed(dentry) && dentry->d_inode)) { 252 if (!(d_unhashed(dentry) && dentry->d_inode)) {
253 inode = dentry->d_inode;
254 spin_lock(&inode->i_lock);
255 __iget(inode);
256 spin_unlock(&inode->i_lock);
225 dget_locked(dentry); 257 dget_locked(dentry);
226 __d_drop(dentry); 258 __d_drop(dentry);
227 spin_unlock(&dentry->d_lock); 259 spin_unlock(&dentry->d_lock);
228 spin_unlock(&dcache_lock); 260 spin_unlock(&dcache_lock);
229 simple_unlink(parent->d_inode, dentry); 261 simple_unlink(parent->d_inode, dentry);
262 orphan_all_buffers(inode);
263 iput(inode);
230 } else { 264 } else {
231 spin_unlock(&dentry->d_lock); 265 spin_unlock(&dentry->d_lock);
232 spin_unlock(&dcache_lock); 266 spin_unlock(&dcache_lock);
@@ -248,7 +282,7 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
248 return -ENOENT; 282 return -ENOENT;
249 283
250 parent_sd = dir->d_fsdata; 284 parent_sd = dir->d_fsdata;
251 mutex_lock(&dir->d_inode->i_mutex); 285 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
252 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 286 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
253 if (!sd->s_element) 287 if (!sd->s_element)
254 continue; 288 continue;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index e503f858fba8..f6a87a824883 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -8,6 +8,7 @@
8#include <linux/mount.h> 8#include <linux/mount.h>
9#include <linux/pagemap.h> 9#include <linux/pagemap.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <asm/semaphore.h>
11 12
12#include "sysfs.h" 13#include "sysfs.h"
13 14
@@ -18,9 +19,12 @@ struct vfsmount *sysfs_mount;
18struct super_block * sysfs_sb = NULL; 19struct super_block * sysfs_sb = NULL;
19struct kmem_cache *sysfs_dir_cachep; 20struct kmem_cache *sysfs_dir_cachep;
20 21
22static void sysfs_clear_inode(struct inode *inode);
23
21static struct super_operations sysfs_ops = { 24static struct super_operations sysfs_ops = {
22 .statfs = simple_statfs, 25 .statfs = simple_statfs,
23 .drop_inode = generic_delete_inode, 26 .drop_inode = sysfs_delete_inode,
27 .clear_inode = sysfs_clear_inode,
24}; 28};
25 29
26static struct sysfs_dirent sysfs_root = { 30static struct sysfs_dirent sysfs_root = {
@@ -31,6 +35,11 @@ static struct sysfs_dirent sysfs_root = {
31 .s_iattr = NULL, 35 .s_iattr = NULL,
32}; 36};
33 37
38static void sysfs_clear_inode(struct inode *inode)
39{
40 kfree(inode->i_private);
41}
42
34static int sysfs_fill_super(struct super_block *sb, void *data, int silent) 43static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
35{ 44{
36 struct inode *inode; 45 struct inode *inode;
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index f50e3cc2ded8..4869f611192f 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -7,6 +7,7 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/kobject.h> 8#include <linux/kobject.h>
9#include <linux/namei.h> 9#include <linux/namei.h>
10#include <asm/semaphore.h>
10 11
11#include "sysfs.h" 12#include "sysfs.h"
12 13
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index bd7cec295dab..fe1cbfd208ed 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -2,6 +2,7 @@
2extern struct vfsmount * sysfs_mount; 2extern struct vfsmount * sysfs_mount;
3extern struct kmem_cache *sysfs_dir_cachep; 3extern struct kmem_cache *sysfs_dir_cachep;
4 4
5extern void sysfs_delete_inode(struct inode *inode);
5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); 6extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 7extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
7 8
@@ -33,6 +34,22 @@ struct sysfs_symlink {
33 struct kobject * target_kobj; 34 struct kobject * target_kobj;
34}; 35};
35 36
37struct sysfs_buffer {
38 struct list_head associates;
39 size_t count;
40 loff_t pos;
41 char * page;
42 struct sysfs_ops * ops;
43 struct semaphore sem;
44 int orphaned;
45 int needs_read_fill;
46 int event;
47};
48
49struct sysfs_buffer_collection {
50 struct list_head associates;
51};
52
36static inline struct kobject * to_kobj(struct dentry * dentry) 53static inline struct kobject * to_kobj(struct dentry * dentry)
37{ 54{
38 struct sysfs_dirent * sd = dentry->d_fsdata; 55 struct sysfs_dirent * sd = dentry->d_fsdata;
@@ -96,3 +113,7 @@ static inline void sysfs_put(struct sysfs_dirent * sd)
96 release_sysfs_dirent(sd); 113 release_sysfs_dirent(sd);
97} 114}
98 115
116static inline int sysfs_is_shadowed_inode(struct inode *inode)
117{
118 return S_ISDIR(inode->i_mode) && inode->i_op->follow_link;
119}
diff --git a/include/linux/device.h b/include/linux/device.h
index f44247fe8135..5ca1cdba563a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -126,6 +126,7 @@ struct device_driver {
126 struct klist_node knode_bus; 126 struct klist_node knode_bus;
127 127
128 struct module * owner; 128 struct module * owner;
129 const char * mod_name; /* used for built-in modules */
129 130
130 int (*probe) (struct device * dev); 131 int (*probe) (struct device * dev);
131 int (*remove) (struct device * dev); 132 int (*remove) (struct device * dev);
@@ -327,6 +328,13 @@ extern struct class_device *class_device_create(struct class *cls,
327 __attribute__((format(printf,5,6))); 328 __attribute__((format(printf,5,6)));
328extern void class_device_destroy(struct class *cls, dev_t devt); 329extern void class_device_destroy(struct class *cls, dev_t devt);
329 330
331struct device_type {
332 struct device_attribute *attrs;
333 int (*uevent)(struct device *dev, char **envp, int num_envp,
334 char *buffer, int buffer_size);
335 void (*release)(struct device *dev);
336};
337
330/* interface for exporting device attributes */ 338/* interface for exporting device attributes */
331struct device_attribute { 339struct device_attribute {
332 struct attribute attr; 340 struct attribute attr;
@@ -355,6 +363,7 @@ struct device {
355 363
356 struct kobject kobj; 364 struct kobject kobj;
357 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 365 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
366 struct device_type *type;
358 unsigned is_registered:1; 367 unsigned is_registered:1;
359 struct device_attribute uevent_attr; 368 struct device_attribute uevent_attr;
360 struct device_attribute *devt_attr; 369 struct device_attribute *devt_attr;
@@ -390,9 +399,10 @@ struct device {
390 399
391 /* class_device migration path */ 400 /* class_device migration path */
392 struct list_head node; 401 struct list_head node;
393 struct class *class; /* optional*/ 402 struct class *class;
394 dev_t devt; /* dev_t, creates the sysfs "dev" */ 403 dev_t devt; /* dev_t, creates the sysfs "dev" */
395 struct attribute_group **groups; /* optional groups */ 404 struct attribute_group **groups; /* optional groups */
405 int uevent_suppress;
396 406
397 void (*release)(struct device * dev); 407 void (*release)(struct device * dev);
398}; 408};
diff --git a/include/linux/ide.h b/include/linux/ide.h
index e26a03981a94..827688f41d6c 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1192,8 +1192,8 @@ void ide_init_disk(struct gendisk *, ide_drive_t *);
1192extern int ideprobe_init(void); 1192extern int ideprobe_init(void);
1193 1193
1194extern void ide_scan_pcibus(int scan_direction) __init; 1194extern void ide_scan_pcibus(int scan_direction) __init;
1195extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner); 1195extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);
1196#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE) 1196#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
1197void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *); 1197void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *);
1198extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d); 1198extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
1199 1199
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 76538fcf2c4e..b850e0310538 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -74,9 +74,13 @@ extern void kobject_init(struct kobject *);
74extern void kobject_cleanup(struct kobject *); 74extern void kobject_cleanup(struct kobject *);
75 75
76extern int __must_check kobject_add(struct kobject *); 76extern int __must_check kobject_add(struct kobject *);
77extern int __must_check kobject_shadow_add(struct kobject *, struct dentry *);
77extern void kobject_del(struct kobject *); 78extern void kobject_del(struct kobject *);
78 79
79extern int __must_check kobject_rename(struct kobject *, const char *new_name); 80extern int __must_check kobject_rename(struct kobject *, const char *new_name);
81extern int __must_check kobject_shadow_rename(struct kobject *kobj,
82 struct dentry *new_parent,
83 const char *new_name);
80extern int __must_check kobject_move(struct kobject *, struct kobject *); 84extern int __must_check kobject_move(struct kobject *, struct kobject *);
81 85
82extern int __must_check kobject_register(struct kobject *); 86extern int __must_check kobject_register(struct kobject *);
diff --git a/include/linux/module.h b/include/linux/module.h
index 10f771a49997..419d3ef293dd 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -58,6 +58,7 @@ struct module_kobject
58{ 58{
59 struct kobject kobj; 59 struct kobject kobj;
60 struct module *mod; 60 struct module *mod;
61 struct kobject *drivers_dir;
61}; 62};
62 63
63/* These are either module local, or the kernel's dummy ones. */ 64/* These are either module local, or the kernel's dummy ones. */
@@ -263,7 +264,7 @@ struct module
263 struct module_attribute *modinfo_attrs; 264 struct module_attribute *modinfo_attrs;
264 const char *version; 265 const char *version;
265 const char *srcversion; 266 const char *srcversion;
266 struct kobject *drivers_dir; 267 struct kobject *holders_dir;
267 268
268 /* Exported symbols */ 269 /* Exported symbols */
269 const struct kernel_symbol *syms; 270 const struct kernel_symbol *syms;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index fea0d9db6846..2e37f5012788 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -529,10 +529,11 @@ struct net_device
529 struct net_bridge_port *br_port; 529 struct net_bridge_port *br_port;
530 530
531 /* class/net/name entry */ 531 /* class/net/name entry */
532 struct class_device class_dev; 532 struct device dev;
533 /* space for optional statistics and wireless sysfs groups */ 533 /* space for optional statistics and wireless sysfs groups */
534 struct attribute_group *sysfs_groups[3]; 534 struct attribute_group *sysfs_groups[3];
535}; 535};
536#define to_net_dev(d) container_of(d, struct net_device, dev)
536 537
537#define NETDEV_ALIGN 32 538#define NETDEV_ALIGN 32
538#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) 539#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
@@ -548,7 +549,7 @@ static inline void *netdev_priv(struct net_device *dev)
548/* Set the sysfs physical device reference for the network logical device 549/* Set the sysfs physical device reference for the network logical device
549 * if set prior to registration will cause a symlink during initialization. 550 * if set prior to registration will cause a symlink during initialization.
550 */ 551 */
551#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev)) 552#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
552 553
553struct packet_type { 554struct packet_type {
554 __be16 type; /* This is really htons(ether_type). */ 555 __be16 type; /* This is really htons(ether_type). */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f3c617eabd8d..cb899eb95d31 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -573,10 +573,11 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
573void pci_enable_bridges(struct pci_bus *bus); 573void pci_enable_bridges(struct pci_bus *bus);
574 574
575/* Proper probing supporting hot-pluggable devices */ 575/* Proper probing supporting hot-pluggable devices */
576int __must_check __pci_register_driver(struct pci_driver *, struct module *); 576int __must_check __pci_register_driver(struct pci_driver *, struct module *,
577 const char *mod_name);
577static inline int __must_check pci_register_driver(struct pci_driver *driver) 578static inline int __must_check pci_register_driver(struct pci_driver *driver)
578{ 579{
579 return __pci_register_driver(driver, THIS_MODULE); 580 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
580} 581}
581 582
582void pci_unregister_driver(struct pci_driver *); 583void pci_unregister_driver(struct pci_driver *);
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 0f478a8791a2..ac2c70e7f760 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -86,6 +86,11 @@ static inline void serio_register_port(struct serio *serio)
86void serio_unregister_port(struct serio *serio); 86void serio_unregister_port(struct serio *serio);
87void serio_unregister_child_port(struct serio *serio); 87void serio_unregister_child_port(struct serio *serio);
88 88
89int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name);
90static inline int serio_register_driver(struct serio_driver *drv)
91{
92 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
93}
89int serio_register_driver(struct serio_driver *drv); 94int serio_register_driver(struct serio_driver *drv);
90void serio_unregister_driver(struct serio_driver *drv); 95void serio_unregister_driver(struct serio_driver *drv);
91 96
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 176f6e36dbfa..8c2edd82a073 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -170,7 +170,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
170 * message's completion function when the transaction completes. 170 * message's completion function when the transaction completes.
171 */ 171 */
172struct spi_master { 172struct spi_master {
173 struct class_device cdev; 173 struct device dev;
174 174
175 /* other than negative (== assign one dynamically), bus_num is fully 175 /* other than negative (== assign one dynamically), bus_num is fully
176 * board-specific. usually that simplifies to being SOC-specific. 176 * board-specific. usually that simplifies to being SOC-specific.
@@ -216,17 +216,17 @@ struct spi_master {
216 216
217static inline void *spi_master_get_devdata(struct spi_master *master) 217static inline void *spi_master_get_devdata(struct spi_master *master)
218{ 218{
219 return class_get_devdata(&master->cdev); 219 return dev_get_drvdata(&master->dev);
220} 220}
221 221
222static inline void spi_master_set_devdata(struct spi_master *master, void *data) 222static inline void spi_master_set_devdata(struct spi_master *master, void *data)
223{ 223{
224 class_set_devdata(&master->cdev, data); 224 dev_set_drvdata(&master->dev, data);
225} 225}
226 226
227static inline struct spi_master *spi_master_get(struct spi_master *master) 227static inline struct spi_master *spi_master_get(struct spi_master *master)
228{ 228{
229 if (!master || !class_device_get(&master->cdev)) 229 if (!master || !get_device(&master->dev))
230 return NULL; 230 return NULL;
231 return master; 231 return master;
232} 232}
@@ -234,7 +234,7 @@ static inline struct spi_master *spi_master_get(struct spi_master *master)
234static inline void spi_master_put(struct spi_master *master) 234static inline void spi_master_put(struct spi_master *master)
235{ 235{
236 if (master) 236 if (master)
237 class_device_put(&master->cdev); 237 put_device(&master->dev);
238} 238}
239 239
240 240
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 2129d1b6c874..192de3afa96b 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -11,10 +11,12 @@
11#define _SYSFS_H_ 11#define _SYSFS_H_
12 12
13#include <linux/compiler.h> 13#include <linux/compiler.h>
14#include <linux/list.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
15 16
16struct kobject; 17struct kobject;
17struct module; 18struct module;
19struct nameidata;
18 20
19struct attribute { 21struct attribute {
20 const char * name; 22 const char * name;
@@ -88,13 +90,13 @@ struct sysfs_dirent {
88#ifdef CONFIG_SYSFS 90#ifdef CONFIG_SYSFS
89 91
90extern int __must_check 92extern int __must_check
91sysfs_create_dir(struct kobject *); 93sysfs_create_dir(struct kobject *, struct dentry *);
92 94
93extern void 95extern void
94sysfs_remove_dir(struct kobject *); 96sysfs_remove_dir(struct kobject *);
95 97
96extern int __must_check 98extern int __must_check
97sysfs_rename_dir(struct kobject *, const char *new_name); 99sysfs_rename_dir(struct kobject *, struct dentry *, const char *new_name);
98 100
99extern int __must_check 101extern int __must_check
100sysfs_move_dir(struct kobject *, struct kobject *); 102sysfs_move_dir(struct kobject *, struct kobject *);
@@ -126,11 +128,17 @@ int __must_check sysfs_create_group(struct kobject *,
126void sysfs_remove_group(struct kobject *, const struct attribute_group *); 128void sysfs_remove_group(struct kobject *, const struct attribute_group *);
127void sysfs_notify(struct kobject * k, char *dir, char *attr); 129void sysfs_notify(struct kobject * k, char *dir, char *attr);
128 130
131
132extern int sysfs_make_shadowed_dir(struct kobject *kobj,
133 void * (*follow_link)(struct dentry *, struct nameidata *));
134extern struct dentry *sysfs_create_shadow_dir(struct kobject *kobj);
135extern void sysfs_remove_shadow_dir(struct dentry *dir);
136
129extern int __must_check sysfs_init(void); 137extern int __must_check sysfs_init(void);
130 138
131#else /* CONFIG_SYSFS */ 139#else /* CONFIG_SYSFS */
132 140
133static inline int sysfs_create_dir(struct kobject * k) 141static inline int sysfs_create_dir(struct kobject * k, struct dentry *shadow)
134{ 142{
135 return 0; 143 return 0;
136} 144}
@@ -140,7 +148,9 @@ static inline void sysfs_remove_dir(struct kobject * k)
140 ; 148 ;
141} 149}
142 150
143static inline int sysfs_rename_dir(struct kobject * k, const char *new_name) 151static inline int sysfs_rename_dir(struct kobject * k,
152 struct dentry *new_parent,
153 const char *new_name)
144{ 154{
145 return 0; 155 return 0;
146} 156}
@@ -204,6 +214,12 @@ static inline void sysfs_notify(struct kobject * k, char *dir, char *attr)
204{ 214{
205} 215}
206 216
217static inline int sysfs_make_shadowed_dir(struct kobject *kobj,
218 void * (*follow_link)(struct dentry *, struct nameidata *))
219{
220 return 0;
221}
222
207static inline int __must_check sysfs_init(void) 223static inline int __must_check sysfs_init(void)
208{ 224{
209 return 0; 225 return 0;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index aab5b1b72021..733f38de4978 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -868,10 +868,11 @@ struct usb_class_driver {
868 * use these in module_init()/module_exit() 868 * use these in module_init()/module_exit()
869 * and don't forget MODULE_DEVICE_TABLE(usb, ...) 869 * and don't forget MODULE_DEVICE_TABLE(usb, ...)
870 */ 870 */
871extern int usb_register_driver(struct usb_driver *, struct module *); 871extern int usb_register_driver(struct usb_driver *, struct module *,
872 const char *);
872static inline int usb_register(struct usb_driver *driver) 873static inline int usb_register(struct usb_driver *driver)
873{ 874{
874 return usb_register_driver(driver, THIS_MODULE); 875 return usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
875} 876}
876extern void usb_deregister(struct usb_driver *); 877extern void usb_deregister(struct usb_driver *);
877 878
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 623a0fc0dae1..6e84258b94de 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -284,7 +284,7 @@ struct pcmcia_socket {
284#endif 284#endif
285 285
286 /* socket device */ 286 /* socket device */
287 struct class_device dev; 287 struct device dev;
288 void *driver_data; /* data internal to the socket driver */ 288 void *driver_data; /* data internal to the socket driver */
289 289
290}; 290};
diff --git a/kernel/module.c b/kernel/module.c
index d0f2260a0210..8a94e054230c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -537,6 +537,8 @@ static int already_uses(struct module *a, struct module *b)
537static int use_module(struct module *a, struct module *b) 537static int use_module(struct module *a, struct module *b)
538{ 538{
539 struct module_use *use; 539 struct module_use *use;
540 int no_warn;
541
540 if (b == NULL || already_uses(a, b)) return 1; 542 if (b == NULL || already_uses(a, b)) return 1;
541 543
542 if (!strong_try_module_get(b)) 544 if (!strong_try_module_get(b))
@@ -552,6 +554,7 @@ static int use_module(struct module *a, struct module *b)
552 554
553 use->module_which_uses = a; 555 use->module_which_uses = a;
554 list_add(&use->list, &b->modules_which_use_me); 556 list_add(&use->list, &b->modules_which_use_me);
557 no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name);
555 return 1; 558 return 1;
556} 559}
557 560
@@ -569,6 +572,7 @@ static void module_unload_free(struct module *mod)
569 module_put(i); 572 module_put(i);
570 list_del(&use->list); 573 list_del(&use->list);
571 kfree(use); 574 kfree(use);
575 sysfs_remove_link(i->holders_dir, mod->name);
572 /* There can be at most one match. */ 576 /* There can be at most one match. */
573 break; 577 break;
574 } 578 }
@@ -1106,9 +1110,7 @@ static void module_remove_modinfo_attrs(struct module *mod)
1106 kfree(mod->modinfo_attrs); 1110 kfree(mod->modinfo_attrs);
1107} 1111}
1108 1112
1109static int mod_sysfs_setup(struct module *mod, 1113static int mod_sysfs_init(struct module *mod)
1110 struct kernel_param *kparam,
1111 unsigned int num_params)
1112{ 1114{
1113 int err; 1115 int err;
1114 1116
@@ -1125,21 +1127,30 @@ static int mod_sysfs_setup(struct module *mod,
1125 kobj_set_kset_s(&mod->mkobj, module_subsys); 1127 kobj_set_kset_s(&mod->mkobj, module_subsys);
1126 mod->mkobj.mod = mod; 1128 mod->mkobj.mod = mod;
1127 1129
1128 /* delay uevent until full sysfs population */
1129 kobject_init(&mod->mkobj.kobj); 1130 kobject_init(&mod->mkobj.kobj);
1131
1132out:
1133 return err;
1134}
1135
1136static int mod_sysfs_setup(struct module *mod,
1137 struct kernel_param *kparam,
1138 unsigned int num_params)
1139{
1140 int err;
1141
1142 /* delay uevent until full sysfs population */
1130 err = kobject_add(&mod->mkobj.kobj); 1143 err = kobject_add(&mod->mkobj.kobj);
1131 if (err) 1144 if (err)
1132 goto out; 1145 goto out;
1133 1146
1134 mod->drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers"); 1147 mod->holders_dir = kobject_add_dir(&mod->mkobj.kobj, "holders");
1135 if (!mod->drivers_dir) { 1148 if (!mod->holders_dir)
1136 err = -ENOMEM;
1137 goto out_unreg; 1149 goto out_unreg;
1138 }
1139 1150
1140 err = module_param_sysfs_setup(mod, kparam, num_params); 1151 err = module_param_sysfs_setup(mod, kparam, num_params);
1141 if (err) 1152 if (err)
1142 goto out_unreg_drivers; 1153 goto out_unreg_holders;
1143 1154
1144 err = module_add_modinfo_attrs(mod); 1155 err = module_add_modinfo_attrs(mod);
1145 if (err) 1156 if (err)
@@ -1150,8 +1161,8 @@ static int mod_sysfs_setup(struct module *mod,
1150 1161
1151out_unreg_param: 1162out_unreg_param:
1152 module_param_sysfs_remove(mod); 1163 module_param_sysfs_remove(mod);
1153out_unreg_drivers: 1164out_unreg_holders:
1154 kobject_unregister(mod->drivers_dir); 1165 kobject_unregister(mod->holders_dir);
1155out_unreg: 1166out_unreg:
1156 kobject_del(&mod->mkobj.kobj); 1167 kobject_del(&mod->mkobj.kobj);
1157 kobject_put(&mod->mkobj.kobj); 1168 kobject_put(&mod->mkobj.kobj);
@@ -1163,7 +1174,10 @@ static void mod_kobject_remove(struct module *mod)
1163{ 1174{
1164 module_remove_modinfo_attrs(mod); 1175 module_remove_modinfo_attrs(mod);
1165 module_param_sysfs_remove(mod); 1176 module_param_sysfs_remove(mod);
1166 kobject_unregister(mod->drivers_dir); 1177 if (mod->mkobj.drivers_dir)
1178 kobject_unregister(mod->mkobj.drivers_dir);
1179 if (mod->holders_dir)
1180 kobject_unregister(mod->holders_dir);
1167 1181
1168 kobject_unregister(&mod->mkobj.kobj); 1182 kobject_unregister(&mod->mkobj.kobj);
1169} 1183}
@@ -1768,6 +1782,10 @@ static struct module *load_module(void __user *umod,
1768 /* Now we've moved module, initialize linked lists, etc. */ 1782 /* Now we've moved module, initialize linked lists, etc. */
1769 module_unload_init(mod); 1783 module_unload_init(mod);
1770 1784
1785 /* Initialize kobject, so we can reference it. */
1786 if (mod_sysfs_init(mod) != 0)
1787 goto cleanup;
1788
1771 /* Set up license info based on the info section */ 1789 /* Set up license info based on the info section */
1772 set_license(mod, get_modinfo(sechdrs, infoindex, "license")); 1790 set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
1773 1791
@@ -2340,19 +2358,43 @@ static char *make_driver_name(struct device_driver *drv)
2340 return driver_name; 2358 return driver_name;
2341} 2359}
2342 2360
2361static void module_create_drivers_dir(struct module_kobject *mk)
2362{
2363 if (!mk || mk->drivers_dir)
2364 return;
2365
2366 mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
2367}
2368
2343void module_add_driver(struct module *mod, struct device_driver *drv) 2369void module_add_driver(struct module *mod, struct device_driver *drv)
2344{ 2370{
2345 char *driver_name; 2371 char *driver_name;
2346 int no_warn; 2372 int no_warn;
2373 struct module_kobject *mk = NULL;
2374
2375 if (!drv)
2376 return;
2377
2378 if (mod)
2379 mk = &mod->mkobj;
2380 else if (drv->mod_name) {
2381 struct kobject *mkobj;
2382
2383 /* Lookup built-in module entry in /sys/modules */
2384 mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name);
2385 if (mkobj)
2386 mk = container_of(mkobj, struct module_kobject, kobj);
2387 }
2347 2388
2348 if (!mod || !drv) 2389 if (!mk)
2349 return; 2390 return;
2350 2391
2351 /* Don't check return codes; these calls are idempotent */ 2392 /* Don't check return codes; these calls are idempotent */
2352 no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); 2393 no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module");
2353 driver_name = make_driver_name(drv); 2394 driver_name = make_driver_name(drv);
2354 if (driver_name) { 2395 if (driver_name) {
2355 no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, 2396 module_create_drivers_dir(mk);
2397 no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj,
2356 driver_name); 2398 driver_name);
2357 kfree(driver_name); 2399 kfree(driver_name);
2358 } 2400 }
@@ -2367,10 +2409,10 @@ void module_remove_driver(struct device_driver *drv)
2367 return; 2409 return;
2368 2410
2369 sysfs_remove_link(&drv->kobj, "module"); 2411 sysfs_remove_link(&drv->kobj, "module");
2370 if (drv->owner && drv->owner->drivers_dir) { 2412 if (drv->owner && drv->owner->mkobj.drivers_dir) {
2371 driver_name = make_driver_name(drv); 2413 driver_name = make_driver_name(drv);
2372 if (driver_name) { 2414 if (driver_name) {
2373 sysfs_remove_link(drv->owner->drivers_dir, 2415 sysfs_remove_link(drv->owner->mkobj.drivers_dir,
2374 driver_name); 2416 driver_name);
2375 kfree(driver_name); 2417 kfree(driver_name);
2376 } 2418 }
diff --git a/kernel/params.c b/kernel/params.c
index 718945da8f58..553cf7d6a4be 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -30,6 +30,8 @@
30#define DEBUGP(fmt, a...) 30#define DEBUGP(fmt, a...)
31#endif 31#endif
32 32
33static struct kobj_type module_ktype;
34
33static inline char dash2underscore(char c) 35static inline char dash2underscore(char c)
34{ 36{
35 if (c == '-') 37 if (c == '-')
@@ -561,14 +563,11 @@ static void __init kernel_param_sysfs_setup(const char *name,
561 mk->mod = THIS_MODULE; 563 mk->mod = THIS_MODULE;
562 kobj_set_kset_s(mk, module_subsys); 564 kobj_set_kset_s(mk, module_subsys);
563 kobject_set_name(&mk->kobj, name); 565 kobject_set_name(&mk->kobj, name);
564 ret = kobject_register(&mk->kobj); 566 kobject_init(&mk->kobj);
567 ret = kobject_add(&mk->kobj);
565 BUG_ON(ret < 0); 568 BUG_ON(ret < 0);
566 569 param_sysfs_setup(mk, kparam, num_params, name_skip);
567 /* no need to keep the kobject if no parameter is exported */ 570 kobject_uevent(&mk->kobj, KOBJ_ADD);
568 if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) {
569 kobject_unregister(&mk->kobj);
570 kfree(mk);
571 }
572} 571}
573 572
574/* 573/*
@@ -674,6 +673,19 @@ static struct sysfs_ops module_sysfs_ops = {
674 .store = module_attr_store, 673 .store = module_attr_store,
675}; 674};
676 675
676static int uevent_filter(struct kset *kset, struct kobject *kobj)
677{
678 struct kobj_type *ktype = get_ktype(kobj);
679
680 if (ktype == &module_ktype)
681 return 1;
682 return 0;
683}
684
685static struct kset_uevent_ops module_uevent_ops = {
686 .filter = uevent_filter,
687};
688
677#else 689#else
678static struct sysfs_ops module_sysfs_ops = { 690static struct sysfs_ops module_sysfs_ops = {
679 .show = NULL, 691 .show = NULL,
@@ -685,7 +697,7 @@ static struct kobj_type module_ktype = {
685 .sysfs_ops = &module_sysfs_ops, 697 .sysfs_ops = &module_sysfs_ops,
686}; 698};
687 699
688decl_subsys(module, &module_ktype, NULL); 700decl_subsys(module, &module_ktype, &module_uevent_ops);
689 701
690/* 702/*
691 * param_sysfs_init - wrapper for built-in params support 703 * param_sysfs_init - wrapper for built-in params support
diff --git a/lib/kobject.c b/lib/kobject.c
index 7ce6dc138e90..c2917ffe8bf1 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -44,11 +44,11 @@ static int populate_dir(struct kobject * kobj)
44 return error; 44 return error;
45} 45}
46 46
47static int create_dir(struct kobject * kobj) 47static int create_dir(struct kobject * kobj, struct dentry *shadow_parent)
48{ 48{
49 int error = 0; 49 int error = 0;
50 if (kobject_name(kobj)) { 50 if (kobject_name(kobj)) {
51 error = sysfs_create_dir(kobj); 51 error = sysfs_create_dir(kobj, shadow_parent);
52 if (!error) { 52 if (!error) {
53 if ((error = populate_dir(kobj))) 53 if ((error = populate_dir(kobj)))
54 sysfs_remove_dir(kobj); 54 sysfs_remove_dir(kobj);
@@ -126,6 +126,8 @@ EXPORT_SYMBOL_GPL(kobject_get_path);
126 */ 126 */
127void kobject_init(struct kobject * kobj) 127void kobject_init(struct kobject * kobj)
128{ 128{
129 if (!kobj)
130 return;
129 kref_init(&kobj->kref); 131 kref_init(&kobj->kref);
130 INIT_LIST_HEAD(&kobj->entry); 132 INIT_LIST_HEAD(&kobj->entry);
131 init_waitqueue_head(&kobj->poll); 133 init_waitqueue_head(&kobj->poll);
@@ -156,9 +158,10 @@ static void unlink(struct kobject * kobj)
156/** 158/**
157 * kobject_add - add an object to the hierarchy. 159 * kobject_add - add an object to the hierarchy.
158 * @kobj: object. 160 * @kobj: object.
161 * @shadow_parent: sysfs directory to add to.
159 */ 162 */
160 163
161int kobject_add(struct kobject * kobj) 164int kobject_shadow_add(struct kobject * kobj, struct dentry *shadow_parent)
162{ 165{
163 int error = 0; 166 int error = 0;
164 struct kobject * parent; 167 struct kobject * parent;
@@ -189,12 +192,11 @@ int kobject_add(struct kobject * kobj)
189 } 192 }
190 kobj->parent = parent; 193 kobj->parent = parent;
191 194
192 error = create_dir(kobj); 195 error = create_dir(kobj, shadow_parent);
193 if (error) { 196 if (error) {
194 /* unlink does the kobject_put() for us */ 197 /* unlink does the kobject_put() for us */
195 unlink(kobj); 198 unlink(kobj);
196 if (parent) 199 kobject_put(parent);
197 kobject_put(parent);
198 200
199 /* be noisy on error issues */ 201 /* be noisy on error issues */
200 if (error == -EEXIST) 202 if (error == -EEXIST)
@@ -211,6 +213,15 @@ int kobject_add(struct kobject * kobj)
211 return error; 213 return error;
212} 214}
213 215
216/**
217 * kobject_add - add an object to the hierarchy.
218 * @kobj: object.
219 */
220int kobject_add(struct kobject * kobj)
221{
222 return kobject_shadow_add(kobj, NULL);
223}
224
214 225
215/** 226/**
216 * kobject_register - initialize and add an object. 227 * kobject_register - initialize and add an object.
@@ -303,7 +314,29 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
303 kobj = kobject_get(kobj); 314 kobj = kobject_get(kobj);
304 if (!kobj) 315 if (!kobj)
305 return -EINVAL; 316 return -EINVAL;
306 error = sysfs_rename_dir(kobj, new_name); 317 if (!kobj->parent)
318 return -EINVAL;
319 error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name);
320 kobject_put(kobj);
321
322 return error;
323}
324
325/**
326 * kobject_rename - change the name of an object
327 * @kobj: object in question.
328 * @new_name: object's new name
329 */
330
331int kobject_shadow_rename(struct kobject * kobj, struct dentry *new_parent,
332 const char *new_name)
333{
334 int error = 0;
335
336 kobj = kobject_get(kobj);
337 if (!kobj)
338 return -EINVAL;
339 error = sysfs_rename_dir(kobj, new_parent, new_name);
307 kobject_put(kobj); 340 kobject_put(kobj);
308 341
309 return error; 342 return error;
@@ -312,7 +345,7 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
312/** 345/**
313 * kobject_move - move object to another parent 346 * kobject_move - move object to another parent
314 * @kobj: object in question. 347 * @kobj: object in question.
315 * @new_parent: object's new parent 348 * @new_parent: object's new parent (can be NULL)
316 */ 349 */
317 350
318int kobject_move(struct kobject *kobj, struct kobject *new_parent) 351int kobject_move(struct kobject *kobj, struct kobject *new_parent)
@@ -328,8 +361,8 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
328 return -EINVAL; 361 return -EINVAL;
329 new_parent = kobject_get(new_parent); 362 new_parent = kobject_get(new_parent);
330 if (!new_parent) { 363 if (!new_parent) {
331 error = -EINVAL; 364 if (kobj->kset)
332 goto out; 365 new_parent = kobject_get(&kobj->kset->kobj);
333 } 366 }
334 /* old object path */ 367 /* old object path */
335 devpath = kobject_get_path(kobj, GFP_KERNEL); 368 devpath = kobject_get_path(kobj, GFP_KERNEL);
@@ -366,6 +399,8 @@ out:
366 399
367void kobject_del(struct kobject * kobj) 400void kobject_del(struct kobject * kobj)
368{ 401{
402 if (!kobj)
403 return;
369 sysfs_remove_dir(kobj); 404 sysfs_remove_dir(kobj);
370 unlink(kobj); 405 unlink(kobj);
371} 406}
@@ -377,6 +412,8 @@ void kobject_del(struct kobject * kobj)
377 412
378void kobject_unregister(struct kobject * kobj) 413void kobject_unregister(struct kobject * kobj)
379{ 414{
415 if (!kobj)
416 return;
380 pr_debug("kobject %s: unregistering\n",kobject_name(kobj)); 417 pr_debug("kobject %s: unregistering\n",kobject_name(kobj));
381 kobject_uevent(kobj, KOBJ_REMOVE); 418 kobject_uevent(kobj, KOBJ_REMOVE);
382 kobject_del(kobj); 419 kobject_del(kobj);
@@ -414,8 +451,7 @@ void kobject_cleanup(struct kobject * kobj)
414 t->release(kobj); 451 t->release(kobj);
415 if (s) 452 if (s)
416 kset_put(s); 453 kset_put(s);
417 if (parent) 454 kobject_put(parent);
418 kobject_put(parent);
419} 455}
420 456
421static void kobject_release(struct kref *kref) 457static void kobject_release(struct kref *kref)
@@ -523,6 +559,8 @@ int kset_add(struct kset * k)
523 559
524int kset_register(struct kset * k) 560int kset_register(struct kset * k)
525{ 561{
562 if (!k)
563 return -EINVAL;
526 kset_init(k); 564 kset_init(k);
527 return kset_add(k); 565 return kset_add(k);
528} 566}
@@ -535,6 +573,8 @@ int kset_register(struct kset * k)
535 573
536void kset_unregister(struct kset * k) 574void kset_unregister(struct kset * k)
537{ 575{
576 if (!k)
577 return;
538 kobject_unregister(&k->kobj); 578 kobject_unregister(&k->kobj);
539} 579}
540 580
@@ -586,6 +626,9 @@ int subsystem_register(struct subsystem * s)
586{ 626{
587 int error; 627 int error;
588 628
629 if (!s)
630 return -EINVAL;
631
589 subsystem_init(s); 632 subsystem_init(s);
590 pr_debug("subsystem %s: registering\n",s->kset.kobj.name); 633 pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
591 634
@@ -598,6 +641,8 @@ int subsystem_register(struct subsystem * s)
598 641
599void subsystem_unregister(struct subsystem * s) 642void subsystem_unregister(struct subsystem * s)
600{ 643{
644 if (!s)
645 return;
601 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name); 646 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
602 kset_unregister(&s->kset); 647 kset_unregister(&s->kset);
603} 648}
@@ -612,6 +657,10 @@ void subsystem_unregister(struct subsystem * s)
612int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) 657int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
613{ 658{
614 int error = 0; 659 int error = 0;
660
661 if (!s || !a)
662 return -EINVAL;
663
615 if (subsys_get(s)) { 664 if (subsys_get(s)) {
616 error = sysfs_create_file(&s->kset.kobj,&a->attr); 665 error = sysfs_create_file(&s->kset.kobj,&a->attr);
617 subsys_put(s); 666 subsys_put(s);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 55bb2634c088..2b7c2c7dad48 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -286,7 +286,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
286 kobject_init(&p->kobj); 286 kobject_init(&p->kobj);
287 kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR); 287 kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR);
288 p->kobj.ktype = &brport_ktype; 288 p->kobj.ktype = &brport_ktype;
289 p->kobj.parent = &(dev->class_dev.kobj); 289 p->kobj.parent = &(dev->dev.kobj);
290 p->kobj.kset = NULL; 290 p->kobj.kset = NULL;
291 291
292 return p; 292 return p;
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index de9d1a9473f2..ce10464716a7 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -21,18 +21,17 @@
21 21
22#include "br_private.h" 22#include "br_private.h"
23 23
24#define to_class_dev(obj) container_of(obj,struct class_device,kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
25#define to_net_dev(class) container_of(class, struct net_device, class_dev)
26#define to_bridge(cd) ((struct net_bridge *)(to_net_dev(cd)->priv)) 25#define to_bridge(cd) ((struct net_bridge *)(to_net_dev(cd)->priv))
27 26
28/* 27/*
29 * Common code for storing bridge parameters. 28 * Common code for storing bridge parameters.
30 */ 29 */
31static ssize_t store_bridge_parm(struct class_device *cd, 30static ssize_t store_bridge_parm(struct device *d,
32 const char *buf, size_t len, 31 const char *buf, size_t len,
33 void (*set)(struct net_bridge *, unsigned long)) 32 void (*set)(struct net_bridge *, unsigned long))
34{ 33{
35 struct net_bridge *br = to_bridge(cd); 34 struct net_bridge *br = to_bridge(d);
36 char *endp; 35 char *endp;
37 unsigned long val; 36 unsigned long val;
38 37
@@ -50,9 +49,10 @@ static ssize_t store_bridge_parm(struct class_device *cd,
50} 49}
51 50
52 51
53static ssize_t show_forward_delay(struct class_device *cd, char *buf) 52static ssize_t show_forward_delay(struct device *d,
53 struct device_attribute *attr, char *buf)
54{ 54{
55 struct net_bridge *br = to_bridge(cd); 55 struct net_bridge *br = to_bridge(d);
56 return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); 56 return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay));
57} 57}
58 58
@@ -64,18 +64,20 @@ static void set_forward_delay(struct net_bridge *br, unsigned long val)
64 br->bridge_forward_delay = delay; 64 br->bridge_forward_delay = delay;
65} 65}
66 66
67static ssize_t store_forward_delay(struct class_device *cd, const char *buf, 67static ssize_t store_forward_delay(struct device *d,
68 size_t len) 68 struct device_attribute *attr,
69 const char *buf, size_t len)
69{ 70{
70 return store_bridge_parm(cd, buf, len, set_forward_delay); 71 return store_bridge_parm(d, buf, len, set_forward_delay);
71} 72}
72static CLASS_DEVICE_ATTR(forward_delay, S_IRUGO | S_IWUSR, 73static DEVICE_ATTR(forward_delay, S_IRUGO | S_IWUSR,
73 show_forward_delay, store_forward_delay); 74 show_forward_delay, store_forward_delay);
74 75
75static ssize_t show_hello_time(struct class_device *cd, char *buf) 76static ssize_t show_hello_time(struct device *d, struct device_attribute *attr,
77 char *buf)
76{ 78{
77 return sprintf(buf, "%lu\n", 79 return sprintf(buf, "%lu\n",
78 jiffies_to_clock_t(to_bridge(cd)->hello_time)); 80 jiffies_to_clock_t(to_bridge(d)->hello_time));
79} 81}
80 82
81static void set_hello_time(struct net_bridge *br, unsigned long val) 83static void set_hello_time(struct net_bridge *br, unsigned long val)
@@ -86,19 +88,20 @@ static void set_hello_time(struct net_bridge *br, unsigned long val)
86 br->bridge_hello_time = t; 88 br->bridge_hello_time = t;
87} 89}
88 90
89static ssize_t store_hello_time(struct class_device *cd, const char *buf, 91static ssize_t store_hello_time(struct device *d,
92 struct device_attribute *attr, const char *buf,
90 size_t len) 93 size_t len)
91{ 94{
92 return store_bridge_parm(cd, buf, len, set_hello_time); 95 return store_bridge_parm(d, buf, len, set_hello_time);
93} 96}
97static DEVICE_ATTR(hello_time, S_IRUGO | S_IWUSR, show_hello_time,
98 store_hello_time);
94 99
95static CLASS_DEVICE_ATTR(hello_time, S_IRUGO | S_IWUSR, show_hello_time, 100static ssize_t show_max_age(struct device *d, struct device_attribute *attr,
96 store_hello_time); 101 char *buf)
97
98static ssize_t show_max_age(struct class_device *cd, char *buf)
99{ 102{
100 return sprintf(buf, "%lu\n", 103 return sprintf(buf, "%lu\n",
101 jiffies_to_clock_t(to_bridge(cd)->max_age)); 104 jiffies_to_clock_t(to_bridge(d)->max_age));
102} 105}
103 106
104static void set_max_age(struct net_bridge *br, unsigned long val) 107static void set_max_age(struct net_bridge *br, unsigned long val)
@@ -109,18 +112,17 @@ static void set_max_age(struct net_bridge *br, unsigned long val)
109 br->bridge_max_age = t; 112 br->bridge_max_age = t;
110} 113}
111 114
112static ssize_t store_max_age(struct class_device *cd, const char *buf, 115static ssize_t store_max_age(struct device *d, struct device_attribute *attr,
113 size_t len) 116 const char *buf, size_t len)
114{ 117{
115 return store_bridge_parm(cd, buf, len, set_max_age); 118 return store_bridge_parm(d, buf, len, set_max_age);
116} 119}
120static DEVICE_ATTR(max_age, S_IRUGO | S_IWUSR, show_max_age, store_max_age);
117 121
118static CLASS_DEVICE_ATTR(max_age, S_IRUGO | S_IWUSR, show_max_age, 122static ssize_t show_ageing_time(struct device *d,
119 store_max_age); 123 struct device_attribute *attr, char *buf)
120
121static ssize_t show_ageing_time(struct class_device *cd, char *buf)
122{ 124{
123 struct net_bridge *br = to_bridge(cd); 125 struct net_bridge *br = to_bridge(d);
124 return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); 126 return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time));
125} 127}
126 128
@@ -129,17 +131,19 @@ static void set_ageing_time(struct net_bridge *br, unsigned long val)
129 br->ageing_time = clock_t_to_jiffies(val); 131 br->ageing_time = clock_t_to_jiffies(val);
130} 132}
131 133
132static ssize_t store_ageing_time(struct class_device *cd, const char *buf, 134static ssize_t store_ageing_time(struct device *d,
133 size_t len) 135 struct device_attribute *attr,
136 const char *buf, size_t len)
134{ 137{
135 return store_bridge_parm(cd, buf, len, set_ageing_time); 138 return store_bridge_parm(d, buf, len, set_ageing_time);
136} 139}
140static DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time,
141 store_ageing_time);
137 142
138static CLASS_DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time, 143static ssize_t show_stp_state(struct device *d,
139 store_ageing_time); 144 struct device_attribute *attr, char *buf)
140static ssize_t show_stp_state(struct class_device *cd, char *buf)
141{ 145{
142 struct net_bridge *br = to_bridge(cd); 146 struct net_bridge *br = to_bridge(d);
143 return sprintf(buf, "%d\n", br->stp_enabled); 147 return sprintf(buf, "%d\n", br->stp_enabled);
144} 148}
145 149
@@ -148,18 +152,19 @@ static void set_stp_state(struct net_bridge *br, unsigned long val)
148 br->stp_enabled = val; 152 br->stp_enabled = val;
149} 153}
150 154
151static ssize_t store_stp_state(struct class_device *cd, 155static ssize_t store_stp_state(struct device *d,
152 const char *buf, size_t len) 156 struct device_attribute *attr, const char *buf,
157 size_t len)
153{ 158{
154 return store_bridge_parm(cd, buf, len, set_stp_state); 159 return store_bridge_parm(d, buf, len, set_stp_state);
155} 160}
161static DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
162 store_stp_state);
156 163
157static CLASS_DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state, 164static ssize_t show_priority(struct device *d, struct device_attribute *attr,
158 store_stp_state); 165 char *buf)
159
160static ssize_t show_priority(struct class_device *cd, char *buf)
161{ 166{
162 struct net_bridge *br = to_bridge(cd); 167 struct net_bridge *br = to_bridge(d);
163 return sprintf(buf, "%d\n", 168 return sprintf(buf, "%d\n",
164 (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); 169 (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]);
165} 170}
@@ -169,92 +174,107 @@ static void set_priority(struct net_bridge *br, unsigned long val)
169 br_stp_set_bridge_priority(br, (u16) val); 174 br_stp_set_bridge_priority(br, (u16) val);
170} 175}
171 176
172static ssize_t store_priority(struct class_device *cd, 177static ssize_t store_priority(struct device *d, struct device_attribute *attr,
173 const char *buf, size_t len) 178 const char *buf, size_t len)
174{ 179{
175 return store_bridge_parm(cd, buf, len, set_priority); 180 return store_bridge_parm(d, buf, len, set_priority);
176} 181}
177static CLASS_DEVICE_ATTR(priority, S_IRUGO | S_IWUSR, show_priority, 182static DEVICE_ATTR(priority, S_IRUGO | S_IWUSR, show_priority, store_priority);
178 store_priority);
179 183
180static ssize_t show_root_id(struct class_device *cd, char *buf) 184static ssize_t show_root_id(struct device *d, struct device_attribute *attr,
185 char *buf)
181{ 186{
182 return br_show_bridge_id(buf, &to_bridge(cd)->designated_root); 187 return br_show_bridge_id(buf, &to_bridge(d)->designated_root);
183} 188}
184static CLASS_DEVICE_ATTR(root_id, S_IRUGO, show_root_id, NULL); 189static DEVICE_ATTR(root_id, S_IRUGO, show_root_id, NULL);
185 190
186static ssize_t show_bridge_id(struct class_device *cd, char *buf) 191static ssize_t show_bridge_id(struct device *d, struct device_attribute *attr,
192 char *buf)
187{ 193{
188 return br_show_bridge_id(buf, &to_bridge(cd)->bridge_id); 194 return br_show_bridge_id(buf, &to_bridge(d)->bridge_id);
189} 195}
190static CLASS_DEVICE_ATTR(bridge_id, S_IRUGO, show_bridge_id, NULL); 196static DEVICE_ATTR(bridge_id, S_IRUGO, show_bridge_id, NULL);
191 197
192static ssize_t show_root_port(struct class_device *cd, char *buf) 198static ssize_t show_root_port(struct device *d, struct device_attribute *attr,
199 char *buf)
193{ 200{
194 return sprintf(buf, "%d\n", to_bridge(cd)->root_port); 201 return sprintf(buf, "%d\n", to_bridge(d)->root_port);
195} 202}
196static CLASS_DEVICE_ATTR(root_port, S_IRUGO, show_root_port, NULL); 203static DEVICE_ATTR(root_port, S_IRUGO, show_root_port, NULL);
197 204
198static ssize_t show_root_path_cost(struct class_device *cd, char *buf) 205static ssize_t show_root_path_cost(struct device *d,
206 struct device_attribute *attr, char *buf)
199{ 207{
200 return sprintf(buf, "%d\n", to_bridge(cd)->root_path_cost); 208 return sprintf(buf, "%d\n", to_bridge(d)->root_path_cost);
201} 209}
202static CLASS_DEVICE_ATTR(root_path_cost, S_IRUGO, show_root_path_cost, NULL); 210static DEVICE_ATTR(root_path_cost, S_IRUGO, show_root_path_cost, NULL);
203 211
204static ssize_t show_topology_change(struct class_device *cd, char *buf) 212static ssize_t show_topology_change(struct device *d,
213 struct device_attribute *attr, char *buf)
205{ 214{
206 return sprintf(buf, "%d\n", to_bridge(cd)->topology_change); 215 return sprintf(buf, "%d\n", to_bridge(d)->topology_change);
207} 216}
208static CLASS_DEVICE_ATTR(topology_change, S_IRUGO, show_topology_change, NULL); 217static DEVICE_ATTR(topology_change, S_IRUGO, show_topology_change, NULL);
209 218
210static ssize_t show_topology_change_detected(struct class_device *cd, char *buf) 219static ssize_t show_topology_change_detected(struct device *d,
220 struct device_attribute *attr,
221 char *buf)
211{ 222{
212 struct net_bridge *br = to_bridge(cd); 223 struct net_bridge *br = to_bridge(d);
213 return sprintf(buf, "%d\n", br->topology_change_detected); 224 return sprintf(buf, "%d\n", br->topology_change_detected);
214} 225}
215static CLASS_DEVICE_ATTR(topology_change_detected, S_IRUGO, show_topology_change_detected, NULL); 226static DEVICE_ATTR(topology_change_detected, S_IRUGO,
227 show_topology_change_detected, NULL);
216 228
217static ssize_t show_hello_timer(struct class_device *cd, char *buf) 229static ssize_t show_hello_timer(struct device *d,
230 struct device_attribute *attr, char *buf)
218{ 231{
219 struct net_bridge *br = to_bridge(cd); 232 struct net_bridge *br = to_bridge(d);
220 return sprintf(buf, "%ld\n", br_timer_value(&br->hello_timer)); 233 return sprintf(buf, "%ld\n", br_timer_value(&br->hello_timer));
221} 234}
222static CLASS_DEVICE_ATTR(hello_timer, S_IRUGO, show_hello_timer, NULL); 235static DEVICE_ATTR(hello_timer, S_IRUGO, show_hello_timer, NULL);
223 236
224static ssize_t show_tcn_timer(struct class_device *cd, char *buf) 237static ssize_t show_tcn_timer(struct device *d, struct device_attribute *attr,
238 char *buf)
225{ 239{
226 struct net_bridge *br = to_bridge(cd); 240 struct net_bridge *br = to_bridge(d);
227 return sprintf(buf, "%ld\n", br_timer_value(&br->tcn_timer)); 241 return sprintf(buf, "%ld\n", br_timer_value(&br->tcn_timer));
228} 242}
229static CLASS_DEVICE_ATTR(tcn_timer, S_IRUGO, show_tcn_timer, NULL); 243static DEVICE_ATTR(tcn_timer, S_IRUGO, show_tcn_timer, NULL);
230 244
231static ssize_t show_topology_change_timer(struct class_device *cd, char *buf) 245static ssize_t show_topology_change_timer(struct device *d,
246 struct device_attribute *attr,
247 char *buf)
232{ 248{
233 struct net_bridge *br = to_bridge(cd); 249 struct net_bridge *br = to_bridge(d);
234 return sprintf(buf, "%ld\n", br_timer_value(&br->topology_change_timer)); 250 return sprintf(buf, "%ld\n", br_timer_value(&br->topology_change_timer));
235} 251}
236static CLASS_DEVICE_ATTR(topology_change_timer, S_IRUGO, show_topology_change_timer, NULL); 252static DEVICE_ATTR(topology_change_timer, S_IRUGO, show_topology_change_timer,
253 NULL);
237 254
238static ssize_t show_gc_timer(struct class_device *cd, char *buf) 255static ssize_t show_gc_timer(struct device *d, struct device_attribute *attr,
256 char *buf)
239{ 257{
240 struct net_bridge *br = to_bridge(cd); 258 struct net_bridge *br = to_bridge(d);
241 return sprintf(buf, "%ld\n", br_timer_value(&br->gc_timer)); 259 return sprintf(buf, "%ld\n", br_timer_value(&br->gc_timer));
242} 260}
243static CLASS_DEVICE_ATTR(gc_timer, S_IRUGO, show_gc_timer, NULL); 261static DEVICE_ATTR(gc_timer, S_IRUGO, show_gc_timer, NULL);
244 262
245static ssize_t show_group_addr(struct class_device *cd, char *buf) 263static ssize_t show_group_addr(struct device *d,
264 struct device_attribute *attr, char *buf)
246{ 265{
247 struct net_bridge *br = to_bridge(cd); 266 struct net_bridge *br = to_bridge(d);
248 return sprintf(buf, "%x:%x:%x:%x:%x:%x\n", 267 return sprintf(buf, "%x:%x:%x:%x:%x:%x\n",
249 br->group_addr[0], br->group_addr[1], 268 br->group_addr[0], br->group_addr[1],
250 br->group_addr[2], br->group_addr[3], 269 br->group_addr[2], br->group_addr[3],
251 br->group_addr[4], br->group_addr[5]); 270 br->group_addr[4], br->group_addr[5]);
252} 271}
253 272
254static ssize_t store_group_addr(struct class_device *cd, const char *buf, 273static ssize_t store_group_addr(struct device *d,
255 size_t len) 274 struct device_attribute *attr,
275 const char *buf, size_t len)
256{ 276{
257 struct net_bridge *br = to_bridge(cd); 277 struct net_bridge *br = to_bridge(d);
258 unsigned new_addr[6]; 278 unsigned new_addr[6];
259 int i; 279 int i;
260 280
@@ -286,28 +306,28 @@ static ssize_t store_group_addr(struct class_device *cd, const char *buf,
286 return len; 306 return len;
287} 307}
288 308
289static CLASS_DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR, 309static DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR,
290 show_group_addr, store_group_addr); 310 show_group_addr, store_group_addr);
291 311
292 312
293static struct attribute *bridge_attrs[] = { 313static struct attribute *bridge_attrs[] = {
294 &class_device_attr_forward_delay.attr, 314 &dev_attr_forward_delay.attr,
295 &class_device_attr_hello_time.attr, 315 &dev_attr_hello_time.attr,
296 &class_device_attr_max_age.attr, 316 &dev_attr_max_age.attr,
297 &class_device_attr_ageing_time.attr, 317 &dev_attr_ageing_time.attr,
298 &class_device_attr_stp_state.attr, 318 &dev_attr_stp_state.attr,
299 &class_device_attr_priority.attr, 319 &dev_attr_priority.attr,
300 &class_device_attr_bridge_id.attr, 320 &dev_attr_bridge_id.attr,
301 &class_device_attr_root_id.attr, 321 &dev_attr_root_id.attr,
302 &class_device_attr_root_path_cost.attr, 322 &dev_attr_root_path_cost.attr,
303 &class_device_attr_root_port.attr, 323 &dev_attr_root_port.attr,
304 &class_device_attr_topology_change.attr, 324 &dev_attr_topology_change.attr,
305 &class_device_attr_topology_change_detected.attr, 325 &dev_attr_topology_change_detected.attr,
306 &class_device_attr_hello_timer.attr, 326 &dev_attr_hello_timer.attr,
307 &class_device_attr_tcn_timer.attr, 327 &dev_attr_tcn_timer.attr,
308 &class_device_attr_topology_change_timer.attr, 328 &dev_attr_topology_change_timer.attr,
309 &class_device_attr_gc_timer.attr, 329 &dev_attr_gc_timer.attr,
310 &class_device_attr_group_addr.attr, 330 &dev_attr_group_addr.attr,
311 NULL 331 NULL
312}; 332};
313 333
@@ -325,8 +345,8 @@ static struct attribute_group bridge_group = {
325static ssize_t brforward_read(struct kobject *kobj, char *buf, 345static ssize_t brforward_read(struct kobject *kobj, char *buf,
326 loff_t off, size_t count) 346 loff_t off, size_t count)
327{ 347{
328 struct class_device *cdev = to_class_dev(kobj); 348 struct device *dev = to_dev(kobj);
329 struct net_bridge *br = to_bridge(cdev); 349 struct net_bridge *br = to_bridge(dev);
330 int n; 350 int n;
331 351
332 /* must read whole records */ 352 /* must read whole records */
@@ -363,7 +383,7 @@ static struct bin_attribute bridge_forward = {
363 */ 383 */
364int br_sysfs_addbr(struct net_device *dev) 384int br_sysfs_addbr(struct net_device *dev)
365{ 385{
366 struct kobject *brobj = &dev->class_dev.kobj; 386 struct kobject *brobj = &dev->dev.kobj;
367 struct net_bridge *br = netdev_priv(dev); 387 struct net_bridge *br = netdev_priv(dev);
368 int err; 388 int err;
369 389
@@ -395,9 +415,9 @@ int br_sysfs_addbr(struct net_device *dev)
395 } 415 }
396 return 0; 416 return 0;
397 out3: 417 out3:
398 sysfs_remove_bin_file(&dev->class_dev.kobj, &bridge_forward); 418 sysfs_remove_bin_file(&dev->dev.kobj, &bridge_forward);
399 out2: 419 out2:
400 sysfs_remove_group(&dev->class_dev.kobj, &bridge_group); 420 sysfs_remove_group(&dev->dev.kobj, &bridge_group);
401 out1: 421 out1:
402 return err; 422 return err;
403 423
@@ -405,7 +425,7 @@ int br_sysfs_addbr(struct net_device *dev)
405 425
406void br_sysfs_delbr(struct net_device *dev) 426void br_sysfs_delbr(struct net_device *dev)
407{ 427{
408 struct kobject *kobj = &dev->class_dev.kobj; 428 struct kobject *kobj = &dev->dev.kobj;
409 struct net_bridge *br = netdev_priv(dev); 429 struct net_bridge *br = netdev_priv(dev);
410 430
411 kobject_unregister(&br->ifobj); 431 kobject_unregister(&br->ifobj);
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index c51c9e42aeb3..0bc2aef8f9f3 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -211,7 +211,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
211 struct brport_attribute **a; 211 struct brport_attribute **a;
212 int err; 212 int err;
213 213
214 err = sysfs_create_link(&p->kobj, &br->dev->class_dev.kobj, 214 err = sysfs_create_link(&p->kobj, &br->dev->dev.kobj,
215 SYSFS_BRIDGE_PORT_LINK); 215 SYSFS_BRIDGE_PORT_LINK);
216 if (err) 216 if (err)
217 goto out2; 217 goto out2;
diff --git a/net/core/dev.c b/net/core/dev.c
index e660cb57e42a..455d589683e8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname)
751 else 751 else
752 strlcpy(dev->name, newname, IFNAMSIZ); 752 strlcpy(dev->name, newname, IFNAMSIZ);
753 753
754 err = class_device_rename(&dev->class_dev, dev->name); 754 err = device_rename(&dev->dev, dev->name);
755 if (!err) { 755 if (!err) {
756 hlist_del(&dev->name_hlist); 756 hlist_del(&dev->name_hlist);
757 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); 757 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
@@ -3221,8 +3221,8 @@ void free_netdev(struct net_device *dev)
3221 BUG_ON(dev->reg_state != NETREG_UNREGISTERED); 3221 BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
3222 dev->reg_state = NETREG_RELEASED; 3222 dev->reg_state = NETREG_RELEASED;
3223 3223
3224 /* will free via class release */ 3224 /* will free via device release */
3225 class_device_put(&dev->class_dev); 3225 put_device(&dev->dev);
3226#else 3226#else
3227 kfree((char *)dev - dev->padded); 3227 kfree((char *)dev - dev->padded);
3228#endif 3228#endif
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f47f319bb7dc..44db095a8f7e 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -18,9 +18,6 @@
18#include <linux/wireless.h> 18#include <linux/wireless.h>
19#include <net/iw_handler.h> 19#include <net/iw_handler.h>
20 20
21#define to_class_dev(obj) container_of(obj,struct class_device,kobj)
22#define to_net_dev(class) container_of(class, struct net_device, class_dev)
23
24static const char fmt_hex[] = "%#x\n"; 21static const char fmt_hex[] = "%#x\n";
25static const char fmt_long_hex[] = "%#lx\n"; 22static const char fmt_long_hex[] = "%#lx\n";
26static const char fmt_dec[] = "%d\n"; 23static const char fmt_dec[] = "%d\n";
@@ -32,10 +29,11 @@ static inline int dev_isalive(const struct net_device *dev)
32} 29}
33 30
34/* use same locking rules as GIF* ioctl's */ 31/* use same locking rules as GIF* ioctl's */
35static ssize_t netdev_show(const struct class_device *cd, char *buf, 32static ssize_t netdev_show(const struct device *dev,
33 struct device_attribute *attr, char *buf,
36 ssize_t (*format)(const struct net_device *, char *)) 34 ssize_t (*format)(const struct net_device *, char *))
37{ 35{
38 struct net_device *net = to_net_dev(cd); 36 struct net_device *net = to_net_dev(dev);
39 ssize_t ret = -EINVAL; 37 ssize_t ret = -EINVAL;
40 38
41 read_lock(&dev_base_lock); 39 read_lock(&dev_base_lock);
@@ -52,14 +50,15 @@ static ssize_t format_##field(const struct net_device *net, char *buf) \
52{ \ 50{ \
53 return sprintf(buf, format_string, net->field); \ 51 return sprintf(buf, format_string, net->field); \
54} \ 52} \
55static ssize_t show_##field(struct class_device *cd, char *buf) \ 53static ssize_t show_##field(struct device *dev, \
54 struct device_attribute *attr, char *buf) \
56{ \ 55{ \
57 return netdev_show(cd, buf, format_##field); \ 56 return netdev_show(dev, attr, buf, format_##field); \
58} 57}
59 58
60 59
61/* use same locking and permission rules as SIF* ioctl's */ 60/* use same locking and permission rules as SIF* ioctl's */
62static ssize_t netdev_store(struct class_device *dev, 61static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
63 const char *buf, size_t len, 62 const char *buf, size_t len,
64 int (*set)(struct net_device *, unsigned long)) 63 int (*set)(struct net_device *, unsigned long))
65{ 64{
@@ -104,7 +103,8 @@ static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
104 return cp - buf; 103 return cp - buf;
105} 104}
106 105
107static ssize_t show_address(struct class_device *dev, char *buf) 106static ssize_t show_address(struct device *dev, struct device_attribute *attr,
107 char *buf)
108{ 108{
109 struct net_device *net = to_net_dev(dev); 109 struct net_device *net = to_net_dev(dev);
110 ssize_t ret = -EINVAL; 110 ssize_t ret = -EINVAL;
@@ -116,7 +116,8 @@ static ssize_t show_address(struct class_device *dev, char *buf)
116 return ret; 116 return ret;
117} 117}
118 118
119static ssize_t show_broadcast(struct class_device *dev, char *buf) 119static ssize_t show_broadcast(struct device *dev,
120 struct device_attribute *attr, char *buf)
120{ 121{
121 struct net_device *net = to_net_dev(dev); 122 struct net_device *net = to_net_dev(dev);
122 if (dev_isalive(net)) 123 if (dev_isalive(net))
@@ -124,7 +125,8 @@ static ssize_t show_broadcast(struct class_device *dev, char *buf)
124 return -EINVAL; 125 return -EINVAL;
125} 126}
126 127
127static ssize_t show_carrier(struct class_device *dev, char *buf) 128static ssize_t show_carrier(struct device *dev,
129 struct device_attribute *attr, char *buf)
128{ 130{
129 struct net_device *netdev = to_net_dev(dev); 131 struct net_device *netdev = to_net_dev(dev);
130 if (netif_running(netdev)) { 132 if (netif_running(netdev)) {
@@ -133,7 +135,8 @@ static ssize_t show_carrier(struct class_device *dev, char *buf)
133 return -EINVAL; 135 return -EINVAL;
134} 136}
135 137
136static ssize_t show_dormant(struct class_device *dev, char *buf) 138static ssize_t show_dormant(struct device *dev,
139 struct device_attribute *attr, char *buf)
137{ 140{
138 struct net_device *netdev = to_net_dev(dev); 141 struct net_device *netdev = to_net_dev(dev);
139 142
@@ -153,7 +156,8 @@ static const char *operstates[] = {
153 "up" 156 "up"
154}; 157};
155 158
156static ssize_t show_operstate(struct class_device *dev, char *buf) 159static ssize_t show_operstate(struct device *dev,
160 struct device_attribute *attr, char *buf)
157{ 161{
158 const struct net_device *netdev = to_net_dev(dev); 162 const struct net_device *netdev = to_net_dev(dev);
159 unsigned char operstate; 163 unsigned char operstate;
@@ -178,9 +182,10 @@ static int change_mtu(struct net_device *net, unsigned long new_mtu)
178 return dev_set_mtu(net, (int) new_mtu); 182 return dev_set_mtu(net, (int) new_mtu);
179} 183}
180 184
181static ssize_t store_mtu(struct class_device *dev, const char *buf, size_t len) 185static ssize_t store_mtu(struct device *dev, struct device_attribute *attr,
186 const char *buf, size_t len)
182{ 187{
183 return netdev_store(dev, buf, len, change_mtu); 188 return netdev_store(dev, attr, buf, len, change_mtu);
184} 189}
185 190
186NETDEVICE_SHOW(flags, fmt_hex); 191NETDEVICE_SHOW(flags, fmt_hex);
@@ -190,9 +195,10 @@ static int change_flags(struct net_device *net, unsigned long new_flags)
190 return dev_change_flags(net, (unsigned) new_flags); 195 return dev_change_flags(net, (unsigned) new_flags);
191} 196}
192 197
193static ssize_t store_flags(struct class_device *dev, const char *buf, size_t len) 198static ssize_t store_flags(struct device *dev, struct device_attribute *attr,
199 const char *buf, size_t len)
194{ 200{
195 return netdev_store(dev, buf, len, change_flags); 201 return netdev_store(dev, attr, buf, len, change_flags);
196} 202}
197 203
198NETDEVICE_SHOW(tx_queue_len, fmt_ulong); 204NETDEVICE_SHOW(tx_queue_len, fmt_ulong);
@@ -203,9 +209,11 @@ static int change_tx_queue_len(struct net_device *net, unsigned long new_len)
203 return 0; 209 return 0;
204} 210}
205 211
206static ssize_t store_tx_queue_len(struct class_device *dev, const char *buf, size_t len) 212static ssize_t store_tx_queue_len(struct device *dev,
213 struct device_attribute *attr,
214 const char *buf, size_t len)
207{ 215{
208 return netdev_store(dev, buf, len, change_tx_queue_len); 216 return netdev_store(dev, attr, buf, len, change_tx_queue_len);
209} 217}
210 218
211NETDEVICE_SHOW(weight, fmt_dec); 219NETDEVICE_SHOW(weight, fmt_dec);
@@ -216,12 +224,13 @@ static int change_weight(struct net_device *net, unsigned long new_weight)
216 return 0; 224 return 0;
217} 225}
218 226
219static ssize_t store_weight(struct class_device *dev, const char *buf, size_t len) 227static ssize_t store_weight(struct device *dev, struct device_attribute *attr,
228 const char *buf, size_t len)
220{ 229{
221 return netdev_store(dev, buf, len, change_weight); 230 return netdev_store(dev, attr, buf, len, change_weight);
222} 231}
223 232
224static struct class_device_attribute net_class_attributes[] = { 233static struct device_attribute net_class_attributes[] = {
225 __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), 234 __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
226 __ATTR(iflink, S_IRUGO, show_iflink, NULL), 235 __ATTR(iflink, S_IRUGO, show_iflink, NULL),
227 __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), 236 __ATTR(ifindex, S_IRUGO, show_ifindex, NULL),
@@ -242,10 +251,11 @@ static struct class_device_attribute net_class_attributes[] = {
242}; 251};
243 252
244/* Show a given an attribute in the statistics group */ 253/* Show a given an attribute in the statistics group */
245static ssize_t netstat_show(const struct class_device *cd, char *buf, 254static ssize_t netstat_show(const struct device *d,
255 struct device_attribute *attr, char *buf,
246 unsigned long offset) 256 unsigned long offset)
247{ 257{
248 struct net_device *dev = to_net_dev(cd); 258 struct net_device *dev = to_net_dev(d);
249 struct net_device_stats *stats; 259 struct net_device_stats *stats;
250 ssize_t ret = -EINVAL; 260 ssize_t ret = -EINVAL;
251 261
@@ -265,12 +275,13 @@ static ssize_t netstat_show(const struct class_device *cd, char *buf,
265 275
266/* generate a read-only statistics attribute */ 276/* generate a read-only statistics attribute */
267#define NETSTAT_ENTRY(name) \ 277#define NETSTAT_ENTRY(name) \
268static ssize_t show_##name(struct class_device *cd, char *buf) \ 278static ssize_t show_##name(struct device *d, \
279 struct device_attribute *attr, char *buf) \
269{ \ 280{ \
270 return netstat_show(cd, buf, \ 281 return netstat_show(d, attr, buf, \
271 offsetof(struct net_device_stats, name)); \ 282 offsetof(struct net_device_stats, name)); \
272} \ 283} \
273static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) 284static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
274 285
275NETSTAT_ENTRY(rx_packets); 286NETSTAT_ENTRY(rx_packets);
276NETSTAT_ENTRY(tx_packets); 287NETSTAT_ENTRY(tx_packets);
@@ -297,29 +308,29 @@ NETSTAT_ENTRY(rx_compressed);
297NETSTAT_ENTRY(tx_compressed); 308NETSTAT_ENTRY(tx_compressed);
298 309
299static struct attribute *netstat_attrs[] = { 310static struct attribute *netstat_attrs[] = {
300 &class_device_attr_rx_packets.attr, 311 &dev_attr_rx_packets.attr,
301 &class_device_attr_tx_packets.attr, 312 &dev_attr_tx_packets.attr,
302 &class_device_attr_rx_bytes.attr, 313 &dev_attr_rx_bytes.attr,
303 &class_device_attr_tx_bytes.attr, 314 &dev_attr_tx_bytes.attr,
304 &class_device_attr_rx_errors.attr, 315 &dev_attr_rx_errors.attr,
305 &class_device_attr_tx_errors.attr, 316 &dev_attr_tx_errors.attr,
306 &class_device_attr_rx_dropped.attr, 317 &dev_attr_rx_dropped.attr,
307 &class_device_attr_tx_dropped.attr, 318 &dev_attr_tx_dropped.attr,
308 &class_device_attr_multicast.attr, 319 &dev_attr_multicast.attr,
309 &class_device_attr_collisions.attr, 320 &dev_attr_collisions.attr,
310 &class_device_attr_rx_length_errors.attr, 321 &dev_attr_rx_length_errors.attr,
311 &class_device_attr_rx_over_errors.attr, 322 &dev_attr_rx_over_errors.attr,
312 &class_device_attr_rx_crc_errors.attr, 323 &dev_attr_rx_crc_errors.attr,
313 &class_device_attr_rx_frame_errors.attr, 324 &dev_attr_rx_frame_errors.attr,
314 &class_device_attr_rx_fifo_errors.attr, 325 &dev_attr_rx_fifo_errors.attr,
315 &class_device_attr_rx_missed_errors.attr, 326 &dev_attr_rx_missed_errors.attr,
316 &class_device_attr_tx_aborted_errors.attr, 327 &dev_attr_tx_aborted_errors.attr,
317 &class_device_attr_tx_carrier_errors.attr, 328 &dev_attr_tx_carrier_errors.attr,
318 &class_device_attr_tx_fifo_errors.attr, 329 &dev_attr_tx_fifo_errors.attr,
319 &class_device_attr_tx_heartbeat_errors.attr, 330 &dev_attr_tx_heartbeat_errors.attr,
320 &class_device_attr_tx_window_errors.attr, 331 &dev_attr_tx_window_errors.attr,
321 &class_device_attr_rx_compressed.attr, 332 &dev_attr_rx_compressed.attr,
322 &class_device_attr_tx_compressed.attr, 333 &dev_attr_tx_compressed.attr,
323 NULL 334 NULL
324}; 335};
325 336
@@ -331,11 +342,11 @@ static struct attribute_group netstat_group = {
331 342
332#ifdef WIRELESS_EXT 343#ifdef WIRELESS_EXT
333/* helper function that does all the locking etc for wireless stats */ 344/* helper function that does all the locking etc for wireless stats */
334static ssize_t wireless_show(struct class_device *cd, char *buf, 345static ssize_t wireless_show(struct device *d, char *buf,
335 ssize_t (*format)(const struct iw_statistics *, 346 ssize_t (*format)(const struct iw_statistics *,
336 char *)) 347 char *))
337{ 348{
338 struct net_device *dev = to_net_dev(cd); 349 struct net_device *dev = to_net_dev(d);
339 const struct iw_statistics *iw = NULL; 350 const struct iw_statistics *iw = NULL;
340 ssize_t ret = -EINVAL; 351 ssize_t ret = -EINVAL;
341 352
@@ -358,11 +369,12 @@ static ssize_t format_iw_##name(const struct iw_statistics *iw, char *buf) \
358{ \ 369{ \
359 return sprintf(buf, format_string, iw->field); \ 370 return sprintf(buf, format_string, iw->field); \
360} \ 371} \
361static ssize_t show_iw_##name(struct class_device *cd, char *buf) \ 372static ssize_t show_iw_##name(struct device *d, \
373 struct device_attribute *attr, char *buf) \
362{ \ 374{ \
363 return wireless_show(cd, buf, format_iw_##name); \ 375 return wireless_show(d, buf, format_iw_##name); \
364} \ 376} \
365static CLASS_DEVICE_ATTR(name, S_IRUGO, show_iw_##name, NULL) 377static DEVICE_ATTR(name, S_IRUGO, show_iw_##name, NULL)
366 378
367WIRELESS_SHOW(status, status, fmt_hex); 379WIRELESS_SHOW(status, status, fmt_hex);
368WIRELESS_SHOW(link, qual.qual, fmt_dec); 380WIRELESS_SHOW(link, qual.qual, fmt_dec);
@@ -376,16 +388,16 @@ WIRELESS_SHOW(retries, discard.retries, fmt_dec);
376WIRELESS_SHOW(beacon, miss.beacon, fmt_dec); 388WIRELESS_SHOW(beacon, miss.beacon, fmt_dec);
377 389
378static struct attribute *wireless_attrs[] = { 390static struct attribute *wireless_attrs[] = {
379 &class_device_attr_status.attr, 391 &dev_attr_status.attr,
380 &class_device_attr_link.attr, 392 &dev_attr_link.attr,
381 &class_device_attr_level.attr, 393 &dev_attr_level.attr,
382 &class_device_attr_noise.attr, 394 &dev_attr_noise.attr,
383 &class_device_attr_nwid.attr, 395 &dev_attr_nwid.attr,
384 &class_device_attr_crypt.attr, 396 &dev_attr_crypt.attr,
385 &class_device_attr_fragment.attr, 397 &dev_attr_fragment.attr,
386 &class_device_attr_retries.attr, 398 &dev_attr_retries.attr,
387 &class_device_attr_misc.attr, 399 &dev_attr_misc.attr,
388 &class_device_attr_beacon.attr, 400 &dev_attr_beacon.attr,
389 NULL 401 NULL
390}; 402};
391 403
@@ -396,10 +408,10 @@ static struct attribute_group wireless_group = {
396#endif 408#endif
397 409
398#ifdef CONFIG_HOTPLUG 410#ifdef CONFIG_HOTPLUG
399static int netdev_uevent(struct class_device *cd, char **envp, 411static int netdev_uevent(struct device *d, char **envp,
400 int num_envp, char *buf, int size) 412 int num_envp, char *buf, int size)
401{ 413{
402 struct net_device *dev = to_net_dev(cd); 414 struct net_device *dev = to_net_dev(d);
403 int i = 0; 415 int i = 0;
404 int n; 416 int n;
405 417
@@ -419,12 +431,11 @@ static int netdev_uevent(struct class_device *cd, char **envp,
419 431
420/* 432/*
421 * netdev_release -- destroy and free a dead device. 433 * netdev_release -- destroy and free a dead device.
422 * Called when last reference to class_device kobject is gone. 434 * Called when last reference to device kobject is gone.
423 */ 435 */
424static void netdev_release(struct class_device *cd) 436static void netdev_release(struct device *d)
425{ 437{
426 struct net_device *dev 438 struct net_device *dev = to_net_dev(d);
427 = container_of(cd, struct net_device, class_dev);
428 439
429 BUG_ON(dev->reg_state != NETREG_RELEASED); 440 BUG_ON(dev->reg_state != NETREG_RELEASED);
430 441
@@ -433,31 +444,31 @@ static void netdev_release(struct class_device *cd)
433 444
434static struct class net_class = { 445static struct class net_class = {
435 .name = "net", 446 .name = "net",
436 .release = netdev_release, 447 .dev_release = netdev_release,
437 .class_dev_attrs = net_class_attributes, 448 .dev_attrs = net_class_attributes,
438#ifdef CONFIG_HOTPLUG 449#ifdef CONFIG_HOTPLUG
439 .uevent = netdev_uevent, 450 .dev_uevent = netdev_uevent,
440#endif 451#endif
441}; 452};
442 453
443void netdev_unregister_sysfs(struct net_device * net) 454void netdev_unregister_sysfs(struct net_device * net)
444{ 455{
445 class_device_del(&(net->class_dev)); 456 device_del(&(net->dev));
446} 457}
447 458
448/* Create sysfs entries for network device. */ 459/* Create sysfs entries for network device. */
449int netdev_register_sysfs(struct net_device *net) 460int netdev_register_sysfs(struct net_device *net)
450{ 461{
451 struct class_device *class_dev = &(net->class_dev); 462 struct device *dev = &(net->dev);
452 struct attribute_group **groups = net->sysfs_groups; 463 struct attribute_group **groups = net->sysfs_groups;
453 464
454 class_device_initialize(class_dev); 465 device_initialize(dev);
455 class_dev->class = &net_class; 466 dev->class = &net_class;
456 class_dev->class_data = net; 467 dev->platform_data = net;
457 class_dev->groups = groups; 468 dev->groups = groups;
458 469
459 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ); 470 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
460 strlcpy(class_dev->class_id, net->name, BUS_ID_SIZE); 471 strlcpy(dev->bus_id, net->name, BUS_ID_SIZE);
461 472
462 if (net->get_stats) 473 if (net->get_stats)
463 *groups++ = &netstat_group; 474 *groups++ = &netstat_group;
@@ -467,7 +478,7 @@ int netdev_register_sysfs(struct net_device *net)
467 *groups++ = &wireless_group; 478 *groups++ = &wireless_group;
468#endif 479#endif
469 480
470 return class_device_add(class_dev); 481 return device_add(dev);
471} 482}
472 483
473int netdev_sysfs_init(void) 484int netdev_sysfs_init(void)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index de7801d589e7..f3404ae9f190 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -268,7 +268,7 @@ nodata:
268struct sk_buff *__netdev_alloc_skb(struct net_device *dev, 268struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
269 unsigned int length, gfp_t gfp_mask) 269 unsigned int length, gfp_t gfp_mask)
270{ 270{
271 int node = dev->class_dev.dev ? dev_to_node(dev->class_dev.dev) : -1; 271 int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
272 struct sk_buff *skb; 272 struct sk_buff *skb;
273 273
274 skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node); 274 skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);