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: (79 commits) arm: bus_id -> dev_name() and dev_set_name() conversions sparc64: fix up bus_id changes in sparc core code 3c59x: handle pci_name() being const MTD: handle pci_name() being const HP iLO driver sysdev: Convert the x86 mce tolerant sysdev attribute to generic attribute sysdev: Add utility functions for simple int/ulong variable sysdev attributes sysdev: Pass the attribute to the low level sysdev show/store function driver core: Suppress sysfs warnings for device_rename(). kobject: Transmit return value of call_usermodehelper() to caller sysfs-rules.txt: reword API stability statement debugfs: Implement debugfs_remove_recursive() HOWTO: change email addresses of James in HOWTO always enable FW_LOADER unless EMBEDDED=y uio-howto.tmpl: use unique output names uio-howto.tmpl: use standard copyright/legal markings sysfs: don't call notify_change sysdev: fix debugging statements in registration code. kobject: should use kobject_put() in kset-example kobject: reorder kobject to save space on 64 bit builds ...

Linus Torvalds committed 18 years ago

Commit 53baaaa2 parents f10140f 3f97870173 files · +2508 −751Browse files

Unified · Split

173 files
  1. Documentation/ABI/testing/sysfs-dev +20 −0
  2. Documentation/DocBook/uio-howto.tmpl +51 −12
  3. Documentation/HOWTO +1 −1
  4. Documentation/filesystems/sysfs.txt +6 −0
  5. Documentation/sysfs-rules.txt +2 −3
  6. arch/arm/common/dmabounce.c +9 −13
  7. arch/arm/common/locomo.c +1 −1
  8. arch/arm/common/sa1111.c +5 −5
  9. arch/arm/common/scoop.c +1 −1
  10. arch/arm/kernel/ecard.c +2 −3
  11. arch/arm/kernel/time.c +3 −1
  12. arch/arm/mach-integrator/impd1.c +2 −5
  13. arch/arm/mach-integrator/lm.c +4 −2
  14. arch/arm/plat-omap/mailbox.c +1 −1
  15. arch/avr32/kernel/cpu.c +25 −13
  16. arch/ia64/kernel/err_inject.c +15 −7
  17. arch/mips/kernel/rtlx.c +2 −2
  18. arch/mips/sibyte/common/sb_tbprof.c +2 −1
  19. arch/powerpc/kernel/sysfs.c +11 −4
  20. arch/powerpc/platforms/cell/cbe_thermal.c +30 −15
  21. arch/powerpc/platforms/cell/spu_base.c +2 −1
  22. arch/powerpc/platforms/chrp/pci.c +1 −1
  23. arch/s390/kernel/smp.c +24 −12
  24. arch/s390/kernel/time.c +24 −11
  25. arch/sh/drivers/dma/dma-sysfs.c +11 −4
  26. arch/sparc64/kernel/ebus.c +2 −2
  27. arch/sparc64/kernel/of_device.c +2 −2
  28. arch/sparc64/kernel/pci.c +1 −1
  29. arch/sparc64/kernel/sysfs.c +11 −5
  30. arch/sparc64/kernel/vio.c +8 −10
  31. arch/x86/kernel/cpu/mcheck/mce_64.c +12 −6
  32. arch/x86/kernel/cpu/mcheck/therm_throt.c +1 −0
  33. arch/x86/kernel/cpuid.c +2 −2
  34. arch/x86/kernel/microcode.c +7 −3
  35. arch/x86/kernel/msr.c +2 −2
  36. arch/x86/kernel/pci-dma.c +2 −4
  37. arch/x86/kernel/pci-gart_64.c +1 −3
  38. block/bsg.c +2 −1
  39. block/genhd.c +119 −86
  40. drivers/acpi/fan.c +5 −5
  41. drivers/acpi/glue.c +2 −4
  42. drivers/acpi/processor_core.c +2 −3
  43. drivers/acpi/scan.c +1 −1
  44. drivers/acpi/thermal.c +2 −2
  45. drivers/acpi/video.c +2 −3
  46. drivers/base/Kconfig +2 −1
  47. drivers/base/base.h +27 −0
  48. drivers/base/class.c +89 −64
  49. drivers/base/core.c +124 −72
  50. drivers/base/cpu.c +6 −4
  51. drivers/base/memory.c +8 −4
  52. drivers/base/node.c +10 −5
  53. drivers/base/power/trace.c +1 −1
  54. drivers/base/sys.c +59 −5
  55. drivers/base/topology.c +12 −5
  56. drivers/block/aoe/aoechr.c +3 −2
  57. drivers/block/paride/pg.c +3 −2
  58. drivers/block/paride/pt.c +6 −4
  59. drivers/block/pktcdvd.c +3 −1
  60. drivers/char/dsp56k.c +2 −1
  61. drivers/char/ip2/ip2main.c +6 −6
  62. drivers/char/ipmi/ipmi_devintf.c +1 −1
  63. drivers/char/istallion.c +3 −2
  64. drivers/char/lp.c +2 −1
  65. drivers/char/mem.c +3 −3
  66. drivers/char/misc.c +2 −2
  67. drivers/char/pcmcia/cm4000_cs.c +1 −1
  68. drivers/char/pcmcia/cm4040_cs.c +2 −1
  69. drivers/char/ppdev.c +3 −2
  70. drivers/char/raw.c +4 −3
  71. drivers/char/snsc.c +2 −1
  72. drivers/char/stallion.c +2 −2
  73. drivers/char/tty_io.c +7 −5
  74. drivers/char/vc_screen.c +6 −6
  75. drivers/char/viotape.c +4 −4
  76. drivers/char/vt.c +8 −6
  77. drivers/char/xilinx_hwicap/xilinx_hwicap.c +3 −2
  78. drivers/cpuidle/sysfs.c +7 −3
  79. drivers/dca/dca-sysfs.c +5 −3
  80. drivers/eisa/Makefile +1 −1
  81. drivers/eisa/eisa-bus.c +2 −2
  82. drivers/hid/hidraw.c +3 −2
  83. drivers/hwmon/hwmon.c +2 −1
  84. drivers/i2c/i2c-core.c +4 −2
  85. drivers/i2c/i2c-dev.c +3 −3
  86. drivers/ide/ide-tape.c +6 −4
  87. drivers/ieee1394/dv1394.c +4 −3
  88. drivers/ieee1394/nodemgr.c +15 −8
  89. drivers/ieee1394/raw1394.c +2 −2
  90. drivers/ieee1394/video1394.c +3 −3
  91. drivers/infiniband/core/cm.c +31 −41
  92. drivers/infiniband/hw/ipath/ipath_file_ops.c +1 −1
  93. drivers/isdn/capi/capi.c +2 −1
  94. drivers/macintosh/adb.c +2 −1
  95. drivers/mca/mca-bus.c +1 −1
  96. drivers/media/dvb/dvb-core/dvbdev.c +2 −2
  97. drivers/memstick/host/jmb38x_ms.c +2 −2
  98. drivers/message/fusion/mptbase.c +2 −1
  99. drivers/message/fusion/mptbase.h +2 −2
  100. drivers/message/fusion/mptfc.c +2 −2
  101. drivers/misc/Kconfig +13 −0
  102. drivers/misc/Makefile +1 −0
  103. drivers/misc/hpilo.c +768 −0
  104. drivers/misc/hpilo.h +189 −0
  105. drivers/misc/phantom.c +3 −2
  106. drivers/mtd/devices/block2mtd.c +5 −3
  107. drivers/mtd/mtdchar.c +6 −3
  108. drivers/net/3c59x.c +1 −1
  109. drivers/net/arm/at91_ether.c +1 −1
  110. drivers/net/arm/ep93xx_eth.c +1 −1
  111. drivers/net/arm/etherh.c +3 −3
  112. drivers/net/ppp_generic.c +2 −1
  113. drivers/net/wan/cosa.c +3 −3
  114. drivers/pci/hotplug/acpiphp.h +2 −2
  115. drivers/power/apm_power.c +1 −1
  116. drivers/power/power_supply_core.c +2 −2
  117. drivers/rtc/interface.c +1 −1
  118. drivers/s390/char/raw3270.c +8 −6
  119. drivers/s390/char/tape_class.c +3 −4
  120. drivers/s390/char/vmur.c +3 −2
  121. drivers/sbus/sbus.c +3 −3
  122. drivers/scsi/dpt_i2o.c +2 −2
  123. drivers/scsi/hosts.c +4 −3
  124. drivers/scsi/scsi_transport_fc.c +5 −4
  125. drivers/scsi/scsi_transport_iscsi.c +4 −4
  126. drivers/spi/spi.c +1 −1
  127. drivers/spi/spidev.c +2 −2
  128. drivers/uio/Kconfig +8 −2
  129. drivers/uio/Makefile +1 −0
  130. drivers/uio/uio.c +26 −0
  131. drivers/uio/uio_pdrv.c +118 −0
  132. drivers/usb/core/devio.c +8 −3
  133. drivers/usb/core/file.c +3 −2
  134. drivers/usb/gadget/printer.c +2 −2
  135. drivers/usb/mon/mon_bin.c +3 −2
  136. drivers/video/aty/aty128fb.c +1 −1
  137. drivers/video/aty/radeonfb.h +1 −1
  138. drivers/video/console/fbcon.c +2 −1
  139. drivers/video/fbmem.c +3 −2
  140. drivers/xen/balloon.c +1 −0
  141. fs/coda/psdev.c +3 −2
  142. fs/debugfs/inode.c +96 −18
  143. fs/partitions/check.c +1 −1
  144. fs/sysfs/dir.c +35 −2
  145. fs/sysfs/file.c +4 −1
  146. fs/sysfs/symlink.c +33 −8
  147. fs/sysfs/sysfs.h +1 −0
  148. include/linux/debugfs.h +4 −0
  149. include/linux/device.h +36 −22
  150. include/linux/eisa.h +1 −1
  151. include/linux/kobject.h +1 −2
  152. include/linux/mtd/map.h +1 −1
  153. include/linux/mtd/mtd.h +1 −1
  154. include/linux/spi/spi.h +1 −1
  155. include/linux/sysdev.h +37 −2
  156. include/linux/sysfs.h +10 −0
  157. include/linux/uio_driver.h +5 −3
  158. include/scsi/scsi_host.h +1 −1
  159. include/scsi/scsi_transport_fc.h +2 −2
  160. include/scsi/scsi_transport_iscsi.h +1 −1
  161. kernel/rtmutex-tester.c +4 −3
  162. kernel/sched.c +6 −2
  163. kernel/time/clocksource.c +6 −2
  164. lib/Kconfig.debug +3 −0
  165. lib/kobject.c +8 −2
  166. lib/kobject_uevent.c +2 −1
  167. net/bluetooth/hci_sysfs.c +0 −7
  168. samples/firmware_class/firmware_sample_firmware_class.c +1 −1
  169. samples/kobject/kset-example.c +1 −1
  170. scripts/mod/file2alias.c +16 −8
  171. sound/core/init.c +3 −2
  172. sound/oss/soundcard.c +8 −6
  173. sound/sound_core.c +3 −2
