Merge tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[deliverable/linux.git] / drivers / pci / pci-sysfs.c
index 9cd27b703dd683b73947d8844b67072b079f5c88..95d9e7bd933bc880315d3584033c4ea2ca41a3b9 100644 (file)
@@ -216,7 +216,10 @@ static ssize_t numa_node_store(struct device *dev,
        if (ret)
                return ret;
 
-       if (node >= MAX_NUMNODES || !node_online(node))
+       if ((node < 0 && node != NUMA_NO_NODE) || node >= MAX_NUMNODES)
+               return -EINVAL;
+
+       if (node != NUMA_NO_NODE && !node_online(node))
                return -EINVAL;
 
        add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
@@ -627,8 +630,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
                               struct bin_attribute *bin_attr, char *buf,
                               loff_t off, size_t count)
 {
-       struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
        unsigned int size = 64;
        loff_t init_off = off;
        u8 *data = (u8 *) buf;
@@ -704,8 +706,7 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
                                struct bin_attribute *bin_attr, char *buf,
                                loff_t off, size_t count)
 {
-       struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
        unsigned int size = count;
        loff_t init_off = off;
        u8 *data = (u8 *) buf;
@@ -766,8 +767,7 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
                             struct bin_attribute *bin_attr, char *buf,
                             loff_t off, size_t count)
 {
-       struct pci_dev *dev =
-               to_pci_dev(container_of(kobj, struct device, kobj));
+       struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 
        if (off > bin_attr->size)
                count = 0;
@@ -781,8 +781,7 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
                              struct bin_attribute *bin_attr, char *buf,
                              loff_t off, size_t count)
 {
-       struct pci_dev *dev =
-               to_pci_dev(container_of(kobj, struct device, kobj));
+       struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 
        if (off > bin_attr->size)
                count = 0;
@@ -809,8 +808,7 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
                                  struct bin_attribute *bin_attr, char *buf,
                                  loff_t off, size_t count)
 {
-       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
 
        /* Only support 1, 2 or 4 byte accesses */
        if (count != 1 && count != 2 && count != 4)
@@ -835,8 +833,7 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
                                   struct bin_attribute *bin_attr, char *buf,
                                   loff_t off, size_t count)
 {
-       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
 
        /* Only support 1, 2 or 4 byte accesses */
        if (count != 1 && count != 2 && count != 4)
@@ -860,8 +857,7 @@ static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
                               struct bin_attribute *attr,
                               struct vm_area_struct *vma)
 {
-       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
 
        return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem);
 }
@@ -881,8 +877,7 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
                              struct bin_attribute *attr,
                              struct vm_area_struct *vma)
 {
-       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
-                                                     kobj));
+       struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
 
        return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
 }
@@ -997,8 +992,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
 static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
                             struct vm_area_struct *vma, int write_combine)
 {
-       struct pci_dev *pdev = to_pci_dev(container_of(kobj,
-                                                      struct device, kobj));
+       struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
        struct resource *res = attr->private;
        enum pci_mmap_state mmap_type;
        resource_size_t start, end;
@@ -1051,8 +1045,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
                               struct bin_attribute *attr, char *buf,
                               loff_t off, size_t count, bool write)
 {
-       struct pci_dev *pdev = to_pci_dev(container_of(kobj,
-                                                      struct device, kobj));
+       struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
        struct resource *res = attr->private;
        unsigned long port = off;
        int i;
@@ -1222,7 +1215,7 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
                             struct bin_attribute *bin_attr, char *buf,
                             loff_t off, size_t count)
 {
-       struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
+       struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 
        if ((off ==  0) && (*buf == '0') && (count == 2))
                pdev->rom_attr_enabled = 0;
@@ -1248,7 +1241,7 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
                            struct bin_attribute *bin_attr, char *buf,
                            loff_t off, size_t count)
 {
-       struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
+       struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
        void __iomem *rom;
        size_t size;
 
@@ -1508,7 +1501,7 @@ static struct attribute *pci_dev_dev_attrs[] = {
 static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
                                         struct attribute *a, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct pci_dev *pdev = to_pci_dev(dev);
 
        if (a == &vga_attr.attr)
@@ -1527,7 +1520,7 @@ static struct attribute *pci_dev_hp_attrs[] = {
 static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj,
                                            struct attribute *a, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct pci_dev *pdev = to_pci_dev(dev);
 
        if (pdev->is_virtfn)
@@ -1551,7 +1544,7 @@ static struct attribute *sriov_dev_attrs[] = {
 static umode_t sriov_attrs_are_visible(struct kobject *kobj,
                                       struct attribute *a, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
 
        if (!dev_is_pf(dev))
                return 0;
This page took 0.031682 seconds and 5 git commands to generate.