This patch exposes HID,UID,SEG,BBN of PCI root bridge via sysfs.
Thanks,
--
Yuji Shimada.
Signed-off-by: Yuji Shimada <shimada-yxb@xxxxxxxxxxxxxxx>
diff -r 618fc299e2f1 -r 4769a6db78f5 drivers/acpi/pci_root.c
--- a/drivers/acpi/pci_root.c Thu Dec 18 11:51:36 2008 +0000
+++ b/drivers/acpi/pci_root.c Thu Dec 25 10:37:52 2008 +0900
@@ -151,6 +151,36 @@
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 @@
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) {
diff -r 618fc299e2f1 -r 4769a6db78f5 drivers/acpi/scan.c
--- a/drivers/acpi/scan.c Thu Dec 18 11:51:36 2008 +0000
+++ b/drivers/acpi/scan.c Thu Dec 25 10:37:52 2008 +0900
@@ -31,12 +31,6 @@
kfree(dev->pnp.cid_list);
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 @@
.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 @@
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)
@@ -343,10 +374,6 @@
--------------------------------------------------------------------------
*/
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);
diff -r 618fc299e2f1 -r 4769a6db78f5 include/acpi/acpi_bus.h
--- a/include/acpi/acpi_bus.h Thu Dec 18 11:51:36 2008 +0000
+++ b/include/acpi/acpi_bus.h Thu Dec 25 10:37:52 2008 +0900
@@ -359,6 +359,16 @@
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__*/
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|