diff options
Diffstat (limited to 'drivers')
41 files changed, 1232 insertions, 195 deletions
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 | ||
11 | config 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 | |||
28 | config 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 | |||
11 | config STANDALONE | 36 | config 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 |
7 | obj-$(CONFIG_DEVTMPFS) += devtmpfs.o | ||
7 | obj-y += power/ | 8 | obj-y += power/ |
8 | obj-$(CONFIG_HAS_DMA) += dma-mapping.o | 9 | obj-$(CONFIG_HAS_DMA) += dma-mapping.o |
10 | obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o | ||
9 | obj-$(CONFIG_ISA) += isa.o | 11 | obj-$(CONFIG_ISA) += isa.o |
10 | obj-$(CONFIG_FW_LOADER) += firmware_class.o | 12 | obj-$(CONFIG_FW_LOADER) += firmware_class.o |
11 | obj-$(CONFIG_NUMA) += node.o | 13 | obj-$(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 | ||
95 | extern int device_private_init(struct device *dev); | ||
96 | |||
92 | /* initialisation functions */ | 97 | /* initialisation functions */ |
93 | extern int devices_init(void); | 98 | extern int devices_init(void); |
94 | extern int buses_init(void); | 99 | extern int buses_init(void); |
@@ -104,7 +109,7 @@ extern int system_bus_init(void); | |||
104 | extern int cpu_dev_init(void); | 109 | extern int cpu_dev_init(void); |
105 | 110 | ||
106 | extern int bus_add_device(struct device *dev); | 111 | extern int bus_add_device(struct device *dev); |
107 | extern void bus_attach_device(struct device *dev); | 112 | extern void bus_probe_device(struct device *dev); |
108 | extern void bus_remove_device(struct device *dev); | 113 | extern void bus_remove_device(struct device *dev); |
109 | 114 | ||
110 | extern int bus_add_driver(struct device_driver *drv); | 115 | extern 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) { } |
135 | static inline void module_remove_driver(struct device_driver *drv) { } | 140 | static inline void module_remove_driver(struct device_driver *drv) { } |
136 | #endif | 141 | #endif |
142 | |||
143 | #ifdef CONFIG_DEVTMPFS | ||
144 | extern int devtmpfs_init(void); | ||
145 | #else | ||
146 | static 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 | */ |
465 | int bus_add_device(struct device *dev) | 466 | int 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 | */ |
507 | void bus_attach_device(struct device *dev) | 508 | void 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 | ||
491 | struct 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 | */ | ||
502 | struct 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 | } | ||
516 | EXPORT_SYMBOL_GPL(class_compat_register); | ||
517 | |||
518 | /** | ||
519 | * class_compat_unregister - unregister a compatibility class | ||
520 | * @cls: the class to unregister | ||
521 | */ | ||
522 | void class_compat_unregister(struct class_compat *cls) | ||
523 | { | ||
524 | kobject_put(cls->kobj); | ||
525 | kfree(cls); | ||
526 | } | ||
527 | EXPORT_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 | */ | ||
536 | int 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 | } | ||
559 | EXPORT_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 | */ | ||
569 | void 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 | } | ||
576 | EXPORT_SYMBOL_GPL(class_compat_remove_link); | ||
577 | |||
491 | int __init classes_init(void) | 578 | int __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 | ||
343 | static int device_add_groups(struct device *dev, | 343 | static 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 | ||
363 | static void device_remove_groups(struct device *dev, | 363 | static 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 | ||
846 | int 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 | */ | ||
399 | void *dev_get_drvdata(const struct device *dev) | ||
400 | { | ||
401 | if (dev && dev->p) | ||
402 | return dev->p->driver_data; | ||
403 | return NULL; | ||
404 | } | ||
405 | EXPORT_SYMBOL(dev_get_drvdata); | ||
406 | |||
407 | void 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 | } | ||
420 | EXPORT_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 | |||
25 | static struct vfsmount *dev_mnt; | ||
26 | |||
27 | #if defined CONFIG_DEVTMPFS_MOUNT | ||
28 | static int dev_mount = 1; | ||
29 | #else | ||
30 | static int dev_mount; | ||
31 | #endif | ||
32 | |||
33 | static 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 | |||
40 | static 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 | |||
46 | static 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 | ||
53 | static inline int is_blockdev(struct device *dev) | ||
54 | { | ||
55 | return dev->class == &block_class; | ||
56 | } | ||
57 | #else | ||
58 | static inline int is_blockdev(struct device *dev) { return 0; } | ||
59 | #endif | ||
60 | |||
61 | static 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 | |||
85 | static 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 | |||
132 | int 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); | ||
180 | out: | ||
181 | kfree(tmp); | ||
182 | revert_creds(curr_cred); | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | static 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 | |||
214 | static 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 | |||
239 | static 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 | |||
260 | int 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); | ||
307 | out: | ||
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 | */ | ||
317 | int 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 | */ | ||
344 | int __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/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c new file mode 100644 index 000000000000..962a3b574f21 --- /dev/null +++ b/drivers/base/dma-coherent.c | |||
@@ -0,0 +1,176 @@ | |||
1 | /* | ||
2 | * Coherent per-device memory handling. | ||
3 | * Borrowed from i386 | ||
4 | */ | ||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/dma-mapping.h> | ||
7 | |||
8 | struct dma_coherent_mem { | ||
9 | void *virt_base; | ||
10 | u32 device_base; | ||
11 | int size; | ||
12 | int flags; | ||
13 | unsigned long *bitmap; | ||
14 | }; | ||
15 | |||
16 | int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, | ||
17 | dma_addr_t device_addr, size_t size, int flags) | ||
18 | { | ||
19 | void __iomem *mem_base = NULL; | ||
20 | int pages = size >> PAGE_SHIFT; | ||
21 | int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long); | ||
22 | |||
23 | if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0) | ||
24 | goto out; | ||
25 | if (!size) | ||
26 | goto out; | ||
27 | if (dev->dma_mem) | ||
28 | goto out; | ||
29 | |||
30 | /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ | ||
31 | |||
32 | mem_base = ioremap(bus_addr, size); | ||
33 | if (!mem_base) | ||
34 | goto out; | ||
35 | |||
36 | dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); | ||
37 | if (!dev->dma_mem) | ||
38 | goto out; | ||
39 | dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); | ||
40 | if (!dev->dma_mem->bitmap) | ||
41 | goto free1_out; | ||
42 | |||
43 | dev->dma_mem->virt_base = mem_base; | ||
44 | dev->dma_mem->device_base = device_addr; | ||
45 | dev->dma_mem->size = pages; | ||
46 | dev->dma_mem->flags = flags; | ||
47 | |||
48 | if (flags & DMA_MEMORY_MAP) | ||
49 | return DMA_MEMORY_MAP; | ||
50 | |||
51 | return DMA_MEMORY_IO; | ||
52 | |||
53 | free1_out: | ||
54 | kfree(dev->dma_mem); | ||
55 | out: | ||
56 | if (mem_base) | ||
57 | iounmap(mem_base); | ||
58 | return 0; | ||
59 | } | ||
60 | EXPORT_SYMBOL(dma_declare_coherent_memory); | ||
61 | |||
62 | void dma_release_declared_memory(struct device *dev) | ||
63 | { | ||
64 | struct dma_coherent_mem *mem = dev->dma_mem; | ||
65 | |||
66 | if (!mem) | ||
67 | return; | ||
68 | dev->dma_mem = NULL; | ||
69 | iounmap(mem->virt_base); | ||
70 | kfree(mem->bitmap); | ||
71 | kfree(mem); | ||
72 | } | ||
73 | EXPORT_SYMBOL(dma_release_declared_memory); | ||
74 | |||
75 | void *dma_mark_declared_memory_occupied(struct device *dev, | ||
76 | dma_addr_t device_addr, size_t size) | ||
77 | { | ||
78 | struct dma_coherent_mem *mem = dev->dma_mem; | ||
79 | int pos, err; | ||
80 | |||
81 | size += device_addr & ~PAGE_MASK; | ||
82 | |||
83 | if (!mem) | ||
84 | return ERR_PTR(-EINVAL); | ||
85 | |||
86 | pos = (device_addr - mem->device_base) >> PAGE_SHIFT; | ||
87 | err = bitmap_allocate_region(mem->bitmap, pos, get_order(size)); | ||
88 | if (err != 0) | ||
89 | return ERR_PTR(err); | ||
90 | return mem->virt_base + (pos << PAGE_SHIFT); | ||
91 | } | ||
92 | EXPORT_SYMBOL(dma_mark_declared_memory_occupied); | ||
93 | |||
94 | /** | ||
95 | * dma_alloc_from_coherent() - try to allocate memory from the per-device coherent area | ||
96 | * | ||
97 | * @dev: device from which we allocate memory | ||
98 | * @size: size of requested memory area | ||
99 | * @dma_handle: This will be filled with the correct dma handle | ||
100 | * @ret: This pointer will be filled with the virtual address | ||
101 | * to allocated area. | ||
102 | * | ||
103 | * This function should be only called from per-arch dma_alloc_coherent() | ||
104 | * to support allocation from per-device coherent memory pools. | ||
105 | * | ||
106 | * Returns 0 if dma_alloc_coherent should continue with allocating from | ||
107 | * generic memory areas, or !0 if dma_alloc_coherent should return @ret. | ||
108 | */ | ||
109 | int dma_alloc_from_coherent(struct device *dev, ssize_t size, | ||
110 | dma_addr_t *dma_handle, void **ret) | ||
111 | { | ||
112 | struct dma_coherent_mem *mem; | ||
113 | int order = get_order(size); | ||
114 | int pageno; | ||
115 | |||
116 | if (!dev) | ||
117 | return 0; | ||
118 | mem = dev->dma_mem; | ||
119 | if (!mem) | ||
120 | return 0; | ||
121 | |||
122 | *ret = NULL; | ||
123 | |||
124 | if (unlikely(size > (mem->size << PAGE_SHIFT))) | ||
125 | goto err; | ||
126 | |||
127 | pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); | ||
128 | if (unlikely(pageno < 0)) | ||
129 | goto err; | ||
130 | |||
131 | /* | ||
132 | * Memory was found in the per-device area. | ||
133 | */ | ||
134 | *dma_handle = mem->device_base + (pageno << PAGE_SHIFT); | ||
135 | *ret = mem->virt_base + (pageno << PAGE_SHIFT); | ||
136 | memset(*ret, 0, size); | ||
137 | |||
138 | return 1; | ||
139 | |||
140 | err: | ||
141 | /* | ||
142 | * In the case where the allocation can not be satisfied from the | ||
143 | * per-device area, try to fall back to generic memory if the | ||
144 | * constraints allow it. | ||
145 | */ | ||
146 | return mem->flags & DMA_MEMORY_EXCLUSIVE; | ||
147 | } | ||
148 | EXPORT_SYMBOL(dma_alloc_from_coherent); | ||
149 | |||
150 | /** | ||
151 | * dma_release_from_coherent() - try to free the memory allocated from per-device coherent memory pool | ||
152 | * @dev: device from which the memory was allocated | ||
153 | * @order: the order of pages allocated | ||
154 | * @vaddr: virtual address of allocated pages | ||
155 | * | ||
156 | * This checks whether the memory was allocated from the per-device | ||
157 | * coherent memory pool and if so, releases that memory. | ||
158 | * | ||
159 | * Returns 1 if we correctly released the memory, or 0 if | ||
160 | * dma_release_coherent() should proceed with releasing memory from | ||
161 | * generic pools. | ||
162 | */ | ||
163 | int dma_release_from_coherent(struct device *dev, int order, void *vaddr) | ||
164 | { | ||
165 | struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; | ||
166 | |||
167 | if (mem && vaddr >= mem->virt_base && vaddr < | ||
168 | (mem->virt_base + (mem->size << PAGE_SHIFT))) { | ||
169 | int page = (vaddr - mem->virt_base) >> PAGE_SHIFT; | ||
170 | |||
171 | bitmap_release_region(mem->bitmap, page, order); | ||
172 | return 1; | ||
173 | } | ||
174 | return 0; | ||
175 | } | ||
176 | EXPORT_SYMBOL(dma_release_from_coherent); | ||
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) | |||
181 | EXPORT_SYMBOL_GPL(put_driver); | 181 | EXPORT_SYMBOL_GPL(put_driver); |
182 | 182 | ||
183 | static int driver_add_groups(struct device_driver *drv, | 183 | static 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 | ||
203 | static void driver_remove_groups(struct device_driver *drv, | 203 | static 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 @@ | |||
20 | void __init driver_init(void) | 20 | void __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); | |||
213 | int platform_device_add_data(struct platform_device *pdev, const void *data, | 214 | int 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 | } |
225 | EXPORT_SYMBOL_GPL(platform_device_add_data); | 225 | EXPORT_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 | ||
575 | static struct attribute_group *cciss_dev_attr_groups[] = { | 575 | static 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 */ | |||
92 | static mempool_t *psd_pool; | 92 | static mempool_t *psd_pool; |
93 | 93 | ||
94 | static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */ | 94 | static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */ |
95 | static struct dentry *pkt_debugfs_root = NULL; /* /debug/pktcdvd */ | 95 | static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */ |
96 | 96 | ||
97 | /* forward declaration */ | 97 | /* forward declaration */ |
98 | static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev); | 98 | static 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 | ||
867 | static const struct { | 867 | static 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 | ||
894 | static int memory_open(struct inode *inode, struct file *filp) | 890 | static 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; | ||
914 | out: | ||
919 | unlock_kernel(); | 915 | unlock_kernel(); |
920 | return ret; | 916 | return ret; |
921 | } | 917 | } |
922 | 918 | ||
923 | static const struct file_operations memory_fops = { | 919 | static 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 | ||
927 | static struct class *mem_class; | 923 | static struct class *mem_class; |
928 | 924 | ||
929 | static int __init chr_dev_init(void) | 925 | static 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 | ||
318 | static ssize_t modalias_show(struct device *dev, | 318 | static 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 | ||
142 | static struct attribute_group* sys_dmi_attribute_groups[] = { | 142 | static 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 | ||
626 | static struct attribute_group *ehca_drv_attr_groups[] = { | 626 | static 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 | ||
1287 | extern const char ib_ipath_version[]; | 1287 | extern const char ib_ipath_version[]; |
1288 | 1288 | ||
1289 | extern struct attribute_group *ipath_driver_attr_groups[]; | 1289 | extern const struct attribute_group *ipath_driver_attr_groups[]; |
1290 | 1290 | ||
1291 | int ipath_device_create_group(struct device *, struct ipath_devdata *); | 1291 | int ipath_device_create_group(struct device *, struct ipath_devdata *); |
1292 | void ipath_device_remove_group(struct device *, struct ipath_devdata *); | 1292 | void 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 | ||
1072 | struct attribute_group *ipath_driver_attr_groups[] = { | 1072 | const 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 | ||
1147 | static struct attribute_group *input_dev_attr_groups[] = { | 1147 | static 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 | ||
241 | static struct attribute_group *enclosure_groups[]; | 241 | static 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 | ||
539 | static struct attribute_group *enclosure_groups[] = { | 539 | static 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 | ||
26 | static struct class *ilo_class; | 29 | static struct class *ilo_class; |
@@ -61,9 +64,10 @@ static inline int desc_mem_sz(int nr_entry) | |||
61 | static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry) | 64 | static 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) | |||
79 | static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry) | 83 | static 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 | |||
106 | static 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 | ||
166 | static 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 | |||
145 | static inline void doorbell_set(struct ccb *ccb) | 173 | static 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 | |||
154 | static inline int ctrl_set(int l2sz, int idxmask, int desclim) | 183 | static 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 | |||
163 | static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz) | 193 | static 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 | ||
193 | static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data) | 223 | static 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 | ||
228 | static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) | 255 | static 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 | |||
319 | static 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 | |||
344 | static 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; |
328 | free: | ||
329 | ilo_ccb_close(pdev, data); | ||
330 | out: | ||
331 | return error; | ||
332 | } | 364 | } |
333 | 365 | ||
334 | static inline int is_channel_reset(struct ccb *ccb) | 366 | static 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 | ||
378 | static inline int get_device_outbound(struct ilo_hwinfo *hw) | ||
379 | { | ||
380 | return ioread32(&hw->mmio_vaddr[DB_OUT]); | ||
381 | } | ||
382 | |||
383 | static inline int is_db_reset(int db_out) | ||
384 | { | ||
385 | return db_out & (1 << DB_RESET); | ||
386 | } | ||
387 | |||
346 | static inline int is_device_reset(struct ilo_hwinfo *hw) | 388 | static 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 | |||
394 | static inline void clear_pending_db(struct ilo_hwinfo *hw, int clr) | ||
395 | { | ||
396 | iowrite32(clr, &hw->mmio_vaddr[DB_OUT]); | ||
350 | } | 397 | } |
351 | 398 | ||
352 | static inline void clear_device(struct ilo_hwinfo *hw) | 399 | static 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 | |||
405 | static 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 | ||
358 | static void ilo_locked_reset(struct ilo_hwinfo *hw) | 410 | static 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 | |||
416 | static 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 | |||
375 | static void ilo_reset(struct ilo_hwinfo *hw) | ||
376 | { | ||
377 | spin_lock(&hw->alloc_lock); | ||
378 | |||
379 | /* reset might have been handled after lock was taken */ | ||
380 | if (is_device_reset(hw)) | ||
381 | ilo_locked_reset(hw); | ||
382 | |||
383 | spin_unlock(&hw->alloc_lock); | ||
384 | } | 429 | } |
385 | 430 | ||
386 | static ssize_t ilo_read(struct file *fp, char __user *buf, | 431 | static 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 | ||
513 | static 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 | |||
483 | static int ilo_close(struct inode *ip, struct file *fp) | 528 | static 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); | 624 | out: |
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 | ||
642 | static 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 | |||
573 | static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw) | 677 | static 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; |
811 | remove_isr: | ||
812 | ilo_disable_interrupts(ilo_hw); | ||
813 | free_irq(pdev->irq, ilo_hw); | ||
698 | unmap: | 814 | unmap: |
699 | ilo_unmap_device(pdev, ilo_hw); | 815 | ilo_unmap_device(pdev, ilo_hw); |
700 | free_regions: | 816 | free_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 | ||
762 | MODULE_VERSION("1.1"); | 878 | MODULE_VERSION("1.2"); |
763 | MODULE_ALIAS(ILO_NAME); | 879 | MODULE_ALIAS(ILO_NAME); |
764 | MODULE_DESCRIPTION(ILO_NAME); | 880 | MODULE_DESCRIPTION(ILO_NAME); |
765 | MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); | 881 | MODULE_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 | ||
279 | static struct attribute_group *mmc_attr_groups[] = { | 279 | static 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 | ||
317 | static struct attribute_group *sd_attr_groups[] = { | 317 | static 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 | ||
220 | struct attribute_group *mtd_groups[] = { | 220 | const 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 | ||
269 | static struct attribute_group *default_subch_attr_groups[] = { | 269 | static 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 | ||
659 | static struct attribute_group *ccwdev_attr_groups[] = { | 659 | static 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 | ||
2162 | static struct attribute_group *netiucv_drv_attr_groups[] = { | 2162 | static 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; | |||
132 | extern void __scsi_remove_device(struct scsi_device *); | 132 | extern void __scsi_remove_device(struct scsi_device *); |
133 | 133 | ||
134 | extern struct bus_type scsi_bus_type; | 134 | extern struct bus_type scsi_bus_type; |
135 | extern struct attribute_group *scsi_sysfs_shost_attr_groups[]; | 135 | extern 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 | ||
278 | struct attribute_group *scsi_sysfs_shost_attr_groups[] = { | 278 | const 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 | ||
748 | static struct attribute_group *scsi_sdev_attr_groups[] = { | 748 | static 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 @@ | |||
1 | menuconfig UIO | 1 | menuconfig 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 | |||
16 | config UIO_CIF | 15 | config 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 | ||
49 | config UIO_SMX | 47 | config 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 | |||
61 | config UIO_AEC | 58 | config 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 | ||
79 | config UIO_SERCOS3 | 75 | config 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 | ||
87 | config 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 | |||
92 | endif | 97 | endif |
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 | |||
5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o | 5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o |
6 | obj-$(CONFIG_UIO_AEC) += uio_aec.o | 6 | obj-$(CONFIG_UIO_AEC) += uio_aec.o |
7 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o | 7 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o |
8 | obj-$(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 | |||
32 | struct uio_pci_generic_dev { | ||
33 | struct uio_info info; | ||
34 | struct pci_dev *pdev; | ||
35 | spinlock_t lock; /* guards command register accesses */ | ||
36 | }; | ||
37 | |||
38 | static inline struct uio_pci_generic_dev * | ||
39 | to_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. */ | ||
46 | static 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; | ||
82 | done: | ||
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. */ | ||
92 | static 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); | ||
119 | err: | ||
120 | pci_unblock_user_cfg_access(pdev); | ||
121 | return err; | ||
122 | } | ||
123 | |||
124 | static 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; | ||
166 | err_register: | ||
167 | kfree(gdev); | ||
168 | err_alloc: | ||
169 | err_verify: | ||
170 | pci_disable_device(pdev); | ||
171 | return err; | ||
172 | } | ||
173 | |||
174 | static 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 | |||
183 | static 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 | |||
190 | static int __init init(void) | ||
191 | { | ||
192 | pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | ||
193 | return pci_register_driver(&driver); | ||
194 | } | ||
195 | |||
196 | static void __exit cleanup(void) | ||
197 | { | ||
198 | pci_unregister_driver(&driver); | ||
199 | } | ||
200 | |||
201 | module_init(init); | ||
202 | module_exit(cleanup); | ||
203 | |||
204 | MODULE_VERSION(DRIVER_VERSION); | ||
205 | MODULE_LICENSE("GPL v2"); | ||
206 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
207 | MODULE_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[] = { | |||
154 | static struct attribute_group ep_dev_attr_grp = { | 154 | static struct attribute_group ep_dev_attr_grp = { |
155 | .attrs = ep_dev_attrs, | 155 | .attrs = ep_dev_attrs, |
156 | }; | 156 | }; |
157 | static struct attribute_group *ep_dev_groups[] = { | 157 | static 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 | ||
576 | struct attribute_group *usb_device_groups[] = { | 576 | const 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 | ||
802 | struct attribute_group *usb_interface_groups[] = { | 802 | const 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) | |||
152 | extern const char *usbcore_name; | 152 | extern const char *usbcore_name; |
153 | 153 | ||
154 | /* sysfs stuff */ | 154 | /* sysfs stuff */ |
155 | extern struct attribute_group *usb_device_groups[]; | 155 | extern const struct attribute_group *usb_device_groups[]; |
156 | extern struct attribute_group *usb_interface_groups[]; | 156 | extern const struct attribute_group *usb_interface_groups[]; |
157 | 157 | ||
158 | /* usbfs stuff */ | 158 | /* usbfs stuff */ |
159 | extern struct mutex usbfs_mutex; | 159 | extern 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 | ||
258 | static struct attribute_group *groups[] = { | 258 | static const struct attribute_group *groups[] = { |
259 | &dev_attr_group, | 259 | &dev_attr_group, |
260 | NULL, | 260 | NULL, |
261 | }; | 261 | }; |