Documentation/ABI/testing/sysfs-dev+20−0
@@ -0,0 +1,20 @@
1+What: /sys/dev
2+Date: April 2008
3+KernelVersion: 2.6.26
4+Contact: Dan Williams <dan.j.williams@intel.com>
5+Description: The /sys/dev tree provides a method to look up the sysfs
6+ path for a device using the information returned from
7+ stat(2). There are two directories, 'block' and 'char',
8+ beneath /sys/dev containing symbolic links with names of
9+ the form "<major>:<minor>". These links point to the
10+ corresponding sysfs path for the given device.
11+
12+ Example:
13+ $ readlink /sys/dev/block/8:32
14+ ../../block/sdc
15+
16+ Entries in /sys/dev/char and /sys/dev/block will be
17+ dynamically created and destroyed as devices enter and
18+ leave the system.
19+
20+Users: mdadm <linux-raid@vger.kernel.org>
Documentation/DocBook/uio-howto.tmpl+51−12
@@ -21,6 +21,18 @@ · 20 unmodified lines
2121 </affiliation>
2222 </author>
2323
24+<copyright>
25+ <year>2006-2008</year>
26+ <holder>Hans-Jürgen Koch.</holder>
27+</copyright>
28+
29+<legalnotice>
30+<para>
31+This documentation is Free Software licensed under the terms of the
32+GPL version 2.
33+</para>
34+</legalnotice>
35+
2436 <pubdate>2006-12-11</pubdate>
2537
2638 <abstract>
@@ -29,6 +41,12 @@ · 2 unmodified lines
2941 </abstract>
3042
3143 <revhistory>
44+ <revision>
45+ <revnumber>0.5</revnumber>
46+ <date>2008-05-22</date>
47+ <authorinitials>hjk</authorinitials>
48+ <revremark>Added description of write() function.</revremark>
49+ </revision>
3250 <revision>
3351 <revnumber>0.4</revnumber>
3452 <date>2007-11-26</date>
@@ -57,20 +75,9 @@ · 22 unmodified lines
5775 </bookinfo>
5876
5977 <chapter id="aboutthisdoc">
60−<?dbhtml filename="about.html"?>
78+<?dbhtml filename="aboutthis.html"?>
6179 <title>About this document</title>
6280
63−<sect1 id="copyright">
64−<?dbhtml filename="copyright.html"?>
65−<title>Copyright and License</title>
66−<para>
67− Copyright (c) 2006 by Hans-Jürgen Koch.</para>
68−<para>
69−This documentation is Free Software licensed under the terms of the
70−GPL version 2.
71−</para>
72−</sect1>
73−
7481 <sect1 id="translations">
7582 <?dbhtml filename="translations.html"?>
7683 <title>Translations</title>
@@ -189,6 +196,30 @@ interested in translating it, please email me · 112 unmodified lines
189196 represents the total interrupt count. You can use this number
190197 to figure out if you missed some interrupts.
191198 </para>
199+ <para>
200+ For some hardware that has more than one interrupt source internally,
201+ but not separate IRQ mask and status registers, there might be
202+ situations where userspace cannot determine what the interrupt source
203+ was if the kernel handler disables them by writing to the chip's IRQ
204+ register. In such a case, the kernel has to disable the IRQ completely
205+ to leave the chip's register untouched. Now the userspace part can
206+ determine the cause of the interrupt, but it cannot re-enable
207+ interrupts. Another cornercase is chips where re-enabling interrupts
208+ is a read-modify-write operation to a combined IRQ status/acknowledge
209+ register. This would be racy if a new interrupt occurred
210+ simultaneously.
211+ </para>
212+ <para>
213+ To address these problems, UIO also implements a write() function. It
214+ is normally not used and can be ignored for hardware that has only a
215+ single interrupt source or has separate IRQ mask and status registers.
216+ If you need it, however, a write to <filename>/dev/uioX</filename>
217+ will call the <function>irqcontrol()</function> function implemented
218+ by the driver. You have to write a 32-bit value that is usually either
219+ 0 or 1 to disable or enable interrupts. If a driver does not implement
220+ <function>irqcontrol()</function>, <function>write()</function> will
221+ return with <varname>-ENOSYS</varname>.
222+ </para>
192223
193224 <para>
194225 To handle interrupts properly, your custom kernel module can
@@ -362,6 +393,14 @@ device is actually used. · 167 unmodified lines
362393 <function>open()</function>, you will probably also want a custom
363394 <function>release()</function> function.
364395 </para></listitem>
396+
397+<listitem><para>
398+<varname>int (*irqcontrol)(struct uio_info *info, s32 irq_on)
399+</varname>: Optional. If you need to be able to enable or disable
400+interrupts from userspace by writing to <filename>/dev/uioX</filename>,
401+you can implement this function. The parameter <varname>irq_on</varname>
402+will be 0 to disable interrupts and 1 to enable them.
403+</para></listitem>
365404 </itemizedlist>
366405
367406 <para>
Documentation/HOWTO+1−1
@@ -358,7 +358,7 @@ Here is a list of some of the different kernel trees available: · 357 unmodified lines
358358 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
359359 git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
360360
361− - SCSI, James Bottomley <James.Bottomley@SteelEye.com>
361+ - SCSI, James Bottomley <James.Bottomley@hansenpartnership.com>
362362 git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
363363
364364 - x86, Ingo Molnar <mingo@elte.hu>
Documentation/filesystems/sysfs.txt+6−0
@@ -248,6 +248,7 @@ The top level sysfs directory looks like: · 247 unmodified lines
248248 block/
249249 bus/
250250 class/
251+dev/
251252 devices/
252253 firmware/
253254 net/
@@ -274,6 +275,11 @@ fs/ contains a directory for some filesystems. Currently each · 20 unmodified lines
274275 filesystem wanting to export attributes must create its own hierarchy
275276 below fs/ (see ./fuse.txt for an example).
276277
278+dev/ contains two directories char/ and block/. Inside these two
279+directories there are symlinks named <major>:<minor>. These symlinks
280+point to the sysfs directory for the given device. /sys/dev provides a
281+quick way to lookup the sysfs interface for a device from the result of
282+a stat(2) operation.
277283
278284 More information can driver-model specific features can be found in
279285 Documentation/driver-model/.
Documentation/sysfs-rules.txt+2−3
@@ -3,9 +3,8 @@ Rules on how to access information in the Linux kernel sysfs · 2 unmodified lines
33 The kernel-exported sysfs exports internal kernel implementation details
44 and depends on internal kernel structures and layout. It is agreed upon
55 by the kernel developers that the Linux kernel does not provide a stable
6−internal API. As sysfs is a direct export of kernel internal
7−structures, the sysfs interface cannot provide a stable interface either;
8−it may always change along with internal kernel changes.
6+internal API. Therefore, there are aspects of the sysfs interface that
7+may not be stable across kernel releases.
98
109 To minimize the risk of breaking users of sysfs, which are in most cases
1110 low-level userspace applications, with a new kernel release, the users
arch/arm/common/dmabounce.c+9−13
@@ -554,9 +554,8 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, · 553 unmodified lines
554554
555555 device_info = kmalloc(sizeof(struct dmabounce_device_info), GFP_ATOMIC);
556556 if (!device_info) {
557− printk(KERN_ERR
558− "Could not allocated dmabounce_device_info for %s",
559− dev->bus_id);
557+ dev_err(dev,
558+ "Could not allocated dmabounce_device_info\n");
560559 return -ENOMEM;
561560 }
562561
@@ -594,8 +593,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, · 31 unmodified lines
594593
595594 dev->archdata.dmabounce = device_info;
596595
597− printk(KERN_INFO "dmabounce: registered device %s on %s bus\n",
598− dev->bus_id, dev->bus->name);
596+ dev_info(dev, "dmabounce: registered device\n");
599597
600598 return 0;
601599
@@ -614,16 +612,15 @@ dmabounce_unregister_dev(struct device *dev) · 12 unmodified lines
614612 dev->archdata.dmabounce = NULL;
615613
616614 if (!device_info) {
617− printk(KERN_WARNING
618− "%s: Never registered with dmabounce but attempting" \
619− "to unregister!\n", dev->bus_id);
615+ dev_warn(dev,
616+ "Never registered with dmabounce but attempting"
617+ "to unregister!\n");
620618 return;
621619 }
622620
623621 if (!list_empty(&device_info->safe_buffers)) {
624− printk(KERN_ERR
625− "%s: Removing from dmabounce with pending buffers!\n",
626− dev->bus_id);
622+ dev_err(dev,
623+ "Removing from dmabounce with pending buffers!\n");
627624 BUG();
628625 }
629626
@@ -639,8 +636,7 @@ dmabounce_unregister_dev(struct device *dev) · 9 unmodified lines
639636
640637 kfree(device_info);
641638
642− printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n",
643− dev->bus_id, dev->bus->name);
639+ dev_info(dev, "dmabounce: device unregistered\n");
644640 }
645641
646642
arch/arm/common/locomo.c+1−1
@@ -543,7 +543,6 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info) · 542 unmodified lines
543543 goto out;
544544 }
545545
546− strncpy(dev->dev.bus_id, info->name, sizeof(dev->dev.bus_id));
547546 /*
548547 * If the parent device has a DMA mask associated with it,
549548 * propagate it down to the children.
@@ -553,6 +552,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info) · 3 unmodified lines
553552 dev->dev.dma_mask = &dev->dma_mask;
554553 }
555554
555+ dev_set_name(&dev->dev, "%s", info->name);
556556 dev->devid = info->devid;
557557 dev->dev.parent = lchip->dev;
558558 dev->dev.bus = &locomo_bus_type;
arch/arm/common/sa1111.c+5−5
@@ -550,9 +550,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 549 unmodified lines
550550 goto out;
551551 }
552552
553− snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
554− "%4.4lx", info->offset);
555−
553+ dev_set_name(&dev->dev, "%4.4lx", info->offset);
556554 dev->devid = info->devid;
557555 dev->dev.parent = sachip->dev;
558556 dev->dev.bus = &sa1111_bus_type;
@@ -560,7 +558,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 1 unmodified line
560558 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
561559 dev->res.start = sachip->phys + info->offset;
562560 dev->res.end = dev->res.start + 511;
563− dev->res.name = dev->dev.bus_id;
561+ dev->res.name = dev_name(&dev->dev);
564562 dev->res.flags = IORESOURCE_MEM;
565563 dev->mapbase = sachip->base + info->offset;
566564 dev->skpcr_mask = info->skpcr_mask;
@@ -570,6 +568,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 3 unmodified lines
570568 if (ret) {
571569 printk("SA1111: failed to allocate resource for %s\n",
572570 dev->res.name);
571+ dev_set_name(&dev->dev, NULL);
573572 kfree(dev);
574573 goto out;
575574 }
@@ -593,7 +592,8 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, · 17 unmodified lines
593592 if (dev->dma_mask != 0xffffffffUL) {
594593 ret = dmabounce_register_dev(&dev->dev, 1024, 4096);
595594 if (ret) {
596− printk("SA1111: Failed to register %s with dmabounce", dev->dev.bus_id);
595+ dev_err(&dev->dev, "SA1111: Failed to register"
596+ " with dmabounce\n");
597597 device_unregister(&dev->dev);
598598 }
599599 }
arch/arm/common/scoop.c+1−1
@@ -247,7 +247,7 @@ static int __devinit scoop_probe(struct platform_device *pdev) · 246 unmodified lines
247247 devptr->gpio.base = -1;
248248
249249 if (inf->gpio_base != 0) {
250− devptr->gpio.label = pdev->dev.bus_id;
250+ devptr->gpio.label = dev_name(&pdev->dev);
251251 devptr->gpio.base = inf->gpio_base;
252252 devptr->gpio.ngpio = 12; /* PA11 = 0, PA12 = 1, etc. up to PA22 = 11 */
253253 devptr->gpio.set = scoop_gpio_set;
arch/arm/kernel/ecard.c+2−3
@@ -783,7 +783,7 @@ static void ecard_proc_init(void) · 782 unmodified lines
783783
784784 #define ec_set_resource(ec,nr,st,sz) \
785785 do { \
786− (ec)->resource[nr].name = ec->dev.bus_id; \
786+ (ec)->resource[nr].name = dev_name(&ec->dev); \
787787 (ec)->resource[nr].start = st; \
788788 (ec)->resource[nr].end = (st) + (sz) - 1; \
789789 (ec)->resource[nr].flags = IORESOURCE_MEM; \
@@ -853,8 +853,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot) · 63 unmodified lines
853853 for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
854854 if (ec->resource[i].flags &&
855855 request_resource(&iomem_resource, &ec->resource[i])) {
856− printk(KERN_ERR "%s: resource(s) not available\n",
857− ec->dev.bus_id);
856+ dev_err(&ec->dev, "resource(s) not available\n");
858857 ec->resource[i].end -= ec->resource[i].start;
859858 ec->resource[i].start = 0;
860859 ec->resource[i].flags = 0;
arch/arm/kernel/time.c+3−1
@@ -130,7 +130,9 @@ static const struct leds_evt_name evt_names[] = { · 129 unmodified lines
130130 { "red", led_red_on, led_red_off },
131131 };
132132
133−static ssize_t leds_store(struct sys_device *dev, const char *buf, size_t size)
133+static ssize_t leds_store(struct sys_device *dev,
134+ struct sysdev_attribute *attr,
135+ const char *buf, size_t size)
134136 {
135137 int ret = -EINVAL, len = strcspn(buf, " ");
136138
arch/arm/mach-integrator/impd1.c+2−5
@@ -393,9 +393,7 @@ static int impd1_probe(struct lm_device *dev) · 392 unmodified lines
393393 if (!d)
394394 continue;
395395
396− snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
397− "lm%x:%5.5lx", dev->id, idev->offset >> 12);
398−
396+ dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
399397 d->dev.parent = &dev->dev;
400398 d->res.start = dev->resource.start + idev->offset;
401399 d->res.end = d->res.start + SZ_4K - 1;
@@ -407,8 +405,7 @@ static int impd1_probe(struct lm_device *dev) · 5 unmodified lines
407405
408406 ret = amba_device_register(d, &dev->resource);
409407 if (ret) {
410− printk("unable to register device %s: %d\n",
411− d->dev.bus_id, ret);
408+ dev_err(&d->dev, "unable to register device: %d\n");
412409 kfree(d);
413410 }
414411 }
arch/arm/mach-integrator/lm.c+4−2
@@ -81,8 +81,10 @@ int lm_device_register(struct lm_device *dev) · 80 unmodified lines
8181 dev->dev.release = lm_device_release;
8282 dev->dev.bus = &lm_bustype;
8383
84− snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id);
85− dev->resource.name = dev->dev.bus_id;
84+ ret = dev_set_name(&dev->dev, "lm%d", dev->id);
85+ if (ret)
86+ return ret;
87+ dev->resource.name = dev_name(&dev->dev);
8688
8789 ret = request_resource(&iomem_resource, &dev->resource);
8890 if (ret == 0) {
arch/arm/plat-omap/mailbox.c+1−1
@@ -334,7 +334,7 @@ static int omap_mbox_init(struct omap_mbox *mbox) · 333 unmodified lines
334334 }
335335
336336 mbox->dev.class = &omap_mbox_class;
337− strlcpy(mbox->dev.bus_id, mbox->name, KOBJ_NAME_LEN);
337+ dev_set_name(&mbox->dev, "%s", mbox->name);
338338 dev_set_drvdata(&mbox->dev, mbox);
339339
340340 ret = device_register(&mbox->dev);
arch/avr32/kernel/cpu.c+25−13
@@ -26,14 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); · 25 unmodified lines
2626 * XXX: If/when a SMP-capable implementation of AVR32 will ever be
2727 * made, we must make sure that the code executes on the correct CPU.
2828 */
29−static ssize_t show_pc0event(struct sys_device *dev, char *buf)
29+static ssize_t show_pc0event(struct sys_device *dev,
30+ struct sysdev_attribute *attr, char *buf)
3031 {
3132 unsigned long pccr;
3233
3334 pccr = sysreg_read(PCCR);
3435 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
3536 }
36−static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
37+static ssize_t store_pc0event(struct sys_device *dev,
38+ struct sysdev_attribute *attr, const char *buf,
3739 size_t count)
3840 {
3941 unsigned long val;
@@ -46,15 +48,17 @@ static ssize_t store_pc0event(struct sys_device *dev, const char *buf, · 6 unmodified lines
4648 sysreg_write(PCCR, val);
4749 return count;
4850 }
49−static ssize_t show_pc0count(struct sys_device *dev, char *buf)
51+static ssize_t show_pc0count(struct sys_device *dev,
52+ struct sysdev_attribute *attr, char *buf)
5053 {
5154 unsigned long pcnt0;
5255
5356 pcnt0 = sysreg_read(PCNT0);
5457 return sprintf(buf, "%lu\n", pcnt0);
5558 }
56−static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
57− size_t count)
59+static ssize_t store_pc0count(struct sys_device *dev,
60+ struct sysdev_attribute *attr,
61+ const char *buf, size_t count)
5862 {
5963 unsigned long val;
6064 char *endp;
@@ -67,14 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev, const char *buf, · 6 unmodified lines
6771 return count;
6872 }
6973
70−static ssize_t show_pc1event(struct sys_device *dev, char *buf)
74+static ssize_t show_pc1event(struct sys_device *dev,
75+ struct sysdev_attribute *attr, char *buf)
7176 {
7277 unsigned long pccr;
7378
7479 pccr = sysreg_read(PCCR);
7580 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
7681 }
77−static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
82+static ssize_t store_pc1event(struct sys_device *dev,
83+ struct sysdev_attribute *attr, const char *buf,
7884 size_t count)
7985 {
8086 unsigned long val;
@@ -87,14 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev, const char *buf, · 6 unmodified lines
8793 sysreg_write(PCCR, val);
8894 return count;
8995 }
90−static ssize_t show_pc1count(struct sys_device *dev, char *buf)
96+static ssize_t show_pc1count(struct sys_device *dev,
97+ struct sysdev_attribute *attr, char *buf)
9198 {
9299 unsigned long pcnt1;
93100
94101 pcnt1 = sysreg_read(PCNT1);
95102 return sprintf(buf, "%lu\n", pcnt1);
96103 }
97−static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
104+static ssize_t store_pc1count(struct sys_device *dev,
105+ struct sysdev_attribute *attr, const char *buf,
98106 size_t count)
99107 {
100108 unsigned long val;
@@ -108,14 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev, const char *buf, · 7 unmodified lines
108116 return count;
109117 }
110118
111−static ssize_t show_pccycles(struct sys_device *dev, char *buf)
119+static ssize_t show_pccycles(struct sys_device *dev,
120+ struct sysdev_attribute *attr, char *buf)
112121 {
113122 unsigned long pccnt;
114123
115124 pccnt = sysreg_read(PCCNT);
116125 return sprintf(buf, "%lu\n", pccnt);
117126 }
118−static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
127+static ssize_t store_pccycles(struct sys_device *dev,
128+ struct sysdev_attribute *attr, const char *buf,
119129 size_t count)
120130 {
121131 unsigned long val;
@@ -129,14 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev, const char *buf, · 7 unmodified lines
129139 return count;
130140 }
131141
132−static ssize_t show_pcenable(struct sys_device *dev, char *buf)
142+static ssize_t show_pcenable(struct sys_device *dev,
143+ struct sysdev_attribute *attr, char *buf)
133144 {
134145 unsigned long pccr;
135146
136147 pccr = sysreg_read(PCCR);
137148 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
138149 }
139−static ssize_t store_pcenable(struct sys_device *dev, const char *buf,
150+static ssize_t store_pcenable(struct sys_device *dev,
151+ struct sysdev_attribute *attr, const char *buf,
140152 size_t count)
141153 {
142154 unsigned long pccr, val;
arch/ia64/kernel/err_inject.c+15−7
@@ -55,7 +55,8 @@ static u64 resources[NR_CPUS]; · 54 unmodified lines
5555
5656 #define show(name) \
5757 static ssize_t \
58−show_##name(struct sys_device *dev, char *buf) \
58+show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
59+ char *buf) \
5960 { \
6061 u32 cpu=dev->id; \
6162 return sprintf(buf, "%lx\n", name[cpu]); \
@@ -63,7 +64,8 @@ show_##name(struct sys_device *dev, char *buf) \ · 1 unmodified line
6364
6465 #define store(name) \
6566 static ssize_t \
66−store_##name(struct sys_device *dev, const char *buf, size_t size) \
67+store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \
68+ const char *buf, size_t size) \
6769 { \
6870 unsigned int cpu=dev->id; \
6971 name[cpu] = simple_strtoull(buf, NULL, 16); \
@@ -76,7 +78,8 @@ show(call_start) · 6 unmodified lines
7678 * processor. The cpu number in driver is only used for storing data.
7779 */
7880 static ssize_t
79−store_call_start(struct sys_device *dev, const char *buf, size_t size)
81+store_call_start(struct sys_device *dev, struct sysdev_attribute *attr,
82+ const char *buf, size_t size)
8083 {
8184 unsigned int cpu=dev->id;
8285 unsigned long call_start = simple_strtoull(buf, NULL, 16);
@@ -124,14 +127,16 @@ show(err_type_info) · 41 unmodified lines
124127 store(err_type_info)
125128
126129 static ssize_t
127−show_virtual_to_phys(struct sys_device *dev, char *buf)
130+show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
131+ char *buf)
128132 {
129133 unsigned int cpu=dev->id;
130134 return sprintf(buf, "%lx\n", phys_addr[cpu]);
131135 }
132136
133137 static ssize_t
134−store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size)
138+store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
139+ const char *buf, size_t size)
135140 {
136141 unsigned int cpu=dev->id;
137142 u64 virt_addr=simple_strtoull(buf, NULL, 16);
@@ -154,7 +159,8 @@ show(err_struct_info) · 16 unmodified lines
154159 store(err_struct_info)
155160
156161 static ssize_t
157−show_err_data_buffer(struct sys_device *dev, char *buf)
162+show_err_data_buffer(struct sys_device *dev,
163+ struct sysdev_attribute *attr, char *buf)
158164 {
159165 unsigned int cpu=dev->id;
160166
@@ -165,7 +171,9 @@ show_err_data_buffer(struct sys_device *dev, char *buf) · 4 unmodified lines
165171 }
166172
167173 static ssize_t
168−store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size)
174+store_err_data_buffer(struct sys_device *dev,
175+ struct sysdev_attribute *attr,
176+ const char *buf, size_t size)
169177 {
170178 unsigned int cpu=dev->id;
171179 int ret;
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(mt_class, NULL, MKDEV(major, i),
526− "%s%d", module_name, i);
525+ dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i),
526+ NULL, "%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+2−1
@@ -576,7 +576,8 @@ static int __init sbprof_tb_init(void) · 575 unmodified lines
576576
577577 tb_class = tbc;
578578
579− dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), "tb");
579+ dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0),
580+ NULL, "tb");
580581 if (IS_ERR(dev)) {
581582 err = PTR_ERR(dev);
582583 goto out_class;
arch/powerpc/kernel/sysfs.c+11−4
@@ -28,7 +28,9 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); · 27 unmodified lines
2828 /* Time in microseconds we delay before sleeping in the idle loop */
2929 DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
3030
31−static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
31+static ssize_t store_smt_snooze_delay(struct sys_device *dev,
32+ struct sysdev_attribute *attr,
33+ const char *buf,
3234 size_t count)
3335 {
3436 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -44,7 +46,9 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf, · 9 unmodified lines
4446 return count;
4547 }
4648
47−static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf)
49+static ssize_t show_smt_snooze_delay(struct sys_device *dev,
50+ struct sysdev_attribute *attr,
51+ char *buf)
4852 {
4953 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
5054
@@ -152,14 +156,17 @@ static unsigned long write_##NAME(unsigned long val) \ · 101 unmodified lines
152156 mtspr(ADDRESS, val); \
153157 return 0; \
154158 } \
155−static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
159+static ssize_t show_##NAME(struct sys_device *dev, \
160+ struct sysdev_attribute *attr, \
161+ char *buf) \
156162 { \
157163 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
158164 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
159165 return sprintf(buf, "%lx\n", val); \
160166 } \
161167 static ssize_t __used \
162− store_##NAME(struct sys_device *dev, const char *buf, size_t count) \
168+ store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \
169+ const char *buf, size_t count) \
163170 { \
164171 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
165172 unsigned long val; \
arch/powerpc/platforms/cell/cbe_thermal.c+30−15
@@ -97,7 +97,8 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom · 96 unmodified lines
9797 return value.spe[spu->spe_id];
9898 }
9999
100−static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
100+static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr,
101+ char *buf)
101102 {
102103 u8 value;
103104 struct cbe_pmd_regs __iomem *pmd_regs;
@@ -146,32 +147,38 @@ static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char · 42 unmodified lines
146147 return size;
147148 }
148149
149−static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf)
150+static ssize_t spu_show_throttle_end(struct sys_device *sysdev,
151+ struct sysdev_attribute *attr, char *buf)
150152 {
151153 return show_throttle(get_pmd_regs(sysdev), buf, 0);
152154 }
153155
154−static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf)
156+static ssize_t spu_show_throttle_begin(struct sys_device *sysdev,
157+ struct sysdev_attribute *attr, char *buf)
155158 {
156159 return show_throttle(get_pmd_regs(sysdev), buf, 8);
157160 }
158161
159−static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
162+static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev,
163+ struct sysdev_attribute *attr, char *buf)
160164 {
161165 return show_throttle(get_pmd_regs(sysdev), buf, 16);
162166 }
163167
164−static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
168+static ssize_t spu_store_throttle_end(struct sys_device *sysdev,
169+ struct sysdev_attribute *attr, const char *buf, size_t size)
165170 {
166171 return store_throttle(get_pmd_regs(sysdev), buf, size, 0);
167172 }
168173
169−static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
174+static ssize_t spu_store_throttle_begin(struct sys_device *sysdev,
175+ struct sysdev_attribute *attr, const char *buf, size_t size)
170176 {
171177 return store_throttle(get_pmd_regs(sysdev), buf, size, 8);
172178 }
173179
174−static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
180+static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev,
181+ struct sysdev_attribute *attr, const char *buf, size_t size)
175182 {
176183 return store_throttle(get_pmd_regs(sysdev), buf, size, 16);
177184 }
@@ -192,43 +199,51 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) · 14 unmodified lines
192199
193200 /* shows the temperature of the DTS on the PPE,
194201 * located near the linear thermal sensor */
195−static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf)
202+static ssize_t ppe_show_temp0(struct sys_device *sysdev,
203+ struct sysdev_attribute *attr, char *buf)
196204 {
197205 return ppe_show_temp(sysdev, buf, 32);
198206 }
199207
200208 /* shows the temperature of the second DTS on the PPE */
201−static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf)
209+static ssize_t ppe_show_temp1(struct sys_device *sysdev,
210+ struct sysdev_attribute *attr, char *buf)
202211 {
203212 return ppe_show_temp(sysdev, buf, 0);
204213 }
205214
206−static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf)
215+static ssize_t ppe_show_throttle_end(struct sys_device *sysdev,
216+ struct sysdev_attribute *attr, char *buf)
207217 {
208218 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32);
209219 }
210220
211−static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf)
221+static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev,
222+ struct sysdev_attribute *attr, char *buf)
212223 {
213224 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40);
214225 }
215226
216−static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
227+static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev,
228+ struct sysdev_attribute *attr, char *buf)
217229 {
218230 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48);
219231 }
220232
221−static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
233+static ssize_t ppe_store_throttle_end(struct sys_device *sysdev,
234+ struct sysdev_attribute *attr, const char *buf, size_t size)
222235 {
223236 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32);
224237 }
225238
226−static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
239+static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev,
240+ struct sysdev_attribute *attr, const char *buf, size_t size)
227241 {
228242 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40);
229243 }
230244
231−static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
245+static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev,
246+ struct sysdev_attribute *attr, const char *buf, size_t size)
232247 {
233248 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48);
234249 }
arch/powerpc/platforms/cell/spu_base.c+2−1
@@ -703,7 +703,8 @@ static unsigned long long spu_acct_time(struct spu *spu, · 702 unmodified lines
703703 }
704704
705705
706−static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf)
706+static ssize_t spu_stat_show(struct sys_device *sysdev,
707+ struct sysdev_attribute *attr, char *buf)
707708 {
708709 struct spu *spu = container_of(sysdev, struct spu, sysdev);
709710
arch/powerpc/platforms/chrp/pci.c+1−1
@@ -367,7 +367,7 @@ static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide) · 366 unmodified lines
367367 viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
368368 if (!viaisa)
369369 return;
370− printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
370+ dev_info(&viaide->dev, "Fixing VIA IDE, force legacy mode on\n");
371371
372372 pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
373373 pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
arch/s390/kernel/smp.c+24−12
@@ -864,7 +864,8 @@ int setup_profiling_timer(unsigned int multiplier) · 863 unmodified lines
864864 }
865865
866866 #ifdef CONFIG_HOTPLUG_CPU
867−static ssize_t cpu_configure_show(struct sys_device *dev, char *buf)
867+static ssize_t cpu_configure_show(struct sys_device *dev,
868+ struct sysdev_attribute *attr, char *buf)
868869 {
869870 ssize_t count;
870871
@@ -874,8 +875,9 @@ static ssize_t cpu_configure_show(struct sys_device *dev, char *buf) · 3 unmodified lines
874875 return count;
875876 }
876877
877−static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
878− size_t count)
878+static ssize_t cpu_configure_store(struct sys_device *dev,
879+ struct sysdev_attribute *attr,
880+ const char *buf, size_t count)
879881 {
880882 int cpu = dev->id;
881883 int val, rc;
@@ -922,7 +924,8 @@ out: · 40 unmodified lines
922924 static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
923925 #endif /* CONFIG_HOTPLUG_CPU */
924926
925−static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf)
927+static ssize_t cpu_polarization_show(struct sys_device *dev,
928+ struct sysdev_attribute *attr, char *buf)
926929 {
927930 int cpu = dev->id;
928931 ssize_t count;
@@ -950,7 +953,8 @@ static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf) · 21 unmodified lines
950953 }
951954 static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL);
952955
953−static ssize_t show_cpu_address(struct sys_device *dev, char *buf)
956+static ssize_t show_cpu_address(struct sys_device *dev,
957+ struct sysdev_attribute *attr, char *buf)
954958 {
955959 return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]);
956960 }
@@ -970,7 +974,8 @@ static struct attribute_group cpu_common_attr_group = { · 13 unmodified lines
970974 .attrs = cpu_common_attrs,
971975 };
972976
973−static ssize_t show_capability(struct sys_device *dev, char *buf)
977+static ssize_t show_capability(struct sys_device *dev,
978+ struct sysdev_attribute *attr, char *buf)
974979 {
975980 unsigned int capability;
976981 int rc;
@@ -982,7 +987,8 @@ static ssize_t show_capability(struct sys_device *dev, char *buf) · 5 unmodified lines
982987 }
983988 static SYSDEV_ATTR(capability, 0444, show_capability, NULL);
984989
985−static ssize_t show_idle_count(struct sys_device *dev, char *buf)
990+static ssize_t show_idle_count(struct sys_device *dev,
991+ struct sysdev_attribute *attr, char *buf)
986992 {
987993 struct s390_idle_data *idle;
988994 unsigned long long idle_count;
@@ -995,7 +1001,8 @@ static ssize_t show_idle_count(struct sys_device *dev, char *buf) · 6 unmodified lines
9951001 }
9961002 static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL);
9971003
998−static ssize_t show_idle_time(struct sys_device *dev, char *buf)
1004+static ssize_t show_idle_time(struct sys_device *dev,
1005+ struct sysdev_attribute *attr, char *buf)
9991006 {
10001007 struct s390_idle_data *idle;
10011008 unsigned long long new_time;
@@ -1112,7 +1119,9 @@ out: · 110 unmodified lines
11121119 return rc;
11131120 }
11141121
1115−static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
1122+static ssize_t __ref rescan_store(struct sys_device *dev,
1123+ struct sysdev_attribute *attr,
1124+ const char *buf,
11161125 size_t count)
11171126 {
11181127 int rc;
@@ -1123,7 +1132,9 @@ static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf, · 4 unmodified lines
11231132 static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store);
11241133 #endif /* CONFIG_HOTPLUG_CPU */
11251134
1126−static ssize_t dispatching_show(struct sys_device *dev, char *buf)
1135+static ssize_t dispatching_show(struct sys_device *dev,
1136+ struct sysdev_attribute *attr,
1137+ char *buf)
11271138 {
11281139 ssize_t count;
11291140
@@ -1133,8 +1144,9 @@ static ssize_t dispatching_show(struct sys_device *dev, char *buf) · 3 unmodified lines
11331144 return count;
11341145 }
11351146
1136−static ssize_t dispatching_store(struct sys_device *dev, const char *buf,
1137− size_t count)
1147+static ssize_t dispatching_store(struct sys_device *dev,
1148+ struct sysdev_attribute *attr,
1149+ const char *buf, size_t count)
11381150 {
11391151 int val, rc;
11401152 char delim;
arch/s390/kernel/time.c+24−11
@@ -1100,7 +1100,9 @@ static inline struct etr_aib *etr_aib_from_dev(struct sys_device *dev) · 1099 unmodified lines
11001100 return etr_port1_online ? &etr_port1 : NULL;
11011101 }
11021102
1103−static ssize_t etr_online_show(struct sys_device *dev, char *buf)
1103+static ssize_t etr_online_show(struct sys_device *dev,
1104+ struct sysdev_attribute *attr,
1105+ char *buf)
11041106 {
11051107 unsigned int online;
11061108
@@ -1109,7 +1111,8 @@ static ssize_t etr_online_show(struct sys_device *dev, char *buf) · 2 unmodified lines
11091111 }
11101112
11111113 static ssize_t etr_online_store(struct sys_device *dev,
1112− const char *buf, size_t count)
1114+ struct sysdev_attribute *attr,
1115+ const char *buf, size_t count)
11131116 {
11141117 unsigned int value;
11151118
@@ -1136,7 +1139,9 @@ static ssize_t etr_online_store(struct sys_device *dev, · 20 unmodified lines
11361139
11371140 static SYSDEV_ATTR(online, 0600, etr_online_show, etr_online_store);
11381141
1139−static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf)
1142+static ssize_t etr_stepping_control_show(struct sys_device *dev,
1143+ struct sysdev_attribute *attr,
1144+ char *buf)
11401145 {
11411146 return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ?
11421147 etr_eacr.e0 : etr_eacr.e1);
@@ -1144,7 +1149,8 @@ static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf) · 1 unmodified line
11441149
11451150 static SYSDEV_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL);
11461151
1147−static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf)
1152+static ssize_t etr_mode_code_show(struct sys_device *dev,
1153+ struct sysdev_attribute *attr, char *buf)
11481154 {
11491155 if (!etr_port0_online && !etr_port1_online)
11501156 /* Status word is not uptodate if both ports are offline. */
@@ -1155,7 +1161,8 @@ static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf) · 4 unmodified lines
11551161
11561162 static SYSDEV_ATTR(state_code, 0400, etr_mode_code_show, NULL);
11571163
1158−static ssize_t etr_untuned_show(struct sys_device *dev, char *buf)
1164+static ssize_t etr_untuned_show(struct sys_device *dev,
1165+ struct sysdev_attribute *attr, char *buf)
11591166 {
11601167 struct etr_aib *aib = etr_aib_from_dev(dev);
11611168
@@ -1166,7 +1173,8 @@ static ssize_t etr_untuned_show(struct sys_device *dev, char *buf) · 4 unmodified lines
11661173
11671174 static SYSDEV_ATTR(untuned, 0400, etr_untuned_show, NULL);
11681175
1169−static ssize_t etr_network_id_show(struct sys_device *dev, char *buf)
1176+static ssize_t etr_network_id_show(struct sys_device *dev,
1177+ struct sysdev_attribute *attr, char *buf)
11701178 {
11711179 struct etr_aib *aib = etr_aib_from_dev(dev);
11721180
@@ -1177,7 +1185,8 @@ static ssize_t etr_network_id_show(struct sys_device *dev, char *buf) · 4 unmodified lines
11771185
11781186 static SYSDEV_ATTR(network, 0400, etr_network_id_show, NULL);
11791187
1180−static ssize_t etr_id_show(struct sys_device *dev, char *buf)
1188+static ssize_t etr_id_show(struct sys_device *dev,
1189+ struct sysdev_attribute *attr, char *buf)
11811190 {
11821191 struct etr_aib *aib = etr_aib_from_dev(dev);
11831192
@@ -1188,7 +1197,8 @@ static ssize_t etr_id_show(struct sys_device *dev, char *buf) · 4 unmodified lines
11881197
11891198 static SYSDEV_ATTR(id, 0400, etr_id_show, NULL);
11901199
1191−static ssize_t etr_port_number_show(struct sys_device *dev, char *buf)
1200+static ssize_t etr_port_number_show(struct sys_device *dev,
1201+ struct sysdev_attribute *attr, char *buf)
11921202 {
11931203 struct etr_aib *aib = etr_aib_from_dev(dev);
11941204
@@ -1199,7 +1209,8 @@ static ssize_t etr_port_number_show(struct sys_device *dev, char *buf) · 4 unmodified lines
11991209
12001210 static SYSDEV_ATTR(port, 0400, etr_port_number_show, NULL);
12011211
1202−static ssize_t etr_coupled_show(struct sys_device *dev, char *buf)
1212+static ssize_t etr_coupled_show(struct sys_device *dev,
1213+ struct sysdev_attribute *attr, char *buf)
12031214 {
12041215 struct etr_aib *aib = etr_aib_from_dev(dev);
12051216
@@ -1210,7 +1221,8 @@ static ssize_t etr_coupled_show(struct sys_device *dev, char *buf) · 4 unmodified lines
12101221
12111222 static SYSDEV_ATTR(coupled, 0400, etr_coupled_show, NULL);
12121223
1213−static ssize_t etr_local_time_show(struct sys_device *dev, char *buf)
1224+static ssize_t etr_local_time_show(struct sys_device *dev,
1225+ struct sysdev_attribute *attr, char *buf)
12141226 {
12151227 struct etr_aib *aib = etr_aib_from_dev(dev);
12161228
@@ -1221,7 +1233,8 @@ static ssize_t etr_local_time_show(struct sys_device *dev, char *buf) · 4 unmodified lines
12211233
12221234 static SYSDEV_ATTR(local_time, 0400, etr_local_time_show, NULL);
12231235
1224−static ssize_t etr_utc_offset_show(struct sys_device *dev, char *buf)
1236+static ssize_t etr_utc_offset_show(struct sys_device *dev,
1237+ struct sysdev_attribute *attr, char *buf)
12251238 {
12261239 struct etr_aib *aib = etr_aib_from_dev(dev);
12271240
arch/sh/drivers/dma/dma-sysfs.c+11−4
@@ -23,7 +23,8 @@ static struct sysdev_class dma_sysclass = { · 22 unmodified lines
2323 };
2424 EXPORT_SYMBOL(dma_sysclass);
2525
26−static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
26+static ssize_t dma_show_devices(struct sys_device *dev,
27+ struct sysdev_attribute *attr, char *buf)
2728 {
2829 ssize_t len = 0;
2930 int i;
@@ -57,13 +58,15 @@ static int __init dma_sysclass_init(void) · 27 unmodified lines
5758 }
5859 postcore_initcall(dma_sysclass_init);
5960
60−static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf)
61+static ssize_t dma_show_dev_id(struct sys_device *dev,
62+ struct sysdev_attribute *attr, char *buf)
6163 {
6264 struct dma_channel *channel = to_dma_channel(dev);
6365 return sprintf(buf, "%s\n", channel->dev_id);
6466 }
6567
6668 static ssize_t dma_store_dev_id(struct sys_device *dev,
69+ struct sysdev_attribute *attr,
6770 const char *buf, size_t count)
6871 {
6972 struct dma_channel *channel = to_dma_channel(dev);
@@ -74,6 +77,7 @@ static ssize_t dma_store_dev_id(struct sys_device *dev, · 4 unmodified lines
7477 static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
7578
7679 static ssize_t dma_store_config(struct sys_device *dev,
80+ struct sysdev_attribute *attr,
7781 const char *buf, size_t count)
7882 {
7983 struct dma_channel *channel = to_dma_channel(dev);
@@ -87,13 +91,15 @@ static ssize_t dma_store_config(struct sys_device *dev, · 7 unmodified lines
8791
8892 static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
8993
90−static ssize_t dma_show_mode(struct sys_device *dev, char *buf)
94+static ssize_t dma_show_mode(struct sys_device *dev,
95+ struct sysdev_attribute *attr, char *buf)
9196 {
9297 struct dma_channel *channel = to_dma_channel(dev);
9398 return sprintf(buf, "0x%08x\n", channel->mode);
9499 }
95100
96101 static ssize_t dma_store_mode(struct sys_device *dev,
102+ struct sysdev_attribute *attr,
97103 const char *buf, size_t count)
98104 {
99105 struct dma_channel *channel = to_dma_channel(dev);
@@ -104,7 +110,8 @@ static ssize_t dma_store_mode(struct sys_device *dev, · 4 unmodified lines
104110 static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
105111
106112 #define dma_ro_attr(field, fmt) \
107−static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \
113+static ssize_t dma_show_##field(struct sys_device *dev, \
114+ struct sysdev_attribute *attr, char *buf)\
108115 { \
109116 struct dma_channel *channel = to_dma_channel(dev); \
110117 return sprintf(buf, fmt, channel->field); \
arch/sparc64/kernel/ebus.c+2−2
@@ -401,7 +401,7 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de · 400 unmodified lines
401401 dev->ofdev.node = dp;
402402 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
403403 dev->ofdev.dev.bus = &ebus_bus_type;
404− sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
404+ dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node);
405405
406406 /* Register with core */
407407 if (of_device_register(&dev->ofdev) != 0)
@@ -501,7 +501,7 @@ void __init ebus_init(void) · 93 unmodified lines
501501 ebus->ofdev.node = dp;
502502 ebus->ofdev.dev.parent = &pdev->dev;
503503 ebus->ofdev.dev.bus = &ebus_bus_type;
504− sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
504+ dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus);
505505
506506 /* Register with core */
507507 if (of_device_register(&ebus->ofdev) != 0)
arch/sparc64/kernel/of_device.c+2−2
@@ -797,9 +797,9 @@ static struct of_device * __init scan_one_device(struct device_node *dp, · 796 unmodified lines
797797 op->dev.parent = parent;
798798 op->dev.bus = &of_platform_bus_type;
799799 if (!parent)
800− strcpy(op->dev.bus_id, "root");
800+ dev_set_name(&op->dev, "root");
801801 else
802− sprintf(op->dev.bus_id, "%08x", dp->node);
802+ dev_set_name(&op->dev, "%08x", dp->node);
803803
804804 if (of_device_register(op)) {
805805 printk("%s: Could not register of device.\n",
arch/sparc64/kernel/pci.c+1−1
@@ -408,7 +408,7 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, · 407 unmodified lines
408408 dev->class = class >> 8;
409409 dev->revision = class & 0xff;
410410
411− sprintf(dev->dev.bus_id, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
411+ dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
412412 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
413413
414414 if (ofpci_verbose)
arch/sparc64/kernel/sysfs.c+11−5
@@ -14,7 +14,8 @@ · 13 unmodified lines
1414 static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64)));
1515
1616 #define SHOW_MMUSTAT_ULONG(NAME) \
17−static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
17+static ssize_t show_##NAME(struct sys_device *dev, \
18+ struct sysdev_attribute *attr, char *buf) \
1819 { \
1920 struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \
2021 return sprintf(buf, "%lu\n", p->NAME); \
@@ -135,13 +136,16 @@ static unsigned long write_mmustat_enable(unsigned long val) · 114 unmodified lines
135136 return sun4v_mmustat_conf(ra, &orig_ra);
136137 }
137138
138−static ssize_t show_mmustat_enable(struct sys_device *s, char *buf)
139+static ssize_t show_mmustat_enable(struct sys_device *s,
140+ struct sysdev_attribute *attr, char *buf)
139141 {
140142 unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0);
141143 return sprintf(buf, "%lx\n", val);
142144 }
143145
144−static ssize_t store_mmustat_enable(struct sys_device *s, const char *buf, size_t count)
146+static ssize_t store_mmustat_enable(struct sys_device *s,
147+ struct sysdev_attribute *attr, const char *buf,
148+ size_t count)
145149 {
146150 unsigned long val, err;
147151 int ret = sscanf(buf, "%ld", &val);
@@ -179,14 +183,16 @@ static void unregister_mmu_stats(struct sys_device *s) · 31 unmodified lines
179183 #endif
180184
181185 #define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \
182−static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
186+static ssize_t show_##NAME(struct sys_device *dev, \
187+ struct sysdev_attribute *attr, char *buf) \
183188 { \
184189 cpuinfo_sparc *c = &cpu_data(dev->id); \
185190 return sprintf(buf, "%lu\n", c->MEMBER); \
186191 }
187192
188193 #define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \
189−static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
194+static ssize_t show_##NAME(struct sys_device *dev, \
195+ struct sysdev_attribute *attr, char *buf) \
190196 { \
191197 cpuinfo_sparc *c = &cpu_data(dev->id); \
192198 return sprintf(buf, "%u\n", c->MEMBER); \
arch/sparc64/kernel/vio.c+8−10
@@ -224,7 +224,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 223 unmodified lines
224224 if (!strcmp(type, "domain-services-port"))
225225 bus_id_name = "ds";
226226
227− if (strlen(bus_id_name) >= KOBJ_NAME_LEN - 4) {
227+ if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) {
228228 printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n",
229229 bus_id_name);
230230 return NULL;
@@ -260,16 +260,14 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 29 unmodified lines
260260 vio_fill_channel_info(hp, mp, vdev);
261261
262262 if (!id) {
263− snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s",
264− bus_id_name);
263+ dev_set_name(&vdev->dev, "%s", bus_id_name);
265264 vdev->dev_no = ~(u64)0;
266265 } else if (!cfg_handle) {
267− snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu",
268− bus_id_name, *id);
266+ dev_set_name(&vdev->dev, "%s-%lu", bus_id_name, *id);
269267 vdev->dev_no = *id;
270268 } else {
271− snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu-%lu",
272− bus_id_name, *cfg_handle, *id);
269+ dev_set_name(&vdev->dev, "%s-%lu-%lu", bus_id_name,
270+ *cfg_handle, *id);
273271 vdev->dev_no = *cfg_handle;
274272 }
275273
@@ -292,12 +290,12 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · 16 unmodified lines
292290 }
293291 vdev->dp = dp;
294292
295− printk(KERN_INFO "VIO: Adding device %s\n", vdev->dev.bus_id);
293+ printk(KERN_INFO "VIO: Adding device %s\n", dev_name(&vdev->dev));
296294
297295 err = device_register(&vdev->dev);
298296 if (err) {
299297 printk(KERN_ERR "VIO: Could not register device %s, err=%d\n",
300− vdev->dev.bus_id, err);
298+ dev_name(&vdev->dev), err);
301299 kfree(vdev);
302300 return NULL;
303301 }
@@ -330,7 +328,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node) · 26 unmodified lines
330328 dev = device_find_child(&root_vdev->dev, (void *) node,
331329 vio_md_node_match);
332330 if (dev) {
333− printk(KERN_INFO "VIO: Removing device %s\n", dev->bus_id);
331+ printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev));
334332
335333 device_unregister(dev);
336334 }
arch/x86/kernel/cpu/mcheck/mce_64.c+12−6
@@ -762,10 +762,14 @@ DEFINE_PER_CPU(struct sys_device, device_mce); · 761 unmodified lines
762762
763763 /* Why are there no generic functions for this? */
764764 #define ACCESSOR(name, var, start) \
765− static ssize_t show_ ## name(struct sys_device *s, char *buf) { \
765+ static ssize_t show_ ## name(struct sys_device *s, \
766+ struct sysdev_attribute *attr, \
767+ char *buf) { \
766768 return sprintf(buf, "%lx\n", (unsigned long)var); \
767769 } \
768− static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \
770+ static ssize_t set_ ## name(struct sys_device *s, \
771+ struct sysdev_attribute *attr, \
772+ const char *buf, size_t siz) { \
769773 char *end; \
770774 unsigned long new = simple_strtoul(buf, &end, 0); \
771775 if (end == buf) return -EINVAL; \
@@ -786,14 +790,16 @@ ACCESSOR(bank3ctl,bank[3],mce_restart()) · 14 unmodified lines
786790 ACCESSOR(bank4ctl,bank[4],mce_restart())
787791 ACCESSOR(bank5ctl,bank[5],mce_restart())
788792
789−static ssize_t show_trigger(struct sys_device *s, char *buf)
793+static ssize_t show_trigger(struct sys_device *s, struct sysdev_attribute *attr,
794+ char *buf)
790795 {
791796 strcpy(buf, trigger);
792797 strcat(buf, "\n");
793798 return strlen(trigger) + 1;
794799 }
795800
796−static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
801+static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
802+ const char *buf,size_t siz)
797803 {
798804 char *p;
799805 int len;
@@ -806,12 +812,12 @@ static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz) · 6 unmodified lines
806812 }
807813
808814 static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
809−ACCESSOR(tolerant,tolerant,)
815+static SYSDEV_INT_ATTR(tolerant, 0644, tolerant);
810816 ACCESSOR(check_interval,check_interval,mce_restart())
811817 static struct sysdev_attribute *mce_attributes[] = {
812818 &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
813819 &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl,
814− &attr_tolerant, &attr_check_interval, &attr_trigger,
820+ &attr_tolerant.attr, &attr_check_interval, &attr_trigger,
815821 NULL
816822 };
817823
arch/x86/kernel/cpu/mcheck/therm_throt.c+1−0
@@ -35,6 +35,7 @@ atomic_t therm_throt_en = ATOMIC_INIT(0); · 34 unmodified lines
3535
3636 #define define_therm_throt_sysdev_show_func(name) \
3737 static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \
38+ struct sysdev_attribute *attr, \
3839 char *buf) \
3940 { \
4041 unsigned int cpu = dev->id; \
arch/x86/kernel/cpuid.c+2−2
@@ -141,8 +141,8 @@ static __cpuinit int cpuid_device_create(int cpu) · 140 unmodified lines
141141 {
142142 struct device *dev;
143143
144− dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
145− "cpu%d", cpu);
144+ dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
145+ NULL, "cpu%d", cpu);
146146 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
147147 }
148148
arch/x86/kernel/microcode.c+7−3
@@ -644,7 +644,9 @@ static void microcode_fini_cpu(int cpu) · 643 unmodified lines
644644 mutex_unlock(&microcode_mutex);
645645 }
646646
647−static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
647+static ssize_t reload_store(struct sys_device *dev,
648+ struct sysdev_attribute *attr,
649+ const char *buf, size_t sz)
648650 {
649651 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
650652 char *end;
@@ -674,14 +676,16 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) · 23 unmodified lines
674676 return sz;
675677 }
676678
677−static ssize_t version_show(struct sys_device *dev, char *buf)
679+static ssize_t version_show(struct sys_device *dev,
680+ struct sysdev_attribute *attr, char *buf)
678681 {
679682 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
680683
681684 return sprintf(buf, "0x%x\n", uci->rev);
682685 }
683686
684−static ssize_t pf_show(struct sys_device *dev, char *buf)
687+static ssize_t pf_show(struct sys_device *dev,
688+ struct sysdev_attribute *attr, char *buf)
685689 {
686690 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
687691
arch/x86/kernel/msr.c+2−2
@@ -149,8 +149,8 @@ static int __cpuinit msr_device_create(int cpu) · 148 unmodified lines
149149 {
150150 struct device *dev;
151151
152− dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
153− "msr%d", cpu);
152+ dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
153+ NULL, "msr%d", cpu);
154154 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
155155 }
156156
arch/x86/kernel/pci-dma.c+2−4
@@ -314,8 +314,7 @@ int dma_supported(struct device *dev, u64 mask) · 313 unmodified lines
314314 {
315315 #ifdef CONFIG_PCI
316316 if (mask > 0xffffffff && forbid_dac > 0) {
317− printk(KERN_INFO "PCI: Disallowing DAC for device %s\n",
318− dev->bus_id);
317+ dev_info(dev, "PCI: Disallowing DAC for device\n");
319318 return 0;
320319 }
321320 #endif
@@ -342,8 +341,7 @@ int dma_supported(struct device *dev, u64 mask) · 20 unmodified lines
342341 type. Normally this doesn't make any difference, but gives
343342 more gentle handling of IOMMU overflow. */
344343 if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
345− printk(KERN_INFO "%s: Force SAC with mask %Lx\n",
346− dev->bus_id, mask);
344+ dev_info(dev, "Force SAC with mask %Lx\n", mask);
347345 return 0;
348346 }
349347
arch/x86/kernel/pci-gart_64.c+1−3
@@ -198,9 +198,7 @@ static void iommu_full(struct device *dev, size_t size, int dir) · 197 unmodified lines
198198 * out. Hopefully no network devices use single mappings that big.
199199 */
200200
201− printk(KERN_ERR
202− "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
203− size, dev->bus_id);
201+ dev_err(dev, "PCI-DMA: Out of IOMMU space for %lu bytes\n", size);
204202
205203 if (size > PAGE_SIZE*EMERGENCY_PAGES) {
206204 if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
block/bsg.c+2−1
@@ -1044,7 +1044,8 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, · 1043 unmodified lines
10441044 bcd->release = release;
10451045 kref_init(&bcd->ref);
10461046 dev = MKDEV(bsg_major, bcd->minor);
1047− class_dev = device_create(bsg_class, parent, dev, "%s", devname);
1047+ class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
1048+ "%s", devname);
10481049 if (IS_ERR(class_dev)) {
10491050 ret = PTR_ERR(class_dev);
10501051 goto put_dev;
block/genhd.c+119−86
@@ -183,6 +183,7 @@ static int exact_lock(dev_t devt, void *data) · 182 unmodified lines
183183 void add_disk(struct gendisk *disk)
184184 {
185185 struct backing_dev_info *bdi;
186+ int retval;
186187
187188 disk->flags |= GENHD_FL_UP;
188189 blk_register_region(MKDEV(disk->major, disk->first_minor),
@@ -193,7 +194,8 @@ void add_disk(struct gendisk *disk) · 4 unmodified lines
193194
194195 bdi = &disk->queue->backing_dev_info;
195196 bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
196− sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
197+ retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
198+ WARN_ON(retval);
197199 }
198200
199201 EXPORT_SYMBOL(add_disk);
@@ -225,89 +227,111 @@ struct gendisk *get_gendisk(dev_t devt, int *part) · 25 unmodified lines
225227 }
226228
227229 /*
228− * print a full list of all partitions - intended for places where the root
229− * filesystem can't be mounted and thus to give the victim some idea of what
230− * went wrong
230+ * print a partitions - intended for places where the root filesystem can't be
231+ * mounted and thus to give the victim some idea of what went wrong
231232 */
232−void __init printk_all_partitions(void)
233+static int printk_partition(struct device *dev, void *data)
233234 {
234− struct device *dev;
235235 struct gendisk *sgp;
236236 char buf[BDEVNAME_SIZE];
237237 int n;
238238
239− mutex_lock(&block_class_lock);
240− /* For each block device... */
241− list_for_each_entry(dev, &block_class.devices, node) {
242− if (dev->type != &disk_type)
243− continue;
244− sgp = dev_to_disk(dev);
245− /*
246− * Don't show empty devices or things that have been surpressed
247− */
248− if (get_capacity(sgp) == 0 ||
249− (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
250− continue;
239+ if (dev->type != &disk_type)
240+ goto exit;
251241
252− /*
253− * Note, unlike /proc/partitions, I am showing the numbers in
254− * hex - the same format as the root= option takes.
255− */
256− printk("%02x%02x %10llu %s",
257− sgp->major, sgp->first_minor,
258− (unsigned long long)get_capacity(sgp) >> 1,
259− disk_name(sgp, 0, buf));
260− if (sgp->driverfs_dev != NULL &&
261− sgp->driverfs_dev->driver != NULL)
262− printk(" driver: %s\n",
263− sgp->driverfs_dev->driver->name);
264− else
265− printk(" (driver?)\n");
266−
267− /* now show the partitions */
268− for (n = 0; n < sgp->minors - 1; ++n) {
269− if (sgp->part[n] == NULL)
270− continue;
271− if (sgp->part[n]->nr_sects == 0)
272− continue;
273− printk(" %02x%02x %10llu %s\n",
274− sgp->major, n + 1 + sgp->first_minor,
275− (unsigned long long)sgp->part[n]->nr_sects >> 1,
276− disk_name(sgp, n + 1, buf));
277− }
242+ sgp = dev_to_disk(dev);
243+ /*
244+ * Don't show empty devices or things that have been surpressed
245+ */
246+ if (get_capacity(sgp) == 0 ||
247+ (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
248+ goto exit;
249+
250+ /*
251+ * Note, unlike /proc/partitions, I am showing the numbers in
252+ * hex - the same format as the root= option takes.
253+ */
254+ printk("%02x%02x %10llu %s",
255+ sgp->major, sgp->first_minor,
256+ (unsigned long long)get_capacity(sgp) >> 1,
257+ disk_name(sgp, 0, buf));
258+ if (sgp->driverfs_dev != NULL &&
259+ sgp->driverfs_dev->driver != NULL)
260+ printk(" driver: %s\n",
261+ sgp->driverfs_dev->driver->name);
262+ else
263+ printk(" (driver?)\n");
264+
265+ /* now show the partitions */
266+ for (n = 0; n < sgp->minors - 1; ++n) {
267+ if (sgp->part[n] == NULL)
268+ goto exit;
269+ if (sgp->part[n]->nr_sects == 0)
270+ goto exit;
271+ printk(" %02x%02x %10llu %s\n",
272+ sgp->major, n + 1 + sgp->first_minor,
273+ (unsigned long long)sgp->part[n]->nr_sects >> 1,
274+ disk_name(sgp, n + 1, buf));
278275 }
276+exit:
277+ return 0;
278+}
279279
280+/*
281+ * print a full list of all partitions - intended for places where the root
282+ * filesystem can't be mounted and thus to give the victim some idea of what
283+ * went wrong
284+ */
285+void __init printk_all_partitions(void)
286+{
287+ mutex_lock(&block_class_lock);
288+ class_for_each_device(&block_class, NULL, NULL, printk_partition);
280289 mutex_unlock(&block_class_lock);
281290 }
282291
283292 #ifdef CONFIG_PROC_FS
284293 /* iterator */
294+static int find_start(struct device *dev, void *data)
295+{
296+ loff_t k = *(loff_t *)data;
297+
298+ if (dev->type != &disk_type)
299+ return 0;
300+ if (!k--)
301+ return 1;
302+ return 0;
303+}
304+
285305 static void *part_start(struct seq_file *part, loff_t *pos)
286306 {
287− loff_t k = *pos;
288307 struct device *dev;
308+ loff_t n = *pos;
309+
310+ if (!n)
311+ seq_puts(part, "major minor #blocks name\n\n");
289312
290313 mutex_lock(&block_class_lock);
291− list_for_each_entry(dev, &block_class.devices, node) {
292− if (dev->type != &disk_type)
293− continue;
294− if (!k--)
295− return dev_to_disk(dev);
296− }
314+ dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
315+ if (dev)
316+ return dev_to_disk(dev);
297317 return NULL;
298318 }
299319
320+static int find_next(struct device *dev, void *data)
321+{
322+ if (dev->type == &disk_type)
323+ return 1;
324+ return 0;
325+}
326+
300327 static void *part_next(struct seq_file *part, void *v, loff_t *pos)
301328 {
302329 struct gendisk *gp = v;
303330 struct device *dev;
304331 ++*pos;
305− list_for_each_entry(dev, &gp->dev.node, node) {
306− if (&dev->node == &block_class.devices)
307− return NULL;
308− if (dev->type == &disk_type)
309− return dev_to_disk(dev);
310− }
332+ dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
333+ if (dev)
334+ return dev_to_disk(dev);
311335 return NULL;
312336 }
313337
@@ -322,9 +346,6 @@ static int show_partition(struct seq_file *part, void *v) · 8 unmodified lines
322346 int n;
323347 char buf[BDEVNAME_SIZE];
324348
325− if (&sgp->dev.node == block_class.devices.next)
326− seq_puts(part, "major minor #blocks name\n\n");
327−
328349 /* Don't show non-partitionable removeable devices or empty devices */
329350 if (!get_capacity(sgp) ||
330351 (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
@@ -370,7 +391,10 @@ static struct kobject *base_probe(dev_t devt, int *part, void *data) · 39 unmodified lines
370391
371392 static int __init genhd_device_init(void)
372393 {
373− int error = class_register(&block_class);
394+ int error;
395+
396+ block_class.dev_kobj = sysfs_dev_block_kobj;
397+ error = class_register(&block_class);
374398 if (unlikely(error))
375399 return error;
376400 bdev_map = kobj_map_init(base_probe, &block_class_lock);
@@ -532,6 +556,7 @@ static struct device_type disk_type = { · 155 unmodified lines
532556 .release = disk_release,
533557 };
534558
559+#ifdef CONFIG_PROC_FS
535560 /*
536561 * aggregate disk stat collector. Uses the same stats that the sysfs
537562 * entries do, above, but makes them available through one seq_file.
@@ -542,16 +567,12 @@ static struct device_type disk_type = { · 4 unmodified lines
542567
543568 static void *diskstats_start(struct seq_file *part, loff_t *pos)
544569 {
545− loff_t k = *pos;
546570 struct device *dev;
547571
548572 mutex_lock(&block_class_lock);
549− list_for_each_entry(dev, &block_class.devices, node) {
550− if (dev->type != &disk_type)
551− continue;
552− if (!k--)
553− return dev_to_disk(dev);
554− }
573+ dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
574+ if (dev)
575+ return dev_to_disk(dev);
555576 return NULL;
556577 }
557578
@@ -561,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos) · 3 unmodified lines
561582 struct device *dev;
562583
563584 ++*pos;
564− list_for_each_entry(dev, &gp->dev.node, node) {
565− if (&dev->node == &block_class.devices)
566− return NULL;
567− if (dev->type == &disk_type)
568− return dev_to_disk(dev);
569− }
585+ dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
586+ if (dev)
587+ return dev_to_disk(dev);
570588 return NULL;
571589 }
572590
@@ -641,6 +659,7 @@ const struct seq_operations diskstats_op = { · 68 unmodified lines
641659 .stop = diskstats_stop,
642660 .show = diskstats_show
643661 };
662+#endif /* CONFIG_PROC_FS */
644663
645664 static void media_change_notify_thread(struct work_struct *work)
646665 {
@@ -665,24 +684,38 @@ void genhd_media_change_notify(struct gendisk *disk) · 18 unmodified lines
665684 EXPORT_SYMBOL_GPL(genhd_media_change_notify);
666685 #endif /* 0 */
667686
687+struct find_block {
688+ const char *name;
689+ int part;
690+};
691+
692+static int match_id(struct device *dev, void *data)
693+{
694+ struct find_block *find = data;
695+
696+ if (dev->type != &disk_type)
697+ return 0;
698+ if (strcmp(dev->bus_id, find->name) == 0) {
699+ struct gendisk *disk = dev_to_disk(dev);
700+ if (find->part < disk->minors)
701+ return 1;
702+ }
703+ return 0;
704+}
705+
668706 dev_t blk_lookup_devt(const char *name, int part)
669707 {
670708 struct device *dev;
671709 dev_t devt = MKDEV(0, 0);
710+ struct find_block find;
672711
673712 mutex_lock(&block_class_lock);
674− list_for_each_entry(dev, &block_class.devices, node) {
675− if (dev->type != &disk_type)
676− continue;
677− if (strcmp(dev->bus_id, name) == 0) {
678− struct gendisk *disk = dev_to_disk(dev);
679−
680− if (part < disk->minors)
681− devt = MKDEV(MAJOR(dev->devt),
682− MINOR(dev->devt) + part);
683− break;
684− }
685− }
713+ find.name = name;
714+ find.part = part;
715+ dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
716+ if (dev)
717+ devt = MKDEV(MAJOR(dev->devt),
718+ MINOR(dev->devt) + part);
686719 mutex_unlock(&block_class_lock);
687720
688721 return devt;
drivers/acpi/fan.c+5−5
@@ -263,22 +263,22 @@ static int acpi_fan_add(struct acpi_device *device) · 262 unmodified lines
263263 goto end;
264264 }
265265
266− printk(KERN_INFO PREFIX
267− "%s is registered as cooling_device%d\n",
268− device->dev.bus_id, cdev->id);
266+ dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
269267
270268 acpi_driver_data(device) = cdev;
271269 result = sysfs_create_link(&device->dev.kobj,
272270 &cdev->device.kobj,
273271 "thermal_cooling");
274272 if (result)
275− printk(KERN_ERR PREFIX "Create sysfs link\n");
273+ dev_err(&device->dev, "Failed to create sysfs link "
274+ "'thermal_cooling'\n");
276275
277276 result = sysfs_create_link(&cdev->device.kobj,
278277 &device->dev.kobj,
279278 "device");
280279 if (result)
281− printk(KERN_ERR PREFIX "Create sysfs link\n");
280+ dev_err(&device->dev, "Failed to create sysfs link "
281+ "'device'\n");
282282
283283 result = acpi_fan_add_fs(device);
284284 if (result)
drivers/acpi/glue.c+2−4
@@ -146,8 +146,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) · 145 unmodified lines
146146 acpi_status status;
147147
148148 if (dev->archdata.acpi_handle) {
149− printk(KERN_WARNING PREFIX
150− "Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
149+ dev_warn(dev, "Drivers changed 'acpi_handle'\n");
151150 return -EINVAL;
152151 }
153152 get_device(dev);
@@ -195,8 +194,7 @@ static int acpi_unbind_one(struct device *dev) · 41 unmodified lines
195194 /* acpi_bind_one increase refcnt by one */
196195 put_device(dev);
197196 } else {
198− printk(KERN_ERR PREFIX
199− "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
197+ dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
200198 }
201199 return 0;
202200 }
drivers/acpi/processor_core.c+2−3
@@ -714,9 +714,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) · 713 unmodified lines
714714 goto end;
715715 }
716716
717− printk(KERN_INFO PREFIX
718− "%s is registered as cooling_device%d\n",
719− device->dev.bus_id, pr->cdev->id);
717+ dev_info(&device->dev, "registered as cooling_device%d\n",
718+ pr->cdev->id);
720719
721720 result = sysfs_create_link(&device->dev.kobj,
722721 &pr->cdev->device.kobj,
drivers/acpi/scan.c+1−1
@@ -471,7 +471,7 @@ static int acpi_device_register(struct acpi_device *device, · 470 unmodified lines
471471 device->dev.release = &acpi_device_release;
472472 result = device_add(&device->dev);
473473 if(result) {
474− printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id);
474+ dev_err(&device->dev, "Error adding device\n");
475475 goto end;
476476 }
477477
drivers/acpi/thermal.c+2−2
@@ -1179,8 +1179,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) · 1178 unmodified lines
11791179
11801180 tz->tz_enabled = 1;
11811181
1182− printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n",
1183− tz->device->dev.bus_id, tz->thermal_zone->id);
1182+ dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
1183+ tz->thermal_zone->id);
11841184 return 0;
11851185 }
11861186
drivers/acpi/video.c+2−3
@@ -762,9 +762,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) · 761 unmodified lines
762762 if (IS_ERR(device->cdev))
763763 return;
764764
765− printk(KERN_INFO PREFIX
766− "%s is registered as cooling_device%d\n",
767− device->dev->dev.bus_id, device->cdev->id);
765+ dev_info(&device->dev->dev, "registered as cooling_device%d\n",
766+ device->cdev->id);
768767 result = sysfs_create_link(&device->dev->dev.kobj,
769768 &device->cdev->device.kobj,
770769 "thermal_cooling");
drivers/base/Kconfig+2−1
@@ -27,8 +27,9 @@ config PREVENT_FIRMWARE_BUILD · 26 unmodified lines
2727 If unsure say Y here.
2828
2929 config FW_LOADER
30− tristate "Userspace firmware loading support"
30+ tristate "Userspace firmware loading support" if EMBEDDED
3131 depends on HOTPLUG
32+ default y
3233 ---help---
3334 This option is provided for the case where no in-kernel-tree modules
3435 require userspace firmware loading support, but a module built outside
drivers/base/base.h+27−0
@@ -36,6 +36,33 @@ struct driver_private { · 35 unmodified lines
3636 };
3737 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
3838
39+
40+/**
41+ * struct class_private - structure to hold the private to the driver core portions of the class structure.
42+ *
43+ * @class_subsys - the struct kset that defines this class. This is the main kobject
44+ * @class_devices - list of devices associated with this class
45+ * @class_interfaces - list of class_interfaces associated with this class
46+ * @class_dirs - "glue" directory for virtual devices associated with this class
47+ * @class_mutex - mutex to protect the children, devices, and interfaces lists.
48+ * @class - pointer back to the struct class that this structure is associated
49+ * with.
50+ *
51+ * This structure is the one that is the actual kobject allowing struct
52+ * class to be statically allocated safely. Nothing outside of the driver
53+ * core should ever touch these fields.
54+ */
55+struct class_private {
56+ struct kset class_subsys;
57+ struct list_head class_devices;
58+ struct list_head class_interfaces;
59+ struct kset class_dirs;
60+ struct mutex class_mutex;
61+ struct class *class;
62+};
63+#define to_class(obj) \
64+ container_of(obj, struct class_private, class_subsys.kobj)
65+
3966 /* initialisation functions */
4067 extern int devices_init(void);
4168 extern int buses_init(void);
drivers/base/class.c+89−64
@@ -18,20 +18,20 @@ · 17 unmodified lines
1818 #include <linux/err.h>
1919 #include <linux/slab.h>
2020 #include <linux/genhd.h>
21+#include <linux/mutex.h>
2122 #include "base.h"
2223
2324 #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
24−#define to_class(obj) container_of(obj, struct class, subsys.kobj)
2525
2626 static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
2727 char *buf)
2828 {
2929 struct class_attribute *class_attr = to_class_attr(attr);
30− struct class *dc = to_class(kobj);
30+ struct class_private *cp = to_class(kobj);
3131 ssize_t ret = -EIO;
3232
3333 if (class_attr->show)
34− ret = class_attr->show(dc, buf);
34+ ret = class_attr->show(cp->class, buf);
3535 return ret;
3636 }
3737
@@ -39,17 +39,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr, · 1 unmodified line
3939 const char *buf, size_t count)
4040 {
4141 struct class_attribute *class_attr = to_class_attr(attr);
42− struct class *dc = to_class(kobj);
42+ struct class_private *cp = to_class(kobj);
4343 ssize_t ret = -EIO;
4444
4545 if (class_attr->store)
46− ret = class_attr->store(dc, buf, count);
46+ ret = class_attr->store(cp->class, buf, count);
4747 return ret;
4848 }
4949
5050 static void class_release(struct kobject *kobj)
5151 {
52− struct class *class = to_class(kobj);
52+ struct class_private *cp = to_class(kobj);
53+ struct class *class = cp->class;
5354
5455 pr_debug("class '%s': release.\n", class->name);
5556
@@ -70,7 +71,7 @@ static struct kobj_type class_ktype = { · 14 unmodified lines
7071 .release = class_release,
7172 };
7273
73−/* Hotplug events for classes go to the class_obj subsys */
74+/* Hotplug events for classes go to the class class_subsys */
7475 static struct kset *class_kset;
7576
7677
@@ -78,7 +79,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) · 1 unmodified line
7879 {
7980 int error;
8081 if (cls)
81− error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
82+ error = sysfs_create_file(&cls->p->class_subsys.kobj,
83+ &attr->attr);
8284 else
8385 error = -EINVAL;
8486 return error;
@@ -87,21 +89,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) · 2 unmodified lines
8789 void class_remove_file(struct class *cls, const struct class_attribute *attr)
8890 {
8991 if (cls)
90− sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
92+ sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
9193 }
9294
9395 static struct class *class_get(struct class *cls)
9496 {
9597 if (cls)
96− return container_of(kset_get(&cls->subsys),
97− struct class, subsys);
98− return NULL;
98+ kset_get(&cls->p->class_subsys);
99+ return cls;
99100 }
100101
101102 static void class_put(struct class *cls)
102103 {
103104 if (cls)
104− kset_put(&cls->subsys);
105+ kset_put(&cls->p->class_subsys);
105106 }
106107
107108 static int add_class_attrs(struct class *cls)
@@ -134,42 +135,57 @@ static void remove_class_attrs(struct class *cls) · 26 unmodified lines
134135 }
135136 }
136137
137−int class_register(struct class *cls)
138+int __class_register(struct class *cls, struct lock_class_key *key)
138139 {
140+ struct class_private *cp;
139141 int error;
140142
141143 pr_debug("device class '%s': registering\n", cls->name);
142144
143− INIT_LIST_HEAD(&cls->devices);
144− INIT_LIST_HEAD(&cls->interfaces);
145− kset_init(&cls->class_dirs);
146− init_MUTEX(&cls->sem);
147− error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
148− if (error)
145+ cp = kzalloc(sizeof(*cp), GFP_KERNEL);
146+ if (!cp)
147+ return -ENOMEM;
148+ INIT_LIST_HEAD(&cp->class_devices);
149+ INIT_LIST_HEAD(&cp->class_interfaces);
150+ kset_init(&cp->class_dirs);
151+ __mutex_init(&cp->class_mutex, "struct class mutex", key);
152+ error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
153+ if (error) {
154+ kfree(cp);
149155 return error;
156+ }
157+
158+ /* set the default /sys/dev directory for devices of this class */
159+ if (!cls->dev_kobj)
160+ cls->dev_kobj = sysfs_dev_char_kobj;
150161
151162 #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
152163 /* let the block class directory show up in the root of sysfs */
153164 if (cls != &block_class)
154− cls->subsys.kobj.kset = class_kset;
165+ cp->class_subsys.kobj.kset = class_kset;
155166 #else
156− cls->subsys.kobj.kset = class_kset;
167+ cp->class_subsys.kobj.kset = class_kset;
157168 #endif
158− cls->subsys.kobj.ktype = &class_ktype;
169+ cp->class_subsys.kobj.ktype = &class_ktype;
170+ cp->class = cls;
171+ cls->p = cp;
159172
160− error = kset_register(&cls->subsys);
161− if (!error) {
162− error = add_class_attrs(class_get(cls));
163− class_put(cls);
173+ error = kset_register(&cp->class_subsys);
174+ if (error) {
175+ kfree(cp);
176+ return error;
164177 }
178+ error = add_class_attrs(class_get(cls));
179+ class_put(cls);
165180 return error;
166181 }
182+EXPORT_SYMBOL_GPL(__class_register);
167183
168184 void class_unregister(struct class *cls)
169185 {
170186 pr_debug("device class '%s': unregistering\n", cls->name);
171187 remove_class_attrs(cls);
172− kset_unregister(&cls->subsys);
188+ kset_unregister(&cls->p->class_subsys);
173189 }
174190
175191 static void class_create_release(struct class *cls)
@@ -189,7 +205,8 @@ static void class_create_release(struct class *cls) · 13 unmodified lines
189205 * Note, the pointer created here is to be destroyed when finished by
190206 * making a call to class_destroy().
191207 */
192−struct class *class_create(struct module *owner, const char *name)
208+struct class *__class_create(struct module *owner, const char *name,
209+ struct lock_class_key *key)
193210 {
194211 struct class *cls;
195212 int retval;
@@ -204,7 +221,7 @@ struct class *class_create(struct module *owner, const char *name) · 8 unmodified lines
204221 cls->owner = owner;
205222 cls->class_release = class_create_release;
206223
207− retval = class_register(cls);
224+ retval = __class_register(cls, key);
208225 if (retval)
209226 goto error;
210227
@@ -214,6 +231,7 @@ error: · 3 unmodified lines
214231 kfree(cls);
215232 return ERR_PTR(retval);
216233 }
234+EXPORT_SYMBOL_GPL(__class_create);
217235
218236 /**
219237 * class_destroy - destroys a struct class structure
@@ -252,39 +270,44 @@ char *make_class_name(const char *name, struct kobject *kobj) · 32 unmodified lines
252270 /**
253271 * class_for_each_device - device iterator
254272 * @class: the class we're iterating
273+ * @start: the device to start with in the list, if any.
255274 * @data: data for the callback
256275 * @fn: function to be called for each device
257276 *
258277 * Iterate over @class's list of devices, and call @fn for each,
259− * passing it @data.
278+ * passing it @data. If @start is set, the list iteration will start
279+ * there, otherwise if it is NULL, the iteration starts at the
280+ * beginning of the list.
260281 *
261282 * We check the return of @fn each time. If it returns anything
262283 * other than 0, we break out and return that value.
263284 *
264− * Note, we hold class->sem in this function, so it can not be
285+ * Note, we hold class->class_mutex in this function, so it can not be
265286 * re-acquired in @fn, otherwise it will self-deadlocking. For
266287 * example, calls to add or remove class members would be verboten.
267288 */
268−int class_for_each_device(struct class *class, void *data,
269− int (*fn)(struct device *, void *))
289+int class_for_each_device(struct class *class, struct device *start,
290+ void *data, int (*fn)(struct device *, void *))
270291 {
271292 struct device *dev;
272293 int error = 0;
273294
274295 if (!class)
275296 return -EINVAL;
276− down(&class->sem);
277− list_for_each_entry(dev, &class->devices, node) {
297+ mutex_lock(&class->p->class_mutex);
298+ list_for_each_entry(dev, &class->p->class_devices, node) {
299+ if (start) {
300+ if (start == dev)
301+ start = NULL;
302+ continue;
303+ }
278304 dev = get_device(dev);
279− if (dev) {
280− error = fn(dev, data);
281− put_device(dev);
282− } else
283− error = -ENODEV;
305+ error = fn(dev, data);
306+ put_device(dev);
284307 if (error)
285308 break;
286309 }
287− up(&class->sem);
310+ mutex_unlock(&class->p->class_mutex);
288311
289312 return error;
290313 }
@@ -293,6 +316,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device); · 2 unmodified lines
293316 /**
294317 * class_find_device - device iterator for locating a particular device
295318 * @class: the class we're iterating
319+ * @start: Device to begin with
296320 * @data: data for the match function
297321 * @match: function to check device
298322 *
@@ -306,12 +330,13 @@ EXPORT_SYMBOL_GPL(class_for_each_device); · 7 unmodified lines
306330 *
307331 * Note, you will need to drop the reference with put_device() after use.
308332 *
309− * We hold class->sem in this function, so it can not be
333+ * We hold class->class_mutex in this function, so it can not be
310334 * re-acquired in @match, otherwise it will self-deadlocking. For
311335 * example, calls to add or remove class members would be verboten.
312336 */
313−struct device *class_find_device(struct class *class, void *data,
314− int (*match)(struct device *, void *))
337+struct device *class_find_device(struct class *class, struct device *start,
338+ void *data,
339+ int (*match)(struct device *, void *))
315340 {
316341 struct device *dev;
317342 int found = 0;
@@ -319,19 +344,21 @@ struct device *class_find_device(struct class *class, void *data, · 1 unmodified line
319344 if (!class)
320345 return NULL;
321346
322− down(&class->sem);
323− list_for_each_entry(dev, &class->devices, node) {
347+ mutex_lock(&class->p->class_mutex);
348+ list_for_each_entry(dev, &class->p->class_devices, node) {
349+ if (start) {
350+ if (start == dev)
351+ start = NULL;
352+ continue;
353+ }
324354 dev = get_device(dev);
325− if (dev) {
326− if (match(dev, data)) {
327− found = 1;
328− break;
329− } else
330− put_device(dev);
331− } else
355+ if (match(dev, data)) {
356+ found = 1;
332357 break;
358+ } else
359+ put_device(dev);
333360 }
334− up(&class->sem);
361+ mutex_unlock(&class->p->class_mutex);
335362
336363 return found ? dev : NULL;
337364 }
@@ -349,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf) · 11 unmodified lines
349376 if (!parent)
350377 return -EINVAL;
351378
352− down(&parent->sem);
353− list_add_tail(&class_intf->node, &parent->interfaces);
379+ mutex_lock(&parent->p->class_mutex);
380+ list_add_tail(&class_intf->node, &parent->p->class_interfaces);
354381 if (class_intf->add_dev) {
355− list_for_each_entry(dev, &parent->devices, node)
382+ list_for_each_entry(dev, &parent->p->class_devices, node)
356383 class_intf->add_dev(dev, class_intf);
357384 }
358− up(&parent->sem);
385+ mutex_unlock(&parent->p->class_mutex);
359386
360387 return 0;
361388 }
@@ -368,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf) · 6 unmodified lines
368395 if (!parent)
369396 return;
370397
371− down(&parent->sem);
398+ mutex_lock(&parent->p->class_mutex);
372399 list_del_init(&class_intf->node);
373400 if (class_intf->remove_dev) {
374− list_for_each_entry(dev, &parent->devices, node)
401+ list_for_each_entry(dev, &parent->p->class_devices, node)
375402 class_intf->remove_dev(dev, class_intf);
376403 }
377− up(&parent->sem);
404+ mutex_unlock(&parent->p->class_mutex);
378405
379406 class_put(parent);
380407 }
@@ -389,9 +416,7 @@ int __init classes_init(void) · 8 unmodified lines
389416
390417 EXPORT_SYMBOL_GPL(class_create_file);
391418 EXPORT_SYMBOL_GPL(class_remove_file);
392−EXPORT_SYMBOL_GPL(class_register);
393419 EXPORT_SYMBOL_GPL(class_unregister);
394−EXPORT_SYMBOL_GPL(class_create);
395420 EXPORT_SYMBOL_GPL(class_destroy);
396421
397422 EXPORT_SYMBOL_GPL(class_interface_register);
drivers/base/core.c+124−72
@@ -21,12 +21,16 @@ · 20 unmodified lines
2121 #include <linux/genhd.h>
2222 #include <linux/kallsyms.h>
2323 #include <linux/semaphore.h>
24+#include <linux/mutex.h>
2425
2526 #include "base.h"
2627 #include "power/power.h"
2728
2829 int (*platform_notify)(struct device *dev) = NULL;
2930 int (*platform_notify_remove)(struct device *dev) = NULL;
31+static struct kobject *dev_kobj;
32+struct kobject *sysfs_dev_char_kobj;
33+struct kobject *sysfs_dev_block_kobj;
3034
3135 #ifdef CONFIG_BLOCK
3236 static inline int device_is_not_partition(struct device *dev)
@@ -548,7 +552,7 @@ static struct kobject *get_device_parent(struct device *dev, · 515 unmodified lines
548552 {
549553 /* class devices without a parent live in /sys/class/<classname>/ */
550554 if (dev->class && (!parent || parent->class != dev->class))
551− return &dev->class->subsys.kobj;
555+ return &dev->class->p->class_subsys.kobj;
552556 /* all other devices keep their parent */
553557 else if (parent)
554558 return &parent->kobj;
@@ -594,13 +598,13 @@ static struct kobject *get_device_parent(struct device *dev, · 39 unmodified lines
594598 parent_kobj = &parent->kobj;
595599
596600 /* find our class-directory at the parent and reference it */
597− spin_lock(&dev->class->class_dirs.list_lock);
598− list_for_each_entry(k, &dev->class->class_dirs.list, entry)
601+ spin_lock(&dev->class->p->class_dirs.list_lock);
602+ list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
599603 if (k->parent == parent_kobj) {
600604 kobj = kobject_get(k);
601605 break;
602606 }
603− spin_unlock(&dev->class->class_dirs.list_lock);
607+ spin_unlock(&dev->class->p->class_dirs.list_lock);
604608 if (kobj)
605609 return kobj;
606610
@@ -608,7 +612,7 @@ static struct kobject *get_device_parent(struct device *dev, · 1 unmodified line
608612 k = kobject_create();
609613 if (!k)
610614 return NULL;
611− k->kset = &dev->class->class_dirs;
615+ k->kset = &dev->class->p->class_dirs;
612616 retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
613617 if (retval < 0) {
614618 kobject_put(k);
@@ -627,7 +631,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) · 12 unmodified lines
627631 {
628632 /* see if we live in a "glue" directory */
629633 if (!glue_dir || !dev->class ||
630− glue_dir->kset != &dev->class->class_dirs)
634+ glue_dir->kset != &dev->class->p->class_dirs)
631635 return;
632636
633637 kobject_put(glue_dir);
@@ -654,17 +658,18 @@ static int device_add_class_symlinks(struct device *dev) · 20 unmodified lines
654658 if (!dev->class)
655659 return 0;
656660
657− error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
661+ error = sysfs_create_link(&dev->kobj,
662+ &dev->class->p->class_subsys.kobj,
658663 "subsystem");
659664 if (error)
660665 goto out;
661666
662667 #ifdef CONFIG_SYSFS_DEPRECATED
663668 /* stacked class devices need a symlink in the class directory */
664− if (dev->kobj.parent != &dev->class->subsys.kobj &&
669+ if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
665670 device_is_not_partition(dev)) {
666− error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
667− dev->bus_id);
671+ error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
672+ &dev->kobj, dev->bus_id);
668673 if (error)
669674 goto out_subsys;
670675 }
@@ -701,13 +706,14 @@ out_device: · 30 unmodified lines
701706 if (dev->parent && device_is_not_partition(dev))
702707 sysfs_remove_link(&dev->kobj, "device");
703708 out_busid:
704− if (dev->kobj.parent != &dev->class->subsys.kobj &&
709+ if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
705710 device_is_not_partition(dev))
706− sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
711+ sysfs_remove_link(&dev->class->p->class_subsys.kobj,
712+ dev->bus_id);
707713 #else
708714 /* link in the class directory pointing to the device */
709− error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
710− dev->bus_id);
715+ error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
716+ &dev->kobj, dev->bus_id);
711717 if (error)
712718 goto out_subsys;
713719
@@ -720,7 +726,7 @@ out_busid: · 6 unmodified lines
720726 return 0;
721727
722728 out_busid:
723− sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
729+ sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
724730 #endif
725731
726732 out_subsys:
@@ -746,14 +752,15 @@ static void device_remove_class_symlinks(struct device *dev) · 19 unmodified lines
746752 sysfs_remove_link(&dev->kobj, "device");
747753 }
748754
749− if (dev->kobj.parent != &dev->class->subsys.kobj &&
755+ if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
750756 device_is_not_partition(dev))
751− sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
757+ sysfs_remove_link(&dev->class->p->class_subsys.kobj,
758+ dev->bus_id);
752759 #else
753760 if (dev->parent && device_is_not_partition(dev))
754761 sysfs_remove_link(&dev->kobj, "device");
755762
756− sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
763+ sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
757764 #endif
758765
759766 sysfs_remove_link(&dev->kobj, "subsystem");
@@ -775,6 +782,54 @@ int dev_set_name(struct device *dev, const char *fmt, ...) · 15 unmodified lines
775782 }
776783 EXPORT_SYMBOL_GPL(dev_set_name);
777784
785+/**
786+ * device_to_dev_kobj - select a /sys/dev/ directory for the device
787+ * @dev: device
788+ *
789+ * By default we select char/ for new entries. Setting class->dev_obj
790+ * to NULL prevents an entry from being created. class->dev_kobj must
791+ * be set (or cleared) before any devices are registered to the class
792+ * otherwise device_create_sys_dev_entry() and
793+ * device_remove_sys_dev_entry() will disagree about the the presence
794+ * of the link.
795+ */
796+static struct kobject *device_to_dev_kobj(struct device *dev)
797+{
798+ struct kobject *kobj;
799+
800+ if (dev->class)
801+ kobj = dev->class->dev_kobj;
802+ else
803+ kobj = sysfs_dev_char_kobj;
804+
805+ return kobj;
806+}
807+
808+static int device_create_sys_dev_entry(struct device *dev)
809+{
810+ struct kobject *kobj = device_to_dev_kobj(dev);
811+ int error = 0;
812+ char devt_str[15];
813+
814+ if (kobj) {
815+ format_dev_t(devt_str, dev->devt);
816+ error = sysfs_create_link(kobj, &dev->kobj, devt_str);
817+ }
818+
819+ return error;
820+}
821+
822+static void device_remove_sys_dev_entry(struct device *dev)
823+{
824+ struct kobject *kobj = device_to_dev_kobj(dev);
825+ char devt_str[15];
826+
827+ if (kobj) {
828+ format_dev_t(devt_str, dev->devt);
829+ sysfs_remove_link(kobj, devt_str);
830+ }
831+}
832+
778833 /**
779834 * device_add - add device to device hierarchy.
780835 * @dev: device.
@@ -829,6 +884,10 @@ int device_add(struct device *dev) · 48 unmodified lines
829884 error = device_create_file(dev, &devt_attr);
830885 if (error)
831886 goto ueventattrError;
887+
888+ error = device_create_sys_dev_entry(dev);
889+ if (error)
890+ goto devtattrError;
832891 }
833892
834893 error = device_add_class_symlinks(dev);
@@ -849,15 +908,16 @@ int device_add(struct device *dev) · 14 unmodified lines
849908 klist_add_tail(&dev->knode_parent, &parent->klist_children);
850909
851910 if (dev->class) {
852− down(&dev->class->sem);
911+ mutex_lock(&dev->class->p->class_mutex);
853912 /* tie the class to the device */
854− list_add_tail(&dev->node, &dev->class->devices);
913+ list_add_tail(&dev->node, &dev->class->p->class_devices);
855914
856915 /* notify any interfaces that the device is here */
857− list_for_each_entry(class_intf, &dev->class->interfaces, node)
916+ list_for_each_entry(class_intf,
917+ &dev->class->p->class_interfaces, node)
858918 if (class_intf->add_dev)
859919 class_intf->add_dev(dev, class_intf);
860− up(&dev->class->sem);
920+ mutex_unlock(&dev->class->p->class_mutex);
861921 }
862922 Done:
863923 put_device(dev);
@@ -872,6 +932,9 @@ int device_add(struct device *dev) · 8 unmodified lines
872932 AttrsError:
873933 device_remove_class_symlinks(dev);
874934 SymlinkError:
935+ if (MAJOR(dev->devt))
936+ device_remove_sys_dev_entry(dev);
937+ devtattrError:
875938 if (MAJOR(dev->devt))
876939 device_remove_file(dev, &devt_attr);
877940 ueventattrError:
@@ -948,19 +1011,22 @@ void device_del(struct device *dev) · 70 unmodified lines
9481011 device_pm_remove(dev);
9491012 if (parent)
9501013 klist_del(&dev->knode_parent);
951− if (MAJOR(dev->devt))
1014+ if (MAJOR(dev->devt)) {
1015+ device_remove_sys_dev_entry(dev);
9521016 device_remove_file(dev, &devt_attr);
1017+ }
9531018 if (dev->class) {
9541019 device_remove_class_symlinks(dev);
9551020
956− down(&dev->class->sem);
1021+ mutex_lock(&dev->class->p->class_mutex);
9571022 /* notify any interfaces that the device is now gone */
958− list_for_each_entry(class_intf, &dev->class->interfaces, node)
1023+ list_for_each_entry(class_intf,
1024+ &dev->class->p->class_interfaces, node)
9591025 if (class_intf->remove_dev)
9601026 class_intf->remove_dev(dev, class_intf);
9611027 /* remove the device from the class list */
9621028 list_del_init(&dev->node);
963− up(&dev->class->sem);
1029+ mutex_unlock(&dev->class->p->class_mutex);
9641030 }
9651031 device_remove_file(dev, &uevent_attr);
9661032 device_remove_attrs(dev);
@@ -1074,7 +1140,25 @@ int __init devices_init(void) · 107 unmodified lines
10741140 devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
10751141 if (!devices_kset)
10761142 return -ENOMEM;
1143+ dev_kobj = kobject_create_and_add("dev", NULL);
1144+ if (!dev_kobj)
1145+ goto dev_kobj_err;
1146+ sysfs_dev_block_kobj = kobject_create_and_add("block", dev_kobj);
1147+ if (!sysfs_dev_block_kobj)
1148+ goto block_kobj_err;
1149+ sysfs_dev_char_kobj = kobject_create_and_add("char", dev_kobj);
1150+ if (!sysfs_dev_char_kobj)
1151+ goto char_kobj_err;
1152+
10771153 return 0;
1154+
1155+ char_kobj_err:
1156+ kobject_put(sysfs_dev_block_kobj);
1157+ block_kobj_err:
1158+ kobject_put(dev_kobj);
1159+ dev_kobj_err:
1160+ kset_unregister(devices_kset);
1161+ return -ENOMEM;
10781162 }
10791163
10801164 EXPORT_SYMBOL_GPL(device_for_each_child);
@@ -1157,49 +1241,12 @@ error: · 76 unmodified lines
11571241 }
11581242 EXPORT_SYMBOL_GPL(device_create_vargs);
11591243
1160−/**
1161− * device_create_drvdata - creates a device and registers it with sysfs
1162− * @class: pointer to the struct class that this device should be registered to
1163− * @parent: pointer to the parent struct device of this new device, if any
1164− * @devt: the dev_t for the char device to be added
1165− * @drvdata: the data to be added to the device for callbacks
1166− * @fmt: string for the device's name
1167− *
1168− * This function can be used by char device classes. A struct device
1169− * will be created in sysfs, registered to the specified class.
1170− *
1171− * A "dev" file will be created, showing the dev_t for the device, if
1172− * the dev_t is not 0,0.
1173− * If a pointer to a parent struct device is passed in, the newly created
1174− * struct device will be a child of that device in sysfs.
1175− * The pointer to the struct device will be returned from the call.
1176− * Any further sysfs files that might be required can be created using this
1177− * pointer.
1178− *
1179− * Note: the struct class passed to this function must have previously
1180− * been created with a call to class_create().
1181− */
1182−struct device *device_create_drvdata(struct class *class,
1183− struct device *parent,
1184− dev_t devt,
1185− void *drvdata,
1186− const char *fmt, ...)
1187−{
1188− va_list vargs;
1189− struct device *dev;
1190−
1191− va_start(vargs, fmt);
1192− dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
1193− va_end(vargs);
1194− return dev;
1195−}
1196−EXPORT_SYMBOL_GPL(device_create_drvdata);
1197−
11981244 /**
11991245 * device_create - creates a device and registers it with sysfs
12001246 * @class: pointer to the struct class that this device should be registered to
12011247 * @parent: pointer to the parent struct device of this new device, if any
12021248 * @devt: the dev_t for the char device to be added
1249+ * @drvdata: the data to be added to the device for callbacks
12031250 * @fmt: string for the device's name
12041251 *
12051252 * This function can be used by char device classes. A struct device
@@ -1217,13 +1264,13 @@ EXPORT_SYMBOL_GPL(device_create_drvdata); · 11 unmodified lines
12171264 * been created with a call to class_create().
12181265 */
12191266 struct device *device_create(struct class *class, struct device *parent,
1220− dev_t devt, const char *fmt, ...)
1267+ dev_t devt, void *drvdata, const char *fmt, ...)
12211268 {
12221269 va_list vargs;
12231270 struct device *dev;
12241271
12251272 va_start(vargs, fmt);
1226− dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs);
1273+ dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
12271274 va_end(vargs);
12281275 return dev;
12291276 }
@@ -1248,7 +1295,7 @@ void device_destroy(struct class *class, dev_t devt) · 18 unmodified lines
12481295 {
12491296 struct device *dev;
12501297
1251− dev = class_find_device(class, &devt, __match_devt);
1298+ dev = class_find_device(class, NULL, &devt, __match_devt);
12521299 if (dev) {
12531300 put_device(dev);
12541301 device_unregister(dev);
@@ -1298,8 +1345,9 @@ int device_rename(struct device *dev, char *new_name) · 43 unmodified lines
12981345 if (old_class_name) {
12991346 new_class_name = make_class_name(dev->class->name, &dev->kobj);
13001347 if (new_class_name) {
1301− error = sysfs_create_link(&dev->parent->kobj,
1302− &dev->kobj, new_class_name);
1348+ error = sysfs_create_link_nowarn(&dev->parent->kobj,
1349+ &dev->kobj,
1350+ new_class_name);
13031351 if (error)
13041352 goto out;
13051353 sysfs_remove_link(&dev->parent->kobj, old_class_name);
@@ -1307,11 +1355,12 @@ int device_rename(struct device *dev, char *new_name) · 1 unmodified line
13071355 }
13081356 #else
13091357 if (dev->class) {
1310− error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
1311− dev->bus_id);
1358+ error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
1359+ &dev->kobj, dev->bus_id);
13121360 if (error)
13131361 goto out;
1314− sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
1362+ sysfs_remove_link(&dev->class->p->class_subsys.kobj,
1363+ old_device_name);
13151364 }
13161365 #endif
13171366
@@ -1447,4 +1496,7 @@ void device_shutdown(void) · 129 unmodified lines
14471496 dev->driver->shutdown(dev);
14481497 }
14491498 }
1499+ kobject_put(sysfs_dev_char_kobj);
1500+ kobject_put(sysfs_dev_block_kobj);
1501+ kobject_put(dev_kobj);
14501502 }
drivers/base/cpu.c+6−4
@@ -21,15 +21,16 @@ EXPORT_SYMBOL(cpu_sysdev_class); · 20 unmodified lines
2121 static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices);
2222
2323 #ifdef CONFIG_HOTPLUG_CPU
24−static ssize_t show_online(struct sys_device *dev, char *buf)
24+static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr,
25+ char *buf)
2526 {
2627 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
2728
2829 return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
2930 }
3031
31−static ssize_t __ref store_online(struct sys_device *dev, const char *buf,
32− size_t count)
32+static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr,
33+ const char *buf, size_t count)
3334 {
3435 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
3536 ssize_t ret;
@@ -80,7 +81,8 @@ static inline void register_cpu_control(struct cpu *cpu) · 44 unmodified lines
8081 #ifdef CONFIG_KEXEC
8182 #include <linux/kexec.h>
8283
83−static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
84+static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr,
85+ char *buf)
8486 {
8587 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
8688 ssize_t rc;
drivers/base/memory.c+8−4
@@ -92,7 +92,8 @@ unregister_memory(struct memory_block *memory, struct mem_section *section) · 91 unmodified lines
9292 * uses.
9393 */
9494
95−static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
95+static ssize_t show_mem_phys_index(struct sys_device *dev,
96+ struct sysdev_attribute *attr, char *buf)
9697 {
9798 struct memory_block *mem =
9899 container_of(dev, struct memory_block, sysdev);
@@ -102,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) · 3 unmodified lines
102103 /*
103104 * online, offline, going offline, etc.
104105 */
105−static ssize_t show_mem_state(struct sys_device *dev, char *buf)
106+static ssize_t show_mem_state(struct sys_device *dev,
107+ struct sysdev_attribute *attr, char *buf)
106108 {
107109 struct memory_block *mem =
108110 container_of(dev, struct memory_block, sysdev);
@@ -217,7 +219,8 @@ out: · 108 unmodified lines
217219 }
218220
219221 static ssize_t
220−store_mem_state(struct sys_device *dev, const char *buf, size_t count)
222+store_mem_state(struct sys_device *dev,
223+ struct sysdev_attribute *attr, const char *buf, size_t count)
221224 {
222225 struct memory_block *mem;
223226 unsigned int phys_section_nr;
@@ -248,7 +251,8 @@ out: · 24 unmodified lines
248251 * s.t. if I offline all of these sections I can then
249252 * remove the physical device?
250253 */
251−static ssize_t show_phys_device(struct sys_device *dev, char *buf)
254+static ssize_t show_phys_device(struct sys_device *dev,
255+ struct sysdev_attribute *attr, char *buf)
252256 {
253257 struct memory_block *mem =
254258 container_of(dev, struct memory_block, sysdev);
drivers/base/node.c+10−5
@@ -36,11 +36,13 @@ static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) · 35 unmodified lines
3636 return len;
3737 }
3838
39−static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
39+static inline ssize_t node_read_cpumask(struct sys_device *dev,
40+ struct sysdev_attribute *attr, char *buf)
4041 {
4142 return node_read_cpumap(dev, 0, buf);
4243 }
43−static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
44+static inline ssize_t node_read_cpulist(struct sys_device *dev,
45+ struct sysdev_attribute *attr, char *buf)
4446 {
4547 return node_read_cpumap(dev, 1, buf);
4648 }
@@ -49,7 +51,8 @@ static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); · 2 unmodified lines
4951 static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
5052
5153 #define K(x) ((x) << (PAGE_SHIFT - 10))
52−static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
54+static ssize_t node_read_meminfo(struct sys_device * dev,
55+ struct sysdev_attribute *attr, char * buf)
5356 {
5457 int n;
5558 int nid = dev->id;
@@ -112,7 +115,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) · 56 unmodified lines
112115 #undef K
113116 static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
114117
115−static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
118+static ssize_t node_read_numastat(struct sys_device * dev,
119+ struct sysdev_attribute *attr, char * buf)
116120 {
117121 return sprintf(buf,
118122 "numa_hit %lu\n"
@@ -130,7 +134,8 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf) · 11 unmodified lines
130134 }
131135 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
132136
133−static ssize_t node_read_distance(struct sys_device * dev, char * buf)
137+static ssize_t node_read_distance(struct sys_device * dev,
138+ struct sysdev_attribute *attr, char * buf)
134139 {
135140 int nid = dev->id;
136141 int len = 0;
drivers/base/power/trace.c+1−1
@@ -194,7 +194,7 @@ static int show_dev_hash(unsigned int value) · 193 unmodified lines
194194 struct device * dev = to_device(entry);
195195 unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH);
196196 if (hash == value) {
197− printk(" hash matches device %s\n", dev->bus_id);
197+ dev_info(dev, "hash matches\n");
198198 match++;
199199 }
200200 entry = entry->prev;
drivers/base/sys.c+59−5
@@ -36,7 +36,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer) · 35 unmodified lines
3636 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
3737
3838 if (sysdev_attr->show)
39− return sysdev_attr->show(sysdev, buffer);
39+ return sysdev_attr->show(sysdev, sysdev_attr, buffer);
4040 return -EIO;
4141 }
4242
@@ -49,7 +49,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr, · 6 unmodified lines
4949 struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
5050
5151 if (sysdev_attr->store)
52− return sysdev_attr->store(sysdev, buffer, count);
52+ return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
5353 return -EIO;
5454 }
5555
@@ -130,8 +130,8 @@ static struct kset *system_kset; · 74 unmodified lines
130130
131131 int sysdev_class_register(struct sysdev_class * cls)
132132 {
133− pr_debug("Registering sysdev class '%s'\n",
134− kobject_name(&cls->kset.kobj));
133+ pr_debug("Registering sysdev class '%s'\n", cls->name);
134+
135135 INIT_LIST_HEAD(&cls->drivers);
136136 memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
137137 cls->kset.kobj.parent = &system_kset->kobj;
@@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev) · 103 unmodified lines
241241 if (!cls)
242242 return -EINVAL;
243243
244− pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
244+ pr_debug("Registering sys device of class '%s'\n",
245+ kobject_name(&cls->kset.kobj));
245246
246247 /* initialize the kobject to 0, in case it had previously been used */
247248 memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
@@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev) · 9 unmodified lines
257258 if (!error) {
258259 struct sysdev_driver * drv;
259260
261+ pr_debug("Registering sys device '%s'\n",
262+ kobject_name(&sysdev->kobj));
263+
260264 mutex_lock(&sysdev_drivers_lock);
261265 /* Generic notification is implicit, because it's that
262266 * code that should have called us.
@@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev) · 6 unmodified lines
269273 }
270274 mutex_unlock(&sysdev_drivers_lock);
271275 }
276+
272277 kobject_uevent(&sysdev->kobj, KOBJ_ADD);
273278 return error;
274279 }
@@ -474,3 +479,52 @@ int __init system_bus_init(void) · 199 unmodified lines
474479
475480 EXPORT_SYMBOL_GPL(sysdev_register);
476481 EXPORT_SYMBOL_GPL(sysdev_unregister);
482+
483+#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
484+
485+ssize_t sysdev_store_ulong(struct sys_device *sysdev,
486+ struct sysdev_attribute *attr,
487+ const char *buf, size_t size)
488+{
489+ struct sysdev_ext_attribute *ea = to_ext_attr(attr);
490+ char *end;
491+ unsigned long new = simple_strtoul(buf, &end, 0);
492+ if (end == buf)
493+ return -EINVAL;
494+ *(unsigned long *)(ea->var) = new;
495+ return end - buf;
496+}
497+EXPORT_SYMBOL_GPL(sysdev_store_ulong);
498+
499+ssize_t sysdev_show_ulong(struct sys_device *sysdev,
500+ struct sysdev_attribute *attr,
501+ char *buf)
502+{
503+ struct sysdev_ext_attribute *ea = to_ext_attr(attr);
504+ return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
505+}
506+EXPORT_SYMBOL_GPL(sysdev_show_ulong);
507+
508+ssize_t sysdev_store_int(struct sys_device *sysdev,
509+ struct sysdev_attribute *attr,
510+ const char *buf, size_t size)
511+{
512+ struct sysdev_ext_attribute *ea = to_ext_attr(attr);
513+ char *end;
514+ long new = simple_strtol(buf, &end, 0);
515+ if (end == buf || new > INT_MAX || new < INT_MIN)
516+ return -EINVAL;
517+ *(int *)(ea->var) = new;
518+ return end - buf;
519+}
520+EXPORT_SYMBOL_GPL(sysdev_store_int);
521+
522+ssize_t sysdev_show_int(struct sys_device *sysdev,
523+ struct sysdev_attribute *attr,
524+ char *buf)
525+{
526+ struct sysdev_ext_attribute *ea = to_ext_attr(attr);
527+ return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
528+}
529+EXPORT_SYMBOL_GPL(sysdev_show_int);
530+
drivers/base/topology.c+12−5
@@ -34,7 +34,8 @@ · 33 unmodified lines
3434 static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
3535
3636 #define define_id_show_func(name) \
37−static ssize_t show_##name(struct sys_device *dev, char *buf) \
37+static ssize_t show_##name(struct sys_device *dev, \
38+ struct sysdev_attribute *attr, char *buf) \
3839 { \
3940 unsigned int cpu = dev->id; \
4041 return sprintf(buf, "%d\n", topology_##name(cpu)); \
@@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf) · 18 unmodified lines
5960
6061 #ifdef arch_provides_topology_pointers
6162 #define define_siblings_show_map(name) \
62−static ssize_t show_##name(struct sys_device *dev, char *buf) \
63+static ssize_t show_##name(struct sys_device *dev, \
64+ struct sysdev_attribute *attr, char *buf) \
6365 { \
6466 unsigned int cpu = dev->id; \
6567 return show_cpumap(0, &(topology_##name(cpu)), buf); \
6668 }
6769
6870 #define define_siblings_show_list(name) \
69−static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
71+static ssize_t show_##name##_list(struct sys_device *dev, \
72+ struct sysdev_attribute *attr, \
73+ char *buf) \
7074 { \
7175 unsigned int cpu = dev->id; \
7276 return show_cpumap(1, &(topology_##name(cpu)), buf); \
@@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ · 1 unmodified line
7478
7579 #else
7680 #define define_siblings_show_map(name) \
77−static ssize_t show_##name(struct sys_device *dev, char *buf) \
81+static ssize_t show_##name(struct sys_device *dev, \
82+ struct sysdev_attribute *attr, char *buf) \
7883 { \
7984 unsigned int cpu = dev->id; \
8085 cpumask_t mask = topology_##name(cpu); \
@@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \ · 1 unmodified line
8287 }
8388
8489 #define define_siblings_show_list(name) \
85−static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
90+static ssize_t show_##name##_list(struct sys_device *dev, \
91+ struct sysdev_attribute *attr, \
92+ char *buf) \
8693 { \
8794 unsigned int cpu = dev->id; \
8895 cpumask_t mask = topology_##name(cpu); \
drivers/block/aoe/aoechr.c+3−2
@@ -277,8 +277,9 @@ aoechr_init(void) · 276 unmodified lines
277277 return PTR_ERR(aoe_class);
278278 }
279279 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
280− device_create(aoe_class, NULL,
281− MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name);
280+ device_create_drvdata(aoe_class, NULL,
281+ MKDEV(AOE_MAJOR, chardevs[i].minor),
282+ NULL, chardevs[i].name);
282283
283284 return 0;
284285 }
drivers/block/paride/pg.c+3−2
@@ -686,8 +686,9 @@ 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(pg_class, NULL, MKDEV(major, unit),
690− "pg%u", unit);
689+ device_create_drvdata(pg_class, NULL,
690+ MKDEV(major, unit), NULL,
691+ "pg%u", unit);
691692 }
692693 err = 0;
693694 goto out;
drivers/block/paride/pt.c+6−4
@@ -979,10 +979,12 @@ 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(pt_class, NULL, MKDEV(major, unit),
983− "pt%d", unit);
984− device_create(pt_class, NULL, MKDEV(major, unit + 128),
985− "pt%dn", unit);
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);
986988 }
987989 goto out;
988990
drivers/block/pktcdvd.c+3−1
@@ -303,7 +303,9 @@ static struct kobj_type kobj_pkt_type_wqueue = { · 302 unmodified lines
303303 static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
304304 {
305305 if (class_pktcdvd) {
306− pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name);
306+ pd->dev = device_create_drvdata(class_pktcdvd, NULL,
307+ pd->pkt_dev, NULL,
308+ "%s", pd->name);
307309 if (IS_ERR(pd->dev))
308310 pd->dev = NULL;
309311 }
drivers/char/dsp56k.c+2−1
@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void) · 499 unmodified lines
500500 err = PTR_ERR(dsp56k_class);
501501 goto out_chrdev;
502502 }
503− device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
503+ device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
504+ NULL, "dsp56k");
504505
505506 printk(banner);
506507 goto out;
drivers/char/ip2/ip2main.c+6−6
@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp) · 717 unmodified lines
718718 }
719719
720720 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
721− device_create(ip2_class, NULL,
722− MKDEV(IP2_IPL_MAJOR, 4 * i),
723− "ipl%d", i);
724− device_create(ip2_class, NULL,
725− MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
726− "stat%d", i);
721+ device_create_drvdata(ip2_class, NULL,
722+ MKDEV(IP2_IPL_MAJOR, 4 * i),
723+ NULL, "ipl%d", i);
724+ device_create_drvdata(ip2_class, NULL,
725+ MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
726+ NULL, "stat%d", i);
727727
728728 for ( box = 0; box < ABS_MAX_BOXES; ++box )
729729 {
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(ipmi_class, device, dev, "ipmi%d", if_num);
874+ device_create_drvdata(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+3−2
@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void) · 4598 unmodified lines
45994599
46004600 istallion_class = class_create(THIS_MODULE, "staliomem");
46014601 for (i = 0; i < 4; i++)
4602− device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4603− "staliomem%d", i);
4602+ device_create_drvdata(istallion_class, NULL,
4603+ MKDEV(STL_SIOMEMMAJOR, i),
4604+ NULL, "staliomem%d", i);
46044605
46054606 return 0;
46064607 err_deinit:
drivers/char/lp.c+2−1
@@ -813,7 +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(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
816+ device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
817+ "lp%d", nr);
817818
818819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
819820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
drivers/char/mem.c+3−3
@@ -989,9 +989,9 @@ static int __init chr_dev_init(void) · 988 unmodified lines
989989
990990 mem_class = class_create(THIS_MODULE, "mem");
991991 for (i = 0; i < ARRAY_SIZE(devlist); i++)
992− device_create(mem_class, NULL,
993− MKDEV(MEM_MAJOR, devlist[i].minor),
994− devlist[i].name);
992+ device_create_drvdata(mem_class, NULL,
993+ MKDEV(MEM_MAJOR, devlist[i].minor),
994+ NULL, devlist[i].name);
995995
996996 return 0;
997997 }
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(misc_class, misc->parent, dev,
221− "%s", misc->name);
220+ misc->this_device = device_create_drvdata(misc_class, misc->parent,
221+ dev, NULL, "%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
@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link) · 1895 unmodified lines
18961896 return ret;
18971897 }
18981898
1899− device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i);
1899+ device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
19001900
19011901 return 0;
19021902 }
drivers/char/pcmcia/cm4040_cs.c+2−1
@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link) · 652 unmodified lines
653653 return ret;
654654 }
655655
656− device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i);
656+ device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
657+ "cmx%d", i);
657658
658659 return 0;
659660 }
drivers/char/ppdev.c+3−2
@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = { · 751 unmodified lines
752752
753753 static void pp_attach(struct parport *port)
754754 {
755− device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
756− "parport%d", port->number);
755+ device_create_drvdata(ppdev_class, port->dev,
756+ MKDEV(PP_MAJOR, port->number),
757+ NULL, "parport%d", port->number);
757758 }
758759
759760 static void pp_detach(struct parport *port)
drivers/char/raw.c+4−3
@@ -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(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
135− "raw%d", rq->raw_minor);
134+ device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
135+ NULL, "raw%d", rq->raw_minor);
136136 }
137137
138138 /*
@@ -283,7 +283,8 @@ static int __init raw_init(void) · 144 unmodified lines
283283 ret = PTR_ERR(raw_class);
284284 goto error_region;
285285 }
286− device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
286+ device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
287+ "rawctl");
287288
288289 return 0;
289290
drivers/char/snsc.c+2−1
@@ -444,7 +444,8 @@ scdrv_init(void) · 443 unmodified lines
444444 continue;
445445 }
446446
447− device_create(snsc_class, NULL, dev, "%s", devname);
447+ device_create_drvdata(snsc_class, NULL, dev, NULL,
448+ "%s", devname);
448449
449450 ia64_sn_irtr_intr_enable(scd->scd_nasid,
450451 0 /*ignored */ ,
drivers/char/stallion.c+2−2
@@ -4755,8 +4755,8 @@ static int __init stallion_module_init(void) · 4754 unmodified lines
47554755 if (IS_ERR(stallion_class))
47564756 printk("STALLION: failed to create class\n");
47574757 for (i = 0; i < 4; i++)
4758− device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4759− "staliomem%d", i);
4758+ device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
4759+ NULL, "staliomem%d", i);
47604760
47614761 return 0;
47624762 err_unrtty:
drivers/char/tty_io.c+7−5
@@ -3412,7 +3412,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, · 3411 unmodified lines
34123412 else
34133413 tty_line_name(driver, index, name);
34143414
3415− return device_create(tty_class, device, dev, name);
3415+ return device_create_drvdata(tty_class, device, dev, NULL, name);
34163416 }
34173417
34183418 /**
@@ -3690,20 +3690,22 @@ static int __init tty_init(void) · 271 unmodified lines
36903690 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
36913691 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
36923692 panic("Couldn't register /dev/tty driver\n");
3693− device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
3693+ device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
3694+ "tty");
36943695
36953696 cdev_init(&console_cdev, &console_fops);
36963697 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
36973698 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
36983699 panic("Couldn't register /dev/console driver\n");
3699− device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
3700+ device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
3701+ "console");
37003702
37013703 #ifdef CONFIG_UNIX98_PTYS
37023704 cdev_init(&ptmx_cdev, &ptmx_fops);
37033705 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
37043706 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
37053707 panic("Couldn't register /dev/ptmx driver\n");
3706− device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
3708+ device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
37073709 #endif
37083710
37093711 #ifdef CONFIG_VT
@@ -3711,7 +3713,7 @@ static int __init tty_init(void) · 1 unmodified line
37113713 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
37123714 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
37133715 panic("Couldn't register /dev/tty0 driver\n");
3714− device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
3716+ device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
37153717
37163718 vty_init();
37173719 #endif
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(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
485− "vcs%u", tty->index + 1);
486− device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
487− "vcsa%u", tty->index + 1);
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);
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(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
503− device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
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");
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(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
890− "iseries!vt%d", i);
891− device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
892− "iseries!nvt%d", i);
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);
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/vt.c+8−6
@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last) · 3424 unmodified lines
34253425 if (retval)
34263426 goto err;
34273427
3428− con_driver->dev = device_create(vtconsole_class, NULL,
3429− MKDEV(0, con_driver->node),
3430− "vtcon%i", con_driver->node);
3428+ con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
3429+ MKDEV(0, con_driver->node),
3430+ NULL, "vtcon%i",
3431+ con_driver->node);
34313432
34323433 if (IS_ERR(con_driver->dev)) {
34333434 printk(KERN_WARNING "Unable to create device for %s; "
@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void) · 101 unmodified lines
35353536 struct con_driver *con = &registered_con_driver[i];
35363537
35373538 if (con->con && !con->dev) {
3538− con->dev = device_create(vtconsole_class, NULL,
3539− MKDEV(0, con->node),
3540− "vtcon%i", con->node);
3539+ con->dev = device_create_drvdata(vtconsole_class, NULL,
3540+ MKDEV(0, con->node),
3541+ NULL, "vtcon%i",
3542+ con->node);
35413543
35423544 if (IS_ERR(con->dev)) {
35433545 printk(KERN_WARNING "Unable to create "
drivers/char/xilinx_hwicap/xilinx_hwicap.c+3−2
@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id, · 657 unmodified lines
658658 dev_err(dev, "cdev_add() failed\n");
659659 goto failed3;
660660 }
661− /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
662− device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
661+
662+ device_create_drvdata(icap_class, dev, devt, NULL,
663+ "%s%d", DRIVER_NAME, id);
663664 return 0; /* success */
664665
665666 failed3:
drivers/cpuidle/sysfs.c+7−3
@@ -21,7 +21,8 @@ static int __init cpuidle_sysfs_setup(char *unused) · 20 unmodified lines
2121 }
2222 __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
2323
24−static ssize_t show_available_governors(struct sys_device *dev, char *buf)
24+static ssize_t show_available_governors(struct sys_device *dev,
25+ struct sysdev_attribute *attr, char *buf)
2526 {
2627 ssize_t i = 0;
2728 struct cpuidle_governor *tmp;
@@ -39,7 +40,8 @@ out: · 11 unmodified lines
3940 return i;
4041 }
4142
42−static ssize_t show_current_driver(struct sys_device *dev, char *buf)
43+static ssize_t show_current_driver(struct sys_device *dev,
44+ struct sysdev_attribute *attr, char *buf)
4345 {
4446 ssize_t ret;
4547
@@ -53,7 +55,8 @@ static ssize_t show_current_driver(struct sys_device *dev, char *buf) · 7 unmodified lines
5355 return ret;
5456 }
5557
56−static ssize_t show_current_governor(struct sys_device *dev, char *buf)
58+static ssize_t show_current_governor(struct sys_device *dev,
59+ struct sysdev_attribute *attr, char *buf)
5760 {
5861 ssize_t ret;
5962
@@ -68,6 +71,7 @@ static ssize_t show_current_governor(struct sys_device *dev, char *buf) · 8 unmodified lines
6871 }
6972
7073 static ssize_t store_current_governor(struct sys_device *dev,
74+ struct sysdev_attribute *attr,
7175 const char *buf, size_t count)
7276 {
7377 char gov_name[CPUIDLE_NAME_LEN];
drivers/dca/dca-sysfs.c+5−3
@@ -14,8 +14,9 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot) · 13 unmodified lines
1414 {
1515 struct device *cd;
1616
17− cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1),
18− "requester%d", slot);
17+ cd = device_create_drvdata(dca_class, dca->cd,
18+ MKDEV(0, slot + 1), NULL,
19+ "requester%d", slot);
1920 if (IS_ERR(cd))
2021 return PTR_ERR(cd);
2122 return 0;
@@ -46,7 +47,8 @@ idr_try_again: · 24 unmodified lines
4647 return err;
4748 }
4849
49− cd = device_create(dca_class, dev, MKDEV(0, 0), "dca%d", dca->id);
50+ cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL,
51+ "dca%d", dca->id);
5052 if (IS_ERR(cd)) {
5153 spin_lock(&dca_idr_lock);
5254 idr_remove(&dca_idr, dca->id);
drivers/eisa/Makefile+1−1
@@ -9,7 +9,7 @@ obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o · 8 unmodified lines
99
1010
1111 # Ugly hack to get DEVICE_NAME_SIZE value...
12−DEVICE_NAME_SIZE =$(shell awk '$$1=="\#define" && $$2=="DEVICE_NAME_SIZE" {print $$3-1}' $(srctree)/include/linux/device.h)
12+DEVICE_NAME_SIZE = 50
1313
1414 $(obj)/eisa-bus.o: $(obj)/devlist.h
1515
drivers/eisa/eisa-bus.c+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222
2323 struct eisa_device_info {
2424 struct eisa_device_id id;
25− char name[DEVICE_NAME_SIZE];
25+ char name[50];
2626 };
2727
2828 #ifdef CONFIG_EISA_NAMES
@@ -63,7 +63,7 @@ static void __init eisa_name_device (struct eisa_device *edev) · 34 unmodified lines
6363 if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) {
6464 strlcpy (edev->pretty_name,
6565 eisa_table[i].name,
66− DEVICE_NAME_SIZE);
66+ sizeof(edev->pretty_name));
6767 return;
6868 }
6969 }
drivers/hid/hidraw.c+3−2
@@ -322,8 +322,9 @@ int hidraw_connect(struct hid_device *hid) · 321 unmodified lines
322322 goto out;
323323 }
324324
325− dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
326− "%s%d", "hidraw", minor);
325+ dev->dev = device_create_drvdata(hidraw_class, NULL,
326+ MKDEV(hidraw_major, minor), NULL,
327+ "%s%d", "hidraw", minor);
327328
328329 if (IS_ERR(dev->dev)) {
329330 spin_lock(&minors_lock);
drivers/hwmon/hwmon.c+2−1
@@ -55,7 +55,8 @@ again: · 54 unmodified lines
5555 return ERR_PTR(err);
5656
5757 id = id & MAX_ID_MASK;
58− hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id);
58+ hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
59+ HWMON_ID_FORMAT, id);
5960
6061 if (IS_ERR(hwdev)) {
6162 spin_lock(&idr_lock);
drivers/i2c/i2c-core.c+4−2
@@ -722,7 +722,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) · 721 unmodified lines
722722
723723 INIT_LIST_HEAD(&driver->clients);
724724 /* Walk the adapters that are already present */
725− class_for_each_device(&i2c_adapter_class, driver, __attach_adapter);
725+ class_for_each_device(&i2c_adapter_class, NULL, driver,
726+ __attach_adapter);
726727
727728 mutex_unlock(&core_lock);
728729 return 0;
@@ -782,7 +783,8 @@ void i2c_del_driver(struct i2c_driver *driver) · 53 unmodified lines
782783 {
783784 mutex_lock(&core_lock);
784785
785− class_for_each_device(&i2c_adapter_class, driver, __detach_adapter);
786+ class_for_each_device(&i2c_adapter_class, NULL, driver,
787+ __detach_adapter);
786788
787789 driver_unregister(&driver->driver);
788790 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
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(i2c_dev_class, &adap->dev,
525− MKDEV(I2C_MAJOR, adap->nr),
526− "i2c-%d", adap->nr);
524+ i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev,
525+ MKDEV(I2C_MAJOR, adap->nr),
526+ NULL, "i2c-%d", adap->nr);
527527 if (IS_ERR(i2c_dev->dev)) {
528528 res = PTR_ERR(i2c_dev->dev);
529529 goto error;
drivers/ide/ide-tape.c+6−4
@@ -2697,10 +2697,12 @@ static int ide_tape_probe(ide_drive_t *drive) · 2696 unmodified lines
26972697
26982698 idetape_setup(drive, tape, minor);
26992699
2700− device_create(idetape_sysfs_class, &drive->gendev,
2701− MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name);
2702− device_create(idetape_sysfs_class, &drive->gendev,
2703− MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name);
2700+ device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2701+ MKDEV(IDETAPE_MAJOR, minor), NULL,
2702+ "%s", tape->name);
2703+ device_create_drvdata(idetape_sysfs_class, &drive->gendev,
2704+ MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
2705+ "n%s", tape->name);
27042706
27052707 g->fops = &idetape_block_ops;
27062708 ide_register_region(g);
drivers/ieee1394/dv1394.c+4−3
@@ -2296,9 +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(hpsb_protocol_class, NULL, MKDEV(
2300− IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2301− "dv1394-%d", id);
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);
23022303
23032304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
23042305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
drivers/ieee1394/nodemgr.c+15−8
@@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne) · 753 unmodified lines
754754 */
755755 mutex_lock(&nodemgr_serialize_remove_uds);
756756 for (;;) {
757− dev = class_find_device(&nodemgr_ud_class, ne, __match_ne);
757+ dev = class_find_device(&nodemgr_ud_class, NULL, ne,
758+ __match_ne);
758759 if (!dev)
759760 break;
760761 ud = container_of(dev, struct unit_directory, unit_dev);
@@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid) · 140 unmodified lines
901902 struct device *dev;
902903 struct node_entry *ne;
903904
904− dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid);
905+ dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
906+ __match_ne_guid);
905907 if (!dev)
906908 return NULL;
907909 ne = container_of(dev, struct node_entry, node_dev);
@@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, · 32 unmodified lines
940942 param.host = host;
941943 param.nodeid = nodeid;
942944
943− dev = class_find_device(&nodemgr_ne_class, &param, __match_ne_nodeid);
945+ dev = class_find_device(&nodemgr_ne_class, NULL, &param,
946+ __match_ne_nodeid);
944947 if (!dev)
945948 return NULL;
946949 ne = container_of(dev, struct node_entry, node_dev);
@@ -1453,7 +1456,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne) · 506 unmodified lines
14531456 ne->in_limbo = 1;
14541457 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
14551458
1456− class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_suspend);
1459+ class_for_each_device(&nodemgr_ud_class, NULL, ne,
1460+ __nodemgr_driver_suspend);
14571461 }
14581462
14591463
@@ -1462,7 +1466,8 @@ static void nodemgr_resume_ne(struct node_entry *ne) · 2 unmodified lines
14621466 ne->in_limbo = 0;
14631467 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
14641468
1465− class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_resume);
1469+ class_for_each_device(&nodemgr_ud_class, NULL, ne,
1470+ __nodemgr_driver_resume);
14661471 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
14671472 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
14681473 }
@@ -1498,7 +1503,8 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data) · 29 unmodified lines
14981503
14991504 static void nodemgr_update_pdrv(struct node_entry *ne)
15001505 {
1501− class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_update_pdrv);
1506+ class_for_each_device(&nodemgr_ud_class, NULL, ne,
1507+ __nodemgr_update_pdrv);
15021508 }
15031509
15041510
@@ -1591,7 +1597,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation) · 86 unmodified lines
15911597 * while probes are time-consuming. (Well, those probes need some
15921598 * improvement...) */
15931599
1594− class_for_each_device(&nodemgr_ne_class, &param, __nodemgr_node_probe);
1600+ class_for_each_device(&nodemgr_ne_class, NULL, &param,
1601+ __nodemgr_node_probe);
15951602
15961603 /* If we had a bus reset while we were scanning the bus, it is
15971604 * possible that we did not probe all nodes. In that case, we
@@ -1826,7 +1833,7 @@ int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) · 228 unmodified lines
18261833
18271834 hip.cb = cb;
18281835 hip.data = data;
1829− error = class_for_each_device(&hpsb_host_class, &hip,
1836+ error = class_for_each_device(&hpsb_host_class, NULL, &hip,
18301837 __nodemgr_for_each_host);
18311838
18321839 return error;
drivers/ieee1394/raw1394.c+2−2
@@ -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(
3013+ (device_create_drvdata(
30143014 hpsb_protocol_class, NULL,
30153015 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
3016− RAW1394_DEVICE_NAME))) {
3016+ NULL, RAW1394_DEVICE_NAME))) {
30173017 ret = -EFAULT;
30183018 goto out_unreg;
30193019 }
drivers/ieee1394/video1394.c+3−3
@@ -1341,9 +1341,9 @@ 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(hpsb_protocol_class, NULL,
1345− MKDEV(IEEE1394_MAJOR, minor),
1346− "%s-%d", VIDEO1394_DRIVER_NAME, 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);
13471347 }
13481348
13491349
drivers/infiniband/core/cm.c+31−41
@@ -44,6 +44,7 @@ · 43 unmodified lines
4444 #include <linux/spinlock.h>
4545 #include <linux/sysfs.h>
4646 #include <linux/workqueue.h>
47+#include <linux/kdev_t.h>
4748
4849 #include <rdma/ib_cache.h>
4950 #include <rdma/ib_cm.h>
@@ -162,8 +163,8 @@ struct cm_port { · 112 unmodified lines
162163
163164 struct cm_device {
164165 struct list_head list;
165− struct ib_device *device;
166− struct kobject dev_obj;
166+ struct ib_device *ib_device;
167+ struct device *device;
167168 u8 ack_delay;
168169 struct cm_port *port[0];
169170 };
@@ -339,7 +340,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc, · 169 unmodified lines
339340 {
340341 av->port = port;
341342 av->pkey_index = wc->pkey_index;
342− ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc,
343+ ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
343344 grh, &av->ah_attr);
344345 }
345346
@@ -353,7 +354,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) · 7 unmodified lines
353354
354355 read_lock_irqsave(&cm.device_lock, flags);
355356 list_for_each_entry(cm_dev, &cm.device_list, list) {
356− if (!ib_find_cached_gid(cm_dev->device, &path->sgid,
357+ if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
357358 &p, NULL)) {
358359 port = cm_dev->port[p-1];
359360 break;
@@ -364,13 +365,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) · 4 unmodified lines
364365 if (!port)
365366 return -EINVAL;
366367
367− ret = ib_find_cached_pkey(cm_dev->device, port->port_num,
368+ ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
368369 be16_to_cpu(path->pkey), &av->pkey_index);
369370 if (ret)
370371 return ret;
371372
372373 av->port = port;
373− ib_init_ah_from_path(cm_dev->device, port->port_num, path,
374+ ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
374375 &av->ah_attr);
375376 av->timeout = path->packet_life_time + 1;
376377 return 0;
@@ -1515,7 +1516,7 @@ static int cm_req_handler(struct cm_work *work) · 1138 unmodified lines
15151516
15161517 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
15171518
1518− cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
1519+ cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
15191520 if (IS_ERR(cm_id))
15201521 return PTR_ERR(cm_id);
15211522
@@ -1550,7 +1551,7 @@ static int cm_req_handler(struct cm_work *work) · 28 unmodified lines
15501551 cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
15511552 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
15521553 if (ret) {
1553− ib_get_cached_gid(work->port->cm_dev->device,
1554+ ib_get_cached_gid(work->port->cm_dev->ib_device,
15541555 work->port->port_num, 0, &work->path[0].sgid);
15551556 ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
15561557 &work->path[0].sgid, sizeof work->path[0].sgid,
@@ -2950,7 +2951,7 @@ static int cm_sidr_req_handler(struct cm_work *work) · 1393 unmodified lines
29502951 struct cm_sidr_req_msg *sidr_req_msg;
29512952 struct ib_wc *wc;
29522953
2953− cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
2954+ cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
29542955 if (IS_ERR(cm_id))
29552956 return PTR_ERR(cm_id);
29562957 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
@@ -3578,7 +3579,7 @@ static void cm_get_ack_delay(struct cm_device *cm_dev) · 621 unmodified lines
35783579 {
35793580 struct ib_device_attr attr;
35803581
3581− if (ib_query_device(cm_dev->device, &attr))
3582+ if (ib_query_device(cm_dev->ib_device, &attr))
35823583 cm_dev->ack_delay = 0; /* acks will rely on packet life time */
35833584 else
35843585 cm_dev->ack_delay = attr.local_ca_ack_delay;
@@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = { · 33 unmodified lines
36183619 .release = cm_release_port_obj
36193620 };
36203621
3621−static void cm_release_dev_obj(struct kobject *obj)
3622−{
3623− struct cm_device *cm_dev;
3624−
3625− cm_dev = container_of(obj, struct cm_device, dev_obj);
3626− kfree(cm_dev);
3627−}
3628−
3629−static struct kobj_type cm_dev_obj_type = {
3630− .release = cm_release_dev_obj
3631−};
3632−
36333622 struct class cm_class = {
36343623 .name = "infiniband_cm",
36353624 };
@@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port) · 4 unmodified lines
36403629 int i, ret;
36413630
36423631 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
3643− &port->cm_dev->dev_obj,
3632+ &port->cm_dev->device->kobj,
36443633 "%d", port->port_num);
36453634 if (ret) {
36463635 kfree(port);
@@ -3676,7 +3665,7 @@ static void cm_remove_port_fs(struct cm_port *port) · 29 unmodified lines
36763665 kobject_put(&port->port_obj);
36773666 }
36783667
3679−static void cm_add_one(struct ib_device *device)
3668+static void cm_add_one(struct ib_device *ib_device)
36803669 {
36813670 struct cm_device *cm_dev;
36823671 struct cm_port *port;
@@ -3691,26 +3680,27 @@ static void cm_add_one(struct ib_device *device) · 8 unmodified lines
36913680 int ret;
36923681 u8 i;
36933682
3694− if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
3683+ if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
36953684 return;
36963685
36973686 cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
3698− device->phys_port_cnt, GFP_KERNEL);
3687+ ib_device->phys_port_cnt, GFP_KERNEL);
36993688 if (!cm_dev)
37003689 return;
37013690
3702− cm_dev->device = device;
3691+ cm_dev->ib_device = ib_device;
37033692 cm_get_ack_delay(cm_dev);
37043693
3705− ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type,
3706− &cm_class.subsys.kobj, "%s", device->name);
3707− if (ret) {
3694+ cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
3695+ MKDEV(0, 0), NULL,
3696+ "%s", ib_device->name);
3697+ if (!cm_dev->device) {
37083698 kfree(cm_dev);
37093699 return;
37103700 }
37113701
37123702 set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
3713− for (i = 1; i <= device->phys_port_cnt; i++) {
3703+ for (i = 1; i <= ib_device->phys_port_cnt; i++) {
37143704 port = kzalloc(sizeof *port, GFP_KERNEL);
37153705 if (!port)
37163706 goto error1;
@@ -3723,7 +3713,7 @@ static void cm_add_one(struct ib_device *device) · 6 unmodified lines
37233713 if (ret)
37243714 goto error1;
37253715
3726− port->mad_agent = ib_register_mad_agent(device, i,
3716+ port->mad_agent = ib_register_mad_agent(ib_device, i,
37273717 IB_QPT_GSI,
37283718 &reg_req,
37293719 0,
@@ -3733,11 +3723,11 @@ static void cm_add_one(struct ib_device *device) · 3 unmodified lines
37333723 if (IS_ERR(port->mad_agent))
37343724 goto error2;
37353725
3736− ret = ib_modify_port(device, i, 0, &port_modify);
3726+ ret = ib_modify_port(ib_device, i, 0, &port_modify);
37373727 if (ret)
37383728 goto error3;
37393729 }
3740− ib_set_client_data(device, &cm_client, cm_dev);
3730+ ib_set_client_data(ib_device, &cm_client, cm_dev);
37413731
37423732 write_lock_irqsave(&cm.device_lock, flags);
37433733 list_add_tail(&cm_dev->list, &cm.device_list);
@@ -3753,14 +3743,14 @@ error1: · 9 unmodified lines
37533743 port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
37543744 while (--i) {
37553745 port = cm_dev->port[i-1];
3756− ib_modify_port(device, port->port_num, 0, &port_modify);
3746+ ib_modify_port(ib_device, port->port_num, 0, &port_modify);
37573747 ib_unregister_mad_agent(port->mad_agent);
37583748 cm_remove_port_fs(port);
37593749 }
3760− kobject_put(&cm_dev->dev_obj);
3750+ device_unregister(cm_dev->device);
37613751 }
37623752
3763−static void cm_remove_one(struct ib_device *device)
3753+static void cm_remove_one(struct ib_device *ib_device)
37643754 {
37653755 struct cm_device *cm_dev;
37663756 struct cm_port *port;
@@ -3770,7 +3760,7 @@ static void cm_remove_one(struct ib_device *device) · 3 unmodified lines
37703760 unsigned long flags;
37713761 int i;
37723762
3773− cm_dev = ib_get_client_data(device, &cm_client);
3763+ cm_dev = ib_get_client_data(ib_device, &cm_client);
37743764 if (!cm_dev)
37753765 return;
37763766
@@ -3778,14 +3768,14 @@ static void cm_remove_one(struct ib_device *device) · 1 unmodified line
37783768 list_del(&cm_dev->list);
37793769 write_unlock_irqrestore(&cm.device_lock, flags);
37803770
3781− for (i = 1; i <= device->phys_port_cnt; i++) {
3771+ for (i = 1; i <= ib_device->phys_port_cnt; i++) {
37823772 port = cm_dev->port[i-1];
3783− ib_modify_port(device, port->port_num, 0, &port_modify);
3773+ ib_modify_port(ib_device, port->port_num, 0, &port_modify);
37843774 ib_unregister_mad_agent(port->mad_agent);
37853775 flush_workqueue(cm.wq);
37863776 cm_remove_port_fs(port);
37873777 }
3788− kobject_put(&cm_dev->dev_obj);
3778+ device_unregister(cm_dev->device);
37893779 }
37903780
37913781 static int __init ib_cm_init(void)
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(ipath_class, NULL, dev, name);
2458+ device = device_create_drvdata(ipath_class, NULL, dev, NULL, name);
24592459
24602460 if (IS_ERR(device)) {
24612461 ret = PTR_ERR(device);
drivers/isdn/capi/capi.c+2−1
@@ -1553,7 +1553,8 @@ static int __init capi_init(void) · 1552 unmodified lines
15531553 return PTR_ERR(capi_class);
15541554 }
15551555
1556− device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
1556+ device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL,
1557+ "capi");
15571558
15581559 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
15591560 if (capinc_tty_init() < 0) {
drivers/macintosh/adb.c+2−1
@@ -862,7 +862,8 @@ 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(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb");
865+ device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL,
866+ "adb");
866867
867868 platform_device_register(&adb_pfdev);
868869 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
drivers/mca/mca-bus.c+1−1
@@ -40,7 +40,7 @@ static struct mca_bus *mca_root_busses[MAX_MCA_BUSSES]; · 39 unmodified lines
4040
4141 struct mca_device_info {
4242 short pos_id; /* the 2 byte pos id for this card */
43− char name[DEVICE_NAME_SIZE];
43+ char name[50];
4444 };
4545
4646 static int mca_bus_match (struct device *dev, struct device_driver *drv)
drivers/media/dvb/dvb-core/dvbdev.c+2−2
@@ -233,9 +233,9 @@ 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(dvb_class, adap->device,
236+ clsdev = device_create_drvdata(dvb_class, adap->device,
237237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
238− "dvb%d.%s%d", adap->num, dnames[type], id);
238+ NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
239239 if (IS_ERR(clsdev)) {
240240 printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
241241 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
drivers/memstick/host/jmb38x_ms.c+2−2
@@ -51,7 +51,7 @@ struct jmb38x_ms_host { · 50 unmodified lines
5151 void __iomem *addr;
5252 spinlock_t lock;
5353 int id;
54− char host_id[DEVICE_ID_SIZE];
54+ char host_id[32];
5555 int irq;
5656 unsigned int block_pos;
5757 unsigned long timeout_jiffies;
@@ -781,7 +781,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt) · 723 unmodified lines
781781
782782 spin_lock_init(&host->lock);
783783 host->id = cnt;
784− snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d",
784+ snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d",
785785 host->id);
786786 host->irq = jm->pdev->irq;
787787 host->timeout_jiffies = msecs_to_jiffies(1000);
drivers/message/fusion/mptbase.c+2−1
@@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) · 1669 unmodified lines
16701670 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
16711671 spin_lock_init(&ioc->fault_reset_work_lock);
16721672
1673− snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id);
1673+ snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name),
1674+ "mpt_poll_%d", ioc->id);
16741675 ioc->reset_work_q =
16751676 create_singlethread_workqueue(ioc->reset_work_q_name);
16761677 if (!ioc->reset_work_q) {
drivers/message/fusion/mptbase.h+2−2
@@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER · 706 unmodified lines
707707 u8 fc_link_speed[2];
708708 spinlock_t fc_rescan_work_lock;
709709 struct work_struct fc_rescan_work;
710− char fc_rescan_work_q_name[KOBJ_NAME_LEN];
710+ char fc_rescan_work_q_name[20];
711711 struct workqueue_struct *fc_rescan_work_q;
712712 struct scsi_cmnd **ScsiLookup;
713713 spinlock_t scsi_lookup_lock;
714714
715− char reset_work_q_name[KOBJ_NAME_LEN];
715+ char reset_work_q_name[20];
716716 struct workqueue_struct *reset_work_q;
717717 struct delayed_work fault_reset_work;
718718 spinlock_t fault_reset_work_lock;
drivers/message/fusion/mptfc.c+2−2
@@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 1325 unmodified lines
13261326
13271327 /* initialize workqueue */
13281328
1329− snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d",
1330− sh->host_no);
1329+ snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
1330+ "mptfc_wq_%d", sh->host_no);
13311331 ioc->fc_rescan_work_q =
13321332 create_singlethread_workqueue(ioc->fc_rescan_work_q_name);
13331333 if (!ioc->fc_rescan_work_q)
drivers/misc/Kconfig+13−0
@@ -420,4 +420,17 @@ config SGI_XP · 419 unmodified lines
420420 this feature will allow for direct communication between SSIs
421421 based on a network adapter and DMA messaging.
422422
423+config HP_ILO
424+ tristate "Channel interface driver for HP iLO/iLO2 processor"
425+ default n
426+ help
427+ The channel interface driver allows applications to communicate
428+ with iLO/iLO2 management processors present on HP ProLiant
429+ servers. Upon loading, the driver creates /dev/hpilo/dXccbN files,
430+ which can be used to gather data from the management processor,
431+ via read and write system calls.
432+
433+ To compile this driver as a module, choose M here: the
434+ module will be called hpilo.
435+
423436 endif # MISC_DEVICES
drivers/misc/Makefile+1−0
@@ -27,3 +27,4 @@ obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o · 26 unmodified lines
2727 obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
2828 obj-$(CONFIG_KGDB_TESTS) += kgdbts.o
2929 obj-$(CONFIG_SGI_XP) += sgi-xp/
30+obj-$(CONFIG_HP_ILO) += hpilo.o
drivers/misc/hpilo.c+768−0
@@ -0,0 +1,768 @@
1+/*
2+ * Driver for HP iLO/iLO2 management processor.
3+ *
4+ * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5+ * David Altobelli <david.altobelli@hp.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License version 2 as
9+ * published by the Free Software Foundation.
10+ */
11+#include <linux/kernel.h>
12+#include <linux/types.h>
13+#include <linux/module.h>
14+#include <linux/fs.h>
15+#include <linux/pci.h>
16+#include <linux/ioport.h>
17+#include <linux/device.h>
18+#include <linux/file.h>
19+#include <linux/cdev.h>
20+#include <linux/spinlock.h>
21+#include <linux/delay.h>
22+#include <linux/uaccess.h>
23+#include <linux/io.h>
24+#include "hpilo.h"
25+
26+static struct class *ilo_class;
27+static unsigned int ilo_major;
28+static char ilo_hwdev[MAX_ILO_DEV];
29+
30+static inline int get_entry_id(int entry)
31+{
32+ return (entry & ENTRY_MASK_DESCRIPTOR) >> ENTRY_BITPOS_DESCRIPTOR;
33+}
34+
35+static inline int get_entry_len(int entry)
36+{
37+ return ((entry & ENTRY_MASK_QWORDS) >> ENTRY_BITPOS_QWORDS) << 3;
38+}
39+
40+static inline int mk_entry(int id, int len)
41+{
42+ int qlen = len & 7 ? (len >> 3) + 1 : len >> 3;
43+ return id << ENTRY_BITPOS_DESCRIPTOR | qlen << ENTRY_BITPOS_QWORDS;
44+}
45+
46+static inline int desc_mem_sz(int nr_entry)
47+{
48+ return nr_entry << L2_QENTRY_SZ;
49+}
50+
51+/*
52+ * FIFO queues, shared with hardware.
53+ *
54+ * If a queue has empty slots, an entry is added to the queue tail,
55+ * and that entry is marked as occupied.
56+ * Entries can be dequeued from the head of the list, when the device
57+ * has marked the entry as consumed.
58+ *
59+ * Returns true on successful queue/dequeue, false on failure.
60+ */
61+static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
62+{
63+ struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
64+ int ret = 0;
65+
66+ spin_lock(&hw->fifo_lock);
67+ if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask]
68+ & ENTRY_MASK_O)) {
69+ fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |=
70+ (entry & ENTRY_MASK_NOSTATE) | fifo_q->merge;
71+ fifo_q->tail += 1;
72+ ret = 1;
73+ }
74+ spin_unlock(&hw->fifo_lock);
75+
76+ return ret;
77+}
78+
79+static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
80+{
81+ struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
82+ int ret = 0;
83+ u64 c;
84+
85+ spin_lock(&hw->fifo_lock);
86+ c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
87+ if (c & ENTRY_MASK_C) {
88+ if (entry)
89+ *entry = c & ENTRY_MASK_NOSTATE;
90+
91+ fifo_q->fifobar[fifo_q->head & fifo_q->imask] =
92+ (c | ENTRY_MASK) + 1;
93+ fifo_q->head += 1;
94+ ret = 1;
95+ }
96+ spin_unlock(&hw->fifo_lock);
97+
98+ return ret;
99+}
100+
101+static int ilo_pkt_enqueue(struct ilo_hwinfo *hw, struct ccb *ccb,
102+ int dir, int id, int len)
103+{
104+ char *fifobar;
105+ int entry;
106+
107+ if (dir == SENDQ)
108+ fifobar = ccb->ccb_u1.send_fifobar;
109+ else
110+ fifobar = ccb->ccb_u3.recv_fifobar;
111+
112+ entry = mk_entry(id, len);
113+ return fifo_enqueue(hw, fifobar, entry);
114+}
115+
116+static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb,
117+ int dir, int *id, int *len, void **pkt)
118+{
119+ char *fifobar, *desc;
120+ int entry = 0, pkt_id = 0;
121+ int ret;
122+
123+ if (dir == SENDQ) {
124+ fifobar = ccb->ccb_u1.send_fifobar;
125+ desc = ccb->ccb_u2.send_desc;
126+ } else {
127+ fifobar = ccb->ccb_u3.recv_fifobar;
128+ desc = ccb->ccb_u4.recv_desc;
129+ }
130+
131+ ret = fifo_dequeue(hw, fifobar, &entry);
132+ if (ret) {
133+ pkt_id = get_entry_id(entry);
134+ if (id)
135+ *id = pkt_id;
136+ if (len)
137+ *len = get_entry_len(entry);
138+ if (pkt)
139+ *pkt = (void *)(desc + desc_mem_sz(pkt_id));
140+ }
141+
142+ return ret;
143+}
144+
145+static inline void doorbell_set(struct ccb *ccb)
146+{
147+ iowrite8(1, ccb->ccb_u5.db_base);
148+}
149+
150+static inline void doorbell_clr(struct ccb *ccb)
151+{
152+ iowrite8(2, ccb->ccb_u5.db_base);
153+}
154+static inline int ctrl_set(int l2sz, int idxmask, int desclim)
155+{
156+ int active = 0, go = 1;
157+ return l2sz << CTRL_BITPOS_L2SZ |
158+ idxmask << CTRL_BITPOS_FIFOINDEXMASK |
159+ desclim << CTRL_BITPOS_DESCLIMIT |
160+ active << CTRL_BITPOS_A |
161+ go << CTRL_BITPOS_G;
162+}
163+static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz)
164+{
165+ /* for simplicity, use the same parameters for send and recv ctrls */
166+ ccb->send_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
167+ ccb->recv_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
168+}
169+
170+static inline int fifo_sz(int nr_entry)
171+{
172+ /* size of a fifo is determined by the number of entries it contains */
173+ return (nr_entry * sizeof(u64)) + FIFOHANDLESIZE;
174+}
175+
176+static void fifo_setup(void *base_addr, int nr_entry)
177+{
178+ struct fifo *fifo_q = base_addr;
179+ int i;
180+
181+ /* set up an empty fifo */
182+ fifo_q->head = 0;
183+ fifo_q->tail = 0;
184+ fifo_q->reset = 0;
185+ fifo_q->nrents = nr_entry;
186+ fifo_q->imask = nr_entry - 1;
187+ fifo_q->merge = ENTRY_MASK_O;
188+
189+ for (i = 0; i < nr_entry; i++)
190+ fifo_q->fifobar[i] = 0;
191+}
192+
193+static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
194+{
195+ struct ccb *driver_ccb;
196+ struct ccb __iomem *device_ccb;
197+ int retries;
198+
199+ driver_ccb = &data->driver_ccb;
200+ device_ccb = data->mapped_ccb;
201+
202+ /* complicated dance to tell the hw we are stopping */
203+ doorbell_clr(driver_ccb);
204+ iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G),
205+ &device_ccb->send_ctrl);
206+ iowrite32(ioread32(&device_ccb->recv_ctrl) & ~(1 << CTRL_BITPOS_G),
207+ &device_ccb->recv_ctrl);
208+
209+ /* give iLO some time to process stop request */
210+ for (retries = 1000; retries > 0; retries--) {
211+ doorbell_set(driver_ccb);
212+ udelay(1);
213+ if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A))
214+ &&
215+ !(ioread32(&device_ccb->recv_ctrl) & (1 << CTRL_BITPOS_A)))
216+ break;
217+ }
218+ if (retries == 0)
219+ dev_err(&pdev->dev, "Closing, but controller still active\n");
220+
221+ /* clear the hw ccb */
222+ memset_io(device_ccb, 0, sizeof(struct ccb));
223+
224+ /* free resources used to back send/recv queues */
225+ pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
226+}
227+
228+static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
229+{
230+ char *dma_va, *dma_pa;
231+ int pkt_id, pkt_sz, i, error;
232+ struct ccb *driver_ccb, *ilo_ccb;
233+ struct pci_dev *pdev;
234+
235+ driver_ccb = &data->driver_ccb;
236+ ilo_ccb = &data->ilo_ccb;
237+ pdev = hw->ilo_dev;
238+
239+ data->dma_size = 2 * fifo_sz(NR_QENTRY) +
240+ 2 * desc_mem_sz(NR_QENTRY) +
241+ ILO_START_ALIGN + ILO_CACHE_SZ;
242+
243+ error = -ENOMEM;
244+ data->dma_va = pci_alloc_consistent(pdev, data->dma_size,
245+ &data->dma_pa);
246+ if (!data->dma_va)
247+ goto out;
248+
249+ dma_va = (char *)data->dma_va;
250+ dma_pa = (char *)data->dma_pa;
251+
252+ memset(dma_va, 0, data->dma_size);
253+
254+ dma_va = (char *)roundup((unsigned long)dma_va, ILO_START_ALIGN);
255+ dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_START_ALIGN);
256+
257+ /*
258+ * Create two ccb's, one with virt addrs, one with phys addrs.
259+ * Copy the phys addr ccb to device shared mem.
260+ */
261+ ctrl_setup(driver_ccb, NR_QENTRY, L2_QENTRY_SZ);
262+ ctrl_setup(ilo_ccb, NR_QENTRY, L2_QENTRY_SZ);
263+
264+ fifo_setup(dma_va, NR_QENTRY);
265+ driver_ccb->ccb_u1.send_fifobar = dma_va + FIFOHANDLESIZE;
266+ ilo_ccb->ccb_u1.send_fifobar = dma_pa + FIFOHANDLESIZE;
267+ dma_va += fifo_sz(NR_QENTRY);
268+ dma_pa += fifo_sz(NR_QENTRY);
269+
270+ dma_va = (char *)roundup((unsigned long)dma_va, ILO_CACHE_SZ);
271+ dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_CACHE_SZ);
272+
273+ fifo_setup(dma_va, NR_QENTRY);
274+ driver_ccb->ccb_u3.recv_fifobar = dma_va + FIFOHANDLESIZE;
275+ ilo_ccb->ccb_u3.recv_fifobar = dma_pa + FIFOHANDLESIZE;
276+ dma_va += fifo_sz(NR_QENTRY);
277+ dma_pa += fifo_sz(NR_QENTRY);
278+
279+ driver_ccb->ccb_u2.send_desc = dma_va;
280+ ilo_ccb->ccb_u2.send_desc = dma_pa;
281+ dma_pa += desc_mem_sz(NR_QENTRY);
282+ dma_va += desc_mem_sz(NR_QENTRY);
283+
284+ driver_ccb->ccb_u4.recv_desc = dma_va;
285+ ilo_ccb->ccb_u4.recv_desc = dma_pa;
286+
287+ driver_ccb->channel = slot;
288+ ilo_ccb->channel = slot;
289+
290+ driver_ccb->ccb_u5.db_base = hw->db_vaddr + (slot << L2_DB_SIZE);
291+ ilo_ccb->ccb_u5.db_base = NULL; /* hw ccb's doorbell is not used */
292+
293+ /* copy the ccb with physical addrs to device memory */
294+ data->mapped_ccb = (struct ccb __iomem *)
295+ (hw->ram_vaddr + (slot * ILOHW_CCB_SZ));
296+ memcpy_toio(data->mapped_ccb, ilo_ccb, sizeof(struct ccb));
297+
298+ /* put packets on the send and receive queues */
299+ pkt_sz = 0;
300+ for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) {
301+ ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, pkt_sz);
302+ doorbell_set(driver_ccb);
303+ }
304+
305+ pkt_sz = desc_mem_sz(1);
306+ for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++)
307+ ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz);
308+
309+ doorbell_clr(driver_ccb);
310+
311+ /* make sure iLO is really handling requests */
312+ for (i = 1000; i > 0; i--) {
313+ if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL))
314+ break;
315+ udelay(1);
316+ }
317+
318+ if (i) {
319+ ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0);
320+ doorbell_set(driver_ccb);
321+ } else {
322+ dev_err(&pdev->dev, "Open could not dequeue a packet\n");
323+ error = -EBUSY;
324+ goto free;
325+ }
326+
327+ return 0;
328+free:
329+ pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
330+out:
331+ return error;
332+}
333+
334+static inline int is_channel_reset(struct ccb *ccb)
335+{
336+ /* check for this particular channel needing a reset */
337+ return FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset;
338+}
339+
340+static inline void set_channel_reset(struct ccb *ccb)
341+{
342+ /* set a flag indicating this channel needs a reset */
343+ FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1;
344+}
345+
346+static inline int is_device_reset(struct ilo_hwinfo *hw)
347+{
348+ /* check for global reset condition */
349+ return ioread32(&hw->mmio_vaddr[DB_OUT]) & (1 << DB_RESET);
350+}
351+
352+static inline void clear_device(struct ilo_hwinfo *hw)
353+{
354+ /* clear the device (reset bits, pending channel entries) */
355+ iowrite32(-1, &hw->mmio_vaddr[DB_OUT]);
356+}
357+
358+static void ilo_locked_reset(struct ilo_hwinfo *hw)
359+{
360+ int slot;
361+
362+ /*
363+ * Mapped memory is zeroed on ilo reset, so set a per ccb flag
364+ * to indicate that this ccb needs to be closed and reopened.
365+ */
366+ for (slot = 0; slot < MAX_CCB; slot++) {
367+ if (!hw->ccb_alloc[slot])
368+ continue;
369+ set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb);
370+ }
371+
372+ clear_device(hw);
373+}
374+
375+static void ilo_reset(struct ilo_hwinfo *hw)
376+{
377+ spin_lock(&hw->alloc_lock);
378+
379+ /* reset might have been handled after lock was taken */
380+ if (is_device_reset(hw))
381+ ilo_locked_reset(hw);
382+
383+ spin_unlock(&hw->alloc_lock);
384+}
385+
386+static ssize_t ilo_read(struct file *fp, char __user *buf,
387+ size_t len, loff_t *off)
388+{
389+ int err, found, cnt, pkt_id, pkt_len;
390+ struct ccb_data *data;
391+ struct ccb *driver_ccb;
392+ struct ilo_hwinfo *hw;
393+ void *pkt;
394+
395+ data = fp->private_data;
396+ driver_ccb = &data->driver_ccb;
397+ hw = data->ilo_hw;
398+
399+ if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
400+ /*
401+ * If the device has been reset, applications
402+ * need to close and reopen all ccbs.
403+ */
404+ ilo_reset(hw);
405+ return -ENODEV;
406+ }
407+
408+ /*
409+ * This function is to be called when data is expected
410+ * in the channel, and will return an error if no packet is found
411+ * during the loop below. The sleep/retry logic is to allow
412+ * applications to call read() immediately post write(),
413+ * and give iLO some time to process the sent packet.
414+ */
415+ cnt = 20;
416+ do {
417+ /* look for a received packet */
418+ found = ilo_pkt_dequeue(hw, driver_ccb, RECVQ, &pkt_id,
419+ &pkt_len, &pkt);
420+ if (found)
421+ break;
422+ cnt--;
423+ msleep(100);
424+ } while (!found && cnt);
425+
426+ if (!found)
427+ return -EAGAIN;
428+
429+ /* only copy the length of the received packet */
430+ if (pkt_len < len)
431+ len = pkt_len;
432+
433+ err = copy_to_user(buf, pkt, len);
434+
435+ /* return the received packet to the queue */
436+ ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1));
437+
438+ return err ? -EFAULT : len;
439+}
440+
441+static ssize_t ilo_write(struct file *fp, const char __user *buf,
442+ size_t len, loff_t *off)
443+{
444+ int err, pkt_id, pkt_len;
445+ struct ccb_data *data;
446+ struct ccb *driver_ccb;
447+ struct ilo_hwinfo *hw;
448+ void *pkt;
449+
450+ data = fp->private_data;
451+ driver_ccb = &data->driver_ccb;
452+ hw = data->ilo_hw;
453+
454+ if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
455+ /*
456+ * If the device has been reset, applications
457+ * need to close and reopen all ccbs.
458+ */
459+ ilo_reset(hw);
460+ return -ENODEV;
461+ }
462+
463+ /* get a packet to send the user command */
464+ if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt))
465+ return -EBUSY;
466+
467+ /* limit the length to the length of the packet */
468+ if (pkt_len < len)
469+ len = pkt_len;
470+
471+ /* on failure, set the len to 0 to return empty packet to the device */
472+ err = copy_from_user(pkt, buf, len);
473+ if (err)
474+ len = 0;
475+
476+ /* send the packet */
477+ ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, len);
478+ doorbell_set(driver_ccb);
479+
480+ return err ? -EFAULT : len;
481+}
482+
483+static int ilo_close(struct inode *ip, struct file *fp)
484+{
485+ int slot;
486+ struct ccb_data *data;
487+ struct ilo_hwinfo *hw;
488+
489+ slot = iminor(ip) % MAX_CCB;
490+ hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
491+
492+ spin_lock(&hw->alloc_lock);
493+
494+ if (is_device_reset(hw))
495+ ilo_locked_reset(hw);
496+
497+ if (hw->ccb_alloc[slot]->ccb_cnt == 1) {
498+
499+ data = fp->private_data;
500+
501+ ilo_ccb_close(hw->ilo_dev, data);
502+
503+ kfree(data);
504+ hw->ccb_alloc[slot] = NULL;
505+ } else
506+ hw->ccb_alloc[slot]->ccb_cnt--;
507+
508+ spin_unlock(&hw->alloc_lock);
509+
510+ return 0;
511+}
512+
513+static int ilo_open(struct inode *ip, struct file *fp)
514+{
515+ int slot, error;
516+ struct ccb_data *data;
517+ struct ilo_hwinfo *hw;
518+
519+ slot = iminor(ip) % MAX_CCB;
520+ hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
521+
522+ /* new ccb allocation */
523+ data = kzalloc(sizeof(*data), GFP_KERNEL);
524+ if (!data)
525+ return -ENOMEM;
526+
527+ spin_lock(&hw->alloc_lock);
528+
529+ if (is_device_reset(hw))
530+ ilo_locked_reset(hw);
531+
532+ /* each fd private_data holds sw/hw view of ccb */
533+ if (hw->ccb_alloc[slot] == NULL) {
534+ /* create a channel control block for this minor */
535+ error = ilo_ccb_open(hw, data, slot);
536+ if (!error) {
537+ hw->ccb_alloc[slot] = data;
538+ hw->ccb_alloc[slot]->ccb_cnt = 1;
539+ hw->ccb_alloc[slot]->ccb_excl = fp->f_flags & O_EXCL;
540+ hw->ccb_alloc[slot]->ilo_hw = hw;
541+ } else
542+ kfree(data);
543+ } else {
544+ kfree(data);
545+ if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) {
546+ /*
547+ * The channel exists, and either this open
548+ * or a previous open of this channel wants
549+ * exclusive access.
550+ */
551+ error = -EBUSY;
552+ } else {
553+ hw->ccb_alloc[slot]->ccb_cnt++;
554+ error = 0;
555+ }
556+ }
557+ spin_unlock(&hw->alloc_lock);
558+
559+ if (!error)
560+ fp->private_data = hw->ccb_alloc[slot];
561+
562+ return error;
563+}
564+
565+static const struct file_operations ilo_fops = {
566+ .owner = THIS_MODULE,
567+ .read = ilo_read,
568+ .write = ilo_write,
569+ .open = ilo_open,
570+ .release = ilo_close,
571+};
572+
573+static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
574+{
575+ pci_iounmap(pdev, hw->db_vaddr);
576+ pci_iounmap(pdev, hw->ram_vaddr);
577+ pci_iounmap(pdev, hw->mmio_vaddr);
578+}
579+
580+static int __devinit ilo_map_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
581+{
582+ int error = -ENOMEM;
583+
584+ /* map the memory mapped i/o registers */
585+ hw->mmio_vaddr = pci_iomap(pdev, 1, 0);
586+ if (hw->mmio_vaddr == NULL) {
587+ dev_err(&pdev->dev, "Error mapping mmio\n");
588+ goto out;
589+ }
590+
591+ /* map the adapter shared memory region */
592+ hw->ram_vaddr = pci_iomap(pdev, 2, MAX_CCB * ILOHW_CCB_SZ);
593+ if (hw->ram_vaddr == NULL) {
594+ dev_err(&pdev->dev, "Error mapping shared mem\n");
595+ goto mmio_free;
596+ }
597+
598+ /* map the doorbell aperture */
599+ hw->db_vaddr = pci_iomap(pdev, 3, MAX_CCB * ONE_DB_SIZE);
600+ if (hw->db_vaddr == NULL) {
601+ dev_err(&pdev->dev, "Error mapping doorbell\n");
602+ goto ram_free;
603+ }
604+
605+ return 0;
606+ram_free:
607+ pci_iounmap(pdev, hw->ram_vaddr);
608+mmio_free:
609+ pci_iounmap(pdev, hw->mmio_vaddr);
610+out:
611+ return error;
612+}
613+
614+static void ilo_remove(struct pci_dev *pdev)
615+{
616+ int i, minor;
617+ struct ilo_hwinfo *ilo_hw = pci_get_drvdata(pdev);
618+
619+ clear_device(ilo_hw);
620+
621+ minor = MINOR(ilo_hw->cdev.dev);
622+ for (i = minor; i < minor + MAX_CCB; i++)
623+ device_destroy(ilo_class, MKDEV(ilo_major, i));
624+
625+ cdev_del(&ilo_hw->cdev);
626+ ilo_unmap_device(pdev, ilo_hw);
627+ pci_release_regions(pdev);
628+ pci_disable_device(pdev);
629+ kfree(ilo_hw);
630+ ilo_hwdev[(minor / MAX_CCB)] = 0;
631+}
632+
633+static int __devinit ilo_probe(struct pci_dev *pdev,
634+ const struct pci_device_id *ent)
635+{
636+ int devnum, minor, start, error;
637+ struct ilo_hwinfo *ilo_hw;
638+
639+ /* find a free range for device files */
640+ for (devnum = 0; devnum < MAX_ILO_DEV; devnum++) {
641+ if (ilo_hwdev[devnum] == 0) {
642+ ilo_hwdev[devnum] = 1;
643+ break;
644+ }
645+ }
646+
647+ if (devnum == MAX_ILO_DEV) {
648+ dev_err(&pdev->dev, "Error finding free device\n");
649+ return -ENODEV;
650+ }
651+
652+ /* track global allocations for this device */
653+ error = -ENOMEM;
654+ ilo_hw = kzalloc(sizeof(*ilo_hw), GFP_KERNEL);
655+ if (!ilo_hw)
656+ goto out;
657+
658+ ilo_hw->ilo_dev = pdev;
659+ spin_lock_init(&ilo_hw->alloc_lock);
660+ spin_lock_init(&ilo_hw->fifo_lock);
661+
662+ error = pci_enable_device(pdev);
663+ if (error)
664+ goto free;
665+
666+ pci_set_master(pdev);
667+
668+ error = pci_request_regions(pdev, ILO_NAME);
669+ if (error)
670+ goto disable;
671+
672+ error = ilo_map_device(pdev, ilo_hw);
673+ if (error)
674+ goto free_regions;
675+
676+ pci_set_drvdata(pdev, ilo_hw);
677+ clear_device(ilo_hw);
678+
679+ cdev_init(&ilo_hw->cdev, &ilo_fops);
680+ ilo_hw->cdev.owner = THIS_MODULE;
681+ start = devnum * MAX_CCB;
682+ error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB);
683+ if (error) {
684+ dev_err(&pdev->dev, "Could not add cdev\n");
685+ goto unmap;
686+ }
687+
688+ for (minor = 0 ; minor < MAX_CCB; minor++) {
689+ struct device *dev;
690+ dev = device_create(ilo_class, &pdev->dev,
691+ MKDEV(ilo_major, minor), NULL,
692+ "hpilo!d%dccb%d", devnum, minor);
693+ if (IS_ERR(dev))
694+ dev_err(&pdev->dev, "Could not create files\n");
695+ }
696+
697+ return 0;
698+unmap:
699+ ilo_unmap_device(pdev, ilo_hw);
700+free_regions:
701+ pci_release_regions(pdev);
702+disable:
703+ pci_disable_device(pdev);
704+free:
705+ kfree(ilo_hw);
706+out:
707+ ilo_hwdev[devnum] = 0;
708+ return error;
709+}
710+
711+static struct pci_device_id ilo_devices[] = {
712+ { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
713+ { }
714+};
715+MODULE_DEVICE_TABLE(pci, ilo_devices);
716+
717+static struct pci_driver ilo_driver = {
718+ .name = ILO_NAME,
719+ .id_table = ilo_devices,
720+ .probe = ilo_probe,
721+ .remove = __devexit_p(ilo_remove),
722+};
723+
724+static int __init ilo_init(void)
725+{
726+ int error;
727+ dev_t dev;
728+
729+ ilo_class = class_create(THIS_MODULE, "iLO");
730+ if (IS_ERR(ilo_class)) {
731+ error = PTR_ERR(ilo_class);
732+ goto out;
733+ }
734+
735+ error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME);
736+ if (error)
737+ goto class_destroy;
738+
739+ ilo_major = MAJOR(dev);
740+
741+ error = pci_register_driver(&ilo_driver);
742+ if (error)
743+ goto chr_remove;
744+
745+ return 0;
746+chr_remove:
747+ unregister_chrdev_region(dev, MAX_OPEN);
748+class_destroy:
749+ class_destroy(ilo_class);
750+out:
751+ return error;
752+}
753+
754+static void __exit ilo_exit(void)
755+{
756+ pci_unregister_driver(&ilo_driver);
757+ unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN);
758+ class_destroy(ilo_class);
759+}
760+
761+MODULE_VERSION("0.05");
762+MODULE_ALIAS(ILO_NAME);
763+MODULE_DESCRIPTION(ILO_NAME);
764+MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
765+MODULE_LICENSE("GPL v2");
766+
767+module_init(ilo_init);
768+module_exit(ilo_exit);
drivers/misc/hpilo.h+189−0
@@ -0,0 +1,189 @@
1+/*
2+ * linux/drivers/char/hpilo.h
3+ *
4+ * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5+ * David Altobelli <david.altobelli@hp.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License version 2 as
9+ * published by the Free Software Foundation.
10+ */
11+#ifndef __HPILO_H
12+#define __HPILO_H
13+
14+#define ILO_NAME "hpilo"
15+
16+/* max number of open channel control blocks per device, hw limited to 32 */
17+#define MAX_CCB 8
18+/* max number of supported devices */
19+#define MAX_ILO_DEV 1
20+/* max number of files */
21+#define MAX_OPEN (MAX_CCB * MAX_ILO_DEV)
22+
23+/*
24+ * Per device, used to track global memory allocations.
25+ */
26+struct ilo_hwinfo {
27+ /* mmio registers on device */
28+ char __iomem *mmio_vaddr;
29+
30+ /* doorbell registers on device */
31+ char __iomem *db_vaddr;
32+
33+ /* shared memory on device used for channel control blocks */
34+ char __iomem *ram_vaddr;
35+
36+ /* files corresponding to this device */
37+ struct ccb_data *ccb_alloc[MAX_CCB];
38+
39+ struct pci_dev *ilo_dev;
40+
41+ spinlock_t alloc_lock;
42+ spinlock_t fifo_lock;
43+
44+ struct cdev cdev;
45+};
46+
47+/* offset from mmio_vaddr */
48+#define DB_OUT 0xD4
49+/* DB_OUT reset bit */
50+#define DB_RESET 26
51+
52+/*
53+ * Channel control block. Used to manage hardware queues.
54+ * The format must match hw's version. The hw ccb is 128 bytes,
55+ * but the context area shouldn't be touched by the driver.
56+ */
57+#define ILOSW_CCB_SZ 64
58+#define ILOHW_CCB_SZ 128
59+struct ccb {
60+ union {
61+ char *send_fifobar;
62+ u64 padding1;
63+ } ccb_u1;
64+ union {
65+ char *send_desc;
66+ u64 padding2;
67+ } ccb_u2;
68+ u64 send_ctrl;
69+
70+ union {
71+ char *recv_fifobar;
72+ u64 padding3;
73+ } ccb_u3;
74+ union {
75+ char *recv_desc;
76+ u64 padding4;
77+ } ccb_u4;
78+ u64 recv_ctrl;
79+
80+ union {
81+ char __iomem *db_base;
82+ u64 padding5;
83+ } ccb_u5;
84+
85+ u64 channel;
86+
87+ /* unused context area (64 bytes) */
88+};
89+
90+/* ccb queue parameters */
91+#define SENDQ 1
92+#define RECVQ 2
93+#define NR_QENTRY 4
94+#define L2_QENTRY_SZ 12
95+
96+/* ccb ctrl bitfields */
97+#define CTRL_BITPOS_L2SZ 0
98+#define CTRL_BITPOS_FIFOINDEXMASK 4
99+#define CTRL_BITPOS_DESCLIMIT 18
100+#define CTRL_BITPOS_A 30
101+#define CTRL_BITPOS_G 31
102+
103+/* ccb doorbell macros */
104+#define L2_DB_SIZE 14
105+#define ONE_DB_SIZE (1 << L2_DB_SIZE)
106+
107+/*
108+ * Per fd structure used to track the ccb allocated to that dev file.
109+ */
110+struct ccb_data {
111+ /* software version of ccb, using virtual addrs */
112+ struct ccb driver_ccb;
113+
114+ /* hardware version of ccb, using physical addrs */
115+ struct ccb ilo_ccb;
116+
117+ /* hardware ccb is written to this shared mapped device memory */
118+ struct ccb __iomem *mapped_ccb;
119+
120+ /* dma'able memory used for send/recv queues */
121+ void *dma_va;
122+ dma_addr_t dma_pa;
123+ size_t dma_size;
124+
125+ /* pointer to hardware device info */
126+ struct ilo_hwinfo *ilo_hw;
127+
128+ /* usage count, to allow for shared ccb's */
129+ int ccb_cnt;
130+
131+ /* open wanted exclusive access to this ccb */
132+ int ccb_excl;
133+};
134+
135+/*
136+ * FIFO queue structure, shared with hw.
137+ */
138+#define ILO_START_ALIGN 4096
139+#define ILO_CACHE_SZ 128
140+struct fifo {
141+ u64 nrents; /* user requested number of fifo entries */
142+ u64 imask; /* mask to extract valid fifo index */
143+ u64 merge; /* O/C bits to merge in during enqueue operation */
144+ u64 reset; /* set to non-zero when the target device resets */
145+ u8 pad_0[ILO_CACHE_SZ - (sizeof(u64) * 4)];
146+
147+ u64 head;
148+ u8 pad_1[ILO_CACHE_SZ - (sizeof(u64))];
149+
150+ u64 tail;
151+ u8 pad_2[ILO_CACHE_SZ - (sizeof(u64))];
152+
153+ u64 fifobar[1];
154+};
155+
156+/* convert between struct fifo, and the fifobar, which is saved in the ccb */
157+#define FIFOHANDLESIZE (sizeof(struct fifo) - sizeof(u64))
158+#define FIFOBARTOHANDLE(_fifo) \
159+ ((struct fifo *)(((char *)(_fifo)) - FIFOHANDLESIZE))
160+
161+/* the number of qwords to consume from the entry descriptor */
162+#define ENTRY_BITPOS_QWORDS 0
163+/* descriptor index number (within a specified queue) */
164+#define ENTRY_BITPOS_DESCRIPTOR 10
165+/* state bit, fifo entry consumed by consumer */
166+#define ENTRY_BITPOS_C 22
167+/* state bit, fifo entry is occupied */
168+#define ENTRY_BITPOS_O 23
169+
170+#define ENTRY_BITS_QWORDS 10
171+#define ENTRY_BITS_DESCRIPTOR 12
172+#define ENTRY_BITS_C 1
173+#define ENTRY_BITS_O 1
174+#define ENTRY_BITS_TOTAL \
175+ (ENTRY_BITS_C + ENTRY_BITS_O + \
176+ ENTRY_BITS_QWORDS + ENTRY_BITS_DESCRIPTOR)
177+
178+/* extract various entry fields */
179+#define ENTRY_MASK ((1 << ENTRY_BITS_TOTAL) - 1)
180+#define ENTRY_MASK_C (((1 << ENTRY_BITS_C) - 1) << ENTRY_BITPOS_C)
181+#define ENTRY_MASK_O (((1 << ENTRY_BITS_O) - 1) << ENTRY_BITPOS_O)
182+#define ENTRY_MASK_QWORDS \
183+ (((1 << ENTRY_BITS_QWORDS) - 1) << ENTRY_BITPOS_QWORDS)
184+#define ENTRY_MASK_DESCRIPTOR \
185+ (((1 << ENTRY_BITS_DESCRIPTOR) - 1) << ENTRY_BITPOS_DESCRIPTOR)
186+
187+#define ENTRY_MASK_NOSTATE (ENTRY_MASK >> (ENTRY_BITS_C + ENTRY_BITS_O))
188+
189+#endif /* __HPILO_H */
drivers/misc/phantom.c+3−2
@@ -399,8 +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(phantom_class, &pdev->dev, MKDEV(phantom_major,
403− minor), "phantom%u", minor)))
402+ if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev,
403+ MKDEV(phantom_major, minor),
404+ NULL, "phantom%u", minor)))
404405 dev_err(&pdev->dev, "can't create device\n");
405406
406407 pci_set_drvdata(pdev, pht);
drivers/mtd/devices/block2mtd.c+5−3
@@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) · 240 unmodified lines
241241 {
242242 struct block_device *bdev;
243243 struct block2mtd_dev *dev;
244+ char *name;
244245
245246 if (!devname)
246247 return NULL;
@@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) · 32 unmodified lines
279280
280281 /* Setup the MTD structure */
281282 /* make the name contain the block device in */
282− dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
283+ name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
283284 GFP_KERNEL);
284− if (!dev->mtd.name)
285+ if (!name)
285286 goto devinit_err;
286287
287− sprintf(dev->mtd.name, "block2mtd: %s", devname);
288+ sprintf(name, "block2mtd: %s", devname);
289+ dev->mtd.name = name;
288290
289291 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
290292 dev->mtd.erasesize = erase_size;
drivers/mtd/mtdchar.c+6−3
@@ -28,10 +28,13 @@ static void mtd_notify_add(struct mtd_info* mtd) · 27 unmodified lines
2828 if (!mtd)
2929 return;
3030
31− device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), "mtd%d", mtd->index);
31+ device_create_drvdata(mtd_class, NULL,
32+ MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
33+ NULL, "mtd%d", mtd->index);
3234
33− device_create(mtd_class, NULL,
34− MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), "mtd%dro", mtd->index);
35+ device_create_drvdata(mtd_class, NULL,
36+ MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
37+ NULL, "mtd%dro", mtd->index);
3538 }
3639
3740 static void mtd_notify_remove(struct mtd_info* mtd)
drivers/net/3c59x.c+1−1
@@ -1010,7 +1010,7 @@ static int __devinit vortex_probe1(struct device *gendev, · 1009 unmodified lines
10101010 static int printed_version;
10111011 int retval, print_info;
10121012 struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx];
1013− char *print_name = "3c59x";
1013+ const char *print_name = "3c59x";
10141014 struct pci_dev *pdev = NULL;
10151015 struct eisa_device *edev = NULL;
10161016 DECLARE_MAC_BUF(mac);
drivers/net/arm/at91_ether.c+1−1
@@ -677,7 +677,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo · 676 unmodified lines
677677 {
678678 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
679679 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
680− strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
680+ strlcpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
681681 }
682682
683683 static const struct ethtool_ops at91ether_ethtool_ops = {
drivers/net/arm/ep93xx_eth.c+1−1
@@ -848,7 +848,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev) · 847 unmodified lines
848848
849849 ep->res = request_mem_region(pdev->resource[0].start,
850850 pdev->resource[0].end - pdev->resource[0].start + 1,
851− pdev->dev.bus_id);
851+ dev_name(&pdev->dev));
852852 if (ep->res == NULL) {
853853 dev_err(&pdev->dev, "Could not reserve memory region\n");
854854 err = -ENOMEM;
drivers/net/arm/etherh.c+3−3
@@ -535,7 +535,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec) · 534 unmodified lines
535535
536536 if (!ecard_readchunk(&cd, ec, 0xf5, 0)) {
537537 printk(KERN_ERR "%s: unable to read podule description string\n",
538− ec->dev.bus_id);
538+ dev_name(&ec->dev));
539539 goto no_addr;
540540 }
541541
@@ -554,7 +554,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec) · 12 unmodified lines
554554 }
555555
556556 printk(KERN_ERR "%s: unable to parse MAC address: %s\n",
557− ec->dev.bus_id, cd.d.string);
557+ dev_name(&ec->dev), cd.d.string);
558558
559559 no_addr:
560560 return -ENODEV;
@@ -585,7 +585,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i · 24 unmodified lines
585585 {
586586 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
587587 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
588− strlcpy(info->bus_info, dev->dev.parent->bus_id,
588+ strlcpy(info->bus_info, dev_name(dev->dev.parent),
589589 sizeof(info->bus_info));
590590 }
591591
drivers/net/ppp_generic.c+2−1
@@ -866,7 +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(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
869+ device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0),
870+ NULL, "ppp");
870871 }
871872
872873 out:
drivers/net/wan/cosa.c+3−3
@@ -397,9 +397,9 @@ static int __init cosa_init(void) · 396 unmodified lines
397397 err = PTR_ERR(cosa_class);
398398 goto out_chrdev;
399399 }
400− for (i=0; i<nr_cards; i++) {
401− device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i);
402− }
400+ for (i = 0; i < nr_cards; i++)
401+ device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i),
402+ NULL, "cosa%d", i);
403403 err = 0;
404404 goto out;
405405
drivers/pci/hotplug/acpiphp.h+2−2
@@ -36,7 +36,7 @@ · 35 unmodified lines
3636 #define _ACPIPHP_H
3737
3838 #include <linux/acpi.h>
39−#include <linux/kobject.h> /* for KOBJ_NAME_LEN */
39+#include <linux/kobject.h>
4040 #include <linux/mutex.h>
4141 #include <linux/pci_hotplug.h>
4242
@@ -51,7 +51,7 @@ · 8 unmodified lines
5151 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
5252
5353 /* name size which is used for entries in pcihpfs */
54−#define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
54+#define SLOT_NAME_SIZE 20 /* {_SUN} */
5555
5656 struct acpiphp_bridge;
5757 struct acpiphp_slot;
drivers/power/apm_power.c+1−1
@@ -78,7 +78,7 @@ static void find_main_battery(void) · 77 unmodified lines
7878 main_battery = NULL;
7979 bp.main = main_battery;
8080
81− error = class_for_each_device(power_supply_class, &bp,
81+ error = class_for_each_device(power_supply_class, NULL, &bp,
8282 __find_main_battery);
8383 if (error) {
8484 main_battery = bp.main;
drivers/power/power_supply_core.c+2−2
@@ -41,7 +41,7 @@ static void power_supply_changed_work(struct work_struct *work) · 40 unmodified lines
4141
4242 dev_dbg(psy->dev, "%s\n", __func__);
4343
44− class_for_each_device(power_supply_class, psy,
44+ class_for_each_device(power_supply_class, NULL, psy,
4545 __power_supply_changed_work);
4646
4747 power_supply_update_leds(psy);
@@ -79,7 +79,7 @@ int power_supply_am_i_supplied(struct power_supply *psy) · 31 unmodified lines
7979 {
8080 int error;
8181
82− error = class_for_each_device(power_supply_class, psy,
82+ error = class_for_each_device(power_supply_class, NULL, psy,
8383 __power_supply_am_i_supplied);
8484
8585 dev_dbg(psy->dev, "%s %d\n", __func__, error);
drivers/rtc/interface.c+1−1
@@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name) · 344 unmodified lines
345345 struct device *dev;
346346 struct rtc_device *rtc = NULL;
347347
348− dev = class_find_device(rtc_class, name, __rtc_match);
348+ dev = class_find_device(rtc_class, NULL, name, __rtc_match);
349349 if (dev)
350350 rtc = to_rtc_device(dev);
351351
drivers/s390/char/raw3270.c+8−6
@@ -1168,17 +1168,19 @@ static int raw3270_create_attributes(struct raw3270 *rp) · 1167 unmodified lines
11681168 if (rc)
11691169 goto out;
11701170
1171− rp->clttydev = device_create(class3270, &rp->cdev->dev,
1172− MKDEV(IBM_TTY3270_MAJOR, rp->minor),
1173− "tty%s", rp->cdev->dev.bus_id);
1171+ rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev,
1172+ MKDEV(IBM_TTY3270_MAJOR, rp->minor),
1173+ NULL,
1174+ "tty%s", rp->cdev->dev.bus_id);
11741175 if (IS_ERR(rp->clttydev)) {
11751176 rc = PTR_ERR(rp->clttydev);
11761177 goto out_ttydev;
11771178 }
11781179
1179− rp->cltubdev = device_create(class3270, &rp->cdev->dev,
1180− MKDEV(IBM_FS3270_MAJOR, rp->minor),
1181− "tub%s", rp->cdev->dev.bus_id);
1180+ rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev,
1181+ MKDEV(IBM_FS3270_MAJOR, rp->minor),
1182+ NULL,
1183+ "tub%s", rp->cdev->dev.bus_id);
11821184 if (!IS_ERR(rp->cltubdev))
11831185 goto out;
11841186
drivers/s390/char/tape_class.c+3−4
@@ -69,10 +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(tape_class, device,
73− tcd->char_device->dev,
74− "%s", tcd->device_name
75− );
72+ tcd->class_device = device_create_drvdata(tape_class, device,
73+ tcd->char_device->dev,
74+ NULL, "%s", tcd->device_name);
7675 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
7776 if (rc)
7877 goto fail_with_cdev;
drivers/s390/char/vmur.c+3−2
@@ -896,8 +896,9 @@ static int ur_set_online(struct ccw_device *cdev) · 895 unmodified lines
896896 goto fail_free_cdev;
897897 }
898898
899− urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
900− "%s", node_id);
899+ urd->device = device_create_drvdata(vmur_class, NULL,
900+ urd->char_device->dev, NULL,
901+ "%s", node_id);
901902 if (IS_ERR(urd->device)) {
902903 rc = PTR_ERR(urd->device);
903904 TRACE("ur_set_online: device_create rc=%d\n", rc);
drivers/sbus/sbus.c+3−3
@@ -78,7 +78,7 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde · 77 unmodified lines
7878 else
7979 sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
8080 sdev->ofdev.dev.bus = &sbus_bus_type;
81− sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node);
81+ dev_set_name(&sdev->ofdev.dev, "sbus[%08x]", dp->node);
8282
8383 if (of_device_register(&sdev->ofdev) != 0)
8484 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
@@ -257,11 +257,11 @@ static void __init build_one_sbus(struct device_node *dp, int num_sbus) · 172 unmodified lines
257257 sbus->ofdev.node = dp;
258258 sbus->ofdev.dev.parent = NULL;
259259 sbus->ofdev.dev.bus = &sbus_bus_type;
260− sprintf(sbus->ofdev.dev.bus_id, "sbus%d", num_sbus);
260+ dev_set_name(&sbus->ofdev.dev, "sbus%d", num_sbus);
261261
262262 if (of_device_register(&sbus->ofdev) != 0)
263263 printk(KERN_DEBUG "sbus: device registration error for %s!\n",
264− sbus->ofdev.dev.bus_id);
264+ dev_name(&sbus->ofdev.dev));
265265
266266 dev_dp = dp->child;
267267 while (dev_dp) {
drivers/scsi/dpt_i2o.c+2−2
@@ -271,8 +271,8 @@ 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(adpt_sysfs_class,
275− NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit),
274+ struct device *dev = device_create_drvdata(adpt_sysfs_class,
275+ NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
276276 "dpti%d", pHba->unit);
277277 if (IS_ERR(dev)) {
278278 printk(KERN_WARNING"dpti%d: unable to "
drivers/scsi/hosts.c+4−3
@@ -232,8 +232,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) · 231 unmodified lines
232232 }
233233
234234 if (shost->transportt->create_work_queue) {
235− snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
236− shost->host_no);
235+ snprintf(shost->work_q_name, sizeof(shost->work_q_name),
236+ "scsi_wq_%d", shost->host_no);
237237 shost->work_q = create_singlethread_workqueue(
238238 shost->work_q_name);
239239 if (!shost->work_q) {
@@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) · 226 unmodified lines
466466 struct device *cdev;
467467 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
468468
469− cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
469+ cdev = class_find_device(&shost_class, NULL, &hostnum,
470+ __scsi_host_match);
470471 if (cdev) {
471472 shost = scsi_host_get(class_to_shost(cdev));
472473 put_device(cdev);
drivers/scsi/scsi_transport_fc.c+5−4
@@ -417,15 +417,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev, · 416 unmodified lines
417417 fc_host->next_vport_number = 0;
418418 fc_host->npiv_vports_inuse = 0;
419419
420− snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d",
421− shost->host_no);
420+ snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
421+ "fc_wq_%d", shost->host_no);
422422 fc_host->work_q = create_singlethread_workqueue(
423423 fc_host->work_q_name);
424424 if (!fc_host->work_q)
425425 return -ENOMEM;
426426
427− snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d",
428− shost->host_no);
427+ snprintf(fc_host->devloss_work_q_name,
428+ sizeof(fc_host->devloss_work_q_name),
429+ "fc_dl_%d", shost->host_no);
429430 fc_host->devloss_work_q = create_singlethread_workqueue(
430431 fc_host->devloss_work_q_name);
431432 if (!fc_host->devloss_work_q) {
drivers/scsi/scsi_transport_iscsi.c+4−4
@@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size) · 169 unmodified lines
170170 int err;
171171
172172 for (id = 1; id < ISCSI_MAX_EPID; id++) {
173− dev = class_find_device(&iscsi_endpoint_class, &id,
173+ dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
174174 iscsi_match_epid);
175175 if (!dev)
176176 break;
@@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) · 45 unmodified lines
222222 struct iscsi_endpoint *ep;
223223 struct device *dev;
224224
225− dev = class_find_device(&iscsi_endpoint_class, &handle,
225+ dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
226226 iscsi_match_epid);
227227 if (!dev)
228228 return NULL;
@@ -247,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, · 18 unmodified lines
247247 atomic_set(&ihost->nr_scans, 0);
248248 mutex_init(&ihost->mutex);
249249
250− snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d",
251− shost->host_no);
250+ snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name),
251+ "iscsi_scan_%d", shost->host_no);
252252 ihost->scan_workq = create_singlethread_workqueue(
253253 ihost->scan_workq_name);
254254 if (!ihost->scan_workq)
drivers/spi/spi.c+1−1
@@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num) · 501 unmodified lines
502502 struct device *dev;
503503 struct spi_master *master = NULL;
504504
505− dev = class_find_device(&spi_master_class, &bus_num,
505+ dev = class_find_device(&spi_master_class, NULL, &bus_num,
506506 __spi_master_match);
507507 if (dev)
508508 master = container_of(dev, struct spi_master, dev);
drivers/spi/spidev.c+2−2
@@ -576,7 +576,8 @@ static int spidev_probe(struct spi_device *spi) · 575 unmodified lines
576576 struct device *dev;
577577
578578 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
579− dev = device_create(spidev_class, &spi->dev, spidev->devt,
579+ dev = device_create_drvdata(spidev_class, &spi->dev,
580+ spidev->devt, spidev,
580581 "spidev%d.%d",
581582 spi->master->bus_num, spi->chip_select);
582583 status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
@@ -586,7 +587,6 @@ static int spidev_probe(struct spi_device *spi) · 3 unmodified lines
586587 }
587588 if (status == 0) {
588589 set_bit(minor, minors);
589− spi_set_drvdata(spi, spidev);
590590 list_add(&spidev->device_entry, &device_list);
591591 }
592592 mutex_unlock(&device_list_lock);
drivers/uio/Kconfig+8−2
@@ -15,7 +15,7 @@ if UIO · 14 unmodified lines
1515
1616 config UIO_CIF
1717 tristate "generic Hilscher CIF Card driver"
18− depends on UIO && PCI
18+ depends on PCI
1919 default n
2020 help
2121 Driver for Hilscher CIF DeviceNet and Profibus cards. This
@@ -26,9 +26,15 @@ config UIO_CIF · 4 unmodified lines
2626 To compile this driver as a module, choose M here: the module
2727 will be called uio_cif.
2828
29+config UIO_PDRV
30+ tristate "Userspace I/O platform driver"
31+ help
32+ Generic platform driver for Userspace I/O devices.
33+
34+ If you don't know what to do here, say N.
35+
2936 config UIO_SMX
3037 tristate "SMX cryptengine UIO interface"
31− depends on UIO
3238 default n
3339 help
3440 Userspace IO interface to the Cryptography engine found on the
drivers/uio/Makefile+1−0
@@ -1,3 +1,4 @@
11 obj-$(CONFIG_UIO) += uio.o
22 obj-$(CONFIG_UIO_CIF) += uio_cif.o
3+obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
34 obj-$(CONFIG_UIO_SMX) += uio_smx.o
drivers/uio/uio.c+26−0
@@ -427,6 +427,31 @@ static ssize_t uio_read(struct file *filep, char __user *buf, · 426 unmodified lines
427427 return retval;
428428 }
429429
430+static ssize_t uio_write(struct file *filep, const char __user *buf,
431+ size_t count, loff_t *ppos)
432+{
433+ struct uio_listener *listener = filep->private_data;
434+ struct uio_device *idev = listener->dev;
435+ ssize_t retval;
436+ s32 irq_on;
437+
438+ if (idev->info->irq == UIO_IRQ_NONE)
439+ return -EIO;
440+
441+ if (count != sizeof(s32))
442+ return -EINVAL;
443+
444+ if (!idev->info->irqcontrol)
445+ return -ENOSYS;
446+
447+ if (copy_from_user(&irq_on, buf, count))
448+ return -EFAULT;
449+
450+ retval = idev->info->irqcontrol(idev->info, irq_on);
451+
452+ return retval ? retval : sizeof(s32);
453+}
454+
430455 static int uio_find_mem_index(struct vm_area_struct *vma)
431456 {
432457 int mi;
@@ -546,6 +571,7 @@ static const struct file_operations uio_fops = { · 113 unmodified lines
546571 .open = uio_open,
547572 .release = uio_release,
548573 .read = uio_read,
574+ .write = uio_write,
549575 .mmap = uio_mmap,
550576 .poll = uio_poll,
551577 .fasync = uio_fasync,
drivers/uio/uio_pdrv.c+118−0
@@ -0,0 +1,118 @@
1+/*
2+ * drivers/uio/uio_pdrv.c
3+ *
4+ * Copyright (C) 2008 by Digi International Inc.
5+ * All rights reserved.
6+ *
7+ * This program is free software; you can redistribute it and/or modify it
8+ * under the terms of the GNU General Public License version 2 as published by
9+ * the Free Software Foundation.
10+ */
11+#include <linux/platform_device.h>
12+#include <linux/uio_driver.h>
13+#include <linux/stringify.h>
14+
15+#define DRIVER_NAME "uio"
16+
17+struct uio_platdata {
18+ struct uio_info *uioinfo;
19+};
20+
21+static int uio_pdrv_probe(struct platform_device *pdev)
22+{
23+ struct uio_info *uioinfo = pdev->dev.platform_data;
24+ struct uio_platdata *pdata;
25+ struct uio_mem *uiomem;
26+ int ret = -ENODEV;
27+ int i;
28+
29+ if (!uioinfo || !uioinfo->name || !uioinfo->version) {
30+ dev_dbg(&pdev->dev, "%s: err_uioinfo\n", __func__);
31+ goto err_uioinfo;
32+ }
33+
34+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
35+ if (!pdata) {
36+ ret = -ENOMEM;
37+ dev_dbg(&pdev->dev, "%s: err_alloc_pdata\n", __func__);
38+ goto err_alloc_pdata;
39+ }
40+
41+ pdata->uioinfo = uioinfo;
42+
43+ uiomem = &uioinfo->mem[0];
44+
45+ for (i = 0; i < pdev->num_resources; ++i) {
46+ struct resource *r = &pdev->resource[i];
47+
48+ if (r->flags != IORESOURCE_MEM)
49+ continue;
50+
51+ if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) {
52+ dev_warn(&pdev->dev, "device has more than "
53+ __stringify(MAX_UIO_MAPS)
54+ " I/O memory resources.\n");
55+ break;
56+ }
57+
58+ uiomem->memtype = UIO_MEM_PHYS;
59+ uiomem->addr = r->start;
60+ uiomem->size = r->end - r->start + 1;
61+ ++uiomem;
62+ }
63+
64+ while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) {
65+ uiomem->size = 0;
66+ ++uiomem;
67+ }
68+
69+ pdata->uioinfo->priv = pdata;
70+
71+ ret = uio_register_device(&pdev->dev, pdata->uioinfo);
72+
73+ if (ret) {
74+ kfree(pdata);
75+err_alloc_pdata:
76+err_uioinfo:
77+ return ret;
78+ }
79+
80+ platform_set_drvdata(pdev, pdata);
81+
82+ return 0;
83+}
84+
85+static int uio_pdrv_remove(struct platform_device *pdev)
86+{
87+ struct uio_platdata *pdata = platform_get_drvdata(pdev);
88+
89+ uio_unregister_device(pdata->uioinfo);
90+
91+ return 0;
92+}
93+
94+static struct platform_driver uio_pdrv = {
95+ .probe = uio_pdrv_probe,
96+ .remove = uio_pdrv_remove,
97+ .driver = {
98+ .name = DRIVER_NAME,
99+ .owner = THIS_MODULE,
100+ },
101+};
102+
103+static int __init uio_pdrv_init(void)
104+{
105+ return platform_driver_register(&uio_pdrv);
106+}
107+
108+static void __exit uio_pdrv_exit(void)
109+{
110+ platform_driver_unregister(&uio_pdrv);
111+}
112+module_init(uio_pdrv_init);
113+module_exit(uio_pdrv_exit);
114+
115+MODULE_AUTHOR("Uwe Kleine-Koenig");
116+MODULE_DESCRIPTION("Userspace I/O platform driver");
117+MODULE_LICENSE("GPL");
118+MODULE_ALIAS("platform:" DRIVER_NAME);
drivers/usb/core/devio.c+8−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(usb_classdev_class, &dev->dev, dev->dev.devt,
1733− "usbdev%d.%d", dev->bus->busnum,
1734− dev->devnum);
1732+ cldev = device_create_drvdata(usb_classdev_class, &dev->dev,
1733+ dev->dev.devt, NULL, "usbdev%d.%d",
1734+ dev->bus->busnum, dev->devnum);
17351735 if (IS_ERR(cldev))
17361736 return PTR_ERR(cldev);
17371737 dev->usb_classdev = cldev;
@@ -1792,6 +1792,11 @@ int __init usb_devio_init(void) · 54 unmodified lines
17921792 usb_classdev_class = NULL;
17931793 goto out;
17941794 }
1795+ /* devices of this class shadow the major:minor of their parent
1796+ * device, so clear ->dev_kobj to prevent adding duplicate entries
1797+ * to /sys/dev
1798+ */
1799+ usb_classdev_class->dev_kobj = NULL;
17951800
17961801 usb_register_notify(&usbdev_nb);
17971802 #endif
drivers/usb/core/file.c+3−2
@@ -196,8 +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(usb_class->class, &intf->dev,
200− MKDEV(USB_MAJOR, minor), "%s", temp);
199+ intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev,
200+ MKDEV(USB_MAJOR, minor), NULL,
201+ "%s", temp);
201202 if (IS_ERR(intf->usb_dev)) {
202203 down_write(&minor_rwsem);
203204 usb_minors[intf->minor] = NULL;
drivers/usb/gadget/printer.c+2−2
@@ -1360,8 +1360,8 @@ printer_bind(struct usb_gadget *gadget) · 1359 unmodified lines
13601360
13611361
13621362 /* Setup the sysfs files for the printer gadget. */
1363− dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno,
1364− "g_printer");
1363+ dev->pdev = device_create_drvdata(usb_gadget_class, NULL,
1364+ g_printer_devno, NULL, "g_printer");
13651365 if (IS_ERR(dev->pdev)) {
13661366 ERROR(dev, "Failed to create device: g_printer\n");
13671367 goto fail;
drivers/usb/mon/mon_bin.c+3−2
@@ -1162,8 +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(mon_bin_class, ubus? ubus->controller: NULL,
1166− MKDEV(MAJOR(mon_bin_dev0), minor), "usbmon%d", minor);
1165+ dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL,
1166+ MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
1167+ "usbmon%d", minor);
11671168 if (IS_ERR(dev))
11681169 return 0;
11691170
drivers/video/aty/aty128fb.c+1−1
@@ -1872,7 +1872,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i · 1871 unmodified lines
18721872 struct fb_info *info = pci_get_drvdata(pdev);
18731873 struct aty128fb_par *par = info->par;
18741874 struct fb_var_screeninfo var;
1875− char video_card[DEVICE_NAME_SIZE];
1875+ char video_card[50];
18761876 u8 chip_rev;
18771877 u32 dac;
18781878
drivers/video/aty/radeonfb.h+1−1
@@ -289,7 +289,7 @@ struct radeonfb_info { · 288 unmodified lines
289289 struct radeon_regs state;
290290 struct radeon_regs init_state;
291291
292− char name[DEVICE_NAME_SIZE];
292+ char name[50];
293293
294294 unsigned long mmio_base_phys;
295295 unsigned long fb_base_phys;
drivers/video/console/fbcon.c+2−1
@@ -3586,7 +3586,8 @@ static int __init fb_console_init(void) · 3585 unmodified lines
35863586
35873587 acquire_console_sem();
35883588 fb_register_client(&fbcon_event_notifier);
3589− fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon");
3589+ fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0),
3590+ NULL, "fbcon");
35903591
35913592 if (IS_ERR(fbcon_device)) {
35923593 printk(KERN_WARNING "Unable to create device "
drivers/video/fbmem.c+3−2
@@ -1439,8 +1439,9 @@ register_framebuffer(struct fb_info *fb_info) · 1438 unmodified lines
14391439 break;
14401440 fb_info->node = i;
14411441
1442− fb_info->dev = device_create(fb_class, fb_info->device,
1443− MKDEV(FB_MAJOR, i), "fb%d", i);
1442+ fb_info->dev = device_create_drvdata(fb_class, fb_info->device,
1443+ MKDEV(FB_MAJOR, i), NULL,
1444+ "fb%d", i);
14441445 if (IS_ERR(fb_info->dev)) {
14451446 /* Not fatal */
14461447 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
drivers/xen/balloon.c+1−0
@@ -610,6 +610,7 @@ static ssize_t show_target_kb(struct sys_device *dev, char *buf) · 609 unmodified lines
610610 }
611611
612612 static ssize_t store_target_kb(struct sys_device *dev,
613+ struct sysdev_attribute *attr,
613614 const char *buf,
614615 size_t count)
615616 {
fs/coda/psdev.c+3−2
@@ -362,8 +362,9 @@ 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(coda_psdev_class, NULL,
366− MKDEV(CODA_PSDEV_MAJOR,i), "cfs%d", i);
365+ device_create_drvdata(coda_psdev_class, NULL,
366+ MKDEV(CODA_PSDEV_MAJOR, i),
367+ NULL, "cfs%d", i);
367368 coda_sysctl_init();
368369 goto out;
369370
fs/debugfs/inode.c+96−18
@@ -309,6 +309,31 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, · 308 unmodified lines
309309 }
310310 EXPORT_SYMBOL_GPL(debugfs_create_symlink);
311311
312+static void __debugfs_remove(struct dentry *dentry, struct dentry *parent)
313+{
314+ int ret = 0;
315+
316+ if (debugfs_positive(dentry)) {
317+ if (dentry->d_inode) {
318+ dget(dentry);
319+ switch (dentry->d_inode->i_mode & S_IFMT) {
320+ case S_IFDIR:
321+ ret = simple_rmdir(parent->d_inode, dentry);
322+ break;
323+ case S_IFLNK:
324+ kfree(dentry->d_inode->i_private);
325+ /* fall through */
326+ default:
327+ simple_unlink(parent->d_inode, dentry);
328+ break;
329+ }
330+ if (!ret)
331+ d_delete(dentry);
332+ dput(dentry);
333+ }
334+ }
335+}
336+
312337 /**
313338 * debugfs_remove - removes a file or directory from the debugfs filesystem
314339 * @dentry: a pointer to a the dentry of the file or directory to be
@@ -325,7 +350,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_symlink); · 10 unmodified lines
325350 void debugfs_remove(struct dentry *dentry)
326351 {
327352 struct dentry *parent;
328− int ret = 0;
329353
330354 if (!dentry)
331355 return;
@@ -335,29 +359,83 @@ void debugfs_remove(struct dentry *dentry) · 3 unmodified lines
335359 return;
336360
337361 mutex_lock(&parent->d_inode->i_mutex);
338− if (debugfs_positive(dentry)) {
339− if (dentry->d_inode) {
340− dget(dentry);
341− switch (dentry->d_inode->i_mode & S_IFMT) {
342− case S_IFDIR:
343− ret = simple_rmdir(parent->d_inode, dentry);
344− break;
345− case S_IFLNK:
346− kfree(dentry->d_inode->i_private);
347− /* fall through */
348− default:
349− simple_unlink(parent->d_inode, dentry);
362+ __debugfs_remove(dentry, parent);
363+ mutex_unlock(&parent->d_inode->i_mutex);
364+ simple_release_fs(&debugfs_mount, &debugfs_mount_count);
365+}
366+EXPORT_SYMBOL_GPL(debugfs_remove);
367+
368+/**
369+ * debugfs_remove_recursive - recursively removes a directory
370+ * @dentry: a pointer to a the dentry of the directory to be removed.
371+ *
372+ * This function recursively removes a directory tree in debugfs that
373+ * was previously created with a call to another debugfs function
374+ * (like debugfs_create_file() or variants thereof.)
375+ *
376+ * This function is required to be called in order for the file to be
377+ * removed, no automatic cleanup of files will happen when a module is
378+ * removed, you are responsible here.
379+ */
380+void debugfs_remove_recursive(struct dentry *dentry)
381+{
382+ struct dentry *child;
383+ struct dentry *parent;
384+
385+ if (!dentry)
386+ return;
387+
388+ parent = dentry->d_parent;
389+ if (!parent || !parent->d_inode)
390+ return;
391+
392+ parent = dentry;
393+ mutex_lock(&parent->d_inode->i_mutex);
394+
395+ while (1) {
396+ /*
397+ * When all dentries under "parent" has been removed,
398+ * walk up the tree until we reach our starting point.
399+ */
400+ if (list_empty(&parent->d_subdirs)) {
401+ mutex_unlock(&parent->d_inode->i_mutex);
402+ if (parent == dentry)
350403 break;
351− }
352− if (!ret)
353− d_delete(dentry);
354− dput(dentry);
404+ parent = parent->d_parent;
405+ mutex_lock(&parent->d_inode->i_mutex);
406+ }
407+ child = list_entry(parent->d_subdirs.next, struct dentry,
408+ d_u.d_child);
409+
410+ /*
411+ * If "child" isn't empty, walk down the tree and
412+ * remove all its descendants first.
413+ */
414+ if (!list_empty(&child->d_subdirs)) {
415+ mutex_unlock(&parent->d_inode->i_mutex);
416+ parent = child;
417+ mutex_lock(&parent->d_inode->i_mutex);
418+ continue;
355419 }
420+ __debugfs_remove(child, parent);
421+ if (parent->d_subdirs.next == &child->d_u.d_child) {
422+ /*
423+ * Avoid infinite loop if we fail to remove
424+ * one dentry.
425+ */
426+ mutex_unlock(&parent->d_inode->i_mutex);
427+ break;
428+ }
429+ simple_release_fs(&debugfs_mount, &debugfs_mount_count);
356430 }
431+
432+ parent = dentry->d_parent;
433+ mutex_lock(&parent->d_inode->i_mutex);
434+ __debugfs_remove(dentry, parent);
357435 mutex_unlock(&parent->d_inode->i_mutex);
358436 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
359437 }
360−EXPORT_SYMBOL_GPL(debugfs_remove);
438+EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
361439
362440 /**
363441 * debugfs_rename - rename a file/directory in the debugfs filesystem
fs/partitions/check.c+1−1
@@ -401,7 +401,7 @@ void register_disk(struct gendisk *disk) · 400 unmodified lines
401401 disk->dev.parent = disk->driverfs_dev;
402402 disk->dev.devt = MKDEV(disk->major, disk->first_minor);
403403
404− strlcpy(disk->dev.bus_id, disk->disk_name, KOBJ_NAME_LEN);
404+ strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE);
405405 /* ewww... some of these buggers have / in the name... */
406406 s = strchr(disk->dev.bus_id, '/');
407407 if (s)
fs/sysfs/dir.c+35−2
@@ -398,7 +398,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 397 unmodified lines
398398 }
399399
400400 /**
401− * sysfs_add_one - add sysfs_dirent to parent
401+ * __sysfs_add_one - add sysfs_dirent to parent without warning
402402 * @acxt: addrm context to use
403403 * @sd: sysfs_dirent to be added
404404 *
@@ -417,7 +417,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 12 unmodified lines
417417 * 0 on success, -EEXIST if entry with the given name already
418418 * exists.
419419 */
420−int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
420+int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
421421 {
422422 if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
423423 return -EEXIST;
@@ -434,6 +434,39 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) · 10 unmodified lines
434434 return 0;
435435 }
436436
437+/**
438+ * sysfs_add_one - add sysfs_dirent to parent
439+ * @acxt: addrm context to use
440+ * @sd: sysfs_dirent to be added
441+ *
442+ * Get @acxt->parent_sd and set sd->s_parent to it and increment
443+ * nlink of parent inode if @sd is a directory and link into the
444+ * children list of the parent.
445+ *
446+ * This function should be called between calls to
447+ * sysfs_addrm_start() and sysfs_addrm_finish() and should be
448+ * passed the same @acxt as passed to sysfs_addrm_start().
449+ *
450+ * LOCKING:
451+ * Determined by sysfs_addrm_start().
452+ *
453+ * RETURNS:
454+ * 0 on success, -EEXIST if entry with the given name already
455+ * exists.
456+ */
457+int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
458+{
459+ int ret;
460+
461+ ret = __sysfs_add_one(acxt, sd);
462+ if (ret == -EEXIST) {
463+ printk(KERN_WARNING "sysfs: duplicate filename '%s' "
464+ "can not be created\n", sd->s_name);
465+ WARN_ON(1);
466+ }
467+ return ret;
468+}
469+
437470 /**
438471 * sysfs_remove_one - remove sysfs_dirent from parent
439472 * @acxt: addrm context to use
fs/sysfs/file.c+4−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/kobject.h>
1515 #include <linux/kallsyms.h>
1616 #include <linux/slab.h>
17+#include <linux/fsnotify.h>
1718 #include <linux/namei.h>
1819 #include <linux/poll.h>
1920 #include <linux/list.h>
@@ -585,9 +586,11 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) · 565 unmodified lines
585586
586587 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
587588 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
588− rc = notify_change(victim, &newattrs);
589+ newattrs.ia_ctime = current_fs_time(inode->i_sb);
590+ rc = sysfs_setattr(victim, &newattrs);
589591
590592 if (rc == 0) {
593+ fsnotify_change(victim, newattrs.ia_valid);
591594 mutex_lock(&sysfs_mutex);
592595 victim_sd->s_mode = newattrs.ia_mode;
593596 mutex_unlock(&sysfs_mutex);
fs/sysfs/symlink.c+33−8
@@ -19,13 +19,8 @@ · 18 unmodified lines
1919
2020 #include "sysfs.h"
2121
22−/**
23− * sysfs_create_link - create symlink between two objects.
24− * @kobj: object whose directory we're creating the link in.
25− * @target: object we're pointing to.
26− * @name: name of the symlink.
27− */
28−int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
22+static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
23+ const char *name, int warn)
2924 {
3025 struct sysfs_dirent *parent_sd = NULL;
3126 struct sysfs_dirent *target_sd = NULL;
@@ -65,7 +60,10 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char · 33 unmodified lines
6560 target_sd = NULL; /* reference is now owned by the symlink */
6661
6762 sysfs_addrm_start(&acxt, parent_sd);
68− error = sysfs_add_one(&acxt, sd);
63+ if (warn)
64+ error = sysfs_add_one(&acxt, sd);
65+ else
66+ error = __sysfs_add_one(&acxt, sd);
6967 sysfs_addrm_finish(&acxt);
7068
7169 if (error)
@@ -79,6 +77,33 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char · 7 unmodified lines
7977 return error;
8078 }
8179
80+/**
81+ * sysfs_create_link - create symlink between two objects.
82+ * @kobj: object whose directory we're creating the link in.
83+ * @target: object we're pointing to.
84+ * @name: name of the symlink.
85+ */
86+int sysfs_create_link(struct kobject *kobj, struct kobject *target,
87+ const char *name)
88+{
89+ return sysfs_do_create_link(kobj, target, name, 1);
90+}
91+
92+/**
93+ * sysfs_create_link_nowarn - create symlink between two objects.
94+ * @kobj: object whose directory we're creating the link in.
95+ * @target: object we're pointing to.
96+ * @name: name of the symlink.
97+ *
98+ * This function does the same as sysf_create_link(), but it
99+ * doesn't warn if the link already exists.
100+ */
101+int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target,
102+ const char *name)
103+{
104+ return sysfs_do_create_link(kobj, target, name, 0);
105+}
106+
82107 /**
83108 * sysfs_remove_link - remove symlink in object's directory.
84109 * @kobj: object we're acting for.
fs/sysfs/sysfs.h+1−0
@@ -107,6 +107,7 @@ struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd); · 106 unmodified lines
107107 void sysfs_put_active_two(struct sysfs_dirent *sd);
108108 void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
109109 struct sysfs_dirent *parent_sd);
110+int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
110111 int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
111112 void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
112113 void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
include/linux/debugfs.h+4−0
@@ -44,6 +44,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, · 43 unmodified lines
4444 const char *dest);
4545
4646 void debugfs_remove(struct dentry *dentry);
47+void debugfs_remove_recursive(struct dentry *dentry);
4748
4849 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
4950 struct dentry *new_dir, const char *new_name);
@@ -101,6 +102,9 @@ static inline struct dentry *debugfs_create_symlink(const char *name, · 51 unmodified lines
101102 static inline void debugfs_remove(struct dentry *dentry)
102103 { }
103104
105+static inline void debugfs_remove_recursive(struct dentry *dentry)
106+{ }
107+
104108 static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
105109 struct dentry *new_dir, char *new_name)
106110 {
include/linux/device.h+36−22
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/kobject.h>
1717 #include <linux/klist.h>
1818 #include <linux/list.h>
19+#include <linux/lockdep.h>
1920 #include <linux/compiler.h>
2021 #include <linux/types.h>
2122 #include <linux/module.h>
@@ -24,17 +25,13 @@ · 2 unmodified lines
2425 #include <asm/atomic.h>
2526 #include <asm/device.h>
2627
27−#define DEVICE_NAME_SIZE 50
28−/* DEVICE_NAME_HALF is really less than half to accommodate slop */
29−#define DEVICE_NAME_HALF __stringify(20)
30−#define DEVICE_ID_SIZE 32
31−#define BUS_ID_SIZE KOBJ_NAME_LEN
32−
28+#define BUS_ID_SIZE 20
3329
3430 struct device;
3531 struct device_driver;
3632 struct driver_private;
3733 struct class;
34+struct class_private;
3835 struct bus_type;
3936 struct bus_type_private;
4037
@@ -186,13 +183,9 @@ struct class { · 145 unmodified lines
186183 const char *name;
187184 struct module *owner;
188185
189− struct kset subsys;
190− struct list_head devices;
191− struct list_head interfaces;
192− struct kset class_dirs;
193− struct semaphore sem; /* locks children, devices, interfaces */
194186 struct class_attribute *class_attrs;
195187 struct device_attribute *dev_attrs;
188+ struct kobject *dev_kobj;
196189
197190 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
198191
@@ -203,13 +196,28 @@ struct class { · 4 unmodified lines
203196 int (*resume)(struct device *dev);
204197
205198 struct pm_ops *pm;
199+ struct class_private *p;
206200 };
207201
208−extern int __must_check class_register(struct class *class);
202+extern struct kobject *sysfs_dev_block_kobj;
203+extern struct kobject *sysfs_dev_char_kobj;
204+extern int __must_check __class_register(struct class *class,
205+ struct lock_class_key *key);
209206 extern void class_unregister(struct class *class);
210−extern int class_for_each_device(struct class *class, void *data,
207+
208+/* This is a #define to keep the compiler from merging different
209+ * instances of the __key variable */
210+#define class_register(class) \
211+({ \
212+ static struct lock_class_key __key; \
213+ __class_register(class, &__key); \
214+})
215+
216+extern int class_for_each_device(struct class *class, struct device *start,
217+ void *data,
211218 int (*fn)(struct device *dev, void *data));
212−extern struct device *class_find_device(struct class *class, void *data,
219+extern struct device *class_find_device(struct class *class,
220+ struct device *start, void *data,
213221 int (*match)(struct device *, void *));
214222
215223 struct class_attribute {
@@ -237,9 +245,19 @@ struct class_interface { · 21 unmodified lines
237245 extern int __must_check class_interface_register(struct class_interface *);
238246 extern void class_interface_unregister(struct class_interface *);
239247
240−extern struct class *class_create(struct module *owner, const char *name);
248+extern struct class * __must_check __class_create(struct module *owner,
249+ const char *name,
250+ struct lock_class_key *key);
241251 extern void class_destroy(struct class *cls);
242252
253+/* This is a #define to keep the compiler from merging different
254+ * instances of the __key variable */
255+#define class_create(owner, name) \
256+({ \
257+ static struct lock_class_key __key; \
258+ __class_create(owner, name, &__key); \
259+})
260+
243261 /*
244262 * The type of device, "struct device" is embedded in. A class
245263 * or bus can contain devices of different types
@@ -468,14 +486,10 @@ extern struct device *device_create_vargs(struct class *cls, · 222 unmodified lines
468486 const char *fmt,
469487 va_list vargs);
470488 extern struct device *device_create(struct class *cls, struct device *parent,
471− dev_t devt, const char *fmt, ...)
472− __attribute__((format(printf, 4, 5)));
473−extern struct device *device_create_drvdata(struct class *cls,
474− struct device *parent,
475− dev_t devt,
476− void *drvdata,
477− const char *fmt, ...)
489+ dev_t devt, void *drvdata,
490+ const char *fmt, ...)
478491 __attribute__((format(printf, 5, 6)));
492+#define device_create_drvdata device_create
479493 extern void device_destroy(struct class *cls, dev_t devt);
480494
481495 /*
include/linux/eisa.h+1−1
@@ -40,7 +40,7 @@ struct eisa_device { · 39 unmodified lines
4040 u64 dma_mask;
4141 struct device dev; /* generic device */
4242 #ifdef CONFIG_EISA_NAMES
43− char pretty_name[DEVICE_NAME_SIZE];
43+ char pretty_name[50];
4444 #endif
4545 };
4646
include/linux/kobject.h+1−2
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 #include <linux/wait.h>
2727 #include <asm/atomic.h>
2828
29−#define KOBJ_NAME_LEN 20
3029 #define UEVENT_HELPER_PATH_LEN 256
3130 #define UEVENT_NUM_ENVP 32 /* number of env pointers */
3231 #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
@@ -59,12 +58,12 @@ enum kobject_action { · 26 unmodified lines
5958
6059 struct kobject {
6160 const char *name;
62− struct kref kref;
6361 struct list_head entry;
6462 struct kobject *parent;
6563 struct kset *kset;
6664 struct kobj_type *ktype;
6765 struct sysfs_dirent *sd;
66+ struct kref kref;
6867 unsigned int state_initialized:1;
6968 unsigned int state_in_sysfs:1;
7069 unsigned int state_add_uevent_sent:1;
include/linux/mtd/map.h+1−1
@@ -189,7 +189,7 @@ typedef union { · 188 unmodified lines
189189 */
190190
191191 struct map_info {
192− char *name;
192+ const char *name;
193193 unsigned long size;
194194 resource_size_t phys;
195195 #define NO_XIP (-1UL)
include/linux/mtd/mtd.h+1−1
@@ -121,7 +121,7 @@ struct mtd_info { · 120 unmodified lines
121121 u_int32_t oobavail; // Available OOB bytes per block
122122
123123 // Kernel-only stuff starts here.
124− char *name;
124+ const char *name;
125125 int index;
126126
127127 /* ecc layout structure pointer - read only ! */
include/linux/spi/spi.h+1−1
@@ -733,7 +733,7 @@ struct spi_board_info { · 732 unmodified lines
733733 * controller_data goes to spi_device.controller_data,
734734 * irq is copied too
735735 */
736− char modalias[KOBJ_NAME_LEN];
736+ char modalias[32];
737737 const void *platform_data;
738738 void *controller_data;
739739 int irq;
include/linux/sysdev.h+37−2
@@ -99,8 +99,9 @@ extern void sysdev_unregister(struct sys_device *); · 98 unmodified lines
9999
100100 struct sysdev_attribute {
101101 struct attribute attr;
102− ssize_t (*show)(struct sys_device *, char *);
103− ssize_t (*store)(struct sys_device *, const char *, size_t);
102+ ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *);
103+ ssize_t (*store)(struct sys_device *, struct sysdev_attribute *,
104+ const char *, size_t);
104105 };
105106
106107
@@ -118,4 +119,38 @@ struct sysdev_attribute { · 11 unmodified lines
118119 extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
119120 extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
120121
122+struct sysdev_ext_attribute {
123+ struct sysdev_attribute attr;
124+ void *var;
125+};
126+
127+/*
128+ * Support for simple variable sysdev attributes.
129+ * The pointer to the variable is stored in a sysdev_ext_attribute
130+ */
131+
132+/* Add more types as needed */
133+
134+extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *,
135+ char *);
136+extern ssize_t sysdev_store_ulong(struct sys_device *,
137+ struct sysdev_attribute *, const char *, size_t);
138+extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *,
139+ char *);
140+extern ssize_t sysdev_store_int(struct sys_device *,
141+ struct sysdev_attribute *, const char *, size_t);
142+
143+#define _SYSDEV_ULONG_ATTR(_name, _mode, _var) \
144+ { _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \
145+ &(_var) }
146+#define SYSDEV_ULONG_ATTR(_name, _mode, _var) \
147+ struct sysdev_ext_attribute attr_##_name = \
148+ _SYSDEV_ULONG_ATTR(_name, _mode, _var);
149+#define _SYSDEV_INT_ATTR(_name, _mode, _var) \
150+ { _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \
151+ &(_var) }
152+#define SYSDEV_INT_ATTR(_name, _mode, _var) \
153+ struct sysdev_ext_attribute attr_##_name = \
154+ _SYSDEV_INT_ATTR(_name, _mode, _var);
155+
121156 #endif /* _SYSDEV_H_ */
include/linux/sysfs.h+10−0
@@ -101,6 +101,9 @@ void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); · 100 unmodified lines
101101
102102 int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
103103 const char *name);
104+int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
105+ struct kobject *target,
106+ const char *name);
104107 void sysfs_remove_link(struct kobject *kobj, const char *name);
105108
106109 int __must_check sysfs_create_group(struct kobject *kobj,
@@ -180,6 +183,13 @@ static inline int sysfs_create_link(struct kobject *kobj, · 73 unmodified lines
180183 return 0;
181184 }
182185
186+static inline int sysfs_create_link_nowarn(struct kobject *kobj,
187+ struct kobject *target,
188+ const char *name)
189+{
190+ return 0;
191+}
192+
183193 static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
184194 {
185195 }
include/linux/uio_driver.h+5−3
@@ -36,7 +36,7 @@ struct uio_mem { · 35 unmodified lines
3636 struct uio_map *map;
3737 };
3838
39−#define MAX_UIO_MAPS 5
39+#define MAX_UIO_MAPS 5
4040
4141 struct uio_device;
4242
@@ -53,6 +53,7 @@ struct uio_device; · 10 unmodified lines
5353 * @mmap: mmap operation for this uio device
5454 * @open: open operation for this uio device
5555 * @release: release operation for this uio device
56+ * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX
5657 */
5758 struct uio_info {
5859 struct uio_device *uio_dev;
@@ -66,6 +67,7 @@ struct uio_info { · 7 unmodified lines
6667 int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
6768 int (*open)(struct uio_info *info, struct inode *inode);
6869 int (*release)(struct uio_info *info, struct inode *inode);
70+ int (*irqcontrol)(struct uio_info *info, s32 irq_on);
6971 };
7072
7173 extern int __must_check
@@ -80,11 +82,11 @@ static inline int __must_check · 8 unmodified lines
8082 extern void uio_unregister_device(struct uio_info *info);
8183 extern void uio_event_notify(struct uio_info *info);
8284
83−/* defines for uio_device->irq */
85+/* defines for uio_info->irq */
8486 #define UIO_IRQ_CUSTOM -1
8587 #define UIO_IRQ_NONE -2
8688
87−/* defines for uio_device->memtype */
89+/* defines for uio_mem->memtype */
8890 #define UIO_MEM_NONE 0
8991 #define UIO_MEM_PHYS 1
9092 #define UIO_MEM_LOGICAL 2
include/scsi/scsi_host.h+1−1
@@ -623,7 +623,7 @@ struct Scsi_Host { · 622 unmodified lines
623623 /*
624624 * Optional work queue to be utilized by the transport
625625 */
626− char work_q_name[KOBJ_NAME_LEN];
626+ char work_q_name[20];
627627 struct workqueue_struct *work_q;
628628
629629 /*
include/scsi/scsi_transport_fc.h+2−2
@@ -489,9 +489,9 @@ struct fc_host_attrs { · 488 unmodified lines
489489 u16 npiv_vports_inuse;
490490
491491 /* work queues for rport state manipulation */
492− char work_q_name[KOBJ_NAME_LEN];
492+ char work_q_name[20];
493493 struct workqueue_struct *work_q;
494− char devloss_work_q_name[KOBJ_NAME_LEN];
494+ char devloss_work_q_name[20];
495495 struct workqueue_struct *devloss_work_q;
496496 };
497497
include/scsi/scsi_transport_iscsi.h+1−1
@@ -198,7 +198,7 @@ struct iscsi_cls_host { · 197 unmodified lines
198198 atomic_t nr_scans;
199199 struct mutex mutex;
200200 struct workqueue_struct *scan_workq;
201− char scan_workq_name[KOBJ_NAME_LEN];
201+ char scan_workq_name[20];
202202 };
203203
204204 extern void iscsi_host_for_each_session(struct Scsi_Host *shost,
kernel/rtmutex-tester.c+4−3
@@ -297,8 +297,8 @@ static int test_func(void *data) · 296 unmodified lines
297297 *
298298 * opcode:data
299299 */
300−static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
301− size_t count)
300+static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr,
301+ const char *buf, size_t count)
302302 {
303303 struct sched_param schedpar;
304304 struct test_thread_data *td;
@@ -360,7 +360,8 @@ static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, · 55 unmodified lines
360360 * @dev: thread to query
361361 * @buf: char buffer to be filled with thread status info
362362 */
363−static ssize_t sysfs_test_status(struct sys_device *dev, char *buf)
363+static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr,
364+ char *buf)
364365 {
365366 struct test_thread_data *td;
366367 struct task_struct *tsk;
kernel/sched.c+6−2
@@ -7737,11 +7737,13 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt) · 7736 unmodified lines
77377737 }
77387738
77397739 #ifdef CONFIG_SCHED_MC
7740−static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page)
7740+static ssize_t sched_mc_power_savings_show(struct sys_device *dev,
7741+ struct sysdev_attribute *attr, char *page)
77417742 {
77427743 return sprintf(page, "%u\n", sched_mc_power_savings);
77437744 }
77447745 static ssize_t sched_mc_power_savings_store(struct sys_device *dev,
7746+ struct sysdev_attribute *attr,
77457747 const char *buf, size_t count)
77467748 {
77477749 return sched_power_savings_store(buf, count, 0);
@@ -7751,11 +7753,13 @@ static SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show, · 3 unmodified lines
77517753 #endif
77527754
77537755 #ifdef CONFIG_SCHED_SMT
7754−static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page)
7756+static ssize_t sched_smt_power_savings_show(struct sys_device *dev,
7757+ struct sysdev_attribute *attr, char *page)
77557758 {
77567759 return sprintf(page, "%u\n", sched_smt_power_savings);
77577760 }
77587761 static ssize_t sched_smt_power_savings_store(struct sys_device *dev,
7762+ struct sysdev_attribute *attr,
77597763 const char *buf, size_t count)
77607764 {
77617765 return sched_power_savings_store(buf, count, 1);
kernel/time/clocksource.c+6−2
@@ -376,7 +376,8 @@ void clocksource_unregister(struct clocksource *cs) · 375 unmodified lines
376376 * Provides sysfs interface for listing current clocksource.
377377 */
378378 static ssize_t
379−sysfs_show_current_clocksources(struct sys_device *dev, char *buf)
379+sysfs_show_current_clocksources(struct sys_device *dev,
380+ struct sysdev_attribute *attr, char *buf)
380381 {
381382 ssize_t count = 0;
382383
@@ -397,6 +398,7 @@ sysfs_show_current_clocksources(struct sys_device *dev, char *buf) · 14 unmodified lines
397398 * clocksource selction.
398399 */
399400 static ssize_t sysfs_override_clocksource(struct sys_device *dev,
401+ struct sysdev_attribute *attr,
400402 const char *buf, size_t count)
401403 {
402404 struct clocksource *ovr = NULL;
@@ -449,7 +451,9 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev, · 46 unmodified lines
449451 * Provides sysfs interface for listing registered clocksources
450452 */
451453 static ssize_t
452−sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
454+sysfs_show_available_clocksources(struct sys_device *dev,
455+ struct sysdev_attribute *attr,
456+ char *buf)
453457 {
454458 struct clocksource *src;
455459 ssize_t count = 0;
lib/Kconfig.debug+3−0
@@ -74,6 +74,9 @@ config DEBUG_FS · 73 unmodified lines
7474 debugging files into. Enable this option to be able to read and
7575 write to these files.
7676
77+ For detailed documentation on the debugfs API, see
78+ Documentation/DocBook/filesystems.
79+
7780 If unsure, say N.
7881
7982 config HEADERS_CHECK
lib/kobject.c+8−2
@@ -216,13 +216,19 @@ static int kobject_add_internal(struct kobject *kobj) · 215 unmodified lines
216216 static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
217217 va_list vargs)
218218 {
219− /* Free the old name, if necessary. */
220− kfree(kobj->name);
219+ const char *old_name = kobj->name;
220+ char *s;
221221
222222 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
223223 if (!kobj->name)
224224 return -ENOMEM;
225225
226+ /* ewww... some of these buggers have '/' in the name ... */
227+ s = strchr(kobj->name, '/');
228+ if (s)
229+ s[0] = '!';
230+
231+ kfree(old_name);
226232 return 0;
227233 }
228234
lib/kobject_uevent.c+2−1
@@ -245,7 +245,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, · 244 unmodified lines
245245 if (retval)
246246 goto exit;
247247
248− call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
248+ retval = call_usermodehelper(argv[0], argv,
249+ env->envp, UMH_WAIT_EXEC);
249250 }
250251
251252 exit:
net/bluetooth/hci_sysfs.c+0−7
@@ -398,10 +398,6 @@ int hci_register_sysfs(struct hci_dev *hdev) · 397 unmodified lines
398398 if (device_create_file(dev, bt_attrs[i]) < 0)
399399 BT_ERR("Failed to create device attribute");
400400
401− if (sysfs_create_link(&bt_class->subsys.kobj,
402− &dev->kobj, kobject_name(&dev->kobj)) < 0)
403− BT_ERR("Failed to create class symlink");
404−
405401 return 0;
406402 }
407403
@@ -409,9 +405,6 @@ void hci_unregister_sysfs(struct hci_dev *hdev) · 1 unmodified line
409405 {
410406 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
411407
412− sysfs_remove_link(&bt_class->subsys.kobj,
413− kobject_name(&hdev->dev.kobj));
414−
415408 device_del(&hdev->dev);
416409 }
417410
samples/firmware_class/firmware_sample_firmware_class.c+1−1
@@ -124,7 +124,7 @@ static int fw_setup_class_device(struct class_device *class_dev, · 123 unmodified lines
124124 class_dev->class_id[BUS_ID_SIZE-1] = '\0';
125125 class_dev->dev = device;
126126
127− class_dev->class = &firmware_class,
127+ class_dev->class = &firmware_class;
128128 class_set_devdata(class_dev, fw_priv);
129129 retval = class_device_register(class_dev);
130130 if (retval) {
samples/kobject/kset-example.c+1−1
@@ -211,7 +211,7 @@ static struct foo_obj *create_foo_obj(const char *name) · 210 unmodified lines
211211 */
212212 retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);
213213 if (retval) {
214− kfree(foo);
214+ kobject_put(&foo->kobj);
215215 return NULL;
216216 }
217217
scripts/mod/file2alias.c+16−8
@@ -340,11 +340,18 @@ static int do_acpi_entry(const char *filename, · 339 unmodified lines
340340 }
341341
342342 /* looks like: "pnp:dD" */
343−static int do_pnp_entry(const char *filename,
344− struct pnp_device_id *id, char *alias)
343+static void do_pnp_device_entry(void *symval, unsigned long size,
344+ struct module *mod)
345345 {
346− sprintf(alias, "pnp:d%s*", id->id);
347− return 1;
346+ const unsigned long id_size = sizeof(struct pnp_device_id);
347+ const struct pnp_device_id *id = symval;
348+
349+ device_id_check(mod->name, "pnp", size, id_size, symval);
350+
351+ buf_printf(&mod->dev_table_buf,
352+ "MODULE_ALIAS(\"pnp:d%s*\");\n", id->id);
353+ buf_printf(&mod->dev_table_buf,
354+ "MODULE_ALIAS(\"acpi*:%s:*\");\n", id->id);
348355 }
349356
350357 /* looks like: "pnp:dD" for every device of the card */
@@ -388,9 +395,12 @@ static void do_pnp_card_entries(void *symval, unsigned long size, · 37 unmodified lines
388395 }
389396
390397 /* add an individual alias for every device entry */
391− if (!dup)
398+ if (!dup) {
392399 buf_printf(&mod->dev_table_buf,
393400 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
401+ buf_printf(&mod->dev_table_buf,
402+ "MODULE_ALIAS(\"acpi*:%s:*\");\n", id);
403+ }
394404 }
395405 }
396406 }
@@ -701,9 +711,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, · 304 unmodified lines
701711 sizeof(struct acpi_device_id), "acpi",
702712 do_acpi_entry, mod);
703713 else if (sym_is(symname, "__mod_pnp_device_table"))
704− do_table(symval, sym->st_size,
705− sizeof(struct pnp_device_id), "pnp",
706− do_pnp_entry, mod);
714+ do_pnp_device_entry(symval, sym->st_size, mod);
707715 else if (sym_is(symname, "__mod_pnp_card_device_table"))
708716 do_pnp_card_entries(symval, sym->st_size, mod);
709717 else if (sym_is(symname, "__mod_pcmcia_device_table"))
sound/core/init.c+3−2
@@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card) · 547 unmodified lines
548548 snd_assert(card != NULL, return -EINVAL);
549549 #ifndef CONFIG_SYSFS_DEPRECATED
550550 if (!card->card_dev) {
551− card->card_dev = device_create(sound_class, card->dev, 0,
552− "card%i", card->number);
551+ card->card_dev = device_create_drvdata(sound_class, card->dev,
552+ MKDEV(0, 0), NULL,
553+ "card%i", card->number);
553554 if (IS_ERR(card->card_dev))
554555 card->card_dev = NULL;
555556 }
sound/oss/soundcard.c+8−6
@@ -560,17 +560,19 @@ 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(sound_class, NULL,
564− MKDEV(SOUND_MAJOR, dev_list[i].minor),
565− "%s", dev_list[i].name);
563+ device_create_drvdata(sound_class, NULL,
564+ MKDEV(SOUND_MAJOR, dev_list[i].minor),
565+ NULL, "%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(sound_class, NULL,
572− MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
573− "%s%d", dev_list[i].name, 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);
574576 }
575577
576578 if (sound_nblocks >= 1024)
sound/sound_core.c+3−2
@@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati · 170 unmodified lines
171171 else
172172 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
173173
174− device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
175− s->name+6);
174+ device_create_drvdata(sound_class, dev,
175+ MKDEV(SOUND_MAJOR, s->unit_minor),
176+ NULL, s->name+6);
176177 return r;
177178
178179 fail: