drivers/acpi/device_sysfs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/acpi/device_sysfs.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -403,6 +403,33 @@ hid_show(struct device *dev, struct devi
}
static DEVICE_ATTR_RO(hid);
+static ssize_t cid_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct acpi_device *acpi_dev = to_acpi_device(dev);
+ struct acpi_device_info *info = NULL;
+ ssize_t len = 0;
+
+ acpi_get_object_info(acpi_dev->handle, &info);
+ if (!info)
+ return 0;
+
+ if (info->valid & ACPI_VALID_CID) {
+ struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list;
+ int i;
+
+ for (i = 0; i < cid_list->count - 1; i++)
+ len += sysfs_emit(buf, "%s,", cid_list->ids[i].string);
+
+ len += sysfs_emit(buf, "%s\n", cid_list->ids[i].string);
+ }
+
+ kfree(info);
+
+ return len;
+}
+static DEVICE_ATTR_RO(cid);
+
static ssize_t uid_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -520,6 +547,7 @@ static DEVICE_ATTR_RO(status);
static struct attribute *acpi_attrs[] = {
&dev_attr_path.attr,
&dev_attr_hid.attr,
+ &dev_attr_cid.attr,
&dev_attr_modalias.attr,
&dev_attr_description.attr,
&dev_attr_adr.attr,
@@ -562,6 +590,9 @@ static bool acpi_show_attr(struct acpi_d
if (attr == &dev_attr_status)
return acpi_has_method(dev->handle, "_STA");
+ if (attr == &dev_attr_cid)
+ return acpi_has_method(dev->handle, "_CID");
+
/*
* If device has _EJ0, 'eject' file is created that is used to trigger
* hot-removal function from userland.
On Fri, Dec 12, 2025 at 09:52:44PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
...
> +static ssize_t cid_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct acpi_device *acpi_dev = to_acpi_device(dev);
> + struct acpi_device_info *info = NULL;
> + ssize_t len = 0;
> +
> + acpi_get_object_info(acpi_dev->handle, &info);
> + if (!info)
> + return 0;
> +
> + if (info->valid & ACPI_VALID_CID) {
> + struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list;
> + int i;
> +
> + for (i = 0; i < cid_list->count - 1; i++)
> + len += sysfs_emit(buf, "%s,", cid_list->ids[i].string);
> +
> + len += sysfs_emit(buf, "%s\n", cid_list->ids[i].string);
You definitely meant to use sysfs_emit_at().
> + }
> +
> + kfree(info);
> +
> + return len;
> +}
> +static DEVICE_ATTR_RO(cid);
Do wee have any ABI documentation for these sysfs attributes?
If so, it needs to be updated, otherwise perhaps create one?
--
With Best Regards,
Andy Shevchenko
On Sun, Dec 28, 2025 at 9:19 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Dec 12, 2025 at 09:52:44PM +0100, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > 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.
>
> ...
>
> > +static ssize_t cid_show(struct device *dev, struct device_attribute *attr,
> > + char *buf)
> > +{
> > + struct acpi_device *acpi_dev = to_acpi_device(dev);
> > + struct acpi_device_info *info = NULL;
> > + ssize_t len = 0;
> > +
> > + acpi_get_object_info(acpi_dev->handle, &info);
> > + if (!info)
> > + return 0;
> > +
> > + if (info->valid & ACPI_VALID_CID) {
> > + struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list;
> > + int i;
> > +
> > + for (i = 0; i < cid_list->count - 1; i++)
> > + len += sysfs_emit(buf, "%s,", cid_list->ids[i].string);
> > +
> > + len += sysfs_emit(buf, "%s\n", cid_list->ids[i].string);
>
> You definitely meant to use sysfs_emit_at().
Right, thanks!
> > + }
> > +
> > + kfree(info);
> > +
> > + return len;
> > +}
> > +static DEVICE_ATTR_RO(cid);
>
> Do wee have any ABI documentation for these sysfs attributes?
No, there's none I know of.
> If so, it needs to be updated, otherwise perhaps create one?
Well, feel free to do so.
© 2016 - 2026 Red Hat, Inc.