Skip to content

Commit 2aa1e46

Browse files
committed
ACPI: sysfs: Add device cid attribute for exposing _CID lists
Add a new sysfs attribute called "cid" under struct acpi_device for exposing the list of compatible device IDs returned by the device's _CID object, if present. The new attribute will be present only if the _CID object is present. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/5957407.DvuYhMxLoT@rafael.j.wysocki
1 parent f8f9c1f commit 2aa1e46

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

drivers/acpi/device_sysfs.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,33 @@ hid_show(struct device *dev, struct device_attribute *attr, char *buf)
403403
}
404404
static DEVICE_ATTR_RO(hid);
405405

406+
static ssize_t cid_show(struct device *dev, struct device_attribute *attr,
407+
char *buf)
408+
{
409+
struct acpi_device *acpi_dev = to_acpi_device(dev);
410+
struct acpi_device_info *info = NULL;
411+
ssize_t len = 0;
412+
413+
acpi_get_object_info(acpi_dev->handle, &info);
414+
if (!info)
415+
return 0;
416+
417+
if (info->valid & ACPI_VALID_CID) {
418+
struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list;
419+
int i;
420+
421+
for (i = 0; i < cid_list->count - 1; i++)
422+
len += sysfs_emit_at(buf, len, "%s,", cid_list->ids[i].string);
423+
424+
len += sysfs_emit_at(buf, len, "%s\n", cid_list->ids[i].string);
425+
}
426+
427+
kfree(info);
428+
429+
return len;
430+
}
431+
static DEVICE_ATTR_RO(cid);
432+
406433
static ssize_t uid_show(struct device *dev,
407434
struct device_attribute *attr, char *buf)
408435
{
@@ -520,6 +547,7 @@ static DEVICE_ATTR_RO(status);
520547
static struct attribute *acpi_attrs[] = {
521548
&dev_attr_path.attr,
522549
&dev_attr_hid.attr,
550+
&dev_attr_cid.attr,
523551
&dev_attr_modalias.attr,
524552
&dev_attr_description.attr,
525553
&dev_attr_adr.attr,
@@ -562,6 +590,9 @@ static bool acpi_show_attr(struct acpi_device *dev, const struct device_attribut
562590
if (attr == &dev_attr_status)
563591
return acpi_has_method(dev->handle, "_STA");
564592

593+
if (attr == &dev_attr_cid)
594+
return acpi_has_method(dev->handle, "_CID");
595+
565596
/*
566597
* If device has _EJ0, 'eject' file is created that is used to trigger
567598
* hot-removal function from userland.

0 commit comments

Comments
 (0)