aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-parameters.txt5
-rw-r--r--Documentation/kobject.txt4
-rw-r--r--arch/mips/kernel/rtlx.c4
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c3
-rw-r--r--arch/x86/kernel/cpuid.c4
-rw-r--r--arch/x86/kernel/dumpstack_32.c2
-rw-r--r--arch/x86/kernel/dumpstack_64.c2
-rw-r--r--arch/x86/kernel/msr.c4
-rw-r--r--block/bsg.c3
-rw-r--r--drivers/base/bus.c54
-rw-r--r--drivers/base/core.c30
-rw-r--r--drivers/base/dd.c3
-rw-r--r--drivers/base/platform.c49
-rw-r--r--drivers/base/power/main.c2
-rw-r--r--drivers/block/aoe/aoechr.c6
-rw-r--r--drivers/block/paride/pg.c5
-rw-r--r--drivers/block/paride/pt.c10
-rw-r--r--drivers/block/pktcdvd.c5
-rw-r--r--drivers/char/bsr.c5
-rw-r--r--drivers/char/dsp56k.c4
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c2
-rw-r--r--drivers/char/istallion.c5
-rw-r--r--drivers/char/lp.c4
-rw-r--r--drivers/char/mem.c6
-rw-r--r--drivers/char/misc.c4
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c3
-rw-r--r--drivers/char/ppdev.c5
-rw-r--r--drivers/char/raw.c7
-rw-r--r--drivers/char/snsc.c4
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/vc_screen.c12
-rw-r--r--drivers/char/viotape.c8
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c3
-rw-r--r--drivers/dca/dca-sysfs.c8
-rw-r--r--drivers/firmware/iscsi_ibft.c18
-rw-r--r--drivers/hid/hidraw.c5
-rw-r--r--drivers/hwmon/hwmon.c4
-rw-r--r--drivers/i2c/i2c-dev.c6
-rw-r--r--drivers/ide/ide-probe.c4
-rw-r--r--drivers/ide/ide-tape.c11
-rw-r--r--drivers/ieee1394/dv1394.c8
-rw-r--r--drivers/ieee1394/raw1394.c8
-rw-r--r--drivers/ieee1394/video1394.c5
-rw-r--r--drivers/infiniband/core/cm.c6
-rw-r--r--drivers/infiniband/core/user_mad.c12
-rw-r--r--drivers/infiniband/core/uverbs_main.c9
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c2
-rw-r--r--drivers/isdn/capi/capi.c3
-rw-r--r--drivers/leds/led-class.c4
-rw-r--r--drivers/macintosh/adb.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c2
-rw-r--r--drivers/misc/phantom.c6
-rw-r--r--drivers/mtd/mtdchar.c10
-rw-r--r--drivers/net/phy/phy_device.c8
-rw-r--r--drivers/net/ppp_generic.c4
-rw-r--r--drivers/net/wan/cosa.c4
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c6
-rw-r--r--drivers/pci/probe.c50
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/core.c10
-rw-r--r--drivers/pnp/driver.c1
-rw-r--r--drivers/pnp/interface.c37
-rw-r--r--drivers/power/power_supply_core.c4
-rw-r--r--drivers/s390/char/raw3270.c14
-rw-r--r--drivers/s390/char/tape_class.c6
-rw-r--r--drivers/s390/char/vmlogrdr.c8
-rw-r--r--drivers/s390/char/vmur.c5
-rw-r--r--drivers/scsi/ch.c6
-rw-r--r--drivers/scsi/dpt_i2o.c2
-rw-r--r--drivers/scsi/osst.c3
-rw-r--r--drivers/scsi/sg.c10
-rw-r--r--drivers/scsi/st.c11
-rw-r--r--drivers/spi/spidev.c7
-rw-r--r--drivers/uio/Kconfig13
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio.c26
-rw-r--r--drivers/uio/uio_pdrv.c2
-rw-r--r--drivers/uio/uio_sercos3.c243
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/file.c6
-rw-r--r--drivers/usb/core/hcd.c5
-rw-r--r--drivers/usb/gadget/Makefile23
-rw-r--r--drivers/usb/gadget/cdc2.c25
-rw-r--r--drivers/usb/gadget/ether.c28
-rw-r--r--drivers/usb/gadget/f_ecm.c108
-rw-r--r--drivers/usb/gadget/f_loopback.c34
-rw-r--r--drivers/usb/gadget/f_subset.c44
-rw-r--r--drivers/usb/gadget/file_storage.c12
-rw-r--r--drivers/usb/gadget/gmidi.c15
-rw-r--r--drivers/usb/gadget/printer.c18
-rw-r--r--drivers/usb/gadget/rndis.c115
-rw-r--r--drivers/usb/gadget/serial.c18
-rw-r--r--drivers/usb/gadget/u_ether.c4
-rw-r--r--drivers/usb/gadget/zero.c17
-rw-r--r--drivers/usb/host/uhci-q.c24
-rw-r--r--drivers/usb/misc/phidgetkit.c5
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c5
-rw-r--r--drivers/usb/misc/phidgetservo.c5
-rw-r--r--drivers/usb/mon/mon_bin.c6
-rw-r--r--drivers/video/console/fbcon.c4
-rw-r--r--drivers/video/display/display-sysfs.c9
-rw-r--r--drivers/video/fbmem.c5
-rw-r--r--fs/coda/psdev.c5
-rw-r--r--fs/sysfs/bin.c42
-rw-r--r--fs/sysfs/dir.c24
-rw-r--r--fs/sysfs/file.c46
-rw-r--r--fs/sysfs/mount.c15
-rw-r--r--fs/sysfs/sysfs.h6
-rw-r--r--include/asm-generic/vmlinux.lds.h10
-rw-r--r--include/linux/device.h18
-rw-r--r--include/linux/dynamic_printk.h93
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/module.h1
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/sysfs.h36
-rw-r--r--kernel/module.c33
-rw-r--r--lib/Kconfig.debug55
-rw-r--r--lib/Makefile2
-rw-r--r--lib/dynamic_printk.c418
-rw-r--r--lib/kobject.c35
-rw-r--r--net/netfilter/nf_conntrack_pptp.c2
-rw-r--r--scripts/Makefile.lib11
-rw-r--r--scripts/basic/Makefile2
-rw-r--r--scripts/basic/hash.c64
-rw-r--r--sound/core/init.c6
-rw-r--r--sound/core/sound.c5
-rw-r--r--sound/oss/soundcard.c15
-rw-r--r--sound/sound_core.c5
131 files changed, 1786 insertions, 617 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 82c561f3abbd..dd28a0d56981 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1714,6 +1714,11 @@ and is between 256 and 4096 characters. It is defined in the file
1714 autoconfiguration. 1714 autoconfiguration.
1715 Ranges are in pairs (memory base and size). 1715 Ranges are in pairs (memory base and size).
1716 1716
1717 dynamic_printk
1718 Enables pr_debug()/dev_dbg() calls if
1719 CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. These can also
1720 be switched on/off via <debugfs>/dynamic_printk/modules
1721
1717 print-fatal-signals= 1722 print-fatal-signals=
1718 [KNL] debug: print fatal signals 1723 [KNL] debug: print fatal signals
1719 print-fatal-signals=1: print segfault info to 1724 print-fatal-signals=1: print segfault info to
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index 51a8021ee532..f5d2aad65a67 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -118,6 +118,10 @@ the name of the kobject, call kobject_rename():
118 118
119 int kobject_rename(struct kobject *kobj, const char *new_name); 119 int kobject_rename(struct kobject *kobj, const char *new_name);
120 120
121Note kobject_rename does perform any locking or have a solid notion of
122what names are valid so the provide must provide their own sanity checking
123and serialization.
124
121There is a function called kobject_set_name() but that is legacy cruft and 125There is a function called kobject_set_name() but that is legacy cruft and
122is being removed. If your code needs to call this function, it is 126is being removed. If your code needs to call this function, it is
123incorrect and needs to be fixed. 127incorrect and needs to be fixed.
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index dfd868b68364..4ce93aa7b372 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -522,8 +522,8 @@ static int __init rtlx_module_init(void)
522 atomic_set(&channel_wqs[i].in_open, 0); 522 atomic_set(&channel_wqs[i].in_open, 0);
523 mutex_init(&channel_wqs[i].mutex); 523 mutex_init(&channel_wqs[i].mutex);
524 524
525 dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i), 525 dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
526 NULL, "%s%d", module_name, i); 526 "%s%d", module_name, i);
527 if (IS_ERR(dev)) { 527 if (IS_ERR(dev)) {
528 err = PTR_ERR(dev); 528 err = PTR_ERR(dev);
529 goto out_chrdev; 529 goto out_chrdev;
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index 66e3e3fb311f..637a194e5cd5 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -576,8 +576,7 @@ static int __init sbprof_tb_init(void)
576 576
577 tb_class = tbc; 577 tb_class = tbc;
578 578
579 dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), 579 dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
580 NULL, "tb");
581 if (IS_ERR(dev)) { 580 if (IS_ERR(dev)) {
582 err = PTR_ERR(dev); 581 err = PTR_ERR(dev);
583 goto out_class; 582 goto out_class;
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 6a44d6465991..72cefd1e649b 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -147,8 +147,8 @@ static __cpuinit int cpuid_device_create(int cpu)
147{ 147{
148 struct device *dev; 148 struct device *dev;
149 149
150 dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), 150 dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL,
151 NULL, "cpu%d", cpu); 151 "cpu%d", cpu);
152 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 152 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
153} 153}
154 154
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 201ee359a1a9..1a78180f08d3 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -13,6 +13,7 @@
13#include <linux/kexec.h> 13#include <linux/kexec.h>
14#include <linux/bug.h> 14#include <linux/bug.h>
15#include <linux/nmi.h> 15#include <linux/nmi.h>
16#include <linux/sysfs.h>
16 17
17#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
18 19
@@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
343 printk("DEBUG_PAGEALLOC"); 344 printk("DEBUG_PAGEALLOC");
344#endif 345#endif
345 printk("\n"); 346 printk("\n");
347 sysfs_printk_last_file();
346 if (notify_die(DIE_OOPS, str, regs, err, 348 if (notify_die(DIE_OOPS, str, regs, err,
347 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 349 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
348 return 1; 350 return 1;
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 086cc8118e39..96a5db7da8a7 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -13,6 +13,7 @@
13#include <linux/kexec.h> 13#include <linux/kexec.h>
14#include <linux/bug.h> 14#include <linux/bug.h>
15#include <linux/nmi.h> 15#include <linux/nmi.h>
16#include <linux/sysfs.h>
16 17
17#include <asm/stacktrace.h> 18#include <asm/stacktrace.h>
18 19
@@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
489 printk("DEBUG_PAGEALLOC"); 490 printk("DEBUG_PAGEALLOC");
490#endif 491#endif
491 printk("\n"); 492 printk("\n");
493 sysfs_printk_last_file();
492 if (notify_die(DIE_OOPS, str, regs, err, 494 if (notify_die(DIE_OOPS, str, regs, err,
493 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 495 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
494 return 1; 496 return 1;
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 2e2af5d18191..82a7c7ed6d45 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -163,8 +163,8 @@ static int __cpuinit msr_device_create(int cpu)
163{ 163{
164 struct device *dev; 164 struct device *dev;
165 165
166 dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), 166 dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL,
167 NULL, "msr%d", cpu); 167 "msr%d", cpu);
168 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 168 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
169} 169}
170 170
diff --git a/block/bsg.c b/block/bsg.c
index 56cb343c76d8..034112bfe1f3 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -1024,8 +1024,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
1024 bcd->release = release; 1024 bcd->release = release;
1025 kref_init(&bcd->ref); 1025 kref_init(&bcd->ref);
1026 dev = MKDEV(bsg_major, bcd->minor); 1026 dev = MKDEV(bsg_major, bcd->minor);
1027 class_dev = device_create_drvdata(bsg_class, parent, dev, NULL, 1027 class_dev = device_create(bsg_class, parent, dev, NULL, "%s", devname);
1028 "%s", devname);
1029 if (IS_ERR(class_dev)) { 1028 if (IS_ERR(class_dev)) {
1030 ret = PTR_ERR(class_dev); 1029 ret = PTR_ERR(class_dev);
1031 goto put_dev; 1030 goto put_dev;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ef522ae55480..5aee1c0169ea 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -333,9 +333,7 @@ static int match_name(struct device *dev, void *data)
333{ 333{
334 const char *name = data; 334 const char *name = data;
335 335
336 if (strcmp(name, dev->bus_id) == 0) 336 return sysfs_streq(name, dev->bus_id);
337 return 1;
338 return 0;
339} 337}
340 338
341/** 339/**
@@ -982,6 +980,56 @@ struct klist *bus_get_device_klist(struct bus_type *bus)
982} 980}
983EXPORT_SYMBOL_GPL(bus_get_device_klist); 981EXPORT_SYMBOL_GPL(bus_get_device_klist);
984 982
983/*
984 * Yes, this forcably breaks the klist abstraction temporarily. It
985 * just wants to sort the klist, not change reference counts and
986 * take/drop locks rapidly in the process. It does all this while
987 * holding the lock for the list, so objects can't otherwise be
988 * added/removed while we're swizzling.
989 */
990static void device_insertion_sort_klist(struct device *a, struct list_head *list,
991 int (*compare)(const struct device *a,
992 const struct device *b))
993{
994 struct list_head *pos;
995 struct klist_node *n;
996 struct device *b;
997
998 list_for_each(pos, list) {
999 n = container_of(pos, struct klist_node, n_node);
1000 b = container_of(n, struct device, knode_bus);
1001 if (compare(a, b) <= 0) {
1002 list_move_tail(&a->knode_bus.n_node,
1003 &b->knode_bus.n_node);
1004 return;
1005 }
1006 }
1007 list_move_tail(&a->knode_bus.n_node, list);
1008}
1009
1010void bus_sort_breadthfirst(struct bus_type *bus,
1011 int (*compare)(const struct device *a,
1012 const struct device *b))
1013{
1014 LIST_HEAD(sorted_devices);
1015 struct list_head *pos, *tmp;
1016 struct klist_node *n;
1017 struct device *dev;
1018 struct klist *device_klist;
1019
1020 device_klist = bus_get_device_klist(bus);
1021
1022 spin_lock(&device_klist->k_lock);
1023 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1024 n = container_of(pos, struct klist_node, n_node);
1025 dev = container_of(n, struct device, knode_bus);
1026 device_insertion_sort_klist(dev, &sorted_devices, compare);
1027 }
1028 list_splice(&sorted_devices, &device_klist->k_list);
1029 spin_unlock(&device_klist->k_lock);
1030}
1031EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
1032
985int __init buses_init(void) 1033int __init buses_init(void)
986{ 1034{
987 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); 1035 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b98cb1416a2d..8c2cc2648f5a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -523,11 +523,16 @@ static void klist_children_put(struct klist_node *n)
523 * device_initialize - init device structure. 523 * device_initialize - init device structure.
524 * @dev: device. 524 * @dev: device.
525 * 525 *
526 * This prepares the device for use by other layers, 526 * This prepares the device for use by other layers by initializing
527 * including adding it to the device hierarchy. 527 * its fields.
528 * It is the first half of device_register(), if called by 528 * It is the first half of device_register(), if called by
529 * that, though it can also be called separately, so one 529 * that function, though it can also be called separately, so one
530 * may use @dev's fields (e.g. the refcount). 530 * may use @dev's fields. In particular, get_device()/put_device()
531 * may be used for reference counting of @dev after calling this
532 * function.
533 *
534 * NOTE: Use put_device() to give up your reference instead of freeing
535 * @dev directly once you have called this function.
531 */ 536 */
532void device_initialize(struct device *dev) 537void device_initialize(struct device *dev)
533{ 538{
@@ -835,9 +840,13 @@ static void device_remove_sys_dev_entry(struct device *dev)
835 * This is part 2 of device_register(), though may be called 840 * This is part 2 of device_register(), though may be called
836 * separately _iff_ device_initialize() has been called separately. 841 * separately _iff_ device_initialize() has been called separately.
837 * 842 *
838 * This adds it to the kobject hierarchy via kobject_add(), adds it 843 * This adds @dev to the kobject hierarchy via kobject_add(), adds it
839 * to the global and sibling lists for the device, then 844 * to the global and sibling lists for the device, then
840 * adds it to the other relevant subsystems of the driver model. 845 * adds it to the other relevant subsystems of the driver model.
846 *
847 * NOTE: _Never_ directly free @dev after calling this function, even
848 * if it returned an error! Always use put_device() to give up your
849 * reference instead.
841 */ 850 */
842int device_add(struct device *dev) 851int device_add(struct device *dev)
843{ 852{
@@ -965,6 +974,10 @@ done:
965 * I.e. you should only call the two helpers separately if 974 * I.e. you should only call the two helpers separately if
966 * have a clearly defined need to use and refcount the device 975 * have a clearly defined need to use and refcount the device
967 * before it is added to the hierarchy. 976 * before it is added to the hierarchy.
977 *
978 * NOTE: _Never_ directly free @dev after calling this function, even
979 * if it returned an error! Always use put_device() to give up the
980 * reference initialized in this function instead.
968 */ 981 */
969int device_register(struct device *dev) 982int device_register(struct device *dev)
970{ 983{
@@ -1243,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
1243 return dev; 1256 return dev;
1244 1257
1245error: 1258error:
1246 kfree(dev); 1259 put_device(dev);
1247 return ERR_PTR(retval); 1260 return ERR_PTR(retval);
1248} 1261}
1249EXPORT_SYMBOL_GPL(device_create_vargs); 1262EXPORT_SYMBOL_GPL(device_create_vargs);
@@ -1314,6 +1327,11 @@ EXPORT_SYMBOL_GPL(device_destroy);
1314 * device_rename - renames a device 1327 * device_rename - renames a device
1315 * @dev: the pointer to the struct device to be renamed 1328 * @dev: the pointer to the struct device to be renamed
1316 * @new_name: the new name of the device 1329 * @new_name: the new name of the device
1330 *
1331 * It is the responsibility of the caller to provide mutual
1332 * exclusion between two different calls of device_rename
1333 * on the same device to ensure that new_name is valid and
1334 * won't conflict with other devices.
1317 */ 1335 */
1318int device_rename(struct device *dev, char *new_name) 1336int device_rename(struct device *dev, char *new_name)
1319{ 1337{
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 3ac443b2ac08..20febc00a525 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data)
257 * is an error. 257 * is an error.
258 */ 258 */
259 259
260 if (drv->bus->match && !drv->bus->match(dev, drv))
261 return 0;
262
260 if (dev->parent) /* Needed for USB */ 263 if (dev->parent) /* Needed for USB */
261 down(&dev->parent->sem); 264 down(&dev->parent->sem);
262 down(&dev->sem); 265 down(&dev->sem);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 66b710c28812..dfcbfe504867 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -394,6 +394,53 @@ error:
394} 394}
395EXPORT_SYMBOL_GPL(platform_device_register_simple); 395EXPORT_SYMBOL_GPL(platform_device_register_simple);
396 396
397/**
398 * platform_device_register_data
399 * @parent: parent device for the device we're adding
400 * @name: base name of the device we're adding
401 * @id: instance id
402 * @data: platform specific data for this platform device
403 * @size: size of platform specific data
404 *
405 * This function creates a simple platform device that requires minimal
406 * resource and memory management. Canned release function freeing memory
407 * allocated for the device allows drivers using such devices to be
408 * unloaded without waiting for the last reference to the device to be
409 * dropped.
410 */
411struct platform_device *platform_device_register_data(
412 struct device *parent,
413 const char *name, int id,
414 const void *data, size_t size)
415{
416 struct platform_device *pdev;
417 int retval;
418
419 pdev = platform_device_alloc(name, id);
420 if (!pdev) {
421 retval = -ENOMEM;
422 goto error;
423 }
424
425 pdev->dev.parent = parent;
426
427 if (size) {
428 retval = platform_device_add_data(pdev, data, size);
429 if (retval)
430 goto error;
431 }
432
433 retval = platform_device_add(pdev);
434 if (retval)
435 goto error;
436
437 return pdev;
438
439error:
440 platform_device_put(pdev);
441 return ERR_PTR(retval);
442}
443
397static int platform_drv_probe(struct device *_dev) 444static int platform_drv_probe(struct device *_dev)
398{ 445{
399 struct platform_driver *drv = to_platform_driver(_dev->driver); 446 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -865,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev)
865 912
866#endif /* !CONFIG_HIBERNATION */ 913#endif /* !CONFIG_HIBERNATION */
867 914
868struct pm_ext_ops platform_pm_ops = { 915static struct pm_ext_ops platform_pm_ops = {
869 .base = { 916 .base = {
870 .prepare = platform_pm_prepare, 917 .prepare = platform_pm_prepare,
871 .complete = platform_pm_complete, 918 .complete = platform_pm_complete,
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 03bde7524bc3..692c20ba5144 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -83,7 +83,7 @@ void device_pm_add(struct device *dev)
83 * transition is in progress in order to avoid leaving them 83 * transition is in progress in order to avoid leaving them
84 * unhandled down the road 84 * unhandled down the road
85 */ 85 */
86 WARN_ON(true); 86 dev_WARN(dev, "Parentless device registered during a PM transaction\n");
87 } 87 }
88 88
89 list_add_tail(&dev->power.entry, &dpm_list); 89 list_add_tail(&dev->power.entry, &dpm_list);
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1f56d2c5b7fc..200efc4d2c1e 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -284,9 +284,9 @@ aoechr_init(void)
284 return PTR_ERR(aoe_class); 284 return PTR_ERR(aoe_class);
285 } 285 }
286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
287 device_create_drvdata(aoe_class, NULL, 287 device_create(aoe_class, NULL,
288 MKDEV(AOE_MAJOR, chardevs[i].minor), 288 MKDEV(AOE_MAJOR, chardevs[i].minor), NULL,
289 NULL, chardevs[i].name); 289 chardevs[i].name);
290 290
291 return 0; 291 return 0;
292} 292}
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index d731ca42f802..9dfa27163001 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -686,9 +686,8 @@ static int __init pg_init(void)
686 for (unit = 0; unit < PG_UNITS; unit++) { 686 for (unit = 0; unit < PG_UNITS; unit++) {
687 struct pg *dev = &devices[unit]; 687 struct pg *dev = &devices[unit];
688 if (dev->present) 688 if (dev->present)
689 device_create_drvdata(pg_class, NULL, 689 device_create(pg_class, NULL, MKDEV(major, unit), NULL,
690 MKDEV(major, unit), NULL, 690 "pg%u", unit);
691 "pg%u", unit);
692 } 691 }
693 err = 0; 692 err = 0;
694 goto out; 693 goto out;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 673b8b2fd337..5ae229656eaa 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -979,12 +979,10 @@ static int __init pt_init(void)
979 979
980 for (unit = 0; unit < PT_UNITS; unit++) 980 for (unit = 0; unit < PT_UNITS; unit++)
981 if (pt[unit].present) { 981 if (pt[unit].present) {
982 device_create_drvdata(pt_class, NULL, 982 device_create(pt_class, NULL, MKDEV(major, unit), NULL,
983 MKDEV(major, unit), NULL, 983 "pt%d", unit);
984 "pt%d", unit); 984 device_create(pt_class, NULL, MKDEV(major, unit + 128),
985 device_create_drvdata(pt_class, NULL, 985 NULL, "pt%dn", unit);
986 MKDEV(major, unit + 128), NULL,
987 "pt%dn", unit);
988 } 986 }
989 goto out; 987 goto out;
990 988
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 0e077150568b..195ca7c720f5 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -302,9 +302,8 @@ static struct kobj_type kobj_pkt_type_wqueue = {
302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 302static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
303{ 303{
304 if (class_pktcdvd) { 304 if (class_pktcdvd) {
305 pd->dev = device_create_drvdata(class_pktcdvd, NULL, 305 pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL,
306 pd->pkt_dev, NULL, 306 "%s", pd->name);
307 "%s", pd->name);
308 if (IS_ERR(pd->dev)) 307 if (IS_ERR(pd->dev))
309 pd->dev = NULL; 308 pd->dev = NULL;
310 } 309 }
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index b650b4e48e50..456f54db73e2 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -229,9 +229,8 @@ static int bsr_create_devs(struct device_node *bn)
229 if (result) 229 if (result)
230 goto out_err; 230 goto out_err;
231 231
232 cur->bsr_device = device_create_drvdata(bsr_class, NULL, 232 cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev,
233 cur->bsr_dev, 233 cur, cur->bsr_name);
234 cur, cur->bsr_name);
235 if (!cur->bsr_device) { 234 if (!cur->bsr_device) {
236 printk(KERN_ERR "device_create failed for %s\n", 235 printk(KERN_ERR "device_create failed for %s\n",
237 cur->bsr_name); 236 cur->bsr_name);
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index ca7c72a486b2..85832ab924e6 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -508,8 +508,8 @@ static int __init dsp56k_init_driver(void)
508 err = PTR_ERR(dsp56k_class); 508 err = PTR_ERR(dsp56k_class);
509 goto out_chrdev; 509 goto out_chrdev;
510 } 510 }
511 device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), 511 device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL,
512 NULL, "dsp56k"); 512 "dsp56k");
513 513
514 printk(banner); 514 printk(banner);
515 goto out; 515 goto out;
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 6774572d3759..70e0ebc30bd0 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -745,12 +745,12 @@ static int __init ip2_loadmain(void)
745 745
746 pB = i2BoardPtrTable[i]; 746 pB = i2BoardPtrTable[i];
747 if (pB != NULL) { 747 if (pB != NULL) {
748 device_create_drvdata(ip2_class, NULL, 748 device_create(ip2_class, NULL,
749 MKDEV(IP2_IPL_MAJOR, 4 * i), 749 MKDEV(IP2_IPL_MAJOR, 4 * i),
750 NULL, "ipl%d", i); 750 NULL, "ipl%d", i);
751 device_create_drvdata(ip2_class, NULL, 751 device_create(ip2_class, NULL,
752 MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 752 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
753 NULL, "stat%d", i); 753 NULL, "stat%d", i);
754 754
755 for (box = 0; box < ABS_MAX_BOXES; box++) 755 for (box = 0; box < ABS_MAX_BOXES; box++)
756 for (j = 0; j < ABS_BIGGEST_BOX; j++) 756 for (j = 0; j < ABS_BIGGEST_BOX; j++)
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 64e1c169e826..835a33c8d5f5 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
871 entry->dev = dev; 871 entry->dev = dev;
872 872
873 mutex_lock(&reg_list_mutex); 873 mutex_lock(&reg_list_mutex);
874 device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num); 874 device_create(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
875 list_add(&entry->link, &reg_list); 875 list_add(&entry->link, &reg_list);
876 mutex_unlock(&reg_list_mutex); 876 mutex_unlock(&reg_list_mutex);
877} 877}
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 505d7a1f6b8c..44e5d60f517e 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -4600,9 +4600,8 @@ static int __init istallion_module_init(void)
4600 4600
4601 istallion_class = class_create(THIS_MODULE, "staliomem"); 4601 istallion_class = class_create(THIS_MODULE, "staliomem");
4602 for (i = 0; i < 4; i++) 4602 for (i = 0; i < 4; i++)
4603 device_create_drvdata(istallion_class, NULL, 4603 device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4604 MKDEV(STL_SIOMEMMAJOR, i), 4604 NULL, "staliomem%d", i);
4605 NULL, "staliomem%d", i);
4606 4605
4607 return 0; 4606 return 0;
4608err_deinit: 4607err_deinit:
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 3f2719b9f77b..e444c2dba160 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -813,8 +813,8 @@ static int lp_register(int nr, struct parport *port)
813 if (reset) 813 if (reset)
814 lp_reset(nr); 814 lp_reset(nr);
815 815
816 device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, 816 device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817 "lp%d", nr); 817 "lp%d", nr);
818 818
819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); 820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 672b08e694d0..6431f6921a67 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -992,9 +992,9 @@ static int __init chr_dev_init(void)
992 992
993 mem_class = class_create(THIS_MODULE, "mem"); 993 mem_class = class_create(THIS_MODULE, "mem");
994 for (i = 0; i < ARRAY_SIZE(devlist); i++) 994 for (i = 0; i < ARRAY_SIZE(devlist); i++)
995 device_create_drvdata(mem_class, NULL, 995 device_create(mem_class, NULL,
996 MKDEV(MEM_MAJOR, devlist[i].minor), 996 MKDEV(MEM_MAJOR, devlist[i].minor), NULL,
997 NULL, devlist[i].name); 997 devlist[i].name);
998 998
999 return 0; 999 return 0;
1000} 1000}
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 999aa779c08a..a5e0db9d7662 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
218 dev = MKDEV(MISC_MAJOR, misc->minor); 218 dev = MKDEV(MISC_MAJOR, misc->minor);
219 219
220 misc->this_device = device_create_drvdata(misc_class, misc->parent, 220 misc->this_device = device_create(misc_class, misc->parent, dev, NULL,
221 dev, NULL, "%s", misc->name); 221 "%s", misc->name);
222 if (IS_ERR(misc->this_device)) { 222 if (IS_ERR(misc->this_device)) {
223 err = PTR_ERR(misc->this_device); 223 err = PTR_ERR(misc->this_device);
224 goto out; 224 goto out;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 1c5bf99895ed..dbb912574569 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1871,7 +1871,7 @@ static int cm4000_probe(struct pcmcia_device *link)
1871 return ret; 1871 return ret;
1872 } 1872 }
1873 1873
1874 device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i); 1874 device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
1875 1875
1876 return 0; 1876 return 0;
1877} 1877}
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 2d7c906435b7..4f0723b07974 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -637,8 +637,7 @@ static int reader_probe(struct pcmcia_device *link)
637 return ret; 637 return ret;
638 } 638 }
639 639
640 device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL, 640 device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i);
641 "cmx%d", i);
642 641
643 return 0; 642 return 0;
644} 643}
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index bee39fdfba73..c84c34fb1231 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -760,9 +760,8 @@ static const struct file_operations pp_fops = {
760 760
761static void pp_attach(struct parport *port) 761static void pp_attach(struct parport *port)
762{ 762{
763 device_create_drvdata(ppdev_class, port->dev, 763 device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
764 MKDEV(PP_MAJOR, port->number), 764 NULL, "parport%d", port->number);
765 NULL, "parport%d", port->number);
766} 765}
767 766
768static void pp_detach(struct parport *port) 767static void pp_detach(struct parport *port)
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 47b8cf281d4a..e139372d0e69 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
131static void bind_device(struct raw_config_request *rq) 131static void bind_device(struct raw_config_request *rq)
132{ 132{
133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
134 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 134 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL,
135 NULL, "raw%d", rq->raw_minor); 135 "raw%d", rq->raw_minor);
136} 136}
137 137
138/* 138/*
@@ -283,8 +283,7 @@ static int __init raw_init(void)
283 ret = PTR_ERR(raw_class); 283 ret = PTR_ERR(raw_class);
284 goto error_region; 284 goto error_region;
285 } 285 }
286 device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, 286 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
287 "rawctl");
288 287
289 return 0; 288 return 0;
290 289
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 3ce60df14c0a..32b74de18f5f 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -444,8 +444,8 @@ scdrv_init(void)
444 continue; 444 continue;
445 } 445 }
446 446
447 device_create_drvdata(snsc_class, NULL, dev, NULL, 447 device_create(snsc_class, NULL, dev, NULL,
448 "%s", devname); 448 "%s", devname);
449 449
450 ia64_sn_irtr_intr_enable(scd->scd_nasid, 450 ia64_sn_irtr_intr_enable(scd->scd_nasid,
451 0 /*ignored */ , 451 0 /*ignored */ ,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 8b8f07a7f505..963b03fb29e5 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4743,8 +4743,8 @@ static int __init stallion_module_init(void)
4743 if (IS_ERR(stallion_class)) 4743 if (IS_ERR(stallion_class))
4744 printk("STALLION: failed to create class\n"); 4744 printk("STALLION: failed to create class\n");
4745 for (i = 0; i < 4; i++) 4745 for (i = 0; i < 4; i++)
4746 device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4746 device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4747 NULL, "staliomem%d", i); 4747 NULL, "staliomem%d", i);
4748 4748
4749 return 0; 4749 return 0;
4750err_unrtty: 4750err_unrtty:
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 3f48d88cffc0..59f472143f08 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2850,7 +2850,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
2850 else 2850 else
2851 tty_line_name(driver, index, name); 2851 tty_line_name(driver, index, name);
2852 2852
2853 return device_create_drvdata(tty_class, device, dev, NULL, name); 2853 return device_create(tty_class, device, dev, NULL, name);
2854} 2854}
2855EXPORT_SYMBOL(tty_register_device); 2855EXPORT_SYMBOL(tty_register_device);
2856 2856
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index c2ae52dd53d1..4f3b3f95fc42 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -481,10 +481,10 @@ static struct class *vc_class;
481 481
482void vcs_make_sysfs(struct tty_struct *tty) 482void vcs_make_sysfs(struct tty_struct *tty)
483{ 483{
484 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 484 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL,
485 NULL, "vcs%u", tty->index + 1); 485 "vcs%u", tty->index + 1);
486 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 486 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL,
487 NULL, "vcsa%u", tty->index + 1); 487 "vcsa%u", tty->index + 1);
488} 488}
489 489
490void vcs_remove_sysfs(struct tty_struct *tty) 490void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void)
499 panic("unable to get major %d for vcs device", VCS_MAJOR); 499 panic("unable to get major %d for vcs device", VCS_MAJOR);
500 vc_class = class_create(THIS_MODULE, "vc"); 500 vc_class = class_create(THIS_MODULE, "vc");
501 501
502 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 502 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
503 device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 503 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
504 return 0; 504 return 0;
505} 505}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 7a70a40ad639..ffc9254f7e02 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
886 state[i].cur_part = 0; 886 state[i].cur_part = 0;
887 for (j = 0; j < MAX_PARTITIONS; ++j) 887 for (j = 0; j < MAX_PARTITIONS; ++j)
888 state[i].part_stat_rwi[j] = VIOT_IDLE; 888 state[i].part_stat_rwi[j] = VIOT_IDLE;
889 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), 889 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL,
890 NULL, "iseries!vt%d", i); 890 "iseries!vt%d", i);
891 device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 891 device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), NULL,
892 NULL, "iseries!nvt%d", i); 892 "iseries!nvt%d", i);
893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " 893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
894 "resource %10.10s type %4.4s, model %3.3s\n", 894 "resource %10.10s type %4.4s, model %3.3s\n",
895 i, viotape_unitinfo[i].rsrcname, 895 i, viotape_unitinfo[i].rsrcname,
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 278c9857bcf5..ed132fe55d3d 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -657,8 +657,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
657 goto failed3; 657 goto failed3;
658 } 658 }
659 659
660 device_create_drvdata(icap_class, dev, devt, NULL, 660 device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
661 "%s%d", DRIVER_NAME, id);
662 return 0; /* success */ 661 return 0; /* success */
663 662
664 failed3: 663 failed3:
diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 7af4b403bd2d..bb538b9690e0 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -15,9 +15,8 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
15 struct device *cd; 15 struct device *cd;
16 static int req_count; 16 static int req_count;
17 17
18 cd = device_create_drvdata(dca_class, dca->cd, 18 cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), NULL,
19 MKDEV(0, slot + 1), NULL, 19 "requester%d", req_count++);
20 "requester%d", req_count++);
21 if (IS_ERR(cd)) 20 if (IS_ERR(cd))
22 return PTR_ERR(cd); 21 return PTR_ERR(cd);
23 return 0; 22 return 0;
@@ -48,8 +47,7 @@ idr_try_again:
48 return err; 47 return err;
49 } 48 }
50 49
51 cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL, 50 cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
52 "dca%d", dca->id);
53 if (IS_ERR(cd)) { 51 if (IS_ERR(cd)) {
54 spin_lock(&dca_idr_lock); 52 spin_lock(&dca_idr_lock);
55 idr_remove(&dca_idr, dca->id); 53 idr_remove(&dca_idr, dca->id);
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index b91ef63126ed..deb154aa47c4 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -334,9 +334,9 @@ static void ibft_release(struct kobject *kobj)
334/* 334/*
335 * Routines for parsing the iBFT data to be human readable. 335 * Routines for parsing the iBFT data to be human readable.
336 */ 336 */
337ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 337static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
338 struct ibft_attribute *attr, 338 struct ibft_attribute *attr,
339 char *buf) 339 char *buf)
340{ 340{
341 struct ibft_initiator *initiator = entry->initiator; 341 struct ibft_initiator *initiator = entry->initiator;
342 void *ibft_loc = entry->header; 342 void *ibft_loc = entry->header;
@@ -376,9 +376,9 @@ ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
376 return str - buf; 376 return str - buf;
377} 377}
378 378
379ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, 379static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
380 struct ibft_attribute *attr, 380 struct ibft_attribute *attr,
381 char *buf) 381 char *buf)
382{ 382{
383 struct ibft_nic *nic = entry->nic; 383 struct ibft_nic *nic = entry->nic;
384 void *ibft_loc = entry->header; 384 void *ibft_loc = entry->header;
@@ -440,9 +440,9 @@ ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
440 return str - buf; 440 return str - buf;
441}; 441};
442 442
443ssize_t ibft_attr_show_target(struct ibft_kobject *entry, 443static ssize_t ibft_attr_show_target(struct ibft_kobject *entry,
444 struct ibft_attribute *attr, 444 struct ibft_attribute *attr,
445 char *buf) 445 char *buf)
446{ 446{
447 struct ibft_tgt *tgt = entry->tgt; 447 struct ibft_tgt *tgt = entry->tgt;
448 void *ibft_loc = entry->header; 448 void *ibft_loc = entry->header;
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 497e0d1dd3c3..af3edb98df43 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -326,9 +326,8 @@ int hidraw_connect(struct hid_device *hid)
326 goto out; 326 goto out;
327 } 327 }
328 328
329 dev->dev = device_create_drvdata(hidraw_class, NULL, 329 dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
330 MKDEV(hidraw_major, minor), NULL, 330 NULL, "%s%d", "hidraw", minor);
331 "%s%d", "hidraw", minor);
332 331
333 if (IS_ERR(dev->dev)) { 332 if (IS_ERR(dev->dev)) {
334 spin_lock(&minors_lock); 333 spin_lock(&minors_lock);
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 7321a88a5112..076a59cdabe9 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -55,8 +55,8 @@ again:
55 return ERR_PTR(err); 55 return ERR_PTR(err);
56 56
57 id = id & MAX_ID_MASK; 57 id = id & MAX_ID_MASK;
58 hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL, 58 hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
59 HWMON_ID_FORMAT, id); 59 HWMON_ID_FORMAT, id);
60 60
61 if (IS_ERR(hwdev)) { 61 if (IS_ERR(hwdev)) {
62 spin_lock(&idr_lock); 62 spin_lock(&idr_lock);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 307d976c9b69..c171988a9f51 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
521 return PTR_ERR(i2c_dev); 521 return PTR_ERR(i2c_dev);
522 522
523 /* register this i2c device with the driver core */ 523 /* register this i2c device with the driver core */
524 i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev, 524 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
525 MKDEV(I2C_MAJOR, adap->nr), 525 MKDEV(I2C_MAJOR, adap->nr), NULL,
526 NULL, "i2c-%d", adap->nr); 526 "i2c-%d", adap->nr);
527 if (IS_ERR(i2c_dev->dev)) { 527 if (IS_ERR(i2c_dev->dev)) {
528 res = PTR_ERR(i2c_dev->dev); 528 res = PTR_ERR(i2c_dev->dev);
529 goto error; 529 goto error;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index f27baa5f140e..19f8c7770a25 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -657,8 +657,8 @@ static int ide_register_port(ide_hwif_t *hwif)
657 goto out; 657 goto out;
658 } 658 }
659 659
660 hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, 660 hwif->portdev = device_create(ide_port_class, &hwif->gendev,
661 MKDEV(0, 0), hwif, hwif->name); 661 MKDEV(0, 0), hwif, hwif->name);
662 if (IS_ERR(hwif->portdev)) { 662 if (IS_ERR(hwif->portdev)) {
663 ret = PTR_ERR(hwif->portdev); 663 ret = PTR_ERR(hwif->portdev);
664 device_unregister(&hwif->gendev); 664 device_unregister(&hwif->gendev);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 25ac60f53273..d879c7797cde 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2420,12 +2420,11 @@ static int ide_tape_probe(ide_drive_t *drive)
2420 2420
2421 idetape_setup(drive, tape, minor); 2421 idetape_setup(drive, tape, minor);
2422 2422
2423 device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2423 device_create(idetape_sysfs_class, &drive->gendev,
2424 MKDEV(IDETAPE_MAJOR, minor), NULL, 2424 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name);
2425 "%s", tape->name); 2425 device_create(idetape_sysfs_class, &drive->gendev,
2426 device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2426 MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2427 MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2427 "n%s", tape->name);
2428 "n%s", tape->name);
2429 2428
2430 g->fops = &idetape_block_ops; 2429 g->fops = &idetape_block_ops;
2431 ide_register_region(g); 2430 ide_register_region(g);
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index b6eb2cf25914..9236c0d5a122 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2296,10 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host)
2296 2296
2297 ohci = (struct ti_ohci *)host->hostdata; 2297 ohci = (struct ti_ohci *)host->hostdata;
2298 2298
2299 device_create_drvdata(hpsb_protocol_class, NULL, 2299 device_create(hpsb_protocol_class, NULL,
2300 MKDEV(IEEE1394_MAJOR, 2300 MKDEV(IEEE1394_MAJOR,
2301 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL, 2301 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2302 "dv1394-%d", id); 2302 NULL, "dv1394-%d", id);
2303 2303
2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); 2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); 2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 6fa9e4a21840..c7833bb37ae1 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -3010,10 +3010,10 @@ static int __init init_raw1394(void)
3010 hpsb_register_highlevel(&raw1394_highlevel); 3010 hpsb_register_highlevel(&raw1394_highlevel);
3011 3011
3012 if (IS_ERR 3012 if (IS_ERR
3013 (device_create_drvdata( 3013 (device_create(hpsb_protocol_class, NULL,
3014 hpsb_protocol_class, NULL, 3014 MKDEV(IEEE1394_MAJOR,
3015 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3015 IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016 NULL, RAW1394_DEVICE_NAME))) { 3016 NULL, RAW1394_DEVICE_NAME))) {
3017 ret = -EFAULT; 3017 ret = -EFAULT;
3018 goto out_unreg; 3018 goto out_unreg;
3019 } 3019 }
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 25db6e67fa4e..6e73b06eed4f 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1341,9 +1341,8 @@ static void video1394_add_host (struct hpsb_host *host)
1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
1342 1342
1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1344 device_create_drvdata(hpsb_protocol_class, NULL, 1344 device_create(hpsb_protocol_class, NULL, MKDEV(IEEE1394_MAJOR, minor),
1345 MKDEV(IEEE1394_MAJOR, minor), NULL, 1345 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1346 "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1347} 1346}
1348 1347
1349 1348
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 3cab0cedfca2..a78d35aecee3 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3691,9 +3691,9 @@ static void cm_add_one(struct ib_device *ib_device)
3691 cm_dev->ib_device = ib_device; 3691 cm_dev->ib_device = ib_device;
3692 cm_get_ack_delay(cm_dev); 3692 cm_get_ack_delay(cm_dev);
3693 3693
3694 cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev, 3694 cm_dev->device = device_create(&cm_class, &ib_device->dev,
3695 MKDEV(0, 0), NULL, 3695 MKDEV(0, 0), NULL,
3696 "%s", ib_device->name); 3696 "%s", ib_device->name);
3697 if (!cm_dev->device) { 3697 if (!cm_dev->device) {
3698 kfree(cm_dev); 3698 kfree(cm_dev);
3699 return; 3699 return;
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 268a2d23b7c9..8c46f2257098 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1016,9 +1016,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) 1016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
1017 goto err_cdev; 1017 goto err_cdev;
1018 1018
1019 port->dev = device_create_drvdata(umad_class, device->dma_device, 1019 port->dev = device_create(umad_class, device->dma_device,
1020 port->cdev->dev, port, 1020 port->cdev->dev, port,
1021 "umad%d", port->dev_num); 1021 "umad%d", port->dev_num);
1022 if (IS_ERR(port->dev)) 1022 if (IS_ERR(port->dev))
1023 goto err_cdev; 1023 goto err_cdev;
1024 1024
@@ -1036,9 +1036,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
1037 goto err_sm_cdev; 1037 goto err_sm_cdev;
1038 1038
1039 port->sm_dev = device_create_drvdata(umad_class, device->dma_device, 1039 port->sm_dev = device_create(umad_class, device->dma_device,
1040 port->sm_cdev->dev, port, 1040 port->sm_cdev->dev, port,
1041 "issm%d", port->dev_num); 1041 "issm%d", port->dev_num);
1042 if (IS_ERR(port->sm_dev)) 1042 if (IS_ERR(port->sm_dev))
1043 goto err_sm_cdev; 1043 goto err_sm_cdev;
1044 1044
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index aeee856c4060..d85af1b67027 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -764,12 +764,9 @@ static void ib_uverbs_add_one(struct ib_device *device)
764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
765 goto err_cdev; 765 goto err_cdev;
766 766
767 uverbs_dev->dev = device_create_drvdata(uverbs_class, 767 uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
768 device->dma_device, 768 uverbs_dev->cdev->dev, uverbs_dev,
769 uverbs_dev->cdev->dev, 769 "uverbs%d", uverbs_dev->devnum);
770 uverbs_dev,
771 "uverbs%d",
772 uverbs_dev->devnum);
773 if (IS_ERR(uverbs_dev->dev)) 770 if (IS_ERR(uverbs_dev->dev))
774 goto err_cdev; 771 goto err_cdev;
775 772
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 56c0eda3c077..1af1f3a907c6 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
2455 goto err_cdev; 2455 goto err_cdev;
2456 } 2456 }
2457 2457
2458 device = device_create_drvdata(ipath_class, NULL, dev, NULL, name); 2458 device = device_create(ipath_class, NULL, dev, NULL, name);
2459 2459
2460 if (IS_ERR(device)) { 2460 if (IS_ERR(device)) {
2461 ret = PTR_ERR(device); 2461 ret = PTR_ERR(device);
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 798d7f3e42ef..1b5bf87c4cf4 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1553,8 +1553,7 @@ static int __init capi_init(void)
1553 return PTR_ERR(capi_class); 1553 return PTR_ERR(capi_class);
1554 } 1554 }
1555 1555
1556 device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL, 1556 device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
1557 "capi");
1558 1557
1559#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1558#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1560 if (capinc_tty_init() < 0) { 1559 if (capinc_tty_init() < 0) {
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 559a40861c39..ee74ee7b2acc 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -103,8 +103,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
103{ 103{
104 int rc; 104 int rc;
105 105
106 led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev, 106 led_cdev->dev = device_create(leds_class, parent, 0, led_cdev,
107 "%s", led_cdev->name); 107 "%s", led_cdev->name);
108 if (IS_ERR(led_cdev->dev)) 108 if (IS_ERR(led_cdev->dev))
109 return PTR_ERR(led_cdev->dev); 109 return PTR_ERR(led_cdev->dev);
110 110
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index cae52485208a..23741cec45e3 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -862,8 +862,7 @@ adbdev_init(void)
862 adb_dev_class = class_create(THIS_MODULE, "adb"); 862 adb_dev_class = class_create(THIS_MODULE, "adb");
863 if (IS_ERR(adb_dev_class)) 863 if (IS_ERR(adb_dev_class))
864 return; 864 return;
865 device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, 865 device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
866 "adb");
867 866
868 platform_device_register(&adb_pfdev); 867 platform_device_register(&adb_pfdev);
869 platform_driver_probe(&adb_pfdrv, adb_dummy_probe); 868 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index e7132770a3bf..665776d72a48 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -233,7 +233,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
233 233
234 mutex_unlock(&dvbdev_register_lock); 234 mutex_unlock(&dvbdev_register_lock);
235 235
236 clsdev = device_create_drvdata(dvb_class, adap->device, 236 clsdev = device_create(dvb_class, adap->device,
237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id); 238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
239 if (IS_ERR(clsdev)) { 239 if (IS_ERR(clsdev)) {
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index daf585689ce3..abdebe347383 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -399,9 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev,
399 goto err_irq; 399 goto err_irq;
400 } 400 }
401 401
402 if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev, 402 if (IS_ERR(device_create(phantom_class, &pdev->dev,
403 MKDEV(phantom_major, minor), 403 MKDEV(phantom_major, minor), NULL,
404 NULL, "phantom%u", minor))) 404 "phantom%u", minor)))
405 dev_err(&pdev->dev, "can't create device\n"); 405 dev_err(&pdev->dev, "can't create device\n");
406 406
407 pci_set_drvdata(pdev, pht); 407 pci_set_drvdata(pdev, pht);
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index e00d424e6575..1c74762dec89 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -26,13 +26,11 @@ static void mtd_notify_add(struct mtd_info* mtd)
26 if (!mtd) 26 if (!mtd)
27 return; 27 return;
28 28
29 device_create_drvdata(mtd_class, NULL, 29 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
30 MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 30 NULL, "mtd%d", mtd->index);
31 NULL, "mtd%d", mtd->index);
32 31
33 device_create_drvdata(mtd_class, NULL, 32 device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
34 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 33 NULL, "mtd%dro", mtd->index);
35 NULL, "mtd%dro", mtd->index);
36} 34}
37 35
38static void mtd_notify_remove(struct mtd_info* mtd) 36static void mtd_notify_remove(struct mtd_info* mtd)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f11e900b437b..e11b03b2b25a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -309,11 +309,6 @@ void phy_disconnect(struct phy_device *phydev)
309} 309}
310EXPORT_SYMBOL(phy_disconnect); 310EXPORT_SYMBOL(phy_disconnect);
311 311
312static int phy_compare_id(struct device *dev, void *data)
313{
314 return strcmp((char *)data, dev->bus_id) ? 0 : 1;
315}
316
317/** 312/**
318 * phy_attach - attach a network device to a particular PHY device 313 * phy_attach - attach a network device to a particular PHY device
319 * @dev: network device to attach 314 * @dev: network device to attach
@@ -337,8 +332,7 @@ struct phy_device *phy_attach(struct net_device *dev,
337 332
338 /* Search the list of PHY devices on the mdio bus for the 333 /* Search the list of PHY devices on the mdio bus for the
339 * PHY with the requested name */ 334 * PHY with the requested name */
340 d = bus_find_device(bus, NULL, (void *)bus_id, phy_compare_id); 335 d = bus_find_device_by_name(bus, NULL, bus_id);
341
342 if (d) { 336 if (d) {
343 phydev = to_phy_device(d); 337 phydev = to_phy_device(d);
344 } else { 338 } else {
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 94818ee3cef5..7e857e938adb 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -866,8 +866,8 @@ static int __init ppp_init(void)
866 err = PTR_ERR(ppp_class); 866 err = PTR_ERR(ppp_class);
867 goto out_chrdev; 867 goto out_chrdev;
868 } 868 }
869 device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), 869 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL,
870 NULL, "ppp"); 870 "ppp");
871 } 871 }
872 872
873out: 873out:
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index f14051556c87..7f97f8d08c39 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -388,8 +388,8 @@ static int __init cosa_init(void)
388 goto out_chrdev; 388 goto out_chrdev;
389 } 389 }
390 for (i = 0; i < nr_cards; i++) 390 for (i = 0; i < nr_cards; i++)
391 device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i), 391 device_create(cosa_class, NULL, MKDEV(cosa_major, i), NULL,
392 NULL, "cosa%d", i); 392 "cosa%d", i);
393 err = 0; 393 err = 0;
394 goto out; 394 goto out;
395 395
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index c9e4a435b2fc..1a019e98dac3 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -533,11 +533,11 @@ static int __init init_mac80211_hwsim(void)
533 data = hw->priv; 533 data = hw->priv;
534 data->hw = hw; 534 data->hw = hw;
535 535
536 data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw, 536 data->dev = device_create(hwsim_class, NULL, 0, hw,
537 "hwsim%d", i); 537 "hwsim%d", i);
538 if (IS_ERR(data->dev)) { 538 if (IS_ERR(data->dev)) {
539 printk(KERN_DEBUG 539 printk(KERN_DEBUG
540 "mac80211_hwsim: device_create_drvdata " 540 "mac80211_hwsim: device_create "
541 "failed (%ld)\n", PTR_ERR(data->dev)); 541 "failed (%ld)\n", PTR_ERR(data->dev));
542 err = -ENOMEM; 542 err = -ENOMEM;
543 goto failed_drvdata; 543 goto failed_drvdata;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 36698e57b97f..dd9161a054e1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1237,8 +1237,11 @@ EXPORT_SYMBOL(pci_scan_bridge);
1237EXPORT_SYMBOL_GPL(pci_scan_child_bus); 1237EXPORT_SYMBOL_GPL(pci_scan_child_bus);
1238#endif 1238#endif
1239 1239
1240static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b) 1240static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
1241{ 1241{
1242 const struct pci_dev *a = to_pci_dev(d_a);
1243 const struct pci_dev *b = to_pci_dev(d_b);
1244
1242 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1; 1245 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
1243 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1; 1246 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1;
1244 1247
@@ -1251,50 +1254,7 @@ static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev
1251 return 0; 1254 return 0;
1252} 1255}
1253 1256
1254/*
1255 * Yes, this forcably breaks the klist abstraction temporarily. It
1256 * just wants to sort the klist, not change reference counts and
1257 * take/drop locks rapidly in the process. It does all this while
1258 * holding the lock for the list, so objects can't otherwise be
1259 * added/removed while we're swizzling.
1260 */
1261static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list)
1262{
1263 struct list_head *pos;
1264 struct klist_node *n;
1265 struct device *dev;
1266 struct pci_dev *b;
1267
1268 list_for_each(pos, list) {
1269 n = container_of(pos, struct klist_node, n_node);
1270 dev = container_of(n, struct device, knode_bus);
1271 b = to_pci_dev(dev);
1272 if (pci_sort_bf_cmp(a, b) <= 0) {
1273 list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node);
1274 return;
1275 }
1276 }
1277 list_move_tail(&a->dev.knode_bus.n_node, list);
1278}
1279
1280void __init pci_sort_breadthfirst(void) 1257void __init pci_sort_breadthfirst(void)
1281{ 1258{
1282 LIST_HEAD(sorted_devices); 1259 bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp);
1283 struct list_head *pos, *tmp;
1284 struct klist_node *n;
1285 struct device *dev;
1286 struct pci_dev *pdev;
1287 struct klist *device_klist;
1288
1289 device_klist = bus_get_device_klist(&pci_bus_type);
1290
1291 spin_lock(&device_klist->k_lock);
1292 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1293 n = container_of(pos, struct klist_node, n_node);
1294 dev = container_of(n, struct device, knode_bus);
1295 pdev = to_pci_dev(dev);
1296 pci_insertion_sort_klist(pdev, &sorted_devices);
1297 }
1298 list_splice(&sorted_devices, &device_klist->k_list);
1299 spin_unlock(&device_klist->k_lock);
1300} 1260}
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 7cc7bf5304aa..3b8b9d3cb03d 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6extern spinlock_t pnp_lock; 6extern spinlock_t pnp_lock;
7extern struct device_attribute pnp_interface_attrs[];
7void *pnp_alloc(long size); 8void *pnp_alloc(long size);
8 9
9int pnp_register_protocol(struct pnp_protocol *protocol); 10int pnp_register_protocol(struct pnp_protocol *protocol);
@@ -16,7 +17,6 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
16 17
17int pnp_add_device(struct pnp_dev *dev); 18int pnp_add_device(struct pnp_dev *dev);
18struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 19struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
19int pnp_interface_attach_device(struct pnp_dev *dev);
20 20
21int pnp_add_card(struct pnp_card *card); 21int pnp_add_card(struct pnp_card *card);
22void pnp_remove_card(struct pnp_card *card); 22void pnp_remove_card(struct pnp_card *card);
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index cc0aeaed6179..817fe626e15b 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
159 159
160int __pnp_add_device(struct pnp_dev *dev) 160int __pnp_add_device(struct pnp_dev *dev)
161{ 161{
162 int ret;
163
164 pnp_fixup_device(dev); 162 pnp_fixup_device(dev);
165 dev->status = PNP_READY; 163 dev->status = PNP_READY;
166 spin_lock(&pnp_lock); 164 spin_lock(&pnp_lock);
167 list_add_tail(&dev->global_list, &pnp_global); 165 list_add_tail(&dev->global_list, &pnp_global);
168 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 166 list_add_tail(&dev->protocol_list, &dev->protocol->devices);
169 spin_unlock(&pnp_lock); 167 spin_unlock(&pnp_lock);
170 168 return device_register(&dev->dev);
171 ret = device_register(&dev->dev);
172 if (ret)
173 return ret;
174
175 pnp_interface_attach_device(dev);
176 return 0;
177} 169}
178 170
179/* 171/*
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index d3f869ee1d92..e3f7e89c4dfb 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = {
206 .remove = pnp_device_remove, 206 .remove = pnp_device_remove,
207 .suspend = pnp_bus_suspend, 207 .suspend = pnp_bus_suspend,
208 .resume = pnp_bus_resume, 208 .resume = pnp_bus_resume,
209 .dev_attrs = pnp_interface_attrs,
209}; 210};
210 211
211int pnp_register_driver(struct pnp_driver *drv) 212int pnp_register_driver(struct pnp_driver *drv)
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index a876ecf7028c..478a4a739c00 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev,
243 return ret; 243 return ret;
244} 244}
245 245
246static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
247
248static ssize_t pnp_show_current_resources(struct device *dmdev, 246static ssize_t pnp_show_current_resources(struct device *dmdev,
249 struct device_attribute *attr, 247 struct device_attribute *attr,
250 char *buf) 248 char *buf)
@@ -420,9 +418,6 @@ done:
420 return count; 418 return count;
421} 419}
422 420
423static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
424 pnp_show_current_resources, pnp_set_current_resources);
425
426static ssize_t pnp_show_current_ids(struct device *dmdev, 421static ssize_t pnp_show_current_ids(struct device *dmdev,
427 struct device_attribute *attr, char *buf) 422 struct device_attribute *attr, char *buf)
428{ 423{
@@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev,
437 return (str - buf); 432 return (str - buf);
438} 433}
439 434
440static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); 435struct device_attribute pnp_interface_attrs[] = {
441 436 __ATTR(resources, S_IRUGO | S_IWUSR,
442int pnp_interface_attach_device(struct pnp_dev *dev) 437 pnp_show_current_resources,
443{ 438 pnp_set_current_resources),
444 int rc = device_create_file(&dev->dev, &dev_attr_options); 439 __ATTR(options, S_IRUGO, pnp_show_options, NULL),
445 440 __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
446 if (rc) 441 __ATTR_NULL,
447 goto err; 442};
448 rc = device_create_file(&dev->dev, &dev_attr_resources);
449 if (rc)
450 goto err_opt;
451 rc = device_create_file(&dev->dev, &dev_attr_id);
452 if (rc)
453 goto err_res;
454
455 return 0;
456
457err_res:
458 device_remove_file(&dev->dev, &dev_attr_resources);
459err_opt:
460 device_remove_file(&dev->dev, &dev_attr_options);
461err:
462 return rc;
463}
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index cb1ccb472921..3007695f90c8 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -91,8 +91,8 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
91{ 91{
92 int rc = 0; 92 int rc = 0;
93 93
94 psy->dev = device_create_drvdata(power_supply_class, parent, 0, 94 psy->dev = device_create(power_supply_class, parent, 0, psy,
95 psy, "%s", psy->name); 95 "%s", psy->name);
96 if (IS_ERR(psy->dev)) { 96 if (IS_ERR(psy->dev)) {
97 rc = PTR_ERR(psy->dev); 97 rc = PTR_ERR(psy->dev);
98 goto dev_create_failed; 98 goto dev_create_failed;
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 1792b2c0130e..0b15cf107ec9 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1168,19 +1168,17 @@ static int raw3270_create_attributes(struct raw3270 *rp)
1168 if (rc) 1168 if (rc)
1169 goto out; 1169 goto out;
1170 1170
1171 rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev, 1171 rp->clttydev = device_create(class3270, &rp->cdev->dev,
1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor), 1172 MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL,
1173 NULL, 1173 "tty%s", dev_name(&rp->cdev->dev));
1174 "tty%s", dev_name(&rp->cdev->dev));
1175 if (IS_ERR(rp->clttydev)) { 1174 if (IS_ERR(rp->clttydev)) {
1176 rc = PTR_ERR(rp->clttydev); 1175 rc = PTR_ERR(rp->clttydev);
1177 goto out_ttydev; 1176 goto out_ttydev;
1178 } 1177 }
1179 1178
1180 rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev, 1179 rp->cltubdev = device_create(class3270, &rp->cdev->dev,
1181 MKDEV(IBM_FS3270_MAJOR, rp->minor), 1180 MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL,
1182 NULL, 1181 "tub%s", dev_name(&rp->cdev->dev));
1183 "tub%s", dev_name(&rp->cdev->dev));
1184 if (!IS_ERR(rp->cltubdev)) 1182 if (!IS_ERR(rp->cltubdev))
1185 goto out; 1183 goto out;
1186 1184
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index 12c2a5aaf31b..ddc914ccea8f 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -69,9 +69,9 @@ struct tape_class_device *register_tape_dev(
69 if (rc) 69 if (rc)
70 goto fail_with_cdev; 70 goto fail_with_cdev;
71 71
72 tcd->class_device = device_create_drvdata(tape_class, device, 72 tcd->class_device = device_create(tape_class, device,
73 tcd->char_device->dev, 73 tcd->char_device->dev, NULL,
74 NULL, "%s", tcd->device_name); 74 "%s", tcd->device_name);
75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0; 75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
76 if (rc) 76 if (rc)
77 goto fail_with_cdev; 77 goto fail_with_cdev;
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 42173cc34610..24762727bc27 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -747,10 +747,10 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
747 device_unregister(dev); 747 device_unregister(dev);
748 return ret; 748 return ret;
749 } 749 }
750 priv->class_device = device_create_drvdata(vmlogrdr_class, dev, 750 priv->class_device = device_create(vmlogrdr_class, dev,
751 MKDEV(vmlogrdr_major, 751 MKDEV(vmlogrdr_major,
752 priv->minor_num), 752 priv->minor_num),
753 priv, "%s", dev_name(dev)); 753 priv, "%s", dev_name(dev));
754 if (IS_ERR(priv->class_device)) { 754 if (IS_ERR(priv->class_device)) {
755 ret = PTR_ERR(priv->class_device); 755 ret = PTR_ERR(priv->class_device);
756 priv->class_device=NULL; 756 priv->class_device=NULL;
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 6fdfa5ddeca8..9020eba620ee 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -896,9 +896,8 @@ static int ur_set_online(struct ccw_device *cdev)
896 goto fail_free_cdev; 896 goto fail_free_cdev;
897 } 897 }
898 898
899 urd->device = device_create_drvdata(vmur_class, NULL, 899 urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
900 urd->char_device->dev, NULL, 900 NULL, "%s", node_id);
901 "%s", node_id);
902 if (IS_ERR(urd->device)) { 901 if (IS_ERR(urd->device)) {
903 rc = PTR_ERR(urd->device); 902 rc = PTR_ERR(urd->device);
904 TRACE("ur_set_online: device_create rc=%d\n", rc); 903 TRACE("ur_set_online: device_create rc=%d\n", rc);
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 3c257fe0893e..88ecf94ad979 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -914,9 +914,9 @@ static int ch_probe(struct device *dev)
914 ch->minor = minor; 914 ch->minor = minor;
915 sprintf(ch->name,"ch%d",ch->minor); 915 sprintf(ch->name,"ch%d",ch->minor);
916 916
917 class_dev = device_create_drvdata(ch_sysfs_class, dev, 917 class_dev = device_create(ch_sysfs_class, dev,
918 MKDEV(SCSI_CHANGER_MAJOR, ch->minor), 918 MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch,
919 ch, "s%s", ch->name); 919 "s%s", ch->name);
920 if (IS_ERR(class_dev)) { 920 if (IS_ERR(class_dev)) {
921 printk(KERN_WARNING "ch%d: device_create failed\n", 921 printk(KERN_WARNING "ch%d: device_create failed\n",
922 ch->minor); 922 ch->minor);
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 1fe0901e8119..8aba4fdfb522 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -271,7 +271,7 @@ rebuild_sys_tab:
271 pHba->initialized = TRUE; 271 pHba->initialized = TRUE;
272 pHba->state &= ~DPTI_STATE_RESET; 272 pHba->state &= ~DPTI_STATE_RESET;
273 if (adpt_sysfs_class) { 273 if (adpt_sysfs_class) {
274 struct device *dev = device_create_drvdata(adpt_sysfs_class, 274 struct device *dev = device_create(adpt_sysfs_class,
275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL, 275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
276 "dpti%d", pHba->unit); 276 "dpti%d", pHba->unit);
277 if (IS_ERR(dev)) { 277 if (IS_ERR(dev)) {
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 1c79f9794f4e..0ea78d9a37db 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5708,7 +5708,8 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S
5708 struct device *osst_member; 5708 struct device *osst_member;
5709 int err; 5709 int err;
5710 5710
5711 osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name); 5711 osst_member = device_create(osst_sysfs_class, device, dev, STp,
5712 "%s", name);
5712 if (IS_ERR(osst_member)) { 5713 if (IS_ERR(osst_member)) {
5713 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5714 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5714 return PTR_ERR(osst_member); 5715 return PTR_ERR(osst_member);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ba9b9bbd4e73..93bd59a1ed79 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1450,12 +1450,10 @@ sg_add(struct device *cl_dev, struct class_interface *cl_intf)
1450 if (sg_sysfs_valid) { 1450 if (sg_sysfs_valid) {
1451 struct device *sg_class_member; 1451 struct device *sg_class_member;
1452 1452
1453 sg_class_member = device_create_drvdata(sg_sysfs_class, 1453 sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
1454 cl_dev->parent, 1454 MKDEV(SCSI_GENERIC_MAJOR,
1455 MKDEV(SCSI_GENERIC_MAJOR, 1455 sdp->index),
1456 sdp->index), 1456 sdp, "%s", disk->disk_name);
1457 sdp,
1458 "%s", disk->disk_name);
1459 if (IS_ERR(sg_class_member)) { 1457 if (IS_ERR(sg_class_member)) {
1460 printk(KERN_ERR "sg_add: " 1458 printk(KERN_ERR "sg_add: "
1461 "device_create failed\n"); 1459 "device_create failed\n");
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c2bb53e3d941..5c28d08f18f4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4428,13 +4428,10 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4428 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4428 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4429 STp->disk->disk_name, st_formats[i]); 4429 STp->disk->disk_name, st_formats[i]);
4430 st_class_member = 4430 st_class_member =
4431 device_create_drvdata(st_sysfs_class, 4431 device_create(st_sysfs_class, &STp->device->sdev_gendev,
4432 &STp->device->sdev_gendev, 4432 MKDEV(SCSI_TAPE_MAJOR,
4433 MKDEV(SCSI_TAPE_MAJOR, 4433 TAPE_MINOR(dev_num, mode, rew)),
4434 TAPE_MINOR(dev_num, 4434 &STp->modes[mode], "%s", name);
4435 mode, rew)),
4436 &STp->modes[mode],
4437 "%s", name);
4438 if (IS_ERR(st_class_member)) { 4435 if (IS_ERR(st_class_member)) {
4439 printk(KERN_WARNING "st%d: device_create failed\n", 4436 printk(KERN_WARNING "st%d: device_create failed\n",
4440 dev_num); 4437 dev_num);
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e5e0cfed5e3b..89a43755a453 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -583,10 +583,9 @@ static int spidev_probe(struct spi_device *spi)
583 struct device *dev; 583 struct device *dev;
584 584
585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor); 585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
586 dev = device_create_drvdata(spidev_class, &spi->dev, 586 dev = device_create(spidev_class, &spi->dev, spidev->devt,
587 spidev->devt, spidev, 587 spidev, "spidev%d.%d",
588 "spidev%d.%d", 588 spi->master->bus_num, spi->chip_select);
589 spi->master->bus_num, spi->chip_select);
590 status = IS_ERR(dev) ? PTR_ERR(dev) : 0; 589 status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
591 } else { 590 } else {
592 dev_dbg(&spi->dev, "no minor number available!\n"); 591 dev_dbg(&spi->dev, "no minor number available!\n");
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 4190be64917f..04b954cfce76 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -58,4 +58,17 @@ config UIO_SMX
58 58
59 If you compile this as a module, it will be called uio_smx. 59 If you compile this as a module, it will be called uio_smx.
60 60
61config UIO_SERCOS3
62 tristate "Automata Sercos III PCI card driver"
63 default n
64 help
65 Userspace I/O interface for the Sercos III PCI card from
66 Automata GmbH. The userspace part of this driver will be
67 available for download from the Automata GmbH web site.
68
69 Automata GmbH: http://www.automataweb.com
70 Sercos III interface: http://www.sercos.com
71
72 If you compile this as a module, it will be called uio_sercos3.
73
61endif 74endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8667bbdef904..e69558149859 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o
3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 3obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 4obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o
5obj-$(CONFIG_UIO_SMX) += uio_smx.o 5obj-$(CONFIG_UIO_SMX) += uio_smx.o
6obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 3a6934bf7131..5dccf057a7dd 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf)
67 return sprintf(buf, "0x%lx\n", mem->size); 67 return sprintf(buf, "0x%lx\n", mem->size);
68} 68}
69 69
70static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
71{
72 return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK);
73}
74
70struct uio_sysfs_entry { 75struct uio_sysfs_entry {
71 struct attribute attr; 76 struct attribute attr;
72 ssize_t (*show)(struct uio_mem *, char *); 77 ssize_t (*show)(struct uio_mem *, char *);
@@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attribute =
77 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 82 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
78static struct uio_sysfs_entry size_attribute = 83static struct uio_sysfs_entry size_attribute =
79 __ATTR(size, S_IRUGO, map_size_show, NULL); 84 __ATTR(size, S_IRUGO, map_size_show, NULL);
85static struct uio_sysfs_entry offset_attribute =
86 __ATTR(offset, S_IRUGO, map_offset_show, NULL);
80 87
81static struct attribute *attrs[] = { 88static struct attribute *attrs[] = {
82 &addr_attribute.attr, 89 &addr_attribute.attr,
83 &size_attribute.attr, 90 &size_attribute.attr,
91 &offset_attribute.attr,
84 NULL, /* need to NULL terminate the list of attributes */ 92 NULL, /* need to NULL terminate the list of attributes */
85}; 93};
86 94
@@ -482,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
482{ 490{
483 struct uio_device *idev = vma->vm_private_data; 491 struct uio_device *idev = vma->vm_private_data;
484 struct page *page; 492 struct page *page;
493 unsigned long offset;
485 494
486 int mi = uio_find_mem_index(vma); 495 int mi = uio_find_mem_index(vma);
487 if (mi < 0) 496 if (mi < 0)
488 return VM_FAULT_SIGBUS; 497 return VM_FAULT_SIGBUS;
489 498
499 /*
500 * We need to subtract mi because userspace uses offset = N*PAGE_SIZE
501 * to use mem[N].
502 */
503 offset = (vmf->pgoff - mi) << PAGE_SHIFT;
504
490 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) 505 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
491 page = virt_to_page(idev->info->mem[mi].addr); 506 page = virt_to_page(idev->info->mem[mi].addr + offset);
492 else 507 else
493 page = vmalloc_to_page((void*)idev->info->mem[mi].addr); 508 page = vmalloc_to_page((void *)idev->info->mem[mi].addr
509 + offset);
494 get_page(page); 510 get_page(page);
495 vmf->page = page; 511 vmf->page = page;
496 return 0; 512 return 0;
@@ -682,9 +698,9 @@ int __uio_register_device(struct module *owner,
682 if (ret) 698 if (ret)
683 goto err_get_minor; 699 goto err_get_minor;
684 700
685 idev->dev = device_create_drvdata(uio_class->class, parent, 701 idev->dev = device_create(uio_class->class, parent,
686 MKDEV(uio_major, idev->minor), idev, 702 MKDEV(uio_major, idev->minor), idev,
687 "uio%d", idev->minor); 703 "uio%d", idev->minor);
688 if (IS_ERR(idev->dev)) { 704 if (IS_ERR(idev->dev)) {
689 printk(KERN_ERR "UIO: device register failed\n"); 705 printk(KERN_ERR "UIO: device register failed\n");
690 ret = PTR_ERR(idev->dev); 706 ret = PTR_ERR(idev->dev);
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c
index 0b4ef39cd85d..d494ce9288c3 100644
--- a/drivers/uio/uio_pdrv.c
+++ b/drivers/uio/uio_pdrv.c
@@ -12,7 +12,7 @@
12#include <linux/uio_driver.h> 12#include <linux/uio_driver.h>
13#include <linux/stringify.h> 13#include <linux/stringify.h>
14 14
15#define DRIVER_NAME "uio" 15#define DRIVER_NAME "uio_pdrv"
16 16
17struct uio_platdata { 17struct uio_platdata {
18 struct uio_info *uioinfo; 18 struct uio_info *uioinfo;
diff --git a/drivers/uio/uio_sercos3.c b/drivers/uio/uio_sercos3.c
new file mode 100644
index 000000000000..a6d1b2bc47f3
--- /dev/null
+++ b/drivers/uio/uio_sercos3.c
@@ -0,0 +1,243 @@
1/* sercos3: UIO driver for the Automata Sercos III PCI card
2
3 Copyright (C) 2008 Linutronix GmbH
4 Author: John Ogness <john.ogness@linutronix.de>
5
6 This is a straight-forward UIO driver, where interrupts are disabled
7 by the interrupt handler and re-enabled via a write to the UIO device
8 by the userspace-part.
9
10 The only part that may seem odd is the use of a logical OR when
11 storing and restoring enabled interrupts. This is done because the
12 userspace-part could directly modify the Interrupt Enable Register
13 at any time. To reduce possible conflicts, the kernel driver uses
14 a logical OR to make more controlled changes (rather than blindly
15 overwriting previous values).
16
17 Race conditions exist if the userspace-part directly modifies the
18 Interrupt Enable Register while in operation. The consequences are
19 that certain interrupts would fail to be enabled or disabled. For
20 this reason, the userspace-part should only directly modify the
21 Interrupt Enable Register at the beginning (to get things going).
22 The userspace-part can safely disable interrupts at any time using
23 a write to the UIO device.
24*/
25
26#include <linux/device.h>
27#include <linux/module.h>
28#include <linux/pci.h>
29#include <linux/uio_driver.h>
30#include <linux/io.h>
31
32/* ID's for SERCOS III PCI card (PLX 9030) */
33#define SERCOS_SUB_VENDOR_ID 0x1971
34#define SERCOS_SUB_SYSID_3530 0x3530
35#define SERCOS_SUB_SYSID_3535 0x3535
36#define SERCOS_SUB_SYSID_3780 0x3780
37
38/* Interrupt Enable Register */
39#define IER0_OFFSET 0x08
40
41/* Interrupt Status Register */
42#define ISR0_OFFSET 0x18
43
44struct sercos3_priv {
45 u32 ier0_cache;
46 spinlock_t ier0_cache_lock;
47};
48
49/* this function assumes ier0_cache_lock is locked! */
50static void sercos3_disable_interrupts(struct uio_info *info,
51 struct sercos3_priv *priv)
52{
53 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
54
55 /* add enabled interrupts to cache */
56 priv->ier0_cache |= ioread32(ier0);
57
58 /* disable interrupts */
59 iowrite32(0, ier0);
60}
61
62/* this function assumes ier0_cache_lock is locked! */
63static void sercos3_enable_interrupts(struct uio_info *info,
64 struct sercos3_priv *priv)
65{
66 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
67
68 /* restore previously enabled interrupts */
69 iowrite32(ioread32(ier0) | priv->ier0_cache, ier0);
70 priv->ier0_cache = 0;
71}
72
73static irqreturn_t sercos3_handler(int irq, struct uio_info *info)
74{
75 struct sercos3_priv *priv = info->priv;
76 void __iomem *isr0 = info->mem[3].internal_addr + ISR0_OFFSET;
77 void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET;
78
79 if (!(ioread32(isr0) & ioread32(ier0)))
80 return IRQ_NONE;
81
82 spin_lock(&priv->ier0_cache_lock);
83 sercos3_disable_interrupts(info, priv);
84 spin_unlock(&priv->ier0_cache_lock);
85
86 return IRQ_HANDLED;
87}
88
89static int sercos3_irqcontrol(struct uio_info *info, s32 irq_on)
90{
91 struct sercos3_priv *priv = info->priv;
92
93 spin_lock_irq(&priv->ier0_cache_lock);
94 if (irq_on)
95 sercos3_enable_interrupts(info, priv);
96 else
97 sercos3_disable_interrupts(info, priv);
98 spin_unlock_irq(&priv->ier0_cache_lock);
99
100 return 0;
101}
102
103static int sercos3_setup_iomem(struct pci_dev *dev, struct uio_info *info,
104 int n, int pci_bar)
105{
106 info->mem[n].addr = pci_resource_start(dev, pci_bar);
107 if (!info->mem[n].addr)
108 return -1;
109 info->mem[n].internal_addr = ioremap(pci_resource_start(dev, pci_bar),
110 pci_resource_len(dev, pci_bar));
111 if (!info->mem[n].internal_addr)
112 return -1;
113 info->mem[n].size = pci_resource_len(dev, pci_bar);
114 info->mem[n].memtype = UIO_MEM_PHYS;
115 return 0;
116}
117
118static int __devinit sercos3_pci_probe(struct pci_dev *dev,
119 const struct pci_device_id *id)
120{
121 struct uio_info *info;
122 struct sercos3_priv *priv;
123 int i;
124
125 info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
126 if (!info)
127 return -ENOMEM;
128
129 priv = kzalloc(sizeof(struct sercos3_priv), GFP_KERNEL);
130 if (!priv)
131 goto out_free;
132
133 if (pci_enable_device(dev))
134 goto out_free_priv;
135
136 if (pci_request_regions(dev, "sercos3"))
137 goto out_disable;
138
139 /* we only need PCI BAR's 0, 2, 3, 4, 5 */
140 if (sercos3_setup_iomem(dev, info, 0, 0))
141 goto out_unmap;
142 if (sercos3_setup_iomem(dev, info, 1, 2))
143 goto out_unmap;
144 if (sercos3_setup_iomem(dev, info, 2, 3))
145 goto out_unmap;
146 if (sercos3_setup_iomem(dev, info, 3, 4))
147 goto out_unmap;
148 if (sercos3_setup_iomem(dev, info, 4, 5))
149 goto out_unmap;
150
151 spin_lock_init(&priv->ier0_cache_lock);
152 info->priv = priv;
153 info->name = "Sercos_III_PCI";
154 info->version = "0.0.1";
155 info->irq = dev->irq;
156 info->irq_flags = IRQF_DISABLED | IRQF_SHARED;
157 info->handler = sercos3_handler;
158 info->irqcontrol = sercos3_irqcontrol;
159
160 pci_set_drvdata(dev, info);
161
162 if (uio_register_device(&dev->dev, info))
163 goto out_unmap;
164
165 return 0;
166
167out_unmap:
168 for (i = 0; i < 5; i++) {
169 if (info->mem[i].internal_addr)
170 iounmap(info->mem[i].internal_addr);
171 }
172 pci_release_regions(dev);
173out_disable:
174 pci_disable_device(dev);
175out_free_priv:
176 kfree(priv);
177out_free:
178 kfree(info);
179 return -ENODEV;
180}
181
182static void sercos3_pci_remove(struct pci_dev *dev)
183{
184 struct uio_info *info = pci_get_drvdata(dev);
185 int i;
186
187 uio_unregister_device(info);
188 pci_release_regions(dev);
189 pci_disable_device(dev);
190 pci_set_drvdata(dev, NULL);
191 for (i = 0; i < 5; i++) {
192 if (info->mem[i].internal_addr)
193 iounmap(info->mem[i].internal_addr);
194 }
195 kfree(info->priv);
196 kfree(info);
197}
198
199static struct pci_device_id sercos3_pci_ids[] __devinitdata = {
200 {
201 .vendor = PCI_VENDOR_ID_PLX,
202 .device = PCI_DEVICE_ID_PLX_9030,
203 .subvendor = SERCOS_SUB_VENDOR_ID,
204 .subdevice = SERCOS_SUB_SYSID_3530,
205 },
206 {
207 .vendor = PCI_VENDOR_ID_PLX,
208 .device = PCI_DEVICE_ID_PLX_9030,
209 .subvendor = SERCOS_SUB_VENDOR_ID,
210 .subdevice = SERCOS_SUB_SYSID_3535,
211 },
212 {
213 .vendor = PCI_VENDOR_ID_PLX,
214 .device = PCI_DEVICE_ID_PLX_9030,
215 .subvendor = SERCOS_SUB_VENDOR_ID,
216 .subdevice = SERCOS_SUB_SYSID_3780,
217 },
218 { 0, }
219};
220
221static struct pci_driver sercos3_pci_driver = {
222 .name = "sercos3",
223 .id_table = sercos3_pci_ids,
224 .probe = sercos3_pci_probe,
225 .remove = sercos3_pci_remove,
226};
227
228static int __init sercos3_init_module(void)
229{
230 return pci_register_driver(&sercos3_pci_driver);
231}
232
233static void __exit sercos3_exit_module(void)
234{
235 pci_unregister_driver(&sercos3_pci_driver);
236}
237
238module_init(sercos3_init_module);
239module_exit(sercos3_exit_module);
240
241MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card");
242MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>");
243MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 20290c5b1562..7a4fa791dc19 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev)
1729{ 1729{
1730 struct device *cldev; 1730 struct device *cldev;
1731 1731
1732 cldev = device_create_drvdata(usb_classdev_class, &dev->dev, 1732 cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
1733 dev->dev.devt, NULL, "usbdev%d.%d", 1733 NULL, "usbdev%d.%d", dev->bus->busnum,
1734 dev->bus->busnum, dev->devnum); 1734 dev->devnum);
1735 if (IS_ERR(cldev)) 1735 if (IS_ERR(cldev))
1736 return PTR_ERR(cldev); 1736 return PTR_ERR(cldev);
1737 dev->usb_classdev = cldev; 1737 dev->usb_classdev = cldev;
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 6b1b229e38cd..55f7f310924b 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -196,9 +196,9 @@ int usb_register_dev(struct usb_interface *intf,
196 ++temp; 196 ++temp;
197 else 197 else
198 temp = name; 198 temp = name;
199 intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev, 199 intf->usb_dev = device_create(usb_class->class, &intf->dev,
200 MKDEV(USB_MAJOR, minor), NULL, 200 MKDEV(USB_MAJOR, minor), NULL,
201 "%s", temp); 201 "%s", temp);
202 if (IS_ERR(intf->usb_dev)) { 202 if (IS_ERR(intf->usb_dev)) {
203 down_write(&minor_rwsem); 203 down_write(&minor_rwsem);
204 usb_minors[intf->minor] = NULL; 204 usb_minors[intf->minor] = NULL;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8ab389dca2b9..c8035a8216bd 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -818,9 +818,8 @@ static int usb_register_bus(struct usb_bus *bus)
818 set_bit (busnum, busmap.busmap); 818 set_bit (busnum, busmap.busmap);
819 bus->busnum = busnum; 819 bus->busnum = busnum;
820 820
821 bus->dev = device_create_drvdata(usb_host_class, bus->controller, 821 bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0),
822 MKDEV(0, 0), bus, 822 bus, "usb_host%d", busnum);
823 "usb_host%d", busnum);
824 result = PTR_ERR(bus->dev); 823 result = PTR_ERR(bus->dev);
825 if (IS_ERR(bus->dev)) 824 if (IS_ERR(bus->dev))
826 goto error_create_class_dev; 825 goto error_create_class_dev;
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index fcb5cb9094d9..2267fa0b51b2 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -22,24 +22,15 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
22# 22#
23# USB gadget drivers 23# USB gadget drivers
24# 24#
25C_UTILS = composite.o usbstring.o config.o epautoconf.o 25g_zero-objs := zero.o
26 26g_ether-objs := ether.o
27g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS) 27g_serial-objs := serial.o
28g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) 28g_midi-objs := gmidi.o
29g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS)
30g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
31gadgetfs-objs := inode.o 29gadgetfs-objs := inode.o
32g_file_storage-objs := file_storage.o usbstring.o config.o \ 30g_file_storage-objs := file_storage.o
33 epautoconf.o 31g_printer-objs := printer.o
34g_printer-objs := printer.o usbstring.o config.o \ 32g_cdc-objs := cdc2.o
35 epautoconf.o
36g_cdc-objs := cdc2.o u_ether.o f_ecm.o \
37 u_serial.o f_acm.o $(C_UTILS)
38 33
39ifeq ($(CONFIG_USB_ETH_RNDIS),y)
40 g_ether-objs += f_rndis.o rndis.o
41endif
42
43obj-$(CONFIG_USB_ZERO) += g_zero.o 34obj-$(CONFIG_USB_ZERO) += g_zero.o
44obj-$(CONFIG_USB_ETH) += g_ether.o 35obj-$(CONFIG_USB_ETH) += g_ether.o
45obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o 36obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index a39a4b940c33..a724fc149850 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -43,6 +43,25 @@
43 43
44/*-------------------------------------------------------------------------*/ 44/*-------------------------------------------------------------------------*/
45 45
46/*
47 * Kbuild is not very cooperative with respect to linking separately
48 * compiled library objects into one module. So for now we won't use
49 * separate compilation ... ensuring init/exit sections work to shrink
50 * the runtime footprint, and giving us at least some parts of what
51 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
52 */
53
54#include "composite.c"
55#include "usbstring.c"
56#include "config.c"
57#include "epautoconf.c"
58#include "u_serial.c"
59#include "f_acm.c"
60#include "f_ecm.c"
61#include "u_ether.c"
62
63/*-------------------------------------------------------------------------*/
64
46static struct usb_device_descriptor device_desc = { 65static struct usb_device_descriptor device_desc = {
47 .bLength = sizeof device_desc, 66 .bLength = sizeof device_desc,
48 .bDescriptorType = USB_DT_DEVICE, 67 .bDescriptorType = USB_DT_DEVICE,
@@ -148,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
148 int status; 167 int status;
149 168
150 if (!can_support_ecm(cdev->gadget)) { 169 if (!can_support_ecm(cdev->gadget)) {
151 ERROR(cdev, "controller '%s' not usable\n", gadget->name); 170 dev_err(&gadget->dev, "controller '%s' not usable\n",
171 gadget->name);
152 return -EINVAL; 172 return -EINVAL;
153 } 173 }
154 174
@@ -203,7 +223,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
203 if (status < 0) 223 if (status < 0)
204 goto fail1; 224 goto fail1;
205 225
206 INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 226 dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
227 DRIVER_DESC);
207 228
208 return 0; 229 return 0;
209 230
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index bcac2e68660d..944c8e889ab4 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -96,6 +96,28 @@ static inline bool has_rndis(void)
96 96
97/*-------------------------------------------------------------------------*/ 97/*-------------------------------------------------------------------------*/
98 98
99/*
100 * Kbuild is not very cooperative with respect to linking separately
101 * compiled library objects into one module. So for now we won't use
102 * separate compilation ... ensuring init/exit sections work to shrink
103 * the runtime footprint, and giving us at least some parts of what
104 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
105 */
106#include "composite.c"
107#include "usbstring.c"
108#include "config.c"
109#include "epautoconf.c"
110
111#include "f_ecm.c"
112#include "f_subset.c"
113#ifdef CONFIG_USB_ETH_RNDIS
114#include "f_rndis.c"
115#include "rndis.c"
116#endif
117#include "u_ether.c"
118
119/*-------------------------------------------------------------------------*/
120
99/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 121/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
100 * Instead: allocate your own, using normal USB-IF procedures. 122 * Instead: allocate your own, using normal USB-IF procedures.
101 */ 123 */
@@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
293 * but if the controller isn't recognized at all then 315 * but if the controller isn't recognized at all then
294 * that assumption is a bit more likely to be wrong. 316 * that assumption is a bit more likely to be wrong.
295 */ 317 */
296 WARNING(cdev, "controller '%s' not recognized; trying %s\n", 318 dev_warn(&gadget->dev,
319 "controller '%s' not recognized; trying %s\n",
297 gadget->name, 320 gadget->name,
298 eth_config_driver.label); 321 eth_config_driver.label);
299 device_desc.bcdDevice = 322 device_desc.bcdDevice =
@@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
332 if (status < 0) 355 if (status < 0)
333 goto fail; 356 goto fail;
334 357
335 INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 358 dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
359 DRIVER_DESC);
336 360
337 return 0; 361 return 0;
338 362
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index a2b5c092bda0..4ae579948e54 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -83,7 +83,7 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f)
83} 83}
84 84
85/* peak (theoretical) bulk transfer rate in bits-per-second */ 85/* peak (theoretical) bulk transfer rate in bits-per-second */
86static inline unsigned bitrate(struct usb_gadget *g) 86static inline unsigned ecm_bitrate(struct usb_gadget *g)
87{ 87{
88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) 88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
89 return 13 * 512 * 8 * 1000 * 8; 89 return 13 * 512 * 8 * 1000 * 8;
@@ -107,7 +107,7 @@ static inline unsigned bitrate(struct usb_gadget *g)
107 */ 107 */
108 108
109#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 109#define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */
110#define STATUS_BYTECOUNT 16 /* 8 byte header + data */ 110#define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */
111 111
112 112
113/* interface descriptor: */ 113/* interface descriptor: */
@@ -125,8 +125,8 @@ static struct usb_interface_descriptor ecm_control_intf __initdata = {
125 /* .iInterface = DYNAMIC */ 125 /* .iInterface = DYNAMIC */
126}; 126};
127 127
128static struct usb_cdc_header_desc header_desc __initdata = { 128static struct usb_cdc_header_desc ecm_header_desc __initdata = {
129 .bLength = sizeof header_desc, 129 .bLength = sizeof ecm_header_desc,
130 .bDescriptorType = USB_DT_CS_INTERFACE, 130 .bDescriptorType = USB_DT_CS_INTERFACE,
131 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 131 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
132 132
@@ -141,8 +141,8 @@ static struct usb_cdc_union_desc ecm_union_desc __initdata = {
141 /* .bSlaveInterface0 = DYNAMIC */ 141 /* .bSlaveInterface0 = DYNAMIC */
142}; 142};
143 143
144static struct usb_cdc_ether_desc ether_desc __initdata = { 144static struct usb_cdc_ether_desc ecm_desc __initdata = {
145 .bLength = sizeof ether_desc, 145 .bLength = sizeof ecm_desc,
146 .bDescriptorType = USB_DT_CS_INTERFACE, 146 .bDescriptorType = USB_DT_CS_INTERFACE,
147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, 147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE,
148 148
@@ -186,17 +186,17 @@ static struct usb_interface_descriptor ecm_data_intf __initdata = {
186 186
187/* full speed support: */ 187/* full speed support: */
188 188
189static struct usb_endpoint_descriptor fs_notify_desc __initdata = { 189static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = {
190 .bLength = USB_DT_ENDPOINT_SIZE, 190 .bLength = USB_DT_ENDPOINT_SIZE,
191 .bDescriptorType = USB_DT_ENDPOINT, 191 .bDescriptorType = USB_DT_ENDPOINT,
192 192
193 .bEndpointAddress = USB_DIR_IN, 193 .bEndpointAddress = USB_DIR_IN,
194 .bmAttributes = USB_ENDPOINT_XFER_INT, 194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 195 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
197}; 197};
198 198
199static struct usb_endpoint_descriptor fs_in_desc __initdata = { 199static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = {
200 .bLength = USB_DT_ENDPOINT_SIZE, 200 .bLength = USB_DT_ENDPOINT_SIZE,
201 .bDescriptorType = USB_DT_ENDPOINT, 201 .bDescriptorType = USB_DT_ENDPOINT,
202 202
@@ -204,7 +204,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = {
204 .bmAttributes = USB_ENDPOINT_XFER_BULK, 204 .bmAttributes = USB_ENDPOINT_XFER_BULK,
205}; 205};
206 206
207static struct usb_endpoint_descriptor fs_out_desc __initdata = { 207static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = {
208 .bLength = USB_DT_ENDPOINT_SIZE, 208 .bLength = USB_DT_ENDPOINT_SIZE,
209 .bDescriptorType = USB_DT_ENDPOINT, 209 .bDescriptorType = USB_DT_ENDPOINT,
210 210
@@ -212,34 +212,34 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = {
212 .bmAttributes = USB_ENDPOINT_XFER_BULK, 212 .bmAttributes = USB_ENDPOINT_XFER_BULK,
213}; 213};
214 214
215static struct usb_descriptor_header *eth_fs_function[] __initdata = { 215static struct usb_descriptor_header *ecm_fs_function[] __initdata = {
216 /* CDC ECM control descriptors */ 216 /* CDC ECM control descriptors */
217 (struct usb_descriptor_header *) &ecm_control_intf, 217 (struct usb_descriptor_header *) &ecm_control_intf,
218 (struct usb_descriptor_header *) &header_desc, 218 (struct usb_descriptor_header *) &ecm_header_desc,
219 (struct usb_descriptor_header *) &ecm_union_desc, 219 (struct usb_descriptor_header *) &ecm_union_desc,
220 (struct usb_descriptor_header *) &ether_desc, 220 (struct usb_descriptor_header *) &ecm_desc,
221 /* NOTE: status endpoint might need to be removed */ 221 /* NOTE: status endpoint might need to be removed */
222 (struct usb_descriptor_header *) &fs_notify_desc, 222 (struct usb_descriptor_header *) &fs_ecm_notify_desc,
223 /* data interface, altsettings 0 and 1 */ 223 /* data interface, altsettings 0 and 1 */
224 (struct usb_descriptor_header *) &ecm_data_nop_intf, 224 (struct usb_descriptor_header *) &ecm_data_nop_intf,
225 (struct usb_descriptor_header *) &ecm_data_intf, 225 (struct usb_descriptor_header *) &ecm_data_intf,
226 (struct usb_descriptor_header *) &fs_in_desc, 226 (struct usb_descriptor_header *) &fs_ecm_in_desc,
227 (struct usb_descriptor_header *) &fs_out_desc, 227 (struct usb_descriptor_header *) &fs_ecm_out_desc,
228 NULL, 228 NULL,
229}; 229};
230 230
231/* high speed support: */ 231/* high speed support: */
232 232
233static struct usb_endpoint_descriptor hs_notify_desc __initdata = { 233static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = {
234 .bLength = USB_DT_ENDPOINT_SIZE, 234 .bLength = USB_DT_ENDPOINT_SIZE,
235 .bDescriptorType = USB_DT_ENDPOINT, 235 .bDescriptorType = USB_DT_ENDPOINT,
236 236
237 .bEndpointAddress = USB_DIR_IN, 237 .bEndpointAddress = USB_DIR_IN,
238 .bmAttributes = USB_ENDPOINT_XFER_INT, 238 .bmAttributes = USB_ENDPOINT_XFER_INT,
239 .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 239 .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
241}; 241};
242static struct usb_endpoint_descriptor hs_in_desc __initdata = { 242static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
243 .bLength = USB_DT_ENDPOINT_SIZE, 243 .bLength = USB_DT_ENDPOINT_SIZE,
244 .bDescriptorType = USB_DT_ENDPOINT, 244 .bDescriptorType = USB_DT_ENDPOINT,
245 245
@@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
248 .wMaxPacketSize = __constant_cpu_to_le16(512), 248 .wMaxPacketSize = __constant_cpu_to_le16(512),
249}; 249};
250 250
251static struct usb_endpoint_descriptor hs_out_desc __initdata = { 251static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
252 .bLength = USB_DT_ENDPOINT_SIZE, 252 .bLength = USB_DT_ENDPOINT_SIZE,
253 .bDescriptorType = USB_DT_ENDPOINT, 253 .bDescriptorType = USB_DT_ENDPOINT,
254 254
@@ -257,19 +257,19 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
257 .wMaxPacketSize = __constant_cpu_to_le16(512), 257 .wMaxPacketSize = __constant_cpu_to_le16(512),
258}; 258};
259 259
260static struct usb_descriptor_header *eth_hs_function[] __initdata = { 260static struct usb_descriptor_header *ecm_hs_function[] __initdata = {
261 /* CDC ECM control descriptors */ 261 /* CDC ECM control descriptors */
262 (struct usb_descriptor_header *) &ecm_control_intf, 262 (struct usb_descriptor_header *) &ecm_control_intf,
263 (struct usb_descriptor_header *) &header_desc, 263 (struct usb_descriptor_header *) &ecm_header_desc,
264 (struct usb_descriptor_header *) &ecm_union_desc, 264 (struct usb_descriptor_header *) &ecm_union_desc,
265 (struct usb_descriptor_header *) &ether_desc, 265 (struct usb_descriptor_header *) &ecm_desc,
266 /* NOTE: status endpoint might need to be removed */ 266 /* NOTE: status endpoint might need to be removed */
267 (struct usb_descriptor_header *) &hs_notify_desc, 267 (struct usb_descriptor_header *) &hs_ecm_notify_desc,
268 /* data interface, altsettings 0 and 1 */ 268 /* data interface, altsettings 0 and 1 */
269 (struct usb_descriptor_header *) &ecm_data_nop_intf, 269 (struct usb_descriptor_header *) &ecm_data_nop_intf,
270 (struct usb_descriptor_header *) &ecm_data_intf, 270 (struct usb_descriptor_header *) &ecm_data_intf,
271 (struct usb_descriptor_header *) &hs_in_desc, 271 (struct usb_descriptor_header *) &hs_ecm_in_desc,
272 (struct usb_descriptor_header *) &hs_out_desc, 272 (struct usb_descriptor_header *) &hs_ecm_out_desc,
273 NULL, 273 NULL,
274}; 274};
275 275
@@ -329,14 +329,14 @@ static void ecm_do_notify(struct f_ecm *ecm)
329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE; 329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE;
330 event->wValue = cpu_to_le16(0); 330 event->wValue = cpu_to_le16(0);
331 event->wLength = cpu_to_le16(8); 331 event->wLength = cpu_to_le16(8);
332 req->length = STATUS_BYTECOUNT; 332 req->length = ECM_STATUS_BYTECOUNT;
333 333
334 /* SPEED_CHANGE data is up/down speeds in bits/sec */ 334 /* SPEED_CHANGE data is up/down speeds in bits/sec */
335 data = req->buf + sizeof *event; 335 data = req->buf + sizeof *event;
336 data[0] = cpu_to_le32(bitrate(cdev->gadget)); 336 data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget));
337 data[1] = data[0]; 337 data[1] = data[0];
338 338
339 DBG(cdev, "notify speed %d\n", bitrate(cdev->gadget)); 339 DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget));
340 ecm->notify_state = ECM_NOTIFY_NONE; 340 ecm->notify_state = ECM_NOTIFY_NONE;
341 break; 341 break;
342 } 342 }
@@ -628,13 +628,13 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
628 status = -ENODEV; 628 status = -ENODEV;
629 629
630 /* allocate instance-specific endpoints */ 630 /* allocate instance-specific endpoints */
631 ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 631 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc);
632 if (!ep) 632 if (!ep)
633 goto fail; 633 goto fail;
634 ecm->port.in_ep = ep; 634 ecm->port.in_ep = ep;
635 ep->driver_data = cdev; /* claim */ 635 ep->driver_data = cdev; /* claim */
636 636
637 ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 637 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
638 if (!ep) 638 if (!ep)
639 goto fail; 639 goto fail;
640 ecm->port.out_ep = ep; 640 ecm->port.out_ep = ep;
@@ -644,7 +644,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
644 * don't treat it that way. It's simpler, and some newer CDC 644 * don't treat it that way. It's simpler, and some newer CDC
645 * profiles (wireless handsets) no longer treat it as optional. 645 * profiles (wireless handsets) no longer treat it as optional.
646 */ 646 */
647 ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc); 647 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc);
648 if (!ep) 648 if (!ep)
649 goto fail; 649 goto fail;
650 ecm->notify = ep; 650 ecm->notify = ep;
@@ -656,47 +656,47 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); 656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
657 if (!ecm->notify_req) 657 if (!ecm->notify_req)
658 goto fail; 658 goto fail;
659 ecm->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL); 659 ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL);
660 if (!ecm->notify_req->buf) 660 if (!ecm->notify_req->buf)
661 goto fail; 661 goto fail;
662 ecm->notify_req->context = ecm; 662 ecm->notify_req->context = ecm;
663 ecm->notify_req->complete = ecm_notify_complete; 663 ecm->notify_req->complete = ecm_notify_complete;
664 664
665 /* copy descriptors, and track endpoint copies */ 665 /* copy descriptors, and track endpoint copies */
666 f->descriptors = usb_copy_descriptors(eth_fs_function); 666 f->descriptors = usb_copy_descriptors(ecm_fs_function);
667 if (!f->descriptors) 667 if (!f->descriptors)
668 goto fail; 668 goto fail;
669 669
670 ecm->fs.in = usb_find_endpoint(eth_fs_function, 670 ecm->fs.in = usb_find_endpoint(ecm_fs_function,
671 f->descriptors, &fs_in_desc); 671 f->descriptors, &fs_ecm_in_desc);
672 ecm->fs.out = usb_find_endpoint(eth_fs_function, 672 ecm->fs.out = usb_find_endpoint(ecm_fs_function,
673 f->descriptors, &fs_out_desc); 673 f->descriptors, &fs_ecm_out_desc);
674 ecm->fs.notify = usb_find_endpoint(eth_fs_function, 674 ecm->fs.notify = usb_find_endpoint(ecm_fs_function,
675 f->descriptors, &fs_notify_desc); 675 f->descriptors, &fs_ecm_notify_desc);
676 676
677 /* support all relevant hardware speeds... we expect that when 677 /* support all relevant hardware speeds... we expect that when
678 * hardware is dual speed, all bulk-capable endpoints work at 678 * hardware is dual speed, all bulk-capable endpoints work at
679 * both speeds 679 * both speeds
680 */ 680 */
681 if (gadget_is_dualspeed(c->cdev->gadget)) { 681 if (gadget_is_dualspeed(c->cdev->gadget)) {
682 hs_in_desc.bEndpointAddress = 682 hs_ecm_in_desc.bEndpointAddress =
683 fs_in_desc.bEndpointAddress; 683 fs_ecm_in_desc.bEndpointAddress;
684 hs_out_desc.bEndpointAddress = 684 hs_ecm_out_desc.bEndpointAddress =
685 fs_out_desc.bEndpointAddress; 685 fs_ecm_out_desc.bEndpointAddress;
686 hs_notify_desc.bEndpointAddress = 686 hs_ecm_notify_desc.bEndpointAddress =
687 fs_notify_desc.bEndpointAddress; 687 fs_ecm_notify_desc.bEndpointAddress;
688 688
689 /* copy descriptors, and track endpoint copies */ 689 /* copy descriptors, and track endpoint copies */
690 f->hs_descriptors = usb_copy_descriptors(eth_hs_function); 690 f->hs_descriptors = usb_copy_descriptors(ecm_hs_function);
691 if (!f->hs_descriptors) 691 if (!f->hs_descriptors)
692 goto fail; 692 goto fail;
693 693
694 ecm->hs.in = usb_find_endpoint(eth_hs_function, 694 ecm->hs.in = usb_find_endpoint(ecm_hs_function,
695 f->hs_descriptors, &hs_in_desc); 695 f->hs_descriptors, &hs_ecm_in_desc);
696 ecm->hs.out = usb_find_endpoint(eth_hs_function, 696 ecm->hs.out = usb_find_endpoint(ecm_hs_function,
697 f->hs_descriptors, &hs_out_desc); 697 f->hs_descriptors, &hs_ecm_out_desc);
698 ecm->hs.notify = usb_find_endpoint(eth_hs_function, 698 ecm->hs.notify = usb_find_endpoint(ecm_hs_function,
699 f->hs_descriptors, &hs_notify_desc); 699 f->hs_descriptors, &hs_ecm_notify_desc);
700 } 700 }
701 701
702 /* NOTE: all that is done without knowing or caring about 702 /* NOTE: all that is done without knowing or caring about
@@ -795,7 +795,7 @@ int __init ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
795 if (status < 0) 795 if (status < 0)
796 return status; 796 return status;
797 ecm_string_defs[1].id = status; 797 ecm_string_defs[1].id = status;
798 ether_desc.iMACAddress = status; 798 ecm_desc.iMACAddress = status;
799 } 799 }
800 800
801 /* allocate and initialize one new instance */ 801 /* allocate and initialize one new instance */
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index eda4cde72c82..87dde012dacc 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = {
70 70
71/* full speed support: */ 71/* full speed support: */
72 72
73static struct usb_endpoint_descriptor fs_source_desc = { 73static struct usb_endpoint_descriptor fs_loop_source_desc = {
74 .bLength = USB_DT_ENDPOINT_SIZE, 74 .bLength = USB_DT_ENDPOINT_SIZE,
75 .bDescriptorType = USB_DT_ENDPOINT, 75 .bDescriptorType = USB_DT_ENDPOINT,
76 76
@@ -78,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = {
78 .bmAttributes = USB_ENDPOINT_XFER_BULK, 78 .bmAttributes = USB_ENDPOINT_XFER_BULK,
79}; 79};
80 80
81static struct usb_endpoint_descriptor fs_sink_desc = { 81static struct usb_endpoint_descriptor fs_loop_sink_desc = {
82 .bLength = USB_DT_ENDPOINT_SIZE, 82 .bLength = USB_DT_ENDPOINT_SIZE,
83 .bDescriptorType = USB_DT_ENDPOINT, 83 .bDescriptorType = USB_DT_ENDPOINT,
84 84
@@ -88,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = {
88 88
89static struct usb_descriptor_header *fs_loopback_descs[] = { 89static struct usb_descriptor_header *fs_loopback_descs[] = {
90 (struct usb_descriptor_header *) &loopback_intf, 90 (struct usb_descriptor_header *) &loopback_intf,
91 (struct usb_descriptor_header *) &fs_sink_desc, 91 (struct usb_descriptor_header *) &fs_loop_sink_desc,
92 (struct usb_descriptor_header *) &fs_source_desc, 92 (struct usb_descriptor_header *) &fs_loop_source_desc,
93 NULL, 93 NULL,
94}; 94};
95 95
96/* high speed support: */ 96/* high speed support: */
97 97
98static struct usb_endpoint_descriptor hs_source_desc = { 98static struct usb_endpoint_descriptor hs_loop_source_desc = {
99 .bLength = USB_DT_ENDPOINT_SIZE, 99 .bLength = USB_DT_ENDPOINT_SIZE,
100 .bDescriptorType = USB_DT_ENDPOINT, 100 .bDescriptorType = USB_DT_ENDPOINT,
101 101
@@ -103,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = {
103 .wMaxPacketSize = __constant_cpu_to_le16(512), 103 .wMaxPacketSize = __constant_cpu_to_le16(512),
104}; 104};
105 105
106static struct usb_endpoint_descriptor hs_sink_desc = { 106static struct usb_endpoint_descriptor hs_loop_sink_desc = {
107 .bLength = USB_DT_ENDPOINT_SIZE, 107 .bLength = USB_DT_ENDPOINT_SIZE,
108 .bDescriptorType = USB_DT_ENDPOINT, 108 .bDescriptorType = USB_DT_ENDPOINT,
109 109
@@ -113,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = {
113 113
114static struct usb_descriptor_header *hs_loopback_descs[] = { 114static struct usb_descriptor_header *hs_loopback_descs[] = {
115 (struct usb_descriptor_header *) &loopback_intf, 115 (struct usb_descriptor_header *) &loopback_intf,
116 (struct usb_descriptor_header *) &hs_source_desc, 116 (struct usb_descriptor_header *) &hs_loop_source_desc,
117 (struct usb_descriptor_header *) &hs_sink_desc, 117 (struct usb_descriptor_header *) &hs_loop_sink_desc,
118 NULL, 118 NULL,
119}; 119};
120 120
@@ -152,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f)
152 152
153 /* allocate endpoints */ 153 /* allocate endpoints */
154 154
155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); 155 loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc);
156 if (!loop->in_ep) { 156 if (!loop->in_ep) {
157autoconf_fail: 157autoconf_fail:
158 ERROR(cdev, "%s: can't autoconfigure on %s\n", 158 ERROR(cdev, "%s: can't autoconfigure on %s\n",
@@ -161,17 +161,17 @@ autoconf_fail:
161 } 161 }
162 loop->in_ep->driver_data = cdev; /* claim */ 162 loop->in_ep->driver_data = cdev; /* claim */
163 163
164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); 164 loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_sink_desc);
165 if (!loop->out_ep) 165 if (!loop->out_ep)
166 goto autoconf_fail; 166 goto autoconf_fail;
167 loop->out_ep->driver_data = cdev; /* claim */ 167 loop->out_ep->driver_data = cdev; /* claim */
168 168
169 /* support high speed hardware */ 169 /* support high speed hardware */
170 if (gadget_is_dualspeed(c->cdev->gadget)) { 170 if (gadget_is_dualspeed(c->cdev->gadget)) {
171 hs_source_desc.bEndpointAddress = 171 hs_loop_source_desc.bEndpointAddress =
172 fs_source_desc.bEndpointAddress; 172 fs_loop_source_desc.bEndpointAddress;
173 hs_sink_desc.bEndpointAddress = 173 hs_loop_sink_desc.bEndpointAddress =
174 fs_sink_desc.bEndpointAddress; 174 fs_loop_sink_desc.bEndpointAddress;
175 f->hs_descriptors = hs_loopback_descs; 175 f->hs_descriptors = hs_loopback_descs;
176 } 176 }
177 177
@@ -255,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
255 struct usb_request *req; 255 struct usb_request *req;
256 unsigned i; 256 unsigned i;
257 257
258 src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); 258 src = ep_choose(cdev->gadget,
259 sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); 259 &hs_loop_source_desc, &fs_loop_source_desc);
260 sink = ep_choose(cdev->gadget,
261 &hs_loop_sink_desc, &fs_loop_sink_desc);
260 262
261 /* one endpoint writes data back IN to the host */ 263 /* one endpoint writes data back IN to the host */
262 ep = loop->in_ep; 264 ep = loop->in_ep;
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index acb8d233aa1d..fe1832875771 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = {
103 /* .iInterface = DYNAMIC */ 103 /* .iInterface = DYNAMIC */
104}; 104};
105 105
106static struct usb_cdc_header_desc header_desc __initdata = { 106static struct usb_cdc_header_desc mdlm_header_desc __initdata = {
107 .bLength = sizeof header_desc, 107 .bLength = sizeof mdlm_header_desc,
108 .bDescriptorType = USB_DT_CS_INTERFACE, 108 .bDescriptorType = USB_DT_CS_INTERFACE,
109 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 109 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
110 110
@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = {
152 152
153/* full speed support: */ 153/* full speed support: */
154 154
155static struct usb_endpoint_descriptor fs_in_desc __initdata = { 155static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = {
156 .bLength = USB_DT_ENDPOINT_SIZE, 156 .bLength = USB_DT_ENDPOINT_SIZE,
157 .bDescriptorType = USB_DT_ENDPOINT, 157 .bDescriptorType = USB_DT_ENDPOINT,
158 158
@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = {
160 .bmAttributes = USB_ENDPOINT_XFER_BULK, 160 .bmAttributes = USB_ENDPOINT_XFER_BULK,
161}; 161};
162 162
163static struct usb_endpoint_descriptor fs_out_desc __initdata = { 163static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = {
164 .bLength = USB_DT_ENDPOINT_SIZE, 164 .bLength = USB_DT_ENDPOINT_SIZE,
165 .bDescriptorType = USB_DT_ENDPOINT, 165 .bDescriptorType = USB_DT_ENDPOINT,
166 166
@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = {
170 170
171static struct usb_descriptor_header *fs_eth_function[] __initdata = { 171static struct usb_descriptor_header *fs_eth_function[] __initdata = {
172 (struct usb_descriptor_header *) &subset_data_intf, 172 (struct usb_descriptor_header *) &subset_data_intf,
173 (struct usb_descriptor_header *) &header_desc, 173 (struct usb_descriptor_header *) &mdlm_header_desc,
174 (struct usb_descriptor_header *) &mdlm_desc, 174 (struct usb_descriptor_header *) &mdlm_desc,
175 (struct usb_descriptor_header *) &mdlm_detail_desc, 175 (struct usb_descriptor_header *) &mdlm_detail_desc,
176 (struct usb_descriptor_header *) &ether_desc, 176 (struct usb_descriptor_header *) &ether_desc,
177 (struct usb_descriptor_header *) &fs_in_desc, 177 (struct usb_descriptor_header *) &fs_subset_in_desc,
178 (struct usb_descriptor_header *) &fs_out_desc, 178 (struct usb_descriptor_header *) &fs_subset_out_desc,
179 NULL, 179 NULL,
180}; 180};
181 181
182/* high speed support: */ 182/* high speed support: */
183 183
184static struct usb_endpoint_descriptor hs_in_desc __initdata = { 184static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = {
185 .bLength = USB_DT_ENDPOINT_SIZE, 185 .bLength = USB_DT_ENDPOINT_SIZE,
186 .bDescriptorType = USB_DT_ENDPOINT, 186 .bDescriptorType = USB_DT_ENDPOINT,
187 187
@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = {
189 .wMaxPacketSize = __constant_cpu_to_le16(512), 189 .wMaxPacketSize = __constant_cpu_to_le16(512),
190}; 190};
191 191
192static struct usb_endpoint_descriptor hs_out_desc __initdata = { 192static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
193 .bLength = USB_DT_ENDPOINT_SIZE, 193 .bLength = USB_DT_ENDPOINT_SIZE,
194 .bDescriptorType = USB_DT_ENDPOINT, 194 .bDescriptorType = USB_DT_ENDPOINT,
195 195
@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = {
199 199
200static struct usb_descriptor_header *hs_eth_function[] __initdata = { 200static struct usb_descriptor_header *hs_eth_function[] __initdata = {
201 (struct usb_descriptor_header *) &subset_data_intf, 201 (struct usb_descriptor_header *) &subset_data_intf,
202 (struct usb_descriptor_header *) &header_desc, 202 (struct usb_descriptor_header *) &mdlm_header_desc,
203 (struct usb_descriptor_header *) &mdlm_desc, 203 (struct usb_descriptor_header *) &mdlm_desc,
204 (struct usb_descriptor_header *) &mdlm_detail_desc, 204 (struct usb_descriptor_header *) &mdlm_detail_desc,
205 (struct usb_descriptor_header *) &ether_desc, 205 (struct usb_descriptor_header *) &ether_desc,
206 (struct usb_descriptor_header *) &hs_in_desc, 206 (struct usb_descriptor_header *) &hs_subset_in_desc,
207 (struct usb_descriptor_header *) &hs_out_desc, 207 (struct usb_descriptor_header *) &hs_subset_out_desc,
208 NULL, 208 NULL,
209}; 209};
210 210
@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
281 status = -ENODEV; 281 status = -ENODEV;
282 282
283 /* allocate instance-specific endpoints */ 283 /* allocate instance-specific endpoints */
284 ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 284 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc);
285 if (!ep) 285 if (!ep)
286 goto fail; 286 goto fail;
287 geth->port.in_ep = ep; 287 geth->port.in_ep = ep;
288 ep->driver_data = cdev; /* claim */ 288 ep->driver_data = cdev; /* claim */
289 289
290 ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 290 ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc);
291 if (!ep) 291 if (!ep)
292 goto fail; 292 goto fail;
293 geth->port.out_ep = ep; 293 geth->port.out_ep = ep;
@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
297 f->descriptors = usb_copy_descriptors(fs_eth_function); 297 f->descriptors = usb_copy_descriptors(fs_eth_function);
298 298
299 geth->fs.in = usb_find_endpoint(fs_eth_function, 299 geth->fs.in = usb_find_endpoint(fs_eth_function,
300 f->descriptors, &fs_in_desc); 300 f->descriptors, &fs_subset_in_desc);
301 geth->fs.out = usb_find_endpoint(fs_eth_function, 301 geth->fs.out = usb_find_endpoint(fs_eth_function,
302 f->descriptors, &fs_out_desc); 302 f->descriptors, &fs_subset_out_desc);
303 303
304 304
305 /* support all relevant hardware speeds... we expect that when 305 /* support all relevant hardware speeds... we expect that when
@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
307 * both speeds 307 * both speeds
308 */ 308 */
309 if (gadget_is_dualspeed(c->cdev->gadget)) { 309 if (gadget_is_dualspeed(c->cdev->gadget)) {
310 hs_in_desc.bEndpointAddress = 310 hs_subset_in_desc.bEndpointAddress =
311 fs_in_desc.bEndpointAddress; 311 fs_subset_in_desc.bEndpointAddress;
312 hs_out_desc.bEndpointAddress = 312 hs_subset_out_desc.bEndpointAddress =
313 fs_out_desc.bEndpointAddress; 313 fs_subset_out_desc.bEndpointAddress;
314 314
315 /* copy descriptors, and track endpoint copies */ 315 /* copy descriptors, and track endpoint copies */
316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function); 316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function);
317 317
318 geth->hs.in = usb_find_endpoint(hs_eth_function, 318 geth->hs.in = usb_find_endpoint(hs_eth_function,
319 f->hs_descriptors, &hs_in_desc); 319 f->hs_descriptors, &hs_subset_in_desc);
320 geth->hs.out = usb_find_endpoint(hs_eth_function, 320 geth->hs.out = usb_find_endpoint(hs_eth_function,
321 f->hs_descriptors, &hs_out_desc); 321 f->hs_descriptors, &hs_subset_out_desc);
322 } 322 }
323 323
324 /* NOTE: all that is done without knowing or caring about 324 /* NOTE: all that is done without knowing or caring about
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index ea2c31d18080..0c632d22a631 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -245,6 +245,18 @@
245#include "gadget_chips.h" 245#include "gadget_chips.h"
246 246
247 247
248
249/*
250 * Kbuild is not very cooperative with respect to linking separately
251 * compiled library objects into one module. So for now we won't use
252 * separate compilation ... ensuring init/exit sections work to shrink
253 * the runtime footprint, and giving us at least some parts of what
254 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
255 */
256#include "usbstring.c"
257#include "config.c"
258#include "epautoconf.c"
259
248/*-------------------------------------------------------------------------*/ 260/*-------------------------------------------------------------------------*/
249 261
250#define DRIVER_DESC "File-backed Storage Gadget" 262#define DRIVER_DESC "File-backed Storage Gadget"
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index ea8651e3da1a..6eee760410d6 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -35,6 +35,21 @@
35 35
36#include "gadget_chips.h" 36#include "gadget_chips.h"
37 37
38
39/*
40 * Kbuild is not very cooperative with respect to linking separately
41 * compiled library objects into one module. So for now we won't use
42 * separate compilation ... ensuring init/exit sections work to shrink
43 * the runtime footprint, and giving us at least some parts of what
44 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
45 */
46#include "usbstring.c"
47#include "config.c"
48#include "epautoconf.c"
49
50/*-------------------------------------------------------------------------*/
51
52
38MODULE_AUTHOR("Ben Williamson"); 53MODULE_AUTHOR("Ben Williamson");
39MODULE_LICENSE("GPL v2"); 54MODULE_LICENSE("GPL v2");
40 55
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index e0090085b78e..2b3b9e1dd2ee 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -53,6 +53,20 @@
53 53
54#include "gadget_chips.h" 54#include "gadget_chips.h"
55 55
56
57/*
58 * Kbuild is not very cooperative with respect to linking separately
59 * compiled library objects into one module. So for now we won't use
60 * separate compilation ... ensuring init/exit sections work to shrink
61 * the runtime footprint, and giving us at least some parts of what
62 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
63 */
64#include "usbstring.c"
65#include "config.c"
66#include "epautoconf.c"
67
68/*-------------------------------------------------------------------------*/
69
56#define DRIVER_DESC "Printer Gadget" 70#define DRIVER_DESC "Printer Gadget"
57#define DRIVER_VERSION "2007 OCT 06" 71#define DRIVER_VERSION "2007 OCT 06"
58 72
@@ -1360,8 +1374,8 @@ printer_bind(struct usb_gadget *gadget)
1360 1374
1361 1375
1362 /* Setup the sysfs files for the printer gadget. */ 1376 /* Setup the sysfs files for the printer gadget. */
1363 dev->pdev = device_create_drvdata(usb_gadget_class, NULL, 1377 dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno,
1364 g_printer_devno, NULL, "g_printer"); 1378 NULL, "g_printer");
1365 if (IS_ERR(dev->pdev)) { 1379 if (IS_ERR(dev->pdev)) {
1366 ERROR(dev, "Failed to create device: g_printer\n"); 1380 ERROR(dev, "Failed to create device: g_printer\n");
1367 goto fail; 1381 goto fail;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 7228e8562236..8c26f5ea2b83 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -57,11 +57,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
57#define rndis_debug 0 57#define rndis_debug 0
58#endif 58#endif
59 59
60#define DBG(str,args...) do { \
61 if (rndis_debug) \
62 pr_debug(str , ## args); \
63 } while (0)
64
65#define RNDIS_MAX_CONFIGS 1 60#define RNDIS_MAX_CONFIGS 1
66 61
67 62
@@ -183,9 +178,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
183 if (!resp) return -ENOMEM; 178 if (!resp) return -ENOMEM;
184 179
185 if (buf_len && rndis_debug > 1) { 180 if (buf_len && rndis_debug > 1) {
186 DBG("query OID %08x value, len %d:\n", OID, buf_len); 181 pr_debug("query OID %08x value, len %d:\n", OID, buf_len);
187 for (i = 0; i < buf_len; i += 16) { 182 for (i = 0; i < buf_len; i += 16) {
188 DBG("%03d: %08x %08x %08x %08x\n", i, 183 pr_debug("%03d: %08x %08x %08x %08x\n", i,
189 get_unaligned_le32(&buf[i]), 184 get_unaligned_le32(&buf[i]),
190 get_unaligned_le32(&buf[i + 4]), 185 get_unaligned_le32(&buf[i + 4]),
191 get_unaligned_le32(&buf[i + 8]), 186 get_unaligned_le32(&buf[i + 8]),
@@ -209,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
209 204
210 /* mandatory */ 205 /* mandatory */
211 case OID_GEN_SUPPORTED_LIST: 206 case OID_GEN_SUPPORTED_LIST:
212 DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); 207 pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
213 length = sizeof (oid_supported_list); 208 length = sizeof (oid_supported_list);
214 count = length / sizeof (u32); 209 count = length / sizeof (u32);
215 for (i = 0; i < count; i++) 210 for (i = 0; i < count; i++)
@@ -219,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
219 214
220 /* mandatory */ 215 /* mandatory */
221 case OID_GEN_HARDWARE_STATUS: 216 case OID_GEN_HARDWARE_STATUS:
222 DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); 217 pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__);
223 /* Bogus question! 218 /* Bogus question!
224 * Hardware must be ready to receive high level protocols. 219 * Hardware must be ready to receive high level protocols.
225 * BTW: 220 * BTW:
@@ -232,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
232 227
233 /* mandatory */ 228 /* mandatory */
234 case OID_GEN_MEDIA_SUPPORTED: 229 case OID_GEN_MEDIA_SUPPORTED:
235 DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); 230 pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
236 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 231 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
237 retval = 0; 232 retval = 0;
238 break; 233 break;
239 234
240 /* mandatory */ 235 /* mandatory */
241 case OID_GEN_MEDIA_IN_USE: 236 case OID_GEN_MEDIA_IN_USE:
242 DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); 237 pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__);
243 /* one medium, one transport... (maybe you do it better) */ 238 /* one medium, one transport... (maybe you do it better) */
244 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 239 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
245 retval = 0; 240 retval = 0;
@@ -247,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
247 242
248 /* mandatory */ 243 /* mandatory */
249 case OID_GEN_MAXIMUM_FRAME_SIZE: 244 case OID_GEN_MAXIMUM_FRAME_SIZE:
250 DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 245 pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__);
251 if (rndis_per_dev_params [configNr].dev) { 246 if (rndis_per_dev_params [configNr].dev) {
252 *outbuf = cpu_to_le32 ( 247 *outbuf = cpu_to_le32 (
253 rndis_per_dev_params [configNr].dev->mtu); 248 rndis_per_dev_params [configNr].dev->mtu);
@@ -258,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
258 /* mandatory */ 253 /* mandatory */
259 case OID_GEN_LINK_SPEED: 254 case OID_GEN_LINK_SPEED:
260 if (rndis_debug > 1) 255 if (rndis_debug > 1)
261 DBG("%s: OID_GEN_LINK_SPEED\n", __func__); 256 pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
262 if (rndis_per_dev_params [configNr].media_state 257 if (rndis_per_dev_params [configNr].media_state
263 == NDIS_MEDIA_STATE_DISCONNECTED) 258 == NDIS_MEDIA_STATE_DISCONNECTED)
264 *outbuf = __constant_cpu_to_le32 (0); 259 *outbuf = __constant_cpu_to_le32 (0);
@@ -270,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
270 265
271 /* mandatory */ 266 /* mandatory */
272 case OID_GEN_TRANSMIT_BLOCK_SIZE: 267 case OID_GEN_TRANSMIT_BLOCK_SIZE:
273 DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 268 pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
274 if (rndis_per_dev_params [configNr].dev) { 269 if (rndis_per_dev_params [configNr].dev) {
275 *outbuf = cpu_to_le32 ( 270 *outbuf = cpu_to_le32 (
276 rndis_per_dev_params [configNr].dev->mtu); 271 rndis_per_dev_params [configNr].dev->mtu);
@@ -280,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
280 275
281 /* mandatory */ 276 /* mandatory */
282 case OID_GEN_RECEIVE_BLOCK_SIZE: 277 case OID_GEN_RECEIVE_BLOCK_SIZE:
283 DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 278 pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
284 if (rndis_per_dev_params [configNr].dev) { 279 if (rndis_per_dev_params [configNr].dev) {
285 *outbuf = cpu_to_le32 ( 280 *outbuf = cpu_to_le32 (
286 rndis_per_dev_params [configNr].dev->mtu); 281 rndis_per_dev_params [configNr].dev->mtu);
@@ -290,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
290 285
291 /* mandatory */ 286 /* mandatory */
292 case OID_GEN_VENDOR_ID: 287 case OID_GEN_VENDOR_ID:
293 DBG("%s: OID_GEN_VENDOR_ID\n", __func__); 288 pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__);
294 *outbuf = cpu_to_le32 ( 289 *outbuf = cpu_to_le32 (
295 rndis_per_dev_params [configNr].vendorID); 290 rndis_per_dev_params [configNr].vendorID);
296 retval = 0; 291 retval = 0;
@@ -298,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
298 293
299 /* mandatory */ 294 /* mandatory */
300 case OID_GEN_VENDOR_DESCRIPTION: 295 case OID_GEN_VENDOR_DESCRIPTION:
301 DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); 296 pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
302 length = strlen (rndis_per_dev_params [configNr].vendorDescr); 297 length = strlen (rndis_per_dev_params [configNr].vendorDescr);
303 memcpy (outbuf, 298 memcpy (outbuf,
304 rndis_per_dev_params [configNr].vendorDescr, length); 299 rndis_per_dev_params [configNr].vendorDescr, length);
@@ -306,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
306 break; 301 break;
307 302
308 case OID_GEN_VENDOR_DRIVER_VERSION: 303 case OID_GEN_VENDOR_DRIVER_VERSION:
309 DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); 304 pr_debug("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__);
310 /* Created as LE */ 305 /* Created as LE */
311 *outbuf = rndis_driver_version; 306 *outbuf = rndis_driver_version;
312 retval = 0; 307 retval = 0;
@@ -314,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
314 309
315 /* mandatory */ 310 /* mandatory */
316 case OID_GEN_CURRENT_PACKET_FILTER: 311 case OID_GEN_CURRENT_PACKET_FILTER:
317 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 312 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
318 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); 313 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter);
319 retval = 0; 314 retval = 0;
320 break; 315 break;
321 316
322 /* mandatory */ 317 /* mandatory */
323 case OID_GEN_MAXIMUM_TOTAL_SIZE: 318 case OID_GEN_MAXIMUM_TOTAL_SIZE:
324 DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 319 pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__);
325 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
326 retval = 0; 321 retval = 0;
327 break; 322 break;
@@ -329,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
329 /* mandatory */ 324 /* mandatory */
330 case OID_GEN_MEDIA_CONNECT_STATUS: 325 case OID_GEN_MEDIA_CONNECT_STATUS:
331 if (rndis_debug > 1) 326 if (rndis_debug > 1)
332 DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 327 pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
333 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 328 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
334 .media_state); 329 .media_state);
335 retval = 0; 330 retval = 0;
336 break; 331 break;
337 332
338 case OID_GEN_PHYSICAL_MEDIUM: 333 case OID_GEN_PHYSICAL_MEDIUM:
339 DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 334 pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
340 *outbuf = __constant_cpu_to_le32 (0); 335 *outbuf = __constant_cpu_to_le32 (0);
341 retval = 0; 336 retval = 0;
342 break; 337 break;
@@ -346,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
346 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! 341 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE!
347 */ 342 */
348 case OID_GEN_MAC_OPTIONS: /* from WinME */ 343 case OID_GEN_MAC_OPTIONS: /* from WinME */
349 DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); 344 pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__);
350 *outbuf = __constant_cpu_to_le32( 345 *outbuf = __constant_cpu_to_le32(
351 NDIS_MAC_OPTION_RECEIVE_SERIALIZED 346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED
352 | NDIS_MAC_OPTION_FULL_DUPLEX); 347 | NDIS_MAC_OPTION_FULL_DUPLEX);
@@ -358,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
358 /* mandatory */ 353 /* mandatory */
359 case OID_GEN_XMIT_OK: 354 case OID_GEN_XMIT_OK:
360 if (rndis_debug > 1) 355 if (rndis_debug > 1)
361 DBG("%s: OID_GEN_XMIT_OK\n", __func__); 356 pr_debug("%s: OID_GEN_XMIT_OK\n", __func__);
362 if (stats) { 357 if (stats) {
363 *outbuf = cpu_to_le32(stats->tx_packets 358 *outbuf = cpu_to_le32(stats->tx_packets
364 - stats->tx_errors - stats->tx_dropped); 359 - stats->tx_errors - stats->tx_dropped);
@@ -369,7 +364,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
369 /* mandatory */ 364 /* mandatory */
370 case OID_GEN_RCV_OK: 365 case OID_GEN_RCV_OK:
371 if (rndis_debug > 1) 366 if (rndis_debug > 1)
372 DBG("%s: OID_GEN_RCV_OK\n", __func__); 367 pr_debug("%s: OID_GEN_RCV_OK\n", __func__);
373 if (stats) { 368 if (stats) {
374 *outbuf = cpu_to_le32(stats->rx_packets 369 *outbuf = cpu_to_le32(stats->rx_packets
375 - stats->rx_errors - stats->rx_dropped); 370 - stats->rx_errors - stats->rx_dropped);
@@ -380,7 +375,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
380 /* mandatory */ 375 /* mandatory */
381 case OID_GEN_XMIT_ERROR: 376 case OID_GEN_XMIT_ERROR:
382 if (rndis_debug > 1) 377 if (rndis_debug > 1)
383 DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); 378 pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__);
384 if (stats) { 379 if (stats) {
385 *outbuf = cpu_to_le32(stats->tx_errors); 380 *outbuf = cpu_to_le32(stats->tx_errors);
386 retval = 0; 381 retval = 0;
@@ -390,7 +385,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
390 /* mandatory */ 385 /* mandatory */
391 case OID_GEN_RCV_ERROR: 386 case OID_GEN_RCV_ERROR:
392 if (rndis_debug > 1) 387 if (rndis_debug > 1)
393 DBG("%s: OID_GEN_RCV_ERROR\n", __func__); 388 pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__);
394 if (stats) { 389 if (stats) {
395 *outbuf = cpu_to_le32(stats->rx_errors); 390 *outbuf = cpu_to_le32(stats->rx_errors);
396 retval = 0; 391 retval = 0;
@@ -399,7 +394,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
399 394
400 /* mandatory */ 395 /* mandatory */
401 case OID_GEN_RCV_NO_BUFFER: 396 case OID_GEN_RCV_NO_BUFFER:
402 DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); 397 pr_debug("%s: OID_GEN_RCV_NO_BUFFER\n", __func__);
403 if (stats) { 398 if (stats) {
404 *outbuf = cpu_to_le32(stats->rx_dropped); 399 *outbuf = cpu_to_le32(stats->rx_dropped);
405 retval = 0; 400 retval = 0;
@@ -410,7 +405,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
410 405
411 /* mandatory */ 406 /* mandatory */
412 case OID_802_3_PERMANENT_ADDRESS: 407 case OID_802_3_PERMANENT_ADDRESS:
413 DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); 408 pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__);
414 if (rndis_per_dev_params [configNr].dev) { 409 if (rndis_per_dev_params [configNr].dev) {
415 length = ETH_ALEN; 410 length = ETH_ALEN;
416 memcpy (outbuf, 411 memcpy (outbuf,
@@ -422,7 +417,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
422 417
423 /* mandatory */ 418 /* mandatory */
424 case OID_802_3_CURRENT_ADDRESS: 419 case OID_802_3_CURRENT_ADDRESS:
425 DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); 420 pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__);
426 if (rndis_per_dev_params [configNr].dev) { 421 if (rndis_per_dev_params [configNr].dev) {
427 length = ETH_ALEN; 422 length = ETH_ALEN;
428 memcpy (outbuf, 423 memcpy (outbuf,
@@ -434,7 +429,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
434 429
435 /* mandatory */ 430 /* mandatory */
436 case OID_802_3_MULTICAST_LIST: 431 case OID_802_3_MULTICAST_LIST:
437 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 432 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
438 /* Multicast base address only */ 433 /* Multicast base address only */
439 *outbuf = __constant_cpu_to_le32 (0xE0000000); 434 *outbuf = __constant_cpu_to_le32 (0xE0000000);
440 retval = 0; 435 retval = 0;
@@ -442,21 +437,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
442 437
443 /* mandatory */ 438 /* mandatory */
444 case OID_802_3_MAXIMUM_LIST_SIZE: 439 case OID_802_3_MAXIMUM_LIST_SIZE:
445 DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 440 pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
446 /* Multicast base address only */ 441 /* Multicast base address only */
447 *outbuf = __constant_cpu_to_le32 (1); 442 *outbuf = __constant_cpu_to_le32 (1);
448 retval = 0; 443 retval = 0;
449 break; 444 break;
450 445
451 case OID_802_3_MAC_OPTIONS: 446 case OID_802_3_MAC_OPTIONS:
452 DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); 447 pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__);
453 break; 448 break;
454 449
455 /* ieee802.3 statistics OIDs (table 4-4) */ 450 /* ieee802.3 statistics OIDs (table 4-4) */
456 451
457 /* mandatory */ 452 /* mandatory */
458 case OID_802_3_RCV_ERROR_ALIGNMENT: 453 case OID_802_3_RCV_ERROR_ALIGNMENT:
459 DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); 454 pr_debug("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__);
460 if (stats) { 455 if (stats) {
461 *outbuf = cpu_to_le32(stats->rx_frame_errors); 456 *outbuf = cpu_to_le32(stats->rx_frame_errors);
462 retval = 0; 457 retval = 0;
@@ -465,14 +460,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
465 460
466 /* mandatory */ 461 /* mandatory */
467 case OID_802_3_XMIT_ONE_COLLISION: 462 case OID_802_3_XMIT_ONE_COLLISION:
468 DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 463 pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
469 *outbuf = __constant_cpu_to_le32 (0); 464 *outbuf = __constant_cpu_to_le32 (0);
470 retval = 0; 465 retval = 0;
471 break; 466 break;
472 467
473 /* mandatory */ 468 /* mandatory */
474 case OID_802_3_XMIT_MORE_COLLISIONS: 469 case OID_802_3_XMIT_MORE_COLLISIONS:
475 DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 470 pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
476 *outbuf = __constant_cpu_to_le32 (0); 471 *outbuf = __constant_cpu_to_le32 (0);
477 retval = 0; 472 retval = 0;
478 break; 473 break;
@@ -504,9 +499,9 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
504 return -ENOMEM; 499 return -ENOMEM;
505 500
506 if (buf_len && rndis_debug > 1) { 501 if (buf_len && rndis_debug > 1) {
507 DBG("set OID %08x value, len %d:\n", OID, buf_len); 502 pr_debug("set OID %08x value, len %d:\n", OID, buf_len);
508 for (i = 0; i < buf_len; i += 16) { 503 for (i = 0; i < buf_len; i += 16) {
509 DBG("%03d: %08x %08x %08x %08x\n", i, 504 pr_debug("%03d: %08x %08x %08x %08x\n", i,
510 get_unaligned_le32(&buf[i]), 505 get_unaligned_le32(&buf[i]),
511 get_unaligned_le32(&buf[i + 4]), 506 get_unaligned_le32(&buf[i + 4]),
512 get_unaligned_le32(&buf[i + 8]), 507 get_unaligned_le32(&buf[i + 8]),
@@ -525,7 +520,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
525 * MULTICAST, ALL_MULTICAST, BROADCAST 520 * MULTICAST, ALL_MULTICAST, BROADCAST
526 */ 521 */
527 *params->filter = (u16)get_unaligned_le32(buf); 522 *params->filter = (u16)get_unaligned_le32(buf);
528 DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 523 pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n",
529 __func__, *params->filter); 524 __func__, *params->filter);
530 525
531 /* this call has a significant side effect: it's 526 /* this call has a significant side effect: it's
@@ -547,7 +542,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
547 542
548 case OID_802_3_MULTICAST_LIST: 543 case OID_802_3_MULTICAST_LIST:
549 /* I think we can ignore this */ 544 /* I think we can ignore this */
550 DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 545 pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
551 retval = 0; 546 retval = 0;
552 break; 547 break;
553 548
@@ -606,7 +601,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
606 rndis_resp_t *r; 601 rndis_resp_t *r;
607 struct rndis_params *params = rndis_per_dev_params + configNr; 602 struct rndis_params *params = rndis_per_dev_params + configNr;
608 603
609 // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); 604 /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */
610 if (!params->dev) 605 if (!params->dev)
611 return -ENOTSUPP; 606 return -ENOTSUPP;
612 607
@@ -659,15 +654,15 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
659 BufOffset = le32_to_cpu (buf->InformationBufferOffset); 654 BufOffset = le32_to_cpu (buf->InformationBufferOffset);
660 655
661#ifdef VERBOSE_DEBUG 656#ifdef VERBOSE_DEBUG
662 DBG("%s: Length: %d\n", __func__, BufLength); 657 pr_debug("%s: Length: %d\n", __func__, BufLength);
663 DBG("%s: Offset: %d\n", __func__, BufOffset); 658 pr_debug("%s: Offset: %d\n", __func__, BufOffset);
664 DBG("%s: InfoBuffer: ", __func__); 659 pr_debug("%s: InfoBuffer: ", __func__);
665 660
666 for (i = 0; i < BufLength; i++) { 661 for (i = 0; i < BufLength; i++) {
667 DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 662 pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset));
668 } 663 }
669 664
670 DBG("\n"); 665 pr_debug("\n");
671#endif 666#endif
672 667
673 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); 668 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT);
@@ -821,14 +816,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
821 /* For USB: responses may take up to 10 seconds */ 816 /* For USB: responses may take up to 10 seconds */
822 switch (MsgType) { 817 switch (MsgType) {
823 case REMOTE_NDIS_INITIALIZE_MSG: 818 case REMOTE_NDIS_INITIALIZE_MSG:
824 DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 819 pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
825 __func__ ); 820 __func__ );
826 params->state = RNDIS_INITIALIZED; 821 params->state = RNDIS_INITIALIZED;
827 return rndis_init_response (configNr, 822 return rndis_init_response (configNr,
828 (rndis_init_msg_type *) buf); 823 (rndis_init_msg_type *) buf);
829 824
830 case REMOTE_NDIS_HALT_MSG: 825 case REMOTE_NDIS_HALT_MSG:
831 DBG("%s: REMOTE_NDIS_HALT_MSG\n", 826 pr_debug("%s: REMOTE_NDIS_HALT_MSG\n",
832 __func__ ); 827 __func__ );
833 params->state = RNDIS_UNINITIALIZED; 828 params->state = RNDIS_UNINITIALIZED;
834 if (params->dev) { 829 if (params->dev) {
@@ -846,7 +841,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
846 (rndis_set_msg_type *) buf); 841 (rndis_set_msg_type *) buf);
847 842
848 case REMOTE_NDIS_RESET_MSG: 843 case REMOTE_NDIS_RESET_MSG:
849 DBG("%s: REMOTE_NDIS_RESET_MSG\n", 844 pr_debug("%s: REMOTE_NDIS_RESET_MSG\n",
850 __func__ ); 845 __func__ );
851 return rndis_reset_response (configNr, 846 return rndis_reset_response (configNr,
852 (rndis_reset_msg_type *) buf); 847 (rndis_reset_msg_type *) buf);
@@ -854,7 +849,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
854 case REMOTE_NDIS_KEEPALIVE_MSG: 849 case REMOTE_NDIS_KEEPALIVE_MSG:
855 /* For USB: host does this every 5 seconds */ 850 /* For USB: host does this every 5 seconds */
856 if (rndis_debug > 1) 851 if (rndis_debug > 1)
857 DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 852 pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
858 __func__ ); 853 __func__ );
859 return rndis_keepalive_response (configNr, 854 return rndis_keepalive_response (configNr,
860 (rndis_keepalive_msg_type *) 855 (rndis_keepalive_msg_type *)
@@ -870,7 +865,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
870 { 865 {
871 unsigned i; 866 unsigned i;
872 for (i = 0; i < MsgLength; i += 16) { 867 for (i = 0; i < MsgLength; i += 16) {
873 DBG("%03d: " 868 pr_debug("%03d: "
874 " %02x %02x %02x %02x" 869 " %02x %02x %02x %02x"
875 " %02x %02x %02x %02x" 870 " %02x %02x %02x %02x"
876 " %02x %02x %02x %02x" 871 " %02x %02x %02x %02x"
@@ -905,18 +900,18 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
905 rndis_per_dev_params [i].used = 1; 900 rndis_per_dev_params [i].used = 1;
906 rndis_per_dev_params [i].resp_avail = resp_avail; 901 rndis_per_dev_params [i].resp_avail = resp_avail;
907 rndis_per_dev_params [i].v = v; 902 rndis_per_dev_params [i].v = v;
908 DBG("%s: configNr = %d\n", __func__, i); 903 pr_debug("%s: configNr = %d\n", __func__, i);
909 return i; 904 return i;
910 } 905 }
911 } 906 }
912 DBG("failed\n"); 907 pr_debug("failed\n");
913 908
914 return -ENODEV; 909 return -ENODEV;
915} 910}
916 911
917void rndis_deregister (int configNr) 912void rndis_deregister (int configNr)
918{ 913{
919 DBG("%s: \n", __func__ ); 914 pr_debug("%s: \n", __func__);
920 915
921 if (configNr >= RNDIS_MAX_CONFIGS) return; 916 if (configNr >= RNDIS_MAX_CONFIGS) return;
922 rndis_per_dev_params [configNr].used = 0; 917 rndis_per_dev_params [configNr].used = 0;
@@ -926,7 +921,7 @@ void rndis_deregister (int configNr)
926 921
927int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) 922int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
928{ 923{
929 DBG("%s:\n", __func__ ); 924 pr_debug("%s:\n", __func__);
930 if (!dev) 925 if (!dev)
931 return -EINVAL; 926 return -EINVAL;
932 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 927 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
@@ -939,7 +934,7 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
939 934
940int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) 935int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
941{ 936{
942 DBG("%s:\n", __func__ ); 937 pr_debug("%s:\n", __func__);
943 if (!vendorDescr) return -1; 938 if (!vendorDescr) return -1;
944 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 939 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
945 940
@@ -951,7 +946,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
951 946
952int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) 947int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
953{ 948{
954 DBG("%s: %u %u\n", __func__, medium, speed); 949 pr_debug("%s: %u %u\n", __func__, medium, speed);
955 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 950 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
956 951
957 rndis_per_dev_params [configNr].medium = medium; 952 rndis_per_dev_params [configNr].medium = medium;
@@ -1114,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
1114 break; 1109 break;
1115 default: 1110 default:
1116 if (fl_speed) p->speed = speed; 1111 if (fl_speed) p->speed = speed;
1117 else DBG("%c is not valid\n", c); 1112 else pr_debug("%c is not valid\n", c);
1118 break; 1113 break;
1119 } 1114 }
1120 1115
@@ -1159,12 +1154,12 @@ int __init rndis_init (void)
1159 &rndis_proc_fops, 1154 &rndis_proc_fops,
1160 (void *)(rndis_per_dev_params + i)))) 1155 (void *)(rndis_per_dev_params + i))))
1161 { 1156 {
1162 DBG("%s :remove entries", __func__); 1157 pr_debug("%s :remove entries", __func__);
1163 while (i) { 1158 while (i) {
1164 sprintf (name, NAME_TEMPLATE, --i); 1159 sprintf (name, NAME_TEMPLATE, --i);
1165 remove_proc_entry (name, NULL); 1160 remove_proc_entry (name, NULL);
1166 } 1161 }
1167 DBG("\n"); 1162 pr_debug("\n");
1168 return -EIO; 1163 return -EIO;
1169 } 1164 }
1170#endif 1165#endif
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index b3699afff002..3faa7a7022df 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -30,6 +30,24 @@
30 30
31/*-------------------------------------------------------------------------*/ 31/*-------------------------------------------------------------------------*/
32 32
33/*
34 * Kbuild is not very cooperative with respect to linking separately
35 * compiled library objects into one module. So for now we won't use
36 * separate compilation ... ensuring init/exit sections work to shrink
37 * the runtime footprint, and giving us at least some parts of what
38 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
39 */
40#include "composite.c"
41#include "usbstring.c"
42#include "config.c"
43#include "epautoconf.c"
44
45#include "f_acm.c"
46#include "f_serial.c"
47#include "u_serial.c"
48
49/*-------------------------------------------------------------------------*/
50
33/* Thanks to NetChip Technologies for donating this product ID. 51/* Thanks to NetChip Technologies for donating this product ID.
34* 52*
35* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 53* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 3791e6271903..dbd575a194f3 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -52,7 +52,7 @@
52 * this single "physical" link to be used by multiple virtual links.) 52 * this single "physical" link to be used by multiple virtual links.)
53 */ 53 */
54 54
55#define DRIVER_VERSION "29-May-2008" 55#define UETH__VERSION "29-May-2008"
56 56
57struct eth_dev { 57struct eth_dev {
58 /* lock is held while accessing port_usb 58 /* lock is held while accessing port_usb
@@ -170,7 +170,7 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
170 struct eth_dev *dev = netdev_priv(net); 170 struct eth_dev *dev = netdev_priv(net);
171 171
172 strlcpy(p->driver, "g_ether", sizeof p->driver); 172 strlcpy(p->driver, "g_ether", sizeof p->driver);
173 strlcpy(p->version, DRIVER_VERSION, sizeof p->version); 173 strlcpy(p->version, UETH__VERSION, sizeof p->version);
174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version); 174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version);
175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); 175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info);
176} 176}
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index aa0bd4f126a1..361d9659ac48 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -59,6 +59,23 @@
59 59
60/*-------------------------------------------------------------------------*/ 60/*-------------------------------------------------------------------------*/
61 61
62/*
63 * Kbuild is not very cooperative with respect to linking separately
64 * compiled library objects into one module. So for now we won't use
65 * separate compilation ... ensuring init/exit sections work to shrink
66 * the runtime footprint, and giving us at least some parts of what
67 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
68 */
69#include "composite.c"
70#include "usbstring.c"
71#include "config.c"
72#include "epautoconf.c"
73
74#include "f_sourcesink.c"
75#include "f_loopback.c"
76
77/*-------------------------------------------------------------------------*/
78
62#define DRIVER_VERSION "Cinco de Mayo 2008" 79#define DRIVER_VERSION "Cinco de Mayo 2008"
63 80
64static const char longname[] = "Gadget Zero"; 81static const char longname[] = "Gadget Zero";
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index db645936eedd..1f0c2cf26e5d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
123 123
124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) 124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
125{ 125{
126 if (!list_empty(&td->list)) { 126 if (!list_empty(&td->list))
127 dev_warn(uhci_dev(uhci), "td %p still in list!\n", td); 127 dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td);
128 WARN_ON(1); 128 if (!list_empty(&td->fl_list))
129 } 129 dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td);
130 if (!list_empty(&td->fl_list)) {
131 dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td);
132 WARN_ON(1);
133 }
134 130
135 dma_pool_free(uhci->td_pool, td, td->dma_handle); 131 dma_pool_free(uhci->td_pool, td, td->dma_handle);
136} 132}
@@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
295static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) 291static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
296{ 292{
297 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); 293 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
298 if (!list_empty(&qh->queue)) { 294 if (!list_empty(&qh->queue))
299 dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); 295 dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh);
300 WARN_ON(1);
301 }
302 296
303 list_del(&qh->node); 297 list_del(&qh->node);
304 if (qh->udev) { 298 if (qh->udev) {
@@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci,
746{ 740{
747 struct uhci_td *td, *tmp; 741 struct uhci_td *td, *tmp;
748 742
749 if (!list_empty(&urbp->node)) { 743 if (!list_empty(&urbp->node))
750 dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", 744 dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n",
751 urbp->urb); 745 urbp->urb);
752 WARN_ON(1);
753 }
754 746
755 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { 747 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
756 uhci_remove_td_from_urbp(td); 748 uhci_remove_td_from_urbp(td);
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 4cfa25b0f44e..cc8e0a926f99 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -595,9 +595,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
595 } while(value); 595 } while(value);
596 kit->dev_no = bit; 596 kit->dev_no = bit;
597 597
598 kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev, 598 kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0),
599 MKDEV(0, 0), kit, 599 kit, "interfacekit%d", kit->dev_no);
600 "interfacekit%d", kit->dev_no);
601 if (IS_ERR(kit->dev)) { 600 if (IS_ERR(kit->dev)) {
602 rc = PTR_ERR(kit->dev); 601 rc = PTR_ERR(kit->dev);
603 kit->dev = NULL; 602 kit->dev = NULL;
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 9b4696f21b22..38088b44349e 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -365,9 +365,8 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
365 } while(value); 365 } while(value);
366 mc->dev_no = bit; 366 mc->dev_no = bit;
367 367
368 mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev, 368 mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc,
369 MKDEV(0, 0), mc, 369 "motorcontrol%d", mc->dev_no);
370 "motorcontrol%d", mc->dev_no);
371 if (IS_ERR(mc->dev)) { 370 if (IS_ERR(mc->dev)) {
372 rc = PTR_ERR(mc->dev); 371 rc = PTR_ERR(mc->dev);
373 mc->dev = NULL; 372 mc->dev = NULL;
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 1ca7ddb41d4d..bef6fe16364b 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -275,9 +275,8 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
275 } while (value); 275 } while (value);
276 dev->dev_no = bit; 276 dev->dev_no = bit;
277 277
278 dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev, 278 dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0),
279 MKDEV(0, 0), dev, 279 dev, "servo%d", dev->dev_no);
280 "servo%d", dev->dev_no);
281 if (IS_ERR(dev->dev)) { 280 if (IS_ERR(dev->dev)) {
282 rc = PTR_ERR(dev->dev); 281 rc = PTR_ERR(dev->dev);
283 dev->dev = NULL; 282 dev->dev = NULL;
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 6566fc0a3228..c9de3f027aab 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1162,9 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
1162 if (minor >= MON_BIN_MAX_MINOR) 1162 if (minor >= MON_BIN_MAX_MINOR)
1163 return 0; 1163 return 0;
1164 1164
1165 dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL, 1165 dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL,
1166 MKDEV(MAJOR(mon_bin_dev0), minor), NULL, 1166 MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167 "usbmon%d", minor); 1167 "usbmon%d", minor);
1168 if (IS_ERR(dev)) 1168 if (IS_ERR(dev))
1169 return 0; 1169 return 0;
1170 1170
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 93a080e827cc..64b3d30027b8 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -3573,8 +3573,8 @@ static int __init fb_console_init(void)
3573 3573
3574 acquire_console_sem(); 3574 acquire_console_sem();
3575 fb_register_client(&fbcon_event_notifier); 3575 fb_register_client(&fbcon_event_notifier);
3576 fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0), 3576 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3577 NULL, "fbcon"); 3577 "fbcon");
3578 3578
3579 if (IS_ERR(fbcon_device)) { 3579 if (IS_ERR(fbcon_device)) {
3580 printk(KERN_WARNING "Unable to create device " 3580 printk(KERN_WARNING "Unable to create device "
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
index 6ef800bdf482..4830b1bf51e5 100644
--- a/drivers/video/display/display-sysfs.c
+++ b/drivers/video/display/display-sysfs.c
@@ -153,12 +153,9 @@ struct display_device *display_device_register(struct display_driver *driver,
153 mutex_unlock(&allocated_dsp_lock); 153 mutex_unlock(&allocated_dsp_lock);
154 154
155 if (!ret) { 155 if (!ret) {
156 new_dev->dev = device_create_drvdata(display_class, 156 new_dev->dev = device_create(display_class, parent,
157 parent, 157 MKDEV(0, 0), new_dev,
158 MKDEV(0,0), 158 "display%d", new_dev->idx);
159 new_dev,
160 "display%d",
161 new_dev->idx);
162 if (!IS_ERR(new_dev->dev)) { 159 if (!IS_ERR(new_dev->dev)) {
163 new_dev->parent = parent; 160 new_dev->parent = parent;
164 new_dev->driver = driver; 161 new_dev->driver = driver;
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 3f18bb9abad0..217c5118ae9e 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1430,9 +1430,8 @@ register_framebuffer(struct fb_info *fb_info)
1430 break; 1430 break;
1431 fb_info->node = i; 1431 fb_info->node = i;
1432 1432
1433 fb_info->dev = device_create_drvdata(fb_class, fb_info->device, 1433 fb_info->dev = device_create(fb_class, fb_info->device,
1434 MKDEV(FB_MAJOR, i), NULL, 1434 MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
1435 "fb%d", i);
1436 if (IS_ERR(fb_info->dev)) { 1435 if (IS_ERR(fb_info->dev)) {
1437 /* Not fatal */ 1436 /* Not fatal */
1438 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev)); 1437 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 0d9b80ec689c..cfd29da714d1 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -362,9 +362,8 @@ static int init_coda_psdev(void)
362 goto out_chrdev; 362 goto out_chrdev;
363 } 363 }
364 for (i = 0; i < MAX_CODADEVS; i++) 364 for (i = 0; i < MAX_CODADEVS; i++)
365 device_create_drvdata(coda_psdev_class, NULL, 365 device_create(coda_psdev_class, NULL,
366 MKDEV(CODA_PSDEV_MAJOR, i), 366 MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i);
367 NULL, "cfs%d", i);
368 coda_sysctl_init(); 367 coda_sysctl_init();
369 goto out; 368 goto out;
370 369
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 006fc64227dd..66f6e58a7e4b 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -61,6 +61,7 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off)
61 int size = dentry->d_inode->i_size; 61 int size = dentry->d_inode->i_size;
62 loff_t offs = *off; 62 loff_t offs = *off;
63 int count = min_t(size_t, bytes, PAGE_SIZE); 63 int count = min_t(size_t, bytes, PAGE_SIZE);
64 char *temp;
64 65
65 if (size) { 66 if (size) {
66 if (offs > size) 67 if (offs > size)
@@ -69,23 +70,33 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off)
69 count = size - offs; 70 count = size - offs;
70 } 71 }
71 72
73 temp = kmalloc(count, GFP_KERNEL);
74 if (!temp)
75 return -ENOMEM;
76
72 mutex_lock(&bb->mutex); 77 mutex_lock(&bb->mutex);
73 78
74 count = fill_read(dentry, bb->buffer, offs, count); 79 count = fill_read(dentry, bb->buffer, offs, count);
75 if (count < 0) 80 if (count < 0) {
76 goto out_unlock; 81 mutex_unlock(&bb->mutex);
82 goto out_free;
83 }
77 84
78 if (copy_to_user(userbuf, bb->buffer, count)) { 85 memcpy(temp, bb->buffer, count);
86
87 mutex_unlock(&bb->mutex);
88
89 if (copy_to_user(userbuf, temp, count)) {
79 count = -EFAULT; 90 count = -EFAULT;
80 goto out_unlock; 91 goto out_free;
81 } 92 }
82 93
83 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count); 94 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count);
84 95
85 *off = offs + count; 96 *off = offs + count;
86 97
87 out_unlock: 98 out_free:
88 mutex_unlock(&bb->mutex); 99 kfree(temp);
89 return count; 100 return count;
90} 101}
91 102
@@ -118,6 +129,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
118 int size = dentry->d_inode->i_size; 129 int size = dentry->d_inode->i_size;
119 loff_t offs = *off; 130 loff_t offs = *off;
120 int count = min_t(size_t, bytes, PAGE_SIZE); 131 int count = min_t(size_t, bytes, PAGE_SIZE);
132 char *temp;
121 133
122 if (size) { 134 if (size) {
123 if (offs > size) 135 if (offs > size)
@@ -126,19 +138,27 @@ static ssize_t write(struct file *file, const char __user *userbuf,
126 count = size - offs; 138 count = size - offs;
127 } 139 }
128 140
129 mutex_lock(&bb->mutex); 141 temp = kmalloc(count, GFP_KERNEL);
142 if (!temp)
143 return -ENOMEM;
130 144
131 if (copy_from_user(bb->buffer, userbuf, count)) { 145 if (copy_from_user(temp, userbuf, count)) {
132 count = -EFAULT; 146 count = -EFAULT;
133 goto out_unlock; 147 goto out_free;
134 } 148 }
135 149
150 mutex_lock(&bb->mutex);
151
152 memcpy(bb->buffer, temp, count);
153
136 count = flush_write(dentry, bb->buffer, offs, count); 154 count = flush_write(dentry, bb->buffer, offs, count);
155 mutex_unlock(&bb->mutex);
156
137 if (count > 0) 157 if (count > 0)
138 *off = offs + count; 158 *off = offs + count;
139 159
140 out_unlock: 160out_free:
141 mutex_unlock(&bb->mutex); 161 kfree(temp);
142 return count; 162 return count;
143} 163}
144 164
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aedaeba82ae5..3a05a596e3b4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
370 memset(acxt, 0, sizeof(*acxt)); 370 memset(acxt, 0, sizeof(*acxt));
371 acxt->parent_sd = parent_sd; 371 acxt->parent_sd = parent_sd;
372 372
373 /* Lookup parent inode. inode initialization and I_NEW 373 /* Lookup parent inode. inode initialization is protected by
374 * clearing are protected by sysfs_mutex. By grabbing it and 374 * sysfs_mutex, so inode existence can be determined by
375 * looking up with _nowait variant, inode state can be 375 * looking up inode while holding sysfs_mutex.
376 * determined reliably.
377 */ 376 */
378 mutex_lock(&sysfs_mutex); 377 mutex_lock(&sysfs_mutex);
379 378
380 inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, 379 inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
381 parent_sd); 380 parent_sd);
381 if (inode) {
382 WARN_ON(inode->i_state & I_NEW);
382 383
383 if (inode && !(inode->i_state & I_NEW)) {
384 /* parent inode available */ 384 /* parent inode available */
385 acxt->parent_inode = inode; 385 acxt->parent_inode = inode;
386 386
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
393 mutex_lock(&inode->i_mutex); 393 mutex_lock(&inode->i_mutex);
394 mutex_lock(&sysfs_mutex); 394 mutex_lock(&sysfs_mutex);
395 } 395 }
396 } else 396 }
397 iput(inode);
398} 397}
399 398
400/** 399/**
@@ -636,6 +635,7 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
636 635
637 return sd; 636 return sd;
638} 637}
638EXPORT_SYMBOL_GPL(sysfs_get_dirent);
639 639
640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, 640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
641 const char *name, struct sysfs_dirent **p_sd) 641 const char *name, struct sysfs_dirent **p_sd)
@@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
829 if (!new_dentry) 829 if (!new_dentry)
830 goto out_unlock; 830 goto out_unlock;
831 831
832 /* rename kobject and sysfs_dirent */ 832 /* rename sysfs_dirent */
833 error = -ENOMEM; 833 error = -ENOMEM;
834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL); 834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
835 if (!new_name) 835 if (!new_name)
836 goto out_unlock; 836 goto out_unlock;
837 837
838 error = kobject_set_name(kobj, "%s", new_name);
839 if (error)
840 goto out_unlock;
841
842 dup_name = sd->s_name; 838 dup_name = sd->s_name;
843 sd->s_name = new_name; 839 sd->s_name = new_name;
844 840
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index c9e4e5091da1..1f4a3f877262 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -19,10 +19,18 @@
19#include <linux/poll.h> 19#include <linux/poll.h>
20#include <linux/list.h> 20#include <linux/list.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/limits.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
24#include "sysfs.h" 25#include "sysfs.h"
25 26
27/* used in crash dumps to help with debugging */
28static char last_sysfs_file[PATH_MAX];
29void sysfs_printk_last_file(void)
30{
31 printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
32}
33
26/* 34/*
27 * There's one sysfs_buffer for each open file and one 35 * There's one sysfs_buffer for each open file and one
28 * sysfs_open_dirent for each sysfs_dirent with one or more open 36 * sysfs_open_dirent for each sysfs_dirent with one or more open
@@ -328,6 +336,11 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
328 struct sysfs_buffer *buffer; 336 struct sysfs_buffer *buffer;
329 struct sysfs_ops *ops; 337 struct sysfs_ops *ops;
330 int error = -EACCES; 338 int error = -EACCES;
339 char *p;
340
341 p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
342 if (p)
343 memmove(last_sysfs_file, p, strlen(p) + 1);
331 344
332 /* need attr_sd for attr and ops, its parent for kobj */ 345 /* need attr_sd for attr and ops, its parent for kobj */
333 if (!sysfs_get_active_two(attr_sd)) 346 if (!sysfs_get_active_two(attr_sd))
@@ -440,7 +453,23 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
440 return POLLERR|POLLPRI; 453 return POLLERR|POLLPRI;
441} 454}
442 455
443void sysfs_notify(struct kobject *k, char *dir, char *attr) 456void sysfs_notify_dirent(struct sysfs_dirent *sd)
457{
458 struct sysfs_open_dirent *od;
459
460 spin_lock(&sysfs_open_dirent_lock);
461
462 od = sd->s_attr.open;
463 if (od) {
464 atomic_inc(&od->event);
465 wake_up_interruptible(&od->poll);
466 }
467
468 spin_unlock(&sysfs_open_dirent_lock);
469}
470EXPORT_SYMBOL_GPL(sysfs_notify_dirent);
471
472void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
444{ 473{
445 struct sysfs_dirent *sd = k->sd; 474 struct sysfs_dirent *sd = k->sd;
446 475
@@ -450,19 +479,8 @@ void sysfs_notify(struct kobject *k, char *dir, char *attr)
450 sd = sysfs_find_dirent(sd, dir); 479 sd = sysfs_find_dirent(sd, dir);
451 if (sd && attr) 480 if (sd && attr)
452 sd = sysfs_find_dirent(sd, attr); 481 sd = sysfs_find_dirent(sd, attr);
453 if (sd) { 482 if (sd)
454 struct sysfs_open_dirent *od; 483 sysfs_notify_dirent(sd);
455
456 spin_lock(&sysfs_open_dirent_lock);
457
458 od = sd->s_attr.open;
459 if (od) {
460 atomic_inc(&od->event);
461 wake_up_interruptible(&od->poll);
462 }
463
464 spin_unlock(&sysfs_open_dirent_lock);
465 }
466 484
467 mutex_unlock(&sysfs_mutex); 485 mutex_unlock(&sysfs_mutex);
468} 486}
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 14f0023984d7..ab343e371d64 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -16,6 +16,7 @@
16#include <linux/mount.h> 16#include <linux/mount.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h>
19 20
20#include "sysfs.h" 21#include "sysfs.h"
21 22
@@ -115,3 +116,17 @@ out_err:
115 sysfs_dir_cachep = NULL; 116 sysfs_dir_cachep = NULL;
116 goto out; 117 goto out;
117} 118}
119
120#undef sysfs_get
121struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
122{
123 return __sysfs_get(sd);
124}
125EXPORT_SYMBOL_GPL(sysfs_get);
126
127#undef sysfs_put
128void sysfs_put(struct sysfs_dirent *sd)
129{
130 __sysfs_put(sd);
131}
132EXPORT_SYMBOL_GPL(sysfs_put);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index a5db496f71c7..93c6d6b27c4d 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -124,7 +124,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name,
124 struct sysfs_dirent **p_sd); 124 struct sysfs_dirent **p_sd);
125void sysfs_remove_subdir(struct sysfs_dirent *sd); 125void sysfs_remove_subdir(struct sysfs_dirent *sd);
126 126
127static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 127static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd)
128{ 128{
129 if (sd) { 129 if (sd) {
130 WARN_ON(!atomic_read(&sd->s_count)); 130 WARN_ON(!atomic_read(&sd->s_count));
@@ -132,12 +132,14 @@ static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
132 } 132 }
133 return sd; 133 return sd;
134} 134}
135#define sysfs_get(sd) __sysfs_get(sd)
135 136
136static inline void sysfs_put(struct sysfs_dirent *sd) 137static inline void __sysfs_put(struct sysfs_dirent *sd)
137{ 138{
138 if (sd && atomic_dec_and_test(&sd->s_count)) 139 if (sd && atomic_dec_and_test(&sd->s_count))
139 release_sysfs_dirent(sd); 140 release_sysfs_dirent(sd);
140} 141}
142#define sysfs_put(sd) __sysfs_put(sd)
141 143
142/* 144/*
143 * inode.c 145 * inode.c
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 7440a0dceddb..74c5faf26c05 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -268,7 +268,15 @@
268 CPU_DISCARD(init.data) \ 268 CPU_DISCARD(init.data) \
269 CPU_DISCARD(init.rodata) \ 269 CPU_DISCARD(init.rodata) \
270 MEM_DISCARD(init.data) \ 270 MEM_DISCARD(init.data) \
271 MEM_DISCARD(init.rodata) 271 MEM_DISCARD(init.rodata) \
272 /* implement dynamic printk debug */ \
273 VMLINUX_SYMBOL(__start___verbose_strings) = .; \
274 *(__verbose_strings) \
275 VMLINUX_SYMBOL(__stop___verbose_strings) = .; \
276 . = ALIGN(8); \
277 VMLINUX_SYMBOL(__start___verbose) = .; \
278 *(__verbose) \
279 VMLINUX_SYMBOL(__stop___verbose) = .;
272 280
273#define INIT_TEXT \ 281#define INIT_TEXT \
274 *(.init.text) \ 282 *(.init.text) \
diff --git a/include/linux/device.h b/include/linux/device.h
index 246937c9cbc7..987f5912720a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
90 struct device_driver *start, void *data, 90 struct device_driver *start, void *data,
91 int (*fn)(struct device_driver *, void *)); 91 int (*fn)(struct device_driver *, void *));
92 92
93void bus_sort_breadthfirst(struct bus_type *bus,
94 int (*compare)(const struct device *a,
95 const struct device *b));
93/* 96/*
94 * Bus notifiers: Get notified of addition/removal of devices 97 * Bus notifiers: Get notified of addition/removal of devices
95 * and binding/unbinding of drivers to devices. 98 * and binding/unbinding of drivers to devices.
@@ -502,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
502 dev_t devt, void *drvdata, 505 dev_t devt, void *drvdata,
503 const char *fmt, ...) 506 const char *fmt, ...)
504 __attribute__((format(printf, 5, 6))); 507 __attribute__((format(printf, 5, 6)));
505#define device_create_drvdata device_create
506extern void device_destroy(struct class *cls, dev_t devt); 508extern void device_destroy(struct class *cls, dev_t devt);
507 509
508/* 510/*
@@ -551,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev);
551#define dev_info(dev, format, arg...) \ 553#define dev_info(dev, format, arg...) \
552 dev_printk(KERN_INFO , dev , format , ## arg) 554 dev_printk(KERN_INFO , dev , format , ## arg)
553 555
554#ifdef DEBUG 556#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
557#define dev_dbg(dev, format, ...) do { \
558 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
559 } while (0)
560#elif defined(DEBUG)
555#define dev_dbg(dev, format, arg...) \ 561#define dev_dbg(dev, format, arg...) \
556 dev_printk(KERN_DEBUG , dev , format , ## arg) 562 dev_printk(KERN_DEBUG , dev , format , ## arg)
557#else 563#else
@@ -567,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev);
567 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
568#endif 574#endif
569 575
576/*
577 * dev_WARN() acts like dev_printk(), but with the key difference
578 * of using a WARN/WARN_ON to get the message out, including the
579 * file/line information and a backtrace.
580 */
581#define dev_WARN(dev, format, arg...) \
582 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
583
570/* Create alias, so I can be autoloaded. */ 584/* Create alias, so I can be autoloaded. */
571#define MODULE_ALIAS_CHARDEV(major,minor) \ 585#define MODULE_ALIAS_CHARDEV(major,minor) \
572 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/dynamic_printk.h b/include/linux/dynamic_printk.h
new file mode 100644
index 000000000000..2d528d009074
--- /dev/null
+++ b/include/linux/dynamic_printk.h
@@ -0,0 +1,93 @@
1#ifndef _DYNAMIC_PRINTK_H
2#define _DYNAMIC_PRINTK_H
3
4#define DYNAMIC_DEBUG_HASH_BITS 6
5#define DEBUG_HASH_TABLE_SIZE (1 << DYNAMIC_DEBUG_HASH_BITS)
6
7#define TYPE_BOOLEAN 1
8
9#define DYNAMIC_ENABLED_ALL 0
10#define DYNAMIC_ENABLED_NONE 1
11#define DYNAMIC_ENABLED_SOME 2
12
13extern int dynamic_enabled;
14
15/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
16 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
17 * use independent hash functions, to reduce the chance of false positives.
18 */
19extern long long dynamic_printk_enabled;
20extern long long dynamic_printk_enabled2;
21
22struct mod_debug {
23 char *modname;
24 char *logical_modname;
25 char *flag_names;
26 int type;
27 int hash;
28 int hash2;
29} __attribute__((aligned(8)));
30
31int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
32 char *flags, int hash, int hash2);
33
34#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
35extern int unregister_dynamic_debug_module(char *mod_name);
36extern int __dynamic_dbg_enabled_helper(char *modname, int type,
37 int value, int hash);
38
39#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ \
40 int __ret = 0; \
41 if (unlikely((dynamic_printk_enabled & (1LL << DEBUG_HASH)) && \
42 (dynamic_printk_enabled2 & (1LL << DEBUG_HASH2)))) \
43 __ret = __dynamic_dbg_enabled_helper(module, type, \
44 value, hash);\
45 __ret; })
46
47#define dynamic_pr_debug(fmt, ...) do { \
48 static char mod_name[] \
49 __attribute__((section("__verbose_strings"))) \
50 = KBUILD_MODNAME; \
51 static struct mod_debug descriptor \
52 __used \
53 __attribute__((section("__verbose"), aligned(8))) = \
54 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
55 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
56 0, 0, DEBUG_HASH)) \
57 printk(KERN_DEBUG KBUILD_MODNAME ":" fmt, \
58 ##__VA_ARGS__); \
59 } while (0)
60
61#define dynamic_dev_dbg(dev, format, ...) do { \
62 static char mod_name[] \
63 __attribute__((section("__verbose_strings"))) \
64 = KBUILD_MODNAME; \
65 static struct mod_debug descriptor \
66 __used \
67 __attribute__((section("__verbose"), aligned(8))) = \
68 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
69 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
70 0, 0, DEBUG_HASH)) \
71 dev_printk(KERN_DEBUG, dev, \
72 KBUILD_MODNAME ": " format, \
73 ##__VA_ARGS__); \
74 } while (0)
75
76#else
77
78static inline int unregister_dynamic_debug_module(const char *mod_name)
79{
80 return 0;
81}
82static inline int __dynamic_dbg_enabled_helper(char *modname, int type,
83 int value, int hash)
84{
85 return 0;
86}
87
88#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ 0; })
89#define dynamic_pr_debug(fmt, ...) do { } while (0)
90#define dynamic_dev_dbg(dev, format, ...) do { } while (0)
91#endif
92
93#endif
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e971c55f45ac..1f3cd8ad0523 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -16,6 +16,7 @@
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/typecheck.h> 17#include <linux/typecheck.h>
18#include <linux/ratelimit.h> 18#include <linux/ratelimit.h>
19#include <linux/dynamic_printk.h>
19#include <asm/byteorder.h> 20#include <asm/byteorder.h>
20#include <asm/bug.h> 21#include <asm/bug.h>
21 22
@@ -304,8 +305,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
304#define pr_info(fmt, arg...) \ 305#define pr_info(fmt, arg...) \
305 printk(KERN_INFO fmt, ##arg) 306 printk(KERN_INFO fmt, ##arg)
306 307
307#ifdef DEBUG
308/* If you are writing a driver, please use dev_dbg instead */ 308/* If you are writing a driver, please use dev_dbg instead */
309#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
310#define pr_debug(fmt, ...) do { \
311 dynamic_pr_debug(fmt, ##__VA_ARGS__); \
312 } while (0)
313#elif defined(DEBUG)
309#define pr_debug(fmt, arg...) \ 314#define pr_debug(fmt, arg...) \
310 printk(KERN_DEBUG fmt, ##arg) 315 printk(KERN_DEBUG fmt, ##arg)
311#else 316#else
diff --git a/include/linux/module.h b/include/linux/module.h
index 68e09557c951..a41555cbe00a 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -345,7 +345,6 @@ struct module
345 /* Reference counts */ 345 /* Reference counts */
346 struct module_ref ref[NR_CPUS]; 346 struct module_ref ref[NR_CPUS];
347#endif 347#endif
348
349}; 348};
350#ifndef MODULE_ARCH_INIT 349#ifndef MODULE_ARCH_INIT
351#define MODULE_ARCH_INIT {} 350#define MODULE_ARCH_INIT {}
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 95ac21ab3a09..4b8cc6a32479 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(const char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40extern struct platform_device *platform_device_register_data(struct device *,
41 const char *, int, const void *, size_t);
40 42
41extern struct platform_device *platform_device_alloc(const char *name, int id); 43extern struct platform_device *platform_device_alloc(const char *name, int id);
42extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 44extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 37fa24152bd8..b330e289d71f 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -78,6 +78,8 @@ struct sysfs_ops {
78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
79}; 79};
80 80
81struct sysfs_dirent;
82
81#ifdef CONFIG_SYSFS 83#ifdef CONFIG_SYSFS
82 84
83int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 85int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
@@ -117,9 +119,14 @@ int sysfs_add_file_to_group(struct kobject *kobj,
117void sysfs_remove_file_from_group(struct kobject *kobj, 119void sysfs_remove_file_from_group(struct kobject *kobj,
118 const struct attribute *attr, const char *group); 120 const struct attribute *attr, const char *group);
119 121
120void sysfs_notify(struct kobject *kobj, char *dir, char *attr); 122void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
121 123void sysfs_notify_dirent(struct sysfs_dirent *sd);
122extern int __must_check sysfs_init(void); 124struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
125 const unsigned char *name);
126struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
127void sysfs_put(struct sysfs_dirent *sd);
128void sysfs_printk_last_file(void);
129int __must_check sysfs_init(void);
123 130
124#else /* CONFIG_SYSFS */ 131#else /* CONFIG_SYSFS */
125 132
@@ -222,7 +229,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
222{ 229{
223} 230}
224 231
225static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) 232static inline void sysfs_notify(struct kobject *kobj, const char *dir,
233 const char *attr)
234{
235}
236static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
237{
238}
239static inline
240struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
241 const unsigned char *name)
242{
243 return NULL;
244}
245static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
246{
247 return NULL;
248}
249static inline void sysfs_put(struct sysfs_dirent *sd)
226{ 250{
227} 251}
228 252
@@ -231,6 +255,10 @@ static inline int __must_check sysfs_init(void)
231 return 0; 255 return 0;
232} 256}
233 257
258static inline void sysfs_printk_last_file(void)
259{
260}
261
234#endif /* CONFIG_SYSFS */ 262#endif /* CONFIG_SYSFS */
235 263
236#endif /* _SYSFS_H_ */ 264#endif /* _SYSFS_H_ */
diff --git a/kernel/module.c b/kernel/module.c
index dd9ac6ad5cb9..b7205f67cfaf 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
784 mutex_lock(&module_mutex); 784 mutex_lock(&module_mutex);
785 /* Store the name of the last unloaded module for diagnostic purposes */ 785 /* Store the name of the last unloaded module for diagnostic purposes */
786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
787 unregister_dynamic_debug_module(mod->name);
787 free_module(mod); 788 free_module(mod);
788 789
789 out: 790 out:
@@ -1173,7 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
1173 while (i-- > 0) 1174 while (i-- > 0)
1174 sysfs_remove_bin_file(notes_attrs->dir, 1175 sysfs_remove_bin_file(notes_attrs->dir,
1175 &notes_attrs->attrs[i]); 1176 &notes_attrs->attrs[i]);
1176 kobject_del(notes_attrs->dir); 1177 kobject_put(notes_attrs->dir);
1177 } 1178 }
1178 kfree(notes_attrs); 1179 kfree(notes_attrs);
1179} 1180}
@@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod,
1783} 1784}
1784#endif /* CONFIG_KALLSYMS */ 1785#endif /* CONFIG_KALLSYMS */
1785 1786
1787#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
1788static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex)
1789{
1790 struct mod_debug *debug_info;
1791 unsigned long pos, end;
1792 unsigned int num_verbose;
1793
1794 pos = sechdrs[verboseindex].sh_addr;
1795 num_verbose = sechdrs[verboseindex].sh_size /
1796 sizeof(struct mod_debug);
1797 end = pos + (num_verbose * sizeof(struct mod_debug));
1798
1799 for (; pos < end; pos += sizeof(struct mod_debug)) {
1800 debug_info = (struct mod_debug *)pos;
1801 register_dynamic_debug_module(debug_info->modname,
1802 debug_info->type, debug_info->logical_modname,
1803 debug_info->flag_names, debug_info->hash,
1804 debug_info->hash2);
1805 }
1806}
1807#else
1808static inline void dynamic_printk_setup(Elf_Shdr *sechdrs,
1809 unsigned int verboseindex)
1810{
1811}
1812#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
1813
1786static void *module_alloc_update_bounds(unsigned long size) 1814static void *module_alloc_update_bounds(unsigned long size)
1787{ 1815{
1788 void *ret = module_alloc(size); 1816 void *ret = module_alloc(size);
@@ -1831,6 +1859,7 @@ static noinline struct module *load_module(void __user *umod,
1831#endif 1859#endif
1832 unsigned int markersindex; 1860 unsigned int markersindex;
1833 unsigned int markersstringsindex; 1861 unsigned int markersstringsindex;
1862 unsigned int verboseindex;
1834 struct module *mod; 1863 struct module *mod;
1835 long err = 0; 1864 long err = 0;
1836 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1865 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -2117,6 +2146,7 @@ static noinline struct module *load_module(void __user *umod,
2117 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); 2146 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
2118 markersstringsindex = find_sec(hdr, sechdrs, secstrings, 2147 markersstringsindex = find_sec(hdr, sechdrs, secstrings,
2119 "__markers_strings"); 2148 "__markers_strings");
2149 verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose");
2120 2150
2121 /* Now do relocations. */ 2151 /* Now do relocations. */
2122 for (i = 1; i < hdr->e_shnum; i++) { 2152 for (i = 1; i < hdr->e_shnum; i++) {
@@ -2167,6 +2197,7 @@ static noinline struct module *load_module(void __user *umod,
2167 marker_update_probe_range(mod->markers, 2197 marker_update_probe_range(mod->markers,
2168 mod->markers + mod->num_markers); 2198 mod->markers + mod->num_markers);
2169#endif 2199#endif
2200 dynamic_printk_setup(sechdrs, verboseindex);
2170 err = module_finalize(hdr, sechdrs, mod); 2201 err = module_finalize(hdr, sechdrs, mod);
2171 if (err < 0) 2202 if (err < 0)
2172 goto cleanup; 2203 goto cleanup;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index aa81d2848448..31d784dd80d0 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -807,6 +807,61 @@ menuconfig BUILD_DOCSRC
807 807
808 Say N if you are unsure. 808 Say N if you are unsure.
809 809
810config DYNAMIC_PRINTK_DEBUG
811 bool "Enable dynamic printk() call support"
812 default n
813 depends on PRINTK
814 select PRINTK_DEBUG
815 help
816
817 Compiles debug level messages into the kernel, which would not
818 otherwise be available at runtime. These messages can then be
819 enabled/disabled on a per module basis. This mechanism implicitly
820 enables all pr_debug() and dev_dbg() calls. The impact of this
821 compile option is a larger kernel text size of about 2%.
822
823 Usage:
824
825 Dynamic debugging is controlled by the debugfs file,
826 dynamic_printk/modules. This file contains a list of the modules that
827 can be enabled. The format of the file is the module name, followed
828 by a set of flags that can be enabled. The first flag is always the
829 'enabled' flag. For example:
830
831 <module_name> <enabled=0/1>
832 .
833 .
834 .
835
836 <module_name> : Name of the module in which the debug call resides
837 <enabled=0/1> : whether the messages are enabled or not
838
839 From a live system:
840
841 snd_hda_intel enabled=0
842 fixup enabled=0
843 driver enabled=0
844
845 Enable a module:
846
847 $echo "set enabled=1 <module_name>" > dynamic_printk/modules
848
849 Disable a module:
850
851 $echo "set enabled=0 <module_name>" > dynamic_printk/modules
852
853 Enable all modules:
854
855 $echo "set enabled=1 all" > dynamic_printk/modules
856
857 Disable all modules:
858
859 $echo "set enabled=0 all" > dynamic_printk/modules
860
861 Finally, passing "dynamic_printk" at the command line enables
862 debugging for all modules. This mode can be turned off via the above
863 disable command.
864
810source "samples/Kconfig" 865source "samples/Kconfig"
811 866
812source "lib/Kconfig.kgdb" 867source "lib/Kconfig.kgdb"
diff --git a/lib/Makefile b/lib/Makefile
index 44001af76a7d..16feaab057b2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -81,6 +81,8 @@ obj-$(CONFIG_HAVE_LMB) += lmb.o
81 81
82obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o 82obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
83 83
84obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o
85
84hostprogs-y := gen_crc32table 86hostprogs-y := gen_crc32table
85clean-files := crc32table.h 87clean-files := crc32table.h
86 88
diff --git a/lib/dynamic_printk.c b/lib/dynamic_printk.c
new file mode 100644
index 000000000000..d640f87bdc9e
--- /dev/null
+++ b/lib/dynamic_printk.c
@@ -0,0 +1,418 @@
1/*
2 * lib/dynamic_printk.c
3 *
4 * make pr_debug()/dev_dbg() calls runtime configurable based upon their
5 * their source module.
6 *
7 * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com>
8 */
9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/uaccess.h>
13#include <linux/seq_file.h>
14#include <linux/debugfs.h>
15#include <linux/fs.h>
16
17extern struct mod_debug __start___verbose[];
18extern struct mod_debug __stop___verbose[];
19
20struct debug_name {
21 struct hlist_node hlist;
22 struct hlist_node hlist2;
23 int hash1;
24 int hash2;
25 char *name;
26 int enable;
27 int type;
28};
29
30static int nr_entries;
31static int num_enabled;
32int dynamic_enabled = DYNAMIC_ENABLED_NONE;
33static struct hlist_head module_table[DEBUG_HASH_TABLE_SIZE] =
34 { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
35static struct hlist_head module_table2[DEBUG_HASH_TABLE_SIZE] =
36 { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
37static DECLARE_MUTEX(debug_list_mutex);
38
39/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
40 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
41 * use independent hash functions, to reduce the chance of false positives.
42 */
43long long dynamic_printk_enabled;
44EXPORT_SYMBOL_GPL(dynamic_printk_enabled);
45long long dynamic_printk_enabled2;
46EXPORT_SYMBOL_GPL(dynamic_printk_enabled2);
47
48/* returns the debug module pointer. */
49static struct debug_name *find_debug_module(char *module_name)
50{
51 int i;
52 struct hlist_head *head;
53 struct hlist_node *node;
54 struct debug_name *element;
55
56 element = NULL;
57 for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) {
58 head = &module_table[i];
59 hlist_for_each_entry_rcu(element, node, head, hlist)
60 if (!strcmp(element->name, module_name))
61 return element;
62 }
63 return NULL;
64}
65
66/* returns the debug module pointer. */
67static struct debug_name *find_debug_module_hash(char *module_name, int hash)
68{
69 struct hlist_head *head;
70 struct hlist_node *node;
71 struct debug_name *element;
72
73 element = NULL;
74 head = &module_table[hash];
75 hlist_for_each_entry_rcu(element, node, head, hlist)
76 if (!strcmp(element->name, module_name))
77 return element;
78 return NULL;
79}
80
81/* caller must hold mutex*/
82static int __add_debug_module(char *mod_name, int hash, int hash2)
83{
84 struct debug_name *new;
85 char *module_name;
86 int ret = 0;
87
88 if (find_debug_module(mod_name)) {
89 ret = -EINVAL;
90 goto out;
91 }
92 module_name = kmalloc(strlen(mod_name) + 1, GFP_KERNEL);
93 if (!module_name) {
94 ret = -ENOMEM;
95 goto out;
96 }
97 module_name = strcpy(module_name, mod_name);
98 module_name[strlen(mod_name)] = '\0';
99 new = kzalloc(sizeof(struct debug_name), GFP_KERNEL);
100 if (!new) {
101 kfree(module_name);
102 ret = -ENOMEM;
103 goto out;
104 }
105 INIT_HLIST_NODE(&new->hlist);
106 INIT_HLIST_NODE(&new->hlist2);
107 new->name = module_name;
108 new->hash1 = hash;
109 new->hash2 = hash2;
110 hlist_add_head_rcu(&new->hlist, &module_table[hash]);
111 hlist_add_head_rcu(&new->hlist2, &module_table2[hash2]);
112 nr_entries++;
113out:
114 return ret;
115}
116
117int unregister_dynamic_debug_module(char *mod_name)
118{
119 struct debug_name *element;
120 int ret = 0;
121
122 down(&debug_list_mutex);
123 element = find_debug_module(mod_name);
124 if (!element) {
125 ret = -EINVAL;
126 goto out;
127 }
128 hlist_del_rcu(&element->hlist);
129 hlist_del_rcu(&element->hlist2);
130 synchronize_rcu();
131 kfree(element->name);
132 if (element->enable)
133 num_enabled--;
134 kfree(element);
135 nr_entries--;
136out:
137 up(&debug_list_mutex);
138 return 0;
139}
140EXPORT_SYMBOL_GPL(unregister_dynamic_debug_module);
141
142int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
143 char *flags, int hash, int hash2)
144{
145 struct debug_name *elem;
146 int ret = 0;
147
148 down(&debug_list_mutex);
149 elem = find_debug_module(mod_name);
150 if (!elem) {
151 if (__add_debug_module(mod_name, hash, hash2))
152 goto out;
153 elem = find_debug_module(mod_name);
154 if (dynamic_enabled == DYNAMIC_ENABLED_ALL &&
155 !strcmp(mod_name, share_name)) {
156 elem->enable = true;
157 num_enabled++;
158 }
159 }
160 elem->type |= type;
161out:
162 up(&debug_list_mutex);
163 return ret;
164}
165EXPORT_SYMBOL_GPL(register_dynamic_debug_module);
166
167int __dynamic_dbg_enabled_helper(char *mod_name, int type, int value, int hash)
168{
169 struct debug_name *elem;
170 int ret = 0;
171
172 if (dynamic_enabled == DYNAMIC_ENABLED_ALL)
173 return 1;
174 rcu_read_lock();
175 elem = find_debug_module_hash(mod_name, hash);
176 if (elem && elem->enable)
177 ret = 1;
178 rcu_read_unlock();
179 return ret;
180}
181EXPORT_SYMBOL_GPL(__dynamic_dbg_enabled_helper);
182
183static void set_all(bool enable)
184{
185 struct debug_name *e;
186 struct hlist_node *node;
187 int i;
188 long long enable_mask;
189
190 for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) {
191 if (module_table[i].first != NULL) {
192 hlist_for_each_entry(e, node, &module_table[i], hlist) {
193 e->enable = enable;
194 }
195 }
196 }
197 if (enable)
198 enable_mask = ULLONG_MAX;
199 else
200 enable_mask = 0;
201 dynamic_printk_enabled = enable_mask;
202 dynamic_printk_enabled2 = enable_mask;
203}
204
205static int disabled_hash(int i, bool first_table)
206{
207 struct debug_name *e;
208 struct hlist_node *node;
209
210 if (first_table) {
211 hlist_for_each_entry(e, node, &module_table[i], hlist) {
212 if (e->enable)
213 return 0;
214 }
215 } else {
216 hlist_for_each_entry(e, node, &module_table2[i], hlist2) {
217 if (e->enable)
218 return 0;
219 }
220 }
221 return 1;
222}
223
224static ssize_t pr_debug_write(struct file *file, const char __user *buf,
225 size_t length, loff_t *ppos)
226{
227 char *buffer, *s, *value_str, *setting_str;
228 int err, value;
229 struct debug_name *elem = NULL;
230 int all = 0;
231
232 if (length > PAGE_SIZE || length < 0)
233 return -EINVAL;
234
235 buffer = (char *)__get_free_page(GFP_KERNEL);
236 if (!buffer)
237 return -ENOMEM;
238
239 err = -EFAULT;
240 if (copy_from_user(buffer, buf, length))
241 goto out;
242
243 err = -EINVAL;
244 if (length < PAGE_SIZE)
245 buffer[length] = '\0';
246 else if (buffer[PAGE_SIZE-1])
247 goto out;
248
249 err = -EINVAL;
250 down(&debug_list_mutex);
251
252 if (strncmp("set", buffer, 3))
253 goto out_up;
254 s = buffer + 3;
255 setting_str = strsep(&s, "=");
256 if (s == NULL)
257 goto out_up;
258 setting_str = strstrip(setting_str);
259 value_str = strsep(&s, " ");
260 if (s == NULL)
261 goto out_up;
262 s = strstrip(s);
263 if (!strncmp(s, "all", 3))
264 all = 1;
265 else
266 elem = find_debug_module(s);
267 if (!strncmp(setting_str, "enable", 6)) {
268 value = !!simple_strtol(value_str, NULL, 10);
269 if (all) {
270 if (value) {
271 set_all(true);
272 num_enabled = nr_entries;
273 dynamic_enabled = DYNAMIC_ENABLED_ALL;
274 } else {
275 set_all(false);
276 num_enabled = 0;
277 dynamic_enabled = DYNAMIC_ENABLED_NONE;
278 }
279 err = 0;
280 } else {
281 if (elem) {
282 if (value && (elem->enable == 0)) {
283 dynamic_printk_enabled |=
284 (1LL << elem->hash1);
285 dynamic_printk_enabled2 |=
286 (1LL << elem->hash2);
287 elem->enable = 1;
288 num_enabled++;
289 dynamic_enabled = DYNAMIC_ENABLED_SOME;
290 err = 0;
291 printk(KERN_DEBUG
292 "debugging enabled for module %s",
293 elem->name);
294 } else if (!value && (elem->enable == 1)) {
295 elem->enable = 0;
296 num_enabled--;
297 if (disabled_hash(elem->hash1, true))
298 dynamic_printk_enabled &=
299 ~(1LL << elem->hash1);
300 if (disabled_hash(elem->hash2, false))
301 dynamic_printk_enabled2 &=
302 ~(1LL << elem->hash2);
303 if (num_enabled)
304 dynamic_enabled =
305 DYNAMIC_ENABLED_SOME;
306 else
307 dynamic_enabled =
308 DYNAMIC_ENABLED_NONE;
309 err = 0;
310 printk(KERN_DEBUG
311 "debugging disabled for module "
312 "%s", elem->name);
313 }
314 }
315 }
316 }
317 if (!err)
318 err = length;
319out_up:
320 up(&debug_list_mutex);
321out:
322 free_page((unsigned long)buffer);
323 return err;
324}
325
326static void *pr_debug_seq_start(struct seq_file *f, loff_t *pos)
327{
328 return (*pos < DEBUG_HASH_TABLE_SIZE) ? pos : NULL;
329}
330
331static void *pr_debug_seq_next(struct seq_file *s, void *v, loff_t *pos)
332{
333 (*pos)++;
334 if (*pos >= DEBUG_HASH_TABLE_SIZE)
335 return NULL;
336 return pos;
337}
338
339static void pr_debug_seq_stop(struct seq_file *s, void *v)
340{
341 /* Nothing to do */
342}
343
344static int pr_debug_seq_show(struct seq_file *s, void *v)
345{
346 struct hlist_head *head;
347 struct hlist_node *node;
348 struct debug_name *elem;
349 unsigned int i = *(loff_t *) v;
350
351 rcu_read_lock();
352 head = &module_table[i];
353 hlist_for_each_entry_rcu(elem, node, head, hlist) {
354 seq_printf(s, "%s enabled=%d", elem->name, elem->enable);
355 seq_printf(s, "\n");
356 }
357 rcu_read_unlock();
358 return 0;
359}
360
361static struct seq_operations pr_debug_seq_ops = {
362 .start = pr_debug_seq_start,
363 .next = pr_debug_seq_next,
364 .stop = pr_debug_seq_stop,
365 .show = pr_debug_seq_show
366};
367
368static int pr_debug_open(struct inode *inode, struct file *filp)
369{
370 return seq_open(filp, &pr_debug_seq_ops);
371}
372
373static const struct file_operations pr_debug_operations = {
374 .open = pr_debug_open,
375 .read = seq_read,
376 .write = pr_debug_write,
377 .llseek = seq_lseek,
378 .release = seq_release,
379};
380
381static int __init dynamic_printk_init(void)
382{
383 struct dentry *dir, *file;
384 struct mod_debug *iter;
385 unsigned long value;
386
387 dir = debugfs_create_dir("dynamic_printk", NULL);
388 if (!dir)
389 return -ENOMEM;
390 file = debugfs_create_file("modules", 0644, dir, NULL,
391 &pr_debug_operations);
392 if (!file) {
393 debugfs_remove(dir);
394 return -ENOMEM;
395 }
396 for (value = (unsigned long)__start___verbose;
397 value < (unsigned long)__stop___verbose;
398 value += sizeof(struct mod_debug)) {
399 iter = (struct mod_debug *)value;
400 register_dynamic_debug_module(iter->modname,
401 iter->type,
402 iter->logical_modname,
403 iter->flag_names, iter->hash, iter->hash2);
404 }
405 return 0;
406}
407module_init(dynamic_printk_init);
408/* may want to move this earlier so we can get traces as early as possible */
409
410static int __init dynamic_printk_setup(char *str)
411{
412 if (str)
413 return -ENOENT;
414 set_all(true);
415 return 0;
416}
417/* Use early_param(), so we can get debug output as early as possible */
418early_param("dynamic_printk", dynamic_printk_setup);
diff --git a/lib/kobject.c b/lib/kobject.c
index fbf0ae282376..0487d1f64806 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -387,11 +387,17 @@ EXPORT_SYMBOL_GPL(kobject_init_and_add);
387 * kobject_rename - change the name of an object 387 * kobject_rename - change the name of an object
388 * @kobj: object in question. 388 * @kobj: object in question.
389 * @new_name: object's new name 389 * @new_name: object's new name
390 *
391 * It is the responsibility of the caller to provide mutual
392 * exclusion between two different calls of kobject_rename
393 * on the same kobject and to ensure that new_name is valid and
394 * won't conflict with other kobjects.
390 */ 395 */
391int kobject_rename(struct kobject *kobj, const char *new_name) 396int kobject_rename(struct kobject *kobj, const char *new_name)
392{ 397{
393 int error = 0; 398 int error = 0;
394 const char *devpath = NULL; 399 const char *devpath = NULL;
400 const char *dup_name = NULL, *name;
395 char *devpath_string = NULL; 401 char *devpath_string = NULL;
396 char *envp[2]; 402 char *envp[2];
397 403
@@ -401,19 +407,6 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
401 if (!kobj->parent) 407 if (!kobj->parent)
402 return -EINVAL; 408 return -EINVAL;
403 409
404 /* see if this name is already in use */
405 if (kobj->kset) {
406 struct kobject *temp_kobj;
407 temp_kobj = kset_find_obj(kobj->kset, new_name);
408 if (temp_kobj) {
409 printk(KERN_WARNING "kobject '%s' cannot be renamed "
410 "to '%s' as '%s' is already in existence.\n",
411 kobject_name(kobj), new_name, new_name);
412 kobject_put(temp_kobj);
413 return -EINVAL;
414 }
415 }
416
417 devpath = kobject_get_path(kobj, GFP_KERNEL); 410 devpath = kobject_get_path(kobj, GFP_KERNEL);
418 if (!devpath) { 411 if (!devpath) {
419 error = -ENOMEM; 412 error = -ENOMEM;
@@ -428,15 +421,27 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
428 envp[0] = devpath_string; 421 envp[0] = devpath_string;
429 envp[1] = NULL; 422 envp[1] = NULL;
430 423
424 name = dup_name = kstrdup(new_name, GFP_KERNEL);
425 if (!name) {
426 error = -ENOMEM;
427 goto out;
428 }
429
431 error = sysfs_rename_dir(kobj, new_name); 430 error = sysfs_rename_dir(kobj, new_name);
431 if (error)
432 goto out;
433
434 /* Install the new kobject name */
435 dup_name = kobj->name;
436 kobj->name = name;
432 437
433 /* This function is mostly/only used for network interface. 438 /* This function is mostly/only used for network interface.
434 * Some hotplug package track interfaces by their name and 439 * Some hotplug package track interfaces by their name and
435 * therefore want to know when the name is changed by the user. */ 440 * therefore want to know when the name is changed by the user. */
436 if (!error) 441 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
437 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
438 442
439out: 443out:
444 kfree(dup_name);
440 kfree(devpath_string); 445 kfree(devpath_string);
441 kfree(devpath); 446 kfree(devpath);
442 kobject_put(kobj); 447 kobject_put(kobj);
diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c
index 373e51e91ce5..1bc3001d1827 100644
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -65,7 +65,7 @@ void
65 struct nf_conntrack_expect *exp) __read_mostly; 65 struct nf_conntrack_expect *exp) __read_mostly;
66EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); 66EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
67 67
68#ifdef DEBUG 68#if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
69/* PptpControlMessageType names */ 69/* PptpControlMessageType names */
70const char *const pptp_msg_name[] = { 70const char *const pptp_msg_name[] = {
71 "UNKNOWN_MESSAGE", 71 "UNKNOWN_MESSAGE",
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ea48b82a3707..b4ca38a21158 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -96,6 +96,14 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
96modname_flags = $(if $(filter 1,$(words $(modname))),\ 96modname_flags = $(if $(filter 1,$(words $(modname))),\
97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
98 98
99#hash values
100ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
101debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\
102 -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))"
103else
104debug_flags =
105endif
106
99orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o) 107orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
100_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 108_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
101_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o) 109_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
@@ -121,7 +129,8 @@ endif
121 129
122c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 130c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
123 $(__c_flags) $(modkern_cflags) \ 131 $(__c_flags) $(modkern_cflags) \
124 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) 132 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
133 $(debug_flags)
125 134
126a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 135a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
127 $(__a_flags) $(modkern_aflags) 136 $(__a_flags) $(modkern_aflags)
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 4c324a1f1e0e..09559951df12 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -9,7 +9,7 @@
9# fixdep: Used to generate dependency information during build process 9# fixdep: Used to generate dependency information during build process
10# docproc: Used in Documentation/DocBook 10# docproc: Used in Documentation/DocBook
11 11
12hostprogs-y := fixdep docproc 12hostprogs-y := fixdep docproc hash
13always := $(hostprogs-y) 13always := $(hostprogs-y)
14 14
15# fixdep is needed to compile other host programs 15# fixdep is needed to compile other host programs
diff --git a/scripts/basic/hash.c b/scripts/basic/hash.c
new file mode 100644
index 000000000000..3299ad7fc8c0
--- /dev/null
+++ b/scripts/basic/hash.c
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com>
3 *
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10#define DYNAMIC_DEBUG_HASH_BITS 6
11
12static const char *program;
13
14static void usage(void)
15{
16 printf("Usage: %s <djb2|r5> <modname>\n", program);
17 exit(1);
18}
19
20/* djb2 hashing algorithm by Dan Bernstein. From:
21 * http://www.cse.yorku.ca/~oz/hash.html
22 */
23
24unsigned int djb2_hash(char *str)
25{
26 unsigned long hash = 5381;
27 int c;
28
29 c = *str;
30 while (c) {
31 hash = ((hash << 5) + hash) + c;
32 c = *++str;
33 }
34 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
35}
36
37unsigned int r5_hash(char *str)
38{
39 unsigned long hash = 0;
40 int c;
41
42 c = *str;
43 while (c) {
44 hash = (hash + (c << 4) + (c >> 4)) * 11;
45 c = *++str;
46 }
47 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
48}
49
50int main(int argc, char *argv[])
51{
52 program = argv[0];
53
54 if (argc != 3)
55 usage();
56 if (!strcmp(argv[1], "djb2"))
57 printf("%d\n", djb2_hash(argv[2]));
58 else if (!strcmp(argv[1], "r5"))
59 printf("%d\n", r5_hash(argv[2]));
60 else
61 usage();
62 exit(0);
63}
64
diff --git a/sound/core/init.c b/sound/core/init.c
index 8af467df9245..ef2352c2e451 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -549,9 +549,9 @@ int snd_card_register(struct snd_card *card)
549 return -EINVAL; 549 return -EINVAL;
550#ifndef CONFIG_SYSFS_DEPRECATED 550#ifndef CONFIG_SYSFS_DEPRECATED
551 if (!card->card_dev) { 551 if (!card->card_dev) {
552 card->card_dev = device_create_drvdata(sound_class, card->dev, 552 card->card_dev = device_create(sound_class, card->dev,
553 MKDEV(0, 0), NULL, 553 MKDEV(0, 0), NULL,
554 "card%i", card->number); 554 "card%i", card->number);
555 if (IS_ERR(card->card_dev)) 555 if (IS_ERR(card->card_dev))
556 card->card_dev = NULL; 556 card->card_dev = NULL;
557 } 557 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index c0685e2f0afa..44a69bb8d4f0 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -274,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
274 return minor; 274 return minor;
275 } 275 }
276 snd_minors[minor] = preg; 276 snd_minors[minor] = preg;
277 preg->dev = device_create_drvdata(sound_class, device, 277 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
278 MKDEV(major, minor), 278 private_data, "%s", name);
279 private_data, "%s", name);
280 if (IS_ERR(preg->dev)) { 279 if (IS_ERR(preg->dev)) {
281 snd_minors[minor] = NULL; 280 snd_minors[minor] = NULL;
282 mutex_unlock(&sound_mutex); 281 mutex_unlock(&sound_mutex);
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 7d89c081a086..61aaedae6b7e 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -560,19 +560,18 @@ static int __init oss_init(void)
560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0); 560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
561 561
562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) { 562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
563 device_create_drvdata(sound_class, NULL, 563 device_create(sound_class, NULL,
564 MKDEV(SOUND_MAJOR, dev_list[i].minor), 564 MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL,
565 NULL, "%s", dev_list[i].name); 565 "%s", dev_list[i].name);
566 566
567 if (!dev_list[i].num) 567 if (!dev_list[i].num)
568 continue; 568 continue;
569 569
570 for (j = 1; j < *dev_list[i].num; j++) 570 for (j = 1; j < *dev_list[i].num; j++)
571 device_create_drvdata(sound_class, NULL, 571 device_create(sound_class, NULL,
572 MKDEV(SOUND_MAJOR, 572 MKDEV(SOUND_MAJOR,
573 dev_list[i].minor + (j*0x10)), 573 dev_list[i].minor + (j*0x10)),
574 NULL, 574 NULL, "%s%d", dev_list[i].name, j);
575 "%s%d", dev_list[i].name, j);
576 } 575 }
577 576
578 if (sound_nblocks >= 1024) 577 if (sound_nblocks >= 1024)
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 4ae07e236b36..faef87a9bc3f 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -220,9 +220,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
220 else 220 else
221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); 221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
222 222
223 device_create_drvdata(sound_class, dev, 223 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
224 MKDEV(SOUND_MAJOR, s->unit_minor), 224 NULL, s->name+6);
225 NULL, s->name+6);
226 return r; 225 return r;
227 226
228 fail: 227 fail: