aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 13:48:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 13:48:32 -0400
commitd6fb1db02e02aea98f2d7e121fd30e24c84639d6 (patch)
tree865546f0388c40d52cf98febe2c6d21039915ea2
parentb4e6b09738fde057ce885703705f71cc953d0512 (diff)
parenta1b3f594dc5faab91d3a218c7019e9b5edd9fe1a (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 ...
-rw-r--r--Documentation/filesystems/sysfs-tagging.txt42
-rw-r--r--arch/alpha/kernel/pci-sysfs.c8
-rw-r--r--arch/mips/txx9/generic/setup.c4
-rw-r--r--arch/powerpc/sysdev/mv64x60_pci.c4
-rw-r--r--arch/s390/kernel/ipl.c14
-rw-r--r--drivers/acpi/system.c2
-rw-r--r--drivers/base/Kconfig7
-rw-r--r--drivers/base/class.c9
-rw-r--r--drivers/base/core.c130
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/dd.c4
-rw-r--r--drivers/base/devtmpfs.c5
-rw-r--r--drivers/base/firmware_class.c206
-rw-r--r--drivers/base/module.c4
-rw-r--r--drivers/base/platform.c8
-rw-r--r--drivers/block/loop.c10
-rw-r--r--drivers/firmware/dcdbas.c4
-rw-r--r--drivers/firmware/dell_rbu.c10
-rw-r--r--drivers/firmware/efivars.c4
-rw-r--r--drivers/gpio/gpiolib.c2
-rw-r--r--drivers/gpu/drm/drm_sysfs.c5
-rw-r--r--drivers/md/bitmap.c4
-rw-r--r--drivers/md/md.c6
-rw-r--r--drivers/misc/c2port/core.c4
-rw-r--r--drivers/misc/ds1682.c6
-rw-r--r--drivers/misc/eeprom/at24.c6
-rw-r--r--drivers/misc/eeprom/at25.c6
-rw-r--r--drivers/misc/eeprom/eeprom.c3
-rw-r--r--drivers/misc/eeprom/max6875.c2
-rw-r--r--drivers/net/mlx4/mlx4.h1
-rw-r--r--drivers/net/netxen/netxen_nic_main.c11
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c12
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c5
-rw-r--r--drivers/pci/pci-sysfs.c45
-rw-r--r--drivers/pcmcia/cistpl.c4
-rw-r--r--drivers/power/olpc_battery.c2
-rw-r--r--drivers/rapidio/rio-sysfs.c6
-rw-r--r--drivers/rtc/rtc-cmos.c6
-rw-r--r--drivers/rtc/rtc-ds1305.c6
-rw-r--r--drivers/rtc/rtc-ds1307.c6
-rw-r--r--drivers/rtc/rtc-ds1511.c10
-rw-r--r--drivers/rtc/rtc-ds1553.c4
-rw-r--r--drivers/rtc/rtc-ds1742.c4
-rw-r--r--drivers/rtc/rtc-m48t59.c4
-rw-r--r--drivers/rtc/rtc-stk17ta8.c4
-rw-r--r--drivers/rtc/rtc-tx4939.c4
-rw-r--r--drivers/s390/cio/chp.c5
-rw-r--r--drivers/scsi/3w-sas.c4
-rw-r--r--drivers/scsi/arcmsr/arcmsr_attr.c9
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c3
-rw-r--r--drivers/scsi/ipr.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c20
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c32
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c1
-rw-r--r--drivers/staging/udlfb/udlfb.c3
-rw-r--r--drivers/usb/core/sysfs.c3
-rw-r--r--drivers/usb/core/usb.c2
-rw-r--r--drivers/video/aty/radeon_base.c4
-rw-r--r--drivers/w1/slaves/w1_ds2431.c4
-rw-r--r--drivers/w1/slaves/w1_ds2433.c4
-rw-r--r--drivers/w1/slaves/w1_ds2760.c2
-rw-r--r--drivers/w1/w1.c4
-rw-r--r--drivers/zorro/zorro-sysfs.c2
-rw-r--r--fs/ramfs/inode.c2
-rw-r--r--fs/sysfs/bin.c26
-rw-r--r--fs/sysfs/dir.c114
-rw-r--r--fs/sysfs/file.c17
-rw-r--r--fs/sysfs/group.c6
-rw-r--r--fs/sysfs/inode.c6
-rw-r--r--fs/sysfs/mount.c95
-rw-r--r--fs/sysfs/symlink.c35
-rw-r--r--fs/sysfs/sysfs.h34
-rw-r--r--include/linux/device.h12
-rw-r--r--include/linux/firmware.h1
-rw-r--r--include/linux/kobject.h38
-rw-r--r--include/linux/kref.h1
-rw-r--r--include/linux/lockdep.h8
-rw-r--r--include/linux/netlink.h4
-rw-r--r--include/linux/ramfs.h2
-rw-r--r--include/linux/sysfs.h26
-rw-r--r--kernel/ksysfs.c3
-rw-r--r--kernel/lockdep.c5
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/user_namespace.c4
-rw-r--r--lib/kobject.c115
-rw-r--r--lib/kobject_uevent.c109
-rw-r--r--lib/kref.c15
-rw-r--r--net/bridge/br_sysfs_br.c2
-rw-r--r--net/core/dev.c28
-rw-r--r--net/core/net-sysfs.c63
-rw-r--r--net/core/net-sysfs.h1
-rw-r--r--net/netlink/af_netlink.c21
-rwxr-xr-xscripts/checkpatch.pl11
-rw-r--r--security/integrity/ima/ima_iint.c4
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 @@
1Sysfs tagging
2-------------
3
4(Taken almost verbatim from Eric Biederman's netns tagging patch
5commit msg)
6
7The problem. Network devices show up in sysfs and with the network
8namespace active multiple devices with the same name can show up in
9the same directory, ouch!
10
11To avoid that problem and allow existing applications in network
12namespaces to see the same interface that is currently presented in
13sysfs, sysfs now has tagging directory support.
14
15By using the network namespace pointers as tags to separate out the
16the sysfs directory entries we ensure that we don't have conflicts
17in the directories and applications only see a limited set of
18the network devices.
19
20Each sysfs directory entry may be tagged with zero or one
21namespaces. A sysfs_dirent is augmented with a void *s_ns. If a
22directory entry is tagged, then sysfs_dirent->s_flags will have a
23flag between KOBJ_NS_TYPE_NONE and KOBJ_NS_TYPES, and s_ns will
24point to the namespace to which it belongs.
25
26Each sysfs superblock's sysfs_super_info contains an array void
27*ns[KOBJ_NS_TYPES]. When a a task in a tagging namespace
28kobj_nstype first mounts sysfs, a new superblock is created. It
29will be differentiated from other sysfs mounts by having its
30s_fs_info->ns[kobj_nstype] set to the new namespace. Note that
31through bind mounting and mounts propagation, a task can easily view
32the contents of other namespaces' sysfs mounts. Therefore, when a
33namespace exits, it will call kobj_ns_exit() to invalidate any
34sysfs_dirent->s_ns pointers pointing to it.
35
36Users 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 */
63static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, 64static 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
92static int pci_mmap_resource_sparse(struct kobject *kobj, 94static 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
99static int pci_mmap_resource_dense(struct kobject *kobj, 101static 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
908static ssize_t txx9_sram_read(struct kobject *kobj, 908static 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
923static ssize_t txx9_sram_write(struct kobject *kobj, 923static 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
27static ssize_t mv64x60_hs_reg_read(struct kobject *kobj, 27static 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
48static ssize_t mv64x60_hs_reg_write(struct kobject *kobj, 48static 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,
403static struct kobj_attribute sys_ipl_device_attr = 403static 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
406static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr, 406static 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
422static ssize_t ipl_scp_data_read(struct kobject *kobj, struct bin_attribute *attr, 423static 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
697static ssize_t reipl_fcp_scpdata_read(struct kobject *kobj, 699static 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
707static ssize_t reipl_fcp_scpdata_write(struct kobject *kobj, 709static 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
74static ssize_t acpi_table_show(struct kobject *kobj, 74static 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
19config DEVTMPFS 19config 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
36config DEVTMPFS_MOUNT 39config 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
66static 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
66static const struct sysfs_ops class_sysfs_ops = { 74static 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 = {
71static struct kobj_type class_ktype = { 79static 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
134static 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
135static struct kobj_type device_ktype = { 145static 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
599static struct kobject *get_device_parent(struct device *dev, 610struct 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
617static void class_dir_release(struct kobject *kobj)
618{
619 struct class_dir *dir = to_class_dir(kobj);
620 kfree(dir);
621}
622
623static const
624struct 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
630static 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
636static struct kobject *
637class_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
660static 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:
738out_busid: 786out_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
758out_busid: 806out_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
762out_subsys: 810out_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
1600out: 1651out:
@@ -1735,10 +1786,25 @@ EXPORT_SYMBOL_GPL(device_move);
1735 */ 1786 */
1736void device_shutdown(void) 1787void 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
50static int driver_sysfs_add(struct device *dev) 50static 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);
45static int dev_get_sb(struct file_system_type *fs_type, int flags, 46static 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
51static struct file_system_type dev_fs_type = { 56static 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");
27MODULE_DESCRIPTION("Multi purpose firmware loading support"); 27MODULE_DESCRIPTION("Multi purpose firmware loading support");
28MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
29 29
30/* Builtin firmware support */
31
32#ifdef CONFIG_FW_LOADER
33
34extern struct builtin_fw __start_builtin_fw[];
35extern struct builtin_fw __end_builtin_fw[];
36
37static 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
52static 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
65static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
66{
67 return false;
68}
69
70static inline bool fw_is_builtin_firmware(const struct firmware *fw)
71{
72 return false;
73}
74#endif
75
30enum { 76enum {
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 */
40static DEFINE_MUTEX(fw_lock); 86static DEFINE_MUTEX(fw_lock);
41 87
42struct firmware_priv { 88struct 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
56extern struct builtin_fw __start_builtin_fw[];
57extern struct builtin_fw __end_builtin_fw[];
58#else /* Module case. Avoid ifdefs later; it'll all optimise out */
59static struct builtin_fw *__start_builtin_fw;
60static struct builtin_fw *__end_builtin_fw;
61#endif
62
63static void 101static void
64fw_load_abort(struct firmware_priv *fw_priv) 102fw_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
103static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 141static 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
147static 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
105static void fw_dev_release(struct device *dev); 158 module_put(THIS_MODULE);
159}
106 160
107static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) 161static 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
119static struct class firmware_class = { 175static 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
190static 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,
207static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); 278static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
208 279
209static ssize_t 280static ssize_t
210firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, 281firmware_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 **/
303static ssize_t 376static ssize_t
304firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, 377firmware_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
356static 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
371static void 430static void
372firmware_class_timeout(u_long data) 431firmware_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
428static int fw_setup_device(struct firmware *fw, struct device **dev_p, 480static 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
471static int 525static 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 **/
570void 618void release_firmware(const struct firmware *fw)
571release_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
673static int __init 713static int __init firmware_class_init(void)
674firmware_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}
691static void __exit 717
692firmware_class_exit(void) 718static 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
738static int platform_pm_suspend(struct device *dev) 738int __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
756static int platform_pm_suspend_noirq(struct device *dev) 756int __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
772static int platform_pm_resume(struct device *dev) 772int __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
790static int platform_pm_resume_noirq(struct device *dev) 790int __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
152static ssize_t smi_data_read(struct kobject *kobj, 152static 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
165static ssize_t smi_data_write(struct kobject *kobj, 165static 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
525static ssize_t read_rbu_data(struct kobject *kobj, 525static 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
579static ssize_t read_rbu_image_type(struct kobject *kobj, 579static 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
589static ssize_t write_rbu_image_type(struct kobject *kobj, 589static 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
650static ssize_t read_rbu_packet_size(struct kobject *kobj, 650static 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
663static ssize_t write_rbu_packet_size(struct kobject *kobj, 663static 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
405static ssize_t efivar_create(struct kobject *kobj, 405static 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
464static ssize_t efivar_delete(struct kobject *kobj, 464static 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
196static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *attr, 196static 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
710static ssize_t c2port_read_flash_data(struct kobject *kobj, 710static 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
827static ssize_t c2port_write_flash_data(struct kobject *kobj, 827static 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 */
143static ssize_t ds1682_eeprom_read(struct kobject *kobj, struct bin_attribute *attr, 143static 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
166static ssize_t ds1682_eeprom_write(struct kobject *kobj, struct bin_attribute *attr, 167static 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
277static ssize_t at24_bin_read(struct kobject *kobj, struct bin_attribute *attr, 277static 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
398static ssize_t at24_bin_write(struct kobject *kobj, struct bin_attribute *attr, 399static 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
128static ssize_t 128static ssize_t
129at25_bin_read(struct kobject *kobj, struct bin_attribute *bin_attr, 129at25_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
255static ssize_t 256static ssize_t
256at25_bin_write(struct kobject *kobj, struct bin_attribute *bin_attr, 257at25_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
84static ssize_t eeprom_read(struct kobject *kobj, struct bin_attribute *bin_attr, 84static 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
110static ssize_t max6875_read(struct kobject *kobj, 110static 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
2562static ssize_t 2562static ssize_t
2563netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, 2563netxen_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
2589static ssize_t 2590static ssize_t
2590netxen_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, 2591netxen_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
2629static ssize_t 2631static ssize_t
2630netxen_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, 2632netxen_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
2650static ssize_t netxen_sysfs_write_mem(struct kobject *kobj, 2653static 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
2466static ssize_t 2466static ssize_t
2467qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, 2467qlcnic_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
2490static ssize_t 2491static ssize_t
2491qlcnic_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, 2492qlcnic_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
2527static ssize_t 2529static ssize_t
2528qlcnic_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, 2530qlcnic_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
2548static ssize_t 2551static ssize_t
2549qlcnic_sysfs_write_mem(struct kobject *kobj, struct bin_attribute *attr, 2552qlcnic_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);
108static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status); 108static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
109static void ibm_handle_events(acpi_handle handle, u32 event, void *context); 109static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
110static int ibm_get_table_from_acpi(char **bufp); 110static int ibm_get_table_from_acpi(char **bufp);
111static ssize_t ibm_read_apci_table(struct kobject *kobj, 111static 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);
114static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 114static 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 */
367static ssize_t ibm_read_apci_table(struct kobject *kobj, 368static 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)
357struct device_attribute vga_attr = __ATTR_RO(boot_vga); 358struct device_attribute vga_attr = __ATTR_RO(boot_vga);
358 359
359static ssize_t 360static ssize_t
360pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, 361pci_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
432static ssize_t 434static ssize_t
433pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, 435pci_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
489static ssize_t 492static ssize_t
490read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, 493read_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
504static ssize_t 508static ssize_t
505write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, 509write_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 */
531static ssize_t 537static ssize_t
532pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, 538pci_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 */
557static ssize_t 565static ssize_t
558pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, 566pci_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 */
581static int 591static int
582pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, 592pci_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 */
602static int 614static int
603pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, 615pci_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
752static int 765static int
753pci_mmap_resource_uc(struct kobject *kobj, struct bin_attribute *attr, 766pci_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
759static int 773static int
760pci_mmap_resource_wc(struct kobject *kobj, struct bin_attribute *attr, 774pci_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 */
872static ssize_t 888static ssize_t
873pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, 889pci_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 */
897static ssize_t 915static ssize_t
898pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, 916pci_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
1534static ssize_t pccard_show_cis(struct kobject *kobj, 1534static 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
1565static ssize_t pccard_store_cis(struct kobject *kobj, 1565static 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
357static ssize_t olpc_bat_eeprom_read(struct kobject *kobj, 357static 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
70static ssize_t 70static ssize_t
71rio_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, 71rio_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
141static ssize_t 142static ssize_t
142rio_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, 143rio_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
521static ssize_t 521static ssize_t
522cmos_nvram_read(struct kobject *kobj, struct bin_attribute *attr, 522cmos_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
549static ssize_t 550static ssize_t
550cmos_nvram_write(struct kobject *kobj, struct bin_attribute *attr, 551cmos_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
544static ssize_t 544static ssize_t
545ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, 545ds1305_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
574static ssize_t 575static ssize_t
575ds1305_nvram_write(struct kobject *kobj, struct bin_attribute *attr, 576ds1305_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
558static ssize_t 558static ssize_t
559ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, 559ds1307_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
582static ssize_t 583static ssize_t
583ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr, 584ds1307_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
426ds1511_nvram_read(struct kobject *kobj, struct bin_attribute *ba, 426ds1511_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
455ds1511_nvram_write(struct kobject *kobj, struct bin_attribute *bin_attr, 456ds1511_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
255static ssize_t ds1553_nvram_read(struct kobject *kobj, 255static 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
270static ssize_t ds1553_nvram_write(struct kobject *kobj, 270static 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
131static ssize_t ds1742_nvram_read(struct kobject *kobj, 131static 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
146static ssize_t ds1742_nvram_write(struct kobject *kobj, 146static 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
346static ssize_t m48t59_nvram_read(struct kobject *kobj, 346static 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
366static ssize_t m48t59_nvram_write(struct kobject *kobj, 366static 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
247static ssize_t stk17ta8_nvram_read(struct kobject *kobj, 247static 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
262static ssize_t stk17ta8_nvram_write(struct kobject *kobj, 262static 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
191static ssize_t tx4939_rtc_nvram_read(struct kobject *kobj, 191static 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
210static ssize_t tx4939_rtc_nvram_write(struct kobject *kobj, 210static 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 */
138static ssize_t chp_measurement_chars_read(struct kobject *kobj, 138static 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
185static ssize_t chp_measurement_read(struct kobject *kobj, 186static 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 */
101static ssize_t twl_sysfs_aen_read(struct kobject *kobj, 101static 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 */
132static ssize_t twl_sysfs_compat_info(struct kobject *kobj, 132static 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
60struct device_attribute *arcmsr_host_attrs[]; 60struct device_attribute *arcmsr_host_attrs[];
61 61
62static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, 62static 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
108static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj, 109static 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
156static ssize_t arcmsr_sysfs_iop_message_clear(struct kobject *kobj, 158static 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 **/
2931static ssize_t ibmvfc_read_trace(struct kobject *kobj, 2932static 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 **/
3132static ssize_t ipr_read_trace(struct kobject *kobj, 3133static 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 **/
3776static ssize_t ipr_read_dump(struct kobject *kobj, 3778static 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 **/
3939static ssize_t ipr_write_dump(struct kobject *kobj, 3942static 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 **/
2656static ssize_t 2657static ssize_t
2657sysfs_drvr_stat_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, 2658sysfs_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 **/
3381static ssize_t 3384static ssize_t
3382sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, 3385sysfs_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 **/
3433static ssize_t 3438static ssize_t
3434sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, 3439sysfs_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 **/
3518static ssize_t 3525static ssize_t
3519sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, 3526sysfs_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 **/
3595static ssize_t 3604static ssize_t
3596sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, 3605sysfs_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
18static ssize_t 18static ssize_t
19qla2x00_sysfs_read_fw_dump(struct kobject *kobj, 19qla2x00_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
34static ssize_t 34static ssize_t
35qla2x00_sysfs_write_fw_dump(struct kobject *kobj, 35qla2x00_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
94static ssize_t 94static ssize_t
95qla2x00_sysfs_read_nvram(struct kobject *kobj, 95qla2x00_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
113static ssize_t 113static ssize_t
114qla2x00_sysfs_write_nvram(struct kobject *kobj, 114qla2x00_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
179static ssize_t 179static ssize_t
180qla2x00_sysfs_read_optrom(struct kobject *kobj, 180qla2x00_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
195static ssize_t 195static ssize_t
196qla2x00_sysfs_write_optrom(struct kobject *kobj, 196qla2x00_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
226static ssize_t 226static ssize_t
227qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, 227qla2x00_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
389static ssize_t 389static ssize_t
390qla2x00_sysfs_read_vpd(struct kobject *kobj, 390qla2x00_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
410static ssize_t 410static ssize_t
411qla2x00_sysfs_write_vpd(struct kobject *kobj, 411qla2x00_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
463static ssize_t 463static ssize_t
464qla2x00_sysfs_read_sfp(struct kobject *kobj, 464qla2x00_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
524static ssize_t 524static ssize_t
525qla2x00_sysfs_write_reset(struct kobject *kobj, 525qla2x00_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
594static ssize_t 594static ssize_t
595qla2x00_sysfs_write_edc(struct kobject *kobj, 595qla2x00_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
652static ssize_t 652static ssize_t
653qla2x00_sysfs_write_edc_status(struct kobject *kobj, 653qla2x00_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
702static ssize_t 702static ssize_t
703qla2x00_sysfs_read_edc_status(struct kobject *kobj, 703qla2x00_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
732static ssize_t 732static ssize_t
733qla2x00_sysfs_read_xgmac_stats(struct kobject *kobj, 733qla2x00_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
784static ssize_t 784static ssize_t
785qla2x00_sysfs_read_dcbx_tlv(struct kobject *kobj, 785qla2x00_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
1066static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *a, 1066static 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
660static ssize_t 660static ssize_t
661read_descriptors(struct kobject *kobj, struct bin_attribute *attr, 661read_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
2102static ssize_t radeon_show_edid1(struct kobject *kobj, 2102static 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
2115static ssize_t radeon_show_edid2(struct kobject *kobj, 2115static 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
99static ssize_t w1_f2d_read_bin(struct kobject *kobj, 99static 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
205static ssize_t w1_f2d_write_bin(struct kobject *kobj, 205static 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
95static ssize_t w1_f23_read_bin(struct kobject *kobj, 95static 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
209static ssize_t w1_f23_write_bin(struct kobject *kobj, 209static 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
100static ssize_t w1_ds2760_read_bin(struct kobject *kobj, 100static 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
123static ssize_t w1_default_write(struct kobject *kobj, 123static 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
142static ssize_t w1_default_read(struct kobject *kobj, 142static 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
50static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL); 50static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
51 51
52static ssize_t zorro_read_config(struct kobject *kobj, 52static 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
217static int ramfs_fill_super(struct super_block * sb, void * data, int silent) 217int 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
48static int 48static int
49fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) 49fill_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
70read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) 70read(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
119static int 118static int
120flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) 119flush_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,
501void sysfs_remove_bin_file(struct kobject *kobj, 499void 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
507EXPORT_SYMBOL_GPL(sysfs_create_bin_file); 505EXPORT_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 */
535struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, 535struct 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 */
560struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 564struct 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,
572EXPORT_SYMBOL_GPL(sysfs_get_dirent); 577EXPORT_SYMBOL_GPL(sysfs_get_dirent);
573 578
574static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, 579static 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,
601int sysfs_create_subdir(struct kobject *kobj, const char *name, 610int 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 */
625static 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 */
611int sysfs_create_dir(struct kobject * kobj) 646int 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
737int sysfs_rename(struct sysfs_dirent *sd, 784int 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
781int sysfs_rename_dir(struct kobject *kobj, const char *new_name) 830int 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
786int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) 841int 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
810static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd, 868static 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
830static struct sysfs_dirent *sysfs_dir_next_pos(struct sysfs_dirent *parent_sd, 889static 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
625void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) 628void 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
630void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) 633void 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
29static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, 29static 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
327int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) 327int 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 = {
35struct sysfs_dirent sysfs_root = { 35struct 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
75static 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
89static 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
75static int sysfs_get_sb(struct file_system_type *fs_type, 98static 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;
133out:
134 return error;
135}
136
137static 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
81static struct file_system_type sysfs_fs_type = { 148static 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
154void 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
87int __init sysfs_init(void) 176int __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 */
120void 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
160out: 189out:
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
87static inline unsigned int sysfs_type(struct sysfs_dirent *sd) 92static 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 */
101static 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) \
94do { \ 108do { \
@@ -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 */
137struct sysfs_super_info {
138 const void *ns[KOBJ_NS_TYPES];
139};
140#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
117extern struct sysfs_dirent sysfs_root; 141extern struct sysfs_dirent sysfs_root;
118extern struct kmem_cache *sysfs_dir_cachep; 142extern 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);
137void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); 161void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
138 162
139struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, 163struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
164 const void *ns,
140 const unsigned char *name); 165 const unsigned char *name);
141struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 166struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
167 const void *ns,
142 const unsigned char *name); 168 const unsigned char *name);
143struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); 169struct 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,
149void sysfs_remove_subdir(struct sysfs_dirent *sd); 175void sysfs_remove_subdir(struct sysfs_dirent *sd);
150 176
151int sysfs_rename(struct sysfs_dirent *sd, 177int 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
154static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) 180static 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);
179int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); 205int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
180int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, 206int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
181 size_t size, int flags); 207 size_t size, int flags);
182int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); 208int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name);
183int sysfs_inode_init(void); 209int 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
515static inline void device_lock(struct device *dev) 517static inline void device_lock(struct device *dev)
516{ 518{
517 down(&dev->sem); 519 mutex_lock(&dev->mutex);
518} 520}
519 521
520static inline int device_trylock(struct device *dev) 522static 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
525static inline void device_unlock(struct device *dev) 527static inline void device_unlock(struct device *dev)
526{ 528{
527 up(&dev->sem); 529 mutex_unlock(&dev->mutex);
528} 530}
529 531
530void driver_init(void); 532void 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 @@
12struct firmware { 12struct 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
17struct device; 18struct 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
113struct kobj_uevent_env { 115struct kobj_uevent_env {
@@ -134,6 +136,42 @@ struct kobj_attribute {
134 136
135extern const struct sysfs_ops kobj_sysfs_ops; 137extern 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 */
143enum kobj_ns_type {
144 KOBJ_NS_TYPE_NONE = 0,
145 KOBJ_NS_TYPE_NET,
146 KOBJ_NS_TYPES
147};
148
149struct 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 */
157struct 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
164int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
165int kobj_ns_type_registered(enum kobj_ns_type type);
166const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent);
167const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj);
168
169const void *kobj_ns_current(enum kobj_ns_type type);
170const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk);
171const void *kobj_ns_initial(enum kobj_ns_type type);
172void 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
24void kref_set(struct kref *kref, int num);
25void kref_init(struct kref *kref); 24void kref_init(struct kref *kref);
26void kref_get(struct kref *kref); 25void kref_get(struct kref *kref);
27int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 26int 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
47extern 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);
188extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock); 188extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
189extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid, 189extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
190 __u32 group, gfp_t allocation); 190 __u32 group, gfp_t allocation);
191extern 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);
191extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code); 195extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
192extern int netlink_register_notifier(struct notifier_block *nb); 196extern int netlink_register_notifier(struct notifier_block *nb);
193extern int netlink_unregister_notifier(struct notifier_block *nb); 197extern 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;
20extern const struct vm_operations_struct generic_file_vm_ops; 20extern const struct vm_operations_struct generic_file_vm_ops;
21extern int __init init_rootfs(void); 21extern int __init init_rootfs(void);
22 22
23int 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
21struct kobject; 21struct kobject;
22struct module; 22struct module;
23enum 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
90struct file;
89struct vm_area_struct; 91struct vm_area_struct;
90 92
91struct bin_attribute { 93struct 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);
154int sysfs_rename_link(struct kobject *kobj, struct kobject *target, 156int 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
159void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
160 const char *name);
161
157int __must_check sysfs_create_group(struct kobject *kobj, 162int __must_check sysfs_create_group(struct kobject *kobj,
158 const struct attribute_group *grp); 163 const struct attribute_group *grp);
159int sysfs_update_group(struct kobject *kobj, 164int sysfs_update_group(struct kobject *kobj,
@@ -168,10 +173,15 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
168void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 173void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
169void sysfs_notify_dirent(struct sysfs_dirent *sd); 174void sysfs_notify_dirent(struct sysfs_dirent *sd);
170struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 175struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
176 const void *ns,
171 const unsigned char *name); 177 const unsigned char *name);
172struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); 178struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
173void sysfs_put(struct sysfs_dirent *sd); 179void sysfs_put(struct sysfs_dirent *sd);
174void sysfs_printk_last_file(void); 180void sysfs_printk_last_file(void);
181
182/* Called to clear a ns tag when it is no longer valid */
183void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
184
175int __must_check sysfs_init(void); 185int __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
277static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
278 const char *name)
279{
280}
281
267static inline int sysfs_create_group(struct kobject *kobj, 282static 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}
302static inline 317static inline
303struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 318struct 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
332static inline void sysfs_exit_ns(int type, const void *tag)
333{
334}
335
316static inline int __must_check sysfs_init(void) 336static 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));
138extern const void __stop_notes __attribute__((weak)); 138extern const void __stop_notes __attribute__((weak));
139#define notes_size (&__stop_notes - &__start_notes) 139#define notes_size (&__stop_notes - &__start_notes)
140 140
141static ssize_t notes_read(struct kobject *kobj, struct bin_attribute *bin_attr, 141static 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}
2712EXPORT_SYMBOL_GPL(lockdep_init_map); 2712EXPORT_SYMBOL_GPL(lockdep_init_map);
2713 2713
2714struct 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
1185static ssize_t module_notes_read(struct kobject *kobj, 1185static 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}
851EXPORT_SYMBOL_GPL(kset_create_and_add); 851EXPORT_SYMBOL_GPL(kset_create_and_add);
852 852
853
854static DEFINE_SPINLOCK(kobj_ns_type_lock);
855static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
856
857int 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
879out:
880 spin_unlock(&kobj_ns_type_lock);
881 return error;
882}
883
884int 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
896const 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
906const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj)
907{
908 return kobj_child_ns_ops(kobj->parent);
909}
910
911
912const 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
925const 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
938const 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 */
962void kobj_ns_exit(enum kobj_ns_type type, const void *ns)
963{
964 sysfs_exit_ns(type, ns);
965}
966
967
853EXPORT_SYMBOL(kobject_get); 968EXPORT_SYMBOL(kobject_get);
854EXPORT_SYMBOL(kobject_put); 969EXPORT_SYMBOL(kobject_put);
855EXPORT_SYMBOL(kobject_del); 970EXPORT_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
29u64 uevent_seqnum; 30u64 uevent_seqnum;
30char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 31char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
31static DEFINE_SPINLOCK(sequence_lock); 32static DEFINE_SPINLOCK(sequence_lock);
32#if defined(CONFIG_NET) 33#ifdef CONFIG_NET
33static struct sock *uevent_sock; 34struct uevent_sock {
35 struct list_head list;
36 struct sock *sk;
37};
38static LIST_HEAD(uevent_sock_list);
39static 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
86static 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
102static 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, ...)
320EXPORT_SYMBOL_GPL(add_uevent_var); 365EXPORT_SYMBOL_GPL(add_uevent_var);
321 366
322#if defined(CONFIG_NET) 367#if defined(CONFIG_NET)
323static int __init kobject_uevent_init(void) 368static 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
389static 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
401found:
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
409static struct pernet_operations uevent_net_ops = {
410 .init = uevent_net_init,
411 .exit = uevent_net_exit,
412};
413
414static 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
336postcore_initcall(kobject_uevent_init); 421postcore_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 */
23void 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 */
33void kref_init(struct kref *kref) 22void 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
75EXPORT_SYMBOL(kref_set);
76EXPORT_SYMBOL(kref_init); 65EXPORT_SYMBOL(kref_init);
77EXPORT_SYMBOL(kref_get); 66EXPORT_SYMBOL(kref_get);
78EXPORT_SYMBOL(kref_put); 67EXPORT_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 */
662static ssize_t brforward_read(struct kobject *kobj, 662static 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
1004rollback: 1004rollback:
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
773static const void *net_current_ns(void)
774{
775 return current->nsproxy->net_ns;
776}
777
778static const void *net_initial_ns(void)
779{
780 return &init_net;
781}
782
783static const void *net_netlink_ns(struct sock *sk)
784{
785 return sock_net(sk);
786}
787
788static 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
795static void net_kobj_ns_exit(struct net *net)
796{
797 kobj_ns_exit(KOBJ_NS_TYPE_NET, net);
798}
799
800static struct pernet_operations kobj_net_ops = {
801 .exit = net_kobj_ns_exit,
802};
803
770 804
771#ifdef CONFIG_HOTPLUG 805#ifdef CONFIG_HOTPLUG
772static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) 806static 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
840static 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
809static struct class net_class = { 847static 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)
896EXPORT_SYMBOL(netdev_class_create_file); 931EXPORT_SYMBOL(netdev_class_create_file);
897EXPORT_SYMBOL(netdev_class_remove_file); 932EXPORT_SYMBOL(netdev_class_remove_file);
898 933
899void netdev_initialize_kobject(struct net_device *net)
900{
901 struct device *device = &(net->dev);
902 device_initialize(device);
903}
904
905int netdev_kobject_init(void) 934int 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 @@
4int netdev_kobject_init(void); 4int netdev_kobject_init(void);
5int netdev_register_kobject(struct net_device *); 5int netdev_register_kobject(struct net_device *);
6void netdev_unregister_kobject(struct net_device *); 6void netdev_unregister_kobject(struct net_device *);
7void 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
983static inline int do_one_broadcast(struct sock *sk, 985static 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
1041int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, 1046int 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}
1095EXPORT_SYMBOL(netlink_broadcast_filtered);
1096
1097int 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}
1086EXPORT_SYMBOL(netlink_broadcast); 1103EXPORT_SYMBOL(netlink_broadcast);
1087 1104
1088struct netlink_set_err_data { 1105struct 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
139static int __init ima_iintcache_init(void) 139static int __init ima_iintcache_init(void)