Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / pci / pci-sysfs.c
index 56ac2bc..fdefa7d 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/stat.h>
@@ -43,6 +42,29 @@ pci_config_attr(subsystem_vendor, "0x%04x\n");
 pci_config_attr(subsystem_device, "0x%04x\n");
 pci_config_attr(class, "0x%06x\n");
 pci_config_attr(irq, "%u\n");
+pci_config_attr(is_enabled, "%u\n");
+
+static ssize_t broken_parity_status_show(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       return sprintf (buf, "%u\n", pdev->broken_parity_status);
+}
+
+static ssize_t broken_parity_status_store(struct device *dev,
+                                         struct device_attribute *attr,
+                                         const char *buf, size_t count)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       ssize_t consumed = -EINVAL;
+
+       if ((count > 0) && (*buf == '0' || *buf == '1')) {
+               pdev->broken_parity_status = *buf == '1' ? 1 : 0;
+               consumed = count;
+       }
+       return consumed;
+}
 
 static ssize_t local_cpus_show(struct device *dev,
                        struct device_attribute *attr, char *buf)
@@ -64,7 +86,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
        char * str = buf;
        int i;
        int max = 7;
-       u64 start, end;
+       resource_size_t start, end;
 
        if (pci_dev->subordinate)
                max = DEVICE_COUNT_RESOURCE;
@@ -90,6 +112,25 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
                       (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
                       (u8)(pci_dev->class));
 }
+static ssize_t
+is_enabled_store(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+
+       /* this can crash the machine when done on the "wrong" device */
+       if (!capable(CAP_SYS_ADMIN))
+               return count;
+
+       if (*buf == '0')
+               pci_disable_device(pdev);
+
+       if (*buf == '1')
+               pci_enable_device(pdev);
+
+       return count;
+}
+
 
 struct device_attribute pci_dev_attrs[] = {
        __ATTR_RO(resource),
@@ -101,6 +142,9 @@ struct device_attribute pci_dev_attrs[] = {
        __ATTR_RO(irq),
        __ATTR_RO(local_cpus),
        __ATTR_RO(modalias),
+       __ATTR(enable, 0600, is_enabled_show, is_enabled_store),
+       __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
+               broken_parity_status_show,broken_parity_status_store),
        __ATTR_NULL,
 };
 
@@ -320,7 +364,7 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
                                                       struct device, kobj));
        struct resource *res = (struct resource *)attr->private;
        enum pci_mmap_state mmap_type;
-       u64 start, end;
+       resource_size_t start, end;
        int i;
 
        for (i = 0; i < PCI_ROM_RESOURCE; i++)