aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/uio-howto.tmpl163
-rw-r--r--Documentation/trace/events.txt24
-rw-r--r--MAINTAINERS7
-rw-r--r--block/genhd.c2
-rw-r--r--drivers/base/Kconfig25
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/base.h13
-rw-r--r--drivers/base/bus.c23
-rw-r--r--drivers/base/class.c87
-rw-r--r--drivers/base/core.c29
-rw-r--r--drivers/base/dd.c31
-rw-r--r--drivers/base/devtmpfs.c367
-rw-r--r--drivers/base/dma-coherent.c (renamed from kernel/dma-coherent.c)0
-rw-r--r--drivers/base/driver.c4
-rw-r--r--drivers/base/init.c1
-rw-r--r--drivers/base/platform.c8
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/char/mem.c82
-rw-r--r--drivers/firewire/core-device.c2
-rw-r--r--drivers/firmware/dmi-id.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c2
-rw-r--r--drivers/input/input.c2
-rw-r--r--drivers/misc/enclosure.c4
-rw-r--r--drivers/misc/hpilo.c290
-rw-r--r--drivers/misc/hpilo.h8
-rw-r--r--drivers/mmc/core/mmc.c2
-rw-r--r--drivers/mmc/core/sd.c2
-rw-r--r--drivers/mtd/mtdcore.c2
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Kconfig6
-rw-r--r--drivers/s390/cio/css.c2
-rw-r--r--drivers/s390/cio/device.c2
-rw-r--r--drivers/s390/net/netiucv.c2
-rw-r--r--drivers/scsi/scsi_priv.h2
-rw-r--r--drivers/scsi/scsi_sysfs.c4
-rw-r--r--drivers/uio/Kconfig15
-rw-r--r--drivers/uio/Makefile1
-rw-r--r--drivers/uio/uio_pci_generic.c207
-rw-r--r--drivers/usb/core/endpoint.c2
-rw-r--r--drivers/usb/core/sysfs.c4
-rw-r--r--drivers/usb/core/usb.h4
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/uwb/lc-dev.c2
-rw-r--r--fs/partitions/check.c2
-rw-r--r--include/linux/attribute_container.h2
-rw-r--r--include/linux/device.h45
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/pci_regs.h1
-rw-r--r--include/linux/shmem_fs.h3
-rw-r--r--include/linux/transport_class.h2
-rw-r--r--init/do_mounts.c2
-rw-r--r--init/main.c2
-rw-r--r--kernel/Makefile1
-rw-r--r--mm/shmem.c9
-rw-r--r--net/bluetooth/hci_sysfs.c4
-rw-r--r--net/core/net-sysfs.c2
-rw-r--r--samples/trace_events/trace-events-sample.h2
59 files changed, 1287 insertions, 239 deletions
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index 8f6e3b2403c7..4d4ce0e61e42 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -25,6 +25,10 @@
25 <year>2006-2008</year> 25 <year>2006-2008</year>
26 <holder>Hans-Jürgen Koch.</holder> 26 <holder>Hans-Jürgen Koch.</holder>
27</copyright> 27</copyright>
28<copyright>
29 <year>2009</year>
30 <holder>Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)</holder>
31</copyright>
28 32
29<legalnotice> 33<legalnotice>
30<para> 34<para>
@@ -42,6 +46,13 @@ GPL version 2.
42 46
43<revhistory> 47<revhistory>
44 <revision> 48 <revision>
49 <revnumber>0.9</revnumber>
50 <date>2009-07-16</date>
51 <authorinitials>mst</authorinitials>
52 <revremark>Added generic pci driver
53 </revremark>
54 </revision>
55 <revision>
45 <revnumber>0.8</revnumber> 56 <revnumber>0.8</revnumber>
46 <date>2008-12-24</date> 57 <date>2008-12-24</date>
47 <authorinitials>hjk</authorinitials> 58 <authorinitials>hjk</authorinitials>
@@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone.
809 820
810</chapter> 821</chapter>
811 822
823<chapter id="uio_pci_generic" xreflabel="Using Generic driver for PCI cards">
824<?dbhtml filename="uio_pci_generic.html"?>
825<title>Generic PCI UIO driver</title>
826 <para>
827 The generic driver is a kernel module named uio_pci_generic.
828 It can work with any device compliant to PCI 2.3 (circa 2002) and
829 any compliant PCI Express device. Using this, you only need to
830 write the userspace driver, removing the need to write
831 a hardware-specific kernel module.
832 </para>
833
834<sect1 id="uio_pci_generic_binding">
835<title>Making the driver recognize the device</title>
836 <para>
837Since the driver does not declare any device ids, it will not get loaded
838automatically and will not automatically bind to any devices, you must load it
839and allocate id to the driver yourself. For example:
840 <programlisting>
841 modprobe uio_pci_generic
842 echo &quot;8086 10f5&quot; &gt; /sys/bus/pci/drivers/uio_pci_generic/new_id
843 </programlisting>
844 </para>
845 <para>
846If there already is a hardware specific kernel driver for your device, the
847generic driver still won't bind to it, in this case if you want to use the
848generic driver (why would you?) you'll have to manually unbind the hardware
849specific driver and bind the generic driver, like this:
850 <programlisting>
851 echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/e1000e/unbind
852 echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/uio_pci_generic/bind
853 </programlisting>
854 </para>
855 <para>
856You can verify that the device has been bound to the driver
857by looking for it in sysfs, for example like the following:
858 <programlisting>
859 ls -l /sys/bus/pci/devices/0000:00:19.0/driver
860 </programlisting>
861Which if successful should print
862 <programlisting>
863 .../0000:00:19.0/driver -&gt; ../../../bus/pci/drivers/uio_pci_generic
864 </programlisting>
865Note that the generic driver will not bind to old PCI 2.2 devices.
866If binding the device failed, run the following command:
867 <programlisting>
868 dmesg
869 </programlisting>
870and look in the output for failure reasons
871 </para>
872</sect1>
873
874<sect1 id="uio_pci_generic_internals">
875<title>Things to know about uio_pci_generic</title>
876 <para>
877Interrupts are handled using the Interrupt Disable bit in the PCI command
878register and Interrupt Status bit in the PCI status register. All devices
879compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should
880support these bits. uio_pci_generic detects this support, and won't bind to
881devices which do not support the Interrupt Disable Bit in the command register.
882 </para>
883 <para>
884On each interrupt, uio_pci_generic sets the Interrupt Disable bit.
885This prevents the device from generating further interrupts
886until the bit is cleared. The userspace driver should clear this
887bit before blocking and waiting for more interrupts.
888 </para>
889</sect1>
890<sect1 id="uio_pci_generic_userspace">
891<title>Writing userspace driver using uio_pci_generic</title>
892 <para>
893Userspace driver can use pci sysfs interface, or the
894libpci libray that wraps it, to talk to the device and to
895re-enable interrupts by writing to the command register.
896 </para>
897</sect1>
898<sect1 id="uio_pci_generic_example">
899<title>Example code using uio_pci_generic</title>
900 <para>
901Here is some sample userspace driver code using uio_pci_generic:
902<programlisting>
903#include &lt;stdlib.h&gt;
904#include &lt;stdio.h&gt;
905#include &lt;unistd.h&gt;
906#include &lt;sys/types.h&gt;
907#include &lt;sys/stat.h&gt;
908#include &lt;fcntl.h&gt;
909#include &lt;errno.h&gt;
910
911int main()
912{
913 int uiofd;
914 int configfd;
915 int err;
916 int i;
917 unsigned icount;
918 unsigned char command_high;
919
920 uiofd = open(&quot;/dev/uio0&quot;, O_RDONLY);
921 if (uiofd &lt; 0) {
922 perror(&quot;uio open:&quot;);
923 return errno;
924 }
925 configfd = open(&quot;/sys/class/uio/uio0/device/config&quot;, O_RDWR);
926 if (uiofd &lt; 0) {
927 perror(&quot;config open:&quot;);
928 return errno;
929 }
930
931 /* Read and cache command value */
932 err = pread(configfd, &amp;command_high, 1, 5);
933 if (err != 1) {
934 perror(&quot;command config read:&quot;);
935 return errno;
936 }
937 command_high &amp;= ~0x4;
938
939 for(i = 0;; ++i) {
940 /* Print out a message, for debugging. */
941 if (i == 0)
942 fprintf(stderr, &quot;Started uio test driver.\n&quot;);
943 else
944 fprintf(stderr, &quot;Interrupts: %d\n&quot;, icount);
945
946 /****************************************/
947 /* Here we got an interrupt from the
948 device. Do something to it. */
949 /****************************************/
950
951 /* Re-enable interrupts. */
952 err = pwrite(configfd, &amp;command_high, 1, 5);
953 if (err != 1) {
954 perror(&quot;config write:&quot;);
955 break;
956 }
957
958 /* Wait for next interrupt. */
959 err = read(uiofd, &amp;icount, 4);
960 if (err != 4) {
961 perror(&quot;uio read:&quot;);
962 break;
963 }
964
965 }
966 return errno;
967}
968
969</programlisting>
970 </para>
971</sect1>
972
973</chapter>
974
812<appendix id="app1"> 975<appendix id="app1">
813<title>Further information</title> 976<title>Further information</title>
814<itemizedlist> 977<itemizedlist>
diff --git a/Documentation/trace/events.txt b/Documentation/trace/events.txt
index 2bcc8d4dea29..90e8b3383ba2 100644
--- a/Documentation/trace/events.txt
+++ b/Documentation/trace/events.txt
@@ -22,12 +22,12 @@ tracing information should be printed.
22--------------------------------- 22---------------------------------
23 23
24The events which are available for tracing can be found in the file 24The events which are available for tracing can be found in the file
25/debug/tracing/available_events. 25/sys/kernel/debug/tracing/available_events.
26 26
27To enable a particular event, such as 'sched_wakeup', simply echo it 27To enable a particular event, such as 'sched_wakeup', simply echo it
28to /debug/tracing/set_event. For example: 28to /sys/kernel/debug/tracing/set_event. For example:
29 29
30 # echo sched_wakeup >> /debug/tracing/set_event 30 # echo sched_wakeup >> /sys/kernel/debug/tracing/set_event
31 31
32[ Note: '>>' is necessary, otherwise it will firstly disable 32[ Note: '>>' is necessary, otherwise it will firstly disable
33 all the events. ] 33 all the events. ]
@@ -35,15 +35,15 @@ to /debug/tracing/set_event. For example:
35To disable an event, echo the event name to the set_event file prefixed 35To disable an event, echo the event name to the set_event file prefixed
36with an exclamation point: 36with an exclamation point:
37 37
38 # echo '!sched_wakeup' >> /debug/tracing/set_event 38 # echo '!sched_wakeup' >> /sys/kernel/debug/tracing/set_event
39 39
40To disable all events, echo an empty line to the set_event file: 40To disable all events, echo an empty line to the set_event file:
41 41
42 # echo > /debug/tracing/set_event 42 # echo > /sys/kernel/debug/tracing/set_event
43 43
44To enable all events, echo '*:*' or '*:' to the set_event file: 44To enable all events, echo '*:*' or '*:' to the set_event file:
45 45
46 # echo *:* > /debug/tracing/set_event 46 # echo *:* > /sys/kernel/debug/tracing/set_event
47 47
48The events are organized into subsystems, such as ext4, irq, sched, 48The events are organized into subsystems, such as ext4, irq, sched,
49etc., and a full event name looks like this: <subsystem>:<event>. The 49etc., and a full event name looks like this: <subsystem>:<event>. The
@@ -52,29 +52,29 @@ file. All of the events in a subsystem can be specified via the syntax
52"<subsystem>:*"; for example, to enable all irq events, you can use the 52"<subsystem>:*"; for example, to enable all irq events, you can use the
53command: 53command:
54 54
55 # echo 'irq:*' > /debug/tracing/set_event 55 # echo 'irq:*' > /sys/kernel/debug/tracing/set_event
56 56
572.2 Via the 'enable' toggle 572.2 Via the 'enable' toggle
58--------------------------- 58---------------------------
59 59
60The events available are also listed in /debug/tracing/events/ hierarchy 60The events available are also listed in /sys/kernel/debug/tracing/events/ hierarchy
61of directories. 61of directories.
62 62
63To enable event 'sched_wakeup': 63To enable event 'sched_wakeup':
64 64
65 # echo 1 > /debug/tracing/events/sched/sched_wakeup/enable 65 # echo 1 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
66 66
67To disable it: 67To disable it:
68 68
69 # echo 0 > /debug/tracing/events/sched/sched_wakeup/enable 69 # echo 0 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
70 70
71To enable all events in sched subsystem: 71To enable all events in sched subsystem:
72 72
73 # echo 1 > /debug/tracing/events/sched/enable 73 # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
74 74
75To eanble all events: 75To eanble all events:
76 76
77 # echo 1 > /debug/tracing/events/enable 77 # echo 1 > /sys/kernel/debug/tracing/events/enable
78 78
79When reading one of these enable files, there are four results: 79When reading one of these enable files, there are four results:
80 80
diff --git a/MAINTAINERS b/MAINTAINERS
index 64b9e447545c..9117b65f4ae3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2218,6 +2218,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git
2218S: Maintained 2218S: Maintained
2219F: include/asm-generic 2219F: include/asm-generic
2220 2220
2221GENERIC UIO DRIVER FOR PCI DEVICES
2222M: Michael S. Tsirkin <mst@redhat.com>
2223L: kvm@vger.kernel.org
2224L: linux-kernel@vger.kernel.org
2225S: Supported
2226F: drivers/uio/uio_pci_generic.c
2227
2221GFS2 FILE SYSTEM 2228GFS2 FILE SYSTEM
2222M: Steven Whitehouse <swhiteho@redhat.com> 2229M: Steven Whitehouse <swhiteho@redhat.com>
2223L: cluster-devel@redhat.com 2230L: cluster-devel@redhat.com
diff --git a/block/genhd.c b/block/genhd.c
index 5b76bf55d05c..2ad91ddad8e2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -903,7 +903,7 @@ static struct attribute_group disk_attr_group = {
903 .attrs = disk_attrs, 903 .attrs = disk_attrs,
904}; 904};
905 905
906static struct attribute_group *disk_attr_groups[] = { 906static const struct attribute_group *disk_attr_groups[] = {
907 &disk_attr_group, 907 &disk_attr_group,
908 NULL 908 NULL
909}; 909};
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 8f006f96ff53..ee377270beb9 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -8,6 +8,31 @@ config UEVENT_HELPER_PATH
8 Path to uevent helper program forked by the kernel for 8 Path to uevent helper program forked by the kernel for
9 every uevent. 9 every uevent.
10 10
11config DEVTMPFS
12 bool "Create a kernel maintained /dev tmpfs (EXPERIMENTAL)"
13 depends on HOTPLUG && SHMEM && TMPFS
14 help
15 This creates a tmpfs filesystem, and mounts it at bootup
16 and mounts it at /dev. The kernel driver core creates device
17 nodes for all registered devices in that filesystem. All device
18 nodes are owned by root and have the default mode of 0600.
19 Userspace can add and delete the nodes as needed. This is
20 intended to simplify bootup, and make it possible to delay
21 the initial coldplug at bootup done by udev in userspace.
22 It should also provide a simpler way for rescue systems
23 to bring up a kernel with dynamic major/minor numbers.
24 Meaningful symlinks, permissions and device ownership must
25 still be handled by userspace.
26 If unsure, say N here.
27
28config DEVTMPFS_MOUNT
29 bool "Automount devtmpfs at /dev"
30 depends on DEVTMPFS
31 help
32 This will mount devtmpfs at /dev if the kernel mounts the root
33 filesystem. It will not affect initramfs based mounting.
34 If unsure, say N here.
35
11config STANDALONE 36config STANDALONE
12 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL 37 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
13 default y 38 default y
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index b5b8ba512b28..c12c7f2f2a6f 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -4,8 +4,10 @@ obj-y := core.o sys.o bus.o dd.o \
4 driver.o class.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o devres.o \ 5 cpu.o firmware.o init.o map.o devres.o \
6 attribute_container.o transport_class.o 6 attribute_container.o transport_class.o
7obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
7obj-y += power/ 8obj-y += power/
8obj-$(CONFIG_HAS_DMA) += dma-mapping.o 9obj-$(CONFIG_HAS_DMA) += dma-mapping.o
10obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
9obj-$(CONFIG_ISA) += isa.o 11obj-$(CONFIG_ISA) += isa.o
10obj-$(CONFIG_FW_LOADER) += firmware_class.o 12obj-$(CONFIG_FW_LOADER) += firmware_class.o
11obj-$(CONFIG_NUMA) += node.o 13obj-$(CONFIG_NUMA) += node.o
diff --git a/drivers/base/base.h b/drivers/base/base.h
index b528145a078f..2ca7f5b7b824 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -70,6 +70,8 @@ struct class_private {
70 * @knode_parent - node in sibling list 70 * @knode_parent - node in sibling list
71 * @knode_driver - node in driver list 71 * @knode_driver - node in driver list
72 * @knode_bus - node in bus list 72 * @knode_bus - node in bus list
73 * @driver_data - private pointer for driver specific info. Will turn into a
74 * list soon.
73 * @device - pointer back to the struct class that this structure is 75 * @device - pointer back to the struct class that this structure is
74 * associated with. 76 * associated with.
75 * 77 *
@@ -80,6 +82,7 @@ struct device_private {
80 struct klist_node knode_parent; 82 struct klist_node knode_parent;
81 struct klist_node knode_driver; 83 struct klist_node knode_driver;
82 struct klist_node knode_bus; 84 struct klist_node knode_bus;
85 void *driver_data;
83 struct device *device; 86 struct device *device;
84}; 87};
85#define to_device_private_parent(obj) \ 88#define to_device_private_parent(obj) \
@@ -89,6 +92,8 @@ struct device_private {
89#define to_device_private_bus(obj) \ 92#define to_device_private_bus(obj) \
90 container_of(obj, struct device_private, knode_bus) 93 container_of(obj, struct device_private, knode_bus)
91 94
95extern int device_private_init(struct device *dev);
96
92/* initialisation functions */ 97/* initialisation functions */
93extern int devices_init(void); 98extern int devices_init(void);
94extern int buses_init(void); 99extern int buses_init(void);
@@ -104,7 +109,7 @@ extern int system_bus_init(void);
104extern int cpu_dev_init(void); 109extern int cpu_dev_init(void);
105 110
106extern int bus_add_device(struct device *dev); 111extern int bus_add_device(struct device *dev);
107extern void bus_attach_device(struct device *dev); 112extern void bus_probe_device(struct device *dev);
108extern void bus_remove_device(struct device *dev); 113extern void bus_remove_device(struct device *dev);
109 114
110extern int bus_add_driver(struct device_driver *drv); 115extern int bus_add_driver(struct device_driver *drv);
@@ -134,3 +139,9 @@ static inline void module_add_driver(struct module *mod,
134 struct device_driver *drv) { } 139 struct device_driver *drv) { }
135static inline void module_remove_driver(struct device_driver *drv) { } 140static inline void module_remove_driver(struct device_driver *drv) { }
136#endif 141#endif
142
143#ifdef CONFIG_DEVTMPFS
144extern int devtmpfs_init(void);
145#else
146static inline int devtmpfs_init(void) { return 0; }
147#endif
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 4b04a15146d7..973bf2ad4e0d 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -459,8 +459,9 @@ static inline void remove_deprecated_bus_links(struct device *dev) { }
459 * bus_add_device - add device to bus 459 * bus_add_device - add device to bus
460 * @dev: device being added 460 * @dev: device being added
461 * 461 *
462 * - Add device's bus attributes.
463 * - Create links to device's bus.
462 * - Add the device to its bus's list of devices. 464 * - Add the device to its bus's list of devices.
463 * - Create link to device's bus.
464 */ 465 */
465int bus_add_device(struct device *dev) 466int bus_add_device(struct device *dev)
466{ 467{
@@ -483,6 +484,7 @@ int bus_add_device(struct device *dev)
483 error = make_deprecated_bus_links(dev); 484 error = make_deprecated_bus_links(dev);
484 if (error) 485 if (error)
485 goto out_deprecated; 486 goto out_deprecated;
487 klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
486 } 488 }
487 return 0; 489 return 0;
488 490
@@ -498,24 +500,19 @@ out_put:
498} 500}
499 501
500/** 502/**
501 * bus_attach_device - add device to bus 503 * bus_probe_device - probe drivers for a new device
502 * @dev: device tried to attach to a driver 504 * @dev: device to probe
503 * 505 *
504 * - Add device to bus's list of devices. 506 * - Automatically probe for a driver if the bus allows it.
505 * - Try to attach to driver.
506 */ 507 */
507void bus_attach_device(struct device *dev) 508void bus_probe_device(struct device *dev)
508{ 509{
509 struct bus_type *bus = dev->bus; 510 struct bus_type *bus = dev->bus;
510 int ret = 0; 511 int ret;
511 512
512 if (bus) { 513 if (bus && bus->p->drivers_autoprobe) {
513 if (bus->p->drivers_autoprobe) 514 ret = device_attach(dev);
514 ret = device_attach(dev);
515 WARN_ON(ret < 0); 515 WARN_ON(ret < 0);
516 if (ret >= 0)
517 klist_add_tail(&dev->p->knode_bus,
518 &bus->p->klist_devices);
519 } 516 }
520} 517}
521 518
diff --git a/drivers/base/class.c b/drivers/base/class.c
index eb85e4312301..161746deab4b 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -488,6 +488,93 @@ void class_interface_unregister(struct class_interface *class_intf)
488 class_put(parent); 488 class_put(parent);
489} 489}
490 490
491struct class_compat {
492 struct kobject *kobj;
493};
494
495/**
496 * class_compat_register - register a compatibility class
497 * @name: the name of the class
498 *
499 * Compatibility class are meant as a temporary user-space compatibility
500 * workaround when converting a family of class devices to a bus devices.
501 */
502struct class_compat *class_compat_register(const char *name)
503{
504 struct class_compat *cls;
505
506 cls = kmalloc(sizeof(struct class_compat), GFP_KERNEL);
507 if (!cls)
508 return NULL;
509 cls->kobj = kobject_create_and_add(name, &class_kset->kobj);
510 if (!cls->kobj) {
511 kfree(cls);
512 return NULL;
513 }
514 return cls;
515}
516EXPORT_SYMBOL_GPL(class_compat_register);
517
518/**
519 * class_compat_unregister - unregister a compatibility class
520 * @cls: the class to unregister
521 */
522void class_compat_unregister(struct class_compat *cls)
523{
524 kobject_put(cls->kobj);
525 kfree(cls);
526}
527EXPORT_SYMBOL_GPL(class_compat_unregister);
528
529/**
530 * class_compat_create_link - create a compatibility class device link to
531 * a bus device
532 * @cls: the compatibility class
533 * @dev: the target bus device
534 * @device_link: an optional device to which a "device" link should be created
535 */
536int class_compat_create_link(struct class_compat *cls, struct device *dev,
537 struct device *device_link)
538{
539 int error;
540
541 error = sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev));
542 if (error)
543 return error;
544
545 /*
546 * Optionally add a "device" link (typically to the parent), as a
547 * class device would have one and we want to provide as much
548 * backwards compatibility as possible.
549 */
550 if (device_link) {
551 error = sysfs_create_link(&dev->kobj, &device_link->kobj,
552 "device");
553 if (error)
554 sysfs_remove_link(cls->kobj, dev_name(dev));
555 }
556
557 return error;
558}
559EXPORT_SYMBOL_GPL(class_compat_create_link);
560
561/**
562 * class_compat_remove_link - remove a compatibility class device link to
563 * a bus device
564 * @cls: the compatibility class
565 * @dev: the target bus device
566 * @device_link: an optional device to which a "device" link was previously
567 * created
568 */
569void class_compat_remove_link(struct class_compat *cls, struct device *dev,
570 struct device *device_link)
571{
572 if (device_link)
573 sysfs_remove_link(&dev->kobj, "device");
574 sysfs_remove_link(cls->kobj, dev_name(dev));
575}
576EXPORT_SYMBOL_GPL(class_compat_remove_link);
577
491int __init classes_init(void) 578int __init classes_init(void)
492{ 579{
493 class_kset = kset_create_and_add("class", NULL, NULL); 580 class_kset = kset_create_and_add("class", NULL, NULL);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7ecb1938e590..390e664ec1c7 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -341,7 +341,7 @@ static void device_remove_attributes(struct device *dev,
341} 341}
342 342
343static int device_add_groups(struct device *dev, 343static int device_add_groups(struct device *dev,
344 struct attribute_group **groups) 344 const struct attribute_group **groups)
345{ 345{
346 int error = 0; 346 int error = 0;
347 int i; 347 int i;
@@ -361,7 +361,7 @@ static int device_add_groups(struct device *dev,
361} 361}
362 362
363static void device_remove_groups(struct device *dev, 363static void device_remove_groups(struct device *dev,
364 struct attribute_group **groups) 364 const struct attribute_group **groups)
365{ 365{
366 int i; 366 int i;
367 367
@@ -843,6 +843,17 @@ static void device_remove_sys_dev_entry(struct device *dev)
843 } 843 }
844} 844}
845 845
846int device_private_init(struct device *dev)
847{
848 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
849 if (!dev->p)
850 return -ENOMEM;
851 dev->p->device = dev;
852 klist_init(&dev->p->klist_children, klist_children_get,
853 klist_children_put);
854 return 0;
855}
856
846/** 857/**
847 * device_add - add device to device hierarchy. 858 * device_add - add device to device hierarchy.
848 * @dev: device. 859 * @dev: device.
@@ -868,14 +879,11 @@ int device_add(struct device *dev)
868 if (!dev) 879 if (!dev)
869 goto done; 880 goto done;
870 881
871 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
872 if (!dev->p) { 882 if (!dev->p) {
873 error = -ENOMEM; 883 error = device_private_init(dev);
874 goto done; 884 if (error)
885 goto done;
875 } 886 }
876 dev->p->device = dev;
877 klist_init(&dev->p->klist_children, klist_children_get,
878 klist_children_put);
879 887
880 /* 888 /*
881 * for statically allocated devices, which should all be converted 889 * for statically allocated devices, which should all be converted
@@ -921,6 +929,8 @@ int device_add(struct device *dev)
921 error = device_create_sys_dev_entry(dev); 929 error = device_create_sys_dev_entry(dev);
922 if (error) 930 if (error)
923 goto devtattrError; 931 goto devtattrError;
932
933 devtmpfs_create_node(dev);
924 } 934 }
925 935
926 error = device_add_class_symlinks(dev); 936 error = device_add_class_symlinks(dev);
@@ -945,7 +955,7 @@ int device_add(struct device *dev)
945 BUS_NOTIFY_ADD_DEVICE, dev); 955 BUS_NOTIFY_ADD_DEVICE, dev);
946 956
947 kobject_uevent(&dev->kobj, KOBJ_ADD); 957 kobject_uevent(&dev->kobj, KOBJ_ADD);
948 bus_attach_device(dev); 958 bus_probe_device(dev);
949 if (parent) 959 if (parent)
950 klist_add_tail(&dev->p->knode_parent, 960 klist_add_tail(&dev->p->knode_parent,
951 &parent->p->klist_children); 961 &parent->p->klist_children);
@@ -1067,6 +1077,7 @@ void device_del(struct device *dev)
1067 if (parent) 1077 if (parent)
1068 klist_del(&dev->p->knode_parent); 1078 klist_del(&dev->p->knode_parent);
1069 if (MAJOR(dev->devt)) { 1079 if (MAJOR(dev->devt)) {
1080 devtmpfs_delete_node(dev);
1070 device_remove_sys_dev_entry(dev); 1081 device_remove_sys_dev_entry(dev);
1071 device_remove_file(dev, &devt_attr); 1082 device_remove_file(dev, &devt_attr);
1072 } 1083 }
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 7b34b3a48f67..979d159b5cd1 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -11,8 +11,8 @@
11 * 11 *
12 * Copyright (c) 2002-5 Patrick Mochel 12 * Copyright (c) 2002-5 Patrick Mochel
13 * Copyright (c) 2002-3 Open Source Development Labs 13 * Copyright (c) 2002-3 Open Source Development Labs
14 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> 14 * Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de>
15 * Copyright (c) 2007 Novell Inc. 15 * Copyright (c) 2007-2009 Novell Inc.
16 * 16 *
17 * This file is released under the GPLv2 17 * This file is released under the GPLv2
18 */ 18 */
@@ -391,3 +391,30 @@ void driver_detach(struct device_driver *drv)
391 put_device(dev); 391 put_device(dev);
392 } 392 }
393} 393}
394
395/*
396 * These exports can't be _GPL due to .h files using this within them, and it
397 * might break something that was previously working...
398 */
399void *dev_get_drvdata(const struct device *dev)
400{
401 if (dev && dev->p)
402 return dev->p->driver_data;
403 return NULL;
404}
405EXPORT_SYMBOL(dev_get_drvdata);
406
407void dev_set_drvdata(struct device *dev, void *data)
408{
409 int error;
410
411 if (!dev)
412 return;
413 if (!dev->p) {
414 error = device_private_init(dev);
415 if (error)
416 return;
417 }
418 dev->p->driver_data = data;
419}
420EXPORT_SYMBOL(dev_set_drvdata);
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
new file mode 100644
index 000000000000..fd488ad4263a
--- /dev/null
+++ b/drivers/base/devtmpfs.c
@@ -0,0 +1,367 @@
1/*
2 * devtmpfs - kernel-maintained tmpfs-based /dev
3 *
4 * Copyright (C) 2009, Kay Sievers <kay.sievers@vrfy.org>
5 *
6 * During bootup, before any driver core device is registered,
7 * devtmpfs, a tmpfs-based filesystem is created. Every driver-core
8 * device which requests a device node, will add a node in this
9 * filesystem. The node is named after the the name of the device,
10 * or the susbsytem can provide a custom name. All devices are
11 * owned by root and have a mode of 0600.
12 */
13
14#include <linux/kernel.h>
15#include <linux/syscalls.h>
16#include <linux/mount.h>
17#include <linux/device.h>
18#include <linux/genhd.h>
19#include <linux/namei.h>
20#include <linux/fs.h>
21#include <linux/shmem_fs.h>
22#include <linux/cred.h>
23#include <linux/init_task.h>
24
25static struct vfsmount *dev_mnt;
26
27#if defined CONFIG_DEVTMPFS_MOUNT
28static int dev_mount = 1;
29#else
30static int dev_mount;
31#endif
32
33static int __init mount_param(char *str)
34{
35 dev_mount = simple_strtoul(str, NULL, 0);
36 return 1;
37}
38__setup("devtmpfs.mount=", mount_param);
39
40static int dev_get_sb(struct file_system_type *fs_type, int flags,
41 const char *dev_name, void *data, struct vfsmount *mnt)
42{
43 return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt);
44}
45
46static struct file_system_type dev_fs_type = {
47 .name = "devtmpfs",
48 .get_sb = dev_get_sb,
49 .kill_sb = kill_litter_super,
50};
51
52#ifdef CONFIG_BLOCK
53static inline int is_blockdev(struct device *dev)
54{
55 return dev->class == &block_class;
56}
57#else
58static inline int is_blockdev(struct device *dev) { return 0; }
59#endif
60
61static int dev_mkdir(const char *name, mode_t mode)
62{
63 struct nameidata nd;
64 struct dentry *dentry;
65 int err;
66
67 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
68 name, LOOKUP_PARENT, &nd);
69 if (err)
70 return err;
71
72 dentry = lookup_create(&nd, 1);
73 if (!IS_ERR(dentry)) {
74 err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode);
75 dput(dentry);
76 } else {
77 err = PTR_ERR(dentry);
78 }
79 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
80
81 path_put(&nd.path);
82 return err;
83}
84
85static int create_path(const char *nodepath)
86{
87 char *path;
88 struct nameidata nd;
89 int err = 0;
90
91 path = kstrdup(nodepath, GFP_KERNEL);
92 if (!path)
93 return -ENOMEM;
94
95 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
96 path, LOOKUP_PARENT, &nd);
97 if (err == 0) {
98 struct dentry *dentry;
99
100 /* create directory right away */
101 dentry = lookup_create(&nd, 1);
102 if (!IS_ERR(dentry)) {
103 err = vfs_mkdir(nd.path.dentry->d_inode,
104 dentry, 0755);
105 dput(dentry);
106 }
107 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
108
109 path_put(&nd.path);
110 } else if (err == -ENOENT) {
111 char *s;
112
113 /* parent directories do not exist, create them */
114 s = path;
115 while (1) {
116 s = strchr(s, '/');
117 if (!s)
118 break;
119 s[0] = '\0';
120 err = dev_mkdir(path, 0755);
121 if (err && err != -EEXIST)
122 break;
123 s[0] = '/';
124 s++;
125 }
126 }
127
128 kfree(path);
129 return err;
130}
131
132int devtmpfs_create_node(struct device *dev)
133{
134 const char *tmp = NULL;
135 const char *nodename;
136 const struct cred *curr_cred;
137 mode_t mode;
138 struct nameidata nd;
139 struct dentry *dentry;
140 int err;
141
142 if (!dev_mnt)
143 return 0;
144
145 nodename = device_get_nodename(dev, &tmp);
146 if (!nodename)
147 return -ENOMEM;
148
149 if (is_blockdev(dev))
150 mode = S_IFBLK|0600;
151 else
152 mode = S_IFCHR|0600;
153
154 curr_cred = override_creds(&init_cred);
155 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
156 nodename, LOOKUP_PARENT, &nd);
157 if (err == -ENOENT) {
158 /* create missing parent directories */
159 create_path(nodename);
160 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
161 nodename, LOOKUP_PARENT, &nd);
162 if (err)
163 goto out;
164 }
165
166 dentry = lookup_create(&nd, 0);
167 if (!IS_ERR(dentry)) {
168 err = vfs_mknod(nd.path.dentry->d_inode,
169 dentry, mode, dev->devt);
170 /* mark as kernel created inode */
171 if (!err)
172 dentry->d_inode->i_private = &dev_mnt;
173 dput(dentry);
174 } else {
175 err = PTR_ERR(dentry);
176 }
177 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
178
179 path_put(&nd.path);
180out:
181 kfree(tmp);
182 revert_creds(curr_cred);
183 return err;
184}
185
186static int dev_rmdir(const char *name)
187{
188 struct nameidata nd;
189 struct dentry *dentry;
190 int err;
191
192 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
193 name, LOOKUP_PARENT, &nd);
194 if (err)
195 return err;
196
197 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
198 dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
199 if (!IS_ERR(dentry)) {
200 if (dentry->d_inode)
201 err = vfs_rmdir(nd.path.dentry->d_inode, dentry);
202 else
203 err = -ENOENT;
204 dput(dentry);
205 } else {
206 err = PTR_ERR(dentry);
207 }
208 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
209
210 path_put(&nd.path);
211 return err;
212}
213
214static int delete_path(const char *nodepath)
215{
216 const char *path;
217 int err = 0;
218
219 path = kstrdup(nodepath, GFP_KERNEL);
220 if (!path)
221 return -ENOMEM;
222
223 while (1) {
224 char *base;
225
226 base = strrchr(path, '/');
227 if (!base)
228 break;
229 base[0] = '\0';
230 err = dev_rmdir(path);
231 if (err)
232 break;
233 }
234
235 kfree(path);
236 return err;
237}
238
239static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *stat)
240{
241 /* did we create it */
242 if (inode->i_private != &dev_mnt)
243 return 0;
244
245 /* does the dev_t match */
246 if (is_blockdev(dev)) {
247 if (!S_ISBLK(stat->mode))
248 return 0;
249 } else {
250 if (!S_ISCHR(stat->mode))
251 return 0;
252 }
253 if (stat->rdev != dev->devt)
254 return 0;
255
256 /* ours */
257 return 1;
258}
259
260int devtmpfs_delete_node(struct device *dev)
261{
262 const char *tmp = NULL;
263 const char *nodename;
264 const struct cred *curr_cred;
265 struct nameidata nd;
266 struct dentry *dentry;
267 struct kstat stat;
268 int deleted = 1;
269 int err;
270
271 if (!dev_mnt)
272 return 0;
273
274 nodename = device_get_nodename(dev, &tmp);
275 if (!nodename)
276 return -ENOMEM;
277
278 curr_cred = override_creds(&init_cred);
279 err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
280 nodename, LOOKUP_PARENT, &nd);
281 if (err)
282 goto out;
283
284 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
285 dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len);
286 if (!IS_ERR(dentry)) {
287 if (dentry->d_inode) {
288 err = vfs_getattr(nd.path.mnt, dentry, &stat);
289 if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
290 err = vfs_unlink(nd.path.dentry->d_inode,
291 dentry);
292 if (!err || err == -ENOENT)
293 deleted = 1;
294 }
295 } else {
296 err = -ENOENT;
297 }
298 dput(dentry);
299 } else {
300 err = PTR_ERR(dentry);
301 }
302 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
303
304 path_put(&nd.path);
305 if (deleted && strchr(nodename, '/'))
306 delete_path(nodename);
307out:
308 kfree(tmp);
309 revert_creds(curr_cred);
310 return err;
311}
312
313/*
314 * If configured, or requested by the commandline, devtmpfs will be
315 * auto-mounted after the kernel mounted the root filesystem.
316 */
317int devtmpfs_mount(const char *mountpoint)
318{
319 struct path path;
320 int err;
321
322 if (!dev_mount)
323 return 0;
324
325 if (!dev_mnt)
326 return 0;
327
328 err = kern_path(mountpoint, LOOKUP_FOLLOW, &path);
329 if (err)
330 return err;
331 err = do_add_mount(dev_mnt, &path, 0, NULL);
332 if (err)
333 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
334 else
335 printk(KERN_INFO "devtmpfs: mounted\n");
336 path_put(&path);
337 return err;
338}
339
340/*
341 * Create devtmpfs instance, driver-core devices will add their device
342 * nodes here.
343 */
344int __init devtmpfs_init(void)
345{
346 int err;
347 struct vfsmount *mnt;
348
349 err = register_filesystem(&dev_fs_type);
350 if (err) {
351 printk(KERN_ERR "devtmpfs: unable to register devtmpfs "
352 "type %i\n", err);
353 return err;
354 }
355
356 mnt = kern_mount(&dev_fs_type);
357 if (IS_ERR(mnt)) {
358 err = PTR_ERR(mnt);
359 printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err);
360 unregister_filesystem(&dev_fs_type);
361 return err;
362 }
363 dev_mnt = mnt;
364
365 printk(KERN_INFO "devtmpfs: initialized\n");
366 return 0;
367}
diff --git a/kernel/dma-coherent.c b/drivers/base/dma-coherent.c
index 962a3b574f21..962a3b574f21 100644
--- a/kernel/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 8ae0f63602e0..ed2ebd3c287d 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -181,7 +181,7 @@ void put_driver(struct device_driver *drv)
181EXPORT_SYMBOL_GPL(put_driver); 181EXPORT_SYMBOL_GPL(put_driver);
182 182
183static int driver_add_groups(struct device_driver *drv, 183static int driver_add_groups(struct device_driver *drv,
184 struct attribute_group **groups) 184 const struct attribute_group **groups)
185{ 185{
186 int error = 0; 186 int error = 0;
187 int i; 187 int i;
@@ -201,7 +201,7 @@ static int driver_add_groups(struct device_driver *drv,
201} 201}
202 202
203static void driver_remove_groups(struct device_driver *drv, 203static void driver_remove_groups(struct device_driver *drv,
204 struct attribute_group **groups) 204 const struct attribute_group **groups)
205{ 205{
206 int i; 206 int i;
207 207
diff --git a/drivers/base/init.c b/drivers/base/init.c
index 7bd9b6a5b01f..c8a934e79421 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -20,6 +20,7 @@
20void __init driver_init(void) 20void __init driver_init(void)
21{ 21{
22 /* These are the core pieces */ 22 /* These are the core pieces */
23 devtmpfs_init();
23 devices_init(); 24 devices_init();
24 buses_init(); 25 buses_init();
25 classes_init(); 26 classes_init();
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 0f7d434ce983..ed156a13aa40 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -10,6 +10,7 @@
10 * information. 10 * information.
11 */ 11 */
12 12
13#include <linux/string.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/init.h> 16#include <linux/init.h>
@@ -213,14 +214,13 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources);
213int platform_device_add_data(struct platform_device *pdev, const void *data, 214int platform_device_add_data(struct platform_device *pdev, const void *data,
214 size_t size) 215 size_t size)
215{ 216{
216 void *d; 217 void *d = kmemdup(data, size, GFP_KERNEL);
217 218
218 d = kmalloc(size, GFP_KERNEL);
219 if (d) { 219 if (d) {
220 memcpy(d, data, size);
221 pdev->dev.platform_data = d; 220 pdev->dev.platform_data = d;
221 return 0;
222 } 222 }
223 return d ? 0 : -ENOMEM; 223 return -ENOMEM;
224} 224}
225EXPORT_SYMBOL_GPL(platform_device_add_data); 225EXPORT_SYMBOL_GPL(platform_device_add_data);
226 226
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 0589dfbbd7db..d8372b432826 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -572,7 +572,7 @@ static struct attribute_group cciss_dev_attr_group = {
572 .attrs = cciss_dev_attrs, 572 .attrs = cciss_dev_attrs,
573}; 573};
574 574
575static struct attribute_group *cciss_dev_attr_groups[] = { 575static const struct attribute_group *cciss_dev_attr_groups[] = {
576 &cciss_dev_attr_group, 576 &cciss_dev_attr_group,
577 NULL 577 NULL
578}; 578};
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 99a506f619b7..95f11cdef203 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -92,7 +92,7 @@ static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
92static mempool_t *psd_pool; 92static mempool_t *psd_pool;
93 93
94static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */ 94static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */
95static struct dentry *pkt_debugfs_root = NULL; /* /debug/pktcdvd */ 95static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */
96 96
97/* forward declaration */ 97/* forward declaration */
98static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev); 98static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 645237bda682..0491cdf63f2a 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -864,71 +864,67 @@ static const struct file_operations kmsg_fops = {
864 .write = kmsg_write, 864 .write = kmsg_write,
865}; 865};
866 866
867static const struct { 867static const struct memdev {
868 unsigned int minor; 868 const char *name;
869 char *name; 869 const struct file_operations *fops;
870 umode_t mode; 870 struct backing_dev_info *dev_info;
871 const struct file_operations *fops; 871} devlist[] = {
872 struct backing_dev_info *dev_info; 872 [ 1] = { "mem", &mem_fops, &directly_mappable_cdev_bdi },
873} devlist[] = { /* list of minor devices */
874 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops,
875 &directly_mappable_cdev_bdi},
876#ifdef CONFIG_DEVKMEM 873#ifdef CONFIG_DEVKMEM
877 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops, 874 [ 2] = { "kmem", &kmem_fops, &directly_mappable_cdev_bdi },
878 &directly_mappable_cdev_bdi},
879#endif 875#endif
880 {3, "null", S_IRUGO | S_IWUGO, &null_fops, NULL}, 876 [ 3] = {"null", &null_fops, NULL },
881#ifdef CONFIG_DEVPORT 877#ifdef CONFIG_DEVPORT
882 {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops, NULL}, 878 [ 4] = { "port", &port_fops, NULL },
883#endif 879#endif
884 {5, "zero", S_IRUGO | S_IWUGO, &zero_fops, &zero_bdi}, 880 [ 5] = { "zero", &zero_fops, &zero_bdi },
885 {7, "full", S_IRUGO | S_IWUGO, &full_fops, NULL}, 881 [ 7] = { "full", &full_fops, NULL },
886 {8, "random", S_IRUGO | S_IWUSR, &random_fops, NULL}, 882 [ 8] = { "random", &random_fops, NULL },
887 {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops, NULL}, 883 [ 9] = { "urandom", &urandom_fops, NULL },
888 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops, NULL}, 884 [11] = { "kmsg", &kmsg_fops, NULL },
889#ifdef CONFIG_CRASH_DUMP 885#ifdef CONFIG_CRASH_DUMP
890 {12,"oldmem", S_IRUSR | S_IWUSR | S_IRGRP, &oldmem_fops, NULL}, 886 [12] = { "oldmem", &oldmem_fops, NULL },
891#endif 887#endif
892}; 888};
893 889
894static int memory_open(struct inode *inode, struct file *filp) 890static int memory_open(struct inode *inode, struct file *filp)
895{ 891{
896 int ret = 0; 892 int minor;
897 int i; 893 const struct memdev *dev;
894 int ret = -ENXIO;
898 895
899 lock_kernel(); 896 lock_kernel();
900 897
901 for (i = 0; i < ARRAY_SIZE(devlist); i++) { 898 minor = iminor(inode);
902 if (devlist[i].minor == iminor(inode)) { 899 if (minor >= ARRAY_SIZE(devlist))
903 filp->f_op = devlist[i].fops; 900 goto out;
904 if (devlist[i].dev_info) {
905 filp->f_mapping->backing_dev_info =
906 devlist[i].dev_info;
907 }
908 901
909 break; 902 dev = &devlist[minor];
910 } 903 if (!dev->fops)
911 } 904 goto out;
912 905
913 if (i == ARRAY_SIZE(devlist)) 906 filp->f_op = dev->fops;
914 ret = -ENXIO; 907 if (dev->dev_info)
915 else 908 filp->f_mapping->backing_dev_info = dev->dev_info;
916 if (filp->f_op && filp->f_op->open)
917 ret = filp->f_op->open(inode, filp);
918 909
910 if (dev->fops->open)
911 ret = dev->fops->open(inode, filp);
912 else
913 ret = 0;
914out:
919 unlock_kernel(); 915 unlock_kernel();
920 return ret; 916 return ret;
921} 917}
922 918
923static const struct file_operations memory_fops = { 919static const struct file_operations memory_fops = {
924 .open = memory_open, /* just a selector for the real open */ 920 .open = memory_open,
925}; 921};
926 922
927static struct class *mem_class; 923static struct class *mem_class;
928 924
929static int __init chr_dev_init(void) 925static int __init chr_dev_init(void)
930{ 926{
931 int i; 927 int minor;
932 int err; 928 int err;
933 929
934 err = bdi_init(&zero_bdi); 930 err = bdi_init(&zero_bdi);
@@ -939,10 +935,12 @@ static int __init chr_dev_init(void)
939 printk("unable to get major %d for memory devs\n", MEM_MAJOR); 935 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
940 936
941 mem_class = class_create(THIS_MODULE, "mem"); 937 mem_class = class_create(THIS_MODULE, "mem");
942 for (i = 0; i < ARRAY_SIZE(devlist); i++) 938 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
943 device_create(mem_class, NULL, 939 if (!devlist[minor].name)
944 MKDEV(MEM_MAJOR, devlist[i].minor), NULL, 940 continue;
945 devlist[i].name); 941 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
942 NULL, devlist[minor].name);
943 }
946 944
947 return 0; 945 return 0;
948} 946}
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 97e656af2d22..9d0dfcbe2c1c 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -312,7 +312,7 @@ static void init_fw_attribute_group(struct device *dev,
312 group->groups[0] = &group->group; 312 group->groups[0] = &group->group;
313 group->groups[1] = NULL; 313 group->groups[1] = NULL;
314 group->group.attrs = group->attrs; 314 group->group.attrs = group->attrs;
315 dev->groups = group->groups; 315 dev->groups = (const struct attribute_group **) group->groups;
316} 316}
317 317
318static ssize_t modalias_show(struct device *dev, 318static ssize_t modalias_show(struct device *dev,
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 5a76d056b9d0..dbdf6fadfc79 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -139,7 +139,7 @@ static struct attribute_group sys_dmi_attribute_group = {
139 .attrs = sys_dmi_attributes, 139 .attrs = sys_dmi_attributes,
140}; 140};
141 141
142static struct attribute_group* sys_dmi_attribute_groups[] = { 142static const struct attribute_group* sys_dmi_attribute_groups[] = {
143 &sys_dmi_attribute_group, 143 &sys_dmi_attribute_group,
144 NULL 144 NULL
145}; 145};
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 5b635aa5947e..fb2d83c5bf01 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -623,7 +623,7 @@ static struct attribute_group ehca_drv_attr_grp = {
623 .attrs = ehca_drv_attrs 623 .attrs = ehca_drv_attrs
624}; 624};
625 625
626static struct attribute_group *ehca_drv_attr_groups[] = { 626static const struct attribute_group *ehca_drv_attr_groups[] = {
627 &ehca_drv_attr_grp, 627 &ehca_drv_attr_grp,
628 NULL, 628 NULL,
629}; 629};
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 6ba4861dd6ac..b3d7efcdf021 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -1286,7 +1286,7 @@ struct device_driver;
1286 1286
1287extern const char ib_ipath_version[]; 1287extern const char ib_ipath_version[];
1288 1288
1289extern struct attribute_group *ipath_driver_attr_groups[]; 1289extern const struct attribute_group *ipath_driver_attr_groups[];
1290 1290
1291int ipath_device_create_group(struct device *, struct ipath_devdata *); 1291int ipath_device_create_group(struct device *, struct ipath_devdata *);
1292void ipath_device_remove_group(struct device *, struct ipath_devdata *); 1292void ipath_device_remove_group(struct device *, struct ipath_devdata *);
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index a6c8efbdc0c9..b8cb2f145ae4 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -1069,7 +1069,7 @@ static ssize_t show_tempsense(struct device *dev,
1069 return ret; 1069 return ret;
1070} 1070}
1071 1071
1072struct attribute_group *ipath_driver_attr_groups[] = { 1072const struct attribute_group *ipath_driver_attr_groups[] = {
1073 &driver_attr_group, 1073 &driver_attr_group,
1074 NULL, 1074 NULL,
1075}; 1075};
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7c237e6ac711..851791d955f3 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1144,7 +1144,7 @@ static struct attribute_group input_dev_caps_attr_group = {
1144 .attrs = input_dev_caps_attrs, 1144 .attrs = input_dev_caps_attrs,
1145}; 1145};
1146 1146
1147static struct attribute_group *input_dev_attr_groups[] = { 1147static const struct attribute_group *input_dev_attr_groups[] = {
1148 &input_dev_attr_group, 1148 &input_dev_attr_group,
1149 &input_dev_id_attr_group, 1149 &input_dev_id_attr_group,
1150 &input_dev_caps_attr_group, 1150 &input_dev_caps_attr_group,
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 7b039306037f..e9eae4a78402 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -238,7 +238,7 @@ static void enclosure_component_release(struct device *dev)
238 put_device(dev->parent); 238 put_device(dev->parent);
239} 239}
240 240
241static struct attribute_group *enclosure_groups[]; 241static const struct attribute_group *enclosure_groups[];
242 242
243/** 243/**
244 * enclosure_component_register - add a particular component to an enclosure 244 * enclosure_component_register - add a particular component to an enclosure
@@ -536,7 +536,7 @@ static struct attribute_group enclosure_group = {
536 .attrs = enclosure_component_attrs, 536 .attrs = enclosure_component_attrs,
537}; 537};
538 538
539static struct attribute_group *enclosure_groups[] = { 539static const struct attribute_group *enclosure_groups[] = {
540 &enclosure_group, 540 &enclosure_group,
541 NULL 541 NULL
542}; 542};
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 880ccf39e23b..1ad27c6abcca 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/interrupt.h>
16#include <linux/ioport.h> 17#include <linux/ioport.h>
17#include <linux/device.h> 18#include <linux/device.h>
18#include <linux/file.h> 19#include <linux/file.h>
@@ -21,6 +22,8 @@
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/uaccess.h> 23#include <linux/uaccess.h>
23#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/wait.h>
26#include <linux/poll.h>
24#include "hpilo.h" 27#include "hpilo.h"
25 28
26static struct class *ilo_class; 29static struct class *ilo_class;
@@ -61,9 +64,10 @@ static inline int desc_mem_sz(int nr_entry)
61static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry) 64static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
62{ 65{
63 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar); 66 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
67 unsigned long flags;
64 int ret = 0; 68 int ret = 0;
65 69
66 spin_lock(&hw->fifo_lock); 70 spin_lock_irqsave(&hw->fifo_lock, flags);
67 if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask] 71 if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask]
68 & ENTRY_MASK_O)) { 72 & ENTRY_MASK_O)) {
69 fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |= 73 fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |=
@@ -71,7 +75,7 @@ static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
71 fifo_q->tail += 1; 75 fifo_q->tail += 1;
72 ret = 1; 76 ret = 1;
73 } 77 }
74 spin_unlock(&hw->fifo_lock); 78 spin_unlock_irqrestore(&hw->fifo_lock, flags);
75 79
76 return ret; 80 return ret;
77} 81}
@@ -79,10 +83,11 @@ static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
79static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry) 83static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
80{ 84{
81 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar); 85 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
86 unsigned long flags;
82 int ret = 0; 87 int ret = 0;
83 u64 c; 88 u64 c;
84 89
85 spin_lock(&hw->fifo_lock); 90 spin_lock_irqsave(&hw->fifo_lock, flags);
86 c = fifo_q->fifobar[fifo_q->head & fifo_q->imask]; 91 c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
87 if (c & ENTRY_MASK_C) { 92 if (c & ENTRY_MASK_C) {
88 if (entry) 93 if (entry)
@@ -93,7 +98,23 @@ static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
93 fifo_q->head += 1; 98 fifo_q->head += 1;
94 ret = 1; 99 ret = 1;
95 } 100 }
96 spin_unlock(&hw->fifo_lock); 101 spin_unlock_irqrestore(&hw->fifo_lock, flags);
102
103 return ret;
104}
105
106static int fifo_check_recv(struct ilo_hwinfo *hw, char *fifobar)
107{
108 struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
109 unsigned long flags;
110 int ret = 0;
111 u64 c;
112
113 spin_lock_irqsave(&hw->fifo_lock, flags);
114 c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
115 if (c & ENTRY_MASK_C)
116 ret = 1;
117 spin_unlock_irqrestore(&hw->fifo_lock, flags);
97 118
98 return ret; 119 return ret;
99} 120}
@@ -142,6 +163,13 @@ static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb,
142 return ret; 163 return ret;
143} 164}
144 165
166static int ilo_pkt_recv(struct ilo_hwinfo *hw, struct ccb *ccb)
167{
168 char *fifobar = ccb->ccb_u3.recv_fifobar;
169
170 return fifo_check_recv(hw, fifobar);
171}
172
145static inline void doorbell_set(struct ccb *ccb) 173static inline void doorbell_set(struct ccb *ccb)
146{ 174{
147 iowrite8(1, ccb->ccb_u5.db_base); 175 iowrite8(1, ccb->ccb_u5.db_base);
@@ -151,6 +179,7 @@ static inline void doorbell_clr(struct ccb *ccb)
151{ 179{
152 iowrite8(2, ccb->ccb_u5.db_base); 180 iowrite8(2, ccb->ccb_u5.db_base);
153} 181}
182
154static inline int ctrl_set(int l2sz, int idxmask, int desclim) 183static inline int ctrl_set(int l2sz, int idxmask, int desclim)
155{ 184{
156 int active = 0, go = 1; 185 int active = 0, go = 1;
@@ -160,6 +189,7 @@ static inline int ctrl_set(int l2sz, int idxmask, int desclim)
160 active << CTRL_BITPOS_A | 189 active << CTRL_BITPOS_A |
161 go << CTRL_BITPOS_G; 190 go << CTRL_BITPOS_G;
162} 191}
192
163static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz) 193static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz)
164{ 194{
165 /* for simplicity, use the same parameters for send and recv ctrls */ 195 /* for simplicity, use the same parameters for send and recv ctrls */
@@ -192,13 +222,10 @@ static void fifo_setup(void *base_addr, int nr_entry)
192 222
193static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data) 223static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
194{ 224{
195 struct ccb *driver_ccb; 225 struct ccb *driver_ccb = &data->driver_ccb;
196 struct ccb __iomem *device_ccb; 226 struct ccb __iomem *device_ccb = data->mapped_ccb;
197 int retries; 227 int retries;
198 228
199 driver_ccb = &data->driver_ccb;
200 device_ccb = data->mapped_ccb;
201
202 /* complicated dance to tell the hw we are stopping */ 229 /* complicated dance to tell the hw we are stopping */
203 doorbell_clr(driver_ccb); 230 doorbell_clr(driver_ccb);
204 iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G), 231 iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G),
@@ -225,26 +252,22 @@ static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
225 pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa); 252 pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
226} 253}
227 254
228static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) 255static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
229{ 256{
230 char *dma_va, *dma_pa; 257 char *dma_va, *dma_pa;
231 int pkt_id, pkt_sz, i, error;
232 struct ccb *driver_ccb, *ilo_ccb; 258 struct ccb *driver_ccb, *ilo_ccb;
233 struct pci_dev *pdev;
234 259
235 driver_ccb = &data->driver_ccb; 260 driver_ccb = &data->driver_ccb;
236 ilo_ccb = &data->ilo_ccb; 261 ilo_ccb = &data->ilo_ccb;
237 pdev = hw->ilo_dev;
238 262
239 data->dma_size = 2 * fifo_sz(NR_QENTRY) + 263 data->dma_size = 2 * fifo_sz(NR_QENTRY) +
240 2 * desc_mem_sz(NR_QENTRY) + 264 2 * desc_mem_sz(NR_QENTRY) +
241 ILO_START_ALIGN + ILO_CACHE_SZ; 265 ILO_START_ALIGN + ILO_CACHE_SZ;
242 266
243 error = -ENOMEM; 267 data->dma_va = pci_alloc_consistent(hw->ilo_dev, data->dma_size,
244 data->dma_va = pci_alloc_consistent(pdev, data->dma_size,
245 &data->dma_pa); 268 &data->dma_pa);
246 if (!data->dma_va) 269 if (!data->dma_va)
247 goto out; 270 return -ENOMEM;
248 271
249 dma_va = (char *)data->dma_va; 272 dma_va = (char *)data->dma_va;
250 dma_pa = (char *)data->dma_pa; 273 dma_pa = (char *)data->dma_pa;
@@ -290,10 +313,18 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
290 driver_ccb->ccb_u5.db_base = hw->db_vaddr + (slot << L2_DB_SIZE); 313 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 */ 314 ilo_ccb->ccb_u5.db_base = NULL; /* hw ccb's doorbell is not used */
292 315
316 return 0;
317}
318
319static void ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
320{
321 int pkt_id, pkt_sz;
322 struct ccb *driver_ccb = &data->driver_ccb;
323
293 /* copy the ccb with physical addrs to device memory */ 324 /* copy the ccb with physical addrs to device memory */
294 data->mapped_ccb = (struct ccb __iomem *) 325 data->mapped_ccb = (struct ccb __iomem *)
295 (hw->ram_vaddr + (slot * ILOHW_CCB_SZ)); 326 (hw->ram_vaddr + (slot * ILOHW_CCB_SZ));
296 memcpy_toio(data->mapped_ccb, ilo_ccb, sizeof(struct ccb)); 327 memcpy_toio(data->mapped_ccb, &data->ilo_ccb, sizeof(struct ccb));
297 328
298 /* put packets on the send and receive queues */ 329 /* put packets on the send and receive queues */
299 pkt_sz = 0; 330 pkt_sz = 0;
@@ -306,7 +337,14 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
306 for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) 337 for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++)
307 ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz); 338 ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz);
308 339
340 /* the ccb is ready to use */
309 doorbell_clr(driver_ccb); 341 doorbell_clr(driver_ccb);
342}
343
344static int ilo_ccb_verify(struct ilo_hwinfo *hw, struct ccb_data *data)
345{
346 int pkt_id, i;
347 struct ccb *driver_ccb = &data->driver_ccb;
310 348
311 /* make sure iLO is really handling requests */ 349 /* make sure iLO is really handling requests */
312 for (i = MAX_WAIT; i > 0; i--) { 350 for (i = MAX_WAIT; i > 0; i--) {
@@ -315,20 +353,14 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
315 udelay(WAIT_TIME); 353 udelay(WAIT_TIME);
316 } 354 }
317 355
318 if (i) { 356 if (i == 0) {
319 ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0); 357 dev_err(&hw->ilo_dev->dev, "Open could not dequeue a packet\n");
320 doorbell_set(driver_ccb); 358 return -EBUSY;
321 } else {
322 dev_err(&pdev->dev, "Open could not dequeue a packet\n");
323 error = -EBUSY;
324 goto free;
325 } 359 }
326 360
361 ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0);
362 doorbell_set(driver_ccb);
327 return 0; 363 return 0;
328free:
329 ilo_ccb_close(pdev, data);
330out:
331 return error;
332} 364}
333 365
334static inline int is_channel_reset(struct ccb *ccb) 366static inline int is_channel_reset(struct ccb *ccb)
@@ -343,19 +375,45 @@ static inline void set_channel_reset(struct ccb *ccb)
343 FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1; 375 FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1;
344} 376}
345 377
378static inline int get_device_outbound(struct ilo_hwinfo *hw)
379{
380 return ioread32(&hw->mmio_vaddr[DB_OUT]);
381}
382
383static inline int is_db_reset(int db_out)
384{
385 return db_out & (1 << DB_RESET);
386}
387
346static inline int is_device_reset(struct ilo_hwinfo *hw) 388static inline int is_device_reset(struct ilo_hwinfo *hw)
347{ 389{
348 /* check for global reset condition */ 390 /* check for global reset condition */
349 return ioread32(&hw->mmio_vaddr[DB_OUT]) & (1 << DB_RESET); 391 return is_db_reset(get_device_outbound(hw));
392}
393
394static inline void clear_pending_db(struct ilo_hwinfo *hw, int clr)
395{
396 iowrite32(clr, &hw->mmio_vaddr[DB_OUT]);
350} 397}
351 398
352static inline void clear_device(struct ilo_hwinfo *hw) 399static inline void clear_device(struct ilo_hwinfo *hw)
353{ 400{
354 /* clear the device (reset bits, pending channel entries) */ 401 /* clear the device (reset bits, pending channel entries) */
355 iowrite32(-1, &hw->mmio_vaddr[DB_OUT]); 402 clear_pending_db(hw, -1);
403}
404
405static inline void ilo_enable_interrupts(struct ilo_hwinfo *hw)
406{
407 iowrite8(ioread8(&hw->mmio_vaddr[DB_IRQ]) | 1, &hw->mmio_vaddr[DB_IRQ]);
356} 408}
357 409
358static void ilo_locked_reset(struct ilo_hwinfo *hw) 410static inline void ilo_disable_interrupts(struct ilo_hwinfo *hw)
411{
412 iowrite8(ioread8(&hw->mmio_vaddr[DB_IRQ]) & ~1,
413 &hw->mmio_vaddr[DB_IRQ]);
414}
415
416static void ilo_set_reset(struct ilo_hwinfo *hw)
359{ 417{
360 int slot; 418 int slot;
361 419
@@ -368,40 +426,22 @@ static void ilo_locked_reset(struct ilo_hwinfo *hw)
368 continue; 426 continue;
369 set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb); 427 set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb);
370 } 428 }
371
372 clear_device(hw);
373}
374
375static void ilo_reset(struct ilo_hwinfo *hw)
376{
377 spin_lock(&hw->alloc_lock);
378
379 /* reset might have been handled after lock was taken */
380 if (is_device_reset(hw))
381 ilo_locked_reset(hw);
382
383 spin_unlock(&hw->alloc_lock);
384} 429}
385 430
386static ssize_t ilo_read(struct file *fp, char __user *buf, 431static ssize_t ilo_read(struct file *fp, char __user *buf,
387 size_t len, loff_t *off) 432 size_t len, loff_t *off)
388{ 433{
389 int err, found, cnt, pkt_id, pkt_len; 434 int err, found, cnt, pkt_id, pkt_len;
390 struct ccb_data *data; 435 struct ccb_data *data = fp->private_data;
391 struct ccb *driver_ccb; 436 struct ccb *driver_ccb = &data->driver_ccb;
392 struct ilo_hwinfo *hw; 437 struct ilo_hwinfo *hw = data->ilo_hw;
393 void *pkt; 438 void *pkt;
394 439
395 data = fp->private_data; 440 if (is_channel_reset(driver_ccb)) {
396 driver_ccb = &data->driver_ccb;
397 hw = data->ilo_hw;
398
399 if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
400 /* 441 /*
401 * If the device has been reset, applications 442 * If the device has been reset, applications
402 * need to close and reopen all ccbs. 443 * need to close and reopen all ccbs.
403 */ 444 */
404 ilo_reset(hw);
405 return -ENODEV; 445 return -ENODEV;
406 } 446 }
407 447
@@ -442,23 +482,13 @@ static ssize_t ilo_write(struct file *fp, const char __user *buf,
442 size_t len, loff_t *off) 482 size_t len, loff_t *off)
443{ 483{
444 int err, pkt_id, pkt_len; 484 int err, pkt_id, pkt_len;
445 struct ccb_data *data; 485 struct ccb_data *data = fp->private_data;
446 struct ccb *driver_ccb; 486 struct ccb *driver_ccb = &data->driver_ccb;
447 struct ilo_hwinfo *hw; 487 struct ilo_hwinfo *hw = data->ilo_hw;
448 void *pkt; 488 void *pkt;
449 489
450 data = fp->private_data; 490 if (is_channel_reset(driver_ccb))
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; 491 return -ENODEV;
461 }
462 492
463 /* get a packet to send the user command */ 493 /* get a packet to send the user command */
464 if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt)) 494 if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt))
@@ -480,32 +510,48 @@ static ssize_t ilo_write(struct file *fp, const char __user *buf,
480 return err ? -EFAULT : len; 510 return err ? -EFAULT : len;
481} 511}
482 512
513static unsigned int ilo_poll(struct file *fp, poll_table *wait)
514{
515 struct ccb_data *data = fp->private_data;
516 struct ccb *driver_ccb = &data->driver_ccb;
517
518 poll_wait(fp, &data->ccb_waitq, wait);
519
520 if (is_channel_reset(driver_ccb))
521 return POLLERR;
522 else if (ilo_pkt_recv(data->ilo_hw, driver_ccb))
523 return POLLIN | POLLRDNORM;
524
525 return 0;
526}
527
483static int ilo_close(struct inode *ip, struct file *fp) 528static int ilo_close(struct inode *ip, struct file *fp)
484{ 529{
485 int slot; 530 int slot;
486 struct ccb_data *data; 531 struct ccb_data *data;
487 struct ilo_hwinfo *hw; 532 struct ilo_hwinfo *hw;
533 unsigned long flags;
488 534
489 slot = iminor(ip) % MAX_CCB; 535 slot = iminor(ip) % MAX_CCB;
490 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev); 536 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
491 537
492 spin_lock(&hw->alloc_lock); 538 spin_lock(&hw->open_lock);
493
494 if (is_device_reset(hw))
495 ilo_locked_reset(hw);
496 539
497 if (hw->ccb_alloc[slot]->ccb_cnt == 1) { 540 if (hw->ccb_alloc[slot]->ccb_cnt == 1) {
498 541
499 data = fp->private_data; 542 data = fp->private_data;
500 543
544 spin_lock_irqsave(&hw->alloc_lock, flags);
545 hw->ccb_alloc[slot] = NULL;
546 spin_unlock_irqrestore(&hw->alloc_lock, flags);
547
501 ilo_ccb_close(hw->ilo_dev, data); 548 ilo_ccb_close(hw->ilo_dev, data);
502 549
503 kfree(data); 550 kfree(data);
504 hw->ccb_alloc[slot] = NULL;
505 } else 551 } else
506 hw->ccb_alloc[slot]->ccb_cnt--; 552 hw->ccb_alloc[slot]->ccb_cnt--;
507 553
508 spin_unlock(&hw->alloc_lock); 554 spin_unlock(&hw->open_lock);
509 555
510 return 0; 556 return 0;
511} 557}
@@ -515,6 +561,7 @@ static int ilo_open(struct inode *ip, struct file *fp)
515 int slot, error; 561 int slot, error;
516 struct ccb_data *data; 562 struct ccb_data *data;
517 struct ilo_hwinfo *hw; 563 struct ilo_hwinfo *hw;
564 unsigned long flags;
518 565
519 slot = iminor(ip) % MAX_CCB; 566 slot = iminor(ip) % MAX_CCB;
520 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev); 567 hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
@@ -524,22 +571,42 @@ static int ilo_open(struct inode *ip, struct file *fp)
524 if (!data) 571 if (!data)
525 return -ENOMEM; 572 return -ENOMEM;
526 573
527 spin_lock(&hw->alloc_lock); 574 spin_lock(&hw->open_lock);
528
529 if (is_device_reset(hw))
530 ilo_locked_reset(hw);
531 575
532 /* each fd private_data holds sw/hw view of ccb */ 576 /* each fd private_data holds sw/hw view of ccb */
533 if (hw->ccb_alloc[slot] == NULL) { 577 if (hw->ccb_alloc[slot] == NULL) {
534 /* create a channel control block for this minor */ 578 /* create a channel control block for this minor */
535 error = ilo_ccb_open(hw, data, slot); 579 error = ilo_ccb_setup(hw, data, slot);
536 if (!error) { 580 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); 581 kfree(data);
582 goto out;
583 }
584
585 data->ccb_cnt = 1;
586 data->ccb_excl = fp->f_flags & O_EXCL;
587 data->ilo_hw = hw;
588 init_waitqueue_head(&data->ccb_waitq);
589
590 /* write the ccb to hw */
591 spin_lock_irqsave(&hw->alloc_lock, flags);
592 ilo_ccb_open(hw, data, slot);
593 hw->ccb_alloc[slot] = data;
594 spin_unlock_irqrestore(&hw->alloc_lock, flags);
595
596 /* make sure the channel is functional */
597 error = ilo_ccb_verify(hw, data);
598 if (error) {
599
600 spin_lock_irqsave(&hw->alloc_lock, flags);
601 hw->ccb_alloc[slot] = NULL;
602 spin_unlock_irqrestore(&hw->alloc_lock, flags);
603
604 ilo_ccb_close(hw->ilo_dev, data);
605
606 kfree(data);
607 goto out;
608 }
609
543 } else { 610 } else {
544 kfree(data); 611 kfree(data);
545 if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) { 612 if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) {
@@ -554,7 +621,8 @@ static int ilo_open(struct inode *ip, struct file *fp)
554 error = 0; 621 error = 0;
555 } 622 }
556 } 623 }
557 spin_unlock(&hw->alloc_lock); 624out:
625 spin_unlock(&hw->open_lock);
558 626
559 if (!error) 627 if (!error)
560 fp->private_data = hw->ccb_alloc[slot]; 628 fp->private_data = hw->ccb_alloc[slot];
@@ -566,10 +634,46 @@ static const struct file_operations ilo_fops = {
566 .owner = THIS_MODULE, 634 .owner = THIS_MODULE,
567 .read = ilo_read, 635 .read = ilo_read,
568 .write = ilo_write, 636 .write = ilo_write,
637 .poll = ilo_poll,
569 .open = ilo_open, 638 .open = ilo_open,
570 .release = ilo_close, 639 .release = ilo_close,
571}; 640};
572 641
642static irqreturn_t ilo_isr(int irq, void *data)
643{
644 struct ilo_hwinfo *hw = data;
645 int pending, i;
646
647 spin_lock(&hw->alloc_lock);
648
649 /* check for ccbs which have data */
650 pending = get_device_outbound(hw);
651 if (!pending) {
652 spin_unlock(&hw->alloc_lock);
653 return IRQ_NONE;
654 }
655
656 if (is_db_reset(pending)) {
657 /* wake up all ccbs if the device was reset */
658 pending = -1;
659 ilo_set_reset(hw);
660 }
661
662 for (i = 0; i < MAX_CCB; i++) {
663 if (!hw->ccb_alloc[i])
664 continue;
665 if (pending & (1 << i))
666 wake_up_interruptible(&hw->ccb_alloc[i]->ccb_waitq);
667 }
668
669 /* clear the device of the channels that have been handled */
670 clear_pending_db(hw, pending);
671
672 spin_unlock(&hw->alloc_lock);
673
674 return IRQ_HANDLED;
675}
676
573static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw) 677static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
574{ 678{
575 pci_iounmap(pdev, hw->db_vaddr); 679 pci_iounmap(pdev, hw->db_vaddr);
@@ -623,6 +727,8 @@ static void ilo_remove(struct pci_dev *pdev)
623 device_destroy(ilo_class, MKDEV(ilo_major, i)); 727 device_destroy(ilo_class, MKDEV(ilo_major, i));
624 728
625 cdev_del(&ilo_hw->cdev); 729 cdev_del(&ilo_hw->cdev);
730 ilo_disable_interrupts(ilo_hw);
731 free_irq(pdev->irq, ilo_hw);
626 ilo_unmap_device(pdev, ilo_hw); 732 ilo_unmap_device(pdev, ilo_hw);
627 pci_release_regions(pdev); 733 pci_release_regions(pdev);
628 pci_disable_device(pdev); 734 pci_disable_device(pdev);
@@ -658,6 +764,7 @@ static int __devinit ilo_probe(struct pci_dev *pdev,
658 ilo_hw->ilo_dev = pdev; 764 ilo_hw->ilo_dev = pdev;
659 spin_lock_init(&ilo_hw->alloc_lock); 765 spin_lock_init(&ilo_hw->alloc_lock);
660 spin_lock_init(&ilo_hw->fifo_lock); 766 spin_lock_init(&ilo_hw->fifo_lock);
767 spin_lock_init(&ilo_hw->open_lock);
661 768
662 error = pci_enable_device(pdev); 769 error = pci_enable_device(pdev);
663 if (error) 770 if (error)
@@ -676,13 +783,19 @@ static int __devinit ilo_probe(struct pci_dev *pdev,
676 pci_set_drvdata(pdev, ilo_hw); 783 pci_set_drvdata(pdev, ilo_hw);
677 clear_device(ilo_hw); 784 clear_device(ilo_hw);
678 785
786 error = request_irq(pdev->irq, ilo_isr, IRQF_SHARED, "hpilo", ilo_hw);
787 if (error)
788 goto unmap;
789
790 ilo_enable_interrupts(ilo_hw);
791
679 cdev_init(&ilo_hw->cdev, &ilo_fops); 792 cdev_init(&ilo_hw->cdev, &ilo_fops);
680 ilo_hw->cdev.owner = THIS_MODULE; 793 ilo_hw->cdev.owner = THIS_MODULE;
681 start = devnum * MAX_CCB; 794 start = devnum * MAX_CCB;
682 error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB); 795 error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB);
683 if (error) { 796 if (error) {
684 dev_err(&pdev->dev, "Could not add cdev\n"); 797 dev_err(&pdev->dev, "Could not add cdev\n");
685 goto unmap; 798 goto remove_isr;
686 } 799 }
687 800
688 for (minor = 0 ; minor < MAX_CCB; minor++) { 801 for (minor = 0 ; minor < MAX_CCB; minor++) {
@@ -695,6 +808,9 @@ static int __devinit ilo_probe(struct pci_dev *pdev,
695 } 808 }
696 809
697 return 0; 810 return 0;
811remove_isr:
812 ilo_disable_interrupts(ilo_hw);
813 free_irq(pdev->irq, ilo_hw);
698unmap: 814unmap:
699 ilo_unmap_device(pdev, ilo_hw); 815 ilo_unmap_device(pdev, ilo_hw);
700free_regions: 816free_regions:
@@ -759,7 +875,7 @@ static void __exit ilo_exit(void)
759 class_destroy(ilo_class); 875 class_destroy(ilo_class);
760} 876}
761 877
762MODULE_VERSION("1.1"); 878MODULE_VERSION("1.2");
763MODULE_ALIAS(ILO_NAME); 879MODULE_ALIAS(ILO_NAME);
764MODULE_DESCRIPTION(ILO_NAME); 880MODULE_DESCRIPTION(ILO_NAME);
765MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); 881MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
diff --git a/drivers/misc/hpilo.h b/drivers/misc/hpilo.h
index 03a14c82aad9..38576050776a 100644
--- a/drivers/misc/hpilo.h
+++ b/drivers/misc/hpilo.h
@@ -46,11 +46,14 @@ struct ilo_hwinfo {
46 46
47 spinlock_t alloc_lock; 47 spinlock_t alloc_lock;
48 spinlock_t fifo_lock; 48 spinlock_t fifo_lock;
49 spinlock_t open_lock;
49 50
50 struct cdev cdev; 51 struct cdev cdev;
51}; 52};
52 53
53/* offset from mmio_vaddr */ 54/* offset from mmio_vaddr for enabling doorbell interrupts */
55#define DB_IRQ 0xB2
56/* offset from mmio_vaddr for outbound communications */
54#define DB_OUT 0xD4 57#define DB_OUT 0xD4
55/* DB_OUT reset bit */ 58/* DB_OUT reset bit */
56#define DB_RESET 26 59#define DB_RESET 26
@@ -131,6 +134,9 @@ struct ccb_data {
131 /* pointer to hardware device info */ 134 /* pointer to hardware device info */
132 struct ilo_hwinfo *ilo_hw; 135 struct ilo_hwinfo *ilo_hw;
133 136
137 /* queue for this ccb to wait for recv data */
138 wait_queue_head_t ccb_waitq;
139
134 /* usage count, to allow for shared ccb's */ 140 /* usage count, to allow for shared ccb's */
135 int ccb_cnt; 141 int ccb_cnt;
136 142
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 06084dbf1277..2fb9d5f271ea 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -276,7 +276,7 @@ static struct attribute_group mmc_std_attr_group = {
276 .attrs = mmc_std_attrs, 276 .attrs = mmc_std_attrs,
277}; 277};
278 278
279static struct attribute_group *mmc_attr_groups[] = { 279static const struct attribute_group *mmc_attr_groups[] = {
280 &mmc_std_attr_group, 280 &mmc_std_attr_group,
281 NULL, 281 NULL,
282}; 282};
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index cd81c395e164..7ad646fe077e 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -314,7 +314,7 @@ static struct attribute_group sd_std_attr_group = {
314 .attrs = sd_std_attrs, 314 .attrs = sd_std_attrs,
315}; 315};
316 316
317static struct attribute_group *sd_attr_groups[] = { 317static const struct attribute_group *sd_attr_groups[] = {
318 &sd_std_attr_group, 318 &sd_std_attr_group,
319 NULL, 319 NULL,
320}; 320};
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 00ebf7af7467..69007a6eff50 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -217,7 +217,7 @@ struct attribute_group mtd_group = {
217 .attrs = mtd_attrs, 217 .attrs = mtd_attrs,
218}; 218};
219 219
220struct attribute_group *mtd_groups[] = { 220const struct attribute_group *mtd_groups[] = {
221 &mtd_group, 221 &mtd_group,
222 NULL, 222 NULL,
223}; 223};
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig
index c62da435285a..c25a04371ca8 100644
--- a/drivers/net/wireless/iwmc3200wifi/Kconfig
+++ b/drivers/net/wireless/iwmc3200wifi/Kconfig
@@ -24,8 +24,8 @@ config IWM_DEBUG
24 To see the list of debug modules and levels, see iwm/debug.h 24 To see the list of debug modules and levels, see iwm/debug.h
25 25
26 For example, if you want the full MLME debug output: 26 For example, if you want the full MLME debug output:
27 echo 0xff > /debug/iwm/phyN/debug/mlme 27 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/mlme
28 28
29 Or, if you want the full debug, for all modules: 29 Or, if you want the full debug, for all modules:
30 echo 0xff > /debug/iwm/phyN/debug/level 30 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/level
31 echo 0xff > /debug/iwm/phyN/debug/modules 31 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/modules
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index e995123fd805..393c73c47f87 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -266,7 +266,7 @@ static struct attribute_group subch_attr_group = {
266 .attrs = subch_attrs, 266 .attrs = subch_attrs,
267}; 267};
268 268
269static struct attribute_group *default_subch_attr_groups[] = { 269static const struct attribute_group *default_subch_attr_groups[] = {
270 &subch_attr_group, 270 &subch_attr_group,
271 NULL, 271 NULL,
272}; 272};
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 0f95405c2c5e..6527f3f34493 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -656,7 +656,7 @@ static struct attribute_group ccwdev_attr_group = {
656 .attrs = ccwdev_attrs, 656 .attrs = ccwdev_attrs,
657}; 657};
658 658
659static struct attribute_group *ccwdev_attr_groups[] = { 659static const struct attribute_group *ccwdev_attr_groups[] = {
660 &ccwdev_attr_group, 660 &ccwdev_attr_group,
661 NULL, 661 NULL,
662}; 662};
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 9215fbbccc08..a4b2c576144b 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2159,7 +2159,7 @@ static struct attribute_group netiucv_drv_attr_group = {
2159 .attrs = netiucv_drv_attrs, 2159 .attrs = netiucv_drv_attrs,
2160}; 2160};
2161 2161
2162static struct attribute_group *netiucv_drv_attr_groups[] = { 2162static const struct attribute_group *netiucv_drv_attr_groups[] = {
2163 &netiucv_drv_attr_group, 2163 &netiucv_drv_attr_group,
2164 NULL, 2164 NULL,
2165}; 2165};
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 021e503c8c44..1fbf7c78bba0 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -132,7 +132,7 @@ extern struct scsi_transport_template blank_transport_template;
132extern void __scsi_remove_device(struct scsi_device *); 132extern void __scsi_remove_device(struct scsi_device *);
133 133
134extern struct bus_type scsi_bus_type; 134extern struct bus_type scsi_bus_type;
135extern struct attribute_group *scsi_sysfs_shost_attr_groups[]; 135extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
136 136
137/* scsi_netlink.c */ 137/* scsi_netlink.c */
138#ifdef CONFIG_SCSI_NETLINK 138#ifdef CONFIG_SCSI_NETLINK
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 91482f2dcc50..fde54537d715 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -275,7 +275,7 @@ struct attribute_group scsi_shost_attr_group = {
275 .attrs = scsi_sysfs_shost_attrs, 275 .attrs = scsi_sysfs_shost_attrs,
276}; 276};
277 277
278struct attribute_group *scsi_sysfs_shost_attr_groups[] = { 278const struct attribute_group *scsi_sysfs_shost_attr_groups[] = {
279 &scsi_shost_attr_group, 279 &scsi_shost_attr_group,
280 NULL 280 NULL
281}; 281};
@@ -745,7 +745,7 @@ static struct attribute_group scsi_sdev_attr_group = {
745 .attrs = scsi_sdev_attrs, 745 .attrs = scsi_sdev_attrs,
746}; 746};
747 747
748static struct attribute_group *scsi_sdev_attr_groups[] = { 748static const struct attribute_group *scsi_sdev_attr_groups[] = {
749 &scsi_sdev_attr_group, 749 &scsi_sdev_attr_group,
750 NULL 750 NULL
751}; 751};
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 7f86534de269..8aa1955f35ed 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -1,7 +1,6 @@
1menuconfig UIO 1menuconfig UIO
2 tristate "Userspace I/O drivers" 2 tristate "Userspace I/O drivers"
3 depends on !S390 3 depends on !S390
4 default n
5 help 4 help
6 Enable this to allow the userspace driver core code to be 5 Enable this to allow the userspace driver core code to be
7 built. This code allows userspace programs easy access to 6 built. This code allows userspace programs easy access to
@@ -16,7 +15,6 @@ if UIO
16config UIO_CIF 15config UIO_CIF
17 tristate "generic Hilscher CIF Card driver" 16 tristate "generic Hilscher CIF Card driver"
18 depends on PCI 17 depends on PCI
19 default n
20 help 18 help
21 Driver for Hilscher CIF DeviceNet and Profibus cards. This 19 Driver for Hilscher CIF DeviceNet and Profibus cards. This
22 driver requires a userspace component that handles all of the 20 driver requires a userspace component that handles all of the
@@ -48,7 +46,6 @@ config UIO_PDRV_GENIRQ
48 46
49config UIO_SMX 47config UIO_SMX
50 tristate "SMX cryptengine UIO interface" 48 tristate "SMX cryptengine UIO interface"
51 default n
52 help 49 help
53 Userspace IO interface to the Cryptography engine found on the 50 Userspace IO interface to the Cryptography engine found on the
54 Nias Digital SMX boards. These will be available from Q4 2008 51 Nias Digital SMX boards. These will be available from Q4 2008
@@ -61,7 +58,6 @@ config UIO_SMX
61config UIO_AEC 58config UIO_AEC
62 tristate "AEC video timestamp device" 59 tristate "AEC video timestamp device"
63 depends on PCI 60 depends on PCI
64 default n
65 help 61 help
66 62
67 UIO driver for the Adrienne Electronics Corporation PCI time 63 UIO driver for the Adrienne Electronics Corporation PCI time
@@ -78,7 +74,6 @@ config UIO_AEC
78 74
79config UIO_SERCOS3 75config UIO_SERCOS3
80 tristate "Automata Sercos III PCI card driver" 76 tristate "Automata Sercos III PCI card driver"
81 default n
82 help 77 help
83 Userspace I/O interface for the Sercos III PCI card from 78 Userspace I/O interface for the Sercos III PCI card from
84 Automata GmbH. The userspace part of this driver will be 79 Automata GmbH. The userspace part of this driver will be
@@ -89,4 +84,14 @@ config UIO_SERCOS3
89 84
90 If you compile this as a module, it will be called uio_sercos3. 85 If you compile this as a module, it will be called uio_sercos3.
91 86
87config UIO_PCI_GENERIC
88 tristate "Generic driver for PCI 2.3 and PCI Express cards"
89 depends on PCI
90 default n
91 help
92 Generic driver that you can bind, dynamically, to any
93 PCI 2.3 compliant and PCI Express card. It is useful,
94 primarily, for virtualization scenarios.
95 If you compile this as a module, it will be called uio_pci_generic.
96
92endif 97endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 5c2586d75797..73b2e7516729 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o
5obj-$(CONFIG_UIO_SMX) += uio_smx.o 5obj-$(CONFIG_UIO_SMX) += uio_smx.o
6obj-$(CONFIG_UIO_AEC) += uio_aec.o 6obj-$(CONFIG_UIO_AEC) += uio_aec.o
7obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o 7obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
8obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
new file mode 100644
index 000000000000..313da35984af
--- /dev/null
+++ b/drivers/uio/uio_pci_generic.c
@@ -0,0 +1,207 @@
1/* uio_pci_generic - generic UIO driver for PCI 2.3 devices
2 *
3 * Copyright (C) 2009 Red Hat, Inc.
4 * Author: Michael S. Tsirkin <mst@redhat.com>
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2.
7 *
8 * Since the driver does not declare any device ids, you must allocate
9 * id and bind the device to the driver yourself. For example:
10 *
11 * # echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id
12 * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
13 * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/uio_pci_generic/bind
14 * # ls -l /sys/bus/pci/devices/0000:00:19.0/driver
15 * .../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic
16 *
17 * Driver won't bind to devices which do not support the Interrupt Disable Bit
18 * in the command register. All devices compliant to PCI 2.3 (circa 2002) and
19 * all compliant PCI Express devices should support this bit.
20 */
21
22#include <linux/device.h>
23#include <linux/module.h>
24#include <linux/pci.h>
25#include <linux/uio_driver.h>
26#include <linux/spinlock.h>
27
28#define DRIVER_VERSION "0.01.0"
29#define DRIVER_AUTHOR "Michael S. Tsirkin <mst@redhat.com>"
30#define DRIVER_DESC "Generic UIO driver for PCI 2.3 devices"
31
32struct uio_pci_generic_dev {
33 struct uio_info info;
34 struct pci_dev *pdev;
35 spinlock_t lock; /* guards command register accesses */
36};
37
38static inline struct uio_pci_generic_dev *
39to_uio_pci_generic_dev(struct uio_info *info)
40{
41 return container_of(info, struct uio_pci_generic_dev, info);
42}
43
44/* Interrupt handler. Read/modify/write the command register to disable
45 * the interrupt. */
46static irqreturn_t irqhandler(int irq, struct uio_info *info)
47{
48 struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info);
49 struct pci_dev *pdev = gdev->pdev;
50 irqreturn_t ret = IRQ_NONE;
51 u32 cmd_status_dword;
52 u16 origcmd, newcmd, status;
53
54 /* We do a single dword read to retrieve both command and status.
55 * Document assumptions that make this possible. */
56 BUILD_BUG_ON(PCI_COMMAND % 4);
57 BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS);
58
59 spin_lock_irq(&gdev->lock);
60 pci_block_user_cfg_access(pdev);
61
62 /* Read both command and status registers in a single 32-bit operation.
63 * Note: we could cache the value for command and move the status read
64 * out of the lock if there was a way to get notified of user changes
65 * to command register through sysfs. Should be good for shared irqs. */
66 pci_read_config_dword(pdev, PCI_COMMAND, &cmd_status_dword);
67 origcmd = cmd_status_dword;
68 status = cmd_status_dword >> 16;
69
70 /* Check interrupt status register to see whether our device
71 * triggered the interrupt. */
72 if (!(status & PCI_STATUS_INTERRUPT))
73 goto done;
74
75 /* We triggered the interrupt, disable it. */
76 newcmd = origcmd | PCI_COMMAND_INTX_DISABLE;
77 if (newcmd != origcmd)
78 pci_write_config_word(pdev, PCI_COMMAND, newcmd);
79
80 /* UIO core will signal the user process. */
81 ret = IRQ_HANDLED;
82done:
83
84 pci_unblock_user_cfg_access(pdev);
85 spin_unlock_irq(&gdev->lock);
86 return ret;
87}
88
89/* Verify that the device supports Interrupt Disable bit in command register,
90 * per PCI 2.3, by flipping this bit and reading it back: this bit was readonly
91 * in PCI 2.2. */
92static int __devinit verify_pci_2_3(struct pci_dev *pdev)
93{
94 u16 orig, new;
95 int err = 0;
96
97 pci_block_user_cfg_access(pdev);
98 pci_read_config_word(pdev, PCI_COMMAND, &orig);
99 pci_write_config_word(pdev, PCI_COMMAND,
100 orig ^ PCI_COMMAND_INTX_DISABLE);
101 pci_read_config_word(pdev, PCI_COMMAND, &new);
102 /* There's no way to protect against
103 * hardware bugs or detect them reliably, but as long as we know
104 * what the value should be, let's go ahead and check it. */
105 if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
106 err = -EBUSY;
107 dev_err(&pdev->dev, "Command changed from 0x%x to 0x%x: "
108 "driver or HW bug?\n", orig, new);
109 goto err;
110 }
111 if (!((new ^ orig) & PCI_COMMAND_INTX_DISABLE)) {
112 dev_warn(&pdev->dev, "Device does not support "
113 "disabling interrupts: unable to bind.\n");
114 err = -ENODEV;
115 goto err;
116 }
117 /* Now restore the original value. */
118 pci_write_config_word(pdev, PCI_COMMAND, orig);
119err:
120 pci_unblock_user_cfg_access(pdev);
121 return err;
122}
123
124static int __devinit probe(struct pci_dev *pdev,
125 const struct pci_device_id *id)
126{
127 struct uio_pci_generic_dev *gdev;
128 int err;
129
130 if (!pdev->irq) {
131 dev_warn(&pdev->dev, "No IRQ assigned to device: "
132 "no support for interrupts?\n");
133 return -ENODEV;
134 }
135
136 err = pci_enable_device(pdev);
137 if (err) {
138 dev_err(&pdev->dev, "%s: pci_enable_device failed: %d\n",
139 __func__, err);
140 return err;
141 }
142
143 err = verify_pci_2_3(pdev);
144 if (err)
145 goto err_verify;
146
147 gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL);
148 if (!gdev) {
149 err = -ENOMEM;
150 goto err_alloc;
151 }
152
153 gdev->info.name = "uio_pci_generic";
154 gdev->info.version = DRIVER_VERSION;
155 gdev->info.irq = pdev->irq;
156 gdev->info.irq_flags = IRQF_SHARED;
157 gdev->info.handler = irqhandler;
158 gdev->pdev = pdev;
159 spin_lock_init(&gdev->lock);
160
161 if (uio_register_device(&pdev->dev, &gdev->info))
162 goto err_register;
163 pci_set_drvdata(pdev, gdev);
164
165 return 0;
166err_register:
167 kfree(gdev);
168err_alloc:
169err_verify:
170 pci_disable_device(pdev);
171 return err;
172}
173
174static void remove(struct pci_dev *pdev)
175{
176 struct uio_pci_generic_dev *gdev = pci_get_drvdata(pdev);
177
178 uio_unregister_device(&gdev->info);
179 pci_disable_device(pdev);
180 kfree(gdev);
181}
182
183static struct pci_driver driver = {
184 .name = "uio_pci_generic",
185 .id_table = NULL, /* only dynamic id's */
186 .probe = probe,
187 .remove = remove,
188};
189
190static int __init init(void)
191{
192 pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
193 return pci_register_driver(&driver);
194}
195
196static void __exit cleanup(void)
197{
198 pci_unregister_driver(&driver);
199}
200
201module_init(init);
202module_exit(cleanup);
203
204MODULE_VERSION(DRIVER_VERSION);
205MODULE_LICENSE("GPL v2");
206MODULE_AUTHOR(DRIVER_AUTHOR);
207MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index bc39fc40bbde..fdfaa7885515 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -154,7 +154,7 @@ static struct attribute *ep_dev_attrs[] = {
154static struct attribute_group ep_dev_attr_grp = { 154static struct attribute_group ep_dev_attr_grp = {
155 .attrs = ep_dev_attrs, 155 .attrs = ep_dev_attrs,
156}; 156};
157static struct attribute_group *ep_dev_groups[] = { 157static const struct attribute_group *ep_dev_groups[] = {
158 &ep_dev_attr_grp, 158 &ep_dev_attr_grp,
159 NULL 159 NULL
160}; 160};
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index b5c72e458943..7ec3041ae79e 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -573,7 +573,7 @@ static struct attribute_group dev_string_attr_grp = {
573 .is_visible = dev_string_attrs_are_visible, 573 .is_visible = dev_string_attrs_are_visible,
574}; 574};
575 575
576struct attribute_group *usb_device_groups[] = { 576const struct attribute_group *usb_device_groups[] = {
577 &dev_attr_grp, 577 &dev_attr_grp,
578 &dev_string_attr_grp, 578 &dev_string_attr_grp,
579 NULL 579 NULL
@@ -799,7 +799,7 @@ static struct attribute_group intf_assoc_attr_grp = {
799 .is_visible = intf_assoc_attrs_are_visible, 799 .is_visible = intf_assoc_attrs_are_visible,
800}; 800};
801 801
802struct attribute_group *usb_interface_groups[] = { 802const struct attribute_group *usb_interface_groups[] = {
803 &intf_attr_grp, 803 &intf_attr_grp,
804 &intf_assoc_attr_grp, 804 &intf_assoc_attr_grp,
805 NULL 805 NULL
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index e2a8cfaade1d..c0e0ae2bb8e7 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -152,8 +152,8 @@ static inline int is_active(const struct usb_interface *f)
152extern const char *usbcore_name; 152extern const char *usbcore_name;
153 153
154/* sysfs stuff */ 154/* sysfs stuff */
155extern struct attribute_group *usb_device_groups[]; 155extern const struct attribute_group *usb_device_groups[];
156extern struct attribute_group *usb_interface_groups[]; 156extern const struct attribute_group *usb_interface_groups[];
157 157
158/* usbfs stuff */ 158/* usbfs stuff */
159extern struct mutex usbfs_mutex; 159extern struct mutex usbfs_mutex;
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 274751b4409c..5cd0e48f67fb 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -67,7 +67,7 @@ MODULE_PARM_DESC(ignore_oc, "ignore hardware overcurrent indications");
67 * debug = 0, no debugging messages 67 * debug = 0, no debugging messages
68 * debug = 1, dump failed URBs except for stalls 68 * debug = 1, dump failed URBs except for stalls
69 * debug = 2, dump all failed URBs (including stalls) 69 * debug = 2, dump all failed URBs (including stalls)
70 * show all queues in /debug/uhci/[pci_addr] 70 * show all queues in /sys/kernel/debug/uhci/[pci_addr]
71 * debug = 3, show all TDs in URBs when dumping 71 * debug = 3, show all TDs in URBs when dumping
72 */ 72 */
73#ifdef DEBUG 73#ifdef DEBUG
diff --git a/drivers/uwb/lc-dev.c b/drivers/uwb/lc-dev.c
index e9fe1bb7eb23..1097e81b56d0 100644
--- a/drivers/uwb/lc-dev.c
+++ b/drivers/uwb/lc-dev.c
@@ -255,7 +255,7 @@ static struct attribute_group dev_attr_group = {
255 .attrs = dev_attrs, 255 .attrs = dev_attrs,
256}; 256};
257 257
258static struct attribute_group *groups[] = { 258static const struct attribute_group *groups[] = {
259 &dev_attr_group, 259 &dev_attr_group,
260 NULL, 260 NULL,
261}; 261};
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 619ba99dfe39..fbeaddf595d3 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -312,7 +312,7 @@ static struct attribute_group part_attr_group = {
312 .attrs = part_attrs, 312 .attrs = part_attrs,
313}; 313};
314 314
315static struct attribute_group *part_attr_groups[] = { 315static const struct attribute_group *part_attr_groups[] = {
316 &part_attr_group, 316 &part_attr_group,
317#ifdef CONFIG_BLK_DEV_IO_TRACE 317#ifdef CONFIG_BLK_DEV_IO_TRACE
318 &blk_trace_attr_group, 318 &blk_trace_attr_group,
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h
index 794ad74b1d61..c3ab81428c66 100644
--- a/include/linux/attribute_container.h
+++ b/include/linux/attribute_container.h
@@ -17,7 +17,7 @@ struct attribute_container {
17 struct list_head node; 17 struct list_head node;
18 struct klist containers; 18 struct klist containers;
19 struct class *class; 19 struct class *class;
20 struct attribute_group *grp; 20 const struct attribute_group *grp;
21 struct device_attribute **attrs; 21 struct device_attribute **attrs;
22 int (*match)(struct attribute_container *, struct device *); 22 int (*match)(struct attribute_container *, struct device *);
23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
diff --git a/include/linux/device.h b/include/linux/device.h
index a28642975053..847b763e40e9 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -2,7 +2,8 @@
2 * device.h - generic, centralized driver model 2 * device.h - generic, centralized driver model
3 * 3 *
4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> 4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
5 * Copyright (c) 2004-2007 Greg Kroah-Hartman <gregkh@suse.de> 5 * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (c) 2008-2009 Novell Inc.
6 * 7 *
7 * This file is released under the GPLv2 8 * This file is released under the GPLv2
8 * 9 *
@@ -130,7 +131,7 @@ struct device_driver {
130 void (*shutdown) (struct device *dev); 131 void (*shutdown) (struct device *dev);
131 int (*suspend) (struct device *dev, pm_message_t state); 132 int (*suspend) (struct device *dev, pm_message_t state);
132 int (*resume) (struct device *dev); 133 int (*resume) (struct device *dev);
133 struct attribute_group **groups; 134 const struct attribute_group **groups;
134 135
135 const struct dev_pm_ops *pm; 136 const struct dev_pm_ops *pm;
136 137
@@ -224,6 +225,14 @@ extern void class_unregister(struct class *class);
224 __class_register(class, &__key); \ 225 __class_register(class, &__key); \
225}) 226})
226 227
228struct class_compat;
229struct class_compat *class_compat_register(const char *name);
230void class_compat_unregister(struct class_compat *cls);
231int class_compat_create_link(struct class_compat *cls, struct device *dev,
232 struct device *device_link);
233void class_compat_remove_link(struct class_compat *cls, struct device *dev,
234 struct device *device_link);
235
227extern void class_dev_iter_init(struct class_dev_iter *iter, 236extern void class_dev_iter_init(struct class_dev_iter *iter,
228 struct class *class, 237 struct class *class,
229 struct device *start, 238 struct device *start,
@@ -287,7 +296,7 @@ extern void class_destroy(struct class *cls);
287 */ 296 */
288struct device_type { 297struct device_type {
289 const char *name; 298 const char *name;
290 struct attribute_group **groups; 299 const struct attribute_group **groups;
291 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 300 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
292 char *(*nodename)(struct device *dev); 301 char *(*nodename)(struct device *dev);
293 void (*release)(struct device *dev); 302 void (*release)(struct device *dev);
@@ -381,7 +390,6 @@ struct device {
381 struct bus_type *bus; /* type of bus device is on */ 390 struct bus_type *bus; /* type of bus device is on */
382 struct device_driver *driver; /* which driver has allocated this 391 struct device_driver *driver; /* which driver has allocated this
383 device */ 392 device */
384 void *driver_data; /* data private to the driver */
385 void *platform_data; /* Platform specific data, device 393 void *platform_data; /* Platform specific data, device
386 core doesn't touch it */ 394 core doesn't touch it */
387 struct dev_pm_info power; 395 struct dev_pm_info power;
@@ -412,7 +420,7 @@ struct device {
412 420
413 struct klist_node knode_class; 421 struct klist_node knode_class;
414 struct class *class; 422 struct class *class;
415 struct attribute_group **groups; /* optional groups */ 423 const struct attribute_group **groups; /* optional groups */
416 424
417 void (*release)(struct device *dev); 425 void (*release)(struct device *dev);
418}; 426};
@@ -447,16 +455,6 @@ static inline void set_dev_node(struct device *dev, int node)
447} 455}
448#endif 456#endif
449 457
450static inline void *dev_get_drvdata(const struct device *dev)
451{
452 return dev->driver_data;
453}
454
455static inline void dev_set_drvdata(struct device *dev, void *data)
456{
457 dev->driver_data = data;
458}
459
460static inline unsigned int dev_get_uevent_suppress(const struct device *dev) 458static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
461{ 459{
462 return dev->kobj.uevent_suppress; 460 return dev->kobj.uevent_suppress;
@@ -490,6 +488,8 @@ extern int device_rename(struct device *dev, char *new_name);
490extern int device_move(struct device *dev, struct device *new_parent, 488extern int device_move(struct device *dev, struct device *new_parent,
491 enum dpm_order dpm_order); 489 enum dpm_order dpm_order);
492extern const char *device_get_nodename(struct device *dev, const char **tmp); 490extern const char *device_get_nodename(struct device *dev, const char **tmp);
491extern void *dev_get_drvdata(const struct device *dev);
492extern void dev_set_drvdata(struct device *dev, void *data);
493 493
494/* 494/*
495 * Root device objects for grouping under /sys/devices 495 * Root device objects for grouping under /sys/devices
@@ -502,6 +502,11 @@ static inline struct device *root_device_register(const char *name)
502} 502}
503extern void root_device_unregister(struct device *root); 503extern void root_device_unregister(struct device *root);
504 504
505static inline void *dev_get_platdata(const struct device *dev)
506{
507 return dev->platform_data;
508}
509
505/* 510/*
506 * Manual binding of a device to driver. See drivers/base/bus.c 511 * Manual binding of a device to driver. See drivers/base/bus.c
507 * for information on use. 512 * for information on use.
@@ -547,6 +552,16 @@ extern void put_device(struct device *dev);
547 552
548extern void wait_for_device_probe(void); 553extern void wait_for_device_probe(void);
549 554
555#ifdef CONFIG_DEVTMPFS
556extern int devtmpfs_create_node(struct device *dev);
557extern int devtmpfs_delete_node(struct device *dev);
558extern int devtmpfs_mount(const char *mountpoint);
559#else
560static inline int devtmpfs_create_node(struct device *dev) { return 0; }
561static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
562static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
563#endif
564
550/* drivers/base/power/shutdown.c */ 565/* drivers/base/power/shutdown.c */
551extern void device_shutdown(void); 566extern void device_shutdown(void);
552 567
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 65ee1929b2b1..a9aa4b5917d7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -895,7 +895,7 @@ struct net_device
895 /* class/net/name entry */ 895 /* class/net/name entry */
896 struct device dev; 896 struct device dev;
897 /* space for optional statistics and wireless sysfs groups */ 897 /* space for optional statistics and wireless sysfs groups */
898 struct attribute_group *sysfs_groups[3]; 898 const struct attribute_group *sysfs_groups[3];
899 899
900 /* rtnetlink link ops */ 900 /* rtnetlink link ops */
901 const struct rtnl_link_ops *rtnl_link_ops; 901 const struct rtnl_link_ops *rtnl_link_ops;
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index fcaee42c7ac2..dd0bed4f1cf0 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -42,6 +42,7 @@
42#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */ 42#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
43 43
44#define PCI_STATUS 0x06 /* 16 bits */ 44#define PCI_STATUS 0x06 /* 16 bits */
45#define PCI_STATUS_INTERRUPT 0x08 /* Interrupt status */
45#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ 46#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
46#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ 47#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
47#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ 48#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 6d3f2f449ead..deee7afd8d66 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -38,6 +38,9 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
38 return container_of(inode, struct shmem_inode_info, vfs_inode); 38 return container_of(inode, struct shmem_inode_info, vfs_inode);
39} 39}
40 40
41extern int init_tmpfs(void);
42extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
43
41#ifdef CONFIG_TMPFS_POSIX_ACL 44#ifdef CONFIG_TMPFS_POSIX_ACL
42int shmem_check_acl(struct inode *, int); 45int shmem_check_acl(struct inode *, int);
43int shmem_acl_init(struct inode *, struct inode *); 46int shmem_acl_init(struct inode *, struct inode *);
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h
index eaec1ea9558e..9ae8da3e6407 100644
--- a/include/linux/transport_class.h
+++ b/include/linux/transport_class.h
@@ -55,7 +55,7 @@ struct anon_transport_class cls = { \
55 55
56struct transport_container { 56struct transport_container {
57 struct attribute_container ac; 57 struct attribute_container ac;
58 struct attribute_group *statistics; 58 const struct attribute_group *statistics;
59}; 59};
60 60
61#define attribute_container_to_transport_container(x) \ 61#define attribute_container_to_transport_container(x) \
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 093f65915501..bb008d064c1a 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -415,7 +415,7 @@ void __init prepare_namespace(void)
415 415
416 mount_root(); 416 mount_root();
417out: 417out:
418 devtmpfs_mount("dev");
418 sys_mount(".", "/", NULL, MS_MOVE, NULL); 419 sys_mount(".", "/", NULL, MS_MOVE, NULL);
419 sys_chroot("."); 420 sys_chroot(".");
420} 421}
421
diff --git a/init/main.c b/init/main.c
index 63904bb6ae37..34971becbd3c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -68,6 +68,7 @@
68#include <linux/async.h> 68#include <linux/async.h>
69#include <linux/kmemcheck.h> 69#include <linux/kmemcheck.h>
70#include <linux/kmemtrace.h> 70#include <linux/kmemtrace.h>
71#include <linux/shmem_fs.h>
71#include <trace/boot.h> 72#include <trace/boot.h>
72 73
73#include <asm/io.h> 74#include <asm/io.h>
@@ -785,6 +786,7 @@ static void __init do_basic_setup(void)
785 init_workqueues(); 786 init_workqueues();
786 cpuset_init_smp(); 787 cpuset_init_smp();
787 usermodehelper_init(); 788 usermodehelper_init();
789 init_tmpfs();
788 driver_init(); 790 driver_init();
789 init_irq_proc(); 791 init_irq_proc();
790 do_ctors(); 792 do_ctors();
diff --git a/kernel/Makefile b/kernel/Makefile
index 961379caf666..3d9c7e27e3f9 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -90,7 +90,6 @@ obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
90obj-$(CONFIG_MARKERS) += marker.o 90obj-$(CONFIG_MARKERS) += marker.o
91obj-$(CONFIG_TRACEPOINTS) += tracepoint.o 91obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
92obj-$(CONFIG_LATENCYTOP) += latencytop.o 92obj-$(CONFIG_LATENCYTOP) += latencytop.o
93obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
94obj-$(CONFIG_FUNCTION_TRACER) += trace/ 93obj-$(CONFIG_FUNCTION_TRACER) += trace/
95obj-$(CONFIG_TRACING) += trace/ 94obj-$(CONFIG_TRACING) += trace/
96obj-$(CONFIG_X86_DS) += trace/ 95obj-$(CONFIG_X86_DS) += trace/
diff --git a/mm/shmem.c b/mm/shmem.c
index 5a0b3d4055f3..bd20f8bb02aa 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2298,8 +2298,7 @@ static void shmem_put_super(struct super_block *sb)
2298 sb->s_fs_info = NULL; 2298 sb->s_fs_info = NULL;
2299} 2299}
2300 2300
2301static int shmem_fill_super(struct super_block *sb, 2301int shmem_fill_super(struct super_block *sb, void *data, int silent)
2302 void *data, int silent)
2303{ 2302{
2304 struct inode *inode; 2303 struct inode *inode;
2305 struct dentry *root; 2304 struct dentry *root;
@@ -2519,7 +2518,7 @@ static struct file_system_type tmpfs_fs_type = {
2519 .kill_sb = kill_litter_super, 2518 .kill_sb = kill_litter_super,
2520}; 2519};
2521 2520
2522static int __init init_tmpfs(void) 2521int __init init_tmpfs(void)
2523{ 2522{
2524 int error; 2523 int error;
2525 2524
@@ -2576,7 +2575,7 @@ static struct file_system_type tmpfs_fs_type = {
2576 .kill_sb = kill_litter_super, 2575 .kill_sb = kill_litter_super,
2577}; 2576};
2578 2577
2579static int __init init_tmpfs(void) 2578int __init init_tmpfs(void)
2580{ 2579{
2581 BUG_ON(register_filesystem(&tmpfs_fs_type) != 0); 2580 BUG_ON(register_filesystem(&tmpfs_fs_type) != 0);
2582 2581
@@ -2687,5 +2686,3 @@ int shmem_zero_setup(struct vm_area_struct *vma)
2687 vma->vm_ops = &shmem_vm_ops; 2686 vma->vm_ops = &shmem_vm_ops;
2688 return 0; 2687 return 0;
2689} 2688}
2690
2691module_init(init_tmpfs)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 95f7a7a544b4..7f939ce29801 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -68,7 +68,7 @@ static struct attribute_group bt_link_group = {
68 .attrs = bt_link_attrs, 68 .attrs = bt_link_attrs,
69}; 69};
70 70
71static struct attribute_group *bt_link_groups[] = { 71static const struct attribute_group *bt_link_groups[] = {
72 &bt_link_group, 72 &bt_link_group,
73 NULL 73 NULL
74}; 74};
@@ -392,7 +392,7 @@ static struct attribute_group bt_host_group = {
392 .attrs = bt_host_attrs, 392 .attrs = bt_host_attrs,
393}; 393};
394 394
395static struct attribute_group *bt_host_groups[] = { 395static const struct attribute_group *bt_host_groups[] = {
396 &bt_host_group, 396 &bt_host_group,
397 NULL 397 NULL
398}; 398};
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index ad91e9e5f475..7d4c57523b09 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -493,7 +493,7 @@ void netdev_unregister_kobject(struct net_device * net)
493int netdev_register_kobject(struct net_device *net) 493int netdev_register_kobject(struct net_device *net)
494{ 494{
495 struct device *dev = &(net->dev); 495 struct device *dev = &(net->dev);
496 struct attribute_group **groups = net->sysfs_groups; 496 const struct attribute_group **groups = net->sysfs_groups;
497 497
498 dev->class = &net_class; 498 dev->class = &net_class;
499 dev->platform_data = net; 499 dev->platform_data = net;
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index f24ae370e514..6af373236d73 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * If TRACE_SYSTEM is defined, that will be the directory created 2 * If TRACE_SYSTEM is defined, that will be the directory created
3 * in the ftrace directory under /debugfs/tracing/events/<system> 3 * in the ftrace directory under /sys/kernel/debug/tracing/events/<system>
4 * 4 *
5 * The define_trace.h below will also look for a file name of 5 * The define_trace.h below will also look for a file name of
6 * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. 6 * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here.