History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (46 commits) UIO: Fix mapping of logical and virtual memory UIO: add automata sercos3 pci card support UIO: Change driver name of uio_pdrv UIO: Add alignment warnings for uio-mem Driver core: add bus_sort_breadthfirst() function NET: convert the phy_device file to use bus_find_device_by_name kobject: Cleanup kobject_rename and !CONFIG_SYSFS kobject: Fix kobject_rename and !CONFIG_SYSFS sysfs: Make dir and name args to sysfs_notify() const platform: add new device registration helper sysfs: use ilookup5() instead of ilookup5_nowait() PNP: create device attributes via default device attributes Driver core: make bus_find_device_by_name() more robust usb: turn dev_warn+WARN_ON combos into dev_WARN debug: use dev_WARN() rather than WARN_ON() in device_pm_add() debug: Introduce a dev_WARN() function sysfs: fix deadlock device model: Do a quickcheck for driver binding before doing an expensive check Driver core: Fix cleanup in device_create_vargs(). Driver core: Clarify device cleanup. ...

Linus Torvalds committed 18 years ago

Commit c813b4e2 parents c8d8a23 02683ff131 files · +1786 −617Browse files

Unified · Split

131 files
  1. Documentation/kernel-parameters.txt +5 −0
  2. Documentation/kobject.txt +4 −0
  3. arch/mips/kernel/rtlx.c +2 −2
  4. arch/mips/sibyte/common/sb_tbprof.c +1 −2
  5. arch/x86/kernel/cpuid.c +2 −2
  6. arch/x86/kernel/dumpstack_32.c +2 −0
  7. arch/x86/kernel/dumpstack_64.c +2 −0
  8. arch/x86/kernel/msr.c +2 −2
  9. block/bsg.c +1 −2
  10. drivers/base/bus.c +51 −3
  11. drivers/base/core.c +24 −6
  12. drivers/base/dd.c +3 −0
  13. drivers/base/platform.c +48 −1
  14. drivers/base/power/main.c +1 −1
  15. drivers/block/aoe/aoechr.c +3 −3
  16. drivers/block/paride/pg.c +2 −3
  17. drivers/block/paride/pt.c +4 −6
  18. drivers/block/pktcdvd.c +2 −3
  19. drivers/char/bsr.c +2 −3
  20. drivers/char/dsp56k.c +2 −2
  21. drivers/char/ip2/ip2main.c +6 −6
  22. drivers/char/ipmi/ipmi_devintf.c +1 −1
  23. drivers/char/istallion.c +2 −3
  24. drivers/char/lp.c +2 −2
  25. drivers/char/mem.c +3 −3
  26. drivers/char/misc.c +2 −2
  27. drivers/char/pcmcia/cm4000_cs.c +1 −1
  28. drivers/char/pcmcia/cm4040_cs.c +1 −2
  29. drivers/char/ppdev.c +2 −3
  30. drivers/char/raw.c +3 −4
  31. drivers/char/snsc.c +2 −2
  32. drivers/char/stallion.c +2 −2
  33. drivers/char/tty_io.c +1 −1
  34. drivers/char/vc_screen.c +6 −6
  35. drivers/char/viotape.c +4 −4
  36. drivers/char/xilinx_hwicap/xilinx_hwicap.c +1 −2
  37. drivers/dca/dca-sysfs.c +3 −5
  38. drivers/firmware/iscsi_ibft.c +9 −9
  39. drivers/hid/hidraw.c +2 −3
  40. drivers/hwmon/hwmon.c +2 −2
  41. drivers/i2c/i2c-dev.c +3 −3
  42. drivers/ide/ide-probe.c +2 −2
  43. drivers/ide/ide-tape.c +5 −6
  44. drivers/ieee1394/dv1394.c +4 −4
  45. drivers/ieee1394/raw1394.c +4 −4
  46. drivers/ieee1394/video1394.c +2 −3
  47. drivers/infiniband/core/cm.c +3 −3
  48. drivers/infiniband/core/user_mad.c +6 −6
  49. drivers/infiniband/core/uverbs_main.c +3 −6
  50. drivers/infiniband/hw/ipath/ipath_file_ops.c +1 −1
  51. drivers/isdn/capi/capi.c +1 −2
  52. drivers/leds/led-class.c +2 −2
  53. drivers/macintosh/adb.c +1 −2
  54. drivers/media/dvb/dvb-core/dvbdev.c +1 −1
  55. drivers/misc/phantom.c +3 −3
  56. drivers/mtd/mtdchar.c +4 −6
  57. drivers/net/phy/phy_device.c +1 −7
  58. drivers/net/ppp_generic.c +2 −2
  59. drivers/net/wan/cosa.c +2 −2
  60. drivers/net/wireless/mac80211_hwsim.c +3 −3
  61. drivers/pci/probe.c +5 −45
  62. drivers/pnp/base.h +1 −1
  63. drivers/pnp/core.c +1 −9
  64. drivers/pnp/driver.c +1 −0
  65. drivers/pnp/interface.c +8 −29
  66. drivers/power/power_supply_core.c +2 −2
  67. drivers/s390/char/raw3270.c +6 −8
  68. drivers/s390/char/tape_class.c +3 −3
  69. drivers/s390/char/vmlogrdr.c +4 −4
  70. drivers/s390/char/vmur.c +2 −3
  71. drivers/scsi/ch.c +3 −3
  72. drivers/scsi/dpt_i2o.c +1 −1
  73. drivers/scsi/osst.c +2 −1
  74. drivers/scsi/sg.c +4 −6
  75. drivers/scsi/st.c +4 −7
  76. drivers/spi/spidev.c +3 −4
  77. drivers/uio/Kconfig +13 −0
  78. drivers/uio/Makefile +1 −0
  79. drivers/uio/uio.c +21 −5
  80. drivers/uio/uio_pdrv.c +1 −1
  81. drivers/uio/uio_sercos3.c +243 −0
  82. drivers/usb/core/devio.c +3 −3
  83. drivers/usb/core/file.c +3 −3
  84. drivers/usb/core/hcd.c +2 −3
  85. drivers/usb/gadget/Makefile +7 −16
  86. drivers/usb/gadget/cdc2.c +23 −2
  87. drivers/usb/gadget/ether.c +26 −2
  88. drivers/usb/gadget/f_ecm.c +54 −54
  89. drivers/usb/gadget/f_loopback.c +18 −16
  90. drivers/usb/gadget/f_subset.c +22 −22
  91. drivers/usb/gadget/file_storage.c +12 −0
  92. drivers/usb/gadget/gmidi.c +15 −0
  93. drivers/usb/gadget/printer.c +16 −2
  94. drivers/usb/gadget/rndis.c +55 −60
  95. drivers/usb/gadget/serial.c +18 −0
  96. drivers/usb/gadget/u_ether.c +2 −2
  97. drivers/usb/gadget/zero.c +17 −0
  98. drivers/usb/host/uhci-q.c +8 −16
  99. drivers/usb/misc/phidgetkit.c +2 −3
  100. drivers/usb/misc/phidgetmotorcontrol.c +2 −3
  101. drivers/usb/misc/phidgetservo.c +2 −3
  102. drivers/usb/mon/mon_bin.c +3 −3
  103. drivers/video/console/fbcon.c +2 −2
  104. drivers/video/display/display-sysfs.c +3 −6
  105. drivers/video/fbmem.c +2 −3
  106. fs/coda/psdev.c +2 −3
  107. fs/sysfs/bin.c +31 −11
  108. fs/sysfs/dir.c +10 −14
  109. fs/sysfs/file.c +32 −14
  110. fs/sysfs/mount.c +15 −0
  111. fs/sysfs/sysfs.h +4 −2
  112. include/asm-generic/vmlinux.lds.h +9 −1
  113. include/linux/device.h +16 −2
  114. include/linux/dynamic_printk.h +93 −0
  115. include/linux/kernel.h +6 −1
  116. include/linux/module.h +0 −1
  117. include/linux/platform_device.h +2 −0
  118. include/linux/sysfs.h +32 −4
  119. kernel/module.c +32 −1
  120. lib/Kconfig.debug +55 −0
  121. lib/Makefile +2 −0
  122. lib/dynamic_printk.c +418 −0
  123. lib/kobject.c +20 −15
  124. net/netfilter/nf_conntrack_pptp.c +1 −1
  125. scripts/Makefile.lib +10 −1
  126. scripts/basic/Makefile +1 −1
  127. scripts/basic/hash.c +64 −0
  128. sound/core/init.c +3 −3
  129. sound/core/sound.c +2 −3
  130. sound/oss/soundcard.c +7 −8
  131. sound/sound_core.c +2 −3
