xref: /openbmc/linux/drivers/pci/pci-label.c (revision 3a83f992)
1911e1c9bSNarendra K /*
2911e1c9bSNarendra K  * Purpose: Export the firmware instance and label associated with
3911e1c9bSNarendra K  * a pci device to sysfs
4911e1c9bSNarendra K  * Copyright (C) 2010 Dell Inc.
5911e1c9bSNarendra K  * by Narendra K <Narendra_K@dell.com>,
6911e1c9bSNarendra K  * Jordan Hargrave <Jordan_Hargrave@dell.com>
7911e1c9bSNarendra K  *
86058989bSNarendra_K@Dell.com  * PCI Firmware Specification Revision 3.1 section 4.6.7 (DSM for Naming a
96058989bSNarendra_K@Dell.com  * PCI or PCI Express Device Under Operating Systems) defines an instance
106058989bSNarendra_K@Dell.com  * number and string name. This code retrieves them and exports them to sysfs.
116058989bSNarendra_K@Dell.com  * If the system firmware does not provide the ACPI _DSM (Device Specific
126058989bSNarendra_K@Dell.com  * Method), then the SMBIOS type 41 instance number and string is exported to
136058989bSNarendra_K@Dell.com  * sysfs.
146058989bSNarendra_K@Dell.com  *
15911e1c9bSNarendra K  * SMBIOS defines type 41 for onboard pci devices. This code retrieves
16911e1c9bSNarendra K  * the instance number and string from the type 41 record and exports
17911e1c9bSNarendra K  * it to sysfs.
18911e1c9bSNarendra K  *
19911e1c9bSNarendra K  * Please see http://linux.dell.com/wiki/index.php/Oss/libnetdevname for more
20911e1c9bSNarendra K  * information.
21911e1c9bSNarendra K  */
22911e1c9bSNarendra K 
23911e1c9bSNarendra K #include <linux/dmi.h>
24911e1c9bSNarendra K #include <linux/sysfs.h>
25911e1c9bSNarendra K #include <linux/pci.h>
26911e1c9bSNarendra K #include <linux/pci_ids.h>
27911e1c9bSNarendra K #include <linux/module.h>
28911e1c9bSNarendra K #include <linux/device.h>
296058989bSNarendra_K@Dell.com #include <linux/nls.h>
306058989bSNarendra_K@Dell.com #include <linux/acpi.h>
316058989bSNarendra_K@Dell.com #include <linux/pci-acpi.h>
326058989bSNarendra_K@Dell.com #include <acpi/acpi_bus.h>
33911e1c9bSNarendra K #include "pci.h"
34911e1c9bSNarendra K 
356058989bSNarendra_K@Dell.com #define	DEVICE_LABEL_DSM	0x07
366058989bSNarendra_K@Dell.com 
376058989bSNarendra_K@Dell.com #ifndef CONFIG_DMI
386058989bSNarendra_K@Dell.com 
396058989bSNarendra_K@Dell.com static inline int
406058989bSNarendra_K@Dell.com pci_create_smbiosname_file(struct pci_dev *pdev)
416058989bSNarendra_K@Dell.com {
426058989bSNarendra_K@Dell.com 	return -1;
436058989bSNarendra_K@Dell.com }
446058989bSNarendra_K@Dell.com 
456058989bSNarendra_K@Dell.com static inline void
466058989bSNarendra_K@Dell.com pci_remove_smbiosname_file(struct pci_dev *pdev)
476058989bSNarendra_K@Dell.com {
486058989bSNarendra_K@Dell.com }
496058989bSNarendra_K@Dell.com 
506058989bSNarendra_K@Dell.com #else
516058989bSNarendra_K@Dell.com 
52911e1c9bSNarendra K enum smbios_attr_enum {
53911e1c9bSNarendra K 	SMBIOS_ATTR_NONE = 0,
54911e1c9bSNarendra K 	SMBIOS_ATTR_LABEL_SHOW,
55911e1c9bSNarendra K 	SMBIOS_ATTR_INSTANCE_SHOW,
56911e1c9bSNarendra K };
57911e1c9bSNarendra K 
58ed476418SAl Viro static size_t
59911e1c9bSNarendra K find_smbios_instance_string(struct pci_dev *pdev, char *buf,
60911e1c9bSNarendra K 			    enum smbios_attr_enum attribute)
61911e1c9bSNarendra K {
62911e1c9bSNarendra K 	const struct dmi_device *dmi;
63911e1c9bSNarendra K 	struct dmi_dev_onboard *donboard;
64911e1c9bSNarendra K 	int bus;
65911e1c9bSNarendra K 	int devfn;
66911e1c9bSNarendra K 
67911e1c9bSNarendra K 	bus = pdev->bus->number;
68911e1c9bSNarendra K 	devfn = pdev->devfn;
69911e1c9bSNarendra K 
70911e1c9bSNarendra K 	dmi = NULL;
71911e1c9bSNarendra K 	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD,
72911e1c9bSNarendra K 				      NULL, dmi)) != NULL) {
73911e1c9bSNarendra K 		donboard = dmi->device_data;
74911e1c9bSNarendra K 		if (donboard && donboard->bus == bus &&
75911e1c9bSNarendra K 					donboard->devfn == devfn) {
76911e1c9bSNarendra K 			if (buf) {
77911e1c9bSNarendra K 				if (attribute == SMBIOS_ATTR_INSTANCE_SHOW)
78911e1c9bSNarendra K 					return scnprintf(buf, PAGE_SIZE,
79911e1c9bSNarendra K 							 "%d\n",
80911e1c9bSNarendra K 							 donboard->instance);
81911e1c9bSNarendra K 				else if (attribute == SMBIOS_ATTR_LABEL_SHOW)
82911e1c9bSNarendra K 					return scnprintf(buf, PAGE_SIZE,
83911e1c9bSNarendra K 							 "%s\n",
84911e1c9bSNarendra K 							 dmi->name);
85911e1c9bSNarendra K 			}
86911e1c9bSNarendra K 			return strlen(dmi->name);
87911e1c9bSNarendra K 		}
88911e1c9bSNarendra K 	}
89911e1c9bSNarendra K 	return 0;
90911e1c9bSNarendra K }
91911e1c9bSNarendra K 
92587a1f16SAl Viro static umode_t
93911e1c9bSNarendra K smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
94911e1c9bSNarendra K 			     int n)
95911e1c9bSNarendra K {
96911e1c9bSNarendra K 	struct device *dev;
97911e1c9bSNarendra K 	struct pci_dev *pdev;
98911e1c9bSNarendra K 
99911e1c9bSNarendra K 	dev = container_of(kobj, struct device, kobj);
100911e1c9bSNarendra K 	pdev = to_pci_dev(dev);
101911e1c9bSNarendra K 
102911e1c9bSNarendra K 	return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE) ?
103911e1c9bSNarendra K 					   S_IRUGO : 0;
104911e1c9bSNarendra K }
105911e1c9bSNarendra K 
106911e1c9bSNarendra K static ssize_t
107911e1c9bSNarendra K smbioslabel_show(struct device *dev, struct device_attribute *attr, char *buf)
108911e1c9bSNarendra K {
109911e1c9bSNarendra K 	struct pci_dev *pdev;
110911e1c9bSNarendra K 	pdev = to_pci_dev(dev);
111911e1c9bSNarendra K 
112911e1c9bSNarendra K 	return find_smbios_instance_string(pdev, buf,
113911e1c9bSNarendra K 					   SMBIOS_ATTR_LABEL_SHOW);
114911e1c9bSNarendra K }
115911e1c9bSNarendra K 
116911e1c9bSNarendra K static ssize_t
117911e1c9bSNarendra K smbiosinstance_show(struct device *dev,
118911e1c9bSNarendra K 		    struct device_attribute *attr, char *buf)
119911e1c9bSNarendra K {
120911e1c9bSNarendra K 	struct pci_dev *pdev;
121911e1c9bSNarendra K 	pdev = to_pci_dev(dev);
122911e1c9bSNarendra K 
123911e1c9bSNarendra K 	return find_smbios_instance_string(pdev, buf,
124911e1c9bSNarendra K 					   SMBIOS_ATTR_INSTANCE_SHOW);
125911e1c9bSNarendra K }
126911e1c9bSNarendra K 
127911e1c9bSNarendra K static struct device_attribute smbios_attr_label = {
128763e9db9SStephen Rothwell 	.attr = {.name = "label", .mode = 0444},
129911e1c9bSNarendra K 	.show = smbioslabel_show,
130911e1c9bSNarendra K };
131911e1c9bSNarendra K 
132911e1c9bSNarendra K static struct device_attribute smbios_attr_instance = {
133763e9db9SStephen Rothwell 	.attr = {.name = "index", .mode = 0444},
134911e1c9bSNarendra K 	.show = smbiosinstance_show,
135911e1c9bSNarendra K };
136911e1c9bSNarendra K 
137911e1c9bSNarendra K static struct attribute *smbios_attributes[] = {
138911e1c9bSNarendra K 	&smbios_attr_label.attr,
139911e1c9bSNarendra K 	&smbios_attr_instance.attr,
140911e1c9bSNarendra K 	NULL,
141911e1c9bSNarendra K };
142911e1c9bSNarendra K 
143911e1c9bSNarendra K static struct attribute_group smbios_attr_group = {
144911e1c9bSNarendra K 	.attrs = smbios_attributes,
145911e1c9bSNarendra K 	.is_visible = smbios_instance_string_exist,
146911e1c9bSNarendra K };
147911e1c9bSNarendra K 
148911e1c9bSNarendra K static int
149911e1c9bSNarendra K pci_create_smbiosname_file(struct pci_dev *pdev)
150911e1c9bSNarendra K {
1516058989bSNarendra_K@Dell.com 	return sysfs_create_group(&pdev->dev.kobj, &smbios_attr_group);
152911e1c9bSNarendra K }
153911e1c9bSNarendra K 
154911e1c9bSNarendra K static void
155911e1c9bSNarendra K pci_remove_smbiosname_file(struct pci_dev *pdev)
156911e1c9bSNarendra K {
157911e1c9bSNarendra K 	sysfs_remove_group(&pdev->dev.kobj, &smbios_attr_group);
158911e1c9bSNarendra K }
159911e1c9bSNarendra K 
1606058989bSNarendra_K@Dell.com #endif
1616058989bSNarendra_K@Dell.com 
1626058989bSNarendra_K@Dell.com #ifndef CONFIG_ACPI
1636058989bSNarendra_K@Dell.com 
1646058989bSNarendra_K@Dell.com static inline int
1656058989bSNarendra_K@Dell.com pci_create_acpi_index_label_files(struct pci_dev *pdev)
1666058989bSNarendra_K@Dell.com {
1676058989bSNarendra_K@Dell.com 	return -1;
1686058989bSNarendra_K@Dell.com }
1696058989bSNarendra_K@Dell.com 
1706058989bSNarendra_K@Dell.com static inline int
1716058989bSNarendra_K@Dell.com pci_remove_acpi_index_label_files(struct pci_dev *pdev)
1726058989bSNarendra_K@Dell.com {
1736058989bSNarendra_K@Dell.com 	return -1;
1746058989bSNarendra_K@Dell.com }
1756058989bSNarendra_K@Dell.com 
17607eefe1cSNarendra_K@Dell.com static inline bool
17707eefe1cSNarendra_K@Dell.com device_has_dsm(struct device *dev)
17807eefe1cSNarendra_K@Dell.com {
17907eefe1cSNarendra_K@Dell.com 	return false;
18007eefe1cSNarendra_K@Dell.com }
18107eefe1cSNarendra_K@Dell.com 
1826058989bSNarendra_K@Dell.com #else
1836058989bSNarendra_K@Dell.com 
1846058989bSNarendra_K@Dell.com static const char device_label_dsm_uuid[] = {
1856058989bSNarendra_K@Dell.com 	0xD0, 0x37, 0xC9, 0xE5, 0x53, 0x35, 0x7A, 0x4D,
1866058989bSNarendra_K@Dell.com 	0x91, 0x17, 0xEA, 0x4D, 0x19, 0xC3, 0x43, 0x4D
1876058989bSNarendra_K@Dell.com };
1886058989bSNarendra_K@Dell.com 
1896058989bSNarendra_K@Dell.com enum acpi_attr_enum {
1906058989bSNarendra_K@Dell.com 	ACPI_ATTR_NONE = 0,
1916058989bSNarendra_K@Dell.com 	ACPI_ATTR_LABEL_SHOW,
1926058989bSNarendra_K@Dell.com 	ACPI_ATTR_INDEX_SHOW,
1936058989bSNarendra_K@Dell.com };
1946058989bSNarendra_K@Dell.com 
1956058989bSNarendra_K@Dell.com static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
1966058989bSNarendra_K@Dell.com {
1976058989bSNarendra_K@Dell.com 	int len;
1986058989bSNarendra_K@Dell.com 	len = utf16s_to_utf8s((const wchar_t *)obj->
1996058989bSNarendra_K@Dell.com 			      package.elements[1].string.pointer,
2006058989bSNarendra_K@Dell.com 			      obj->package.elements[1].string.length,
2016058989bSNarendra_K@Dell.com 			      UTF16_LITTLE_ENDIAN,
2026058989bSNarendra_K@Dell.com 			      buf, PAGE_SIZE);
2036058989bSNarendra_K@Dell.com 	buf[len] = '\n';
2046058989bSNarendra_K@Dell.com }
2056058989bSNarendra_K@Dell.com 
2066058989bSNarendra_K@Dell.com static int
2076058989bSNarendra_K@Dell.com dsm_get_label(acpi_handle handle, int func,
2086058989bSNarendra_K@Dell.com 	      struct acpi_buffer *output,
2096058989bSNarendra_K@Dell.com 	      char *buf, enum acpi_attr_enum attribute)
2106058989bSNarendra_K@Dell.com {
2116058989bSNarendra_K@Dell.com 	struct acpi_object_list input;
2126058989bSNarendra_K@Dell.com 	union acpi_object params[4];
2136058989bSNarendra_K@Dell.com 	union acpi_object *obj;
2146058989bSNarendra_K@Dell.com 	int len = 0;
2156058989bSNarendra_K@Dell.com 
2166058989bSNarendra_K@Dell.com 	int err;
2176058989bSNarendra_K@Dell.com 
2186058989bSNarendra_K@Dell.com 	input.count = 4;
2196058989bSNarendra_K@Dell.com 	input.pointer = params;
2206058989bSNarendra_K@Dell.com 	params[0].type = ACPI_TYPE_BUFFER;
2216058989bSNarendra_K@Dell.com 	params[0].buffer.length = sizeof(device_label_dsm_uuid);
2226058989bSNarendra_K@Dell.com 	params[0].buffer.pointer = (char *)device_label_dsm_uuid;
2236058989bSNarendra_K@Dell.com 	params[1].type = ACPI_TYPE_INTEGER;
2246058989bSNarendra_K@Dell.com 	params[1].integer.value = 0x02;
2256058989bSNarendra_K@Dell.com 	params[2].type = ACPI_TYPE_INTEGER;
2266058989bSNarendra_K@Dell.com 	params[2].integer.value = func;
2276058989bSNarendra_K@Dell.com 	params[3].type = ACPI_TYPE_PACKAGE;
2286058989bSNarendra_K@Dell.com 	params[3].package.count = 0;
2296058989bSNarendra_K@Dell.com 	params[3].package.elements = NULL;
2306058989bSNarendra_K@Dell.com 
2316058989bSNarendra_K@Dell.com 	err = acpi_evaluate_object(handle, "_DSM", &input, output);
2326058989bSNarendra_K@Dell.com 	if (err)
2336058989bSNarendra_K@Dell.com 		return -1;
2346058989bSNarendra_K@Dell.com 
2356058989bSNarendra_K@Dell.com 	obj = (union acpi_object *)output->pointer;
2366058989bSNarendra_K@Dell.com 
2376058989bSNarendra_K@Dell.com 	switch (obj->type) {
2386058989bSNarendra_K@Dell.com 	case ACPI_TYPE_PACKAGE:
2396058989bSNarendra_K@Dell.com 		if (obj->package.count != 2)
2406058989bSNarendra_K@Dell.com 			break;
2416058989bSNarendra_K@Dell.com 		len = obj->package.elements[0].integer.value;
2426058989bSNarendra_K@Dell.com 		if (buf) {
2436058989bSNarendra_K@Dell.com 			if (attribute == ACPI_ATTR_INDEX_SHOW)
2446058989bSNarendra_K@Dell.com 				scnprintf(buf, PAGE_SIZE, "%llu\n",
2456058989bSNarendra_K@Dell.com 				obj->package.elements[0].integer.value);
2466058989bSNarendra_K@Dell.com 			else if (attribute == ACPI_ATTR_LABEL_SHOW)
2476058989bSNarendra_K@Dell.com 				dsm_label_utf16s_to_utf8s(obj, buf);
2486058989bSNarendra_K@Dell.com 			kfree(output->pointer);
2496058989bSNarendra_K@Dell.com 			return strlen(buf);
2506058989bSNarendra_K@Dell.com 		}
2516058989bSNarendra_K@Dell.com 		kfree(output->pointer);
2526058989bSNarendra_K@Dell.com 		return len;
2536058989bSNarendra_K@Dell.com 	break;
2546058989bSNarendra_K@Dell.com 	default:
2556058989bSNarendra_K@Dell.com 		kfree(output->pointer);
2566058989bSNarendra_K@Dell.com 	}
2576058989bSNarendra_K@Dell.com 	return -1;
2586058989bSNarendra_K@Dell.com }
2596058989bSNarendra_K@Dell.com 
2606058989bSNarendra_K@Dell.com static bool
2616058989bSNarendra_K@Dell.com device_has_dsm(struct device *dev)
2626058989bSNarendra_K@Dell.com {
2636058989bSNarendra_K@Dell.com 	acpi_handle handle;
2646058989bSNarendra_K@Dell.com 	struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
2656058989bSNarendra_K@Dell.com 
2663a83f992SRafael J. Wysocki 	handle = ACPI_HANDLE(dev);
2676058989bSNarendra_K@Dell.com 
2686058989bSNarendra_K@Dell.com 	if (!handle)
2696058989bSNarendra_K@Dell.com 		return FALSE;
2706058989bSNarendra_K@Dell.com 
2716058989bSNarendra_K@Dell.com 	if (dsm_get_label(handle, DEVICE_LABEL_DSM, &output, NULL,
2726058989bSNarendra_K@Dell.com 			  ACPI_ATTR_NONE) > 0)
2736058989bSNarendra_K@Dell.com 		return TRUE;
2746058989bSNarendra_K@Dell.com 
2756058989bSNarendra_K@Dell.com 	return FALSE;
2766058989bSNarendra_K@Dell.com }
2776058989bSNarendra_K@Dell.com 
278587a1f16SAl Viro static umode_t
2796058989bSNarendra_K@Dell.com acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
2806058989bSNarendra_K@Dell.com {
2816058989bSNarendra_K@Dell.com 	struct device *dev;
2826058989bSNarendra_K@Dell.com 
2836058989bSNarendra_K@Dell.com 	dev = container_of(kobj, struct device, kobj);
2846058989bSNarendra_K@Dell.com 
2856058989bSNarendra_K@Dell.com 	if (device_has_dsm(dev))
2866058989bSNarendra_K@Dell.com 		return S_IRUGO;
2876058989bSNarendra_K@Dell.com 
2886058989bSNarendra_K@Dell.com 	return 0;
2896058989bSNarendra_K@Dell.com }
2906058989bSNarendra_K@Dell.com 
2916058989bSNarendra_K@Dell.com static ssize_t
2926058989bSNarendra_K@Dell.com acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf)
2936058989bSNarendra_K@Dell.com {
2946058989bSNarendra_K@Dell.com 	struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
2956058989bSNarendra_K@Dell.com 	acpi_handle handle;
2966058989bSNarendra_K@Dell.com 	int length;
2976058989bSNarendra_K@Dell.com 
2983a83f992SRafael J. Wysocki 	handle = ACPI_HANDLE(dev);
2996058989bSNarendra_K@Dell.com 
3006058989bSNarendra_K@Dell.com 	if (!handle)
3016058989bSNarendra_K@Dell.com 		return -1;
3026058989bSNarendra_K@Dell.com 
3036058989bSNarendra_K@Dell.com 	length = dsm_get_label(handle, DEVICE_LABEL_DSM,
3046058989bSNarendra_K@Dell.com 			       &output, buf, ACPI_ATTR_LABEL_SHOW);
3056058989bSNarendra_K@Dell.com 
3066058989bSNarendra_K@Dell.com 	if (length < 1)
3076058989bSNarendra_K@Dell.com 		return -1;
3086058989bSNarendra_K@Dell.com 
3096058989bSNarendra_K@Dell.com 	return length;
3106058989bSNarendra_K@Dell.com }
3116058989bSNarendra_K@Dell.com 
3126058989bSNarendra_K@Dell.com static ssize_t
3136058989bSNarendra_K@Dell.com acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf)
3146058989bSNarendra_K@Dell.com {
3156058989bSNarendra_K@Dell.com 	struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
3166058989bSNarendra_K@Dell.com 	acpi_handle handle;
3176058989bSNarendra_K@Dell.com 	int length;
3186058989bSNarendra_K@Dell.com 
3193a83f992SRafael J. Wysocki 	handle = ACPI_HANDLE(dev);
3206058989bSNarendra_K@Dell.com 
3216058989bSNarendra_K@Dell.com 	if (!handle)
3226058989bSNarendra_K@Dell.com 		return -1;
3236058989bSNarendra_K@Dell.com 
3246058989bSNarendra_K@Dell.com 	length = dsm_get_label(handle, DEVICE_LABEL_DSM,
3256058989bSNarendra_K@Dell.com 			       &output, buf, ACPI_ATTR_INDEX_SHOW);
3266058989bSNarendra_K@Dell.com 
3276058989bSNarendra_K@Dell.com 	if (length < 0)
3286058989bSNarendra_K@Dell.com 		return -1;
3296058989bSNarendra_K@Dell.com 
3306058989bSNarendra_K@Dell.com 	return length;
3316058989bSNarendra_K@Dell.com 
3326058989bSNarendra_K@Dell.com }
3336058989bSNarendra_K@Dell.com 
3346058989bSNarendra_K@Dell.com static struct device_attribute acpi_attr_label = {
3356058989bSNarendra_K@Dell.com 	.attr = {.name = "label", .mode = 0444},
3366058989bSNarendra_K@Dell.com 	.show = acpilabel_show,
3376058989bSNarendra_K@Dell.com };
3386058989bSNarendra_K@Dell.com 
3396058989bSNarendra_K@Dell.com static struct device_attribute acpi_attr_index = {
3406058989bSNarendra_K@Dell.com 	.attr = {.name = "acpi_index", .mode = 0444},
3416058989bSNarendra_K@Dell.com 	.show = acpiindex_show,
3426058989bSNarendra_K@Dell.com };
3436058989bSNarendra_K@Dell.com 
3446058989bSNarendra_K@Dell.com static struct attribute *acpi_attributes[] = {
3456058989bSNarendra_K@Dell.com 	&acpi_attr_label.attr,
3466058989bSNarendra_K@Dell.com 	&acpi_attr_index.attr,
3476058989bSNarendra_K@Dell.com 	NULL,
3486058989bSNarendra_K@Dell.com };
3496058989bSNarendra_K@Dell.com 
3506058989bSNarendra_K@Dell.com static struct attribute_group acpi_attr_group = {
3516058989bSNarendra_K@Dell.com 	.attrs = acpi_attributes,
3526058989bSNarendra_K@Dell.com 	.is_visible = acpi_index_string_exist,
3536058989bSNarendra_K@Dell.com };
3546058989bSNarendra_K@Dell.com 
3556058989bSNarendra_K@Dell.com static int
3566058989bSNarendra_K@Dell.com pci_create_acpi_index_label_files(struct pci_dev *pdev)
3576058989bSNarendra_K@Dell.com {
3586058989bSNarendra_K@Dell.com 	return sysfs_create_group(&pdev->dev.kobj, &acpi_attr_group);
3596058989bSNarendra_K@Dell.com }
3606058989bSNarendra_K@Dell.com 
3616058989bSNarendra_K@Dell.com static int
3626058989bSNarendra_K@Dell.com pci_remove_acpi_index_label_files(struct pci_dev *pdev)
3636058989bSNarendra_K@Dell.com {
3646058989bSNarendra_K@Dell.com 	sysfs_remove_group(&pdev->dev.kobj, &acpi_attr_group);
3656058989bSNarendra_K@Dell.com 	return 0;
3666058989bSNarendra_K@Dell.com }
3676058989bSNarendra_K@Dell.com #endif
3686058989bSNarendra_K@Dell.com 
369911e1c9bSNarendra K void pci_create_firmware_label_files(struct pci_dev *pdev)
370911e1c9bSNarendra K {
3716058989bSNarendra_K@Dell.com 	if (device_has_dsm(&pdev->dev))
3726058989bSNarendra_K@Dell.com 		pci_create_acpi_index_label_files(pdev);
3736058989bSNarendra_K@Dell.com 	else
3746058989bSNarendra_K@Dell.com 		pci_create_smbiosname_file(pdev);
375911e1c9bSNarendra K }
376911e1c9bSNarendra K 
377911e1c9bSNarendra K void pci_remove_firmware_label_files(struct pci_dev *pdev)
378911e1c9bSNarendra K {
3796058989bSNarendra_K@Dell.com 	if (device_has_dsm(&pdev->dev))
3806058989bSNarendra_K@Dell.com 		pci_remove_acpi_index_label_files(pdev);
3816058989bSNarendra_K@Dell.com 	else
382911e1c9bSNarendra K 		pci_remove_smbiosname_file(pdev);
383911e1c9bSNarendra K }
384