]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
Expose HID, UID, SEG, BBN of PCI root bridge via sysfs.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jan 2009 10:53:06 +0000 (10:53 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jan 2009 10:53:06 +0000 (10:53 +0000)
Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
drivers/acpi/pci_root.c
drivers/acpi/scan.c
include/acpi/acpi_bus.h

index 0984a1ee24edceecbd9593b8da72b139f1fc4201..6deb26747c794de5ca8918f9cd619a4bcaf8ac78 100644 (file)
@@ -151,6 +151,36 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum)
        return AE_OK;
 }
 
+ssize_t
+acpi_device_seg_show(struct acpi_device *acpi_dev, char *buf) 
+{
+       struct list_head *entry;
+
+       list_for_each(entry, &acpi_pci_roots) {
+               struct acpi_pci_root *root;
+               root = list_entry(entry, struct acpi_pci_root, node);
+               if (root->device == acpi_dev)
+                       return sprintf(buf, "%04x\n", root->id.segment);
+       }
+       return 0;
+}
+ACPI_DEVICE_ATTR(seg, 0444, acpi_device_seg_show, NULL);
+
+ssize_t
+acpi_device_bbn_show(struct acpi_device *acpi_dev, char *buf) 
+{
+       struct list_head *entry;
+
+       list_for_each(entry, &acpi_pci_roots) {
+               struct acpi_pci_root *root;
+               root = list_entry(entry, struct acpi_pci_root, node);
+               if (root->device == acpi_dev)
+                       return sprintf(buf, "%02x\n", root->id.bus);
+       }
+       return 0;
+}
+ACPI_DEVICE_ATTR(bbn, 0444, acpi_device_bbn_show, NULL);
+
 static int acpi_pci_root_add(struct acpi_device *device)
 {
        int result = 0;
@@ -298,6 +328,12 @@ static int acpi_pci_root_add(struct acpi_device *device)
        if (ACPI_SUCCESS(status))
                result = acpi_pci_irq_add_prt(device->handle, root->id.segment,
                                              root->id.bus);
+       if (result)
+               goto end;
+
+       sysfs_create_file(&device->kobj, &acpi_device_attr_seg.attr);
+
+       sysfs_create_file(&device->kobj, &acpi_device_attr_bbn.attr);
 
       end:
        if (result) {
index 698a1540e3033ce1960d4c72a45f3a8177397d94..b8c57f2247a6cff0e23164b8495aaf6dedf6579a 100644 (file)
@@ -32,12 +32,6 @@ static void acpi_device_release(struct kobject *kobj)
        kfree(dev);
 }
 
-struct acpi_device_attribute {
-       struct attribute attr;
-        ssize_t(*show) (struct acpi_device *, char *);
-        ssize_t(*store) (struct acpi_device *, const char *, size_t);
-};
-
 typedef void acpi_device_sysfs_files(struct kobject *,
                                     const struct attribute *);
 
@@ -111,6 +105,42 @@ static struct kset acpi_namespace_kset = {
        .uevent_ops = &namespace_uevent_ops,
 };
 
+static ssize_t
+acpi_device_hid_show(struct acpi_device *acpi_dev, char *buf) 
+{
+       return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id);
+}
+ACPI_DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
+
+static ssize_t
+acpi_device_uid_show(struct acpi_device *acpi_dev, char *buf) 
+{
+       return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
+}
+ACPI_DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
+
+static int acpi_device_setup_files(struct acpi_device *dev)
+{
+       int result = 0;
+
+       if (dev->flags.hardware_id) {
+               result = sysfs_create_file(&dev->kobj,
+                                       &acpi_device_attr_hid.attr);
+               if (result)
+                       goto end;
+       }
+
+       if (dev->flags.unique_id) {
+               result = sysfs_create_file(&dev->kobj,
+                                       &acpi_device_attr_uid.attr);
+               if (result)
+                       goto end;
+       }
+
+      end:
+       return result;
+}
+
 static void acpi_device_register(struct acpi_device *device,
                                 struct acpi_device *parent)
 {
@@ -146,6 +176,7 @@ static void acpi_device_register(struct acpi_device *device,
                printk(KERN_WARNING "%s: kobject_register error: %d\n",
                        __FUNCTION__, err);
        create_sysfs_device_files(device);
+       acpi_device_setup_files(device);
 }
 
 static void acpi_device_unregister(struct acpi_device *device, int type)
@@ -344,10 +375,6 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
 static ssize_t acpi_eject_store(struct acpi_device *device,
                                const char *buf, size_t count);
 
-#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
-static struct acpi_device_attribute acpi_device_attr_##_name = \
-               __ATTR(_name, _mode, _show, _store)
-
 ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
 
 /**
index f338e40bd54477b2af0cc26ad0dd3455619d393b..dcee93653b3d2e9677be2db3ee675ea4f4ff24d1 100644 (file)
@@ -359,6 +359,16 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer);
 acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
 #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data))
 
+#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
+static struct acpi_device_attribute acpi_device_attr_##_name = \
+               __ATTR(_name, _mode, _show, _store)
+
+struct acpi_device_attribute {
+       struct attribute attr;
+       ssize_t(*show) (struct acpi_device *, char *);
+       ssize_t(*store) (struct acpi_device *, const char *, size_t);
+};
+
 #endif /* CONFIG_ACPI */
 
 #endif /*__ACPI_BUS_H__*/