diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 13:48:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 13:48:32 -0400 |
commit | d6fb1db02e02aea98f2d7e121fd30e24c84639d6 (patch) | |
tree | 865546f0388c40d52cf98febe2c6d21039915ea2 | |
parent | b4e6b09738fde057ce885703705f71cc953d0512 (diff) | |
parent | a1b3f594dc5faab91d3a218c7019e9b5edd9fe1a (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (38 commits)
net: Expose all network devices in a namespaces in sysfs
hotplug: netns aware uevent_helper
kobj: Send hotplug events in the proper namespace.
netlink: Implment netlink_broadcast_filtered
net/sysfs: Fix the bitrot in network device kobject namespace support
netns: Teach network device kobjects which namespace they are in.
kobject: Send hotplug events in all network namespaces
driver-core: fix Typo in drivers/base/core.c for CONFIG_MODULE
pci: check caps from sysfs file open to read device dependent config space
sysfs: add struct file* to bin_attr callbacks
sysfs: Remove usage of S_BIAS to avoid merge conflict with the vfs tree
sysfs: Don't use enums in inline function declaration.
sysfs-namespaces: add a high-level Documentation file
sysfs: Comment sysfs directory tagging logic
driver core: Implement ns directory support for device classes.
sysfs: Implement sysfs_delete_link
sysfs: Add support for tagged directories with untagged members.
sysfs: Implement sysfs tagged directory support.
kobj: Add basic infrastructure for dealing with namespaces.
sysfs: Remove double free sysfs_get_sb
...
94 files changed, 1165 insertions, 411 deletions
diff --git a/Documentation/filesystems/sysfs-tagging.txt b/Documentation/filesystems/sysfs-tagging.txt new file mode 100644 index 000000000000..caaaf1266d8f --- /dev/null +++ b/Documentation/filesystems/sysfs-tagging.txt | |||
@@ -0,0 +1,42 @@ | |||
1 | Sysfs tagging | ||
2 | ------------- | ||
3 | |||
4 | (Taken almost verbatim from Eric Biederman's netns tagging patch | ||
5 | commit msg) | ||
6 | |||
7 | The problem. Network devices show up in sysfs and with the network | ||
8 | namespace active multiple devices with the same name can show up in | ||
9 | the same directory, ouch! | ||
10 | |||
11 | To avoid that problem and allow existing applications in network | ||
12 | namespaces to see the same interface that is currently presented in | ||
13 | sysfs, sysfs now has tagging directory support. | ||
14 | |||
15 | By using the network namespace pointers as tags to separate out the | ||
16 | the sysfs directory entries we ensure that we don't have conflicts | ||
17 | in the directories and applications only see a limited set of | ||
18 | the network devices. | ||
19 | |||
20 | Each sysfs directory entry may be tagged with zero or one | ||
21 | namespaces. A sysfs_dirent is augmented with a void *s_ns. If a | ||
22 | directory entry is tagged, then sysfs_dirent->s_flags will have a | ||
23 | flag between KOBJ_NS_TYPE_NONE and KOBJ_NS_TYPES, and s_ns will | ||
24 | point to the namespace to which it belongs. | ||
25 | |||
26 | Each sysfs superblock's sysfs_super_info contains an array void | ||
27 | *ns[KOBJ_NS_TYPES]. When a a task in a tagging namespace | ||
28 | kobj_nstype first mounts sysfs, a new superblock is created. It | ||
29 | will be differentiated from other sysfs mounts by having its | ||
30 | s_fs_info->ns[kobj_nstype] set to the new namespace. Note that | ||
31 | through bind mounting and mounts propagation, a task can easily view | ||
32 | the contents of other namespaces' sysfs mounts. Therefore, when a | ||
33 | namespace exits, it will call kobj_ns_exit() to invalidate any | ||
34 | sysfs_dirent->s_ns pointers pointing to it. | ||
35 | |||
36 | Users of this interface: | ||
37 | - define a type in the kobj_ns_type enumeration. | ||
38 | - call kobj_ns_type_register() with its kobj_ns_type_operations which has | ||
39 | - current_ns() which returns current's namespace | ||
40 | - netlink_ns() which returns a socket's namespace | ||
41 | - initial_ns() which returns the initial namesapce | ||
42 | - call kobj_ns_exit() when an individual tag is no longer valid | ||
diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c index d979e7c7bc4b..a5fffc882c72 100644 --- a/arch/alpha/kernel/pci-sysfs.c +++ b/arch/alpha/kernel/pci-sysfs.c | |||
@@ -53,6 +53,7 @@ static int __pci_mmap_fits(struct pci_dev *pdev, int num, | |||
53 | 53 | ||
54 | /** | 54 | /** |
55 | * pci_mmap_resource - map a PCI resource into user memory space | 55 | * pci_mmap_resource - map a PCI resource into user memory space |
56 | * @filp: open sysfs file | ||
56 | * @kobj: kobject for mapping | 57 | * @kobj: kobject for mapping |
57 | * @attr: struct bin_attribute for the file being mapped | 58 | * @attr: struct bin_attribute for the file being mapped |
58 | * @vma: struct vm_area_struct passed into the mmap | 59 | * @vma: struct vm_area_struct passed into the mmap |
@@ -60,7 +61,8 @@ static int __pci_mmap_fits(struct pci_dev *pdev, int num, | |||
60 | * | 61 | * |
61 | * Use the bus mapping routines to map a PCI resource into userspace. | 62 | * Use the bus mapping routines to map a PCI resource into userspace. |
62 | */ | 63 | */ |
63 | static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | 64 | static int pci_mmap_resource(struct file *filp, struct kobject *kobj, |
65 | struct bin_attribute *attr, | ||
64 | struct vm_area_struct *vma, int sparse) | 66 | struct vm_area_struct *vma, int sparse) |
65 | { | 67 | { |
66 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 68 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, |
@@ -89,14 +91,14 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
89 | return hose_mmap_page_range(pdev->sysdata, vma, mmap_type, sparse); | 91 | return hose_mmap_page_range(pdev->sysdata, vma, mmap_type, sparse); |
90 | } | 92 | } |
91 | 93 | ||
92 | static int pci_mmap_resource_sparse(struct kobject *kobj, | 94 | static int pci_mmap_resource_sparse(struct file *filp, struct kobject *kobj, |
93 | struct bin_attribute *attr, | 95 | struct bin_attribute *attr, |
94 | struct vm_area_struct *vma) | 96 | struct vm_area_struct *vma) |
95 | { | 97 | { |
96 | return pci_mmap_resource(kobj, attr, vma, 1); | 98 | return pci_mmap_resource(kobj, attr, vma, 1); |
97 | } | 99 | } |
98 | 100 | ||
99 | static int pci_mmap_resource_dense(struct kobject *kobj, | 101 | static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj, |
100 | struct bin_attribute *attr, | 102 | struct bin_attribute *attr, |
101 | struct vm_area_struct *vma) | 103 | struct vm_area_struct *vma) |
102 | { | 104 | { |
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c index adc69291f9e2..575d219b8001 100644 --- a/arch/mips/txx9/generic/setup.c +++ b/arch/mips/txx9/generic/setup.c | |||
@@ -905,7 +905,7 @@ struct txx9_sramc_sysdev { | |||
905 | void __iomem *base; | 905 | void __iomem *base; |
906 | }; | 906 | }; |
907 | 907 | ||
908 | static ssize_t txx9_sram_read(struct kobject *kobj, | 908 | static ssize_t txx9_sram_read(struct file *filp, struct kobject *kobj, |
909 | struct bin_attribute *bin_attr, | 909 | struct bin_attribute *bin_attr, |
910 | char *buf, loff_t pos, size_t size) | 910 | char *buf, loff_t pos, size_t size) |
911 | { | 911 | { |
@@ -920,7 +920,7 @@ static ssize_t txx9_sram_read(struct kobject *kobj, | |||
920 | return size; | 920 | return size; |
921 | } | 921 | } |
922 | 922 | ||
923 | static ssize_t txx9_sram_write(struct kobject *kobj, | 923 | static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj, |
924 | struct bin_attribute *bin_attr, | 924 | struct bin_attribute *bin_attr, |
925 | char *buf, loff_t pos, size_t size) | 925 | char *buf, loff_t pos, size_t size) |
926 | { | 926 | { |
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c index 1456015a22d8..198f288570cc 100644 --- a/arch/powerpc/sysdev/mv64x60_pci.c +++ b/arch/powerpc/sysdev/mv64x60_pci.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #define MV64X60_VAL_LEN_MAX 11 | 24 | #define MV64X60_VAL_LEN_MAX 11 |
25 | #define MV64X60_PCICFG_CPCI_HOTSWAP 0x68 | 25 | #define MV64X60_PCICFG_CPCI_HOTSWAP 0x68 |
26 | 26 | ||
27 | static ssize_t mv64x60_hs_reg_read(struct kobject *kobj, | 27 | static ssize_t mv64x60_hs_reg_read(struct file *filp, struct kobject *kobj, |
28 | struct bin_attribute *attr, char *buf, | 28 | struct bin_attribute *attr, char *buf, |
29 | loff_t off, size_t count) | 29 | loff_t off, size_t count) |
30 | { | 30 | { |
@@ -45,7 +45,7 @@ static ssize_t mv64x60_hs_reg_read(struct kobject *kobj, | |||
45 | return sprintf(buf, "0x%08x\n", v); | 45 | return sprintf(buf, "0x%08x\n", v); |
46 | } | 46 | } |
47 | 47 | ||
48 | static ssize_t mv64x60_hs_reg_write(struct kobject *kobj, | 48 | static ssize_t mv64x60_hs_reg_write(struct file *filp, struct kobject *kobj, |
49 | struct bin_attribute *attr, char *buf, | 49 | struct bin_attribute *attr, char *buf, |
50 | loff_t off, size_t count) | 50 | loff_t off, size_t count) |
51 | { | 51 | { |
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c index 72c8b0d070c8..a689070be287 100644 --- a/arch/s390/kernel/ipl.c +++ b/arch/s390/kernel/ipl.c | |||
@@ -403,8 +403,9 @@ static ssize_t sys_ipl_device_show(struct kobject *kobj, | |||
403 | static struct kobj_attribute sys_ipl_device_attr = | 403 | static struct kobj_attribute sys_ipl_device_attr = |
404 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); | 404 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); |
405 | 405 | ||
406 | static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr, | 406 | static ssize_t ipl_parameter_read(struct file *filp, struct kobject *kobj, |
407 | char *buf, loff_t off, size_t count) | 407 | struct bin_attribute *attr, char *buf, |
408 | loff_t off, size_t count) | ||
408 | { | 409 | { |
409 | return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START, | 410 | return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START, |
410 | IPL_PARMBLOCK_SIZE); | 411 | IPL_PARMBLOCK_SIZE); |
@@ -419,8 +420,9 @@ static struct bin_attribute ipl_parameter_attr = { | |||
419 | .read = &ipl_parameter_read, | 420 | .read = &ipl_parameter_read, |
420 | }; | 421 | }; |
421 | 422 | ||
422 | static ssize_t ipl_scp_data_read(struct kobject *kobj, struct bin_attribute *attr, | 423 | static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj, |
423 | char *buf, loff_t off, size_t count) | 424 | struct bin_attribute *attr, char *buf, |
425 | loff_t off, size_t count) | ||
424 | { | 426 | { |
425 | unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len; | 427 | unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len; |
426 | void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data; | 428 | void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data; |
@@ -694,7 +696,7 @@ static struct kobj_attribute sys_reipl_ccw_vmparm_attr = | |||
694 | 696 | ||
695 | /* FCP reipl device attributes */ | 697 | /* FCP reipl device attributes */ |
696 | 698 | ||
697 | static ssize_t reipl_fcp_scpdata_read(struct kobject *kobj, | 699 | static ssize_t reipl_fcp_scpdata_read(struct file *filp, struct kobject *kobj, |
698 | struct bin_attribute *attr, | 700 | struct bin_attribute *attr, |
699 | char *buf, loff_t off, size_t count) | 701 | char *buf, loff_t off, size_t count) |
700 | { | 702 | { |
@@ -704,7 +706,7 @@ static ssize_t reipl_fcp_scpdata_read(struct kobject *kobj, | |||
704 | return memory_read_from_buffer(buf, count, &off, scp_data, size); | 706 | return memory_read_from_buffer(buf, count, &off, scp_data, size); |
705 | } | 707 | } |
706 | 708 | ||
707 | static ssize_t reipl_fcp_scpdata_write(struct kobject *kobj, | 709 | static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj, |
708 | struct bin_attribute *attr, | 710 | struct bin_attribute *attr, |
709 | char *buf, loff_t off, size_t count) | 711 | char *buf, loff_t off, size_t count) |
710 | { | 712 | { |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index e35525b39f6b..c79e789ed03a 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -71,7 +71,7 @@ struct acpi_table_attr { | |||
71 | struct list_head node; | 71 | struct list_head node; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static ssize_t acpi_table_show(struct kobject *kobj, | 74 | static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj, |
75 | struct bin_attribute *bin_attr, char *buf, | 75 | struct bin_attribute *bin_attr, char *buf, |
76 | loff_t offset, size_t count) | 76 | loff_t offset, size_t count) |
77 | { | 77 | { |
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index fd52c48ee762..ef38aff737eb 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig | |||
@@ -18,9 +18,9 @@ config UEVENT_HELPER_PATH | |||
18 | 18 | ||
19 | config DEVTMPFS | 19 | config DEVTMPFS |
20 | bool "Maintain a devtmpfs filesystem to mount at /dev" | 20 | bool "Maintain a devtmpfs filesystem to mount at /dev" |
21 | depends on HOTPLUG && SHMEM && TMPFS | 21 | depends on HOTPLUG |
22 | help | 22 | help |
23 | This creates a tmpfs filesystem instance early at bootup. | 23 | This creates a tmpfs/ramfs filesystem instance early at bootup. |
24 | In this filesystem, the kernel driver core maintains device | 24 | In this filesystem, the kernel driver core maintains device |
25 | nodes with their default names and permissions for all | 25 | nodes with their default names and permissions for all |
26 | registered devices with an assigned major/minor number. | 26 | registered devices with an assigned major/minor number. |
@@ -33,6 +33,9 @@ config DEVTMPFS | |||
33 | functional /dev without any further help. It also allows simple | 33 | functional /dev without any further help. It also allows simple |
34 | rescue systems, and reliably handles dynamic major/minor numbers. | 34 | rescue systems, and reliably handles dynamic major/minor numbers. |
35 | 35 | ||
36 | Notice: if CONFIG_TMPFS isn't enabled, the simpler ramfs | ||
37 | file system will be used instead. | ||
38 | |||
36 | config DEVTMPFS_MOUNT | 39 | config DEVTMPFS_MOUNT |
37 | bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" | 40 | bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" |
38 | depends on DEVTMPFS | 41 | depends on DEVTMPFS |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 9c6a0d6408e7..8e231d05b400 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -63,6 +63,14 @@ static void class_release(struct kobject *kobj) | |||
63 | kfree(cp); | 63 | kfree(cp); |
64 | } | 64 | } |
65 | 65 | ||
66 | static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj) | ||
67 | { | ||
68 | struct class_private *cp = to_class(kobj); | ||
69 | struct class *class = cp->class; | ||
70 | |||
71 | return class->ns_type; | ||
72 | } | ||
73 | |||
66 | static const struct sysfs_ops class_sysfs_ops = { | 74 | static const struct sysfs_ops class_sysfs_ops = { |
67 | .show = class_attr_show, | 75 | .show = class_attr_show, |
68 | .store = class_attr_store, | 76 | .store = class_attr_store, |
@@ -71,6 +79,7 @@ static const struct sysfs_ops class_sysfs_ops = { | |||
71 | static struct kobj_type class_ktype = { | 79 | static struct kobj_type class_ktype = { |
72 | .sysfs_ops = &class_sysfs_ops, | 80 | .sysfs_ops = &class_sysfs_ops, |
73 | .release = class_release, | 81 | .release = class_release, |
82 | .child_ns_type = class_child_ns_type, | ||
74 | }; | 83 | }; |
75 | 84 | ||
76 | /* Hotplug events for classes go to the class class_subsys */ | 85 | /* Hotplug events for classes go to the class class_subsys */ |
diff --git a/drivers/base/core.c b/drivers/base/core.c index b56a0ba31d4a..9630fbdf4e6c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/notifier.h> | 20 | #include <linux/notifier.h> |
21 | #include <linux/genhd.h> | 21 | #include <linux/genhd.h> |
22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
23 | #include <linux/semaphore.h> | ||
24 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
25 | #include <linux/async.h> | 24 | #include <linux/async.h> |
26 | 25 | ||
@@ -132,9 +131,21 @@ static void device_release(struct kobject *kobj) | |||
132 | kfree(p); | 131 | kfree(p); |
133 | } | 132 | } |
134 | 133 | ||
134 | static const void *device_namespace(struct kobject *kobj) | ||
135 | { | ||
136 | struct device *dev = to_dev(kobj); | ||
137 | const void *ns = NULL; | ||
138 | |||
139 | if (dev->class && dev->class->ns_type) | ||
140 | ns = dev->class->namespace(dev); | ||
141 | |||
142 | return ns; | ||
143 | } | ||
144 | |||
135 | static struct kobj_type device_ktype = { | 145 | static struct kobj_type device_ktype = { |
136 | .release = device_release, | 146 | .release = device_release, |
137 | .sysfs_ops = &dev_sysfs_ops, | 147 | .sysfs_ops = &dev_sysfs_ops, |
148 | .namespace = device_namespace, | ||
138 | }; | 149 | }; |
139 | 150 | ||
140 | 151 | ||
@@ -559,10 +570,10 @@ void device_initialize(struct device *dev) | |||
559 | dev->kobj.kset = devices_kset; | 570 | dev->kobj.kset = devices_kset; |
560 | kobject_init(&dev->kobj, &device_ktype); | 571 | kobject_init(&dev->kobj, &device_ktype); |
561 | INIT_LIST_HEAD(&dev->dma_pools); | 572 | INIT_LIST_HEAD(&dev->dma_pools); |
562 | init_MUTEX(&dev->sem); | 573 | mutex_init(&dev->mutex); |
574 | lockdep_set_novalidate_class(&dev->mutex); | ||
563 | spin_lock_init(&dev->devres_lock); | 575 | spin_lock_init(&dev->devres_lock); |
564 | INIT_LIST_HEAD(&dev->devres_head); | 576 | INIT_LIST_HEAD(&dev->devres_head); |
565 | device_init_wakeup(dev, 0); | ||
566 | device_pm_init(dev); | 577 | device_pm_init(dev); |
567 | set_dev_node(dev, -1); | 578 | set_dev_node(dev, -1); |
568 | } | 579 | } |
@@ -596,11 +607,59 @@ static struct kobject *virtual_device_parent(struct device *dev) | |||
596 | return virtual_dir; | 607 | return virtual_dir; |
597 | } | 608 | } |
598 | 609 | ||
599 | static struct kobject *get_device_parent(struct device *dev, | 610 | struct class_dir { |
600 | struct device *parent) | 611 | struct kobject kobj; |
612 | struct class *class; | ||
613 | }; | ||
614 | |||
615 | #define to_class_dir(obj) container_of(obj, struct class_dir, kobj) | ||
616 | |||
617 | static void class_dir_release(struct kobject *kobj) | ||
618 | { | ||
619 | struct class_dir *dir = to_class_dir(kobj); | ||
620 | kfree(dir); | ||
621 | } | ||
622 | |||
623 | static const | ||
624 | struct kobj_ns_type_operations *class_dir_child_ns_type(struct kobject *kobj) | ||
601 | { | 625 | { |
626 | struct class_dir *dir = to_class_dir(kobj); | ||
627 | return dir->class->ns_type; | ||
628 | } | ||
629 | |||
630 | static struct kobj_type class_dir_ktype = { | ||
631 | .release = class_dir_release, | ||
632 | .sysfs_ops = &kobj_sysfs_ops, | ||
633 | .child_ns_type = class_dir_child_ns_type | ||
634 | }; | ||
635 | |||
636 | static struct kobject * | ||
637 | class_dir_create_and_add(struct class *class, struct kobject *parent_kobj) | ||
638 | { | ||
639 | struct class_dir *dir; | ||
602 | int retval; | 640 | int retval; |
603 | 641 | ||
642 | dir = kzalloc(sizeof(*dir), GFP_KERNEL); | ||
643 | if (!dir) | ||
644 | return NULL; | ||
645 | |||
646 | dir->class = class; | ||
647 | kobject_init(&dir->kobj, &class_dir_ktype); | ||
648 | |||
649 | dir->kobj.kset = &class->p->class_dirs; | ||
650 | |||
651 | retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name); | ||
652 | if (retval < 0) { | ||
653 | kobject_put(&dir->kobj); | ||
654 | return NULL; | ||
655 | } | ||
656 | return &dir->kobj; | ||
657 | } | ||
658 | |||
659 | |||
660 | static struct kobject *get_device_parent(struct device *dev, | ||
661 | struct device *parent) | ||
662 | { | ||
604 | if (dev->class) { | 663 | if (dev->class) { |
605 | static DEFINE_MUTEX(gdp_mutex); | 664 | static DEFINE_MUTEX(gdp_mutex); |
606 | struct kobject *kobj = NULL; | 665 | struct kobject *kobj = NULL; |
@@ -635,18 +694,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
635 | } | 694 | } |
636 | 695 | ||
637 | /* or create a new class-directory at the parent device */ | 696 | /* or create a new class-directory at the parent device */ |
638 | k = kobject_create(); | 697 | k = class_dir_create_and_add(dev->class, parent_kobj); |
639 | if (!k) { | ||
640 | mutex_unlock(&gdp_mutex); | ||
641 | return NULL; | ||
642 | } | ||
643 | k->kset = &dev->class->p->class_dirs; | ||
644 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); | ||
645 | if (retval < 0) { | ||
646 | mutex_unlock(&gdp_mutex); | ||
647 | kobject_put(k); | ||
648 | return NULL; | ||
649 | } | ||
650 | /* do not emit an uevent for this simple "glue" directory */ | 698 | /* do not emit an uevent for this simple "glue" directory */ |
651 | mutex_unlock(&gdp_mutex); | 699 | mutex_unlock(&gdp_mutex); |
652 | return k; | 700 | return k; |
@@ -738,7 +786,7 @@ out_device: | |||
738 | out_busid: | 786 | out_busid: |
739 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | 787 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
740 | device_is_not_partition(dev)) | 788 | device_is_not_partition(dev)) |
741 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, | 789 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, |
742 | dev_name(dev)); | 790 | dev_name(dev)); |
743 | #else | 791 | #else |
744 | /* link in the class directory pointing to the device */ | 792 | /* link in the class directory pointing to the device */ |
@@ -756,7 +804,7 @@ out_busid: | |||
756 | return 0; | 804 | return 0; |
757 | 805 | ||
758 | out_busid: | 806 | out_busid: |
759 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); | 807 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); |
760 | #endif | 808 | #endif |
761 | 809 | ||
762 | out_subsys: | 810 | out_subsys: |
@@ -784,13 +832,13 @@ static void device_remove_class_symlinks(struct device *dev) | |||
784 | 832 | ||
785 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | 833 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
786 | device_is_not_partition(dev)) | 834 | device_is_not_partition(dev)) |
787 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, | 835 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, |
788 | dev_name(dev)); | 836 | dev_name(dev)); |
789 | #else | 837 | #else |
790 | if (dev->parent && device_is_not_partition(dev)) | 838 | if (dev->parent && device_is_not_partition(dev)) |
791 | sysfs_remove_link(&dev->kobj, "device"); | 839 | sysfs_remove_link(&dev->kobj, "device"); |
792 | 840 | ||
793 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); | 841 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); |
794 | #endif | 842 | #endif |
795 | 843 | ||
796 | sysfs_remove_link(&dev->kobj, "subsystem"); | 844 | sysfs_remove_link(&dev->kobj, "subsystem"); |
@@ -1372,7 +1420,7 @@ struct device *__root_device_register(const char *name, struct module *owner) | |||
1372 | return ERR_PTR(err); | 1420 | return ERR_PTR(err); |
1373 | } | 1421 | } |
1374 | 1422 | ||
1375 | #ifdef CONFIG_MODULE /* gotta find a "cleaner" way to do this */ | 1423 | #ifdef CONFIG_MODULES /* gotta find a "cleaner" way to do this */ |
1376 | if (owner) { | 1424 | if (owner) { |
1377 | struct module_kobject *mk = &owner->mkobj; | 1425 | struct module_kobject *mk = &owner->mkobj; |
1378 | 1426 | ||
@@ -1576,6 +1624,14 @@ int device_rename(struct device *dev, char *new_name) | |||
1576 | goto out; | 1624 | goto out; |
1577 | } | 1625 | } |
1578 | 1626 | ||
1627 | #ifndef CONFIG_SYSFS_DEPRECATED | ||
1628 | if (dev->class) { | ||
1629 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, | ||
1630 | &dev->kobj, old_device_name, new_name); | ||
1631 | if (error) | ||
1632 | goto out; | ||
1633 | } | ||
1634 | #endif | ||
1579 | error = kobject_rename(&dev->kobj, new_name); | 1635 | error = kobject_rename(&dev->kobj, new_name); |
1580 | if (error) | 1636 | if (error) |
1581 | goto out; | 1637 | goto out; |
@@ -1590,11 +1646,6 @@ int device_rename(struct device *dev, char *new_name) | |||
1590 | new_class_name); | 1646 | new_class_name); |
1591 | } | 1647 | } |
1592 | } | 1648 | } |
1593 | #else | ||
1594 | if (dev->class) { | ||
1595 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, | ||
1596 | &dev->kobj, old_device_name, new_name); | ||
1597 | } | ||
1598 | #endif | 1649 | #endif |
1599 | 1650 | ||
1600 | out: | 1651 | out: |
@@ -1735,10 +1786,25 @@ EXPORT_SYMBOL_GPL(device_move); | |||
1735 | */ | 1786 | */ |
1736 | void device_shutdown(void) | 1787 | void device_shutdown(void) |
1737 | { | 1788 | { |
1738 | struct device *dev, *devn; | 1789 | struct device *dev; |
1790 | |||
1791 | spin_lock(&devices_kset->list_lock); | ||
1792 | /* | ||
1793 | * Walk the devices list backward, shutting down each in turn. | ||
1794 | * Beware that device unplug events may also start pulling | ||
1795 | * devices offline, even as the system is shutting down. | ||
1796 | */ | ||
1797 | while (!list_empty(&devices_kset->list)) { | ||
1798 | dev = list_entry(devices_kset->list.prev, struct device, | ||
1799 | kobj.entry); | ||
1800 | get_device(dev); | ||
1801 | /* | ||
1802 | * Make sure the device is off the kset list, in the | ||
1803 | * event that dev->*->shutdown() doesn't remove it. | ||
1804 | */ | ||
1805 | list_del_init(&dev->kobj.entry); | ||
1806 | spin_unlock(&devices_kset->list_lock); | ||
1739 | 1807 | ||
1740 | list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list, | ||
1741 | kobj.entry) { | ||
1742 | if (dev->bus && dev->bus->shutdown) { | 1808 | if (dev->bus && dev->bus->shutdown) { |
1743 | dev_dbg(dev, "shutdown\n"); | 1809 | dev_dbg(dev, "shutdown\n"); |
1744 | dev->bus->shutdown(dev); | 1810 | dev->bus->shutdown(dev); |
@@ -1746,6 +1812,10 @@ void device_shutdown(void) | |||
1746 | dev_dbg(dev, "shutdown\n"); | 1812 | dev_dbg(dev, "shutdown\n"); |
1747 | dev->driver->shutdown(dev); | 1813 | dev->driver->shutdown(dev); |
1748 | } | 1814 | } |
1815 | put_device(dev); | ||
1816 | |||
1817 | spin_lock(&devices_kset->list_lock); | ||
1749 | } | 1818 | } |
1819 | spin_unlock(&devices_kset->list_lock); | ||
1750 | async_synchronize_full(); | 1820 | async_synchronize_full(); |
1751 | } | 1821 | } |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index f35719aab3c1..251acea3d359 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -186,7 +186,7 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, | |||
186 | /* display offline cpus < nr_cpu_ids */ | 186 | /* display offline cpus < nr_cpu_ids */ |
187 | if (!alloc_cpumask_var(&offline, GFP_KERNEL)) | 187 | if (!alloc_cpumask_var(&offline, GFP_KERNEL)) |
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | cpumask_complement(offline, cpu_online_mask); | 189 | cpumask_andnot(offline, cpu_possible_mask, cpu_online_mask); |
190 | n = cpulist_scnprintf(buf, len, offline); | 190 | n = cpulist_scnprintf(buf, len, offline); |
191 | free_cpumask_var(offline); | 191 | free_cpumask_var(offline); |
192 | 192 | ||
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index c89291f8a16b..503c2620bbcc 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -40,11 +40,11 @@ static void driver_bound(struct device *dev) | |||
40 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev), | 40 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev), |
41 | __func__, dev->driver->name); | 41 | __func__, dev->driver->name); |
42 | 42 | ||
43 | klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); | ||
44 | |||
43 | if (dev->bus) | 45 | if (dev->bus) |
44 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 46 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
45 | BUS_NOTIFY_BOUND_DRIVER, dev); | 47 | BUS_NOTIFY_BOUND_DRIVER, dev); |
46 | |||
47 | klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); | ||
48 | } | 48 | } |
49 | 49 | ||
50 | static int driver_sysfs_add(struct device *dev) | 50 | static int driver_sysfs_add(struct device *dev) |
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 057cf11326bf..af0600143d1c 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/namei.h> | 20 | #include <linux/namei.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/shmem_fs.h> | 22 | #include <linux/shmem_fs.h> |
23 | #include <linux/ramfs.h> | ||
23 | #include <linux/cred.h> | 24 | #include <linux/cred.h> |
24 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
25 | #include <linux/init_task.h> | 26 | #include <linux/init_task.h> |
@@ -45,7 +46,11 @@ __setup("devtmpfs.mount=", mount_param); | |||
45 | static int dev_get_sb(struct file_system_type *fs_type, int flags, | 46 | static int dev_get_sb(struct file_system_type *fs_type, int flags, |
46 | const char *dev_name, void *data, struct vfsmount *mnt) | 47 | const char *dev_name, void *data, struct vfsmount *mnt) |
47 | { | 48 | { |
49 | #ifdef CONFIG_TMPFS | ||
48 | return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt); | 50 | return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt); |
51 | #else | ||
52 | return get_sb_single(fs_type, flags, data, ramfs_fill_super, mnt); | ||
53 | #endif | ||
49 | } | 54 | } |
50 | 55 | ||
51 | static struct file_system_type dev_fs_type = { | 56 | static struct file_system_type dev_fs_type = { |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 985da11174e7..3f093b0dd217 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -27,6 +27,52 @@ MODULE_AUTHOR("Manuel Estrada Sainz"); | |||
27 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); | 27 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); |
28 | MODULE_LICENSE("GPL"); | 28 | MODULE_LICENSE("GPL"); |
29 | 29 | ||
30 | /* Builtin firmware support */ | ||
31 | |||
32 | #ifdef CONFIG_FW_LOADER | ||
33 | |||
34 | extern struct builtin_fw __start_builtin_fw[]; | ||
35 | extern struct builtin_fw __end_builtin_fw[]; | ||
36 | |||
37 | static bool fw_get_builtin_firmware(struct firmware *fw, const char *name) | ||
38 | { | ||
39 | struct builtin_fw *b_fw; | ||
40 | |||
41 | for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { | ||
42 | if (strcmp(name, b_fw->name) == 0) { | ||
43 | fw->size = b_fw->size; | ||
44 | fw->data = b_fw->data; | ||
45 | return true; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | return false; | ||
50 | } | ||
51 | |||
52 | static bool fw_is_builtin_firmware(const struct firmware *fw) | ||
53 | { | ||
54 | struct builtin_fw *b_fw; | ||
55 | |||
56 | for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) | ||
57 | if (fw->data == b_fw->data) | ||
58 | return true; | ||
59 | |||
60 | return false; | ||
61 | } | ||
62 | |||
63 | #else /* Module case - no builtin firmware support */ | ||
64 | |||
65 | static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name) | ||
66 | { | ||
67 | return false; | ||
68 | } | ||
69 | |||
70 | static inline bool fw_is_builtin_firmware(const struct firmware *fw) | ||
71 | { | ||
72 | return false; | ||
73 | } | ||
74 | #endif | ||
75 | |||
30 | enum { | 76 | enum { |
31 | FW_STATUS_LOADING, | 77 | FW_STATUS_LOADING, |
32 | FW_STATUS_DONE, | 78 | FW_STATUS_DONE, |
@@ -40,7 +86,6 @@ static int loading_timeout = 60; /* In seconds */ | |||
40 | static DEFINE_MUTEX(fw_lock); | 86 | static DEFINE_MUTEX(fw_lock); |
41 | 87 | ||
42 | struct firmware_priv { | 88 | struct firmware_priv { |
43 | char *fw_id; | ||
44 | struct completion completion; | 89 | struct completion completion; |
45 | struct bin_attribute attr_data; | 90 | struct bin_attribute attr_data; |
46 | struct firmware *fw; | 91 | struct firmware *fw; |
@@ -48,18 +93,11 @@ struct firmware_priv { | |||
48 | struct page **pages; | 93 | struct page **pages; |
49 | int nr_pages; | 94 | int nr_pages; |
50 | int page_array_size; | 95 | int page_array_size; |
51 | const char *vdata; | ||
52 | struct timer_list timeout; | 96 | struct timer_list timeout; |
97 | bool nowait; | ||
98 | char fw_id[]; | ||
53 | }; | 99 | }; |
54 | 100 | ||
55 | #ifdef CONFIG_FW_LOADER | ||
56 | extern struct builtin_fw __start_builtin_fw[]; | ||
57 | extern struct builtin_fw __end_builtin_fw[]; | ||
58 | #else /* Module case. Avoid ifdefs later; it'll all optimise out */ | ||
59 | static struct builtin_fw *__start_builtin_fw; | ||
60 | static struct builtin_fw *__end_builtin_fw; | ||
61 | #endif | ||
62 | |||
63 | static void | 101 | static void |
64 | fw_load_abort(struct firmware_priv *fw_priv) | 102 | fw_load_abort(struct firmware_priv *fw_priv) |
65 | { | 103 | { |
@@ -100,9 +138,25 @@ firmware_timeout_store(struct class *class, | |||
100 | return count; | 138 | return count; |
101 | } | 139 | } |
102 | 140 | ||
103 | static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); | 141 | static struct class_attribute firmware_class_attrs[] = { |
142 | __ATTR(timeout, S_IWUSR | S_IRUGO, | ||
143 | firmware_timeout_show, firmware_timeout_store), | ||
144 | __ATTR_NULL | ||
145 | }; | ||
146 | |||
147 | static void fw_dev_release(struct device *dev) | ||
148 | { | ||
149 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
150 | int i; | ||
151 | |||
152 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
153 | __free_page(fw_priv->pages[i]); | ||
154 | kfree(fw_priv->pages); | ||
155 | kfree(fw_priv); | ||
156 | kfree(dev); | ||
104 | 157 | ||
105 | static void fw_dev_release(struct device *dev); | 158 | module_put(THIS_MODULE); |
159 | } | ||
106 | 160 | ||
107 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | 161 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) |
108 | { | 162 | { |
@@ -112,12 +166,15 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
112 | return -ENOMEM; | 166 | return -ENOMEM; |
113 | if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) | 167 | if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) |
114 | return -ENOMEM; | 168 | return -ENOMEM; |
169 | if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait)) | ||
170 | return -ENOMEM; | ||
115 | 171 | ||
116 | return 0; | 172 | return 0; |
117 | } | 173 | } |
118 | 174 | ||
119 | static struct class firmware_class = { | 175 | static struct class firmware_class = { |
120 | .name = "firmware", | 176 | .name = "firmware", |
177 | .class_attrs = firmware_class_attrs, | ||
121 | .dev_uevent = firmware_uevent, | 178 | .dev_uevent = firmware_uevent, |
122 | .dev_release = fw_dev_release, | 179 | .dev_release = fw_dev_release, |
123 | }; | 180 | }; |
@@ -130,6 +187,17 @@ static ssize_t firmware_loading_show(struct device *dev, | |||
130 | return sprintf(buf, "%d\n", loading); | 187 | return sprintf(buf, "%d\n", loading); |
131 | } | 188 | } |
132 | 189 | ||
190 | static void firmware_free_data(const struct firmware *fw) | ||
191 | { | ||
192 | int i; | ||
193 | vunmap(fw->data); | ||
194 | if (fw->pages) { | ||
195 | for (i = 0; i < PFN_UP(fw->size); i++) | ||
196 | __free_page(fw->pages[i]); | ||
197 | kfree(fw->pages); | ||
198 | } | ||
199 | } | ||
200 | |||
133 | /* Some architectures don't have PAGE_KERNEL_RO */ | 201 | /* Some architectures don't have PAGE_KERNEL_RO */ |
134 | #ifndef PAGE_KERNEL_RO | 202 | #ifndef PAGE_KERNEL_RO |
135 | #define PAGE_KERNEL_RO PAGE_KERNEL | 203 | #define PAGE_KERNEL_RO PAGE_KERNEL |
@@ -162,21 +230,21 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
162 | mutex_unlock(&fw_lock); | 230 | mutex_unlock(&fw_lock); |
163 | break; | 231 | break; |
164 | } | 232 | } |
165 | vfree(fw_priv->fw->data); | 233 | firmware_free_data(fw_priv->fw); |
166 | fw_priv->fw->data = NULL; | 234 | memset(fw_priv->fw, 0, sizeof(struct firmware)); |
235 | /* If the pages are not owned by 'struct firmware' */ | ||
167 | for (i = 0; i < fw_priv->nr_pages; i++) | 236 | for (i = 0; i < fw_priv->nr_pages; i++) |
168 | __free_page(fw_priv->pages[i]); | 237 | __free_page(fw_priv->pages[i]); |
169 | kfree(fw_priv->pages); | 238 | kfree(fw_priv->pages); |
170 | fw_priv->pages = NULL; | 239 | fw_priv->pages = NULL; |
171 | fw_priv->page_array_size = 0; | 240 | fw_priv->page_array_size = 0; |
172 | fw_priv->nr_pages = 0; | 241 | fw_priv->nr_pages = 0; |
173 | fw_priv->fw->size = 0; | ||
174 | set_bit(FW_STATUS_LOADING, &fw_priv->status); | 242 | set_bit(FW_STATUS_LOADING, &fw_priv->status); |
175 | mutex_unlock(&fw_lock); | 243 | mutex_unlock(&fw_lock); |
176 | break; | 244 | break; |
177 | case 0: | 245 | case 0: |
178 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { | 246 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { |
179 | vfree(fw_priv->fw->data); | 247 | vunmap(fw_priv->fw->data); |
180 | fw_priv->fw->data = vmap(fw_priv->pages, | 248 | fw_priv->fw->data = vmap(fw_priv->pages, |
181 | fw_priv->nr_pages, | 249 | fw_priv->nr_pages, |
182 | 0, PAGE_KERNEL_RO); | 250 | 0, PAGE_KERNEL_RO); |
@@ -184,7 +252,10 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
184 | dev_err(dev, "%s: vmap() failed\n", __func__); | 252 | dev_err(dev, "%s: vmap() failed\n", __func__); |
185 | goto err; | 253 | goto err; |
186 | } | 254 | } |
187 | /* Pages will be freed by vfree() */ | 255 | /* Pages are now owned by 'struct firmware' */ |
256 | fw_priv->fw->pages = fw_priv->pages; | ||
257 | fw_priv->pages = NULL; | ||
258 | |||
188 | fw_priv->page_array_size = 0; | 259 | fw_priv->page_array_size = 0; |
189 | fw_priv->nr_pages = 0; | 260 | fw_priv->nr_pages = 0; |
190 | complete(&fw_priv->completion); | 261 | complete(&fw_priv->completion); |
@@ -207,8 +278,9 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
207 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); | 278 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); |
208 | 279 | ||
209 | static ssize_t | 280 | static ssize_t |
210 | firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 281 | firmware_data_read(struct file *filp, struct kobject *kobj, |
211 | char *buffer, loff_t offset, size_t count) | 282 | struct bin_attribute *bin_attr, char *buffer, loff_t offset, |
283 | size_t count) | ||
212 | { | 284 | { |
213 | struct device *dev = to_dev(kobj); | 285 | struct device *dev = to_dev(kobj); |
214 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 286 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); |
@@ -291,6 +363,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
291 | 363 | ||
292 | /** | 364 | /** |
293 | * firmware_data_write - write method for firmware | 365 | * firmware_data_write - write method for firmware |
366 | * @filp: open sysfs file | ||
294 | * @kobj: kobject for the device | 367 | * @kobj: kobject for the device |
295 | * @bin_attr: bin_attr structure | 368 | * @bin_attr: bin_attr structure |
296 | * @buffer: buffer being written | 369 | * @buffer: buffer being written |
@@ -301,8 +374,9 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
301 | * the driver as a firmware image. | 374 | * the driver as a firmware image. |
302 | **/ | 375 | **/ |
303 | static ssize_t | 376 | static ssize_t |
304 | firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 377 | firmware_data_write(struct file* filp, struct kobject *kobj, |
305 | char *buffer, loff_t offset, size_t count) | 378 | struct bin_attribute *bin_attr, char *buffer, |
379 | loff_t offset, size_t count) | ||
306 | { | 380 | { |
307 | struct device *dev = to_dev(kobj); | 381 | struct device *dev = to_dev(kobj); |
308 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 382 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); |
@@ -353,21 +427,6 @@ static struct bin_attribute firmware_attr_data_tmpl = { | |||
353 | .write = firmware_data_write, | 427 | .write = firmware_data_write, |
354 | }; | 428 | }; |
355 | 429 | ||
356 | static void fw_dev_release(struct device *dev) | ||
357 | { | ||
358 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
359 | int i; | ||
360 | |||
361 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
362 | __free_page(fw_priv->pages[i]); | ||
363 | kfree(fw_priv->pages); | ||
364 | kfree(fw_priv->fw_id); | ||
365 | kfree(fw_priv); | ||
366 | kfree(dev); | ||
367 | |||
368 | module_put(THIS_MODULE); | ||
369 | } | ||
370 | |||
371 | static void | 430 | static void |
372 | firmware_class_timeout(u_long data) | 431 | firmware_class_timeout(u_long data) |
373 | { | 432 | { |
@@ -379,8 +438,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
379 | struct device *device) | 438 | struct device *device) |
380 | { | 439 | { |
381 | int retval; | 440 | int retval; |
382 | struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), | 441 | struct firmware_priv *fw_priv = |
383 | GFP_KERNEL); | 442 | kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); |
384 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); | 443 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); |
385 | 444 | ||
386 | *dev_p = NULL; | 445 | *dev_p = NULL; |
@@ -391,16 +450,9 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
391 | goto error_kfree; | 450 | goto error_kfree; |
392 | } | 451 | } |
393 | 452 | ||
453 | strcpy(fw_priv->fw_id, fw_name); | ||
394 | init_completion(&fw_priv->completion); | 454 | init_completion(&fw_priv->completion); |
395 | fw_priv->attr_data = firmware_attr_data_tmpl; | 455 | fw_priv->attr_data = firmware_attr_data_tmpl; |
396 | fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); | ||
397 | if (!fw_priv->fw_id) { | ||
398 | dev_err(device, "%s: Firmware name allocation failed\n", | ||
399 | __func__); | ||
400 | retval = -ENOMEM; | ||
401 | goto error_kfree; | ||
402 | } | ||
403 | |||
404 | fw_priv->timeout.function = firmware_class_timeout; | 456 | fw_priv->timeout.function = firmware_class_timeout; |
405 | fw_priv->timeout.data = (u_long) fw_priv; | 457 | fw_priv->timeout.data = (u_long) fw_priv; |
406 | init_timer(&fw_priv->timeout); | 458 | init_timer(&fw_priv->timeout); |
@@ -427,7 +479,7 @@ error_kfree: | |||
427 | 479 | ||
428 | static int fw_setup_device(struct firmware *fw, struct device **dev_p, | 480 | static int fw_setup_device(struct firmware *fw, struct device **dev_p, |
429 | const char *fw_name, struct device *device, | 481 | const char *fw_name, struct device *device, |
430 | int uevent) | 482 | int uevent, bool nowait) |
431 | { | 483 | { |
432 | struct device *f_dev; | 484 | struct device *f_dev; |
433 | struct firmware_priv *fw_priv; | 485 | struct firmware_priv *fw_priv; |
@@ -443,6 +495,8 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, | |||
443 | 495 | ||
444 | fw_priv = dev_get_drvdata(f_dev); | 496 | fw_priv = dev_get_drvdata(f_dev); |
445 | 497 | ||
498 | fw_priv->nowait = nowait; | ||
499 | |||
446 | fw_priv->fw = fw; | 500 | fw_priv->fw = fw; |
447 | sysfs_bin_attr_init(&fw_priv->attr_data); | 501 | sysfs_bin_attr_init(&fw_priv->attr_data); |
448 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); | 502 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); |
@@ -470,12 +524,11 @@ out: | |||
470 | 524 | ||
471 | static int | 525 | static int |
472 | _request_firmware(const struct firmware **firmware_p, const char *name, | 526 | _request_firmware(const struct firmware **firmware_p, const char *name, |
473 | struct device *device, int uevent) | 527 | struct device *device, int uevent, bool nowait) |
474 | { | 528 | { |
475 | struct device *f_dev; | 529 | struct device *f_dev; |
476 | struct firmware_priv *fw_priv; | 530 | struct firmware_priv *fw_priv; |
477 | struct firmware *firmware; | 531 | struct firmware *firmware; |
478 | struct builtin_fw *builtin; | ||
479 | int retval; | 532 | int retval; |
480 | 533 | ||
481 | if (!firmware_p) | 534 | if (!firmware_p) |
@@ -489,21 +542,16 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
489 | goto out; | 542 | goto out; |
490 | } | 543 | } |
491 | 544 | ||
492 | for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; | 545 | if (fw_get_builtin_firmware(firmware, name)) { |
493 | builtin++) { | 546 | dev_dbg(device, "firmware: using built-in firmware %s\n", name); |
494 | if (strcmp(name, builtin->name)) | ||
495 | continue; | ||
496 | dev_info(device, "firmware: using built-in firmware %s\n", | ||
497 | name); | ||
498 | firmware->size = builtin->size; | ||
499 | firmware->data = builtin->data; | ||
500 | return 0; | 547 | return 0; |
501 | } | 548 | } |
502 | 549 | ||
503 | if (uevent) | 550 | if (uevent) |
504 | dev_info(device, "firmware: requesting %s\n", name); | 551 | dev_dbg(device, "firmware: requesting %s\n", name); |
505 | 552 | ||
506 | retval = fw_setup_device(firmware, &f_dev, name, device, uevent); | 553 | retval = fw_setup_device(firmware, &f_dev, name, device, |
554 | uevent, nowait); | ||
507 | if (retval) | 555 | if (retval) |
508 | goto error_kfree_fw; | 556 | goto error_kfree_fw; |
509 | 557 | ||
@@ -560,26 +608,18 @@ request_firmware(const struct firmware **firmware_p, const char *name, | |||
560 | struct device *device) | 608 | struct device *device) |
561 | { | 609 | { |
562 | int uevent = 1; | 610 | int uevent = 1; |
563 | return _request_firmware(firmware_p, name, device, uevent); | 611 | return _request_firmware(firmware_p, name, device, uevent, false); |
564 | } | 612 | } |
565 | 613 | ||
566 | /** | 614 | /** |
567 | * release_firmware: - release the resource associated with a firmware image | 615 | * release_firmware: - release the resource associated with a firmware image |
568 | * @fw: firmware resource to release | 616 | * @fw: firmware resource to release |
569 | **/ | 617 | **/ |
570 | void | 618 | void release_firmware(const struct firmware *fw) |
571 | release_firmware(const struct firmware *fw) | ||
572 | { | 619 | { |
573 | struct builtin_fw *builtin; | ||
574 | |||
575 | if (fw) { | 620 | if (fw) { |
576 | for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; | 621 | if (!fw_is_builtin_firmware(fw)) |
577 | builtin++) { | 622 | firmware_free_data(fw); |
578 | if (fw->data == builtin->data) | ||
579 | goto free_fw; | ||
580 | } | ||
581 | vfree(fw->data); | ||
582 | free_fw: | ||
583 | kfree(fw); | 623 | kfree(fw); |
584 | } | 624 | } |
585 | } | 625 | } |
@@ -606,7 +646,7 @@ request_firmware_work_func(void *arg) | |||
606 | return 0; | 646 | return 0; |
607 | } | 647 | } |
608 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, | 648 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, |
609 | fw_work->uevent); | 649 | fw_work->uevent, true); |
610 | 650 | ||
611 | fw_work->cont(fw, fw_work->context); | 651 | fw_work->cont(fw, fw_work->context); |
612 | 652 | ||
@@ -670,26 +710,12 @@ request_firmware_nowait( | |||
670 | return 0; | 710 | return 0; |
671 | } | 711 | } |
672 | 712 | ||
673 | static int __init | 713 | static int __init firmware_class_init(void) |
674 | firmware_class_init(void) | ||
675 | { | 714 | { |
676 | int error; | 715 | return class_register(&firmware_class); |
677 | error = class_register(&firmware_class); | ||
678 | if (error) { | ||
679 | printk(KERN_ERR "%s: class_register failed\n", __func__); | ||
680 | return error; | ||
681 | } | ||
682 | error = class_create_file(&firmware_class, &class_attr_timeout); | ||
683 | if (error) { | ||
684 | printk(KERN_ERR "%s: class_create_file failed\n", | ||
685 | __func__); | ||
686 | class_unregister(&firmware_class); | ||
687 | } | ||
688 | return error; | ||
689 | |||
690 | } | 716 | } |
691 | static void __exit | 717 | |
692 | firmware_class_exit(void) | 718 | static void __exit firmware_class_exit(void) |
693 | { | 719 | { |
694 | class_unregister(&firmware_class); | 720 | class_unregister(&firmware_class); |
695 | } | 721 | } |
diff --git a/drivers/base/module.c b/drivers/base/module.c index f32f2f9b7be5..db930d3ee312 100644 --- a/drivers/base/module.c +++ b/drivers/base/module.c | |||
@@ -15,12 +15,10 @@ static char *make_driver_name(struct device_driver *drv) | |||
15 | { | 15 | { |
16 | char *driver_name; | 16 | char *driver_name; |
17 | 17 | ||
18 | driver_name = kmalloc(strlen(drv->name) + strlen(drv->bus->name) + 2, | 18 | driver_name = kasprintf(GFP_KERNEL, "%s:%s", drv->bus->name, drv->name); |
19 | GFP_KERNEL); | ||
20 | if (!driver_name) | 19 | if (!driver_name) |
21 | return NULL; | 20 | return NULL; |
22 | 21 | ||
23 | sprintf(driver_name, "%s:%s", drv->bus->name, drv->name); | ||
24 | return driver_name; | 22 | return driver_name; |
25 | } | 23 | } |
26 | 24 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ada6397c23a5..4d99c8bdfedc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -735,7 +735,7 @@ static void platform_pm_complete(struct device *dev) | |||
735 | 735 | ||
736 | #ifdef CONFIG_SUSPEND | 736 | #ifdef CONFIG_SUSPEND |
737 | 737 | ||
738 | static int platform_pm_suspend(struct device *dev) | 738 | int __weak platform_pm_suspend(struct device *dev) |
739 | { | 739 | { |
740 | struct device_driver *drv = dev->driver; | 740 | struct device_driver *drv = dev->driver; |
741 | int ret = 0; | 741 | int ret = 0; |
@@ -753,7 +753,7 @@ static int platform_pm_suspend(struct device *dev) | |||
753 | return ret; | 753 | return ret; |
754 | } | 754 | } |
755 | 755 | ||
756 | static int platform_pm_suspend_noirq(struct device *dev) | 756 | int __weak platform_pm_suspend_noirq(struct device *dev) |
757 | { | 757 | { |
758 | struct device_driver *drv = dev->driver; | 758 | struct device_driver *drv = dev->driver; |
759 | int ret = 0; | 759 | int ret = 0; |
@@ -769,7 +769,7 @@ static int platform_pm_suspend_noirq(struct device *dev) | |||
769 | return ret; | 769 | return ret; |
770 | } | 770 | } |
771 | 771 | ||
772 | static int platform_pm_resume(struct device *dev) | 772 | int __weak platform_pm_resume(struct device *dev) |
773 | { | 773 | { |
774 | struct device_driver *drv = dev->driver; | 774 | struct device_driver *drv = dev->driver; |
775 | int ret = 0; | 775 | int ret = 0; |
@@ -787,7 +787,7 @@ static int platform_pm_resume(struct device *dev) | |||
787 | return ret; | 787 | return ret; |
788 | } | 788 | } |
789 | 789 | ||
790 | static int platform_pm_resume_noirq(struct device *dev) | 790 | int __weak platform_pm_resume_noirq(struct device *dev) |
791 | { | 791 | { |
792 | struct device_driver *drv = dev->driver; | 792 | struct device_driver *drv = dev->driver; |
793 | int ret = 0; | 793 | int ret = 0; |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 8546d123b9a7..a90e83c9be96 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -835,6 +835,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, | |||
835 | 835 | ||
836 | set_capacity(lo->lo_disk, size); | 836 | set_capacity(lo->lo_disk, size); |
837 | bd_set_size(bdev, size << 9); | 837 | bd_set_size(bdev, size << 9); |
838 | /* let user-space know about the new size */ | ||
839 | kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); | ||
838 | 840 | ||
839 | set_blocksize(bdev, lo_blocksize); | 841 | set_blocksize(bdev, lo_blocksize); |
840 | 842 | ||
@@ -858,6 +860,7 @@ out_clr: | |||
858 | set_capacity(lo->lo_disk, 0); | 860 | set_capacity(lo->lo_disk, 0); |
859 | invalidate_bdev(bdev); | 861 | invalidate_bdev(bdev); |
860 | bd_set_size(bdev, 0); | 862 | bd_set_size(bdev, 0); |
863 | kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); | ||
861 | mapping_set_gfp_mask(mapping, lo->old_gfp_mask); | 864 | mapping_set_gfp_mask(mapping, lo->old_gfp_mask); |
862 | lo->lo_state = Lo_unbound; | 865 | lo->lo_state = Lo_unbound; |
863 | out_putf: | 866 | out_putf: |
@@ -944,8 +947,11 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev) | |||
944 | if (bdev) | 947 | if (bdev) |
945 | invalidate_bdev(bdev); | 948 | invalidate_bdev(bdev); |
946 | set_capacity(lo->lo_disk, 0); | 949 | set_capacity(lo->lo_disk, 0); |
947 | if (bdev) | 950 | if (bdev) { |
948 | bd_set_size(bdev, 0); | 951 | bd_set_size(bdev, 0); |
952 | /* let user-space know about this change */ | ||
953 | kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); | ||
954 | } | ||
949 | mapping_set_gfp_mask(filp->f_mapping, gfp); | 955 | mapping_set_gfp_mask(filp->f_mapping, gfp); |
950 | lo->lo_state = Lo_unbound; | 956 | lo->lo_state = Lo_unbound; |
951 | /* This is safe: open() is still holding a reference. */ | 957 | /* This is safe: open() is still holding a reference. */ |
@@ -1189,6 +1195,8 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev) | |||
1189 | sz <<= 9; | 1195 | sz <<= 9; |
1190 | mutex_lock(&bdev->bd_mutex); | 1196 | mutex_lock(&bdev->bd_mutex); |
1191 | bd_set_size(bdev, sz); | 1197 | bd_set_size(bdev, sz); |
1198 | /* let user-space know about the new size */ | ||
1199 | kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); | ||
1192 | mutex_unlock(&bdev->bd_mutex); | 1200 | mutex_unlock(&bdev->bd_mutex); |
1193 | 1201 | ||
1194 | out: | 1202 | out: |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index fb09bb3c0ad6..aa9bc9e980e1 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -149,7 +149,7 @@ static ssize_t smi_data_buf_size_store(struct device *dev, | |||
149 | return count; | 149 | return count; |
150 | } | 150 | } |
151 | 151 | ||
152 | static ssize_t smi_data_read(struct kobject *kobj, | 152 | static ssize_t smi_data_read(struct file *filp, struct kobject *kobj, |
153 | struct bin_attribute *bin_attr, | 153 | struct bin_attribute *bin_attr, |
154 | char *buf, loff_t pos, size_t count) | 154 | char *buf, loff_t pos, size_t count) |
155 | { | 155 | { |
@@ -162,7 +162,7 @@ static ssize_t smi_data_read(struct kobject *kobj, | |||
162 | return ret; | 162 | return ret; |
163 | } | 163 | } |
164 | 164 | ||
165 | static ssize_t smi_data_write(struct kobject *kobj, | 165 | static ssize_t smi_data_write(struct file *filp, struct kobject *kobj, |
166 | struct bin_attribute *bin_attr, | 166 | struct bin_attribute *bin_attr, |
167 | char *buf, loff_t pos, size_t count) | 167 | char *buf, loff_t pos, size_t count) |
168 | { | 168 | { |
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 3a4460265b10..2f452f1f7c8a 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c | |||
@@ -522,7 +522,7 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) | |||
522 | rbu_data.image_update_buffer, rbu_data.bios_image_size); | 522 | rbu_data.image_update_buffer, rbu_data.bios_image_size); |
523 | } | 523 | } |
524 | 524 | ||
525 | static ssize_t read_rbu_data(struct kobject *kobj, | 525 | static ssize_t read_rbu_data(struct file *filp, struct kobject *kobj, |
526 | struct bin_attribute *bin_attr, | 526 | struct bin_attribute *bin_attr, |
527 | char *buffer, loff_t pos, size_t count) | 527 | char *buffer, loff_t pos, size_t count) |
528 | { | 528 | { |
@@ -576,7 +576,7 @@ static void callbackfn_rbu(const struct firmware *fw, void *context) | |||
576 | release_firmware(fw); | 576 | release_firmware(fw); |
577 | } | 577 | } |
578 | 578 | ||
579 | static ssize_t read_rbu_image_type(struct kobject *kobj, | 579 | static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj, |
580 | struct bin_attribute *bin_attr, | 580 | struct bin_attribute *bin_attr, |
581 | char *buffer, loff_t pos, size_t count) | 581 | char *buffer, loff_t pos, size_t count) |
582 | { | 582 | { |
@@ -586,7 +586,7 @@ static ssize_t read_rbu_image_type(struct kobject *kobj, | |||
586 | return size; | 586 | return size; |
587 | } | 587 | } |
588 | 588 | ||
589 | static ssize_t write_rbu_image_type(struct kobject *kobj, | 589 | static ssize_t write_rbu_image_type(struct file *filp, struct kobject *kobj, |
590 | struct bin_attribute *bin_attr, | 590 | struct bin_attribute *bin_attr, |
591 | char *buffer, loff_t pos, size_t count) | 591 | char *buffer, loff_t pos, size_t count) |
592 | { | 592 | { |
@@ -647,7 +647,7 @@ static ssize_t write_rbu_image_type(struct kobject *kobj, | |||
647 | return rc; | 647 | return rc; |
648 | } | 648 | } |
649 | 649 | ||
650 | static ssize_t read_rbu_packet_size(struct kobject *kobj, | 650 | static ssize_t read_rbu_packet_size(struct file *filp, struct kobject *kobj, |
651 | struct bin_attribute *bin_attr, | 651 | struct bin_attribute *bin_attr, |
652 | char *buffer, loff_t pos, size_t count) | 652 | char *buffer, loff_t pos, size_t count) |
653 | { | 653 | { |
@@ -660,7 +660,7 @@ static ssize_t read_rbu_packet_size(struct kobject *kobj, | |||
660 | return size; | 660 | return size; |
661 | } | 661 | } |
662 | 662 | ||
663 | static ssize_t write_rbu_packet_size(struct kobject *kobj, | 663 | static ssize_t write_rbu_packet_size(struct file *filp, struct kobject *kobj, |
664 | struct bin_attribute *bin_attr, | 664 | struct bin_attribute *bin_attr, |
665 | char *buffer, loff_t pos, size_t count) | 665 | char *buffer, loff_t pos, size_t count) |
666 | { | 666 | { |
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 81b70bd07586..2a62ec6390e0 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
@@ -402,7 +402,7 @@ efivar_unregister(struct efivar_entry *var) | |||
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | static ssize_t efivar_create(struct kobject *kobj, | 405 | static ssize_t efivar_create(struct file *filp, struct kobject *kobj, |
406 | struct bin_attribute *bin_attr, | 406 | struct bin_attribute *bin_attr, |
407 | char *buf, loff_t pos, size_t count) | 407 | char *buf, loff_t pos, size_t count) |
408 | { | 408 | { |
@@ -461,7 +461,7 @@ static ssize_t efivar_create(struct kobject *kobj, | |||
461 | return count; | 461 | return count; |
462 | } | 462 | } |
463 | 463 | ||
464 | static ssize_t efivar_delete(struct kobject *kobj, | 464 | static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, |
465 | struct bin_attribute *bin_attr, | 465 | struct bin_attribute *bin_attr, |
466 | char *buf, loff_t pos, size_t count) | 466 | char *buf, loff_t pos, size_t count) |
467 | { | 467 | { |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eb0c3fe44b29..cae1b8c5b08c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -399,7 +399,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev, | |||
399 | goto free_id; | 399 | goto free_id; |
400 | } | 400 | } |
401 | 401 | ||
402 | pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, "value"); | 402 | pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, NULL, "value"); |
403 | if (!pdesc->value_sd) { | 403 | if (!pdesc->value_sd) { |
404 | ret = -ENODEV; | 404 | ret = -ENODEV; |
405 | goto free_id; | 405 | goto free_id; |
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 25bbd30ed7af..387166d5a109 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -193,8 +193,9 @@ static ssize_t enabled_show(struct device *device, | |||
193 | "disabled"); | 193 | "disabled"); |
194 | } | 194 | } |
195 | 195 | ||
196 | static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *attr, | 196 | static ssize_t edid_show(struct file *filp, struct kobject *kobj, |
197 | char *buf, loff_t off, size_t count) | 197 | struct bin_attribute *attr, char *buf, loff_t off, |
198 | size_t count) | ||
198 | { | 199 | { |
199 | struct device *connector_dev = container_of(kobj, struct device, kobj); | 200 | struct device *connector_dev = container_of(kobj, struct device, kobj); |
200 | struct drm_connector *connector = to_drm_connector(connector_dev); | 201 | struct drm_connector *connector = to_drm_connector(connector_dev); |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 26ac8aad0b19..f084249295d9 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1678,9 +1678,9 @@ int bitmap_create(mddev_t *mddev) | |||
1678 | 1678 | ||
1679 | bitmap->mddev = mddev; | 1679 | bitmap->mddev = mddev; |
1680 | 1680 | ||
1681 | bm = sysfs_get_dirent(mddev->kobj.sd, "bitmap"); | 1681 | bm = sysfs_get_dirent(mddev->kobj.sd, NULL, "bitmap"); |
1682 | if (bm) { | 1682 | if (bm) { |
1683 | bitmap->sysfs_can_clear = sysfs_get_dirent(bm, "can_clear"); | 1683 | bitmap->sysfs_can_clear = sysfs_get_dirent(bm, NULL, "can_clear"); |
1684 | sysfs_put(bm); | 1684 | sysfs_put(bm); |
1685 | } else | 1685 | } else |
1686 | bitmap->sysfs_can_clear = NULL; | 1686 | bitmap->sysfs_can_clear = NULL; |
diff --git a/drivers/md/md.c b/drivers/md/md.c index cefd63daff31..a9fd491796ac 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1766,7 +1766,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1766 | kobject_del(&rdev->kobj); | 1766 | kobject_del(&rdev->kobj); |
1767 | goto fail; | 1767 | goto fail; |
1768 | } | 1768 | } |
1769 | rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, "state"); | 1769 | rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, NULL, "state"); |
1770 | 1770 | ||
1771 | list_add_rcu(&rdev->same_set, &mddev->disks); | 1771 | list_add_rcu(&rdev->same_set, &mddev->disks); |
1772 | bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); | 1772 | bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); |
@@ -4189,7 +4189,7 @@ static int md_alloc(dev_t dev, char *name) | |||
4189 | mutex_unlock(&disks_mutex); | 4189 | mutex_unlock(&disks_mutex); |
4190 | if (!error) { | 4190 | if (!error) { |
4191 | kobject_uevent(&mddev->kobj, KOBJ_ADD); | 4191 | kobject_uevent(&mddev->kobj, KOBJ_ADD); |
4192 | mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); | 4192 | mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, NULL, "array_state"); |
4193 | } | 4193 | } |
4194 | mddev_put(mddev); | 4194 | mddev_put(mddev); |
4195 | return error; | 4195 | return error; |
@@ -4398,7 +4398,7 @@ static int do_md_run(mddev_t * mddev) | |||
4398 | printk(KERN_WARNING | 4398 | printk(KERN_WARNING |
4399 | "md: cannot register extra attributes for %s\n", | 4399 | "md: cannot register extra attributes for %s\n", |
4400 | mdname(mddev)); | 4400 | mdname(mddev)); |
4401 | mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, "sync_action"); | 4401 | mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, NULL, "sync_action"); |
4402 | } else if (mddev->ro == 2) /* auto-readonly not meaningful */ | 4402 | } else if (mddev->ro == 2) /* auto-readonly not meaningful */ |
4403 | mddev->ro = 0; | 4403 | mddev->ro = 0; |
4404 | 4404 | ||
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index ed090e77c9cd..19fc7c1cb428 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
@@ -707,7 +707,7 @@ static ssize_t __c2port_read_flash_data(struct c2port_device *dev, | |||
707 | return nread; | 707 | return nread; |
708 | } | 708 | } |
709 | 709 | ||
710 | static ssize_t c2port_read_flash_data(struct kobject *kobj, | 710 | static ssize_t c2port_read_flash_data(struct file *filp, struct kobject *kobj, |
711 | struct bin_attribute *attr, | 711 | struct bin_attribute *attr, |
712 | char *buffer, loff_t offset, size_t count) | 712 | char *buffer, loff_t offset, size_t count) |
713 | { | 713 | { |
@@ -824,7 +824,7 @@ static ssize_t __c2port_write_flash_data(struct c2port_device *dev, | |||
824 | return nwrite; | 824 | return nwrite; |
825 | } | 825 | } |
826 | 826 | ||
827 | static ssize_t c2port_write_flash_data(struct kobject *kobj, | 827 | static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj, |
828 | struct bin_attribute *attr, | 828 | struct bin_attribute *attr, |
829 | char *buffer, loff_t offset, size_t count) | 829 | char *buffer, loff_t offset, size_t count) |
830 | { | 830 | { |
diff --git a/drivers/misc/ds1682.c b/drivers/misc/ds1682.c index 9197cfc55015..a513f0aa6432 100644 --- a/drivers/misc/ds1682.c +++ b/drivers/misc/ds1682.c | |||
@@ -140,7 +140,8 @@ static const struct attribute_group ds1682_group = { | |||
140 | /* | 140 | /* |
141 | * User data attribute | 141 | * User data attribute |
142 | */ | 142 | */ |
143 | static ssize_t ds1682_eeprom_read(struct kobject *kobj, struct bin_attribute *attr, | 143 | static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj, |
144 | struct bin_attribute *attr, | ||
144 | char *buf, loff_t off, size_t count) | 145 | char *buf, loff_t off, size_t count) |
145 | { | 146 | { |
146 | struct i2c_client *client = kobj_to_i2c_client(kobj); | 147 | struct i2c_client *client = kobj_to_i2c_client(kobj); |
@@ -163,7 +164,8 @@ static ssize_t ds1682_eeprom_read(struct kobject *kobj, struct bin_attribute *at | |||
163 | return count; | 164 | return count; |
164 | } | 165 | } |
165 | 166 | ||
166 | static ssize_t ds1682_eeprom_write(struct kobject *kobj, struct bin_attribute *attr, | 167 | static ssize_t ds1682_eeprom_write(struct file *filp, struct kobject *kobj, |
168 | struct bin_attribute *attr, | ||
167 | char *buf, loff_t off, size_t count) | 169 | char *buf, loff_t off, size_t count) |
168 | { | 170 | { |
169 | struct i2c_client *client = kobj_to_i2c_client(kobj); | 171 | struct i2c_client *client = kobj_to_i2c_client(kobj); |
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index db7d0f21b65d..a79a62f75481 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c | |||
@@ -274,7 +274,8 @@ static ssize_t at24_read(struct at24_data *at24, | |||
274 | return retval; | 274 | return retval; |
275 | } | 275 | } |
276 | 276 | ||
277 | static ssize_t at24_bin_read(struct kobject *kobj, struct bin_attribute *attr, | 277 | static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj, |
278 | struct bin_attribute *attr, | ||
278 | char *buf, loff_t off, size_t count) | 279 | char *buf, loff_t off, size_t count) |
279 | { | 280 | { |
280 | struct at24_data *at24; | 281 | struct at24_data *at24; |
@@ -395,7 +396,8 @@ static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off, | |||
395 | return retval; | 396 | return retval; |
396 | } | 397 | } |
397 | 398 | ||
398 | static ssize_t at24_bin_write(struct kobject *kobj, struct bin_attribute *attr, | 399 | static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj, |
400 | struct bin_attribute *attr, | ||
399 | char *buf, loff_t off, size_t count) | 401 | char *buf, loff_t off, size_t count) |
400 | { | 402 | { |
401 | struct at24_data *at24; | 403 | struct at24_data *at24; |
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index d194212a41f6..c627e4174ccd 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c | |||
@@ -126,7 +126,8 @@ at25_ee_read( | |||
126 | } | 126 | } |
127 | 127 | ||
128 | static ssize_t | 128 | static ssize_t |
129 | at25_bin_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 129 | at25_bin_read(struct file *filp, struct kobject *kobj, |
130 | struct bin_attribute *bin_attr, | ||
130 | char *buf, loff_t off, size_t count) | 131 | char *buf, loff_t off, size_t count) |
131 | { | 132 | { |
132 | struct device *dev; | 133 | struct device *dev; |
@@ -253,7 +254,8 @@ at25_ee_write(struct at25_data *at25, const char *buf, loff_t off, | |||
253 | } | 254 | } |
254 | 255 | ||
255 | static ssize_t | 256 | static ssize_t |
256 | at25_bin_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 257 | at25_bin_write(struct file *filp, struct kobject *kobj, |
258 | struct bin_attribute *bin_attr, | ||
257 | char *buf, loff_t off, size_t count) | 259 | char *buf, loff_t off, size_t count) |
258 | { | 260 | { |
259 | struct device *dev; | 261 | struct device *dev; |
diff --git a/drivers/misc/eeprom/eeprom.c b/drivers/misc/eeprom/eeprom.c index e306a8cd2f96..45060ddc4e59 100644 --- a/drivers/misc/eeprom/eeprom.c +++ b/drivers/misc/eeprom/eeprom.c | |||
@@ -81,7 +81,8 @@ exit: | |||
81 | mutex_unlock(&data->update_lock); | 81 | mutex_unlock(&data->update_lock); |
82 | } | 82 | } |
83 | 83 | ||
84 | static ssize_t eeprom_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 84 | static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, |
85 | struct bin_attribute *bin_attr, | ||
85 | char *buf, loff_t off, size_t count) | 86 | char *buf, loff_t off, size_t count) |
86 | { | 87 | { |
87 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | 88 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); |
diff --git a/drivers/misc/eeprom/max6875.c b/drivers/misc/eeprom/max6875.c index fe2909278507..5653a3ce0517 100644 --- a/drivers/misc/eeprom/max6875.c +++ b/drivers/misc/eeprom/max6875.c | |||
@@ -107,7 +107,7 @@ exit_up: | |||
107 | mutex_unlock(&data->update_lock); | 107 | mutex_unlock(&data->update_lock); |
108 | } | 108 | } |
109 | 109 | ||
110 | static ssize_t max6875_read(struct kobject *kobj, | 110 | static ssize_t max6875_read(struct file *filp, struct kobject *kobj, |
111 | struct bin_attribute *bin_attr, | 111 | struct bin_attribute *bin_attr, |
112 | char *buf, loff_t off, size_t count) | 112 | char *buf, loff_t off, size_t count) |
113 | { | 113 | { |
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index bc72d6e4919b..13343e884999 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/radix-tree.h> | 41 | #include <linux/radix-tree.h> |
42 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
43 | #include <linux/semaphore.h> | ||
43 | #include <linux/workqueue.h> | 44 | #include <linux/workqueue.h> |
44 | 45 | ||
45 | #include <linux/mlx4/device.h> | 46 | #include <linux/mlx4/device.h> |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index c61a61f177b7..6ce6ce1df6d2 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -2560,7 +2560,8 @@ netxen_sysfs_validate_crb(struct netxen_adapter *adapter, | |||
2560 | } | 2560 | } |
2561 | 2561 | ||
2562 | static ssize_t | 2562 | static ssize_t |
2563 | netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | 2563 | netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, |
2564 | struct bin_attribute *attr, | ||
2564 | char *buf, loff_t offset, size_t size) | 2565 | char *buf, loff_t offset, size_t size) |
2565 | { | 2566 | { |
2566 | struct device *dev = container_of(kobj, struct device, kobj); | 2567 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2587,7 +2588,8 @@ netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
2587 | } | 2588 | } |
2588 | 2589 | ||
2589 | static ssize_t | 2590 | static ssize_t |
2590 | netxen_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, | 2591 | netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj, |
2592 | struct bin_attribute *attr, | ||
2591 | char *buf, loff_t offset, size_t size) | 2593 | char *buf, loff_t offset, size_t size) |
2592 | { | 2594 | { |
2593 | struct device *dev = container_of(kobj, struct device, kobj); | 2595 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2627,7 +2629,8 @@ netxen_sysfs_validate_mem(struct netxen_adapter *adapter, | |||
2627 | } | 2629 | } |
2628 | 2630 | ||
2629 | static ssize_t | 2631 | static ssize_t |
2630 | netxen_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | 2632 | netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, |
2633 | struct bin_attribute *attr, | ||
2631 | char *buf, loff_t offset, size_t size) | 2634 | char *buf, loff_t offset, size_t size) |
2632 | { | 2635 | { |
2633 | struct device *dev = container_of(kobj, struct device, kobj); | 2636 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2647,7 +2650,7 @@ netxen_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
2647 | return size; | 2650 | return size; |
2648 | } | 2651 | } |
2649 | 2652 | ||
2650 | static ssize_t netxen_sysfs_write_mem(struct kobject *kobj, | 2653 | static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, |
2651 | struct bin_attribute *attr, char *buf, | 2654 | struct bin_attribute *attr, char *buf, |
2652 | loff_t offset, size_t size) | 2655 | loff_t offset, size_t size) |
2653 | { | 2656 | { |
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 1003eb76fda3..23ea9caa5261 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -2464,7 +2464,8 @@ qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, | |||
2464 | } | 2464 | } |
2465 | 2465 | ||
2466 | static ssize_t | 2466 | static ssize_t |
2467 | qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | 2467 | qlcnic_sysfs_read_crb(struct file *filp, struct kobject *kobj, |
2468 | struct bin_attribute *attr, | ||
2468 | char *buf, loff_t offset, size_t size) | 2469 | char *buf, loff_t offset, size_t size) |
2469 | { | 2470 | { |
2470 | struct device *dev = container_of(kobj, struct device, kobj); | 2471 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2488,7 +2489,8 @@ qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
2488 | } | 2489 | } |
2489 | 2490 | ||
2490 | static ssize_t | 2491 | static ssize_t |
2491 | qlcnic_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, | 2492 | qlcnic_sysfs_write_crb(struct file *filp, struct kobject *kobj, |
2493 | struct bin_attribute *attr, | ||
2492 | char *buf, loff_t offset, size_t size) | 2494 | char *buf, loff_t offset, size_t size) |
2493 | { | 2495 | { |
2494 | struct device *dev = container_of(kobj, struct device, kobj); | 2496 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2525,7 +2527,8 @@ qlcnic_sysfs_validate_mem(struct qlcnic_adapter *adapter, | |||
2525 | } | 2527 | } |
2526 | 2528 | ||
2527 | static ssize_t | 2529 | static ssize_t |
2528 | qlcnic_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | 2530 | qlcnic_sysfs_read_mem(struct file *filp, struct kobject *kobj, |
2531 | struct bin_attribute *attr, | ||
2529 | char *buf, loff_t offset, size_t size) | 2532 | char *buf, loff_t offset, size_t size) |
2530 | { | 2533 | { |
2531 | struct device *dev = container_of(kobj, struct device, kobj); | 2534 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -2546,7 +2549,8 @@ qlcnic_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
2546 | } | 2549 | } |
2547 | 2550 | ||
2548 | static ssize_t | 2551 | static ssize_t |
2549 | qlcnic_sysfs_write_mem(struct kobject *kobj, struct bin_attribute *attr, | 2552 | qlcnic_sysfs_write_mem(struct file *filp, struct kobject *kobj, |
2553 | struct bin_attribute *attr, | ||
2550 | char *buf, loff_t offset, size_t size) | 2554 | char *buf, loff_t offset, size_t size) |
2551 | { | 2555 | { |
2552 | struct device *dev = container_of(kobj, struct device, kobj); | 2556 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 6ecbfb27db9d..e525263210ee 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -108,7 +108,7 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status); | |||
108 | static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status); | 108 | static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status); |
109 | static void ibm_handle_events(acpi_handle handle, u32 event, void *context); | 109 | static void ibm_handle_events(acpi_handle handle, u32 event, void *context); |
110 | static int ibm_get_table_from_acpi(char **bufp); | 110 | static int ibm_get_table_from_acpi(char **bufp); |
111 | static ssize_t ibm_read_apci_table(struct kobject *kobj, | 111 | static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj, |
112 | struct bin_attribute *bin_attr, | 112 | struct bin_attribute *bin_attr, |
113 | char *buffer, loff_t pos, size_t size); | 113 | char *buffer, loff_t pos, size_t size); |
114 | static acpi_status __init ibm_find_acpi_device(acpi_handle handle, | 114 | static acpi_status __init ibm_find_acpi_device(acpi_handle handle, |
@@ -351,6 +351,7 @@ read_table_done: | |||
351 | 351 | ||
352 | /** | 352 | /** |
353 | * ibm_read_apci_table - callback for the sysfs apci_table file | 353 | * ibm_read_apci_table - callback for the sysfs apci_table file |
354 | * @filp: the open sysfs file | ||
354 | * @kobj: the kobject this binary attribute is a part of | 355 | * @kobj: the kobject this binary attribute is a part of |
355 | * @bin_attr: struct bin_attribute for this file | 356 | * @bin_attr: struct bin_attribute for this file |
356 | * @buffer: the kernel space buffer to fill | 357 | * @buffer: the kernel space buffer to fill |
@@ -364,7 +365,7 @@ read_table_done: | |||
364 | * things get really tricky here... | 365 | * things get really tricky here... |
365 | * our solution is to only allow reading the table in all at once. | 366 | * our solution is to only allow reading the table in all at once. |
366 | */ | 367 | */ |
367 | static ssize_t ibm_read_apci_table(struct kobject *kobj, | 368 | static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj, |
368 | struct bin_attribute *bin_attr, | 369 | struct bin_attribute *bin_attr, |
369 | char *buffer, loff_t pos, size_t size) | 370 | char *buffer, loff_t pos, size_t size) |
370 | { | 371 | { |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index fad93983bfed..6309c5a2528f 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/stat.h> | 21 | #include <linux/stat.h> |
22 | #include <linux/topology.h> | 22 | #include <linux/topology.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/fs.h> | ||
24 | #include <linux/capability.h> | 25 | #include <linux/capability.h> |
25 | #include <linux/pci-aspm.h> | 26 | #include <linux/pci-aspm.h> |
26 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
@@ -357,7 +358,8 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
357 | struct device_attribute vga_attr = __ATTR_RO(boot_vga); | 358 | struct device_attribute vga_attr = __ATTR_RO(boot_vga); |
358 | 359 | ||
359 | static ssize_t | 360 | static ssize_t |
360 | pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 361 | pci_read_config(struct file *filp, struct kobject *kobj, |
362 | struct bin_attribute *bin_attr, | ||
361 | char *buf, loff_t off, size_t count) | 363 | char *buf, loff_t off, size_t count) |
362 | { | 364 | { |
363 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); | 365 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
@@ -366,7 +368,7 @@ pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
366 | u8 *data = (u8*) buf; | 368 | u8 *data = (u8*) buf; |
367 | 369 | ||
368 | /* Several chips lock up trying to read undefined config space */ | 370 | /* Several chips lock up trying to read undefined config space */ |
369 | if (capable(CAP_SYS_ADMIN)) { | 371 | if (cap_raised(filp->f_cred->cap_effective, CAP_SYS_ADMIN)) { |
370 | size = dev->cfg_size; | 372 | size = dev->cfg_size; |
371 | } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | 373 | } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { |
372 | size = 128; | 374 | size = 128; |
@@ -430,7 +432,8 @@ pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
430 | } | 432 | } |
431 | 433 | ||
432 | static ssize_t | 434 | static ssize_t |
433 | pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 435 | pci_write_config(struct file* filp, struct kobject *kobj, |
436 | struct bin_attribute *bin_attr, | ||
434 | char *buf, loff_t off, size_t count) | 437 | char *buf, loff_t off, size_t count) |
435 | { | 438 | { |
436 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); | 439 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
@@ -487,7 +490,8 @@ pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
487 | } | 490 | } |
488 | 491 | ||
489 | static ssize_t | 492 | static ssize_t |
490 | read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | 493 | read_vpd_attr(struct file *filp, struct kobject *kobj, |
494 | struct bin_attribute *bin_attr, | ||
491 | char *buf, loff_t off, size_t count) | 495 | char *buf, loff_t off, size_t count) |
492 | { | 496 | { |
493 | struct pci_dev *dev = | 497 | struct pci_dev *dev = |
@@ -502,7 +506,8 @@ read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
502 | } | 506 | } |
503 | 507 | ||
504 | static ssize_t | 508 | static ssize_t |
505 | write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | 509 | write_vpd_attr(struct file *filp, struct kobject *kobj, |
510 | struct bin_attribute *bin_attr, | ||
506 | char *buf, loff_t off, size_t count) | 511 | char *buf, loff_t off, size_t count) |
507 | { | 512 | { |
508 | struct pci_dev *dev = | 513 | struct pci_dev *dev = |
@@ -519,6 +524,7 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
519 | #ifdef HAVE_PCI_LEGACY | 524 | #ifdef HAVE_PCI_LEGACY |
520 | /** | 525 | /** |
521 | * pci_read_legacy_io - read byte(s) from legacy I/O port space | 526 | * pci_read_legacy_io - read byte(s) from legacy I/O port space |
527 | * @filp: open sysfs file | ||
522 | * @kobj: kobject corresponding to file to read from | 528 | * @kobj: kobject corresponding to file to read from |
523 | * @bin_attr: struct bin_attribute for this file | 529 | * @bin_attr: struct bin_attribute for this file |
524 | * @buf: buffer to store results | 530 | * @buf: buffer to store results |
@@ -529,7 +535,8 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
529 | * callback routine (pci_legacy_read). | 535 | * callback routine (pci_legacy_read). |
530 | */ | 536 | */ |
531 | static ssize_t | 537 | static ssize_t |
532 | pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 538 | pci_read_legacy_io(struct file *filp, struct kobject *kobj, |
539 | struct bin_attribute *bin_attr, | ||
533 | char *buf, loff_t off, size_t count) | 540 | char *buf, loff_t off, size_t count) |
534 | { | 541 | { |
535 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 542 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -545,6 +552,7 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
545 | 552 | ||
546 | /** | 553 | /** |
547 | * pci_write_legacy_io - write byte(s) to legacy I/O port space | 554 | * pci_write_legacy_io - write byte(s) to legacy I/O port space |
555 | * @filp: open sysfs file | ||
548 | * @kobj: kobject corresponding to file to read from | 556 | * @kobj: kobject corresponding to file to read from |
549 | * @bin_attr: struct bin_attribute for this file | 557 | * @bin_attr: struct bin_attribute for this file |
550 | * @buf: buffer containing value to be written | 558 | * @buf: buffer containing value to be written |
@@ -555,7 +563,8 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
555 | * callback routine (pci_legacy_write). | 563 | * callback routine (pci_legacy_write). |
556 | */ | 564 | */ |
557 | static ssize_t | 565 | static ssize_t |
558 | pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 566 | pci_write_legacy_io(struct file *filp, struct kobject *kobj, |
567 | struct bin_attribute *bin_attr, | ||
559 | char *buf, loff_t off, size_t count) | 568 | char *buf, loff_t off, size_t count) |
560 | { | 569 | { |
561 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 570 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -570,6 +579,7 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
570 | 579 | ||
571 | /** | 580 | /** |
572 | * pci_mmap_legacy_mem - map legacy PCI memory into user memory space | 581 | * pci_mmap_legacy_mem - map legacy PCI memory into user memory space |
582 | * @filp: open sysfs file | ||
573 | * @kobj: kobject corresponding to device to be mapped | 583 | * @kobj: kobject corresponding to device to be mapped |
574 | * @attr: struct bin_attribute for this file | 584 | * @attr: struct bin_attribute for this file |
575 | * @vma: struct vm_area_struct passed to mmap | 585 | * @vma: struct vm_area_struct passed to mmap |
@@ -579,7 +589,8 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
579 | * memory space. | 589 | * memory space. |
580 | */ | 590 | */ |
581 | static int | 591 | static int |
582 | pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | 592 | pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, |
593 | struct bin_attribute *attr, | ||
583 | struct vm_area_struct *vma) | 594 | struct vm_area_struct *vma) |
584 | { | 595 | { |
585 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 596 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -591,6 +602,7 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
591 | 602 | ||
592 | /** | 603 | /** |
593 | * pci_mmap_legacy_io - map legacy PCI IO into user memory space | 604 | * pci_mmap_legacy_io - map legacy PCI IO into user memory space |
605 | * @filp: open sysfs file | ||
594 | * @kobj: kobject corresponding to device to be mapped | 606 | * @kobj: kobject corresponding to device to be mapped |
595 | * @attr: struct bin_attribute for this file | 607 | * @attr: struct bin_attribute for this file |
596 | * @vma: struct vm_area_struct passed to mmap | 608 | * @vma: struct vm_area_struct passed to mmap |
@@ -600,7 +612,8 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
600 | * memory space. Returns -ENOSYS if the operation isn't supported | 612 | * memory space. Returns -ENOSYS if the operation isn't supported |
601 | */ | 613 | */ |
602 | static int | 614 | static int |
603 | pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, | 615 | pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, |
616 | struct bin_attribute *attr, | ||
604 | struct vm_area_struct *vma) | 617 | struct vm_area_struct *vma) |
605 | { | 618 | { |
606 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 619 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -750,14 +763,16 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
750 | } | 763 | } |
751 | 764 | ||
752 | static int | 765 | static int |
753 | pci_mmap_resource_uc(struct kobject *kobj, struct bin_attribute *attr, | 766 | pci_mmap_resource_uc(struct file *filp, struct kobject *kobj, |
767 | struct bin_attribute *attr, | ||
754 | struct vm_area_struct *vma) | 768 | struct vm_area_struct *vma) |
755 | { | 769 | { |
756 | return pci_mmap_resource(kobj, attr, vma, 0); | 770 | return pci_mmap_resource(kobj, attr, vma, 0); |
757 | } | 771 | } |
758 | 772 | ||
759 | static int | 773 | static int |
760 | pci_mmap_resource_wc(struct kobject *kobj, struct bin_attribute *attr, | 774 | pci_mmap_resource_wc(struct file *filp, struct kobject *kobj, |
775 | struct bin_attribute *attr, | ||
761 | struct vm_area_struct *vma) | 776 | struct vm_area_struct *vma) |
762 | { | 777 | { |
763 | return pci_mmap_resource(kobj, attr, vma, 1); | 778 | return pci_mmap_resource(kobj, attr, vma, 1); |
@@ -861,6 +876,7 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; } | |||
861 | 876 | ||
862 | /** | 877 | /** |
863 | * pci_write_rom - used to enable access to the PCI ROM display | 878 | * pci_write_rom - used to enable access to the PCI ROM display |
879 | * @filp: sysfs file | ||
864 | * @kobj: kernel object handle | 880 | * @kobj: kernel object handle |
865 | * @bin_attr: struct bin_attribute for this file | 881 | * @bin_attr: struct bin_attribute for this file |
866 | * @buf: user input | 882 | * @buf: user input |
@@ -870,7 +886,8 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; } | |||
870 | * writing anything except 0 enables it | 886 | * writing anything except 0 enables it |
871 | */ | 887 | */ |
872 | static ssize_t | 888 | static ssize_t |
873 | pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | 889 | pci_write_rom(struct file *filp, struct kobject *kobj, |
890 | struct bin_attribute *bin_attr, | ||
874 | char *buf, loff_t off, size_t count) | 891 | char *buf, loff_t off, size_t count) |
875 | { | 892 | { |
876 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 893 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |
@@ -885,6 +902,7 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
885 | 902 | ||
886 | /** | 903 | /** |
887 | * pci_read_rom - read a PCI ROM | 904 | * pci_read_rom - read a PCI ROM |
905 | * @filp: sysfs file | ||
888 | * @kobj: kernel object handle | 906 | * @kobj: kernel object handle |
889 | * @bin_attr: struct bin_attribute for this file | 907 | * @bin_attr: struct bin_attribute for this file |
890 | * @buf: where to put the data we read from the ROM | 908 | * @buf: where to put the data we read from the ROM |
@@ -895,7 +913,8 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
895 | * device corresponding to @kobj. | 913 | * device corresponding to @kobj. |
896 | */ | 914 | */ |
897 | static ssize_t | 915 | static ssize_t |
898 | pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | 916 | pci_read_rom(struct file *filp, struct kobject *kobj, |
917 | struct bin_attribute *bin_attr, | ||
899 | char *buf, loff_t off, size_t count) | 918 | char *buf, loff_t off, size_t count) |
900 | { | 919 | { |
901 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 920 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 60d428be0b07..8844bc3e3118 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -1531,7 +1531,7 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, | |||
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | 1533 | ||
1534 | static ssize_t pccard_show_cis(struct kobject *kobj, | 1534 | static ssize_t pccard_show_cis(struct file *filp, struct kobject *kobj, |
1535 | struct bin_attribute *bin_attr, | 1535 | struct bin_attribute *bin_attr, |
1536 | char *buf, loff_t off, size_t count) | 1536 | char *buf, loff_t off, size_t count) |
1537 | { | 1537 | { |
@@ -1562,7 +1562,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj, | |||
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | 1564 | ||
1565 | static ssize_t pccard_store_cis(struct kobject *kobj, | 1565 | static ssize_t pccard_store_cis(struct file *filp, struct kobject *kobj, |
1566 | struct bin_attribute *bin_attr, | 1566 | struct bin_attribute *bin_attr, |
1567 | char *buf, loff_t off, size_t count) | 1567 | char *buf, loff_t off, size_t count) |
1568 | { | 1568 | { |
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 8fefe5a73558..baefcf1cffc9 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -354,7 +354,7 @@ static enum power_supply_property olpc_bat_props[] = { | |||
354 | #define EEPROM_END 0x80 | 354 | #define EEPROM_END 0x80 |
355 | #define EEPROM_SIZE (EEPROM_END - EEPROM_START) | 355 | #define EEPROM_SIZE (EEPROM_END - EEPROM_START) |
356 | 356 | ||
357 | static ssize_t olpc_bat_eeprom_read(struct kobject *kobj, | 357 | static ssize_t olpc_bat_eeprom_read(struct file *filp, struct kobject *kobj, |
358 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) | 358 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) |
359 | { | 359 | { |
360 | uint8_t ec_byte; | 360 | uint8_t ec_byte; |
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c index ba742e82c57d..00b475658356 100644 --- a/drivers/rapidio/rio-sysfs.c +++ b/drivers/rapidio/rio-sysfs.c | |||
@@ -68,7 +68,8 @@ struct device_attribute rio_dev_attrs[] = { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | static ssize_t | 70 | static ssize_t |
71 | rio_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 71 | rio_read_config(struct file *filp, struct kobject *kobj, |
72 | struct bin_attribute *bin_attr, | ||
72 | char *buf, loff_t off, size_t count) | 73 | char *buf, loff_t off, size_t count) |
73 | { | 74 | { |
74 | struct rio_dev *dev = | 75 | struct rio_dev *dev = |
@@ -139,7 +140,8 @@ rio_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
139 | } | 140 | } |
140 | 141 | ||
141 | static ssize_t | 142 | static ssize_t |
142 | rio_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 143 | rio_write_config(struct file *filp, struct kobject *kobj, |
144 | struct bin_attribute *bin_attr, | ||
143 | char *buf, loff_t off, size_t count) | 145 | char *buf, loff_t off, size_t count) |
144 | { | 146 | { |
145 | struct rio_dev *dev = | 147 | struct rio_dev *dev = |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index e9aa814ddd23..ece4dbddc0ea 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -519,7 +519,8 @@ static const struct rtc_class_ops cmos_rtc_ops = { | |||
519 | #define NVRAM_OFFSET (RTC_REG_D + 1) | 519 | #define NVRAM_OFFSET (RTC_REG_D + 1) |
520 | 520 | ||
521 | static ssize_t | 521 | static ssize_t |
522 | cmos_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | 522 | cmos_nvram_read(struct file *filp, struct kobject *kobj, |
523 | struct bin_attribute *attr, | ||
523 | char *buf, loff_t off, size_t count) | 524 | char *buf, loff_t off, size_t count) |
524 | { | 525 | { |
525 | int retval; | 526 | int retval; |
@@ -547,7 +548,8 @@ cmos_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
547 | } | 548 | } |
548 | 549 | ||
549 | static ssize_t | 550 | static ssize_t |
550 | cmos_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | 551 | cmos_nvram_write(struct file *filp, struct kobject *kobj, |
552 | struct bin_attribute *attr, | ||
551 | char *buf, loff_t off, size_t count) | 553 | char *buf, loff_t off, size_t count) |
552 | { | 554 | { |
553 | struct cmos_rtc *cmos; | 555 | struct cmos_rtc *cmos; |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 7836c9cec557..48da85e97ca4 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -542,7 +542,8 @@ static void msg_init(struct spi_message *m, struct spi_transfer *x, | |||
542 | } | 542 | } |
543 | 543 | ||
544 | static ssize_t | 544 | static ssize_t |
545 | ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | 545 | ds1305_nvram_read(struct file *filp, struct kobject *kobj, |
546 | struct bin_attribute *attr, | ||
546 | char *buf, loff_t off, size_t count) | 547 | char *buf, loff_t off, size_t count) |
547 | { | 548 | { |
548 | struct spi_device *spi; | 549 | struct spi_device *spi; |
@@ -572,7 +573,8 @@ ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
572 | } | 573 | } |
573 | 574 | ||
574 | static ssize_t | 575 | static ssize_t |
575 | ds1305_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | 576 | ds1305_nvram_write(struct file *filp, struct kobject *kobj, |
577 | struct bin_attribute *attr, | ||
576 | char *buf, loff_t off, size_t count) | 578 | char *buf, loff_t off, size_t count) |
577 | { | 579 | { |
578 | struct spi_device *spi; | 580 | struct spi_device *spi; |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index c4ec5c158aa1..de033b7ac21f 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -556,7 +556,8 @@ static const struct rtc_class_ops ds13xx_rtc_ops = { | |||
556 | #define NVRAM_SIZE 56 | 556 | #define NVRAM_SIZE 56 |
557 | 557 | ||
558 | static ssize_t | 558 | static ssize_t |
559 | ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | 559 | ds1307_nvram_read(struct file *filp, struct kobject *kobj, |
560 | struct bin_attribute *attr, | ||
560 | char *buf, loff_t off, size_t count) | 561 | char *buf, loff_t off, size_t count) |
561 | { | 562 | { |
562 | struct i2c_client *client; | 563 | struct i2c_client *client; |
@@ -580,7 +581,8 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
580 | } | 581 | } |
581 | 582 | ||
582 | static ssize_t | 583 | static ssize_t |
583 | ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | 584 | ds1307_nvram_write(struct file *filp, struct kobject *kobj, |
585 | struct bin_attribute *attr, | ||
584 | char *buf, loff_t off, size_t count) | 586 | char *buf, loff_t off, size_t count) |
585 | { | 587 | { |
586 | struct i2c_client *client; | 588 | struct i2c_client *client; |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 06b8566c4532..37268e97de49 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -423,8 +423,9 @@ static const struct rtc_class_ops ds1511_rtc_ops = { | |||
423 | }; | 423 | }; |
424 | 424 | ||
425 | static ssize_t | 425 | static ssize_t |
426 | ds1511_nvram_read(struct kobject *kobj, struct bin_attribute *ba, | 426 | ds1511_nvram_read(struct file *filp, struct kobject *kobj, |
427 | char *buf, loff_t pos, size_t size) | 427 | struct bin_attribute *ba, |
428 | char *buf, loff_t pos, size_t size) | ||
428 | { | 429 | { |
429 | ssize_t count; | 430 | ssize_t count; |
430 | 431 | ||
@@ -452,8 +453,9 @@ ds1511_nvram_read(struct kobject *kobj, struct bin_attribute *ba, | |||
452 | } | 453 | } |
453 | 454 | ||
454 | static ssize_t | 455 | static ssize_t |
455 | ds1511_nvram_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 456 | ds1511_nvram_write(struct file *filp, struct kobject *kobj, |
456 | char *buf, loff_t pos, size_t size) | 457 | struct bin_attribute *bin_attr, |
458 | char *buf, loff_t pos, size_t size) | ||
457 | { | 459 | { |
458 | ssize_t count; | 460 | ssize_t count; |
459 | 461 | ||
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 244f9994bcbb..ff432e2ca275 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -252,7 +252,7 @@ static const struct rtc_class_ops ds1553_rtc_ops = { | |||
252 | .update_irq_enable = ds1553_rtc_update_irq_enable, | 252 | .update_irq_enable = ds1553_rtc_update_irq_enable, |
253 | }; | 253 | }; |
254 | 254 | ||
255 | static ssize_t ds1553_nvram_read(struct kobject *kobj, | 255 | static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, |
256 | struct bin_attribute *bin_attr, | 256 | struct bin_attribute *bin_attr, |
257 | char *buf, loff_t pos, size_t size) | 257 | char *buf, loff_t pos, size_t size) |
258 | { | 258 | { |
@@ -267,7 +267,7 @@ static ssize_t ds1553_nvram_read(struct kobject *kobj, | |||
267 | return count; | 267 | return count; |
268 | } | 268 | } |
269 | 269 | ||
270 | static ssize_t ds1553_nvram_write(struct kobject *kobj, | 270 | static ssize_t ds1553_nvram_write(struct file *filp, struct kobject *kobj, |
271 | struct bin_attribute *bin_attr, | 271 | struct bin_attribute *bin_attr, |
272 | char *buf, loff_t pos, size_t size) | 272 | char *buf, loff_t pos, size_t size) |
273 | { | 273 | { |
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index 2b4b0bc42d6f..042630c90dd3 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -128,7 +128,7 @@ static const struct rtc_class_ops ds1742_rtc_ops = { | |||
128 | .set_time = ds1742_rtc_set_time, | 128 | .set_time = ds1742_rtc_set_time, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static ssize_t ds1742_nvram_read(struct kobject *kobj, | 131 | static ssize_t ds1742_nvram_read(struct file *filp, struct kobject *kobj, |
132 | struct bin_attribute *bin_attr, | 132 | struct bin_attribute *bin_attr, |
133 | char *buf, loff_t pos, size_t size) | 133 | char *buf, loff_t pos, size_t size) |
134 | { | 134 | { |
@@ -143,7 +143,7 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj, | |||
143 | return count; | 143 | return count; |
144 | } | 144 | } |
145 | 145 | ||
146 | static ssize_t ds1742_nvram_write(struct kobject *kobj, | 146 | static ssize_t ds1742_nvram_write(struct file *filp, struct kobject *kobj, |
147 | struct bin_attribute *bin_attr, | 147 | struct bin_attribute *bin_attr, |
148 | char *buf, loff_t pos, size_t size) | 148 | char *buf, loff_t pos, size_t size) |
149 | { | 149 | { |
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index 365ff3ac2348..be8359fdb65a 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c | |||
@@ -343,7 +343,7 @@ static const struct rtc_class_ops m48t02_rtc_ops = { | |||
343 | .set_time = m48t59_rtc_set_time, | 343 | .set_time = m48t59_rtc_set_time, |
344 | }; | 344 | }; |
345 | 345 | ||
346 | static ssize_t m48t59_nvram_read(struct kobject *kobj, | 346 | static ssize_t m48t59_nvram_read(struct file *filp, struct kobject *kobj, |
347 | struct bin_attribute *bin_attr, | 347 | struct bin_attribute *bin_attr, |
348 | char *buf, loff_t pos, size_t size) | 348 | char *buf, loff_t pos, size_t size) |
349 | { | 349 | { |
@@ -363,7 +363,7 @@ static ssize_t m48t59_nvram_read(struct kobject *kobj, | |||
363 | return cnt; | 363 | return cnt; |
364 | } | 364 | } |
365 | 365 | ||
366 | static ssize_t m48t59_nvram_write(struct kobject *kobj, | 366 | static ssize_t m48t59_nvram_write(struct file *filp, struct kobject *kobj, |
367 | struct bin_attribute *bin_attr, | 367 | struct bin_attribute *bin_attr, |
368 | char *buf, loff_t pos, size_t size) | 368 | char *buf, loff_t pos, size_t size) |
369 | { | 369 | { |
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index b53a00198dbe..3b943673cd3e 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -244,7 +244,7 @@ static const struct rtc_class_ops stk17ta8_rtc_ops = { | |||
244 | .alarm_irq_enable = stk17ta8_rtc_alarm_irq_enable, | 244 | .alarm_irq_enable = stk17ta8_rtc_alarm_irq_enable, |
245 | }; | 245 | }; |
246 | 246 | ||
247 | static ssize_t stk17ta8_nvram_read(struct kobject *kobj, | 247 | static ssize_t stk17ta8_nvram_read(struct file *filp, struct kobject *kobj, |
248 | struct bin_attribute *attr, char *buf, | 248 | struct bin_attribute *attr, char *buf, |
249 | loff_t pos, size_t size) | 249 | loff_t pos, size_t size) |
250 | { | 250 | { |
@@ -259,7 +259,7 @@ static ssize_t stk17ta8_nvram_read(struct kobject *kobj, | |||
259 | return count; | 259 | return count; |
260 | } | 260 | } |
261 | 261 | ||
262 | static ssize_t stk17ta8_nvram_write(struct kobject *kobj, | 262 | static ssize_t stk17ta8_nvram_write(struct file *filp, struct kobject *kobj, |
263 | struct bin_attribute *attr, char *buf, | 263 | struct bin_attribute *attr, char *buf, |
264 | loff_t pos, size_t size) | 264 | loff_t pos, size_t size) |
265 | { | 265 | { |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index 20bfc64a15c8..ec6313d15359 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -188,7 +188,7 @@ static const struct rtc_class_ops tx4939_rtc_ops = { | |||
188 | .alarm_irq_enable = tx4939_rtc_alarm_irq_enable, | 188 | .alarm_irq_enable = tx4939_rtc_alarm_irq_enable, |
189 | }; | 189 | }; |
190 | 190 | ||
191 | static ssize_t tx4939_rtc_nvram_read(struct kobject *kobj, | 191 | static ssize_t tx4939_rtc_nvram_read(struct file *filp, struct kobject *kobj, |
192 | struct bin_attribute *bin_attr, | 192 | struct bin_attribute *bin_attr, |
193 | char *buf, loff_t pos, size_t size) | 193 | char *buf, loff_t pos, size_t size) |
194 | { | 194 | { |
@@ -207,7 +207,7 @@ static ssize_t tx4939_rtc_nvram_read(struct kobject *kobj, | |||
207 | return count; | 207 | return count; |
208 | } | 208 | } |
209 | 209 | ||
210 | static ssize_t tx4939_rtc_nvram_write(struct kobject *kobj, | 210 | static ssize_t tx4939_rtc_nvram_write(struct file *filp, struct kobject *kobj, |
211 | struct bin_attribute *bin_attr, | 211 | struct bin_attribute *bin_attr, |
212 | char *buf, loff_t pos, size_t size) | 212 | char *buf, loff_t pos, size_t size) |
213 | { | 213 | { |
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c index 1d16189f2f2d..6c9fa15aac7b 100644 --- a/drivers/s390/cio/chp.c +++ b/drivers/s390/cio/chp.c | |||
@@ -135,7 +135,8 @@ static int s390_vary_chpid(struct chp_id chpid, int on) | |||
135 | /* | 135 | /* |
136 | * Channel measurement related functions | 136 | * Channel measurement related functions |
137 | */ | 137 | */ |
138 | static ssize_t chp_measurement_chars_read(struct kobject *kobj, | 138 | static ssize_t chp_measurement_chars_read(struct file *filp, |
139 | struct kobject *kobj, | ||
139 | struct bin_attribute *bin_attr, | 140 | struct bin_attribute *bin_attr, |
140 | char *buf, loff_t off, size_t count) | 141 | char *buf, loff_t off, size_t count) |
141 | { | 142 | { |
@@ -182,7 +183,7 @@ static void chp_measurement_copy_block(struct cmg_entry *buf, | |||
182 | } while (reference_buf.values[0] != buf->values[0]); | 183 | } while (reference_buf.values[0] != buf->values[0]); |
183 | } | 184 | } |
184 | 185 | ||
185 | static ssize_t chp_measurement_read(struct kobject *kobj, | 186 | static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj, |
186 | struct bin_attribute *bin_attr, | 187 | struct bin_attribute *bin_attr, |
187 | char *buf, loff_t off, size_t count) | 188 | char *buf, loff_t off, size_t count) |
188 | { | 189 | { |
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index 54c5ffb1eaa1..d38000db9237 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c | |||
@@ -98,7 +98,7 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res | |||
98 | /* Functions */ | 98 | /* Functions */ |
99 | 99 | ||
100 | /* This function returns AENs through sysfs */ | 100 | /* This function returns AENs through sysfs */ |
101 | static ssize_t twl_sysfs_aen_read(struct kobject *kobj, | 101 | static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj, |
102 | struct bin_attribute *bin_attr, | 102 | struct bin_attribute *bin_attr, |
103 | char *outbuf, loff_t offset, size_t count) | 103 | char *outbuf, loff_t offset, size_t count) |
104 | { | 104 | { |
@@ -129,7 +129,7 @@ static struct bin_attribute twl_sysfs_aen_read_attr = { | |||
129 | }; | 129 | }; |
130 | 130 | ||
131 | /* This function returns driver compatibility info through sysfs */ | 131 | /* This function returns driver compatibility info through sysfs */ |
132 | static ssize_t twl_sysfs_compat_info(struct kobject *kobj, | 132 | static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj, |
133 | struct bin_attribute *bin_attr, | 133 | struct bin_attribute *bin_attr, |
134 | char *outbuf, loff_t offset, size_t count) | 134 | char *outbuf, loff_t offset, size_t count) |
135 | { | 135 | { |
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index 5877f29a6005..a4e04c50c436 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c | |||
@@ -59,7 +59,8 @@ | |||
59 | 59 | ||
60 | struct device_attribute *arcmsr_host_attrs[]; | 60 | struct device_attribute *arcmsr_host_attrs[]; |
61 | 61 | ||
62 | static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, | 62 | static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp, |
63 | struct kobject *kobj, | ||
63 | struct bin_attribute *bin, | 64 | struct bin_attribute *bin, |
64 | char *buf, loff_t off, | 65 | char *buf, loff_t off, |
65 | size_t count) | 66 | size_t count) |
@@ -105,7 +106,8 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, | |||
105 | return (allxfer_len); | 106 | return (allxfer_len); |
106 | } | 107 | } |
107 | 108 | ||
108 | static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj, | 109 | static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp, |
110 | struct kobject *kobj, | ||
109 | struct bin_attribute *bin, | 111 | struct bin_attribute *bin, |
110 | char *buf, loff_t off, | 112 | char *buf, loff_t off, |
111 | size_t count) | 113 | size_t count) |
@@ -153,7 +155,8 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj, | |||
153 | } | 155 | } |
154 | } | 156 | } |
155 | 157 | ||
156 | static ssize_t arcmsr_sysfs_iop_message_clear(struct kobject *kobj, | 158 | static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp, |
159 | struct kobject *kobj, | ||
157 | struct bin_attribute *bin, | 160 | struct bin_attribute *bin, |
158 | char *buf, loff_t off, | 161 | char *buf, loff_t off, |
159 | size_t count) | 162 | size_t count) |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index d18f45c95639..3eb2b7b3d8b0 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c | |||
@@ -2919,6 +2919,7 @@ static DEVICE_ATTR(log_level, S_IRUGO | S_IWUSR, | |||
2919 | #ifdef CONFIG_SCSI_IBMVFC_TRACE | 2919 | #ifdef CONFIG_SCSI_IBMVFC_TRACE |
2920 | /** | 2920 | /** |
2921 | * ibmvfc_read_trace - Dump the adapter trace | 2921 | * ibmvfc_read_trace - Dump the adapter trace |
2922 | * @filp: open sysfs file | ||
2922 | * @kobj: kobject struct | 2923 | * @kobj: kobject struct |
2923 | * @bin_attr: bin_attribute struct | 2924 | * @bin_attr: bin_attribute struct |
2924 | * @buf: buffer | 2925 | * @buf: buffer |
@@ -2928,7 +2929,7 @@ static DEVICE_ATTR(log_level, S_IRUGO | S_IWUSR, | |||
2928 | * Return value: | 2929 | * Return value: |
2929 | * number of bytes printed to buffer | 2930 | * number of bytes printed to buffer |
2930 | **/ | 2931 | **/ |
2931 | static ssize_t ibmvfc_read_trace(struct kobject *kobj, | 2932 | static ssize_t ibmvfc_read_trace(struct file *filp, struct kobject *kobj, |
2932 | struct bin_attribute *bin_attr, | 2933 | struct bin_attribute *bin_attr, |
2933 | char *buf, loff_t off, size_t count) | 2934 | char *buf, loff_t off, size_t count) |
2934 | { | 2935 | { |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index b90c118119d7..6a6661c35b2f 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -3120,6 +3120,7 @@ restart: | |||
3120 | #ifdef CONFIG_SCSI_IPR_TRACE | 3120 | #ifdef CONFIG_SCSI_IPR_TRACE |
3121 | /** | 3121 | /** |
3122 | * ipr_read_trace - Dump the adapter trace | 3122 | * ipr_read_trace - Dump the adapter trace |
3123 | * @filp: open sysfs file | ||
3123 | * @kobj: kobject struct | 3124 | * @kobj: kobject struct |
3124 | * @bin_attr: bin_attribute struct | 3125 | * @bin_attr: bin_attribute struct |
3125 | * @buf: buffer | 3126 | * @buf: buffer |
@@ -3129,7 +3130,7 @@ restart: | |||
3129 | * Return value: | 3130 | * Return value: |
3130 | * number of bytes printed to buffer | 3131 | * number of bytes printed to buffer |
3131 | **/ | 3132 | **/ |
3132 | static ssize_t ipr_read_trace(struct kobject *kobj, | 3133 | static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj, |
3133 | struct bin_attribute *bin_attr, | 3134 | struct bin_attribute *bin_attr, |
3134 | char *buf, loff_t off, size_t count) | 3135 | char *buf, loff_t off, size_t count) |
3135 | { | 3136 | { |
@@ -3764,6 +3765,7 @@ static struct device_attribute *ipr_ioa_attrs[] = { | |||
3764 | #ifdef CONFIG_SCSI_IPR_DUMP | 3765 | #ifdef CONFIG_SCSI_IPR_DUMP |
3765 | /** | 3766 | /** |
3766 | * ipr_read_dump - Dump the adapter | 3767 | * ipr_read_dump - Dump the adapter |
3768 | * @filp: open sysfs file | ||
3767 | * @kobj: kobject struct | 3769 | * @kobj: kobject struct |
3768 | * @bin_attr: bin_attribute struct | 3770 | * @bin_attr: bin_attribute struct |
3769 | * @buf: buffer | 3771 | * @buf: buffer |
@@ -3773,7 +3775,7 @@ static struct device_attribute *ipr_ioa_attrs[] = { | |||
3773 | * Return value: | 3775 | * Return value: |
3774 | * number of bytes printed to buffer | 3776 | * number of bytes printed to buffer |
3775 | **/ | 3777 | **/ |
3776 | static ssize_t ipr_read_dump(struct kobject *kobj, | 3778 | static ssize_t ipr_read_dump(struct file *filp, struct kobject *kobj, |
3777 | struct bin_attribute *bin_attr, | 3779 | struct bin_attribute *bin_attr, |
3778 | char *buf, loff_t off, size_t count) | 3780 | char *buf, loff_t off, size_t count) |
3779 | { | 3781 | { |
@@ -3927,6 +3929,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg) | |||
3927 | 3929 | ||
3928 | /** | 3930 | /** |
3929 | * ipr_write_dump - Setup dump state of adapter | 3931 | * ipr_write_dump - Setup dump state of adapter |
3932 | * @filp: open sysfs file | ||
3930 | * @kobj: kobject struct | 3933 | * @kobj: kobject struct |
3931 | * @bin_attr: bin_attribute struct | 3934 | * @bin_attr: bin_attribute struct |
3932 | * @buf: buffer | 3935 | * @buf: buffer |
@@ -3936,7 +3939,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg) | |||
3936 | * Return value: | 3939 | * Return value: |
3937 | * number of bytes printed to buffer | 3940 | * number of bytes printed to buffer |
3938 | **/ | 3941 | **/ |
3939 | static ssize_t ipr_write_dump(struct kobject *kobj, | 3942 | static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj, |
3940 | struct bin_attribute *bin_attr, | 3943 | struct bin_attribute *bin_attr, |
3941 | char *buf, loff_t off, size_t count) | 3944 | char *buf, loff_t off, size_t count) |
3942 | { | 3945 | { |
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 2e5f376d9ccc..bf33b315f93e 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -2643,6 +2643,7 @@ static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, | |||
2643 | 2643 | ||
2644 | /** | 2644 | /** |
2645 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute | 2645 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute |
2646 | * @filp: sysfs file | ||
2646 | * @kobj: Pointer to the kernel object | 2647 | * @kobj: Pointer to the kernel object |
2647 | * @bin_attr: Attribute object | 2648 | * @bin_attr: Attribute object |
2648 | * @buff: Buffer pointer | 2649 | * @buff: Buffer pointer |
@@ -2654,7 +2655,8 @@ static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, | |||
2654 | * applications. | 2655 | * applications. |
2655 | **/ | 2656 | **/ |
2656 | static ssize_t | 2657 | static ssize_t |
2657 | sysfs_drvr_stat_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 2658 | sysfs_drvr_stat_data_read(struct file *filp, struct kobject *kobj, |
2659 | struct bin_attribute *bin_attr, | ||
2658 | char *buf, loff_t off, size_t count) | 2660 | char *buf, loff_t off, size_t count) |
2659 | { | 2661 | { |
2660 | struct device *dev = container_of(kobj, struct device, | 2662 | struct device *dev = container_of(kobj, struct device, |
@@ -3362,6 +3364,7 @@ struct device_attribute *lpfc_vport_attrs[] = { | |||
3362 | 3364 | ||
3363 | /** | 3365 | /** |
3364 | * sysfs_ctlreg_write - Write method for writing to ctlreg | 3366 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
3367 | * @filp: open sysfs file | ||
3365 | * @kobj: kernel kobject that contains the kernel class device. | 3368 | * @kobj: kernel kobject that contains the kernel class device. |
3366 | * @bin_attr: kernel attributes passed to us. | 3369 | * @bin_attr: kernel attributes passed to us. |
3367 | * @buf: contains the data to be written to the adapter IOREG space. | 3370 | * @buf: contains the data to be written to the adapter IOREG space. |
@@ -3379,7 +3382,8 @@ struct device_attribute *lpfc_vport_attrs[] = { | |||
3379 | * value of count, buf contents written | 3382 | * value of count, buf contents written |
3380 | **/ | 3383 | **/ |
3381 | static ssize_t | 3384 | static ssize_t |
3382 | sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 3385 | sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, |
3386 | struct bin_attribute *bin_attr, | ||
3383 | char *buf, loff_t off, size_t count) | 3387 | char *buf, loff_t off, size_t count) |
3384 | { | 3388 | { |
3385 | size_t buf_off; | 3389 | size_t buf_off; |
@@ -3415,6 +3419,7 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3415 | 3419 | ||
3416 | /** | 3420 | /** |
3417 | * sysfs_ctlreg_read - Read method for reading from ctlreg | 3421 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
3422 | * @filp: open sysfs file | ||
3418 | * @kobj: kernel kobject that contains the kernel class device. | 3423 | * @kobj: kernel kobject that contains the kernel class device. |
3419 | * @bin_attr: kernel attributes passed to us. | 3424 | * @bin_attr: kernel attributes passed to us. |
3420 | * @buf: if successful contains the data from the adapter IOREG space. | 3425 | * @buf: if successful contains the data from the adapter IOREG space. |
@@ -3431,7 +3436,8 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3431 | * value of count, buf contents read | 3436 | * value of count, buf contents read |
3432 | **/ | 3437 | **/ |
3433 | static ssize_t | 3438 | static ssize_t |
3434 | sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 3439 | sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, |
3440 | struct bin_attribute *bin_attr, | ||
3435 | char *buf, loff_t off, size_t count) | 3441 | char *buf, loff_t off, size_t count) |
3436 | { | 3442 | { |
3437 | size_t buf_off; | 3443 | size_t buf_off; |
@@ -3496,6 +3502,7 @@ sysfs_mbox_idle(struct lpfc_hba *phba) | |||
3496 | 3502 | ||
3497 | /** | 3503 | /** |
3498 | * sysfs_mbox_write - Write method for writing information via mbox | 3504 | * sysfs_mbox_write - Write method for writing information via mbox |
3505 | * @filp: open sysfs file | ||
3499 | * @kobj: kernel kobject that contains the kernel class device. | 3506 | * @kobj: kernel kobject that contains the kernel class device. |
3500 | * @bin_attr: kernel attributes passed to us. | 3507 | * @bin_attr: kernel attributes passed to us. |
3501 | * @buf: contains the data to be written to sysfs mbox. | 3508 | * @buf: contains the data to be written to sysfs mbox. |
@@ -3516,7 +3523,8 @@ sysfs_mbox_idle(struct lpfc_hba *phba) | |||
3516 | * count number of bytes transferred | 3523 | * count number of bytes transferred |
3517 | **/ | 3524 | **/ |
3518 | static ssize_t | 3525 | static ssize_t |
3519 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 3526 | sysfs_mbox_write(struct file *filp, struct kobject *kobj, |
3527 | struct bin_attribute *bin_attr, | ||
3520 | char *buf, loff_t off, size_t count) | 3528 | char *buf, loff_t off, size_t count) |
3521 | { | 3529 | { |
3522 | struct device *dev = container_of(kobj, struct device, kobj); | 3530 | struct device *dev = container_of(kobj, struct device, kobj); |
@@ -3571,6 +3579,7 @@ sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3571 | 3579 | ||
3572 | /** | 3580 | /** |
3573 | * sysfs_mbox_read - Read method for reading information via mbox | 3581 | * sysfs_mbox_read - Read method for reading information via mbox |
3582 | * @filp: open sysfs file | ||
3574 | * @kobj: kernel kobject that contains the kernel class device. | 3583 | * @kobj: kernel kobject that contains the kernel class device. |
3575 | * @bin_attr: kernel attributes passed to us. | 3584 | * @bin_attr: kernel attributes passed to us. |
3576 | * @buf: contains the data to be read from sysfs mbox. | 3585 | * @buf: contains the data to be read from sysfs mbox. |
@@ -3593,7 +3602,8 @@ sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3593 | * count number of bytes transferred | 3602 | * count number of bytes transferred |
3594 | **/ | 3603 | **/ |
3595 | static ssize_t | 3604 | static ssize_t |
3596 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 3605 | sysfs_mbox_read(struct file *filp, struct kobject *kobj, |
3606 | struct bin_attribute *bin_attr, | ||
3597 | char *buf, loff_t off, size_t count) | 3607 | char *buf, loff_t off, size_t count) |
3598 | { | 3608 | { |
3599 | struct device *dev = container_of(kobj, struct device, kobj); | 3609 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 3b708606b932..1e4cafabba15 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -16,7 +16,7 @@ static int qla24xx_vport_disable(struct fc_vport *, bool); | |||
16 | /* SYSFS attributes --------------------------------------------------------- */ | 16 | /* SYSFS attributes --------------------------------------------------------- */ |
17 | 17 | ||
18 | static ssize_t | 18 | static ssize_t |
19 | qla2x00_sysfs_read_fw_dump(struct kobject *kobj, | 19 | qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj, |
20 | struct bin_attribute *bin_attr, | 20 | struct bin_attribute *bin_attr, |
21 | char *buf, loff_t off, size_t count) | 21 | char *buf, loff_t off, size_t count) |
22 | { | 22 | { |
@@ -32,7 +32,7 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj, | |||
32 | } | 32 | } |
33 | 33 | ||
34 | static ssize_t | 34 | static ssize_t |
35 | qla2x00_sysfs_write_fw_dump(struct kobject *kobj, | 35 | qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, |
36 | struct bin_attribute *bin_attr, | 36 | struct bin_attribute *bin_attr, |
37 | char *buf, loff_t off, size_t count) | 37 | char *buf, loff_t off, size_t count) |
38 | { | 38 | { |
@@ -92,7 +92,7 @@ static struct bin_attribute sysfs_fw_dump_attr = { | |||
92 | }; | 92 | }; |
93 | 93 | ||
94 | static ssize_t | 94 | static ssize_t |
95 | qla2x00_sysfs_read_nvram(struct kobject *kobj, | 95 | qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj, |
96 | struct bin_attribute *bin_attr, | 96 | struct bin_attribute *bin_attr, |
97 | char *buf, loff_t off, size_t count) | 97 | char *buf, loff_t off, size_t count) |
98 | { | 98 | { |
@@ -111,7 +111,7 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, | |||
111 | } | 111 | } |
112 | 112 | ||
113 | static ssize_t | 113 | static ssize_t |
114 | qla2x00_sysfs_write_nvram(struct kobject *kobj, | 114 | qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, |
115 | struct bin_attribute *bin_attr, | 115 | struct bin_attribute *bin_attr, |
116 | char *buf, loff_t off, size_t count) | 116 | char *buf, loff_t off, size_t count) |
117 | { | 117 | { |
@@ -177,7 +177,7 @@ static struct bin_attribute sysfs_nvram_attr = { | |||
177 | }; | 177 | }; |
178 | 178 | ||
179 | static ssize_t | 179 | static ssize_t |
180 | qla2x00_sysfs_read_optrom(struct kobject *kobj, | 180 | qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj, |
181 | struct bin_attribute *bin_attr, | 181 | struct bin_attribute *bin_attr, |
182 | char *buf, loff_t off, size_t count) | 182 | char *buf, loff_t off, size_t count) |
183 | { | 183 | { |
@@ -193,7 +193,7 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj, | |||
193 | } | 193 | } |
194 | 194 | ||
195 | static ssize_t | 195 | static ssize_t |
196 | qla2x00_sysfs_write_optrom(struct kobject *kobj, | 196 | qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, |
197 | struct bin_attribute *bin_attr, | 197 | struct bin_attribute *bin_attr, |
198 | char *buf, loff_t off, size_t count) | 198 | char *buf, loff_t off, size_t count) |
199 | { | 199 | { |
@@ -224,7 +224,7 @@ static struct bin_attribute sysfs_optrom_attr = { | |||
224 | }; | 224 | }; |
225 | 225 | ||
226 | static ssize_t | 226 | static ssize_t |
227 | qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, | 227 | qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, |
228 | struct bin_attribute *bin_attr, | 228 | struct bin_attribute *bin_attr, |
229 | char *buf, loff_t off, size_t count) | 229 | char *buf, loff_t off, size_t count) |
230 | { | 230 | { |
@@ -387,7 +387,7 @@ static struct bin_attribute sysfs_optrom_ctl_attr = { | |||
387 | }; | 387 | }; |
388 | 388 | ||
389 | static ssize_t | 389 | static ssize_t |
390 | qla2x00_sysfs_read_vpd(struct kobject *kobj, | 390 | qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, |
391 | struct bin_attribute *bin_attr, | 391 | struct bin_attribute *bin_attr, |
392 | char *buf, loff_t off, size_t count) | 392 | char *buf, loff_t off, size_t count) |
393 | { | 393 | { |
@@ -408,7 +408,7 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj, | |||
408 | } | 408 | } |
409 | 409 | ||
410 | static ssize_t | 410 | static ssize_t |
411 | qla2x00_sysfs_write_vpd(struct kobject *kobj, | 411 | qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, |
412 | struct bin_attribute *bin_attr, | 412 | struct bin_attribute *bin_attr, |
413 | char *buf, loff_t off, size_t count) | 413 | char *buf, loff_t off, size_t count) |
414 | { | 414 | { |
@@ -461,7 +461,7 @@ static struct bin_attribute sysfs_vpd_attr = { | |||
461 | }; | 461 | }; |
462 | 462 | ||
463 | static ssize_t | 463 | static ssize_t |
464 | qla2x00_sysfs_read_sfp(struct kobject *kobj, | 464 | qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, |
465 | struct bin_attribute *bin_attr, | 465 | struct bin_attribute *bin_attr, |
466 | char *buf, loff_t off, size_t count) | 466 | char *buf, loff_t off, size_t count) |
467 | { | 467 | { |
@@ -522,7 +522,7 @@ static struct bin_attribute sysfs_sfp_attr = { | |||
522 | }; | 522 | }; |
523 | 523 | ||
524 | static ssize_t | 524 | static ssize_t |
525 | qla2x00_sysfs_write_reset(struct kobject *kobj, | 525 | qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, |
526 | struct bin_attribute *bin_attr, | 526 | struct bin_attribute *bin_attr, |
527 | char *buf, loff_t off, size_t count) | 527 | char *buf, loff_t off, size_t count) |
528 | { | 528 | { |
@@ -592,7 +592,7 @@ static struct bin_attribute sysfs_reset_attr = { | |||
592 | }; | 592 | }; |
593 | 593 | ||
594 | static ssize_t | 594 | static ssize_t |
595 | qla2x00_sysfs_write_edc(struct kobject *kobj, | 595 | qla2x00_sysfs_write_edc(struct file *filp, struct kobject *kobj, |
596 | struct bin_attribute *bin_attr, | 596 | struct bin_attribute *bin_attr, |
597 | char *buf, loff_t off, size_t count) | 597 | char *buf, loff_t off, size_t count) |
598 | { | 598 | { |
@@ -650,7 +650,7 @@ static struct bin_attribute sysfs_edc_attr = { | |||
650 | }; | 650 | }; |
651 | 651 | ||
652 | static ssize_t | 652 | static ssize_t |
653 | qla2x00_sysfs_write_edc_status(struct kobject *kobj, | 653 | qla2x00_sysfs_write_edc_status(struct file *filp, struct kobject *kobj, |
654 | struct bin_attribute *bin_attr, | 654 | struct bin_attribute *bin_attr, |
655 | char *buf, loff_t off, size_t count) | 655 | char *buf, loff_t off, size_t count) |
656 | { | 656 | { |
@@ -700,7 +700,7 @@ qla2x00_sysfs_write_edc_status(struct kobject *kobj, | |||
700 | } | 700 | } |
701 | 701 | ||
702 | static ssize_t | 702 | static ssize_t |
703 | qla2x00_sysfs_read_edc_status(struct kobject *kobj, | 703 | qla2x00_sysfs_read_edc_status(struct file *filp, struct kobject *kobj, |
704 | struct bin_attribute *bin_attr, | 704 | struct bin_attribute *bin_attr, |
705 | char *buf, loff_t off, size_t count) | 705 | char *buf, loff_t off, size_t count) |
706 | { | 706 | { |
@@ -730,7 +730,7 @@ static struct bin_attribute sysfs_edc_status_attr = { | |||
730 | }; | 730 | }; |
731 | 731 | ||
732 | static ssize_t | 732 | static ssize_t |
733 | qla2x00_sysfs_read_xgmac_stats(struct kobject *kobj, | 733 | qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj, |
734 | struct bin_attribute *bin_attr, | 734 | struct bin_attribute *bin_attr, |
735 | char *buf, loff_t off, size_t count) | 735 | char *buf, loff_t off, size_t count) |
736 | { | 736 | { |
@@ -782,7 +782,7 @@ static struct bin_attribute sysfs_xgmac_stats_attr = { | |||
782 | }; | 782 | }; |
783 | 783 | ||
784 | static ssize_t | 784 | static ssize_t |
785 | qla2x00_sysfs_read_dcbx_tlv(struct kobject *kobj, | 785 | qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, |
786 | struct bin_attribute *bin_attr, | 786 | struct bin_attribute *bin_attr, |
787 | char *buf, loff_t off, size_t count) | 787 | char *buf, loff_t off, size_t count) |
788 | { | 788 | { |
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 1786db2f3378..8b274b708259 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c | |||
@@ -48,6 +48,7 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308 | |||
48 | */ | 48 | */ |
49 | 49 | ||
50 | #include "../comedidev.h" | 50 | #include "../comedidev.h" |
51 | #include <linux/semaphore.h> | ||
51 | 52 | ||
52 | #include <pcmcia/cs_types.h> | 53 | #include <pcmcia/cs_types.h> |
53 | #include <pcmcia/cs.h> | 54 | #include <pcmcia/cs.h> |
diff --git a/drivers/staging/udlfb/udlfb.c b/drivers/staging/udlfb/udlfb.c index aa8195199a2c..577f2bf6eb23 100644 --- a/drivers/staging/udlfb/udlfb.c +++ b/drivers/staging/udlfb/udlfb.c | |||
@@ -1063,7 +1063,8 @@ static ssize_t metrics_misc_show(struct device *fbdev, | |||
1063 | atomic_read(&dev->lost_pixels) ? "yes" : "no"); | 1063 | atomic_read(&dev->lost_pixels) ? "yes" : "no"); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *a, | 1066 | static ssize_t edid_show(struct file *filp, struct kobject *kobj, |
1067 | struct bin_attribute *a, | ||
1067 | char *buf, loff_t off, size_t count) { | 1068 | char *buf, loff_t off, size_t count) { |
1068 | struct device *fbdev = container_of(kobj, struct device, kobj); | 1069 | struct device *fbdev = container_of(kobj, struct device, kobj); |
1069 | struct fb_info *fb_info = dev_get_drvdata(fbdev); | 1070 | struct fb_info *fb_info = dev_get_drvdata(fbdev); |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 06863befaf3a..448f5b47fc48 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -658,7 +658,8 @@ const struct attribute_group *usb_device_groups[] = { | |||
658 | /* Binary descriptors */ | 658 | /* Binary descriptors */ |
659 | 659 | ||
660 | static ssize_t | 660 | static ssize_t |
661 | read_descriptors(struct kobject *kobj, struct bin_attribute *attr, | 661 | read_descriptors(struct file *filp, struct kobject *kobj, |
662 | struct bin_attribute *attr, | ||
662 | char *buf, loff_t off, size_t count) | 663 | char *buf, loff_t off, size_t count) |
663 | { | 664 | { |
664 | struct device *dev = container_of(kobj, struct device, kobj); | 665 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 397b678f1c47..5ae14f6c1e7a 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -573,7 +573,7 @@ int usb_lock_device_for_reset(struct usb_device *udev, | |||
573 | iface->condition == USB_INTERFACE_UNBOUND)) | 573 | iface->condition == USB_INTERFACE_UNBOUND)) |
574 | return -EINTR; | 574 | return -EINTR; |
575 | 575 | ||
576 | while (usb_trylock_device(udev) != 0) { | 576 | while (!usb_trylock_device(udev)) { |
577 | 577 | ||
578 | /* If we can't acquire the lock after waiting one second, | 578 | /* If we can't acquire the lock after waiting one second, |
579 | * we're probably deadlocked */ | 579 | * we're probably deadlocked */ |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 6c37e8ee5efe..3c1e13ed1cba 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -2099,7 +2099,7 @@ static ssize_t radeon_show_one_edid(char *buf, loff_t off, size_t count, const u | |||
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | 2101 | ||
2102 | static ssize_t radeon_show_edid1(struct kobject *kobj, | 2102 | static ssize_t radeon_show_edid1(struct file *filp, struct kobject *kobj, |
2103 | struct bin_attribute *bin_attr, | 2103 | struct bin_attribute *bin_attr, |
2104 | char *buf, loff_t off, size_t count) | 2104 | char *buf, loff_t off, size_t count) |
2105 | { | 2105 | { |
@@ -2112,7 +2112,7 @@ static ssize_t radeon_show_edid1(struct kobject *kobj, | |||
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | 2114 | ||
2115 | static ssize_t radeon_show_edid2(struct kobject *kobj, | 2115 | static ssize_t radeon_show_edid2(struct file *filp, struct kobject *kobj, |
2116 | struct bin_attribute *bin_attr, | 2116 | struct bin_attribute *bin_attr, |
2117 | char *buf, loff_t off, size_t count) | 2117 | char *buf, loff_t off, size_t count) |
2118 | { | 2118 | { |
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c index 2c6c0cf6a20f..84e2410aec1d 100644 --- a/drivers/w1/slaves/w1_ds2431.c +++ b/drivers/w1/slaves/w1_ds2431.c | |||
@@ -96,7 +96,7 @@ static int w1_f2d_readblock(struct w1_slave *sl, int off, int count, char *buf) | |||
96 | return -1; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | static ssize_t w1_f2d_read_bin(struct kobject *kobj, | 99 | static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj, |
100 | struct bin_attribute *bin_attr, | 100 | struct bin_attribute *bin_attr, |
101 | char *buf, loff_t off, size_t count) | 101 | char *buf, loff_t off, size_t count) |
102 | { | 102 | { |
@@ -202,7 +202,7 @@ retry: | |||
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | static ssize_t w1_f2d_write_bin(struct kobject *kobj, | 205 | static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj, |
206 | struct bin_attribute *bin_attr, | 206 | struct bin_attribute *bin_attr, |
207 | char *buf, loff_t off, size_t count) | 207 | char *buf, loff_t off, size_t count) |
208 | { | 208 | { |
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index d2bf32118a98..0f7b8f9c509a 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c | |||
@@ -92,7 +92,7 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, | |||
92 | } | 92 | } |
93 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ | 93 | #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ |
94 | 94 | ||
95 | static ssize_t w1_f23_read_bin(struct kobject *kobj, | 95 | static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj, |
96 | struct bin_attribute *bin_attr, | 96 | struct bin_attribute *bin_attr, |
97 | char *buf, loff_t off, size_t count) | 97 | char *buf, loff_t off, size_t count) |
98 | { | 98 | { |
@@ -206,7 +206,7 @@ static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) | |||
206 | return 0; | 206 | return 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | static ssize_t w1_f23_write_bin(struct kobject *kobj, | 209 | static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj, |
210 | struct bin_attribute *bin_attr, | 210 | struct bin_attribute *bin_attr, |
211 | char *buf, loff_t off, size_t count) | 211 | char *buf, loff_t off, size_t count) |
212 | { | 212 | { |
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c index 6e153343e117..483d45180911 100644 --- a/drivers/w1/slaves/w1_ds2760.c +++ b/drivers/w1/slaves/w1_ds2760.c | |||
@@ -97,7 +97,7 @@ int w1_ds2760_recall_eeprom(struct device *dev, int addr) | |||
97 | return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA); | 97 | return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA); |
98 | } | 98 | } |
99 | 99 | ||
100 | static ssize_t w1_ds2760_read_bin(struct kobject *kobj, | 100 | static ssize_t w1_ds2760_read_bin(struct file *filp, struct kobject *kobj, |
101 | struct bin_attribute *bin_attr, | 101 | struct bin_attribute *bin_attr, |
102 | char *buf, loff_t off, size_t count) | 102 | char *buf, loff_t off, size_t count) |
103 | { | 103 | { |
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index ad5897dc4495..2839e281cd65 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -120,7 +120,7 @@ static struct device_attribute w1_slave_attr_id = | |||
120 | 120 | ||
121 | /* Default family */ | 121 | /* Default family */ |
122 | 122 | ||
123 | static ssize_t w1_default_write(struct kobject *kobj, | 123 | static ssize_t w1_default_write(struct file *filp, struct kobject *kobj, |
124 | struct bin_attribute *bin_attr, | 124 | struct bin_attribute *bin_attr, |
125 | char *buf, loff_t off, size_t count) | 125 | char *buf, loff_t off, size_t count) |
126 | { | 126 | { |
@@ -139,7 +139,7 @@ out_up: | |||
139 | return count; | 139 | return count; |
140 | } | 140 | } |
141 | 141 | ||
142 | static ssize_t w1_default_read(struct kobject *kobj, | 142 | static ssize_t w1_default_read(struct file *filp, struct kobject *kobj, |
143 | struct bin_attribute *bin_attr, | 143 | struct bin_attribute *bin_attr, |
144 | char *buf, loff_t off, size_t count) | 144 | char *buf, loff_t off, size_t count) |
145 | { | 145 | { |
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c index eb924e0a64ce..26f7184ef9e1 100644 --- a/drivers/zorro/zorro-sysfs.c +++ b/drivers/zorro/zorro-sysfs.c | |||
@@ -49,7 +49,7 @@ static ssize_t zorro_show_resource(struct device *dev, struct device_attribute * | |||
49 | 49 | ||
50 | static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL); | 50 | static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL); |
51 | 51 | ||
52 | static ssize_t zorro_read_config(struct kobject *kobj, | 52 | static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj, |
53 | struct bin_attribute *bin_attr, | 53 | struct bin_attribute *bin_attr, |
54 | char *buf, loff_t off, size_t count) | 54 | char *buf, loff_t off, size_t count) |
55 | { | 55 | { |
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index c94853473ca9..f47cd212dee1 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c | |||
@@ -214,7 +214,7 @@ static int ramfs_parse_options(char *data, struct ramfs_mount_opts *opts) | |||
214 | return 0; | 214 | return 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | static int ramfs_fill_super(struct super_block * sb, void * data, int silent) | 217 | int ramfs_fill_super(struct super_block *sb, void *data, int silent) |
218 | { | 218 | { |
219 | struct ramfs_fs_info *fsi; | 219 | struct ramfs_fs_info *fsi; |
220 | struct inode *inode = NULL; | 220 | struct inode *inode = NULL; |
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index e9d293593e52..4e321f7353fa 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c | |||
@@ -46,9 +46,9 @@ struct bin_buffer { | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | static int | 48 | static int |
49 | fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) | 49 | fill_read(struct file *file, char *buffer, loff_t off, size_t count) |
50 | { | 50 | { |
51 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; | 51 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
52 | struct bin_attribute *attr = attr_sd->s_bin_attr.bin_attr; | 52 | struct bin_attribute *attr = attr_sd->s_bin_attr.bin_attr; |
53 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; | 53 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
54 | int rc; | 54 | int rc; |
@@ -59,7 +59,7 @@ fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) | |||
59 | 59 | ||
60 | rc = -EIO; | 60 | rc = -EIO; |
61 | if (attr->read) | 61 | if (attr->read) |
62 | rc = attr->read(kobj, attr, buffer, off, count); | 62 | rc = attr->read(file, kobj, attr, buffer, off, count); |
63 | 63 | ||
64 | sysfs_put_active(attr_sd); | 64 | sysfs_put_active(attr_sd); |
65 | 65 | ||
@@ -70,8 +70,7 @@ static ssize_t | |||
70 | read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) | 70 | read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) |
71 | { | 71 | { |
72 | struct bin_buffer *bb = file->private_data; | 72 | struct bin_buffer *bb = file->private_data; |
73 | struct dentry *dentry = file->f_path.dentry; | 73 | int size = file->f_path.dentry->d_inode->i_size; |
74 | int size = dentry->d_inode->i_size; | ||
75 | loff_t offs = *off; | 74 | loff_t offs = *off; |
76 | int count = min_t(size_t, bytes, PAGE_SIZE); | 75 | int count = min_t(size_t, bytes, PAGE_SIZE); |
77 | char *temp; | 76 | char *temp; |
@@ -92,7 +91,7 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) | |||
92 | 91 | ||
93 | mutex_lock(&bb->mutex); | 92 | mutex_lock(&bb->mutex); |
94 | 93 | ||
95 | count = fill_read(dentry, bb->buffer, offs, count); | 94 | count = fill_read(file, bb->buffer, offs, count); |
96 | if (count < 0) { | 95 | if (count < 0) { |
97 | mutex_unlock(&bb->mutex); | 96 | mutex_unlock(&bb->mutex); |
98 | goto out_free; | 97 | goto out_free; |
@@ -117,9 +116,9 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) | |||
117 | } | 116 | } |
118 | 117 | ||
119 | static int | 118 | static int |
120 | flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) | 119 | flush_write(struct file *file, char *buffer, loff_t offset, size_t count) |
121 | { | 120 | { |
122 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; | 121 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
123 | struct bin_attribute *attr = attr_sd->s_bin_attr.bin_attr; | 122 | struct bin_attribute *attr = attr_sd->s_bin_attr.bin_attr; |
124 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; | 123 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
125 | int rc; | 124 | int rc; |
@@ -130,7 +129,7 @@ flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) | |||
130 | 129 | ||
131 | rc = -EIO; | 130 | rc = -EIO; |
132 | if (attr->write) | 131 | if (attr->write) |
133 | rc = attr->write(kobj, attr, buffer, offset, count); | 132 | rc = attr->write(file, kobj, attr, buffer, offset, count); |
134 | 133 | ||
135 | sysfs_put_active(attr_sd); | 134 | sysfs_put_active(attr_sd); |
136 | 135 | ||
@@ -141,8 +140,7 @@ static ssize_t write(struct file *file, const char __user *userbuf, | |||
141 | size_t bytes, loff_t *off) | 140 | size_t bytes, loff_t *off) |
142 | { | 141 | { |
143 | struct bin_buffer *bb = file->private_data; | 142 | struct bin_buffer *bb = file->private_data; |
144 | struct dentry *dentry = file->f_path.dentry; | 143 | int size = file->f_path.dentry->d_inode->i_size; |
145 | int size = dentry->d_inode->i_size; | ||
146 | loff_t offs = *off; | 144 | loff_t offs = *off; |
147 | int count = min_t(size_t, bytes, PAGE_SIZE); | 145 | int count = min_t(size_t, bytes, PAGE_SIZE); |
148 | char *temp; | 146 | char *temp; |
@@ -165,7 +163,7 @@ static ssize_t write(struct file *file, const char __user *userbuf, | |||
165 | 163 | ||
166 | memcpy(bb->buffer, temp, count); | 164 | memcpy(bb->buffer, temp, count); |
167 | 165 | ||
168 | count = flush_write(dentry, bb->buffer, offs, count); | 166 | count = flush_write(file, bb->buffer, offs, count); |
169 | mutex_unlock(&bb->mutex); | 167 | mutex_unlock(&bb->mutex); |
170 | 168 | ||
171 | if (count > 0) | 169 | if (count > 0) |
@@ -363,7 +361,7 @@ static int mmap(struct file *file, struct vm_area_struct *vma) | |||
363 | if (!attr->mmap) | 361 | if (!attr->mmap) |
364 | goto out_put; | 362 | goto out_put; |
365 | 363 | ||
366 | rc = attr->mmap(kobj, attr, vma); | 364 | rc = attr->mmap(file, kobj, attr, vma); |
367 | if (rc) | 365 | if (rc) |
368 | goto out_put; | 366 | goto out_put; |
369 | 367 | ||
@@ -501,7 +499,7 @@ int sysfs_create_bin_file(struct kobject *kobj, | |||
501 | void sysfs_remove_bin_file(struct kobject *kobj, | 499 | void sysfs_remove_bin_file(struct kobject *kobj, |
502 | const struct bin_attribute *attr) | 500 | const struct bin_attribute *attr) |
503 | { | 501 | { |
504 | sysfs_hash_and_remove(kobj->sd, attr->attr.name); | 502 | sysfs_hash_and_remove(kobj->sd, NULL, attr->attr.name); |
505 | } | 503 | } |
506 | 504 | ||
507 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); | 505 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); |
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 590717861c7a..7e54bac8c4b0 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -380,7 +380,7 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
380 | { | 380 | { |
381 | struct sysfs_inode_attrs *ps_iattr; | 381 | struct sysfs_inode_attrs *ps_iattr; |
382 | 382 | ||
383 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) | 383 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name)) |
384 | return -EEXIST; | 384 | return -EEXIST; |
385 | 385 | ||
386 | sd->s_parent = sysfs_get(acxt->parent_sd); | 386 | sd->s_parent = sysfs_get(acxt->parent_sd); |
@@ -533,13 +533,17 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt) | |||
533 | * Pointer to sysfs_dirent if found, NULL if not. | 533 | * Pointer to sysfs_dirent if found, NULL if not. |
534 | */ | 534 | */ |
535 | struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | 535 | struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, |
536 | const void *ns, | ||
536 | const unsigned char *name) | 537 | const unsigned char *name) |
537 | { | 538 | { |
538 | struct sysfs_dirent *sd; | 539 | struct sysfs_dirent *sd; |
539 | 540 | ||
540 | for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) | 541 | for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) { |
542 | if (ns && sd->s_ns && (sd->s_ns != ns)) | ||
543 | continue; | ||
541 | if (!strcmp(sd->s_name, name)) | 544 | if (!strcmp(sd->s_name, name)) |
542 | return sd; | 545 | return sd; |
546 | } | ||
543 | return NULL; | 547 | return NULL; |
544 | } | 548 | } |
545 | 549 | ||
@@ -558,12 +562,13 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | |||
558 | * Pointer to sysfs_dirent if found, NULL if not. | 562 | * Pointer to sysfs_dirent if found, NULL if not. |
559 | */ | 563 | */ |
560 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | 564 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, |
565 | const void *ns, | ||
561 | const unsigned char *name) | 566 | const unsigned char *name) |
562 | { | 567 | { |
563 | struct sysfs_dirent *sd; | 568 | struct sysfs_dirent *sd; |
564 | 569 | ||
565 | mutex_lock(&sysfs_mutex); | 570 | mutex_lock(&sysfs_mutex); |
566 | sd = sysfs_find_dirent(parent_sd, name); | 571 | sd = sysfs_find_dirent(parent_sd, ns, name); |
567 | sysfs_get(sd); | 572 | sysfs_get(sd); |
568 | mutex_unlock(&sysfs_mutex); | 573 | mutex_unlock(&sysfs_mutex); |
569 | 574 | ||
@@ -572,7 +577,8 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | |||
572 | EXPORT_SYMBOL_GPL(sysfs_get_dirent); | 577 | EXPORT_SYMBOL_GPL(sysfs_get_dirent); |
573 | 578 | ||
574 | static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, | 579 | static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, |
575 | const char *name, struct sysfs_dirent **p_sd) | 580 | enum kobj_ns_type type, const void *ns, const char *name, |
581 | struct sysfs_dirent **p_sd) | ||
576 | { | 582 | { |
577 | umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; | 583 | umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; |
578 | struct sysfs_addrm_cxt acxt; | 584 | struct sysfs_addrm_cxt acxt; |
@@ -583,6 +589,9 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, | |||
583 | sd = sysfs_new_dirent(name, mode, SYSFS_DIR); | 589 | sd = sysfs_new_dirent(name, mode, SYSFS_DIR); |
584 | if (!sd) | 590 | if (!sd) |
585 | return -ENOMEM; | 591 | return -ENOMEM; |
592 | |||
593 | sd->s_flags |= (type << SYSFS_NS_TYPE_SHIFT); | ||
594 | sd->s_ns = ns; | ||
586 | sd->s_dir.kobj = kobj; | 595 | sd->s_dir.kobj = kobj; |
587 | 596 | ||
588 | /* link in */ | 597 | /* link in */ |
@@ -601,7 +610,33 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, | |||
601 | int sysfs_create_subdir(struct kobject *kobj, const char *name, | 610 | int sysfs_create_subdir(struct kobject *kobj, const char *name, |
602 | struct sysfs_dirent **p_sd) | 611 | struct sysfs_dirent **p_sd) |
603 | { | 612 | { |
604 | return create_dir(kobj, kobj->sd, name, p_sd); | 613 | return create_dir(kobj, kobj->sd, |
614 | KOBJ_NS_TYPE_NONE, NULL, name, p_sd); | ||
615 | } | ||
616 | |||
617 | /** | ||
618 | * sysfs_read_ns_type: return associated ns_type | ||
619 | * @kobj: the kobject being queried | ||
620 | * | ||
621 | * Each kobject can be tagged with exactly one namespace type | ||
622 | * (i.e. network or user). Return the ns_type associated with | ||
623 | * this object if any | ||
624 | */ | ||
625 | static enum kobj_ns_type sysfs_read_ns_type(struct kobject *kobj) | ||
626 | { | ||
627 | const struct kobj_ns_type_operations *ops; | ||
628 | enum kobj_ns_type type; | ||
629 | |||
630 | ops = kobj_child_ns_ops(kobj); | ||
631 | if (!ops) | ||
632 | return KOBJ_NS_TYPE_NONE; | ||
633 | |||
634 | type = ops->type; | ||
635 | BUG_ON(type <= KOBJ_NS_TYPE_NONE); | ||
636 | BUG_ON(type >= KOBJ_NS_TYPES); | ||
637 | BUG_ON(!kobj_ns_type_registered(type)); | ||
638 | |||
639 | return type; | ||
605 | } | 640 | } |
606 | 641 | ||
607 | /** | 642 | /** |
@@ -610,7 +645,9 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name, | |||
610 | */ | 645 | */ |
611 | int sysfs_create_dir(struct kobject * kobj) | 646 | int sysfs_create_dir(struct kobject * kobj) |
612 | { | 647 | { |
648 | enum kobj_ns_type type; | ||
613 | struct sysfs_dirent *parent_sd, *sd; | 649 | struct sysfs_dirent *parent_sd, *sd; |
650 | const void *ns = NULL; | ||
614 | int error = 0; | 651 | int error = 0; |
615 | 652 | ||
616 | BUG_ON(!kobj); | 653 | BUG_ON(!kobj); |
@@ -620,7 +657,11 @@ int sysfs_create_dir(struct kobject * kobj) | |||
620 | else | 657 | else |
621 | parent_sd = &sysfs_root; | 658 | parent_sd = &sysfs_root; |
622 | 659 | ||
623 | error = create_dir(kobj, parent_sd, kobject_name(kobj), &sd); | 660 | if (sysfs_ns_type(parent_sd)) |
661 | ns = kobj->ktype->namespace(kobj); | ||
662 | type = sysfs_read_ns_type(kobj); | ||
663 | |||
664 | error = create_dir(kobj, parent_sd, type, ns, kobject_name(kobj), &sd); | ||
624 | if (!error) | 665 | if (!error) |
625 | kobj->sd = sd; | 666 | kobj->sd = sd; |
626 | return error; | 667 | return error; |
@@ -630,13 +671,19 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
630 | struct nameidata *nd) | 671 | struct nameidata *nd) |
631 | { | 672 | { |
632 | struct dentry *ret = NULL; | 673 | struct dentry *ret = NULL; |
633 | struct sysfs_dirent *parent_sd = dentry->d_parent->d_fsdata; | 674 | struct dentry *parent = dentry->d_parent; |
675 | struct sysfs_dirent *parent_sd = parent->d_fsdata; | ||
634 | struct sysfs_dirent *sd; | 676 | struct sysfs_dirent *sd; |
635 | struct inode *inode; | 677 | struct inode *inode; |
678 | enum kobj_ns_type type; | ||
679 | const void *ns; | ||
636 | 680 | ||
637 | mutex_lock(&sysfs_mutex); | 681 | mutex_lock(&sysfs_mutex); |
638 | 682 | ||
639 | sd = sysfs_find_dirent(parent_sd, dentry->d_name.name); | 683 | type = sysfs_ns_type(parent_sd); |
684 | ns = sysfs_info(dir->i_sb)->ns[type]; | ||
685 | |||
686 | sd = sysfs_find_dirent(parent_sd, ns, dentry->d_name.name); | ||
640 | 687 | ||
641 | /* no such entry */ | 688 | /* no such entry */ |
642 | if (!sd) { | 689 | if (!sd) { |
@@ -735,7 +782,8 @@ void sysfs_remove_dir(struct kobject * kobj) | |||
735 | } | 782 | } |
736 | 783 | ||
737 | int sysfs_rename(struct sysfs_dirent *sd, | 784 | int sysfs_rename(struct sysfs_dirent *sd, |
738 | struct sysfs_dirent *new_parent_sd, const char *new_name) | 785 | struct sysfs_dirent *new_parent_sd, const void *new_ns, |
786 | const char *new_name) | ||
739 | { | 787 | { |
740 | const char *dup_name = NULL; | 788 | const char *dup_name = NULL; |
741 | int error; | 789 | int error; |
@@ -743,12 +791,12 @@ int sysfs_rename(struct sysfs_dirent *sd, | |||
743 | mutex_lock(&sysfs_mutex); | 791 | mutex_lock(&sysfs_mutex); |
744 | 792 | ||
745 | error = 0; | 793 | error = 0; |
746 | if ((sd->s_parent == new_parent_sd) && | 794 | if ((sd->s_parent == new_parent_sd) && (sd->s_ns == new_ns) && |
747 | (strcmp(sd->s_name, new_name) == 0)) | 795 | (strcmp(sd->s_name, new_name) == 0)) |
748 | goto out; /* nothing to rename */ | 796 | goto out; /* nothing to rename */ |
749 | 797 | ||
750 | error = -EEXIST; | 798 | error = -EEXIST; |
751 | if (sysfs_find_dirent(new_parent_sd, new_name)) | 799 | if (sysfs_find_dirent(new_parent_sd, new_ns, new_name)) |
752 | goto out; | 800 | goto out; |
753 | 801 | ||
754 | /* rename sysfs_dirent */ | 802 | /* rename sysfs_dirent */ |
@@ -770,6 +818,7 @@ int sysfs_rename(struct sysfs_dirent *sd, | |||
770 | sd->s_parent = new_parent_sd; | 818 | sd->s_parent = new_parent_sd; |
771 | sysfs_link_sibling(sd); | 819 | sysfs_link_sibling(sd); |
772 | } | 820 | } |
821 | sd->s_ns = new_ns; | ||
773 | 822 | ||
774 | error = 0; | 823 | error = 0; |
775 | out: | 824 | out: |
@@ -780,19 +829,28 @@ int sysfs_rename(struct sysfs_dirent *sd, | |||
780 | 829 | ||
781 | int sysfs_rename_dir(struct kobject *kobj, const char *new_name) | 830 | int sysfs_rename_dir(struct kobject *kobj, const char *new_name) |
782 | { | 831 | { |
783 | return sysfs_rename(kobj->sd, kobj->sd->s_parent, new_name); | 832 | struct sysfs_dirent *parent_sd = kobj->sd->s_parent; |
833 | const void *new_ns = NULL; | ||
834 | |||
835 | if (sysfs_ns_type(parent_sd)) | ||
836 | new_ns = kobj->ktype->namespace(kobj); | ||
837 | |||
838 | return sysfs_rename(kobj->sd, parent_sd, new_ns, new_name); | ||
784 | } | 839 | } |
785 | 840 | ||
786 | int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) | 841 | int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) |
787 | { | 842 | { |
788 | struct sysfs_dirent *sd = kobj->sd; | 843 | struct sysfs_dirent *sd = kobj->sd; |
789 | struct sysfs_dirent *new_parent_sd; | 844 | struct sysfs_dirent *new_parent_sd; |
845 | const void *new_ns = NULL; | ||
790 | 846 | ||
791 | BUG_ON(!sd->s_parent); | 847 | BUG_ON(!sd->s_parent); |
848 | if (sysfs_ns_type(sd->s_parent)) | ||
849 | new_ns = kobj->ktype->namespace(kobj); | ||
792 | new_parent_sd = new_parent_kobj && new_parent_kobj->sd ? | 850 | new_parent_sd = new_parent_kobj && new_parent_kobj->sd ? |
793 | new_parent_kobj->sd : &sysfs_root; | 851 | new_parent_kobj->sd : &sysfs_root; |
794 | 852 | ||
795 | return sysfs_rename(sd, new_parent_sd, sd->s_name); | 853 | return sysfs_rename(sd, new_parent_sd, new_ns, sd->s_name); |
796 | } | 854 | } |
797 | 855 | ||
798 | /* Relationship between s_mode and the DT_xxx types */ | 856 | /* Relationship between s_mode and the DT_xxx types */ |
@@ -807,32 +865,35 @@ static int sysfs_dir_release(struct inode *inode, struct file *filp) | |||
807 | return 0; | 865 | return 0; |
808 | } | 866 | } |
809 | 867 | ||
810 | static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd, | 868 | static struct sysfs_dirent *sysfs_dir_pos(const void *ns, |
811 | ino_t ino, struct sysfs_dirent *pos) | 869 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) |
812 | { | 870 | { |
813 | if (pos) { | 871 | if (pos) { |
814 | int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) && | 872 | int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) && |
815 | pos->s_parent == parent_sd && | 873 | pos->s_parent == parent_sd && |
816 | ino == pos->s_ino; | 874 | ino == pos->s_ino; |
817 | sysfs_put(pos); | 875 | sysfs_put(pos); |
818 | if (valid) | 876 | if (!valid) |
819 | return pos; | 877 | pos = NULL; |
820 | } | 878 | } |
821 | pos = NULL; | 879 | if (!pos && (ino > 1) && (ino < INT_MAX)) { |
822 | if ((ino > 1) && (ino < INT_MAX)) { | ||
823 | pos = parent_sd->s_dir.children; | 880 | pos = parent_sd->s_dir.children; |
824 | while (pos && (ino > pos->s_ino)) | 881 | while (pos && (ino > pos->s_ino)) |
825 | pos = pos->s_sibling; | 882 | pos = pos->s_sibling; |
826 | } | 883 | } |
884 | while (pos && pos->s_ns && pos->s_ns != ns) | ||
885 | pos = pos->s_sibling; | ||
827 | return pos; | 886 | return pos; |
828 | } | 887 | } |
829 | 888 | ||
830 | static struct sysfs_dirent *sysfs_dir_next_pos(struct sysfs_dirent *parent_sd, | 889 | static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns, |
831 | ino_t ino, struct sysfs_dirent *pos) | 890 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) |
832 | { | 891 | { |
833 | pos = sysfs_dir_pos(parent_sd, ino, pos); | 892 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); |
834 | if (pos) | 893 | if (pos) |
835 | pos = pos->s_sibling; | 894 | pos = pos->s_sibling; |
895 | while (pos && pos->s_ns && pos->s_ns != ns) | ||
896 | pos = pos->s_sibling; | ||
836 | return pos; | 897 | return pos; |
837 | } | 898 | } |
838 | 899 | ||
@@ -841,8 +902,13 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
841 | struct dentry *dentry = filp->f_path.dentry; | 902 | struct dentry *dentry = filp->f_path.dentry; |
842 | struct sysfs_dirent * parent_sd = dentry->d_fsdata; | 903 | struct sysfs_dirent * parent_sd = dentry->d_fsdata; |
843 | struct sysfs_dirent *pos = filp->private_data; | 904 | struct sysfs_dirent *pos = filp->private_data; |
905 | enum kobj_ns_type type; | ||
906 | const void *ns; | ||
844 | ino_t ino; | 907 | ino_t ino; |
845 | 908 | ||
909 | type = sysfs_ns_type(parent_sd); | ||
910 | ns = sysfs_info(dentry->d_sb)->ns[type]; | ||
911 | |||
846 | if (filp->f_pos == 0) { | 912 | if (filp->f_pos == 0) { |
847 | ino = parent_sd->s_ino; | 913 | ino = parent_sd->s_ino; |
848 | if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) == 0) | 914 | if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) == 0) |
@@ -857,9 +923,9 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
857 | filp->f_pos++; | 923 | filp->f_pos++; |
858 | } | 924 | } |
859 | mutex_lock(&sysfs_mutex); | 925 | mutex_lock(&sysfs_mutex); |
860 | for (pos = sysfs_dir_pos(parent_sd, filp->f_pos, pos); | 926 | for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos); |
861 | pos; | 927 | pos; |
862 | pos = sysfs_dir_next_pos(parent_sd, filp->f_pos, pos)) { | 928 | pos = sysfs_dir_next_pos(ns, parent_sd, filp->f_pos, pos)) { |
863 | const char * name; | 929 | const char * name; |
864 | unsigned int type; | 930 | unsigned int type; |
865 | int len, ret; | 931 | int len, ret; |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index e222b2582746..1beaa739d0a6 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -478,9 +478,12 @@ void sysfs_notify(struct kobject *k, const char *dir, const char *attr) | |||
478 | mutex_lock(&sysfs_mutex); | 478 | mutex_lock(&sysfs_mutex); |
479 | 479 | ||
480 | if (sd && dir) | 480 | if (sd && dir) |
481 | sd = sysfs_find_dirent(sd, dir); | 481 | /* Only directories are tagged, so no need to pass |
482 | * a tag explicitly. | ||
483 | */ | ||
484 | sd = sysfs_find_dirent(sd, NULL, dir); | ||
482 | if (sd && attr) | 485 | if (sd && attr) |
483 | sd = sysfs_find_dirent(sd, attr); | 486 | sd = sysfs_find_dirent(sd, NULL, attr); |
484 | if (sd) | 487 | if (sd) |
485 | sysfs_notify_dirent(sd); | 488 | sysfs_notify_dirent(sd); |
486 | 489 | ||
@@ -569,7 +572,7 @@ int sysfs_add_file_to_group(struct kobject *kobj, | |||
569 | int error; | 572 | int error; |
570 | 573 | ||
571 | if (group) | 574 | if (group) |
572 | dir_sd = sysfs_get_dirent(kobj->sd, group); | 575 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, group); |
573 | else | 576 | else |
574 | dir_sd = sysfs_get(kobj->sd); | 577 | dir_sd = sysfs_get(kobj->sd); |
575 | 578 | ||
@@ -599,7 +602,7 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | |||
599 | mutex_lock(&sysfs_mutex); | 602 | mutex_lock(&sysfs_mutex); |
600 | 603 | ||
601 | rc = -ENOENT; | 604 | rc = -ENOENT; |
602 | sd = sysfs_find_dirent(kobj->sd, attr->name); | 605 | sd = sysfs_find_dirent(kobj->sd, NULL, attr->name); |
603 | if (!sd) | 606 | if (!sd) |
604 | goto out; | 607 | goto out; |
605 | 608 | ||
@@ -624,7 +627,7 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file); | |||
624 | 627 | ||
625 | void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) | 628 | void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) |
626 | { | 629 | { |
627 | sysfs_hash_and_remove(kobj->sd, attr->name); | 630 | sysfs_hash_and_remove(kobj->sd, NULL, attr->name); |
628 | } | 631 | } |
629 | 632 | ||
630 | void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) | 633 | void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) |
@@ -646,11 +649,11 @@ void sysfs_remove_file_from_group(struct kobject *kobj, | |||
646 | struct sysfs_dirent *dir_sd; | 649 | struct sysfs_dirent *dir_sd; |
647 | 650 | ||
648 | if (group) | 651 | if (group) |
649 | dir_sd = sysfs_get_dirent(kobj->sd, group); | 652 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, group); |
650 | else | 653 | else |
651 | dir_sd = sysfs_get(kobj->sd); | 654 | dir_sd = sysfs_get(kobj->sd); |
652 | if (dir_sd) { | 655 | if (dir_sd) { |
653 | sysfs_hash_and_remove(dir_sd, attr->name); | 656 | sysfs_hash_and_remove(dir_sd, NULL, attr->name); |
654 | sysfs_put(dir_sd); | 657 | sysfs_put(dir_sd); |
655 | } | 658 | } |
656 | } | 659 | } |
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index fe611949a7f7..23c1e598792a 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -23,7 +23,7 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, | |||
23 | int i; | 23 | int i; |
24 | 24 | ||
25 | for (i = 0, attr = grp->attrs; *attr; i++, attr++) | 25 | for (i = 0, attr = grp->attrs; *attr; i++, attr++) |
26 | sysfs_hash_and_remove(dir_sd, (*attr)->name); | 26 | sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); |
27 | } | 27 | } |
28 | 28 | ||
29 | static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, | 29 | static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, |
@@ -39,7 +39,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, | |||
39 | * visibility. Do this by first removing then | 39 | * visibility. Do this by first removing then |
40 | * re-adding (if required) the file */ | 40 | * re-adding (if required) the file */ |
41 | if (update) | 41 | if (update) |
42 | sysfs_hash_and_remove(dir_sd, (*attr)->name); | 42 | sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); |
43 | if (grp->is_visible) { | 43 | if (grp->is_visible) { |
44 | mode = grp->is_visible(kobj, *attr, i); | 44 | mode = grp->is_visible(kobj, *attr, i); |
45 | if (!mode) | 45 | if (!mode) |
@@ -132,7 +132,7 @@ void sysfs_remove_group(struct kobject * kobj, | |||
132 | struct sysfs_dirent *sd; | 132 | struct sysfs_dirent *sd; |
133 | 133 | ||
134 | if (grp->name) { | 134 | if (grp->name) { |
135 | sd = sysfs_get_dirent(dir_sd, grp->name); | 135 | sd = sysfs_get_dirent(dir_sd, NULL, grp->name); |
136 | if (!sd) { | 136 | if (!sd) { |
137 | WARN(!sd, KERN_WARNING "sysfs group %p not found for " | 137 | WARN(!sd, KERN_WARNING "sysfs group %p not found for " |
138 | "kobject '%s'\n", grp, kobject_name(kobj)); | 138 | "kobject '%s'\n", grp, kobject_name(kobj)); |
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index a4a0a9419711..bbd77e95cf7f 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -324,7 +324,7 @@ void sysfs_delete_inode(struct inode *inode) | |||
324 | sysfs_put(sd); | 324 | sysfs_put(sd); |
325 | } | 325 | } |
326 | 326 | ||
327 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) | 327 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name) |
328 | { | 328 | { |
329 | struct sysfs_addrm_cxt acxt; | 329 | struct sysfs_addrm_cxt acxt; |
330 | struct sysfs_dirent *sd; | 330 | struct sysfs_dirent *sd; |
@@ -334,7 +334,9 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) | |||
334 | 334 | ||
335 | sysfs_addrm_start(&acxt, dir_sd); | 335 | sysfs_addrm_start(&acxt, dir_sd); |
336 | 336 | ||
337 | sd = sysfs_find_dirent(dir_sd, name); | 337 | sd = sysfs_find_dirent(dir_sd, ns, name); |
338 | if (sd && (sd->s_ns != ns)) | ||
339 | sd = NULL; | ||
338 | if (sd) | 340 | if (sd) |
339 | sysfs_remove_one(&acxt, sd); | 341 | sysfs_remove_one(&acxt, sd); |
340 | 342 | ||
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 776137828dca..281c0c9bc39f 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c | |||
@@ -35,7 +35,7 @@ static const struct super_operations sysfs_ops = { | |||
35 | struct sysfs_dirent sysfs_root = { | 35 | struct sysfs_dirent sysfs_root = { |
36 | .s_name = "", | 36 | .s_name = "", |
37 | .s_count = ATOMIC_INIT(1), | 37 | .s_count = ATOMIC_INIT(1), |
38 | .s_flags = SYSFS_DIR, | 38 | .s_flags = SYSFS_DIR | (KOBJ_NS_TYPE_NONE << SYSFS_NS_TYPE_SHIFT), |
39 | .s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 39 | .s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, |
40 | .s_ino = 1, | 40 | .s_ino = 1, |
41 | }; | 41 | }; |
@@ -72,18 +72,107 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) | |||
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | static int sysfs_test_super(struct super_block *sb, void *data) | ||
76 | { | ||
77 | struct sysfs_super_info *sb_info = sysfs_info(sb); | ||
78 | struct sysfs_super_info *info = data; | ||
79 | enum kobj_ns_type type; | ||
80 | int found = 1; | ||
81 | |||
82 | for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) { | ||
83 | if (sb_info->ns[type] != info->ns[type]) | ||
84 | found = 0; | ||
85 | } | ||
86 | return found; | ||
87 | } | ||
88 | |||
89 | static int sysfs_set_super(struct super_block *sb, void *data) | ||
90 | { | ||
91 | int error; | ||
92 | error = set_anon_super(sb, data); | ||
93 | if (!error) | ||
94 | sb->s_fs_info = data; | ||
95 | return error; | ||
96 | } | ||
97 | |||
75 | static int sysfs_get_sb(struct file_system_type *fs_type, | 98 | static int sysfs_get_sb(struct file_system_type *fs_type, |
76 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 99 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
77 | { | 100 | { |
78 | return get_sb_single(fs_type, flags, data, sysfs_fill_super, mnt); | 101 | struct sysfs_super_info *info; |
102 | enum kobj_ns_type type; | ||
103 | struct super_block *sb; | ||
104 | int error; | ||
105 | |||
106 | error = -ENOMEM; | ||
107 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
108 | if (!info) | ||
109 | goto out; | ||
110 | |||
111 | for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) | ||
112 | info->ns[type] = kobj_ns_current(type); | ||
113 | |||
114 | sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info); | ||
115 | if (IS_ERR(sb) || sb->s_fs_info != info) | ||
116 | kfree(info); | ||
117 | if (IS_ERR(sb)) { | ||
118 | error = PTR_ERR(sb); | ||
119 | goto out; | ||
120 | } | ||
121 | if (!sb->s_root) { | ||
122 | sb->s_flags = flags; | ||
123 | error = sysfs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0); | ||
124 | if (error) { | ||
125 | deactivate_locked_super(sb); | ||
126 | goto out; | ||
127 | } | ||
128 | sb->s_flags |= MS_ACTIVE; | ||
129 | } | ||
130 | |||
131 | simple_set_mnt(mnt, sb); | ||
132 | error = 0; | ||
133 | out: | ||
134 | return error; | ||
135 | } | ||
136 | |||
137 | static void sysfs_kill_sb(struct super_block *sb) | ||
138 | { | ||
139 | struct sysfs_super_info *info = sysfs_info(sb); | ||
140 | |||
141 | /* Remove the superblock from fs_supers/s_instances | ||
142 | * so we can't find it, before freeing sysfs_super_info. | ||
143 | */ | ||
144 | kill_anon_super(sb); | ||
145 | kfree(info); | ||
79 | } | 146 | } |
80 | 147 | ||
81 | static struct file_system_type sysfs_fs_type = { | 148 | static struct file_system_type sysfs_fs_type = { |
82 | .name = "sysfs", | 149 | .name = "sysfs", |
83 | .get_sb = sysfs_get_sb, | 150 | .get_sb = sysfs_get_sb, |
84 | .kill_sb = kill_anon_super, | 151 | .kill_sb = sysfs_kill_sb, |
85 | }; | 152 | }; |
86 | 153 | ||
154 | void sysfs_exit_ns(enum kobj_ns_type type, const void *ns) | ||
155 | { | ||
156 | struct super_block *sb; | ||
157 | |||
158 | mutex_lock(&sysfs_mutex); | ||
159 | spin_lock(&sb_lock); | ||
160 | list_for_each_entry(sb, &sysfs_fs_type.fs_supers, s_instances) { | ||
161 | struct sysfs_super_info *info = sysfs_info(sb); | ||
162 | /* | ||
163 | * If we see a superblock on the fs_supers/s_instances | ||
164 | * list the unmount has not completed and sb->s_fs_info | ||
165 | * points to a valid struct sysfs_super_info. | ||
166 | */ | ||
167 | /* Ignore superblocks with the wrong ns */ | ||
168 | if (info->ns[type] != ns) | ||
169 | continue; | ||
170 | info->ns[type] = NULL; | ||
171 | } | ||
172 | spin_unlock(&sb_lock); | ||
173 | mutex_unlock(&sysfs_mutex); | ||
174 | } | ||
175 | |||
87 | int __init sysfs_init(void) | 176 | int __init sysfs_init(void) |
88 | { | 177 | { |
89 | int err = -ENOMEM; | 178 | int err = -ENOMEM; |
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index 942f239a2132..f71246bebfe4 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -58,6 +58,8 @@ static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target, | |||
58 | if (!sd) | 58 | if (!sd) |
59 | goto out_put; | 59 | goto out_put; |
60 | 60 | ||
61 | if (sysfs_ns_type(parent_sd)) | ||
62 | sd->s_ns = target->ktype->namespace(target); | ||
61 | sd->s_symlink.target_sd = target_sd; | 63 | sd->s_symlink.target_sd = target_sd; |
62 | target_sd = NULL; /* reference is now owned by the symlink */ | 64 | target_sd = NULL; /* reference is now owned by the symlink */ |
63 | 65 | ||
@@ -107,6 +109,26 @@ int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target, | |||
107 | } | 109 | } |
108 | 110 | ||
109 | /** | 111 | /** |
112 | * sysfs_delete_link - remove symlink in object's directory. | ||
113 | * @kobj: object we're acting for. | ||
114 | * @targ: object we're pointing to. | ||
115 | * @name: name of the symlink to remove. | ||
116 | * | ||
117 | * Unlike sysfs_remove_link sysfs_delete_link has enough information | ||
118 | * to successfully delete symlinks in tagged directories. | ||
119 | */ | ||
120 | void sysfs_delete_link(struct kobject *kobj, struct kobject *targ, | ||
121 | const char *name) | ||
122 | { | ||
123 | const void *ns = NULL; | ||
124 | spin_lock(&sysfs_assoc_lock); | ||
125 | if (targ->sd) | ||
126 | ns = targ->sd->s_ns; | ||
127 | spin_unlock(&sysfs_assoc_lock); | ||
128 | sysfs_hash_and_remove(kobj->sd, ns, name); | ||
129 | } | ||
130 | |||
131 | /** | ||
110 | * sysfs_remove_link - remove symlink in object's directory. | 132 | * sysfs_remove_link - remove symlink in object's directory. |
111 | * @kobj: object we're acting for. | 133 | * @kobj: object we're acting for. |
112 | * @name: name of the symlink to remove. | 134 | * @name: name of the symlink to remove. |
@@ -121,7 +143,7 @@ void sysfs_remove_link(struct kobject * kobj, const char * name) | |||
121 | else | 143 | else |
122 | parent_sd = kobj->sd; | 144 | parent_sd = kobj->sd; |
123 | 145 | ||
124 | sysfs_hash_and_remove(parent_sd, name); | 146 | sysfs_hash_and_remove(parent_sd, NULL, name); |
125 | } | 147 | } |
126 | 148 | ||
127 | /** | 149 | /** |
@@ -137,6 +159,7 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, | |||
137 | const char *old, const char *new) | 159 | const char *old, const char *new) |
138 | { | 160 | { |
139 | struct sysfs_dirent *parent_sd, *sd = NULL; | 161 | struct sysfs_dirent *parent_sd, *sd = NULL; |
162 | const void *old_ns = NULL, *new_ns = NULL; | ||
140 | int result; | 163 | int result; |
141 | 164 | ||
142 | if (!kobj) | 165 | if (!kobj) |
@@ -144,8 +167,11 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, | |||
144 | else | 167 | else |
145 | parent_sd = kobj->sd; | 168 | parent_sd = kobj->sd; |
146 | 169 | ||
170 | if (targ->sd) | ||
171 | old_ns = targ->sd->s_ns; | ||
172 | |||
147 | result = -ENOENT; | 173 | result = -ENOENT; |
148 | sd = sysfs_get_dirent(parent_sd, old); | 174 | sd = sysfs_get_dirent(parent_sd, old_ns, old); |
149 | if (!sd) | 175 | if (!sd) |
150 | goto out; | 176 | goto out; |
151 | 177 | ||
@@ -155,7 +181,10 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, | |||
155 | if (sd->s_symlink.target_sd->s_dir.kobj != targ) | 181 | if (sd->s_symlink.target_sd->s_dir.kobj != targ) |
156 | goto out; | 182 | goto out; |
157 | 183 | ||
158 | result = sysfs_rename(sd, parent_sd, new); | 184 | if (sysfs_ns_type(parent_sd)) |
185 | new_ns = targ->ktype->namespace(targ); | ||
186 | |||
187 | result = sysfs_rename(sd, parent_sd, new_ns, new); | ||
159 | 188 | ||
160 | out: | 189 | out: |
161 | sysfs_put(sd); | 190 | sysfs_put(sd); |
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 30f5a44fb5d3..6a13105b5594 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -58,6 +58,7 @@ struct sysfs_dirent { | |||
58 | struct sysfs_dirent *s_sibling; | 58 | struct sysfs_dirent *s_sibling; |
59 | const char *s_name; | 59 | const char *s_name; |
60 | 60 | ||
61 | const void *s_ns; /* namespace tag */ | ||
61 | union { | 62 | union { |
62 | struct sysfs_elem_dir s_dir; | 63 | struct sysfs_elem_dir s_dir; |
63 | struct sysfs_elem_symlink s_symlink; | 64 | struct sysfs_elem_symlink s_symlink; |
@@ -81,14 +82,27 @@ struct sysfs_dirent { | |||
81 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) | 82 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) |
82 | #define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) | 83 | #define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) |
83 | 84 | ||
84 | #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK | 85 | /* identify any namespace tag on sysfs_dirents */ |
85 | #define SYSFS_FLAG_REMOVED 0x0200 | 86 | #define SYSFS_NS_TYPE_MASK 0xff00 |
87 | #define SYSFS_NS_TYPE_SHIFT 8 | ||
88 | |||
89 | #define SYSFS_FLAG_MASK ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK) | ||
90 | #define SYSFS_FLAG_REMOVED 0x020000 | ||
86 | 91 | ||
87 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) | 92 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) |
88 | { | 93 | { |
89 | return sd->s_flags & SYSFS_TYPE_MASK; | 94 | return sd->s_flags & SYSFS_TYPE_MASK; |
90 | } | 95 | } |
91 | 96 | ||
97 | /* | ||
98 | * Return any namespace tags on this dirent. | ||
99 | * enum kobj_ns_type is defined in linux/kobject.h | ||
100 | */ | ||
101 | static inline enum kobj_ns_type sysfs_ns_type(struct sysfs_dirent *sd) | ||
102 | { | ||
103 | return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT; | ||
104 | } | ||
105 | |||
92 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 106 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
93 | #define sysfs_dirent_init_lockdep(sd) \ | 107 | #define sysfs_dirent_init_lockdep(sd) \ |
94 | do { \ | 108 | do { \ |
@@ -114,6 +128,16 @@ struct sysfs_addrm_cxt { | |||
114 | /* | 128 | /* |
115 | * mount.c | 129 | * mount.c |
116 | */ | 130 | */ |
131 | |||
132 | /* | ||
133 | * Each sb is associated with a set of namespace tags (i.e. | ||
134 | * the network namespace of the task which mounted this sysfs | ||
135 | * instance). | ||
136 | */ | ||
137 | struct sysfs_super_info { | ||
138 | const void *ns[KOBJ_NS_TYPES]; | ||
139 | }; | ||
140 | #define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info)) | ||
117 | extern struct sysfs_dirent sysfs_root; | 141 | extern struct sysfs_dirent sysfs_root; |
118 | extern struct kmem_cache *sysfs_dir_cachep; | 142 | extern struct kmem_cache *sysfs_dir_cachep; |
119 | 143 | ||
@@ -137,8 +161,10 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); | |||
137 | void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); | 161 | void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); |
138 | 162 | ||
139 | struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | 163 | struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, |
164 | const void *ns, | ||
140 | const unsigned char *name); | 165 | const unsigned char *name); |
141 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | 166 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, |
167 | const void *ns, | ||
142 | const unsigned char *name); | 168 | const unsigned char *name); |
143 | struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); | 169 | struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); |
144 | 170 | ||
@@ -149,7 +175,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name, | |||
149 | void sysfs_remove_subdir(struct sysfs_dirent *sd); | 175 | void sysfs_remove_subdir(struct sysfs_dirent *sd); |
150 | 176 | ||
151 | int sysfs_rename(struct sysfs_dirent *sd, | 177 | int sysfs_rename(struct sysfs_dirent *sd, |
152 | struct sysfs_dirent *new_parent_sd, const char *new_name); | 178 | struct sysfs_dirent *new_parent_sd, const void *ns, const char *new_name); |
153 | 179 | ||
154 | static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) | 180 | static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) |
155 | { | 181 | { |
@@ -179,7 +205,7 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); | |||
179 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); | 205 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); |
180 | int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 206 | int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
181 | size_t size, int flags); | 207 | size_t size, int flags); |
182 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); | 208 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name); |
183 | int sysfs_inode_init(void); | 209 | int sysfs_inode_init(void); |
184 | 210 | ||
185 | /* | 211 | /* |
diff --git a/include/linux/device.h b/include/linux/device.h index 241b96bcd7ad..7bb9f426f3e6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
25 | #include <linux/semaphore.h> | ||
26 | #include <asm/atomic.h> | 25 | #include <asm/atomic.h> |
27 | #include <asm/device.h> | 26 | #include <asm/device.h> |
28 | 27 | ||
@@ -203,6 +202,9 @@ struct class { | |||
203 | int (*suspend)(struct device *dev, pm_message_t state); | 202 | int (*suspend)(struct device *dev, pm_message_t state); |
204 | int (*resume)(struct device *dev); | 203 | int (*resume)(struct device *dev); |
205 | 204 | ||
205 | const struct kobj_ns_type_operations *ns_type; | ||
206 | const void *(*namespace)(struct device *dev); | ||
207 | |||
206 | const struct dev_pm_ops *pm; | 208 | const struct dev_pm_ops *pm; |
207 | 209 | ||
208 | struct class_private *p; | 210 | struct class_private *p; |
@@ -404,7 +406,7 @@ struct device { | |||
404 | const char *init_name; /* initial name of the device */ | 406 | const char *init_name; /* initial name of the device */ |
405 | struct device_type *type; | 407 | struct device_type *type; |
406 | 408 | ||
407 | struct semaphore sem; /* semaphore to synchronize calls to | 409 | struct mutex mutex; /* mutex to synchronize calls to |
408 | * its driver. | 410 | * its driver. |
409 | */ | 411 | */ |
410 | 412 | ||
@@ -514,17 +516,17 @@ static inline bool device_async_suspend_enabled(struct device *dev) | |||
514 | 516 | ||
515 | static inline void device_lock(struct device *dev) | 517 | static inline void device_lock(struct device *dev) |
516 | { | 518 | { |
517 | down(&dev->sem); | 519 | mutex_lock(&dev->mutex); |
518 | } | 520 | } |
519 | 521 | ||
520 | static inline int device_trylock(struct device *dev) | 522 | static inline int device_trylock(struct device *dev) |
521 | { | 523 | { |
522 | return down_trylock(&dev->sem); | 524 | return mutex_trylock(&dev->mutex); |
523 | } | 525 | } |
524 | 526 | ||
525 | static inline void device_unlock(struct device *dev) | 527 | static inline void device_unlock(struct device *dev) |
526 | { | 528 | { |
527 | up(&dev->sem); | 529 | mutex_unlock(&dev->mutex); |
528 | } | 530 | } |
529 | 531 | ||
530 | void driver_init(void); | 532 | void driver_init(void); |
diff --git a/include/linux/firmware.h b/include/linux/firmware.h index 043811f0d277..53d1e6c4f848 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h | |||
@@ -12,6 +12,7 @@ | |||
12 | struct firmware { | 12 | struct firmware { |
13 | size_t size; | 13 | size_t size; |
14 | const u8 *data; | 14 | const u8 *data; |
15 | struct page **pages; | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | struct device; | 18 | struct device; |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 3950d3c2850d..cf343a852534 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -108,6 +108,8 @@ struct kobj_type { | |||
108 | void (*release)(struct kobject *kobj); | 108 | void (*release)(struct kobject *kobj); |
109 | const struct sysfs_ops *sysfs_ops; | 109 | const struct sysfs_ops *sysfs_ops; |
110 | struct attribute **default_attrs; | 110 | struct attribute **default_attrs; |
111 | const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj); | ||
112 | const void *(*namespace)(struct kobject *kobj); | ||
111 | }; | 113 | }; |
112 | 114 | ||
113 | struct kobj_uevent_env { | 115 | struct kobj_uevent_env { |
@@ -134,6 +136,42 @@ struct kobj_attribute { | |||
134 | 136 | ||
135 | extern const struct sysfs_ops kobj_sysfs_ops; | 137 | extern const struct sysfs_ops kobj_sysfs_ops; |
136 | 138 | ||
139 | /* | ||
140 | * Namespace types which are used to tag kobjects and sysfs entries. | ||
141 | * Network namespace will likely be the first. | ||
142 | */ | ||
143 | enum kobj_ns_type { | ||
144 | KOBJ_NS_TYPE_NONE = 0, | ||
145 | KOBJ_NS_TYPE_NET, | ||
146 | KOBJ_NS_TYPES | ||
147 | }; | ||
148 | |||
149 | struct sock; | ||
150 | |||
151 | /* | ||
152 | * Callbacks so sysfs can determine namespaces | ||
153 | * @current_ns: return calling task's namespace | ||
154 | * @netlink_ns: return namespace to which a sock belongs (right?) | ||
155 | * @initial_ns: return the initial namespace (i.e. init_net_ns) | ||
156 | */ | ||
157 | struct kobj_ns_type_operations { | ||
158 | enum kobj_ns_type type; | ||
159 | const void *(*current_ns)(void); | ||
160 | const void *(*netlink_ns)(struct sock *sk); | ||
161 | const void *(*initial_ns)(void); | ||
162 | }; | ||
163 | |||
164 | int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); | ||
165 | int kobj_ns_type_registered(enum kobj_ns_type type); | ||
166 | const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent); | ||
167 | const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj); | ||
168 | |||
169 | const void *kobj_ns_current(enum kobj_ns_type type); | ||
170 | const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk); | ||
171 | const void *kobj_ns_initial(enum kobj_ns_type type); | ||
172 | void kobj_ns_exit(enum kobj_ns_type type, const void *ns); | ||
173 | |||
174 | |||
137 | /** | 175 | /** |
138 | * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. | 176 | * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. |
139 | * | 177 | * |
diff --git a/include/linux/kref.h b/include/linux/kref.h index baf4b9e4b194..6cc38fc07ab7 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h | |||
@@ -21,7 +21,6 @@ struct kref { | |||
21 | atomic_t refcount; | 21 | atomic_t refcount; |
22 | }; | 22 | }; |
23 | 23 | ||
24 | void kref_set(struct kref *kref, int num); | ||
25 | void kref_init(struct kref *kref); | 24 | void kref_init(struct kref *kref); |
26 | void kref_get(struct kref *kref); | 25 | void kref_get(struct kref *kref); |
27 | int kref_put(struct kref *kref, void (*release) (struct kref *kref)); | 26 | int kref_put(struct kref *kref, void (*release) (struct kref *kref)); |
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index a03977a96d7e..06aed8305bf3 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h | |||
@@ -44,6 +44,8 @@ struct lock_class_key { | |||
44 | struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; | 44 | struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | extern struct lock_class_key __lockdep_no_validate__; | ||
48 | |||
47 | #define LOCKSTAT_POINTS 4 | 49 | #define LOCKSTAT_POINTS 4 |
48 | 50 | ||
49 | /* | 51 | /* |
@@ -270,6 +272,9 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name, | |||
270 | #define lockdep_set_subclass(lock, sub) \ | 272 | #define lockdep_set_subclass(lock, sub) \ |
271 | lockdep_init_map(&(lock)->dep_map, #lock, \ | 273 | lockdep_init_map(&(lock)->dep_map, #lock, \ |
272 | (lock)->dep_map.key, sub) | 274 | (lock)->dep_map.key, sub) |
275 | |||
276 | #define lockdep_set_novalidate_class(lock) \ | ||
277 | lockdep_set_class(lock, &__lockdep_no_validate__) | ||
273 | /* | 278 | /* |
274 | * Compare locking classes | 279 | * Compare locking classes |
275 | */ | 280 | */ |
@@ -354,6 +359,9 @@ static inline void lockdep_on(void) | |||
354 | #define lockdep_set_class_and_subclass(lock, key, sub) \ | 359 | #define lockdep_set_class_and_subclass(lock, key, sub) \ |
355 | do { (void)(key); } while (0) | 360 | do { (void)(key); } while (0) |
356 | #define lockdep_set_subclass(lock, sub) do { } while (0) | 361 | #define lockdep_set_subclass(lock, sub) do { } while (0) |
362 | |||
363 | #define lockdep_set_novalidate_class(lock) do { } while (0) | ||
364 | |||
357 | /* | 365 | /* |
358 | * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP | 366 | * We don't define lockdep_match_class() and lockdep_match_key() for !LOCKDEP |
359 | * case since the result is not well defined and the caller should rather | 367 | * case since the result is not well defined and the caller should rather |
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 6eaca5e1e8ca..59d066936ab9 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h | |||
@@ -188,6 +188,10 @@ extern int netlink_has_listeners(struct sock *sk, unsigned int group); | |||
188 | extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock); | 188 | extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock); |
189 | extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid, | 189 | extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid, |
190 | __u32 group, gfp_t allocation); | 190 | __u32 group, gfp_t allocation); |
191 | extern int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, | ||
192 | __u32 pid, __u32 group, gfp_t allocation, | ||
193 | int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data), | ||
194 | void *filter_data); | ||
191 | extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code); | 195 | extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code); |
192 | extern int netlink_register_notifier(struct notifier_block *nb); | 196 | extern int netlink_register_notifier(struct notifier_block *nb); |
193 | extern int netlink_unregister_notifier(struct notifier_block *nb); | 197 | extern int netlink_unregister_notifier(struct notifier_block *nb); |
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h index 4e768dda87b0..8600508c77a6 100644 --- a/include/linux/ramfs.h +++ b/include/linux/ramfs.h | |||
@@ -20,4 +20,6 @@ extern const struct file_operations ramfs_file_operations; | |||
20 | extern const struct vm_operations_struct generic_file_vm_ops; | 20 | extern const struct vm_operations_struct generic_file_vm_ops; |
21 | extern int __init init_rootfs(void); | 21 | extern int __init init_rootfs(void); |
22 | 22 | ||
23 | int ramfs_fill_super(struct super_block *sb, void *data, int silent); | ||
24 | |||
23 | #endif | 25 | #endif |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f0496b3d1811..f2694eb4dd3d 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | struct kobject; | 21 | struct kobject; |
22 | struct module; | 22 | struct module; |
23 | enum kobj_ns_type; | ||
23 | 24 | ||
24 | /* FIXME | 25 | /* FIXME |
25 | * The *owner field is no longer used. | 26 | * The *owner field is no longer used. |
@@ -86,17 +87,18 @@ struct attribute_group { | |||
86 | 87 | ||
87 | #define attr_name(_attr) (_attr).attr.name | 88 | #define attr_name(_attr) (_attr).attr.name |
88 | 89 | ||
90 | struct file; | ||
89 | struct vm_area_struct; | 91 | struct vm_area_struct; |
90 | 92 | ||
91 | struct bin_attribute { | 93 | struct bin_attribute { |
92 | struct attribute attr; | 94 | struct attribute attr; |
93 | size_t size; | 95 | size_t size; |
94 | void *private; | 96 | void *private; |
95 | ssize_t (*read)(struct kobject *, struct bin_attribute *, | 97 | ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, |
96 | char *, loff_t, size_t); | 98 | char *, loff_t, size_t); |
97 | ssize_t (*write)(struct kobject *, struct bin_attribute *, | 99 | ssize_t (*write)(struct file *,struct kobject *, struct bin_attribute *, |
98 | char *, loff_t, size_t); | 100 | char *, loff_t, size_t); |
99 | int (*mmap)(struct kobject *, struct bin_attribute *attr, | 101 | int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr, |
100 | struct vm_area_struct *vma); | 102 | struct vm_area_struct *vma); |
101 | }; | 103 | }; |
102 | 104 | ||
@@ -154,6 +156,9 @@ void sysfs_remove_link(struct kobject *kobj, const char *name); | |||
154 | int sysfs_rename_link(struct kobject *kobj, struct kobject *target, | 156 | int sysfs_rename_link(struct kobject *kobj, struct kobject *target, |
155 | const char *old_name, const char *new_name); | 157 | const char *old_name, const char *new_name); |
156 | 158 | ||
159 | void sysfs_delete_link(struct kobject *dir, struct kobject *targ, | ||
160 | const char *name); | ||
161 | |||
157 | int __must_check sysfs_create_group(struct kobject *kobj, | 162 | int __must_check sysfs_create_group(struct kobject *kobj, |
158 | const struct attribute_group *grp); | 163 | const struct attribute_group *grp); |
159 | int sysfs_update_group(struct kobject *kobj, | 164 | int sysfs_update_group(struct kobject *kobj, |
@@ -168,10 +173,15 @@ void sysfs_remove_file_from_group(struct kobject *kobj, | |||
168 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); | 173 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); |
169 | void sysfs_notify_dirent(struct sysfs_dirent *sd); | 174 | void sysfs_notify_dirent(struct sysfs_dirent *sd); |
170 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | 175 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, |
176 | const void *ns, | ||
171 | const unsigned char *name); | 177 | const unsigned char *name); |
172 | struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); | 178 | struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); |
173 | void sysfs_put(struct sysfs_dirent *sd); | 179 | void sysfs_put(struct sysfs_dirent *sd); |
174 | void sysfs_printk_last_file(void); | 180 | void sysfs_printk_last_file(void); |
181 | |||
182 | /* Called to clear a ns tag when it is no longer valid */ | ||
183 | void sysfs_exit_ns(enum kobj_ns_type type, const void *tag); | ||
184 | |||
175 | int __must_check sysfs_init(void); | 185 | int __must_check sysfs_init(void); |
176 | 186 | ||
177 | #else /* CONFIG_SYSFS */ | 187 | #else /* CONFIG_SYSFS */ |
@@ -264,6 +274,11 @@ static inline int sysfs_rename_link(struct kobject *k, struct kobject *t, | |||
264 | return 0; | 274 | return 0; |
265 | } | 275 | } |
266 | 276 | ||
277 | static inline void sysfs_delete_link(struct kobject *k, struct kobject *t, | ||
278 | const char *name) | ||
279 | { | ||
280 | } | ||
281 | |||
267 | static inline int sysfs_create_group(struct kobject *kobj, | 282 | static inline int sysfs_create_group(struct kobject *kobj, |
268 | const struct attribute_group *grp) | 283 | const struct attribute_group *grp) |
269 | { | 284 | { |
@@ -301,6 +316,7 @@ static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) | |||
301 | } | 316 | } |
302 | static inline | 317 | static inline |
303 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | 318 | struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, |
319 | const void *ns, | ||
304 | const unsigned char *name) | 320 | const unsigned char *name) |
305 | { | 321 | { |
306 | return NULL; | 322 | return NULL; |
@@ -313,6 +329,10 @@ static inline void sysfs_put(struct sysfs_dirent *sd) | |||
313 | { | 329 | { |
314 | } | 330 | } |
315 | 331 | ||
332 | static inline void sysfs_exit_ns(int type, const void *tag) | ||
333 | { | ||
334 | } | ||
335 | |||
316 | static inline int __must_check sysfs_init(void) | 336 | static inline int __must_check sysfs_init(void) |
317 | { | 337 | { |
318 | return 0; | 338 | return 0; |
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 21fe3c426948..0b624e791805 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c | |||
@@ -138,7 +138,8 @@ extern const void __start_notes __attribute__((weak)); | |||
138 | extern const void __stop_notes __attribute__((weak)); | 138 | extern const void __stop_notes __attribute__((weak)); |
139 | #define notes_size (&__stop_notes - &__start_notes) | 139 | #define notes_size (&__stop_notes - &__start_notes) |
140 | 140 | ||
141 | static ssize_t notes_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 141 | static ssize_t notes_read(struct file *filp, struct kobject *kobj, |
142 | struct bin_attribute *bin_attr, | ||
142 | char *buf, loff_t off, size_t count) | 143 | char *buf, loff_t off, size_t count) |
143 | { | 144 | { |
144 | memcpy(buf, &__start_notes + off, count); | 145 | memcpy(buf, &__start_notes + off, count); |
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index ec21304856d1..54286798c37b 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -2711,6 +2711,8 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name, | |||
2711 | } | 2711 | } |
2712 | EXPORT_SYMBOL_GPL(lockdep_init_map); | 2712 | EXPORT_SYMBOL_GPL(lockdep_init_map); |
2713 | 2713 | ||
2714 | struct lock_class_key __lockdep_no_validate__; | ||
2715 | |||
2714 | /* | 2716 | /* |
2715 | * This gets called for every mutex_lock*()/spin_lock*() operation. | 2717 | * This gets called for every mutex_lock*()/spin_lock*() operation. |
2716 | * We maintain the dependency maps and validate the locking attempt: | 2718 | * We maintain the dependency maps and validate the locking attempt: |
@@ -2745,6 +2747,9 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
2745 | return 0; | 2747 | return 0; |
2746 | } | 2748 | } |
2747 | 2749 | ||
2750 | if (lock->key == &__lockdep_no_validate__) | ||
2751 | check = 1; | ||
2752 | |||
2748 | if (!subclass) | 2753 | if (!subclass) |
2749 | class = lock->class_cache; | 2754 | class = lock->class_cache; |
2750 | /* | 2755 | /* |
diff --git a/kernel/module.c b/kernel/module.c index e2564580f3f1..5e14483768bb 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1182,7 +1182,7 @@ struct module_notes_attrs { | |||
1182 | struct bin_attribute attrs[0]; | 1182 | struct bin_attribute attrs[0]; |
1183 | }; | 1183 | }; |
1184 | 1184 | ||
1185 | static ssize_t module_notes_read(struct kobject *kobj, | 1185 | static ssize_t module_notes_read(struct file *filp, struct kobject *kobj, |
1186 | struct bin_attribute *bin_attr, | 1186 | struct bin_attribute *bin_attr, |
1187 | char *buf, loff_t pos, size_t count) | 1187 | char *buf, loff_t pos, size_t count) |
1188 | { | 1188 | { |
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 076c7c8215b0..b2d70d38dff4 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
@@ -54,8 +54,8 @@ int create_user_ns(struct cred *new) | |||
54 | #endif | 54 | #endif |
55 | /* tgcred will be cleared in our caller bc CLONE_THREAD won't be set */ | 55 | /* tgcred will be cleared in our caller bc CLONE_THREAD won't be set */ |
56 | 56 | ||
57 | /* alloc_uid() incremented the userns refcount. Just set it to 1 */ | 57 | /* root_user holds a reference to ns, our reference can be dropped */ |
58 | kref_set(&ns->kref, 1); | 58 | put_user_ns(ns); |
59 | 59 | ||
60 | return 0; | 60 | return 0; |
61 | } | 61 | } |
diff --git a/lib/kobject.c b/lib/kobject.c index 8115eb1bbf4d..f07c57252e82 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -850,6 +850,121 @@ struct kset *kset_create_and_add(const char *name, | |||
850 | } | 850 | } |
851 | EXPORT_SYMBOL_GPL(kset_create_and_add); | 851 | EXPORT_SYMBOL_GPL(kset_create_and_add); |
852 | 852 | ||
853 | |||
854 | static DEFINE_SPINLOCK(kobj_ns_type_lock); | ||
855 | static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES]; | ||
856 | |||
857 | int kobj_ns_type_register(const struct kobj_ns_type_operations *ops) | ||
858 | { | ||
859 | enum kobj_ns_type type = ops->type; | ||
860 | int error; | ||
861 | |||
862 | spin_lock(&kobj_ns_type_lock); | ||
863 | |||
864 | error = -EINVAL; | ||
865 | if (type >= KOBJ_NS_TYPES) | ||
866 | goto out; | ||
867 | |||
868 | error = -EINVAL; | ||
869 | if (type <= KOBJ_NS_TYPE_NONE) | ||
870 | goto out; | ||
871 | |||
872 | error = -EBUSY; | ||
873 | if (kobj_ns_ops_tbl[type]) | ||
874 | goto out; | ||
875 | |||
876 | error = 0; | ||
877 | kobj_ns_ops_tbl[type] = ops; | ||
878 | |||
879 | out: | ||
880 | spin_unlock(&kobj_ns_type_lock); | ||
881 | return error; | ||
882 | } | ||
883 | |||
884 | int kobj_ns_type_registered(enum kobj_ns_type type) | ||
885 | { | ||
886 | int registered = 0; | ||
887 | |||
888 | spin_lock(&kobj_ns_type_lock); | ||
889 | if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES)) | ||
890 | registered = kobj_ns_ops_tbl[type] != NULL; | ||
891 | spin_unlock(&kobj_ns_type_lock); | ||
892 | |||
893 | return registered; | ||
894 | } | ||
895 | |||
896 | const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent) | ||
897 | { | ||
898 | const struct kobj_ns_type_operations *ops = NULL; | ||
899 | |||
900 | if (parent && parent->ktype->child_ns_type) | ||
901 | ops = parent->ktype->child_ns_type(parent); | ||
902 | |||
903 | return ops; | ||
904 | } | ||
905 | |||
906 | const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj) | ||
907 | { | ||
908 | return kobj_child_ns_ops(kobj->parent); | ||
909 | } | ||
910 | |||
911 | |||
912 | const void *kobj_ns_current(enum kobj_ns_type type) | ||
913 | { | ||
914 | const void *ns = NULL; | ||
915 | |||
916 | spin_lock(&kobj_ns_type_lock); | ||
917 | if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && | ||
918 | kobj_ns_ops_tbl[type]) | ||
919 | ns = kobj_ns_ops_tbl[type]->current_ns(); | ||
920 | spin_unlock(&kobj_ns_type_lock); | ||
921 | |||
922 | return ns; | ||
923 | } | ||
924 | |||
925 | const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk) | ||
926 | { | ||
927 | const void *ns = NULL; | ||
928 | |||
929 | spin_lock(&kobj_ns_type_lock); | ||
930 | if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && | ||
931 | kobj_ns_ops_tbl[type]) | ||
932 | ns = kobj_ns_ops_tbl[type]->netlink_ns(sk); | ||
933 | spin_unlock(&kobj_ns_type_lock); | ||
934 | |||
935 | return ns; | ||
936 | } | ||
937 | |||
938 | const void *kobj_ns_initial(enum kobj_ns_type type) | ||
939 | { | ||
940 | const void *ns = NULL; | ||
941 | |||
942 | spin_lock(&kobj_ns_type_lock); | ||
943 | if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && | ||
944 | kobj_ns_ops_tbl[type]) | ||
945 | ns = kobj_ns_ops_tbl[type]->initial_ns(); | ||
946 | spin_unlock(&kobj_ns_type_lock); | ||
947 | |||
948 | return ns; | ||
949 | } | ||
950 | |||
951 | /* | ||
952 | * kobj_ns_exit - invalidate a namespace tag | ||
953 | * | ||
954 | * @type: the namespace type (i.e. KOBJ_NS_TYPE_NET) | ||
955 | * @ns: the actual namespace being invalidated | ||
956 | * | ||
957 | * This is called when a tag is no longer valid. For instance, | ||
958 | * when a network namespace exits, it uses this helper to | ||
959 | * make sure no sb's sysfs_info points to the now-invalidated | ||
960 | * netns. | ||
961 | */ | ||
962 | void kobj_ns_exit(enum kobj_ns_type type, const void *ns) | ||
963 | { | ||
964 | sysfs_exit_ns(type, ns); | ||
965 | } | ||
966 | |||
967 | |||
853 | EXPORT_SYMBOL(kobject_get); | 968 | EXPORT_SYMBOL(kobject_get); |
854 | EXPORT_SYMBOL(kobject_put); | 969 | EXPORT_SYMBOL(kobject_put); |
855 | EXPORT_SYMBOL(kobject_del); | 970 | EXPORT_SYMBOL(kobject_del); |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 7b48d44ced6e..59c15511d58a 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
@@ -19,18 +19,24 @@ | |||
19 | #include <linux/kobject.h> | 19 | #include <linux/kobject.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | 22 | #include <linux/user_namespace.h> | |
23 | #include <linux/socket.h> | 23 | #include <linux/socket.h> |
24 | #include <linux/skbuff.h> | 24 | #include <linux/skbuff.h> |
25 | #include <linux/netlink.h> | 25 | #include <linux/netlink.h> |
26 | #include <net/sock.h> | 26 | #include <net/sock.h> |
27 | #include <net/net_namespace.h> | ||
27 | 28 | ||
28 | 29 | ||
29 | u64 uevent_seqnum; | 30 | u64 uevent_seqnum; |
30 | char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; | 31 | char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; |
31 | static DEFINE_SPINLOCK(sequence_lock); | 32 | static DEFINE_SPINLOCK(sequence_lock); |
32 | #if defined(CONFIG_NET) | 33 | #ifdef CONFIG_NET |
33 | static struct sock *uevent_sock; | 34 | struct uevent_sock { |
35 | struct list_head list; | ||
36 | struct sock *sk; | ||
37 | }; | ||
38 | static LIST_HEAD(uevent_sock_list); | ||
39 | static DEFINE_MUTEX(uevent_sock_mutex); | ||
34 | #endif | 40 | #endif |
35 | 41 | ||
36 | /* the strings here must match the enum in include/linux/kobject.h */ | 42 | /* the strings here must match the enum in include/linux/kobject.h */ |
@@ -77,6 +83,37 @@ out: | |||
77 | return ret; | 83 | return ret; |
78 | } | 84 | } |
79 | 85 | ||
86 | static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data) | ||
87 | { | ||
88 | struct kobject *kobj = data; | ||
89 | const struct kobj_ns_type_operations *ops; | ||
90 | |||
91 | ops = kobj_ns_ops(kobj); | ||
92 | if (ops) { | ||
93 | const void *sock_ns, *ns; | ||
94 | ns = kobj->ktype->namespace(kobj); | ||
95 | sock_ns = ops->netlink_ns(dsk); | ||
96 | return sock_ns != ns; | ||
97 | } | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static int kobj_usermode_filter(struct kobject *kobj) | ||
103 | { | ||
104 | const struct kobj_ns_type_operations *ops; | ||
105 | |||
106 | ops = kobj_ns_ops(kobj); | ||
107 | if (ops) { | ||
108 | const void *init_ns, *ns; | ||
109 | ns = kobj->ktype->namespace(kobj); | ||
110 | init_ns = ops->initial_ns(); | ||
111 | return ns != init_ns; | ||
112 | } | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
80 | /** | 117 | /** |
81 | * kobject_uevent_env - send an uevent with environmental data | 118 | * kobject_uevent_env - send an uevent with environmental data |
82 | * | 119 | * |
@@ -100,6 +137,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
100 | u64 seq; | 137 | u64 seq; |
101 | int i = 0; | 138 | int i = 0; |
102 | int retval = 0; | 139 | int retval = 0; |
140 | #ifdef CONFIG_NET | ||
141 | struct uevent_sock *ue_sk; | ||
142 | #endif | ||
103 | 143 | ||
104 | pr_debug("kobject: '%s' (%p): %s\n", | 144 | pr_debug("kobject: '%s' (%p): %s\n", |
105 | kobject_name(kobj), kobj, __func__); | 145 | kobject_name(kobj), kobj, __func__); |
@@ -211,7 +251,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
211 | 251 | ||
212 | #if defined(CONFIG_NET) | 252 | #if defined(CONFIG_NET) |
213 | /* send netlink message */ | 253 | /* send netlink message */ |
214 | if (uevent_sock) { | 254 | mutex_lock(&uevent_sock_mutex); |
255 | list_for_each_entry(ue_sk, &uevent_sock_list, list) { | ||
256 | struct sock *uevent_sock = ue_sk->sk; | ||
215 | struct sk_buff *skb; | 257 | struct sk_buff *skb; |
216 | size_t len; | 258 | size_t len; |
217 | 259 | ||
@@ -233,18 +275,21 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
233 | } | 275 | } |
234 | 276 | ||
235 | NETLINK_CB(skb).dst_group = 1; | 277 | NETLINK_CB(skb).dst_group = 1; |
236 | retval = netlink_broadcast(uevent_sock, skb, 0, 1, | 278 | retval = netlink_broadcast_filtered(uevent_sock, skb, |
237 | GFP_KERNEL); | 279 | 0, 1, GFP_KERNEL, |
280 | kobj_bcast_filter, | ||
281 | kobj); | ||
238 | /* ENOBUFS should be handled in userspace */ | 282 | /* ENOBUFS should be handled in userspace */ |
239 | if (retval == -ENOBUFS) | 283 | if (retval == -ENOBUFS) |
240 | retval = 0; | 284 | retval = 0; |
241 | } else | 285 | } else |
242 | retval = -ENOMEM; | 286 | retval = -ENOMEM; |
243 | } | 287 | } |
288 | mutex_unlock(&uevent_sock_mutex); | ||
244 | #endif | 289 | #endif |
245 | 290 | ||
246 | /* call uevent_helper, usually only enabled during early boot */ | 291 | /* call uevent_helper, usually only enabled during early boot */ |
247 | if (uevent_helper[0]) { | 292 | if (uevent_helper[0] && !kobj_usermode_filter(kobj)) { |
248 | char *argv [3]; | 293 | char *argv [3]; |
249 | 294 | ||
250 | argv [0] = uevent_helper; | 295 | argv [0] = uevent_helper; |
@@ -320,18 +365,58 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) | |||
320 | EXPORT_SYMBOL_GPL(add_uevent_var); | 365 | EXPORT_SYMBOL_GPL(add_uevent_var); |
321 | 366 | ||
322 | #if defined(CONFIG_NET) | 367 | #if defined(CONFIG_NET) |
323 | static int __init kobject_uevent_init(void) | 368 | static int uevent_net_init(struct net *net) |
324 | { | 369 | { |
325 | uevent_sock = netlink_kernel_create(&init_net, NETLINK_KOBJECT_UEVENT, | 370 | struct uevent_sock *ue_sk; |
326 | 1, NULL, NULL, THIS_MODULE); | 371 | |
327 | if (!uevent_sock) { | 372 | ue_sk = kzalloc(sizeof(*ue_sk), GFP_KERNEL); |
373 | if (!ue_sk) | ||
374 | return -ENOMEM; | ||
375 | |||
376 | ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, | ||
377 | 1, NULL, NULL, THIS_MODULE); | ||
378 | if (!ue_sk->sk) { | ||
328 | printk(KERN_ERR | 379 | printk(KERN_ERR |
329 | "kobject_uevent: unable to create netlink socket!\n"); | 380 | "kobject_uevent: unable to create netlink socket!\n"); |
330 | return -ENODEV; | 381 | return -ENODEV; |
331 | } | 382 | } |
332 | netlink_set_nonroot(NETLINK_KOBJECT_UEVENT, NL_NONROOT_RECV); | 383 | mutex_lock(&uevent_sock_mutex); |
384 | list_add_tail(&ue_sk->list, &uevent_sock_list); | ||
385 | mutex_unlock(&uevent_sock_mutex); | ||
333 | return 0; | 386 | return 0; |
334 | } | 387 | } |
335 | 388 | ||
389 | static void uevent_net_exit(struct net *net) | ||
390 | { | ||
391 | struct uevent_sock *ue_sk; | ||
392 | |||
393 | mutex_lock(&uevent_sock_mutex); | ||
394 | list_for_each_entry(ue_sk, &uevent_sock_list, list) { | ||
395 | if (sock_net(ue_sk->sk) == net) | ||
396 | goto found; | ||
397 | } | ||
398 | mutex_unlock(&uevent_sock_mutex); | ||
399 | return; | ||
400 | |||
401 | found: | ||
402 | list_del(&ue_sk->list); | ||
403 | mutex_unlock(&uevent_sock_mutex); | ||
404 | |||
405 | netlink_kernel_release(ue_sk->sk); | ||
406 | kfree(ue_sk); | ||
407 | } | ||
408 | |||
409 | static struct pernet_operations uevent_net_ops = { | ||
410 | .init = uevent_net_init, | ||
411 | .exit = uevent_net_exit, | ||
412 | }; | ||
413 | |||
414 | static int __init kobject_uevent_init(void) | ||
415 | { | ||
416 | netlink_set_nonroot(NETLINK_KOBJECT_UEVENT, NL_NONROOT_RECV); | ||
417 | return register_pernet_subsys(&uevent_net_ops); | ||
418 | } | ||
419 | |||
420 | |||
336 | postcore_initcall(kobject_uevent_init); | 421 | postcore_initcall(kobject_uevent_init); |
337 | #endif | 422 | #endif |
diff --git a/lib/kref.c b/lib/kref.c index 6d19f690380b..d3d227a08a4b 100644 --- a/lib/kref.c +++ b/lib/kref.c | |||
@@ -16,23 +16,13 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * kref_set - initialize object and set refcount to requested number. | ||
20 | * @kref: object in question. | ||
21 | * @num: initial reference counter | ||
22 | */ | ||
23 | void kref_set(struct kref *kref, int num) | ||
24 | { | ||
25 | atomic_set(&kref->refcount, num); | ||
26 | smp_mb(); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * kref_init - initialize object. | 19 | * kref_init - initialize object. |
31 | * @kref: object in question. | 20 | * @kref: object in question. |
32 | */ | 21 | */ |
33 | void kref_init(struct kref *kref) | 22 | void kref_init(struct kref *kref) |
34 | { | 23 | { |
35 | kref_set(kref, 1); | 24 | atomic_set(&kref->refcount, 1); |
25 | smp_mb(); | ||
36 | } | 26 | } |
37 | 27 | ||
38 | /** | 28 | /** |
@@ -72,7 +62,6 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref)) | |||
72 | return 0; | 62 | return 0; |
73 | } | 63 | } |
74 | 64 | ||
75 | EXPORT_SYMBOL(kref_set); | ||
76 | EXPORT_SYMBOL(kref_init); | 65 | EXPORT_SYMBOL(kref_init); |
77 | EXPORT_SYMBOL(kref_get); | 66 | EXPORT_SYMBOL(kref_get); |
78 | EXPORT_SYMBOL(kref_put); | 67 | EXPORT_SYMBOL(kref_put); |
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index dd321e39e621..486b8f3861d2 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c | |||
@@ -659,7 +659,7 @@ static struct attribute_group bridge_group = { | |||
659 | * | 659 | * |
660 | * Returns the number of bytes read. | 660 | * Returns the number of bytes read. |
661 | */ | 661 | */ |
662 | static ssize_t brforward_read(struct kobject *kobj, | 662 | static ssize_t brforward_read(struct file *filp, struct kobject *kobj, |
663 | struct bin_attribute *bin_attr, | 663 | struct bin_attribute *bin_attr, |
664 | char *buf, loff_t off, size_t count) | 664 | char *buf, loff_t off, size_t count) |
665 | { | 665 | { |
diff --git a/net/core/dev.c b/net/core/dev.c index 6c820650b80f..d273e4e3ecdc 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1002,15 +1002,10 @@ int dev_change_name(struct net_device *dev, const char *newname) | |||
1002 | return err; | 1002 | return err; |
1003 | 1003 | ||
1004 | rollback: | 1004 | rollback: |
1005 | /* For now only devices in the initial network namespace | 1005 | ret = device_rename(&dev->dev, dev->name); |
1006 | * are in sysfs. | 1006 | if (ret) { |
1007 | */ | 1007 | memcpy(dev->name, oldname, IFNAMSIZ); |
1008 | if (net_eq(net, &init_net)) { | 1008 | return ret; |
1009 | ret = device_rename(&dev->dev, dev->name); | ||
1010 | if (ret) { | ||
1011 | memcpy(dev->name, oldname, IFNAMSIZ); | ||
1012 | return ret; | ||
1013 | } | ||
1014 | } | 1009 | } |
1015 | 1010 | ||
1016 | write_lock_bh(&dev_base_lock); | 1011 | write_lock_bh(&dev_base_lock); |
@@ -4994,8 +4989,6 @@ int register_netdevice(struct net_device *dev) | |||
4994 | if (dev->features & NETIF_F_SG) | 4989 | if (dev->features & NETIF_F_SG) |
4995 | dev->features |= NETIF_F_GSO; | 4990 | dev->features |= NETIF_F_GSO; |
4996 | 4991 | ||
4997 | netdev_initialize_kobject(dev); | ||
4998 | |||
4999 | ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); | 4992 | ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); |
5000 | ret = notifier_to_errno(ret); | 4993 | ret = notifier_to_errno(ret); |
5001 | if (ret) | 4994 | if (ret) |
@@ -5547,15 +5540,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
5547 | if (dev->features & NETIF_F_NETNS_LOCAL) | 5540 | if (dev->features & NETIF_F_NETNS_LOCAL) |
5548 | goto out; | 5541 | goto out; |
5549 | 5542 | ||
5550 | #ifdef CONFIG_SYSFS | ||
5551 | /* Don't allow real devices to be moved when sysfs | ||
5552 | * is enabled. | ||
5553 | */ | ||
5554 | err = -EINVAL; | ||
5555 | if (dev->dev.parent) | ||
5556 | goto out; | ||
5557 | #endif | ||
5558 | |||
5559 | /* Ensure the device has been registrered */ | 5543 | /* Ensure the device has been registrered */ |
5560 | err = -EINVAL; | 5544 | err = -EINVAL; |
5561 | if (dev->reg_state != NETREG_REGISTERED) | 5545 | if (dev->reg_state != NETREG_REGISTERED) |
@@ -5606,8 +5590,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
5606 | dev_uc_flush(dev); | 5590 | dev_uc_flush(dev); |
5607 | dev_mc_flush(dev); | 5591 | dev_mc_flush(dev); |
5608 | 5592 | ||
5609 | netdev_unregister_kobject(dev); | ||
5610 | |||
5611 | /* Actually switch the network namespace */ | 5593 | /* Actually switch the network namespace */ |
5612 | dev_net_set(dev, net); | 5594 | dev_net_set(dev, net); |
5613 | 5595 | ||
@@ -5620,7 +5602,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
5620 | } | 5602 | } |
5621 | 5603 | ||
5622 | /* Fixup kobjects */ | 5604 | /* Fixup kobjects */ |
5623 | err = netdev_register_kobject(dev); | 5605 | err = device_rename(&dev->dev, dev->name); |
5624 | WARN_ON(err); | 5606 | WARN_ON(err); |
5625 | 5607 | ||
5626 | /* Add the device back in the hashes */ | 5608 | /* Add the device back in the hashes */ |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index c57c4b228bb5..99e7052d7323 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -14,7 +14,9 @@ | |||
14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
15 | #include <linux/if_arp.h> | 15 | #include <linux/if_arp.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/nsproxy.h> | ||
17 | #include <net/sock.h> | 18 | #include <net/sock.h> |
19 | #include <net/net_namespace.h> | ||
18 | #include <linux/rtnetlink.h> | 20 | #include <linux/rtnetlink.h> |
19 | #include <linux/wireless.h> | 21 | #include <linux/wireless.h> |
20 | #include <linux/vmalloc.h> | 22 | #include <linux/vmalloc.h> |
@@ -467,6 +469,7 @@ static struct attribute_group wireless_group = { | |||
467 | .attrs = wireless_attrs, | 469 | .attrs = wireless_attrs, |
468 | }; | 470 | }; |
469 | #endif | 471 | #endif |
472 | #endif /* CONFIG_SYSFS */ | ||
470 | 473 | ||
471 | #ifdef CONFIG_RPS | 474 | #ifdef CONFIG_RPS |
472 | /* | 475 | /* |
@@ -766,7 +769,38 @@ static void rx_queue_remove_kobjects(struct net_device *net) | |||
766 | kset_unregister(net->queues_kset); | 769 | kset_unregister(net->queues_kset); |
767 | } | 770 | } |
768 | #endif /* CONFIG_RPS */ | 771 | #endif /* CONFIG_RPS */ |
769 | #endif /* CONFIG_SYSFS */ | 772 | |
773 | static const void *net_current_ns(void) | ||
774 | { | ||
775 | return current->nsproxy->net_ns; | ||
776 | } | ||
777 | |||
778 | static const void *net_initial_ns(void) | ||
779 | { | ||
780 | return &init_net; | ||
781 | } | ||
782 | |||
783 | static const void *net_netlink_ns(struct sock *sk) | ||
784 | { | ||
785 | return sock_net(sk); | ||
786 | } | ||
787 | |||
788 | static struct kobj_ns_type_operations net_ns_type_operations = { | ||
789 | .type = KOBJ_NS_TYPE_NET, | ||
790 | .current_ns = net_current_ns, | ||
791 | .netlink_ns = net_netlink_ns, | ||
792 | .initial_ns = net_initial_ns, | ||
793 | }; | ||
794 | |||
795 | static void net_kobj_ns_exit(struct net *net) | ||
796 | { | ||
797 | kobj_ns_exit(KOBJ_NS_TYPE_NET, net); | ||
798 | } | ||
799 | |||
800 | static struct pernet_operations kobj_net_ops = { | ||
801 | .exit = net_kobj_ns_exit, | ||
802 | }; | ||
803 | |||
770 | 804 | ||
771 | #ifdef CONFIG_HOTPLUG | 805 | #ifdef CONFIG_HOTPLUG |
772 | static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) | 806 | static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) |
@@ -774,9 +808,6 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) | |||
774 | struct net_device *dev = to_net_dev(d); | 808 | struct net_device *dev = to_net_dev(d); |
775 | int retval; | 809 | int retval; |
776 | 810 | ||
777 | if (!net_eq(dev_net(dev), &init_net)) | ||
778 | return 0; | ||
779 | |||
780 | /* pass interface to uevent. */ | 811 | /* pass interface to uevent. */ |
781 | retval = add_uevent_var(env, "INTERFACE=%s", dev->name); | 812 | retval = add_uevent_var(env, "INTERFACE=%s", dev->name); |
782 | if (retval) | 813 | if (retval) |
@@ -806,6 +837,13 @@ static void netdev_release(struct device *d) | |||
806 | kfree((char *)dev - dev->padded); | 837 | kfree((char *)dev - dev->padded); |
807 | } | 838 | } |
808 | 839 | ||
840 | static const void *net_namespace(struct device *d) | ||
841 | { | ||
842 | struct net_device *dev; | ||
843 | dev = container_of(d, struct net_device, dev); | ||
844 | return dev_net(dev); | ||
845 | } | ||
846 | |||
809 | static struct class net_class = { | 847 | static struct class net_class = { |
810 | .name = "net", | 848 | .name = "net", |
811 | .dev_release = netdev_release, | 849 | .dev_release = netdev_release, |
@@ -815,6 +853,8 @@ static struct class net_class = { | |||
815 | #ifdef CONFIG_HOTPLUG | 853 | #ifdef CONFIG_HOTPLUG |
816 | .dev_uevent = netdev_uevent, | 854 | .dev_uevent = netdev_uevent, |
817 | #endif | 855 | #endif |
856 | .ns_type = &net_ns_type_operations, | ||
857 | .namespace = net_namespace, | ||
818 | }; | 858 | }; |
819 | 859 | ||
820 | /* Delete sysfs entries but hold kobject reference until after all | 860 | /* Delete sysfs entries but hold kobject reference until after all |
@@ -826,9 +866,6 @@ void netdev_unregister_kobject(struct net_device * net) | |||
826 | 866 | ||
827 | kobject_get(&dev->kobj); | 867 | kobject_get(&dev->kobj); |
828 | 868 | ||
829 | if (!net_eq(dev_net(net), &init_net)) | ||
830 | return; | ||
831 | |||
832 | #ifdef CONFIG_RPS | 869 | #ifdef CONFIG_RPS |
833 | rx_queue_remove_kobjects(net); | 870 | rx_queue_remove_kobjects(net); |
834 | #endif | 871 | #endif |
@@ -843,6 +880,7 @@ int netdev_register_kobject(struct net_device *net) | |||
843 | const struct attribute_group **groups = net->sysfs_groups; | 880 | const struct attribute_group **groups = net->sysfs_groups; |
844 | int error = 0; | 881 | int error = 0; |
845 | 882 | ||
883 | device_initialize(dev); | ||
846 | dev->class = &net_class; | 884 | dev->class = &net_class; |
847 | dev->platform_data = net; | 885 | dev->platform_data = net; |
848 | dev->groups = groups; | 886 | dev->groups = groups; |
@@ -865,9 +903,6 @@ int netdev_register_kobject(struct net_device *net) | |||
865 | #endif | 903 | #endif |
866 | #endif /* CONFIG_SYSFS */ | 904 | #endif /* CONFIG_SYSFS */ |
867 | 905 | ||
868 | if (!net_eq(dev_net(net), &init_net)) | ||
869 | return 0; | ||
870 | |||
871 | error = device_add(dev); | 906 | error = device_add(dev); |
872 | if (error) | 907 | if (error) |
873 | return error; | 908 | return error; |
@@ -896,13 +931,9 @@ void netdev_class_remove_file(struct class_attribute *class_attr) | |||
896 | EXPORT_SYMBOL(netdev_class_create_file); | 931 | EXPORT_SYMBOL(netdev_class_create_file); |
897 | EXPORT_SYMBOL(netdev_class_remove_file); | 932 | EXPORT_SYMBOL(netdev_class_remove_file); |
898 | 933 | ||
899 | void netdev_initialize_kobject(struct net_device *net) | ||
900 | { | ||
901 | struct device *device = &(net->dev); | ||
902 | device_initialize(device); | ||
903 | } | ||
904 | |||
905 | int netdev_kobject_init(void) | 934 | int netdev_kobject_init(void) |
906 | { | 935 | { |
936 | kobj_ns_type_register(&net_ns_type_operations); | ||
937 | register_pernet_subsys(&kobj_net_ops); | ||
907 | return class_register(&net_class); | 938 | return class_register(&net_class); |
908 | } | 939 | } |
diff --git a/net/core/net-sysfs.h b/net/core/net-sysfs.h index 14e7524260b3..805555e8b187 100644 --- a/net/core/net-sysfs.h +++ b/net/core/net-sysfs.h | |||
@@ -4,5 +4,4 @@ | |||
4 | int netdev_kobject_init(void); | 4 | int netdev_kobject_init(void); |
5 | int netdev_register_kobject(struct net_device *); | 5 | int netdev_register_kobject(struct net_device *); |
6 | void netdev_unregister_kobject(struct net_device *); | 6 | void netdev_unregister_kobject(struct net_device *); |
7 | void netdev_initialize_kobject(struct net_device *); | ||
8 | #endif | 7 | #endif |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 6464a1972a69..a2eb965207d3 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -978,6 +978,8 @@ struct netlink_broadcast_data { | |||
978 | int delivered; | 978 | int delivered; |
979 | gfp_t allocation; | 979 | gfp_t allocation; |
980 | struct sk_buff *skb, *skb2; | 980 | struct sk_buff *skb, *skb2; |
981 | int (*tx_filter)(struct sock *dsk, struct sk_buff *skb, void *data); | ||
982 | void *tx_data; | ||
981 | }; | 983 | }; |
982 | 984 | ||
983 | static inline int do_one_broadcast(struct sock *sk, | 985 | static inline int do_one_broadcast(struct sock *sk, |
@@ -1020,6 +1022,9 @@ static inline int do_one_broadcast(struct sock *sk, | |||
1020 | p->failure = 1; | 1022 | p->failure = 1; |
1021 | if (nlk->flags & NETLINK_BROADCAST_SEND_ERROR) | 1023 | if (nlk->flags & NETLINK_BROADCAST_SEND_ERROR) |
1022 | p->delivery_failure = 1; | 1024 | p->delivery_failure = 1; |
1025 | } else if (p->tx_filter && p->tx_filter(sk, p->skb2, p->tx_data)) { | ||
1026 | kfree_skb(p->skb2); | ||
1027 | p->skb2 = NULL; | ||
1023 | } else if (sk_filter(sk, p->skb2)) { | 1028 | } else if (sk_filter(sk, p->skb2)) { |
1024 | kfree_skb(p->skb2); | 1029 | kfree_skb(p->skb2); |
1025 | p->skb2 = NULL; | 1030 | p->skb2 = NULL; |
@@ -1038,8 +1043,10 @@ out: | |||
1038 | return 0; | 1043 | return 0; |
1039 | } | 1044 | } |
1040 | 1045 | ||
1041 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | 1046 | int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 pid, |
1042 | u32 group, gfp_t allocation) | 1047 | u32 group, gfp_t allocation, |
1048 | int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data), | ||
1049 | void *filter_data) | ||
1043 | { | 1050 | { |
1044 | struct net *net = sock_net(ssk); | 1051 | struct net *net = sock_net(ssk); |
1045 | struct netlink_broadcast_data info; | 1052 | struct netlink_broadcast_data info; |
@@ -1059,6 +1066,8 @@ int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | |||
1059 | info.allocation = allocation; | 1066 | info.allocation = allocation; |
1060 | info.skb = skb; | 1067 | info.skb = skb; |
1061 | info.skb2 = NULL; | 1068 | info.skb2 = NULL; |
1069 | info.tx_filter = filter; | ||
1070 | info.tx_data = filter_data; | ||
1062 | 1071 | ||
1063 | /* While we sleep in clone, do not allow to change socket list */ | 1072 | /* While we sleep in clone, do not allow to change socket list */ |
1064 | 1073 | ||
@@ -1083,6 +1092,14 @@ int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | |||
1083 | } | 1092 | } |
1084 | return -ESRCH; | 1093 | return -ESRCH; |
1085 | } | 1094 | } |
1095 | EXPORT_SYMBOL(netlink_broadcast_filtered); | ||
1096 | |||
1097 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | ||
1098 | u32 group, gfp_t allocation) | ||
1099 | { | ||
1100 | return netlink_broadcast_filtered(ssk, skb, pid, group, allocation, | ||
1101 | NULL, NULL); | ||
1102 | } | ||
1086 | EXPORT_SYMBOL(netlink_broadcast); | 1103 | EXPORT_SYMBOL(netlink_broadcast); |
1087 | 1104 | ||
1088 | struct netlink_set_err_data { | 1105 | struct netlink_set_err_data { |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a4d74344d805..f2bbea900700 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -2656,6 +2656,7 @@ sub process { | |||
2656 | # check for semaphores used as mutexes | 2656 | # check for semaphores used as mutexes |
2657 | if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { | 2657 | if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { |
2658 | WARN("consider using a completion\n" . $herecurr); | 2658 | WARN("consider using a completion\n" . $herecurr); |
2659 | |||
2659 | } | 2660 | } |
2660 | # recommend strict_strto* over simple_strto* | 2661 | # recommend strict_strto* over simple_strto* |
2661 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | 2662 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { |
@@ -2740,6 +2741,16 @@ sub process { | |||
2740 | WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); | 2741 | WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); |
2741 | } | 2742 | } |
2742 | } | 2743 | } |
2744 | |||
2745 | # check for lockdep_set_novalidate_class | ||
2746 | if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || | ||
2747 | $line =~ /__lockdep_no_validate__\s*\)/ ) { | ||
2748 | if ($realfile !~ m@^kernel/lockdep@ && | ||
2749 | $realfile !~ m@^include/linux/lockdep@ && | ||
2750 | $realfile !~ m@^drivers/base/core@) { | ||
2751 | ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); | ||
2752 | } | ||
2753 | } | ||
2743 | } | 2754 | } |
2744 | 2755 | ||
2745 | # If we have no input at all, then there is nothing to report on | 2756 | # If we have no input at all, then there is nothing to report on |
diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c index 2dc2d6594145..7625b85c2274 100644 --- a/security/integrity/ima/ima_iint.c +++ b/security/integrity/ima/ima_iint.c | |||
@@ -94,7 +94,7 @@ void iint_free(struct kref *kref) | |||
94 | iint->opencount); | 94 | iint->opencount); |
95 | iint->opencount = 0; | 95 | iint->opencount = 0; |
96 | } | 96 | } |
97 | kref_set(&iint->refcount, 1); | 97 | kref_init(&iint->refcount); |
98 | kmem_cache_free(iint_cache, iint); | 98 | kmem_cache_free(iint_cache, iint); |
99 | } | 99 | } |
100 | 100 | ||
@@ -133,7 +133,7 @@ static void init_once(void *foo) | |||
133 | iint->readcount = 0; | 133 | iint->readcount = 0; |
134 | iint->writecount = 0; | 134 | iint->writecount = 0; |
135 | iint->opencount = 0; | 135 | iint->opencount = 0; |
136 | kref_set(&iint->refcount, 1); | 136 | kref_init(&iint->refcount); |
137 | } | 137 | } |
138 | 138 | ||
139 | static int __init ima_iintcache_init(void) | 139 | static int __init ima_iintcache_init(void) |