ia64/linux-2.6.18-xen.hg

changeset 768:fad85221407b

Expose HID, UID, SEG, BBN of PCI root bridge via sysfs.

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jan 05 10:53:06 2009 +0000 (2009-01-05)
parents 618fc299e2f1
children 2fdc121e9b5d
files drivers/acpi/pci_root.c drivers/acpi/scan.c include/acpi/acpi_bus.h
line diff
     1.1 --- a/drivers/acpi/pci_root.c	Thu Dec 18 11:51:36 2008 +0000
     1.2 +++ b/drivers/acpi/pci_root.c	Mon Jan 05 10:53:06 2009 +0000
     1.3 @@ -151,6 +151,36 @@ static acpi_status try_get_root_bridge_b
     1.4  	return AE_OK;
     1.5  }
     1.6  
     1.7 +ssize_t
     1.8 +acpi_device_seg_show(struct acpi_device *acpi_dev, char *buf) 
     1.9 +{
    1.10 +	struct list_head *entry;
    1.11 +
    1.12 +	list_for_each(entry, &acpi_pci_roots) {
    1.13 +		struct acpi_pci_root *root;
    1.14 +		root = list_entry(entry, struct acpi_pci_root, node);
    1.15 +		if (root->device == acpi_dev)
    1.16 +			return sprintf(buf, "%04x\n", root->id.segment);
    1.17 +	}
    1.18 +	return 0;
    1.19 +}
    1.20 +ACPI_DEVICE_ATTR(seg, 0444, acpi_device_seg_show, NULL);
    1.21 +
    1.22 +ssize_t
    1.23 +acpi_device_bbn_show(struct acpi_device *acpi_dev, char *buf) 
    1.24 +{
    1.25 +	struct list_head *entry;
    1.26 +
    1.27 +	list_for_each(entry, &acpi_pci_roots) {
    1.28 +		struct acpi_pci_root *root;
    1.29 +		root = list_entry(entry, struct acpi_pci_root, node);
    1.30 +		if (root->device == acpi_dev)
    1.31 +			return sprintf(buf, "%02x\n", root->id.bus);
    1.32 +	}
    1.33 +	return 0;
    1.34 +}
    1.35 +ACPI_DEVICE_ATTR(bbn, 0444, acpi_device_bbn_show, NULL);
    1.36 +
    1.37  static int acpi_pci_root_add(struct acpi_device *device)
    1.38  {
    1.39  	int result = 0;
    1.40 @@ -298,6 +328,12 @@ static int acpi_pci_root_add(struct acpi
    1.41  	if (ACPI_SUCCESS(status))
    1.42  		result = acpi_pci_irq_add_prt(device->handle, root->id.segment,
    1.43  					      root->id.bus);
    1.44 +	if (result)
    1.45 +		goto end;
    1.46 +
    1.47 +	sysfs_create_file(&device->kobj, &acpi_device_attr_seg.attr);
    1.48 +
    1.49 +	sysfs_create_file(&device->kobj, &acpi_device_attr_bbn.attr);
    1.50  
    1.51        end:
    1.52  	if (result) {
     2.1 --- a/drivers/acpi/scan.c	Thu Dec 18 11:51:36 2008 +0000
     2.2 +++ b/drivers/acpi/scan.c	Mon Jan 05 10:53:06 2009 +0000
     2.3 @@ -32,12 +32,6 @@ static void acpi_device_release(struct k
     2.4  	kfree(dev);
     2.5  }
     2.6  
     2.7 -struct acpi_device_attribute {
     2.8 -	struct attribute attr;
     2.9 -	 ssize_t(*show) (struct acpi_device *, char *);
    2.10 -	 ssize_t(*store) (struct acpi_device *, const char *, size_t);
    2.11 -};
    2.12 -
    2.13  typedef void acpi_device_sysfs_files(struct kobject *,
    2.14  				     const struct attribute *);
    2.15  
    2.16 @@ -111,6 +105,42 @@ static struct kset acpi_namespace_kset =
    2.17  	.uevent_ops = &namespace_uevent_ops,
    2.18  };
    2.19  
    2.20 +static ssize_t
    2.21 +acpi_device_hid_show(struct acpi_device *acpi_dev, char *buf) 
    2.22 +{
    2.23 +	return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id);
    2.24 +}
    2.25 +ACPI_DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
    2.26 +
    2.27 +static ssize_t
    2.28 +acpi_device_uid_show(struct acpi_device *acpi_dev, char *buf) 
    2.29 +{
    2.30 +	return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
    2.31 +}
    2.32 +ACPI_DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
    2.33 +
    2.34 +static int acpi_device_setup_files(struct acpi_device *dev)
    2.35 +{
    2.36 +	int result = 0;
    2.37 +
    2.38 +	if (dev->flags.hardware_id) {
    2.39 +		result = sysfs_create_file(&dev->kobj,
    2.40 +					&acpi_device_attr_hid.attr);
    2.41 +		if (result)
    2.42 +			goto end;
    2.43 +	}
    2.44 +
    2.45 +	if (dev->flags.unique_id) {
    2.46 +		result = sysfs_create_file(&dev->kobj,
    2.47 +					&acpi_device_attr_uid.attr);
    2.48 +		if (result)
    2.49 +			goto end;
    2.50 +	}
    2.51 +
    2.52 +      end:
    2.53 +	return result;
    2.54 +}
    2.55 +
    2.56  static void acpi_device_register(struct acpi_device *device,
    2.57  				 struct acpi_device *parent)
    2.58  {
    2.59 @@ -146,6 +176,7 @@ static void acpi_device_register(struct 
    2.60  		printk(KERN_WARNING "%s: kobject_register error: %d\n",
    2.61  			__FUNCTION__, err);
    2.62  	create_sysfs_device_files(device);
    2.63 +	acpi_device_setup_files(device);
    2.64  }
    2.65  
    2.66  static void acpi_device_unregister(struct acpi_device *device, int type)
    2.67 @@ -344,10 +375,6 @@ static int acpi_bus_get_wakeup_device_fl
    2.68  static ssize_t acpi_eject_store(struct acpi_device *device,
    2.69  				const char *buf, size_t count);
    2.70  
    2.71 -#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
    2.72 -static struct acpi_device_attribute acpi_device_attr_##_name = \
    2.73 -		__ATTR(_name, _mode, _show, _store)
    2.74 -
    2.75  ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
    2.76  
    2.77  /**
     3.1 --- a/include/acpi/acpi_bus.h	Thu Dec 18 11:51:36 2008 +0000
     3.2 +++ b/include/acpi/acpi_bus.h	Mon Jan 05 10:53:06 2009 +0000
     3.3 @@ -359,6 +359,16 @@ acpi_handle acpi_get_child(acpi_handle, 
     3.4  acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
     3.5  #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data))
     3.6  
     3.7 +#define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
     3.8 +static struct acpi_device_attribute acpi_device_attr_##_name = \
     3.9 +		__ATTR(_name, _mode, _show, _store)
    3.10 +
    3.11 +struct acpi_device_attribute {
    3.12 +	struct attribute attr;
    3.13 +	ssize_t(*show) (struct acpi_device *, char *);
    3.14 +	ssize_t(*store) (struct acpi_device *, const char *, size_t);
    3.15 +};
    3.16 +
    3.17  #endif /* CONFIG_ACPI */
    3.18  
    3.19  #endif /*__ACPI_BUS_H__*/