25 #include <linux/pci.h>
27 #include <linux/module.h>
28 #include <linux/device.h>
35 #define DEVICE_LABEL_DSM 0x07
40 pci_create_smbiosname_file(
struct pci_dev *pdev)
46 pci_remove_smbiosname_file(
struct pci_dev *pdev)
52 enum smbios_attr_enum {
54 SMBIOS_ATTR_LABEL_SHOW,
55 SMBIOS_ATTR_INSTANCE_SHOW,
59 find_smbios_instance_string(
struct pci_dev *pdev,
char *
buf,
63 struct dmi_dev_onboard *donboard;
67 bus = pdev->
bus->number;
74 if (donboard && donboard->bus == bus &&
75 donboard->devfn == devfn) {
77 if (attribute == SMBIOS_ATTR_INSTANCE_SHOW)
81 else if (attribute == SMBIOS_ATTR_LABEL_SHOW)
93 smbios_instance_string_exist(
struct kobject *kobj,
struct attribute *
attr,
102 return find_smbios_instance_string(pdev,
NULL, SMBIOS_ATTR_NONE) ?
112 return find_smbios_instance_string(pdev, buf,
113 SMBIOS_ATTR_LABEL_SHOW);
123 return find_smbios_instance_string(pdev, buf,
124 SMBIOS_ATTR_INSTANCE_SHOW);
128 .
attr = {.name =
"label", .mode = 0444},
129 .show = smbioslabel_show,
133 .
attr = {.name =
"index", .mode = 0444},
134 .show = smbiosinstance_show,
137 static struct attribute *smbios_attributes[] = {
138 &smbios_attr_label.
attr,
139 &smbios_attr_instance.
attr,
144 .
attrs = smbios_attributes,
145 .is_visible = smbios_instance_string_exist,
149 pci_create_smbiosname_file(
struct pci_dev *pdev)
155 pci_remove_smbiosname_file(
struct pci_dev *pdev)
165 pci_create_acpi_index_label_files(
struct pci_dev *pdev)
171 pci_remove_acpi_index_label_files(
struct pci_dev *pdev)
184 static const char device_label_dsm_uuid[] = {
185 0xD0, 0x37, 0xC9, 0xE5, 0x53, 0x35, 0x7A, 0x4D,
186 0x91, 0x17, 0xEA, 0x4D, 0x19, 0xC3, 0x43, 0x4D
189 enum acpi_attr_enum {
191 ACPI_ATTR_LABEL_SHOW,
192 ACPI_ATTR_INDEX_SHOW,
195 static void dsm_label_utf16s_to_utf8s(
union acpi_object *obj,
char *buf)
200 obj->
package.elements[1].string.length,
209 char *buf,
enum acpi_attr_enum attribute)
221 params[0].buffer.length =
sizeof(device_label_dsm_uuid);
222 params[0].buffer.pointer = (
char *)device_label_dsm_uuid;
224 params[1].integer.value = 0x02;
228 params[3].package.count = 0;
241 len = obj->
package.elements[0].integer.value;
243 if (attribute == ACPI_ATTR_INDEX_SHOW)
245 obj->
package.elements[0].integer.value);
246 else if (attribute == ACPI_ATTR_LABEL_SHOW)
247 dsm_label_utf16s_to_utf8s(obj, buf);
266 handle = DEVICE_ACPI_HANDLE(dev);
279 acpi_index_string_exist(
struct kobject *kobj,
struct attribute *
attr,
int n)
285 if (device_has_dsm(dev))
298 handle = DEVICE_ACPI_HANDLE(dev);
304 &output, buf, ACPI_ATTR_LABEL_SHOW);
319 handle = DEVICE_ACPI_HANDLE(dev);
325 &output, buf, ACPI_ATTR_INDEX_SHOW);
335 .
attr = {.name =
"label", .mode = 0444},
336 .show = acpilabel_show,
340 .
attr = {.name =
"acpi_index", .mode = 0444},
341 .show = acpiindex_show,
344 static struct attribute *acpi_attributes[] = {
345 &acpi_attr_label.
attr,
346 &acpi_attr_index.
attr,
351 .
attrs = acpi_attributes,
352 .is_visible = acpi_index_string_exist,
356 pci_create_acpi_index_label_files(
struct pci_dev *pdev)
362 pci_remove_acpi_index_label_files(
struct pci_dev *pdev)
371 if (device_has_dsm(&pdev->
dev))
372 pci_create_acpi_index_label_files(pdev);
374 pci_create_smbiosname_file(pdev);
379 if (device_has_dsm(&pdev->
dev))
380 pci_remove_acpi_index_label_files(pdev);
382 pci_remove_smbiosname_file(pdev);