Documentation/kernel-parameters.txt+5−0
@@ -1714,6 +1714,11 @@ and is between 256 and 4096 characters. It is defined in the file · 1713 unmodified lines
17141714 autoconfiguration.
17151715 Ranges are in pairs (memory base and size).
17161716
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+
17171722 print-fatal-signals=
17181723 [KNL] debug: print fatal signals
17191724 print-fatal-signals=1: print segfault info to
Documentation/kobject.txt+4−0
@@ -118,6 +118,10 @@ the name of the kobject, call kobject_rename(): · 117 unmodified lines
118118
119119 int kobject_rename(struct kobject *kobj, const char *new_name);
120120
121+Note kobject_rename does perform any locking or have a solid notion of
122+what names are valid so the provide must provide their own sanity checking
123+and serialization.
124+
121125 There is a function called kobject_set_name() but that is legacy cruft and
122126 is being removed. If your code needs to call this function, it is
123127 incorrect and needs to be fixed.
arch/mips/kernel/rtlx.c+2−2
@@ -522,8 +522,8 @@ static int __init rtlx_module_init(void) · 521 unmodified lines
522522 atomic_set(&channel_wqs[i].in_open, 0);
523523 mutex_init(&channel_wqs[i].mutex);
524524
525− dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i),
526− NULL, "%s%d", module_name, i);
525+ dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
526+ "%s%d", module_name, i);
527527 if (IS_ERR(dev)) {
528528 err = PTR_ERR(dev);
529529 goto out_chrdev;
arch/mips/sibyte/common/sb_tbprof.c+1−2
@@ -576,8 +576,7 @@ static int __init sbprof_tb_init(void) · 575 unmodified lines
576576
577577 tb_class = tbc;
578578
579− dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0),
580− NULL, "tb");
579+ dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
581580 if (IS_ERR(dev)) {
582581 err = PTR_ERR(dev);
583582 goto out_class;
arch/x86/kernel/cpuid.c+2−2
@@ -147,8 +147,8 @@ static __cpuinit int cpuid_device_create(int cpu) · 146 unmodified lines
147147 {
148148 struct device *dev;
149149
150− dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
151− NULL, "cpu%d", cpu);
150+ dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL,
151+ "cpu%d", cpu);
152152 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
153153 }
154154
arch/x86/kernel/dumpstack_32.c+2−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/kexec.h>
1414 #include <linux/bug.h>
1515 #include <linux/nmi.h>
16+#include <linux/sysfs.h>
1617
1718 #include <asm/stacktrace.h>
1819
@@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err) · 324 unmodified lines
343344 printk("DEBUG_PAGEALLOC");
344345 #endif
345346 printk("\n");
347+ sysfs_printk_last_file();
346348 if (notify_die(DIE_OOPS, str, regs, err,
347349 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
348350 return 1;
arch/x86/kernel/dumpstack_64.c+2−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/kexec.h>
1414 #include <linux/bug.h>
1515 #include <linux/nmi.h>
16+#include <linux/sysfs.h>
1617
1718 #include <asm/stacktrace.h>
1819
@@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err) · 470 unmodified lines
489490 printk("DEBUG_PAGEALLOC");
490491 #endif
491492 printk("\n");
493+ sysfs_printk_last_file();
492494 if (notify_die(DIE_OOPS, str, regs, err,
493495 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
494496 return 1;
arch/x86/kernel/msr.c+2−2
@@ -163,8 +163,8 @@ static int __cpuinit msr_device_create(int cpu) · 162 unmodified lines
163163 {
164164 struct device *dev;
165165
166− dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
167− NULL, "msr%d", cpu);
166+ dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL,
167+ "msr%d", cpu);
168168 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
169169 }
170170
block/bsg.c+1−2
@@ -1024,8 +1024,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, · 1023 unmodified lines
10241024 bcd->release = release;
10251025 kref_init(&bcd->ref);
10261026 dev = MKDEV(bsg_major, bcd->minor);
1027− class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
1028− "%s", devname);
1027+ class_dev = device_create(bsg_class, parent, dev, NULL, "%s", devname);
10291028 if (IS_ERR(class_dev)) {
10301029 ret = PTR_ERR(class_dev);
10311030 goto put_dev;
drivers/base/bus.c+51−3
@@ -333,9 +333,7 @@ static int match_name(struct device *dev, void *data) · 332 unmodified lines
333333 {
334334 const char *name = data;
335335
336− if (strcmp(name, dev->bus_id) == 0)
337− return 1;
338− return 0;
336+ return sysfs_streq(name, dev->bus_id);
339337 }
340338
341339 /**
@@ -982,6 +980,56 @@ struct klist *bus_get_device_klist(struct bus_type *bus) · 640 unmodified lines
982980 }
983981 EXPORT_SYMBOL_GPL(bus_get_device_klist);
984982
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+ */
990+static 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+
1010+void 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+}
1031+EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
1032+
9851033 int __init buses_init(void)
9861034 {
9871035 bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
drivers/base/core.c+24−6
@@ -523,11 +523,16 @@ static void klist_children_put(struct klist_node *n) · 522 unmodified lines
523523 * device_initialize - init device structure.
524524 * @dev: device.
525525 *
526− * This prepares the device for use by other layers,
527− * including adding it to the device hierarchy.
526+ * This prepares the device for use by other layers by initializing
527+ * its fields.
528528 * It is the first half of device_register(), if called by
529− * that, though it can also be called separately, so one
530− * may use @dev's fields (e.g. the refcount).
529+ * that function, though it can also be called separately, so one
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.
531536 */
532537 void device_initialize(struct device *dev)
533538 {
@@ -835,9 +840,13 @@ static void device_remove_sys_dev_entry(struct device *dev) · 301 unmodified lines
835840 * This is part 2 of device_register(), though may be called
836841 * separately _iff_ device_initialize() has been called separately.
837842 *
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
839844 * to the global and sibling lists for the device, then
840845 * 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.
841850 */
842851 int device_add(struct device *dev)
843852 {
@@ -965,6 +974,10 @@ done: · 121 unmodified lines
965974 * I.e. you should only call the two helpers separately if
966975 * have a clearly defined need to use and refcount the device
967976 * 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.
968981 */
969982 int device_register(struct device *dev)
970983 {
@@ -1243,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent, · 272 unmodified lines
12431256 return dev;
12441257
12451258 error:
1246− kfree(dev);
1259+ put_device(dev);
12471260 return ERR_PTR(retval);
12481261 }
12491262 EXPORT_SYMBOL_GPL(device_create_vargs);
@@ -1314,6 +1327,11 @@ EXPORT_SYMBOL_GPL(device_destroy); · 64 unmodified lines
13141327 * device_rename - renames a device
13151328 * @dev: the pointer to the struct device to be renamed
13161329 * @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.
13171335 */
13181336 int device_rename(struct device *dev, char *new_name)
13191337 {
drivers/base/dd.c+3−0
@@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data) · 256 unmodified lines
257257 * is an error.
258258 */
259259
260+ if (drv->bus->match && !drv->bus->match(dev, drv))
261+ return 0;
262+
260263 if (dev->parent) /* Needed for USB */
261264 down(&dev->parent->sem);
262265 down(&dev->sem);
drivers/base/platform.c+48−1
@@ -394,6 +394,53 @@ error: · 393 unmodified lines
394394 }
395395 EXPORT_SYMBOL_GPL(platform_device_register_simple);
396396
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+ */
411+struct 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+
439+error:
440+ platform_device_put(pdev);
441+ return ERR_PTR(retval);
442+}
443+
397444 static int platform_drv_probe(struct device *_dev)
398445 {
399446 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -865,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev) · 465 unmodified lines
865912
866913 #endif /* !CONFIG_HIBERNATION */
867914
868−struct pm_ext_ops platform_pm_ops = {
915+static struct pm_ext_ops platform_pm_ops = {
869916 .base = {
870917 .prepare = platform_pm_prepare,
871918 .complete = platform_pm_complete,
drivers/base/power/main.c+1−1
@@ -83,7 +83,7 @@ void device_pm_add(struct device *dev) · 82 unmodified lines
8383 * transition is in progress in order to avoid leaving them
8484 * unhandled down the road
8585 */
86− WARN_ON(true);
86+ dev_WARN(dev, "Parentless device registered during a PM transaction\n");
8787 }
8888
8989 list_add_tail(&dev->power.entry, &dpm_list);
drivers/block/aoe/aoechr.c+3−3
@@ -284,9 +284,9 @@ aoechr_init(void) · 283 unmodified lines
284284 return PTR_ERR(aoe_class);
285285 }
286286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
287− device_create_drvdata(aoe_class, NULL,
288− MKDEV(AOE_MAJOR, chardevs[i].minor),
289− NULL, chardevs[i].name);
287+ device_create(aoe_class, NULL,
288+ MKDEV(AOE_MAJOR, chardevs[i].minor), NULL,
289+ chardevs[i].name);
290290
291291 return 0;
292292 }
drivers/block/paride/pg.c+2−3
@@ -686,9 +686,8 @@ static int __init pg_init(void) · 685 unmodified lines
686686 for (unit = 0; unit < PG_UNITS; unit++) {
687687 struct pg *dev = &devices[unit];
688688 if (dev->present)
689− device_create_drvdata(pg_class, NULL,
690− MKDEV(major, unit), NULL,
691− "pg%u", unit);
689+ device_create(pg_class, NULL, MKDEV(major, unit), NULL,
690+ "pg%u", unit);
692691 }
693692 err = 0;
694693 goto out;
drivers/block/paride/pt.c+4−6
@@ -979,12 +979,10 @@ static int __init pt_init(void) · 978 unmodified lines
979979
980980 for (unit = 0; unit < PT_UNITS; unit++)
981981 if (pt[unit].present) {
982− device_create_drvdata(pt_class, NULL,
983− MKDEV(major, unit), NULL,
984− "pt%d", unit);
985− device_create_drvdata(pt_class, NULL,
986− MKDEV(major, unit + 128), NULL,
987− "pt%dn", unit);
982+ device_create(pt_class, NULL, MKDEV(major, unit), NULL,
983+ "pt%d", unit);
984+ device_create(pt_class, NULL, MKDEV(major, unit + 128),
985+ NULL, "pt%dn", unit);
988986 }
989987 goto out;
990988
drivers/block/pktcdvd.c+2−3
@@ -302,9 +302,8 @@ static struct kobj_type kobj_pkt_type_wqueue = { · 301 unmodified lines
302302 static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
303303 {
304304 if (class_pktcdvd) {
305− pd->dev = device_create_drvdata(class_pktcdvd, NULL,
306− pd->pkt_dev, NULL,
307− "%s", pd->name);
305+ pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL,
306+ "%s", pd->name);
308307 if (IS_ERR(pd->dev))
309308 pd->dev = NULL;
310309 }
drivers/char/bsr.c+2−3
@@ -229,9 +229,8 @@ static int bsr_create_devs(struct device_node *bn) · 228 unmodified lines
229229 if (result)
230230 goto out_err;
231231
232− cur->bsr_device = device_create_drvdata(bsr_class, NULL,
233− cur->bsr_dev,
234− cur, cur->bsr_name);
232+ cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev,
233+ cur, cur->bsr_name);
235234 if (!cur->bsr_device) {
236235 printk(KERN_ERR "device_create failed for %s\n",
237236 cur->bsr_name);
drivers/char/dsp56k.c+2−2
@@ -508,8 +508,8 @@ static int __init dsp56k_init_driver(void) · 507 unmodified lines
508508 err = PTR_ERR(dsp56k_class);
509509 goto out_chrdev;
510510 }
511− device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
512− NULL, "dsp56k");
511+ device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL,
512+ "dsp56k");
513513
514514 printk(banner);
515515 goto out;
drivers/char/ip2/ip2main.c+6−6
@@ -745,12 +745,12 @@ static int __init ip2_loadmain(void) · 744 unmodified lines
745745
746746 pB = i2BoardPtrTable[i];
747747 if (pB != NULL) {
748− device_create_drvdata(ip2_class, NULL,
749− MKDEV(IP2_IPL_MAJOR, 4 * i),
750− NULL, "ipl%d", i);
751− device_create_drvdata(ip2_class, NULL,
752− MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
753− NULL, "stat%d", i);
748+ device_create(ip2_class, NULL,
749+ MKDEV(IP2_IPL_MAJOR, 4 * i),
750+ NULL, "ipl%d", i);
751+ device_create(ip2_class, NULL,
752+ MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
753+ NULL, "stat%d", i);
754754
755755 for (box = 0; box < ABS_MAX_BOXES; box++)
756756 for (j = 0; j < ABS_BIGGEST_BOX; j++)
drivers/char/ipmi/ipmi_devintf.c+1−1
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device) · 870 unmodified lines
871871 entry->dev = dev;
872872
873873 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);
875875 list_add(&entry->link, &reg_list);
876876 mutex_unlock(&reg_list_mutex);
877877 }
drivers/char/istallion.c+2−3
@@ -4600,9 +4600,8 @@ static int __init istallion_module_init(void) · 4599 unmodified lines
46004600
46014601 istallion_class = class_create(THIS_MODULE, "staliomem");
46024602 for (i = 0; i < 4; i++)
4603− device_create_drvdata(istallion_class, NULL,
4604− MKDEV(STL_SIOMEMMAJOR, i),
4605− NULL, "staliomem%d", i);
4603+ device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4604+ NULL, "staliomem%d", i);
46064605
46074606 return 0;
46084607 err_deinit:
drivers/char/lp.c+2−2
@@ -813,8 +813,8 @@ static int lp_register(int nr, struct parport *port) · 812 unmodified lines
813813 if (reset)
814814 lp_reset(nr);
815815
816− device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817− "lp%d", nr);
816+ device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817+ "lp%d", nr);
818818
819819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
820820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
drivers/char/mem.c+3−3
@@ -992,9 +992,9 @@ static int __init chr_dev_init(void) · 991 unmodified lines
992992
993993 mem_class = class_create(THIS_MODULE, "mem");
994994 for (i = 0; i < ARRAY_SIZE(devlist); i++)
995− device_create_drvdata(mem_class, NULL,
996− MKDEV(MEM_MAJOR, devlist[i].minor),
997− NULL, devlist[i].name);
995+ device_create(mem_class, NULL,
996+ MKDEV(MEM_MAJOR, devlist[i].minor), NULL,
997+ devlist[i].name);
998998
999999 return 0;
10001000 }
drivers/char/misc.c+2−2
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc) · 216 unmodified lines
217217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
218218 dev = MKDEV(MISC_MAJOR, misc->minor);
219219
220− misc->this_device = device_create_drvdata(misc_class, misc->parent,
221− dev, NULL, "%s", misc->name);
220+ misc->this_device = device_create(misc_class, misc->parent, dev, NULL,
221+ "%s", misc->name);
222222 if (IS_ERR(misc->this_device)) {
223223 err = PTR_ERR(misc->this_device);
224224 goto out;
drivers/char/pcmcia/cm4000_cs.c+1−1
@@ -1871,7 +1871,7 @@ static int cm4000_probe(struct pcmcia_device *link) · 1870 unmodified lines
18711871 return ret;
18721872 }
18731873
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);
18751875
18761876 return 0;
18771877 }
drivers/char/pcmcia/cm4040_cs.c+1−2
@@ -637,8 +637,7 @@ static int reader_probe(struct pcmcia_device *link) · 636 unmodified lines
637637 return ret;
638638 }
639639
640− device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
641− "cmx%d", i);
640+ device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i);
642641
643642 return 0;
644643 }
drivers/char/ppdev.c+2−3
@@ -760,9 +760,8 @@ static const struct file_operations pp_fops = { · 759 unmodified lines
760760
761761 static void pp_attach(struct parport *port)
762762 {
763− device_create_drvdata(ppdev_class, port->dev,
764− MKDEV(PP_MAJOR, port->number),
765− NULL, "parport%d", port->number);
763+ device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
764+ NULL, "parport%d", port->number);
766765 }
767766
768767 static void pp_detach(struct parport *port)
drivers/char/raw.c+3−4
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp, · 130 unmodified lines
131131 static void bind_device(struct raw_config_request *rq)
132132 {
133133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
134− device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
135− NULL, "raw%d", rq->raw_minor);
134+ device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL,
135+ "raw%d", rq->raw_minor);
136136 }
137137
138138 /*
@@ -283,8 +283,7 @@ static int __init raw_init(void) · 144 unmodified lines
283283 ret = PTR_ERR(raw_class);
284284 goto error_region;
285285 }
286− device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
287− "rawctl");
286+ device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
288287
289288 return 0;
290289
drivers/char/snsc.c+2−2
@@ -444,8 +444,8 @@ scdrv_init(void) · 443 unmodified lines
444444 continue;
445445 }
446446
447− device_create_drvdata(snsc_class, NULL, dev, NULL,
448− "%s", devname);
447+ device_create(snsc_class, NULL, dev, NULL,
448+ "%s", devname);
449449
450450 ia64_sn_irtr_intr_enable(scd->scd_nasid,
451451 0 /*ignored */ ,
drivers/char/stallion.c+2−2
@@ -4743,8 +4743,8 @@ static int __init stallion_module_init(void) · 4742 unmodified lines
47434743 if (IS_ERR(stallion_class))
47444744 printk("STALLION: failed to create class\n");
47454745 for (i = 0; i < 4; i++)
4746− device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4747− NULL, "staliomem%d", i);
4746+ device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4747+ NULL, "staliomem%d", i);
47484748
47494749 return 0;
47504750 err_unrtty:
drivers/char/tty_io.c+1−1
@@ -2850,7 +2850,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, · 2849 unmodified lines
28502850 else
28512851 tty_line_name(driver, index, name);
28522852
2853− return device_create_drvdata(tty_class, device, dev, NULL, name);
2853+ return device_create(tty_class, device, dev, NULL, name);
28542854 }
28552855 EXPORT_SYMBOL(tty_register_device);
28562856
drivers/char/vc_screen.c+6−6
@@ -481,10 +481,10 @@ static struct class *vc_class; · 480 unmodified lines
481481
482482 void vcs_make_sysfs(struct tty_struct *tty)
483483 {
484− device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
485− NULL, "vcs%u", tty->index + 1);
486− device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
487− NULL, "vcsa%u", tty->index + 1);
484+ device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL,
485+ "vcs%u", tty->index + 1);
486+ device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL,
487+ "vcsa%u", tty->index + 1);
488488 }
489489
490490 void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void) · 8 unmodified lines
499499 panic("unable to get major %d for vcs device", VCS_MAJOR);
500500 vc_class = class_create(THIS_MODULE, "vc");
501501
502− device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
503− device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
502+ device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
503+ device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
504504 return 0;
505505 }
drivers/char/viotape.c+4−4
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) · 885 unmodified lines
886886 state[i].cur_part = 0;
887887 for (j = 0; j < MAX_PARTITIONS; ++j)
888888 state[i].part_stat_rwi[j] = VIOT_IDLE;
889− device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
890− NULL, "iseries!vt%d", i);
891− device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
892− NULL, "iseries!nvt%d", i);
889+ device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL,
890+ "iseries!vt%d", i);
891+ device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), NULL,
892+ "iseries!nvt%d", i);
893893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
894894 "resource %10.10s type %4.4s, model %3.3s\n",
895895 i, viotape_unitinfo[i].rsrcname,
drivers/char/xilinx_hwicap/xilinx_hwicap.c+1−2
@@ -657,8 +657,7 @@ static int __devinit hwicap_setup(struct device *dev, int id, · 656 unmodified lines
657657 goto failed3;
658658 }
659659
660− device_create_drvdata(icap_class, dev, devt, NULL,
661− "%s%d", DRIVER_NAME, id);
660+ device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
662661 return 0; /* success */
663662
664663 failed3:
drivers/dca/dca-sysfs.c+3−5
@@ -15,9 +15,8 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot) · 14 unmodified lines
1515 struct device *cd;
1616 static int req_count;
1717
18− cd = device_create_drvdata(dca_class, dca->cd,
19− MKDEV(0, slot + 1), NULL,
20− "requester%d", req_count++);
18+ cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), NULL,
19+ "requester%d", req_count++);
2120 if (IS_ERR(cd))
2221 return PTR_ERR(cd);
2322 return 0;
@@ -48,8 +47,7 @@ idr_try_again: · 24 unmodified lines
4847 return err;
4948 }
5049
51− cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL,
52− "dca%d", dca->id);
50+ cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
5351 if (IS_ERR(cd)) {
5452 spin_lock(&dca_idr_lock);
5553 idr_remove(&dca_idr, dca->id);
drivers/firmware/iscsi_ibft.c+9−9
@@ -334,9 +334,9 @@ static void ibft_release(struct kobject *kobj) · 333 unmodified lines
334334 /*
335335 * Routines for parsing the iBFT data to be human readable.
336336 */
337−ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
338− struct ibft_attribute *attr,
339− char *buf)
337+static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
338+ struct ibft_attribute *attr,
339+ char *buf)
340340 {
341341 struct ibft_initiator *initiator = entry->initiator;
342342 void *ibft_loc = entry->header;
@@ -376,9 +376,9 @@ ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, · 33 unmodified lines
376376 return str - buf;
377377 }
378378
379−ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
380− struct ibft_attribute *attr,
381− char *buf)
379+static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
380+ struct ibft_attribute *attr,
381+ char *buf)
382382 {
383383 struct ibft_nic *nic = entry->nic;
384384 void *ibft_loc = entry->header;
@@ -440,9 +440,9 @@ ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, · 55 unmodified lines
440440 return str - buf;
441441 };
442442
443−ssize_t ibft_attr_show_target(struct ibft_kobject *entry,
444− struct ibft_attribute *attr,
445− char *buf)
443+static ssize_t ibft_attr_show_target(struct ibft_kobject *entry,
444+ struct ibft_attribute *attr,
445+ char *buf)
446446 {
447447 struct ibft_tgt *tgt = entry->tgt;
448448 void *ibft_loc = entry->header;
drivers/hid/hidraw.c+2−3
@@ -326,9 +326,8 @@ int hidraw_connect(struct hid_device *hid) · 325 unmodified lines
326326 goto out;
327327 }
328328
329− dev->dev = device_create_drvdata(hidraw_class, NULL,
330− MKDEV(hidraw_major, minor), NULL,
331− "%s%d", "hidraw", minor);
329+ dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
330+ NULL, "%s%d", "hidraw", minor);
332331
333332 if (IS_ERR(dev->dev)) {
334333 spin_lock(&minors_lock);
drivers/hwmon/hwmon.c+2−2
@@ -55,8 +55,8 @@ again: · 54 unmodified lines
5555 return ERR_PTR(err);
5656
5757 id = id & MAX_ID_MASK;
58− hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
59− HWMON_ID_FORMAT, id);
58+ hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
59+ HWMON_ID_FORMAT, id);
6060
6161 if (IS_ERR(hwdev)) {
6262 spin_lock(&idr_lock);
drivers/i2c/i2c-dev.c+3−3
@@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) · 520 unmodified lines
521521 return PTR_ERR(i2c_dev);
522522
523523 /* register this i2c device with the driver core */
524− i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev,
525− MKDEV(I2C_MAJOR, adap->nr),
526− NULL, "i2c-%d", adap->nr);
524+ i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
525+ MKDEV(I2C_MAJOR, adap->nr), NULL,
526+ "i2c-%d", adap->nr);
527527 if (IS_ERR(i2c_dev->dev)) {
528528 res = PTR_ERR(i2c_dev->dev);
529529 goto error;
drivers/ide/ide-probe.c+2−2
@@ -657,8 +657,8 @@ static int ide_register_port(ide_hwif_t *hwif) · 656 unmodified lines
657657 goto out;
658658 }
659659
660− hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev,
661− MKDEV(0, 0), hwif, hwif->name);
660+ hwif->portdev = device_create(ide_port_class, &hwif->gendev,
661+ MKDEV(0, 0), hwif, hwif->name);
662662 if (IS_ERR(hwif->portdev)) {
663663 ret = PTR_ERR(hwif->portdev);
664664 device_unregister(&hwif->gendev);
drivers/ide/ide-tape.c+5−6
@@ -2420,12 +2420,11 @@ static int ide_tape_probe(ide_drive_t *drive) · 2419 unmodified lines
24202420
24212421 idetape_setup(drive, tape, minor);
24222422
2423− device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2424− MKDEV(IDETAPE_MAJOR, minor), NULL,
2425− "%s", tape->name);
2426− device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2427− MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2428− "n%s", tape->name);
2423+ device_create(idetape_sysfs_class, &drive->gendev,
2424+ MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name);
2425+ device_create(idetape_sysfs_class, &drive->gendev,
2426+ MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2427+ "n%s", tape->name);
24292428
24302429 g->fops = &idetape_block_ops;
24312430 ide_register_region(g);
drivers/ieee1394/dv1394.c+4−4
@@ -2296,10 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host) · 2295 unmodified lines
22962296
22972297 ohci = (struct ti_ohci *)host->hostdata;
22982298
2299− device_create_drvdata(hpsb_protocol_class, NULL,
2300− MKDEV(IEEE1394_MAJOR,
2301− IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
2302− "dv1394-%d", id);
2299+ device_create(hpsb_protocol_class, NULL,
2300+ MKDEV(IEEE1394_MAJOR,
2301+ IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2302+ NULL, "dv1394-%d", id);
23032303
23042304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
23052305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
drivers/ieee1394/raw1394.c+4−4
@@ -3010,10 +3010,10 @@ static int __init init_raw1394(void) · 3009 unmodified lines
30103010 hpsb_register_highlevel(&raw1394_highlevel);
30113011
30123012 if (IS_ERR
3013− (device_create_drvdata(
3014− hpsb_protocol_class, NULL,
3015− MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016− NULL, RAW1394_DEVICE_NAME))) {
3013+ (device_create(hpsb_protocol_class, NULL,
3014+ MKDEV(IEEE1394_MAJOR,
3015+ IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016+ NULL, RAW1394_DEVICE_NAME))) {
30173017 ret = -EFAULT;
30183018 goto out_unreg;
30193019 }
drivers/ieee1394/video1394.c+2−3
@@ -1341,9 +1341,8 @@ static void video1394_add_host (struct hpsb_host *host) · 1340 unmodified lines
13411341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
13421342
13431343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1344− device_create_drvdata(hpsb_protocol_class, NULL,
1345− MKDEV(IEEE1394_MAJOR, minor), NULL,
1346− "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1344+ device_create(hpsb_protocol_class, NULL, MKDEV(IEEE1394_MAJOR, minor),
1345+ NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
13471346 }
13481347
13491348
drivers/infiniband/core/cm.c+3−3
@@ -3691,9 +3691,9 @@ static void cm_add_one(struct ib_device *ib_device) · 3690 unmodified lines
36913691 cm_dev->ib_device = ib_device;
36923692 cm_get_ack_delay(cm_dev);
36933693
3694− cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
3695− MKDEV(0, 0), NULL,
3696− "%s", ib_device->name);
3694+ cm_dev->device = device_create(&cm_class, &ib_device->dev,
3695+ MKDEV(0, 0), NULL,
3696+ "%s", ib_device->name);
36973697 if (!cm_dev->device) {
36983698 kfree(cm_dev);
36993699 return;
drivers/infiniband/core/user_mad.c+6−6
@@ -1016,9 +1016,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, · 1015 unmodified lines
10161016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
10171017 goto err_cdev;
10181018
1019− port->dev = device_create_drvdata(umad_class, device->dma_device,
1020− port->cdev->dev, port,
1021− "umad%d", port->dev_num);
1019+ port->dev = device_create(umad_class, device->dma_device,
1020+ port->cdev->dev, port,
1021+ "umad%d", port->dev_num);
10221022 if (IS_ERR(port->dev))
10231023 goto err_cdev;
10241024
@@ -1036,9 +1036,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, · 11 unmodified lines
10361036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
10371037 goto err_sm_cdev;
10381038
1039− port->sm_dev = device_create_drvdata(umad_class, device->dma_device,
1040− port->sm_cdev->dev, port,
1041− "issm%d", port->dev_num);
1039+ port->sm_dev = device_create(umad_class, device->dma_device,
1040+ port->sm_cdev->dev, port,
1041+ "issm%d", port->dev_num);
10421042 if (IS_ERR(port->sm_dev))
10431043 goto err_sm_cdev;
10441044
drivers/infiniband/core/uverbs_main.c+3−6
@@ -764,12 +764,9 @@ static void ib_uverbs_add_one(struct ib_device *device) · 763 unmodified lines
764764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
765765 goto err_cdev;
766766
767− uverbs_dev->dev = device_create_drvdata(uverbs_class,
768− device->dma_device,
769− uverbs_dev->cdev->dev,
770− uverbs_dev,
771− "uverbs%d",
772− uverbs_dev->devnum);
767+ uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
768+ uverbs_dev->cdev->dev, uverbs_dev,
769+ "uverbs%d", uverbs_dev->devnum);
773770 if (IS_ERR(uverbs_dev->dev))
774771 goto err_cdev;
775772
drivers/infiniband/hw/ipath/ipath_file_ops.c+1−1
@@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, · 2454 unmodified lines
24552455 goto err_cdev;
24562456 }
24572457
2458− device = device_create_drvdata(ipath_class, NULL, dev, NULL, name);
2458+ device = device_create(ipath_class, NULL, dev, NULL, name);
24592459
24602460 if (IS_ERR(device)) {
24612461 ret = PTR_ERR(device);
drivers/isdn/capi/capi.c+1−2
@@ -1553,8 +1553,7 @@ static int __init capi_init(void) · 1552 unmodified lines
15531553 return PTR_ERR(capi_class);
15541554 }
15551555
1556− device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL,
1557− "capi");
1556+ device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
15581557
15591558 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
15601559 if (capinc_tty_init() < 0) {
drivers/leds/led-class.c+2−2
@@ -103,8 +103,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) · 102 unmodified lines
103103 {
104104 int rc;
105105
106− led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev,
107− "%s", led_cdev->name);
106+ led_cdev->dev = device_create(leds_class, parent, 0, led_cdev,
107+ "%s", led_cdev->name);
108108 if (IS_ERR(led_cdev->dev))
109109 return PTR_ERR(led_cdev->dev);
110110
drivers/macintosh/adb.c+1−2
@@ -862,8 +862,7 @@ adbdev_init(void) · 861 unmodified lines
862862 adb_dev_class = class_create(THIS_MODULE, "adb");
863863 if (IS_ERR(adb_dev_class))
864864 return;
865− device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL,
866− "adb");
865+ device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
867866
868867 platform_device_register(&adb_pfdev);
869868 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
drivers/media/dvb/dvb-core/dvbdev.c+1−1
@@ -233,7 +233,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, · 232 unmodified lines
233233
234234 mutex_unlock(&dvbdev_register_lock);
235235
236− clsdev = device_create_drvdata(dvb_class, adap->device,
236+ clsdev = device_create(dvb_class, adap->device,
237237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
238238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
239239 if (IS_ERR(clsdev)) {
drivers/misc/phantom.c+3−3
@@ -399,9 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev, · 398 unmodified lines
399399 goto err_irq;
400400 }
401401
402− if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev,
403− MKDEV(phantom_major, minor),
404− NULL, "phantom%u", minor)))
402+ if (IS_ERR(device_create(phantom_class, &pdev->dev,
403+ MKDEV(phantom_major, minor), NULL,
404+ "phantom%u", minor)))
405405 dev_err(&pdev->dev, "can't create device\n");
406406
407407 pci_set_drvdata(pdev, pht);
drivers/mtd/mtdchar.c+4−6
@@ -26,13 +26,11 @@ static void mtd_notify_add(struct mtd_info* mtd) · 25 unmodified lines
2626 if (!mtd)
2727 return;
2828
29− device_create_drvdata(mtd_class, NULL,
30− MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
31− NULL, "mtd%d", mtd->index);
29+ device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
30+ NULL, "mtd%d", mtd->index);
3231
33− device_create_drvdata(mtd_class, NULL,
34− MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
35− NULL, "mtd%dro", mtd->index);
32+ device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
33+ NULL, "mtd%dro", mtd->index);
3634 }
3735
3836 static void mtd_notify_remove(struct mtd_info* mtd)
drivers/net/phy/phy_device.c+1−7
@@ -309,11 +309,6 @@ void phy_disconnect(struct phy_device *phydev) · 308 unmodified lines
309309 }
310310 EXPORT_SYMBOL(phy_disconnect);
311311
312−static int phy_compare_id(struct device *dev, void *data)
313−{
314− return strcmp((char *)data, dev->bus_id) ? 0 : 1;
315−}
316−
317312 /**
318313 * phy_attach - attach a network device to a particular PHY device
319314 * @dev: network device to attach
@@ -337,8 +332,7 @@ struct phy_device *phy_attach(struct net_device *dev, · 17 unmodified lines
337332
338333 /* Search the list of PHY devices on the mdio bus for the
339334 * PHY with the requested name */
340− d = bus_find_device(bus, NULL, (void *)bus_id, phy_compare_id);
341−
335+ d = bus_find_device_by_name(bus, NULL, bus_id);
342336 if (d) {
343337 phydev = to_phy_device(d);
344338 } else {
drivers/net/ppp_generic.c+2−2
@@ -866,8 +866,8 @@ static int __init ppp_init(void) · 865 unmodified lines
866866 err = PTR_ERR(ppp_class);
867867 goto out_chrdev;
868868 }
869− device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0),
870− NULL, "ppp");
869+ device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL,
870+ "ppp");
871871 }
872872
873873 out:
drivers/net/wan/cosa.c+2−2
@@ -388,8 +388,8 @@ static int __init cosa_init(void) · 387 unmodified lines
388388 goto out_chrdev;
389389 }
390390 for (i = 0; i < nr_cards; i++)
391− device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i),
392− NULL, "cosa%d", i);
391+ device_create(cosa_class, NULL, MKDEV(cosa_major, i), NULL,
392+ "cosa%d", i);
393393 err = 0;
394394 goto out;
395395
drivers/net/wireless/mac80211_hwsim.c+3−3
@@ -533,11 +533,11 @@ static int __init init_mac80211_hwsim(void) · 532 unmodified lines
533533 data = hw->priv;
534534 data->hw = hw;
535535
536− data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw,
537− "hwsim%d", i);
536+ data->dev = device_create(hwsim_class, NULL, 0, hw,
537+ "hwsim%d", i);
538538 if (IS_ERR(data->dev)) {
539539 printk(KERN_DEBUG
540− "mac80211_hwsim: device_create_drvdata "
540+ "mac80211_hwsim: device_create "
541541 "failed (%ld)\n", PTR_ERR(data->dev));
542542 err = -ENOMEM;
543543 goto failed_drvdata;
drivers/pci/probe.c+5−45
@@ -1237,8 +1237,11 @@ EXPORT_SYMBOL(pci_scan_bridge); · 1236 unmodified lines
12371237 EXPORT_SYMBOL_GPL(pci_scan_child_bus);
12381238 #endif
12391239
1240−static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b)
1240+static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
12411241 {
1242+ const struct pci_dev *a = to_pci_dev(d_a);
1243+ const struct pci_dev *b = to_pci_dev(d_b);
1244+
12421245 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
12431246 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1;
12441247
@@ -1251,50 +1254,7 @@ static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev · 6 unmodified lines
12511254 return 0;
12521255 }
12531256
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− */
1261−static 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−
12801257 void __init pci_sort_breadthfirst(void)
12811258 {
1282− LIST_HEAD(sorted_devices);
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);
1259+ bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp);
13001260 }
drivers/pnp/base.h+1−1
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 */
55
66 extern spinlock_t pnp_lock;
7+extern struct device_attribute pnp_interface_attrs[];
78 void *pnp_alloc(long size);
89
910 int pnp_register_protocol(struct pnp_protocol *protocol);
@@ -16,7 +17,6 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid); · 6 unmodified lines
1617
1718 int pnp_add_device(struct pnp_dev *dev);
1819 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
19−int pnp_interface_attach_device(struct pnp_dev *dev);
2020
2121 int pnp_add_card(struct pnp_card *card);
2222 void pnp_remove_card(struct pnp_card *card);
drivers/pnp/core.c+1−9
@@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid · 158 unmodified lines
159159
160160 int __pnp_add_device(struct pnp_dev *dev)
161161 {
162− int ret;
163−
164162 pnp_fixup_device(dev);
165163 dev->status = PNP_READY;
166164 spin_lock(&pnp_lock);
167165 list_add_tail(&dev->global_list, &pnp_global);
168166 list_add_tail(&dev->protocol_list, &dev->protocol->devices);
169167 spin_unlock(&pnp_lock);
170−
171− ret = device_register(&dev->dev);
172− if (ret)
173− return ret;
174−
175− pnp_interface_attach_device(dev);
176− return 0;
168+ return device_register(&dev->dev);
177169 }
178170
179171 /*
drivers/pnp/driver.c+1−0
@@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = { · 205 unmodified lines
206206 .remove = pnp_device_remove,
207207 .suspend = pnp_bus_suspend,
208208 .resume = pnp_bus_resume,
209+ .dev_attrs = pnp_interface_attrs,
209210 };
210211
211212 int pnp_register_driver(struct pnp_driver *drv)
drivers/pnp/interface.c+8−29
@@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev, · 242 unmodified lines
243243 return ret;
244244 }
245245
246−static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
247−
248246 static ssize_t pnp_show_current_resources(struct device *dmdev,
249247 struct device_attribute *attr,
250248 char *buf)
@@ -420,9 +418,6 @@ done: · 169 unmodified lines
420418 return count;
421419 }
422420
423−static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
424− pnp_show_current_resources, pnp_set_current_resources);
425−
426421 static ssize_t pnp_show_current_ids(struct device *dmdev,
427422 struct device_attribute *attr, char *buf)
428423 {
@@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev, · 8 unmodified lines
437432 return (str - buf);
438433 }
439434
440−static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL);
441−
442−int pnp_interface_attach_device(struct pnp_dev *dev)
443−{
444− int rc = device_create_file(&dev->dev, &dev_attr_options);
445−
446− if (rc)
447− goto err;
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−
457−err_res:
458− device_remove_file(&dev->dev, &dev_attr_resources);
459−err_opt:
460− device_remove_file(&dev->dev, &dev_attr_options);
461−err:
462− return rc;
463−}
435+struct device_attribute pnp_interface_attrs[] = {
436+ __ATTR(resources, S_IRUGO | S_IWUSR,
437+ pnp_show_current_resources,
438+ pnp_set_current_resources),
439+ __ATTR(options, S_IRUGO, pnp_show_options, NULL),
440+ __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
441+ __ATTR_NULL,
442+};
drivers/power/power_supply_core.c+2−2
@@ -91,8 +91,8 @@ int power_supply_register(struct device *parent, struct power_supply *psy) · 90 unmodified lines
9191 {
9292 int rc = 0;
9393
94− psy->dev = device_create_drvdata(power_supply_class, parent, 0,
95− psy, "%s", psy->name);
94+ psy->dev = device_create(power_supply_class, parent, 0, psy,
95+ "%s", psy->name);
9696 if (IS_ERR(psy->dev)) {
9797 rc = PTR_ERR(psy->dev);
9898 goto dev_create_failed;
drivers/s390/char/raw3270.c+6−8
@@ -1168,19 +1168,17 @@ static int raw3270_create_attributes(struct raw3270 *rp) · 1167 unmodified lines
11681168 if (rc)
11691169 goto out;
11701170
1171− rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev,
1172− MKDEV(IBM_TTY3270_MAJOR, rp->minor),
1173− NULL,
1174− "tty%s", dev_name(&rp->cdev->dev));
1171+ rp->clttydev = device_create(class3270, &rp->cdev->dev,
1172+ MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL,
1173+ "tty%s", dev_name(&rp->cdev->dev));
11751174 if (IS_ERR(rp->clttydev)) {
11761175 rc = PTR_ERR(rp->clttydev);
11771176 goto out_ttydev;
11781177 }
11791178
1180− rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev,
1181− MKDEV(IBM_FS3270_MAJOR, rp->minor),
1182− NULL,
1183− "tub%s", dev_name(&rp->cdev->dev));
1179+ rp->cltubdev = device_create(class3270, &rp->cdev->dev,
1180+ MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL,
1181+ "tub%s", dev_name(&rp->cdev->dev));
11841182 if (!IS_ERR(rp->cltubdev))
11851183 goto out;
11861184
drivers/s390/char/tape_class.c+3−3
@@ -69,9 +69,9 @@ struct tape_class_device *register_tape_dev( · 68 unmodified lines
6969 if (rc)
7070 goto fail_with_cdev;
7171
72− tcd->class_device = device_create_drvdata(tape_class, device,
73− tcd->char_device->dev,
74− NULL, "%s", tcd->device_name);
72+ tcd->class_device = device_create(tape_class, device,
73+ tcd->char_device->dev, NULL,
74+ "%s", tcd->device_name);
7575 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
7676 if (rc)
7777 goto fail_with_cdev;
drivers/s390/char/vmlogrdr.c+4−4
@@ -747,10 +747,10 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) · 746 unmodified lines
747747 device_unregister(dev);
748748 return ret;
749749 }
750− priv->class_device = device_create_drvdata(vmlogrdr_class, dev,
751− MKDEV(vmlogrdr_major,
752− priv->minor_num),
753− priv, "%s", dev_name(dev));
750+ priv->class_device = device_create(vmlogrdr_class, dev,
751+ MKDEV(vmlogrdr_major,
752+ priv->minor_num),
753+ priv, "%s", dev_name(dev));
754754 if (IS_ERR(priv->class_device)) {
755755 ret = PTR_ERR(priv->class_device);
756756 priv->class_device=NULL;
drivers/s390/char/vmur.c+2−3
@@ -896,9 +896,8 @@ static int ur_set_online(struct ccw_device *cdev) · 895 unmodified lines
896896 goto fail_free_cdev;
897897 }
898898
899− urd->device = device_create_drvdata(vmur_class, NULL,
900− urd->char_device->dev, NULL,
901− "%s", node_id);
899+ urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
900+ NULL, "%s", node_id);
902901 if (IS_ERR(urd->device)) {
903902 rc = PTR_ERR(urd->device);
904903 TRACE("ur_set_online: device_create rc=%d\n", rc);
drivers/scsi/ch.c+3−3
@@ -914,9 +914,9 @@ static int ch_probe(struct device *dev) · 913 unmodified lines
914914 ch->minor = minor;
915915 sprintf(ch->name,"ch%d",ch->minor);
916916
917− class_dev = device_create_drvdata(ch_sysfs_class, dev,
918− MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
919− ch, "s%s", ch->name);
917+ class_dev = device_create(ch_sysfs_class, dev,
918+ MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch,
919+ "s%s", ch->name);
920920 if (IS_ERR(class_dev)) {
921921 printk(KERN_WARNING "ch%d: device_create failed\n",
922922 ch->minor);
drivers/scsi/dpt_i2o.c+1−1
@@ -271,7 +271,7 @@ rebuild_sys_tab: · 270 unmodified lines
271271 pHba->initialized = TRUE;
272272 pHba->state &= ~DPTI_STATE_RESET;
273273 if (adpt_sysfs_class) {
274− struct device *dev = device_create_drvdata(adpt_sysfs_class,
274+ struct device *dev = device_create(adpt_sysfs_class,
275275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
276276 "dpti%d", pHba->unit);
277277 if (IS_ERR(dev)) {
drivers/scsi/osst.c+2−1
@@ -5708,7 +5708,8 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S · 5707 unmodified lines
57085708 struct device *osst_member;
57095709 int err;
57105710
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);
57125713 if (IS_ERR(osst_member)) {
57135714 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
57145715 return PTR_ERR(osst_member);
drivers/scsi/sg.c+4−6
@@ -1450,12 +1450,10 @@ sg_add(struct device *cl_dev, struct class_interface *cl_intf) · 1449 unmodified lines
14501450 if (sg_sysfs_valid) {
14511451 struct device *sg_class_member;
14521452
1453− sg_class_member = device_create_drvdata(sg_sysfs_class,
1454− cl_dev->parent,
1455− MKDEV(SCSI_GENERIC_MAJOR,
1456− sdp->index),
1457− sdp,
1458− "%s", disk->disk_name);
1453+ sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
1454+ MKDEV(SCSI_GENERIC_MAJOR,
1455+ sdp->index),
1456+ sdp, "%s", disk->disk_name);
14591457 if (IS_ERR(sg_class_member)) {
14601458 printk(KERN_ERR "sg_add: "
14611459 "device_create failed\n");
drivers/scsi/st.c+4−7
@@ -4428,13 +4428,10 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) · 4427 unmodified lines
44284428 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
44294429 STp->disk->disk_name, st_formats[i]);
44304430 st_class_member =
4431− device_create_drvdata(st_sysfs_class,
4432− &STp->device->sdev_gendev,
4433− MKDEV(SCSI_TAPE_MAJOR,
4434− TAPE_MINOR(dev_num,
4435− mode, rew)),
4436− &STp->modes[mode],
4437− "%s", name);
4431+ device_create(st_sysfs_class, &STp->device->sdev_gendev,
4432+ MKDEV(SCSI_TAPE_MAJOR,
4433+ TAPE_MINOR(dev_num, mode, rew)),
4434+ &STp->modes[mode], "%s", name);
44384435 if (IS_ERR(st_class_member)) {
44394436 printk(KERN_WARNING "st%d: device_create failed\n",
44404437 dev_num);
drivers/spi/spidev.c+3−4
@@ -583,10 +583,9 @@ static int spidev_probe(struct spi_device *spi) · 582 unmodified lines
583583 struct device *dev;
584584
585585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
586− dev = device_create_drvdata(spidev_class, &spi->dev,
587− spidev->devt, spidev,
588− "spidev%d.%d",
589− spi->master->bus_num, spi->chip_select);
586+ dev = device_create(spidev_class, &spi->dev, spidev->devt,
587+ spidev, "spidev%d.%d",
588+ spi->master->bus_num, spi->chip_select);
590589 status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
591590 } else {
592591 dev_dbg(&spi->dev, "no minor number available!\n");
drivers/uio/Kconfig+13−0
@@ -58,4 +58,17 @@ config UIO_SMX · 57 unmodified lines
5858
5959 If you compile this as a module, it will be called uio_smx.
6060
61+config 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+
6174 endif
drivers/uio/Makefile+1−0
@@ -3,3 +3,4 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o · 2 unmodified lines
33 obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
44 obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o
55 obj-$(CONFIG_UIO_SMX) += uio_smx.o
6+obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
drivers/uio/uio.c+21−5
@@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf) · 66 unmodified lines
6767 return sprintf(buf, "0x%lx\n", mem->size);
6868 }
6969
70+static 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+
7075 struct uio_sysfs_entry {
7176 struct attribute attr;
7277 ssize_t (*show)(struct uio_mem *, char *);
@@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attribute = · 4 unmodified lines
7782 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
7883 static struct uio_sysfs_entry size_attribute =
7984 __ATTR(size, S_IRUGO, map_size_show, NULL);
85+static struct uio_sysfs_entry offset_attribute =
86+ __ATTR(offset, S_IRUGO, map_offset_show, NULL);
8087
8188 static struct attribute *attrs[] = {
8289 &addr_attribute.attr,
8390 &size_attribute.attr,
91+ &offset_attribute.attr,
8492 NULL, /* need to NULL terminate the list of attributes */
8593 };
8694
@@ -482,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · 395 unmodified lines
482490 {
483491 struct uio_device *idev = vma->vm_private_data;
484492 struct page *page;
493+ unsigned long offset;
485494
486495 int mi = uio_find_mem_index(vma);
487496 if (mi < 0)
488497 return VM_FAULT_SIGBUS;
489498
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+
490505 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);
492507 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);
494510 get_page(page);
495511 vmf->page = page;
496512 return 0;
@@ -682,9 +698,9 @@ int __uio_register_device(struct module *owner, · 185 unmodified lines
682698 if (ret)
683699 goto err_get_minor;
684700
685− idev->dev = device_create_drvdata(uio_class->class, parent,
686− MKDEV(uio_major, idev->minor), idev,
687− "uio%d", idev->minor);
701+ idev->dev = device_create(uio_class->class, parent,
702+ MKDEV(uio_major, idev->minor), idev,
703+ "uio%d", idev->minor);
688704 if (IS_ERR(idev->dev)) {
689705 printk(KERN_ERR "UIO: device register failed\n");
690706 ret = PTR_ERR(idev->dev);
drivers/uio/uio_pdrv.c+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <linux/uio_driver.h>
1313 #include <linux/stringify.h>
1414
15−#define DRIVER_NAME "uio"
15+#define DRIVER_NAME "uio_pdrv"
1616
1717 struct uio_platdata {
1818 struct uio_info *uioinfo;
drivers/uio/uio_sercos3.c+243−0
@@ -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+
44+struct sercos3_priv {
45+ u32 ier0_cache;
46+ spinlock_t ier0_cache_lock;
47+};
48+
49+/* this function assumes ier0_cache_lock is locked! */
50+static 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! */
63+static 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+
73+static 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+
89+static 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+
103+static 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+
118+static 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+
167+out_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);
173+out_disable:
174+ pci_disable_device(dev);
175+out_free_priv:
176+ kfree(priv);
177+out_free:
178+ kfree(info);
179+ return -ENODEV;
180+}
181+
182+static 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+
199+static 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+
221+static 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+
228+static int __init sercos3_init_module(void)
229+{
230+ return pci_register_driver(&sercos3_pci_driver);
231+}
232+
233+static void __exit sercos3_exit_module(void)
234+{
235+ pci_unregister_driver(&sercos3_pci_driver);
236+}
237+
238+module_init(sercos3_init_module);
239+module_exit(sercos3_exit_module);
240+
241+MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card");
242+MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>");
243+MODULE_LICENSE("GPL v2");
drivers/usb/core/devio.c+3−3
@@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev) · 1728 unmodified lines
17291729 {
17301730 struct device *cldev;
17311731
1732− cldev = device_create_drvdata(usb_classdev_class, &dev->dev,
1733− dev->dev.devt, NULL, "usbdev%d.%d",
1734− dev->bus->busnum, dev->devnum);
1732+ cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
1733+ NULL, "usbdev%d.%d", dev->bus->busnum,
1734+ dev->devnum);
17351735 if (IS_ERR(cldev))
17361736 return PTR_ERR(cldev);
17371737 dev->usb_classdev = cldev;
drivers/usb/core/file.c+3−3
@@ -196,9 +196,9 @@ int usb_register_dev(struct usb_interface *intf, · 195 unmodified lines
196196 ++temp;
197197 else
198198 temp = name;
199− intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev,
200− MKDEV(USB_MAJOR, minor), NULL,
201− "%s", temp);
199+ intf->usb_dev = device_create(usb_class->class, &intf->dev,
200+ MKDEV(USB_MAJOR, minor), NULL,
201+ "%s", temp);
202202 if (IS_ERR(intf->usb_dev)) {
203203 down_write(&minor_rwsem);
204204 usb_minors[intf->minor] = NULL;
drivers/usb/core/hcd.c+2−3
@@ -818,9 +818,8 @@ static int usb_register_bus(struct usb_bus *bus) · 817 unmodified lines
818818 set_bit (busnum, busmap.busmap);
819819 bus->busnum = busnum;
820820
821− bus->dev = device_create_drvdata(usb_host_class, bus->controller,
822− MKDEV(0, 0), bus,
823− "usb_host%d", busnum);
821+ bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0),
822+ bus, "usb_host%d", busnum);
824823 result = PTR_ERR(bus->dev);
825824 if (IS_ERR(bus->dev))
826825 goto error_create_class_dev;
drivers/usb/gadget/Makefile+7−16
@@ -22,24 +22,15 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o · 21 unmodified lines
2222 #
2323 # USB gadget drivers
2424 #
25−C_UTILS = composite.o usbstring.o config.o epautoconf.o
26−
27−g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS)
28−g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS)
29−g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS)
30−g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
25+g_zero-objs := zero.o
26+g_ether-objs := ether.o
27+g_serial-objs := serial.o
28+g_midi-objs := gmidi.o
3129 gadgetfs-objs := inode.o
32−g_file_storage-objs := file_storage.o usbstring.o config.o \
33− epautoconf.o
34−g_printer-objs := printer.o usbstring.o config.o \
35− epautoconf.o
36−g_cdc-objs := cdc2.o u_ether.o f_ecm.o \
37− u_serial.o f_acm.o $(C_UTILS)
30+g_file_storage-objs := file_storage.o
31+g_printer-objs := printer.o
32+g_cdc-objs := cdc2.o
3833
39−ifeq ($(CONFIG_USB_ETH_RNDIS),y)
40− g_ether-objs += f_rndis.o rndis.o
41−endif
42−
4334 obj-$(CONFIG_USB_ZERO) += g_zero.o
4435 obj-$(CONFIG_USB_ETH) += g_ether.o
4536 obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
drivers/usb/gadget/cdc2.c+23−2
@@ -43,6 +43,25 @@ · 42 unmodified lines
4343
4444 /*-------------------------------------------------------------------------*/
4545
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+
4665 static struct usb_device_descriptor device_desc = {
4766 .bLength = sizeof device_desc,
4867 .bDescriptorType = USB_DT_DEVICE,
@@ -148,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) · 99 unmodified lines
148167 int status;
149168
150169 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);
152172 return -EINVAL;
153173 }
154174
@@ -203,7 +223,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) · 48 unmodified lines
203223 if (status < 0)
204224 goto fail1;
205225
206− INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC);
226+ dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
227+ DRIVER_DESC);
207228
208229 return 0;
209230
drivers/usb/gadget/ether.c+26−2
@@ -96,6 +96,28 @@ static inline bool has_rndis(void) · 95 unmodified lines
9696
9797 /*-------------------------------------------------------------------------*/
9898
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+
99121 /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
100122 * Instead: allocate your own, using normal USB-IF procedures.
101123 */
@@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) · 191 unmodified lines
293315 * but if the controller isn't recognized at all then
294316 * that assumption is a bit more likely to be wrong.
295317 */
296− WARNING(cdev, "controller '%s' not recognized; trying %s\n",
318+ dev_warn(&gadget->dev,
319+ "controller '%s' not recognized; trying %s\n",
297320 gadget->name,
298321 eth_config_driver.label);
299322 device_desc.bcdDevice =
@@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) · 32 unmodified lines
332355 if (status < 0)
333356 goto fail;
334357
335− INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC);
358+ dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
359+ DRIVER_DESC);
336360
337361 return 0;
338362
drivers/usb/gadget/f_ecm.c+54−54
@@ -83,7 +83,7 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f) · 82 unmodified lines
8383 }
8484
8585 /* peak (theoretical) bulk transfer rate in bits-per-second */
86−static inline unsigned bitrate(struct usb_gadget *g)
86+static inline unsigned ecm_bitrate(struct usb_gadget *g)
8787 {
8888 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
8989 return 13 * 512 * 8 * 1000 * 8;
@@ -107,7 +107,7 @@ static inline unsigned bitrate(struct usb_gadget *g) · 17 unmodified lines
107107 */
108108
109109 #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 */
111111
112112
113113 /* interface descriptor: */
@@ -125,8 +125,8 @@ static struct usb_interface_descriptor ecm_control_intf __initdata = { · 11 unmodified lines
125125 /* .iInterface = DYNAMIC */
126126 };
127127
128−static struct usb_cdc_header_desc header_desc __initdata = {
129− .bLength = sizeof header_desc,
128+static struct usb_cdc_header_desc ecm_header_desc __initdata = {
129+ .bLength = sizeof ecm_header_desc,
130130 .bDescriptorType = USB_DT_CS_INTERFACE,
131131 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
132132
@@ -141,8 +141,8 @@ static struct usb_cdc_union_desc ecm_union_desc __initdata = { · 8 unmodified lines
141141 /* .bSlaveInterface0 = DYNAMIC */
142142 };
143143
144−static struct usb_cdc_ether_desc ether_desc __initdata = {
145− .bLength = sizeof ether_desc,
144+static struct usb_cdc_ether_desc ecm_desc __initdata = {
145+ .bLength = sizeof ecm_desc,
146146 .bDescriptorType = USB_DT_CS_INTERFACE,
147147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE,
148148
@@ -186,17 +186,17 @@ static struct usb_interface_descriptor ecm_data_intf __initdata = { · 37 unmodified lines
186186
187187 /* full speed support: */
188188
189−static struct usb_endpoint_descriptor fs_notify_desc __initdata = {
189+static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = {
190190 .bLength = USB_DT_ENDPOINT_SIZE,
191191 .bDescriptorType = USB_DT_ENDPOINT,
192192
193193 .bEndpointAddress = USB_DIR_IN,
194194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195− .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT),
195+ .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
196196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
197197 };
198198
199−static struct usb_endpoint_descriptor fs_in_desc __initdata = {
199+static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = {
200200 .bLength = USB_DT_ENDPOINT_SIZE,
201201 .bDescriptorType = USB_DT_ENDPOINT,
202202
@@ -204,7 +204,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { · 1 unmodified line
204204 .bmAttributes = USB_ENDPOINT_XFER_BULK,
205205 };
206206
207−static struct usb_endpoint_descriptor fs_out_desc __initdata = {
207+static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = {
208208 .bLength = USB_DT_ENDPOINT_SIZE,
209209 .bDescriptorType = USB_DT_ENDPOINT,
210210
@@ -212,34 +212,34 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { · 1 unmodified line
212212 .bmAttributes = USB_ENDPOINT_XFER_BULK,
213213 };
214214
215−static struct usb_descriptor_header *eth_fs_function[] __initdata = {
215+static struct usb_descriptor_header *ecm_fs_function[] __initdata = {
216216 /* CDC ECM control descriptors */
217217 (struct usb_descriptor_header *) &ecm_control_intf,
218− (struct usb_descriptor_header *) &header_desc,
218+ (struct usb_descriptor_header *) &ecm_header_desc,
219219 (struct usb_descriptor_header *) &ecm_union_desc,
220− (struct usb_descriptor_header *) &ether_desc,
220+ (struct usb_descriptor_header *) &ecm_desc,
221221 /* 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,
223223 /* data interface, altsettings 0 and 1 */
224224 (struct usb_descriptor_header *) &ecm_data_nop_intf,
225225 (struct usb_descriptor_header *) &ecm_data_intf,
226− (struct usb_descriptor_header *) &fs_in_desc,
227− (struct usb_descriptor_header *) &fs_out_desc,
226+ (struct usb_descriptor_header *) &fs_ecm_in_desc,
227+ (struct usb_descriptor_header *) &fs_ecm_out_desc,
228228 NULL,
229229 };
230230
231231 /* high speed support: */
232232
233−static struct usb_endpoint_descriptor hs_notify_desc __initdata = {
233+static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = {
234234 .bLength = USB_DT_ENDPOINT_SIZE,
235235 .bDescriptorType = USB_DT_ENDPOINT,
236236
237237 .bEndpointAddress = USB_DIR_IN,
238238 .bmAttributes = USB_ENDPOINT_XFER_INT,
239− .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT),
239+ .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT),
240240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
241241 };
242−static struct usb_endpoint_descriptor hs_in_desc __initdata = {
242+static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
243243 .bLength = USB_DT_ENDPOINT_SIZE,
244244 .bDescriptorType = USB_DT_ENDPOINT,
245245
@@ -248,7 +248,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { · 2 unmodified lines
248248 .wMaxPacketSize = __constant_cpu_to_le16(512),
249249 };
250250
251−static struct usb_endpoint_descriptor hs_out_desc __initdata = {
251+static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
252252 .bLength = USB_DT_ENDPOINT_SIZE,
253253 .bDescriptorType = USB_DT_ENDPOINT,
254254
@@ -257,19 +257,19 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { · 2 unmodified lines
257257 .wMaxPacketSize = __constant_cpu_to_le16(512),
258258 };
259259
260−static struct usb_descriptor_header *eth_hs_function[] __initdata = {
260+static struct usb_descriptor_header *ecm_hs_function[] __initdata = {
261261 /* CDC ECM control descriptors */
262262 (struct usb_descriptor_header *) &ecm_control_intf,
263− (struct usb_descriptor_header *) &header_desc,
263+ (struct usb_descriptor_header *) &ecm_header_desc,
264264 (struct usb_descriptor_header *) &ecm_union_desc,
265− (struct usb_descriptor_header *) &ether_desc,
265+ (struct usb_descriptor_header *) &ecm_desc,
266266 /* 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,
268268 /* data interface, altsettings 0 and 1 */
269269 (struct usb_descriptor_header *) &ecm_data_nop_intf,
270270 (struct usb_descriptor_header *) &ecm_data_intf,
271− (struct usb_descriptor_header *) &hs_in_desc,
272− (struct usb_descriptor_header *) &hs_out_desc,
271+ (struct usb_descriptor_header *) &hs_ecm_in_desc,
272+ (struct usb_descriptor_header *) &hs_ecm_out_desc,
273273 NULL,
274274 };
275275
@@ -329,14 +329,14 @@ static void ecm_do_notify(struct f_ecm *ecm) · 53 unmodified lines
329329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE;
330330 event->wValue = cpu_to_le16(0);
331331 event->wLength = cpu_to_le16(8);
332− req->length = STATUS_BYTECOUNT;
332+ req->length = ECM_STATUS_BYTECOUNT;
333333
334334 /* SPEED_CHANGE data is up/down speeds in bits/sec */
335335 data = req->buf + sizeof *event;
336− data[0] = cpu_to_le32(bitrate(cdev->gadget));
336+ data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget));
337337 data[1] = data[0];
338338
339− DBG(cdev, "notify speed %d\n", bitrate(cdev->gadget));
339+ DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget));
340340 ecm->notify_state = ECM_NOTIFY_NONE;
341341 break;
342342 }
@@ -628,13 +628,13 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 285 unmodified lines
628628 status = -ENODEV;
629629
630630 /* 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);
632632 if (!ep)
633633 goto fail;
634634 ecm->port.in_ep = ep;
635635 ep->driver_data = cdev; /* claim */
636636
637− ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc);
637+ ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
638638 if (!ep)
639639 goto fail;
640640 ecm->port.out_ep = ep;
@@ -644,7 +644,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 3 unmodified lines
644644 * don't treat it that way. It's simpler, and some newer CDC
645645 * profiles (wireless handsets) no longer treat it as optional.
646646 */
647− ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc);
647+ ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc);
648648 if (!ep)
649649 goto fail;
650650 ecm->notify = ep;
@@ -656,47 +656,47 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 5 unmodified lines
656656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
657657 if (!ecm->notify_req)
658658 goto fail;
659− ecm->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL);
659+ ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL);
660660 if (!ecm->notify_req->buf)
661661 goto fail;
662662 ecm->notify_req->context = ecm;
663663 ecm->notify_req->complete = ecm_notify_complete;
664664
665665 /* copy descriptors, and track endpoint copies */
666− f->descriptors = usb_copy_descriptors(eth_fs_function);
666+ f->descriptors = usb_copy_descriptors(ecm_fs_function);
667667 if (!f->descriptors)
668668 goto fail;
669669
670− ecm->fs.in = usb_find_endpoint(eth_fs_function,
671− f->descriptors, &fs_in_desc);
672− ecm->fs.out = usb_find_endpoint(eth_fs_function,
673− f->descriptors, &fs_out_desc);
674− ecm->fs.notify = usb_find_endpoint(eth_fs_function,
675− f->descriptors, &fs_notify_desc);
670+ ecm->fs.in = usb_find_endpoint(ecm_fs_function,
671+ f->descriptors, &fs_ecm_in_desc);
672+ ecm->fs.out = usb_find_endpoint(ecm_fs_function,
673+ f->descriptors, &fs_ecm_out_desc);
674+ ecm->fs.notify = usb_find_endpoint(ecm_fs_function,
675+ f->descriptors, &fs_ecm_notify_desc);
676676
677677 /* support all relevant hardware speeds... we expect that when
678678 * hardware is dual speed, all bulk-capable endpoints work at
679679 * both speeds
680680 */
681681 if (gadget_is_dualspeed(c->cdev->gadget)) {
682− hs_in_desc.bEndpointAddress =
683− fs_in_desc.bEndpointAddress;
684− hs_out_desc.bEndpointAddress =
685− fs_out_desc.bEndpointAddress;
686− hs_notify_desc.bEndpointAddress =
687− fs_notify_desc.bEndpointAddress;
682+ hs_ecm_in_desc.bEndpointAddress =
683+ fs_ecm_in_desc.bEndpointAddress;
684+ hs_ecm_out_desc.bEndpointAddress =
685+ fs_ecm_out_desc.bEndpointAddress;
686+ hs_ecm_notify_desc.bEndpointAddress =
687+ fs_ecm_notify_desc.bEndpointAddress;
688688
689689 /* 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);
691691 if (!f->hs_descriptors)
692692 goto fail;
693693
694− ecm->hs.in = usb_find_endpoint(eth_hs_function,
695− f->hs_descriptors, &hs_in_desc);
696− ecm->hs.out = usb_find_endpoint(eth_hs_function,
697− f->hs_descriptors, &hs_out_desc);
698− ecm->hs.notify = usb_find_endpoint(eth_hs_function,
699− f->hs_descriptors, &hs_notify_desc);
694+ ecm->hs.in = usb_find_endpoint(ecm_hs_function,
695+ f->hs_descriptors, &hs_ecm_in_desc);
696+ ecm->hs.out = usb_find_endpoint(ecm_hs_function,
697+ f->hs_descriptors, &hs_ecm_out_desc);
698+ ecm->hs.notify = usb_find_endpoint(ecm_hs_function,
699+ f->hs_descriptors, &hs_ecm_notify_desc);
700700 }
701701
702702 /* 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]) · 92 unmodified lines
795795 if (status < 0)
796796 return status;
797797 ecm_string_defs[1].id = status;
798− ether_desc.iMACAddress = status;
798+ ecm_desc.iMACAddress = status;
799799 }
800800
801801 /* allocate and initialize one new instance */
drivers/usb/gadget/f_loopback.c+18−16
@@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = { · 69 unmodified lines
7070
7171 /* full speed support: */
7272
73−static struct usb_endpoint_descriptor fs_source_desc = {
73+static struct usb_endpoint_descriptor fs_loop_source_desc = {
7474 .bLength = USB_DT_ENDPOINT_SIZE,
7575 .bDescriptorType = USB_DT_ENDPOINT,
7676
@@ -78,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = { · 1 unmodified line
7878 .bmAttributes = USB_ENDPOINT_XFER_BULK,
7979 };
8080
81−static struct usb_endpoint_descriptor fs_sink_desc = {
81+static struct usb_endpoint_descriptor fs_loop_sink_desc = {
8282 .bLength = USB_DT_ENDPOINT_SIZE,
8383 .bDescriptorType = USB_DT_ENDPOINT,
8484
@@ -88,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = { · 3 unmodified lines
8888
8989 static struct usb_descriptor_header *fs_loopback_descs[] = {
9090 (struct usb_descriptor_header *) &loopback_intf,
91− (struct usb_descriptor_header *) &fs_sink_desc,
92− (struct usb_descriptor_header *) &fs_source_desc,
91+ (struct usb_descriptor_header *) &fs_loop_sink_desc,
92+ (struct usb_descriptor_header *) &fs_loop_source_desc,
9393 NULL,
9494 };
9595
9696 /* high speed support: */
9797
98−static struct usb_endpoint_descriptor hs_source_desc = {
98+static struct usb_endpoint_descriptor hs_loop_source_desc = {
9999 .bLength = USB_DT_ENDPOINT_SIZE,
100100 .bDescriptorType = USB_DT_ENDPOINT,
101101
@@ -103,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = { · 1 unmodified line
103103 .wMaxPacketSize = __constant_cpu_to_le16(512),
104104 };
105105
106−static struct usb_endpoint_descriptor hs_sink_desc = {
106+static struct usb_endpoint_descriptor hs_loop_sink_desc = {
107107 .bLength = USB_DT_ENDPOINT_SIZE,
108108 .bDescriptorType = USB_DT_ENDPOINT,
109109
@@ -113,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = { · 3 unmodified lines
113113
114114 static struct usb_descriptor_header *hs_loopback_descs[] = {
115115 (struct usb_descriptor_header *) &loopback_intf,
116− (struct usb_descriptor_header *) &hs_source_desc,
117− (struct usb_descriptor_header *) &hs_sink_desc,
116+ (struct usb_descriptor_header *) &hs_loop_source_desc,
117+ (struct usb_descriptor_header *) &hs_loop_sink_desc,
118118 NULL,
119119 };
120120
@@ -152,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f) · 31 unmodified lines
152152
153153 /* allocate endpoints */
154154
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);
156156 if (!loop->in_ep) {
157157 autoconf_fail:
158158 ERROR(cdev, "%s: can't autoconfigure on %s\n",
@@ -161,17 +161,17 @@ autoconf_fail: · 2 unmodified lines
161161 }
162162 loop->in_ep->driver_data = cdev; /* claim */
163163
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);
165165 if (!loop->out_ep)
166166 goto autoconf_fail;
167167 loop->out_ep->driver_data = cdev; /* claim */
168168
169169 /* support high speed hardware */
170170 if (gadget_is_dualspeed(c->cdev->gadget)) {
171− hs_source_desc.bEndpointAddress =
172− fs_source_desc.bEndpointAddress;
173− hs_sink_desc.bEndpointAddress =
174− fs_sink_desc.bEndpointAddress;
171+ hs_loop_source_desc.bEndpointAddress =
172+ fs_loop_source_desc.bEndpointAddress;
173+ hs_loop_sink_desc.bEndpointAddress =
174+ fs_loop_sink_desc.bEndpointAddress;
175175 f->hs_descriptors = hs_loopback_descs;
176176 }
177177
@@ -255,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) · 77 unmodified lines
255255 struct usb_request *req;
256256 unsigned i;
257257
258− src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc);
259− sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc);
258+ src = ep_choose(cdev->gadget,
259+ &hs_loop_source_desc, &fs_loop_source_desc);
260+ sink = ep_choose(cdev->gadget,
261+ &hs_loop_sink_desc, &fs_loop_sink_desc);
260262
261263 /* one endpoint writes data back IN to the host */
262264 ep = loop->in_ep;
drivers/usb/gadget/f_subset.c+22−22
@@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = { · 102 unmodified lines
103103 /* .iInterface = DYNAMIC */
104104 };
105105
106−static struct usb_cdc_header_desc header_desc __initdata = {
107− .bLength = sizeof header_desc,
106+static struct usb_cdc_header_desc mdlm_header_desc __initdata = {
107+ .bLength = sizeof mdlm_header_desc,
108108 .bDescriptorType = USB_DT_CS_INTERFACE,
109109 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
110110
@@ -152,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { · 41 unmodified lines
152152
153153 /* full speed support: */
154154
155−static struct usb_endpoint_descriptor fs_in_desc __initdata = {
155+static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = {
156156 .bLength = USB_DT_ENDPOINT_SIZE,
157157 .bDescriptorType = USB_DT_ENDPOINT,
158158
@@ -160,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { · 1 unmodified line
160160 .bmAttributes = USB_ENDPOINT_XFER_BULK,
161161 };
162162
163−static struct usb_endpoint_descriptor fs_out_desc __initdata = {
163+static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = {
164164 .bLength = USB_DT_ENDPOINT_SIZE,
165165 .bDescriptorType = USB_DT_ENDPOINT,
166166
@@ -170,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { · 3 unmodified lines
170170
171171 static struct usb_descriptor_header *fs_eth_function[] __initdata = {
172172 (struct usb_descriptor_header *) &subset_data_intf,
173− (struct usb_descriptor_header *) &header_desc,
173+ (struct usb_descriptor_header *) &mdlm_header_desc,
174174 (struct usb_descriptor_header *) &mdlm_desc,
175175 (struct usb_descriptor_header *) &mdlm_detail_desc,
176176 (struct usb_descriptor_header *) &ether_desc,
177− (struct usb_descriptor_header *) &fs_in_desc,
178− (struct usb_descriptor_header *) &fs_out_desc,
177+ (struct usb_descriptor_header *) &fs_subset_in_desc,
178+ (struct usb_descriptor_header *) &fs_subset_out_desc,
179179 NULL,
180180 };
181181
182182 /* high speed support: */
183183
184−static struct usb_endpoint_descriptor hs_in_desc __initdata = {
184+static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = {
185185 .bLength = USB_DT_ENDPOINT_SIZE,
186186 .bDescriptorType = USB_DT_ENDPOINT,
187187
@@ -189,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { · 1 unmodified line
189189 .wMaxPacketSize = __constant_cpu_to_le16(512),
190190 };
191191
192−static struct usb_endpoint_descriptor hs_out_desc __initdata = {
192+static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = {
193193 .bLength = USB_DT_ENDPOINT_SIZE,
194194 .bDescriptorType = USB_DT_ENDPOINT,
195195
@@ -199,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { · 3 unmodified lines
199199
200200 static struct usb_descriptor_header *hs_eth_function[] __initdata = {
201201 (struct usb_descriptor_header *) &subset_data_intf,
202− (struct usb_descriptor_header *) &header_desc,
202+ (struct usb_descriptor_header *) &mdlm_header_desc,
203203 (struct usb_descriptor_header *) &mdlm_desc,
204204 (struct usb_descriptor_header *) &mdlm_detail_desc,
205205 (struct usb_descriptor_header *) &ether_desc,
206− (struct usb_descriptor_header *) &hs_in_desc,
207− (struct usb_descriptor_header *) &hs_out_desc,
206+ (struct usb_descriptor_header *) &hs_subset_in_desc,
207+ (struct usb_descriptor_header *) &hs_subset_out_desc,
208208 NULL,
209209 };
210210
@@ -281,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 70 unmodified lines
281281 status = -ENODEV;
282282
283283 /* 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);
285285 if (!ep)
286286 goto fail;
287287 geth->port.in_ep = ep;
288288 ep->driver_data = cdev; /* claim */
289289
290− ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc);
290+ ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc);
291291 if (!ep)
292292 goto fail;
293293 geth->port.out_ep = ep;
@@ -297,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 3 unmodified lines
297297 f->descriptors = usb_copy_descriptors(fs_eth_function);
298298
299299 geth->fs.in = usb_find_endpoint(fs_eth_function,
300− f->descriptors, &fs_in_desc);
300+ f->descriptors, &fs_subset_in_desc);
301301 geth->fs.out = usb_find_endpoint(fs_eth_function,
302− f->descriptors, &fs_out_desc);
302+ f->descriptors, &fs_subset_out_desc);
303303
304304
305305 /* support all relevant hardware speeds... we expect that when
@@ -307,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 1 unmodified line
307307 * both speeds
308308 */
309309 if (gadget_is_dualspeed(c->cdev->gadget)) {
310− hs_in_desc.bEndpointAddress =
311− fs_in_desc.bEndpointAddress;
312− hs_out_desc.bEndpointAddress =
313− fs_out_desc.bEndpointAddress;
310+ hs_subset_in_desc.bEndpointAddress =
311+ fs_subset_in_desc.bEndpointAddress;
312+ hs_subset_out_desc.bEndpointAddress =
313+ fs_subset_out_desc.bEndpointAddress;
314314
315315 /* copy descriptors, and track endpoint copies */
316316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function);
317317
318318 geth->hs.in = usb_find_endpoint(hs_eth_function,
319− f->hs_descriptors, &hs_in_desc);
319+ f->hs_descriptors, &hs_subset_in_desc);
320320 geth->hs.out = usb_find_endpoint(hs_eth_function,
321− f->hs_descriptors, &hs_out_desc);
321+ f->hs_descriptors, &hs_subset_out_desc);
322322 }
323323
324324 /* NOTE: all that is done without knowing or caring about
drivers/usb/gadget/file_storage.c+12−0
@@ -245,6 +245,18 @@ · 244 unmodified lines
245245 #include "gadget_chips.h"
246246
247247
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+
248260 /*-------------------------------------------------------------------------*/
249261
250262 #define DRIVER_DESC "File-backed Storage Gadget"
drivers/usb/gadget/gmidi.c+15−0
@@ -35,6 +35,21 @@ · 34 unmodified lines
3535
3636 #include "gadget_chips.h"
3737
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+
3853 MODULE_AUTHOR("Ben Williamson");
3954 MODULE_LICENSE("GPL v2");
4055
drivers/usb/gadget/printer.c+16−2
@@ -53,6 +53,20 @@ · 52 unmodified lines
5353
5454 #include "gadget_chips.h"
5555
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+
5670 #define DRIVER_DESC "Printer Gadget"
5771 #define DRIVER_VERSION "2007 OCT 06"
5872
@@ -1360,8 +1374,8 @@ printer_bind(struct usb_gadget *gadget) · 1301 unmodified lines
13601374
13611375
13621376 /* Setup the sysfs files for the printer gadget. */
1363− dev->pdev = device_create_drvdata(usb_gadget_class, NULL,
1364− g_printer_devno, NULL, "g_printer");
1377+ dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno,
1378+ NULL, "g_printer");
13651379 if (IS_ERR(dev->pdev)) {
13661380 ERROR(dev, "Failed to create device: g_printer\n");
13671381 goto fail;
drivers/usb/gadget/rndis.c+55−60
@@ -57,11 +57,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging"); · 56 unmodified lines
5757 #define rndis_debug 0
5858 #endif
5959
60−#define DBG(str,args...) do { \
61− if (rndis_debug) \
62− pr_debug(str , ## args); \
63− } while (0)
64−
6560 #define RNDIS_MAX_CONFIGS 1
6661
6762
@@ -183,9 +178,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 115 unmodified lines
183178 if (!resp) return -ENOMEM;
184179
185180 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);
187182 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,
189184 get_unaligned_le32(&buf[i]),
190185 get_unaligned_le32(&buf[i + 4]),
191186 get_unaligned_le32(&buf[i + 8]),
@@ -209,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 17 unmodified lines
209204
210205 /* mandatory */
211206 case OID_GEN_SUPPORTED_LIST:
212− DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
207+ pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
213208 length = sizeof (oid_supported_list);
214209 count = length / sizeof (u32);
215210 for (i = 0; i < count; i++)
@@ -219,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines
219214
220215 /* mandatory */
221216 case OID_GEN_HARDWARE_STATUS:
222− DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__);
217+ pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__);
223218 /* Bogus question!
224219 * Hardware must be ready to receive high level protocols.
225220 * BTW:
@@ -232,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 6 unmodified lines
232227
233228 /* mandatory */
234229 case OID_GEN_MEDIA_SUPPORTED:
235− DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
230+ pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
236231 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
237232 retval = 0;
238233 break;
239234
240235 /* mandatory */
241236 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__);
243238 /* one medium, one transport... (maybe you do it better) */
244239 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
245240 retval = 0;
@@ -247,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
247242
248243 /* mandatory */
249244 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__);
251246 if (rndis_per_dev_params [configNr].dev) {
252247 *outbuf = cpu_to_le32 (
253248 rndis_per_dev_params [configNr].dev->mtu);
@@ -258,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines
258253 /* mandatory */
259254 case OID_GEN_LINK_SPEED:
260255 if (rndis_debug > 1)
261− DBG("%s: OID_GEN_LINK_SPEED\n", __func__);
256+ pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
262257 if (rndis_per_dev_params [configNr].media_state
263258 == NDIS_MEDIA_STATE_DISCONNECTED)
264259 *outbuf = __constant_cpu_to_le32 (0);
@@ -270,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines
270265
271266 /* mandatory */
272267 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__);
274269 if (rndis_per_dev_params [configNr].dev) {
275270 *outbuf = cpu_to_le32 (
276271 rndis_per_dev_params [configNr].dev->mtu);
@@ -280,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines
280275
281276 /* mandatory */
282277 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__);
284279 if (rndis_per_dev_params [configNr].dev) {
285280 *outbuf = cpu_to_le32 (
286281 rndis_per_dev_params [configNr].dev->mtu);
@@ -290,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines
290285
291286 /* mandatory */
292287 case OID_GEN_VENDOR_ID:
293− DBG("%s: OID_GEN_VENDOR_ID\n", __func__);
288+ pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__);
294289 *outbuf = cpu_to_le32 (
295290 rndis_per_dev_params [configNr].vendorID);
296291 retval = 0;
@@ -298,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
298293
299294 /* mandatory */
300295 case OID_GEN_VENDOR_DESCRIPTION:
301− DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
296+ pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
302297 length = strlen (rndis_per_dev_params [configNr].vendorDescr);
303298 memcpy (outbuf,
304299 rndis_per_dev_params [configNr].vendorDescr, length);
@@ -306,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
306301 break;
307302
308303 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__);
310305 /* Created as LE */
311306 *outbuf = rndis_driver_version;
312307 retval = 0;
@@ -314,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
314309
315310 /* mandatory */
316311 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__);
318313 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter);
319314 retval = 0;
320315 break;
321316
322317 /* mandatory */
323318 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__);
325320 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
326321 retval = 0;
327322 break;
@@ -329,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
329324 /* mandatory */
330325 case OID_GEN_MEDIA_CONNECT_STATUS:
331326 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__);
333328 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
334329 .media_state);
335330 retval = 0;
336331 break;
337332
338333 case OID_GEN_PHYSICAL_MEDIUM:
339− DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
334+ pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
340335 *outbuf = __constant_cpu_to_le32 (0);
341336 retval = 0;
342337 break;
@@ -346,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines
346341 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE!
347342 */
348343 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__);
350345 *outbuf = __constant_cpu_to_le32(
351346 NDIS_MAC_OPTION_RECEIVE_SERIALIZED
352347 | NDIS_MAC_OPTION_FULL_DUPLEX);
@@ -358,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines
358353 /* mandatory */
359354 case OID_GEN_XMIT_OK:
360355 if (rndis_debug > 1)
361− DBG("%s: OID_GEN_XMIT_OK\n", __func__);
356+ pr_debug("%s: OID_GEN_XMIT_OK\n", __func__);
362357 if (stats) {
363358 *outbuf = cpu_to_le32(stats->tx_packets
364359 - stats->tx_errors - stats->tx_dropped);
@@ -369,7 +364,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines
369364 /* mandatory */
370365 case OID_GEN_RCV_OK:
371366 if (rndis_debug > 1)
372− DBG("%s: OID_GEN_RCV_OK\n", __func__);
367+ pr_debug("%s: OID_GEN_RCV_OK\n", __func__);
373368 if (stats) {
374369 *outbuf = cpu_to_le32(stats->rx_packets
375370 - stats->rx_errors - stats->rx_dropped);
@@ -380,7 +375,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines
380375 /* mandatory */
381376 case OID_GEN_XMIT_ERROR:
382377 if (rndis_debug > 1)
383− DBG("%s: OID_GEN_XMIT_ERROR\n", __func__);
378+ pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__);
384379 if (stats) {
385380 *outbuf = cpu_to_le32(stats->tx_errors);
386381 retval = 0;
@@ -390,7 +385,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines
390385 /* mandatory */
391386 case OID_GEN_RCV_ERROR:
392387 if (rndis_debug > 1)
393− DBG("%s: OID_GEN_RCV_ERROR\n", __func__);
388+ pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__);
394389 if (stats) {
395390 *outbuf = cpu_to_le32(stats->rx_errors);
396391 retval = 0;
@@ -399,7 +394,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 2 unmodified lines
399394
400395 /* mandatory */
401396 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__);
403398 if (stats) {
404399 *outbuf = cpu_to_le32(stats->rx_dropped);
405400 retval = 0;
@@ -410,7 +405,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines
410405
411406 /* mandatory */
412407 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__);
414409 if (rndis_per_dev_params [configNr].dev) {
415410 length = ETH_ALEN;
416411 memcpy (outbuf,
@@ -422,7 +417,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines
422417
423418 /* mandatory */
424419 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__);
426421 if (rndis_per_dev_params [configNr].dev) {
427422 length = ETH_ALEN;
428423 memcpy (outbuf,
@@ -434,7 +429,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines
434429
435430 /* mandatory */
436431 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__);
438433 /* Multicast base address only */
439434 *outbuf = __constant_cpu_to_le32 (0xE0000000);
440435 retval = 0;
@@ -442,21 +437,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line
442437
443438 /* mandatory */
444439 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__);
446441 /* Multicast base address only */
447442 *outbuf = __constant_cpu_to_le32 (1);
448443 retval = 0;
449444 break;
450445
451446 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__);
453448 break;
454449
455450 /* ieee802.3 statistics OIDs (table 4-4) */
456451
457452 /* mandatory */
458453 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__);
460455 if (stats) {
461456 *outbuf = cpu_to_le32(stats->rx_frame_errors);
462457 retval = 0;
@@ -465,14 +460,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 2 unmodified lines
465460
466461 /* mandatory */
467462 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__);
469464 *outbuf = __constant_cpu_to_le32 (0);
470465 retval = 0;
471466 break;
472467
473468 /* mandatory */
474469 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__);
476471 *outbuf = __constant_cpu_to_le32 (0);
477472 retval = 0;
478473 break;
@@ -504,9 +499,9 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, · 25 unmodified lines
504499 return -ENOMEM;
505500
506501 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);
508503 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,
510505 get_unaligned_le32(&buf[i]),
511506 get_unaligned_le32(&buf[i + 4]),
512507 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, · 12 unmodified lines
525520 * MULTICAST, ALL_MULTICAST, BROADCAST
526521 */
527522 *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",
529524 __func__, *params->filter);
530525
531526 /* 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, · 15 unmodified lines
547542
548543 case OID_802_3_MULTICAST_LIST:
549544 /* 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__);
551546 retval = 0;
552547 break;
553548
@@ -606,7 +601,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) · 52 unmodified lines
606601 rndis_resp_t *r;
607602 struct rndis_params *params = rndis_per_dev_params + configNr;
608603
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)); */
610605 if (!params->dev)
611606 return -ENOTSUPP;
612607
@@ -659,15 +654,15 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) · 46 unmodified lines
659654 BufOffset = le32_to_cpu (buf->InformationBufferOffset);
660655
661656 #ifdef VERBOSE_DEBUG
662− DBG("%s: Length: %d\n", __func__, BufLength);
663− DBG("%s: Offset: %d\n", __func__, BufOffset);
664− DBG("%s: InfoBuffer: ", __func__);
657+ pr_debug("%s: Length: %d\n", __func__, BufLength);
658+ pr_debug("%s: Offset: %d\n", __func__, BufOffset);
659+ pr_debug("%s: InfoBuffer: ", __func__);
665660
666661 for (i = 0; i < BufLength; i++) {
667− DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset));
662+ pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset));
668663 }
669664
670− DBG("\n");
665+ pr_debug("\n");
671666 #endif
672667
673668 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT);
@@ -821,14 +816,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 147 unmodified lines
821816 /* For USB: responses may take up to 10 seconds */
822817 switch (MsgType) {
823818 case REMOTE_NDIS_INITIALIZE_MSG:
824− DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
819+ pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
825820 __func__ );
826821 params->state = RNDIS_INITIALIZED;
827822 return rndis_init_response (configNr,
828823 (rndis_init_msg_type *) buf);
829824
830825 case REMOTE_NDIS_HALT_MSG:
831− DBG("%s: REMOTE_NDIS_HALT_MSG\n",
826+ pr_debug("%s: REMOTE_NDIS_HALT_MSG\n",
832827 __func__ );
833828 params->state = RNDIS_UNINITIALIZED;
834829 if (params->dev) {
@@ -846,7 +841,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 11 unmodified lines
846841 (rndis_set_msg_type *) buf);
847842
848843 case REMOTE_NDIS_RESET_MSG:
849− DBG("%s: REMOTE_NDIS_RESET_MSG\n",
844+ pr_debug("%s: REMOTE_NDIS_RESET_MSG\n",
850845 __func__ );
851846 return rndis_reset_response (configNr,
852847 (rndis_reset_msg_type *) buf);
@@ -854,7 +849,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 1 unmodified line
854849 case REMOTE_NDIS_KEEPALIVE_MSG:
855850 /* For USB: host does this every 5 seconds */
856851 if (rndis_debug > 1)
857− DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
852+ pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
858853 __func__ );
859854 return rndis_keepalive_response (configNr,
860855 (rndis_keepalive_msg_type *)
@@ -870,7 +865,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 9 unmodified lines
870865 {
871866 unsigned i;
872867 for (i = 0; i < MsgLength; i += 16) {
873− DBG("%03d: "
868+ pr_debug("%03d: "
874869 " %02x %02x %02x %02x"
875870 " %02x %02x %02x %02x"
876871 " %02x %02x %02x %02x"
@@ -905,18 +900,18 @@ int rndis_register(void (*resp_avail)(void *v), void *v) · 28 unmodified lines
905900 rndis_per_dev_params [i].used = 1;
906901 rndis_per_dev_params [i].resp_avail = resp_avail;
907902 rndis_per_dev_params [i].v = v;
908− DBG("%s: configNr = %d\n", __func__, i);
903+ pr_debug("%s: configNr = %d\n", __func__, i);
909904 return i;
910905 }
911906 }
912− DBG("failed\n");
907+ pr_debug("failed\n");
913908
914909 return -ENODEV;
915910 }
916911
917912 void rndis_deregister (int configNr)
918913 {
919− DBG("%s: \n", __func__ );
914+ pr_debug("%s: \n", __func__);
920915
921916 if (configNr >= RNDIS_MAX_CONFIGS) return;
922917 rndis_per_dev_params [configNr].used = 0;
@@ -926,7 +921,7 @@ void rndis_deregister (int configNr) · 3 unmodified lines
926921
927922 int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
928923 {
929− DBG("%s:\n", __func__ );
924+ pr_debug("%s:\n", __func__);
930925 if (!dev)
931926 return -EINVAL;
932927 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) · 6 unmodified lines
939934
940935 int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
941936 {
942− DBG("%s:\n", __func__ );
937+ pr_debug("%s:\n", __func__);
943938 if (!vendorDescr) return -1;
944939 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
945940
@@ -951,7 +946,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) · 5 unmodified lines
951946
952947 int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
953948 {
954− DBG("%s: %u %u\n", __func__, medium, speed);
949+ pr_debug("%s: %u %u\n", __func__, medium, speed);
955950 if (configNr >= RNDIS_MAX_CONFIGS) return -1;
956951
957952 rndis_per_dev_params [configNr].medium = medium;
@@ -1114,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, · 156 unmodified lines
11141109 break;
11151110 default:
11161111 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);
11181113 break;
11191114 }
11201115
@@ -1159,12 +1154,12 @@ int __init rndis_init (void) · 38 unmodified lines
11591154 &rndis_proc_fops,
11601155 (void *)(rndis_per_dev_params + i))))
11611156 {
1162− DBG("%s :remove entries", __func__);
1157+ pr_debug("%s :remove entries", __func__);
11631158 while (i) {
11641159 sprintf (name, NAME_TEMPLATE, --i);
11651160 remove_proc_entry (name, NULL);
11661161 }
1167− DBG("\n");
1162+ pr_debug("\n");
11681163 return -EIO;
11691164 }
11701165 #endif
drivers/usb/gadget/serial.c+18−0
@@ -30,6 +30,24 @@ · 29 unmodified lines
3030
3131 /*-------------------------------------------------------------------------*/
3232
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+
3351 /* Thanks to NetChip Technologies for donating this product ID.
3452 *
3553 * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
drivers/usb/gadget/u_ether.c+2−2
@@ -52,7 +52,7 @@ · 51 unmodified lines
5252 * this single "physical" link to be used by multiple virtual links.)
5353 */
5454
55−#define DRIVER_VERSION "29-May-2008"
55+#define UETH__VERSION "29-May-2008"
5656
5757 struct eth_dev {
5858 /* lock is held while accessing port_usb
@@ -170,7 +170,7 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) · 111 unmodified lines
170170 struct eth_dev *dev = netdev_priv(net);
171171
172172 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);
174174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version);
175175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info);
176176 }
drivers/usb/gadget/zero.c+17−0
@@ -57,6 +57,23 @@ · 56 unmodified lines
5757 #include "gadget_chips.h"
5858
5959
60+/*-------------------------------------------------------------------------*/
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+
6077 /*-------------------------------------------------------------------------*/
6178
6279 #define DRIVER_VERSION "Cinco de Mayo 2008"
drivers/usb/host/uhci-q.c+8−16
@@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci) · 122 unmodified lines
123123
124124 static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
125125 {
126− if (!list_empty(&td->list)) {
127− dev_warn(uhci_dev(uhci), "td %p still in list!\n", td);
128− WARN_ON(1);
129− }
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− }
126+ if (!list_empty(&td->list))
127+ dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td);
128+ if (!list_empty(&td->fl_list))
129+ dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td);
134130
135131 dma_pool_free(uhci->td_pool, td, td->dma_handle);
136132 }
@@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, · 158 unmodified lines
295291 static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
296292 {
297293 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
298− if (!list_empty(&qh->queue)) {
299− dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh);
300− WARN_ON(1);
301− }
294+ if (!list_empty(&qh->queue))
295+ dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh);
302296
303297 list_del(&qh->node);
304298 if (qh->udev) {
@@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci, · 441 unmodified lines
746740 {
747741 struct uhci_td *td, *tmp;
748742
749− if (!list_empty(&urbp->node)) {
750− dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n",
743+ if (!list_empty(&urbp->node))
744+ dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n",
751745 urbp->urb);
752− WARN_ON(1);
753− }
754746
755747 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
756748 uhci_remove_td_from_urbp(td);
drivers/usb/misc/phidgetkit.c+2−3
@@ -595,9 +595,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic · 594 unmodified lines
595595 } while(value);
596596 kit->dev_no = bit;
597597
598− kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev,
599− MKDEV(0, 0), kit,
600− "interfacekit%d", kit->dev_no);
598+ kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0),
599+ kit, "interfacekit%d", kit->dev_no);
601600 if (IS_ERR(kit->dev)) {
602601 rc = PTR_ERR(kit->dev);
603602 kit->dev = NULL;
drivers/usb/misc/phidgetmotorcontrol.c+2−3
@@ -365,9 +365,8 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic · 364 unmodified lines
365365 } while(value);
366366 mc->dev_no = bit;
367367
368− mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev,
369− MKDEV(0, 0), mc,
370− "motorcontrol%d", mc->dev_no);
368+ mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc,
369+ "motorcontrol%d", mc->dev_no);
371370 if (IS_ERR(mc->dev)) {
372371 rc = PTR_ERR(mc->dev);
373372 mc->dev = NULL;
drivers/usb/misc/phidgetservo.c+2−3
@@ -275,9 +275,8 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id) · 274 unmodified lines
275275 } while (value);
276276 dev->dev_no = bit;
277277
278− dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev,
279− MKDEV(0, 0), dev,
280− "servo%d", dev->dev_no);
278+ dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0),
279+ dev, "servo%d", dev->dev_no);
281280 if (IS_ERR(dev->dev)) {
282281 rc = PTR_ERR(dev->dev);
283282 dev->dev = NULL;
drivers/usb/mon/mon_bin.c+3−3
@@ -1162,9 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus) · 1161 unmodified lines
11621162 if (minor >= MON_BIN_MAX_MINOR)
11631163 return 0;
11641164
1165− dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL,
1166− MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167− "usbmon%d", minor);
1165+ dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL,
1166+ MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167+ "usbmon%d", minor);
11681168 if (IS_ERR(dev))
11691169 return 0;
11701170
drivers/video/console/fbcon.c+2−2
@@ -3573,8 +3573,8 @@ static int __init fb_console_init(void) · 3572 unmodified lines
35733573
35743574 acquire_console_sem();
35753575 fb_register_client(&fbcon_event_notifier);
3576− fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0),
3577− NULL, "fbcon");
3576+ fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3577+ "fbcon");
35783578
35793579 if (IS_ERR(fbcon_device)) {
35803580 printk(KERN_WARNING "Unable to create device "
drivers/video/display/display-sysfs.c+3−6
@@ -153,12 +153,9 @@ struct display_device *display_device_register(struct display_driver *driver, · 152 unmodified lines
153153 mutex_unlock(&allocated_dsp_lock);
154154
155155 if (!ret) {
156− new_dev->dev = device_create_drvdata(display_class,
157− parent,
158− MKDEV(0,0),
159− new_dev,
160− "display%d",
161− new_dev->idx);
156+ new_dev->dev = device_create(display_class, parent,
157+ MKDEV(0, 0), new_dev,
158+ "display%d", new_dev->idx);
162159 if (!IS_ERR(new_dev->dev)) {
163160 new_dev->parent = parent;
164161 new_dev->driver = driver;
drivers/video/fbmem.c+2−3
@@ -1430,9 +1430,8 @@ register_framebuffer(struct fb_info *fb_info) · 1429 unmodified lines
14301430 break;
14311431 fb_info->node = i;
14321432
1433− fb_info->dev = device_create_drvdata(fb_class, fb_info->device,
1434− MKDEV(FB_MAJOR, i), NULL,
1435− "fb%d", i);
1433+ fb_info->dev = device_create(fb_class, fb_info->device,
1434+ MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
14361435 if (IS_ERR(fb_info->dev)) {
14371436 /* Not fatal */
14381437 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
fs/coda/psdev.c+2−3
@@ -362,9 +362,8 @@ static int init_coda_psdev(void) · 361 unmodified lines
362362 goto out_chrdev;
363363 }
364364 for (i = 0; i < MAX_CODADEVS; i++)
365− device_create_drvdata(coda_psdev_class, NULL,
366− MKDEV(CODA_PSDEV_MAJOR, i),
367− NULL, "cfs%d", i);
365+ device_create(coda_psdev_class, NULL,
366+ MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i);
368367 coda_sysctl_init();
369368 goto out;
370369
fs/sysfs/bin.c+31−11
@@ -61,6 +61,7 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) · 60 unmodified lines
6161 int size = dentry->d_inode->i_size;
6262 loff_t offs = *off;
6363 int count = min_t(size_t, bytes, PAGE_SIZE);
64+ char *temp;
6465
6566 if (size) {
6667 if (offs > size)
@@ -69,23 +70,33 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) · 2 unmodified lines
6970 count = size - offs;
7071 }
7172
73+ temp = kmalloc(count, GFP_KERNEL);
74+ if (!temp)
75+ return -ENOMEM;
76+
7277 mutex_lock(&bb->mutex);
7378
7479 count = fill_read(dentry, bb->buffer, offs, count);
75− if (count < 0)
76− goto out_unlock;
80+ if (count < 0) {
81+ mutex_unlock(&bb->mutex);
82+ goto out_free;
83+ }
7784
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)) {
7990 count = -EFAULT;
80− goto out_unlock;
91+ goto out_free;
8192 }
8293
8394 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count);
8495
8596 *off = offs + count;
8697
87− out_unlock:
88− mutex_unlock(&bb->mutex);
98+ out_free:
99+ kfree(temp);
89100 return count;
90101 }
91102
@@ -118,6 +129,7 @@ static ssize_t write(struct file *file, const char __user *userbuf, · 26 unmodified lines
118129 int size = dentry->d_inode->i_size;
119130 loff_t offs = *off;
120131 int count = min_t(size_t, bytes, PAGE_SIZE);
132+ char *temp;
121133
122134 if (size) {
123135 if (offs > size)
@@ -126,19 +138,27 @@ static ssize_t write(struct file *file, const char __user *userbuf, · 2 unmodified lines
126138 count = size - offs;
127139 }
128140
129− mutex_lock(&bb->mutex);
141+ temp = kmalloc(count, GFP_KERNEL);
142+ if (!temp)
143+ return -ENOMEM;
130144
131− if (copy_from_user(bb->buffer, userbuf, count)) {
145+ if (copy_from_user(temp, userbuf, count)) {
132146 count = -EFAULT;
133− goto out_unlock;
147+ goto out_free;
134148 }
135149
150+ mutex_lock(&bb->mutex);
151+
152+ memcpy(bb->buffer, temp, count);
153+
136154 count = flush_write(dentry, bb->buffer, offs, count);
155+ mutex_unlock(&bb->mutex);
156+
137157 if (count > 0)
138158 *off = offs + count;
139159
140− out_unlock:
141− mutex_unlock(&bb->mutex);
160+out_free:
161+ kfree(temp);
142162 return count;
143163 }
144164
fs/sysfs/dir.c+10−14
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 369 unmodified lines
370370 memset(acxt, 0, sizeof(*acxt));
371371 acxt->parent_sd = parent_sd;
372372
373− /* Lookup parent inode. inode initialization and I_NEW
374− * clearing are protected by sysfs_mutex. By grabbing it and
375− * looking up with _nowait variant, inode state can be
376− * determined reliably.
373+ /* Lookup parent inode. inode initialization is protected by
374+ * sysfs_mutex, so inode existence can be determined by
375+ * looking up inode while holding sysfs_mutex.
377376 */
378377 mutex_lock(&sysfs_mutex);
379378
380− inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
381− parent_sd);
379+ inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
380+ parent_sd);
381+ if (inode) {
382+ WARN_ON(inode->i_state & I_NEW);
382383
383− if (inode && !(inode->i_state & I_NEW)) {
384384 /* parent inode available */
385385 acxt->parent_inode = inode;
386386
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 6 unmodified lines
393393 mutex_lock(&inode->i_mutex);
394394 mutex_lock(&sysfs_mutex);
395395 }
396− } else
397− iput(inode);
396+ }
398397 }
399398
400399 /**
@@ -636,6 +635,7 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, · 235 unmodified lines
636635
637636 return sd;
638637 }
638+EXPORT_SYMBOL_GPL(sysfs_get_dirent);
639639
640640 static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
641641 const char *name, struct sysfs_dirent **p_sd)
@@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) · 187 unmodified lines
829829 if (!new_dentry)
830830 goto out_unlock;
831831
832− /* rename kobject and sysfs_dirent */
832+ /* rename sysfs_dirent */
833833 error = -ENOMEM;
834834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
835835 if (!new_name)
836836 goto out_unlock;
837837
838− error = kobject_set_name(kobj, "%s", new_name);
839− if (error)
840− goto out_unlock;
841−
842838 dup_name = sd->s_name;
843839 sd->s_name = new_name;
844840
fs/sysfs/file.c+32−14
@@ -19,10 +19,18 @@ · 18 unmodified lines
1919 #include <linux/poll.h>
2020 #include <linux/list.h>
2121 #include <linux/mutex.h>
22+#include <linux/limits.h>
2223 #include <asm/uaccess.h>
2324
2425 #include "sysfs.h"
2526
27+/* used in crash dumps to help with debugging */
28+static char last_sysfs_file[PATH_MAX];
29+void sysfs_printk_last_file(void)
30+{
31+ printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
32+}
33+
2634 /*
2735 * There's one sysfs_buffer for each open file and one
2836 * 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) · 299 unmodified lines
328336 struct sysfs_buffer *buffer;
329337 struct sysfs_ops *ops;
330338 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);
331344
332345 /* need attr_sd for attr and ops, its parent for kobj */
333346 if (!sysfs_get_active_two(attr_sd))
@@ -440,7 +453,23 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait) · 106 unmodified lines
440453 return POLLERR|POLLPRI;
441454 }
442455
443−void sysfs_notify(struct kobject *k, char *dir, char *attr)
456+void 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+}
470+EXPORT_SYMBOL_GPL(sysfs_notify_dirent);
471+
472+void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
444473 {
445474 struct sysfs_dirent *sd = k->sd;
446475
@@ -450,19 +479,8 @@ void sysfs_notify(struct kobject *k, char *dir, char *attr) · 3 unmodified lines
450479 sd = sysfs_find_dirent(sd, dir);
451480 if (sd && attr)
452481 sd = sysfs_find_dirent(sd, attr);
453− if (sd) {
454− struct sysfs_open_dirent *od;
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− }
482+ if (sd)
483+ sysfs_notify_dirent(sd);
466484
467485 mutex_unlock(&sysfs_mutex);
468486 }
fs/sysfs/mount.c+15−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/mount.h>
1717 #include <linux/pagemap.h>
1818 #include <linux/init.h>
19+#include <linux/module.h>
1920
2021 #include "sysfs.h"
2122
@@ -115,3 +116,17 @@ out_err: · 93 unmodified lines
115116 sysfs_dir_cachep = NULL;
116117 goto out;
117118 }
119+
120+#undef sysfs_get
121+struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
122+{
123+ return __sysfs_get(sd);
124+}
125+EXPORT_SYMBOL_GPL(sysfs_get);
126+
127+#undef sysfs_put
128+void sysfs_put(struct sysfs_dirent *sd)
129+{
130+ __sysfs_put(sd);
131+}
132+EXPORT_SYMBOL_GPL(sysfs_put);
fs/sysfs/sysfs.h+4−2
@@ -124,7 +124,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name, · 123 unmodified lines
124124 struct sysfs_dirent **p_sd);
125125 void sysfs_remove_subdir(struct sysfs_dirent *sd);
126126
127−static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
127+static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd)
128128 {
129129 if (sd) {
130130 WARN_ON(!atomic_read(&sd->s_count));
@@ -132,12 +132,14 @@ static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) · 1 unmodified line
132132 }
133133 return sd;
134134 }
135+#define sysfs_get(sd) __sysfs_get(sd)
135136
136−static inline void sysfs_put(struct sysfs_dirent *sd)
137+static inline void __sysfs_put(struct sysfs_dirent *sd)
137138 {
138139 if (sd && atomic_dec_and_test(&sd->s_count))
139140 release_sysfs_dirent(sd);
140141 }
142+#define sysfs_put(sd) __sysfs_put(sd)
141143
142144 /*
143145 * inode.c
include/asm-generic/vmlinux.lds.h+9−1
@@ -268,7 +268,15 @@ · 267 unmodified lines
268268 CPU_DISCARD(init.data) \
269269 CPU_DISCARD(init.rodata) \
270270 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) = .;
272280
273281 #define INIT_TEXT \
274282 *(.init.text) \
include/linux/device.h+16−2
@@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus, · 89 unmodified lines
9090 struct device_driver *start, void *data,
9191 int (*fn)(struct device_driver *, void *));
9292
93+void bus_sort_breadthfirst(struct bus_type *bus,
94+ int (*compare)(const struct device *a,
95+ const struct device *b));
9396 /*
9497 * Bus notifiers: Get notified of addition/removal of devices
9598 * and binding/unbinding of drivers to devices.
@@ -502,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent, · 406 unmodified lines
502505 dev_t devt, void *drvdata,
503506 const char *fmt, ...)
504507 __attribute__((format(printf, 5, 6)));
505−#define device_create_drvdata device_create
506508 extern void device_destroy(struct class *cls, dev_t devt);
507509
508510 /*
@@ -551,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev); · 42 unmodified lines
551553 #define dev_info(dev, format, arg...) \
552554 dev_printk(KERN_INFO , dev , format , ## arg)
553555
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)
555561 #define dev_dbg(dev, format, arg...) \
556562 dev_printk(KERN_DEBUG , dev , format , ## arg)
557563 #else
@@ -567,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev); · 9 unmodified lines
567573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
568574 #endif
569575
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+
570584 /* Create alias, so I can be autoloaded. */
571585 #define MODULE_ALIAS_CHARDEV(major,minor) \
572586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
include/linux/dynamic_printk.h+93−0
@@ -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+
13+extern 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+ */
19+extern long long dynamic_printk_enabled;
20+extern long long dynamic_printk_enabled2;
21+
22+struct 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+
31+int 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)
35+extern int unregister_dynamic_debug_module(char *mod_name);
36+extern 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+
78+static inline int unregister_dynamic_debug_module(const char *mod_name)
79+{
80+ return 0;
81+}
82+static 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
include/linux/kernel.h+6−1
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/log2.h>
1717 #include <linux/typecheck.h>
1818 #include <linux/ratelimit.h>
19+#include <linux/dynamic_printk.h>
1920 #include <asm/byteorder.h>
2021 #include <asm/bug.h>
2122
@@ -304,8 +305,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte) · 282 unmodified lines
304305 #define pr_info(fmt, arg...) \
305306 printk(KERN_INFO fmt, ##arg)
306307
307−#ifdef DEBUG
308308 /* 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)
309314 #define pr_debug(fmt, arg...) \
310315 printk(KERN_DEBUG fmt, ##arg)
311316 #else
include/linux/module.h+0−1
@@ -345,7 +345,6 @@ struct module · 344 unmodified lines
345345 /* Reference counts */
346346 struct module_ref ref[NR_CPUS];
347347 #endif
348−
349348 };
350349 #ifndef MODULE_ARCH_INIT
351350 #define MODULE_ARCH_INIT {}
include/linux/platform_device.h+2−0
@@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int); · 36 unmodified lines
3737
3838 extern struct platform_device *platform_device_register_simple(const char *, int id,
3939 struct resource *, unsigned int);
40+extern struct platform_device *platform_device_register_data(struct device *,
41+ const char *, int, const void *, size_t);
4042
4143 extern struct platform_device *platform_device_alloc(const char *name, int id);
4244 extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
include/linux/sysfs.h+32−4
@@ -78,6 +78,8 @@ struct sysfs_ops { · 77 unmodified lines
7878 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
7979 };
8080
81+struct sysfs_dirent;
82+
8183 #ifdef CONFIG_SYSFS
8284
8385 int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
@@ -117,9 +119,14 @@ int sysfs_add_file_to_group(struct kobject *kobj, · 33 unmodified lines
117119 void sysfs_remove_file_from_group(struct kobject *kobj,
118120 const struct attribute *attr, const char *group);
119121
120−void sysfs_notify(struct kobject *kobj, char *dir, char *attr);
121−
122−extern int __must_check sysfs_init(void);
122+void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
123+void sysfs_notify_dirent(struct sysfs_dirent *sd);
124+struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
125+ const unsigned char *name);
126+struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
127+void sysfs_put(struct sysfs_dirent *sd);
128+void sysfs_printk_last_file(void);
129+int __must_check sysfs_init(void);
123130
124131 #else /* CONFIG_SYSFS */
125132
@@ -222,7 +229,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj, · 96 unmodified lines
222229 {
223230 }
224231
225−static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr)
232+static inline void sysfs_notify(struct kobject *kobj, const char *dir,
233+ const char *attr)
234+{
235+}
236+static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
237+{
238+}
239+static inline
240+struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
241+ const unsigned char *name)
242+{
243+ return NULL;
244+}
245+static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
246+{
247+ return NULL;
248+}
249+static inline void sysfs_put(struct sysfs_dirent *sd)
226250 {
227251 }
228252
@@ -231,6 +255,10 @@ static inline int __must_check sysfs_init(void) · 2 unmodified lines
231255 return 0;
232256 }
233257
258+static inline void sysfs_printk_last_file(void)
259+{
260+}
261+
234262 #endif /* CONFIG_SYSFS */
235263
236264 #endif /* _SYSFS_H_ */
kernel/module.c+32−1
@@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) · 783 unmodified lines
784784 mutex_lock(&module_mutex);
785785 /* Store the name of the last unloaded module for diagnostic purposes */
786786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
787+ unregister_dynamic_debug_module(mod->name);
787788 free_module(mod);
788789
789790 out:
@@ -1173,7 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · 383 unmodified lines
11731174 while (i-- > 0)
11741175 sysfs_remove_bin_file(notes_attrs->dir,
11751176 &notes_attrs->attrs[i]);
1176− kobject_del(notes_attrs->dir);
1177+ kobject_put(notes_attrs->dir);
11771178 }
11781179 kfree(notes_attrs);
11791180 }
@@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod, · 603 unmodified lines
17831784 }
17841785 #endif /* CONFIG_KALLSYMS */
17851786
1787+#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
1788+static 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
1808+static inline void dynamic_printk_setup(Elf_Shdr *sechdrs,
1809+ unsigned int verboseindex)
1810+{
1811+}
1812+#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
1813+
17861814 static void *module_alloc_update_bounds(unsigned long size)
17871815 {
17881816 void *ret = module_alloc(size);
@@ -1831,6 +1859,7 @@ static noinline struct module *load_module(void __user *umod, · 42 unmodified lines
18311859 #endif
18321860 unsigned int markersindex;
18331861 unsigned int markersstringsindex;
1862+ unsigned int verboseindex;
18341863 struct module *mod;
18351864 long err = 0;
18361865 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -2117,6 +2146,7 @@ static noinline struct module *load_module(void __user *umod, · 280 unmodified lines
21172146 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
21182147 markersstringsindex = find_sec(hdr, sechdrs, secstrings,
21192148 "__markers_strings");
2149+ verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose");
21202150
21212151 /* Now do relocations. */
21222152 for (i = 1; i < hdr->e_shnum; i++) {
@@ -2167,6 +2197,7 @@ static noinline struct module *load_module(void __user *umod, · 44 unmodified lines
21672197 marker_update_probe_range(mod->markers,
21682198 mod->markers + mod->num_markers);
21692199 #endif
2200+ dynamic_printk_setup(sechdrs, verboseindex);
21702201 err = module_finalize(hdr, sechdrs, mod);
21712202 if (err < 0)
21722203 goto cleanup;
lib/Kconfig.debug+55−0
@@ -807,6 +807,61 @@ menuconfig BUILD_DOCSRC · 806 unmodified lines
807807
808808 Say N if you are unsure.
809809
810+config 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+
810865 source "samples/Kconfig"
811866
812867 source "lib/Kconfig.kgdb"
lib/Makefile+2−0
@@ -81,6 +81,8 @@ obj-$(CONFIG_HAVE_LMB) += lmb.o · 80 unmodified lines
8181
8282 obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
8383
84+obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o
85+
8486 hostprogs-y := gen_crc32table
8587 clean-files := crc32table.h
8688
lib/dynamic_printk.c+418−0
@@ -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+
17+extern struct mod_debug __start___verbose[];
18+extern struct mod_debug __stop___verbose[];
19+
20+struct 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+
30+static int nr_entries;
31+static int num_enabled;
32+int dynamic_enabled = DYNAMIC_ENABLED_NONE;
33+static struct hlist_head module_table[DEBUG_HASH_TABLE_SIZE] =
34+ { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
35+static struct hlist_head module_table2[DEBUG_HASH_TABLE_SIZE] =
36+ { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
37+static 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+ */
43+long long dynamic_printk_enabled;
44+EXPORT_SYMBOL_GPL(dynamic_printk_enabled);
45+long long dynamic_printk_enabled2;
46+EXPORT_SYMBOL_GPL(dynamic_printk_enabled2);
47+
48+/* returns the debug module pointer. */
49+static 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. */
67+static 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*/
82+static 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++;
113+out:
114+ return ret;
115+}
116+
117+int 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--;
136+out:
137+ up(&debug_list_mutex);
138+ return 0;
139+}
140+EXPORT_SYMBOL_GPL(unregister_dynamic_debug_module);
141+
142+int 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;
161+out:
162+ up(&debug_list_mutex);
163+ return ret;
164+}
165+EXPORT_SYMBOL_GPL(register_dynamic_debug_module);
166+
167+int __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+}
181+EXPORT_SYMBOL_GPL(__dynamic_dbg_enabled_helper);
182+
183+static 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+
205+static 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+
224+static 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;
319+out_up:
320+ up(&debug_list_mutex);
321+out:
322+ free_page((unsigned long)buffer);
323+ return err;
324+}
325+
326+static void *pr_debug_seq_start(struct seq_file *f, loff_t *pos)
327+{
328+ return (*pos < DEBUG_HASH_TABLE_SIZE) ? pos : NULL;
329+}
330+
331+static 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+
339+static void pr_debug_seq_stop(struct seq_file *s, void *v)
340+{
341+ /* Nothing to do */
342+}
343+
344+static 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+
361+static 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+
368+static int pr_debug_open(struct inode *inode, struct file *filp)
369+{
370+ return seq_open(filp, &pr_debug_seq_ops);
371+}
372+
373+static 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+
381+static 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+}
407+module_init(dynamic_printk_init);
408+/* may want to move this earlier so we can get traces as early as possible */
409+
410+static 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 */
418+early_param("dynamic_printk", dynamic_printk_setup);
lib/kobject.c+20−15
@@ -387,11 +387,17 @@ EXPORT_SYMBOL_GPL(kobject_init_and_add); · 386 unmodified lines
387387 * kobject_rename - change the name of an object
388388 * @kobj: object in question.
389389 * @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.
390395 */
391396 int kobject_rename(struct kobject *kobj, const char *new_name)
392397 {
393398 int error = 0;
394399 const char *devpath = NULL;
400+ const char *dup_name = NULL, *name;
395401 char *devpath_string = NULL;
396402 char *envp[2];
397403
@@ -401,19 +407,6 @@ int kobject_rename(struct kobject *kobj, const char *new_name) · 3 unmodified lines
401407 if (!kobj->parent)
402408 return -EINVAL;
403409
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−
417410 devpath = kobject_get_path(kobj, GFP_KERNEL);
418411 if (!devpath) {
419412 error = -ENOMEM;
@@ -428,15 +421,27 @@ int kobject_rename(struct kobject *kobj, const char *new_name) · 8 unmodified lines
428421 envp[0] = devpath_string;
429422 envp[1] = NULL;
430423
424+ name = dup_name = kstrdup(new_name, GFP_KERNEL);
425+ if (!name) {
426+ error = -ENOMEM;
427+ goto out;
428+ }
429+
431430 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;
432437
433438 /* This function is mostly/only used for network interface.
434439 * Some hotplug package track interfaces by their name and
435440 * therefore want to know when the name is changed by the user. */
436− if (!error)
437− kobject_uevent_env(kobj, KOBJ_MOVE, envp);
441+ kobject_uevent_env(kobj, KOBJ_MOVE, envp);
438442
439443 out:
444+ kfree(dup_name);
440445 kfree(devpath_string);
441446 kfree(devpath);
442447 kobject_put(kobj);
net/netfilter/nf_conntrack_pptp.c+1−1
@@ -65,7 +65,7 @@ void · 64 unmodified lines
6565 struct nf_conntrack_expect *exp) __read_mostly;
6666 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
6767
68−#ifdef DEBUG
68+#if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
6969 /* PptpControlMessageType names */
7070 const char *const pptp_msg_name[] = {
7171 "UNKNOWN_MESSAGE",
scripts/Makefile.lib+10−1
@@ -96,6 +96,14 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" · 95 unmodified lines
9696 modname_flags = $(if $(filter 1,$(words $(modname))),\
9797 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
9898
99+#hash values
100+ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
101+debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\
102+ -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))"
103+else
104+debug_flags =
105+endif
106+
99107 orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
100108 _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
101109 _a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
@@ -121,7 +129,8 @@ endif · 19 unmodified lines
121129
122130 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
123131 $(__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)
125134
126135 a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
127136 $(__a_flags) $(modkern_aflags)
scripts/basic/Makefile+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 # fixdep: Used to generate dependency information during build process
1010 # docproc: Used in Documentation/DocBook
1111
12−hostprogs-y := fixdep docproc
12+hostprogs-y := fixdep docproc hash
1313 always := $(hostprogs-y)
1414
1515 # fixdep is needed to compile other host programs
scripts/basic/hash.c+64−0
@@ -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+
12+static const char *program;
13+
14+static 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+
24+unsigned 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+
37+unsigned 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+
50+int 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+
sound/core/init.c+3−3
@@ -549,9 +549,9 @@ int snd_card_register(struct snd_card *card) · 548 unmodified lines
549549 return -EINVAL;
550550 #ifndef CONFIG_SYSFS_DEPRECATED
551551 if (!card->card_dev) {
552− card->card_dev = device_create_drvdata(sound_class, card->dev,
553− MKDEV(0, 0), NULL,
554− "card%i", card->number);
552+ card->card_dev = device_create(sound_class, card->dev,
553+ MKDEV(0, 0), NULL,
554+ "card%i", card->number);
555555 if (IS_ERR(card->card_dev))
556556 card->card_dev = NULL;
557557 }
sound/core/sound.c+2−3
@@ -274,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, · 273 unmodified lines
274274 return minor;
275275 }
276276 snd_minors[minor] = preg;
277− preg->dev = device_create_drvdata(sound_class, device,
278− MKDEV(major, minor),
279− private_data, "%s", name);
277+ preg->dev = device_create(sound_class, device, MKDEV(major, minor),
278+ private_data, "%s", name);
280279 if (IS_ERR(preg->dev)) {
281280 snd_minors[minor] = NULL;
282281 mutex_unlock(&sound_mutex);
sound/oss/soundcard.c+7−8
@@ -560,19 +560,18 @@ static int __init oss_init(void) · 559 unmodified lines
560560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
561561
562562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
563− device_create_drvdata(sound_class, NULL,
564− MKDEV(SOUND_MAJOR, dev_list[i].minor),
565− NULL, "%s", dev_list[i].name);
563+ device_create(sound_class, NULL,
564+ MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL,
565+ "%s", dev_list[i].name);
566566
567567 if (!dev_list[i].num)
568568 continue;
569569
570570 for (j = 1; j < *dev_list[i].num; j++)
571− device_create_drvdata(sound_class, NULL,
572− MKDEV(SOUND_MAJOR,
573− dev_list[i].minor + (j*0x10)),
574− NULL,
575− "%s%d", dev_list[i].name, j);
571+ device_create(sound_class, NULL,
572+ MKDEV(SOUND_MAJOR,
573+ dev_list[i].minor + (j*0x10)),
574+ NULL, "%s%d", dev_list[i].name, j);
576575 }
577576
578577 if (sound_nblocks >= 1024)
sound/sound_core.c+2−3
@@ -220,9 +220,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati · 219 unmodified lines
220220 else
221221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
222222
223− device_create_drvdata(sound_class, dev,
224− MKDEV(SOUND_MAJOR, s->unit_minor),
225− NULL, s->name+6);
223+ device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
224+ NULL, s->name+6);
226225 return r;
227226
228227 fail: