drivers/pci/pci-label.c
Source file repositories/reference/linux-study-clean/drivers/pci/pci-label.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pci-label.c- Extension
.c- Size
- 5767 bytes
- Lines
- 232
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dmi.hlinux/sysfs.hlinux/pci.hlinux/pci_ids.hlinux/module.hlinux/device.hlinux/nls.hlinux/acpi.hlinux/pci-acpi.hpci.h
Detected Declarations
enum smbios_attr_enumenum acpi_attr_enumfunction Copyrightfunction find_smbios_instance_stringfunction smbios_label_showfunction index_showfunction smbios_attr_is_visiblefunction dsm_label_utf16s_to_utf8sfunction dsm_get_labelfunction label_showfunction acpi_index_showfunction acpi_attr_is_visible
Annotated Snippet
if (buf) {
if (attribute == SMBIOS_ATTR_INSTANCE_SHOW)
return sysfs_emit(buf, "%d\n",
donboard->instance);
else if (attribute == SMBIOS_ATTR_LABEL_SHOW)
return sysfs_emit(buf, "%s\n",
dmi->name);
}
return strlen(dmi->name);
}
}
return 0;
}
static ssize_t smbios_label_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
return find_smbios_instance_string(pdev, buf,
SMBIOS_ATTR_LABEL_SHOW);
}
static struct device_attribute dev_attr_smbios_label = __ATTR(label, 0444,
smbios_label_show, NULL);
static ssize_t index_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
return find_smbios_instance_string(pdev, buf,
SMBIOS_ATTR_INSTANCE_SHOW);
}
static DEVICE_ATTR_RO(index);
static struct attribute *smbios_attrs[] = {
&dev_attr_smbios_label.attr,
&dev_attr_index.attr,
NULL,
};
static umode_t smbios_attr_is_visible(struct kobject *kobj, struct attribute *a,
int n)
{
struct device *dev = kobj_to_dev(kobj);
struct pci_dev *pdev = to_pci_dev(dev);
if (device_has_acpi_name(dev))
return 0;
if (!find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE))
return 0;
return a->mode;
}
const struct attribute_group pci_dev_smbios_attr_group = {
.attrs = smbios_attrs,
.is_visible = smbios_attr_is_visible,
};
#endif
#ifdef CONFIG_ACPI
enum acpi_attr_enum {
ACPI_ATTR_LABEL_SHOW,
ACPI_ATTR_INDEX_SHOW,
};
static int dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
{
int len;
len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
obj->buffer.length,
UTF16_LITTLE_ENDIAN,
buf, PAGE_SIZE - 1);
buf[len++] = '\n';
return len;
}
static int dsm_get_label(struct device *dev, char *buf,
enum acpi_attr_enum attr)
{
acpi_handle handle = ACPI_HANDLE(dev);
union acpi_object *obj, *tmp;
int len = 0;
if (!handle)
return -1;
Annotation
- Immediate include surface: `linux/dmi.h`, `linux/sysfs.h`, `linux/pci.h`, `linux/pci_ids.h`, `linux/module.h`, `linux/device.h`, `linux/nls.h`, `linux/acpi.h`.
- Detected declarations: `enum smbios_attr_enum`, `enum acpi_attr_enum`, `function Copyright`, `function find_smbios_instance_string`, `function smbios_label_show`, `function index_show`, `function smbios_attr_is_visible`, `function dsm_label_utf16s_to_utf8s`, `function dsm_get_label`, `function label_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.