Export SMBIOS provided firmware instance and label to sysfs
Subsystems (4)
PATCH v3 1/1 Export SMBIOS provided firmware instance and label to sysfs
Hello,
Resubmitting the patch with suggested changes -
V2 -> V3:
1. Added documentation about the sysfs attributes in Documentation/ABI directory.
2. Changed the type of parameter 'attribute' of the function 'find_smbios_instance_string' from int to enum.
3. Changed the return type of the functions 'pci_create_firmware_label_files' and 'pci_remove_firmware_label_files' from int to void
Please find the patch with above changes -
From: Narendra K <[email protected]>
Subject: [PATCH] Export SMBIOS provided firmware instance and label to sysfs
This patch exports SMBIOS provided firmware instance and label of onboard pci devices to sysfs
--- Documentation/ABI/testing/sysfs-bus-pci | 26 ++++++ drivers/firmware/dmi_scan.c | 25 ++++++ drivers/pci/Makefile | 3 + drivers/pci/pci-label.c | 143 +++++++++++++++++++++++++++++++ drivers/pci/pci-sysfs.c | 5 + drivers/pci/pci.h | 9 ++ include/linux/dmi.h | 9 ++ 7 files changed, 220 insertions(+), 0 deletions(-) create mode 100644 drivers/pci/pci-label.c
Documentation/ABI/testing/sysfs-bus-pci +26 -0
@@ -179,3 +179,29 @@ Contact: [email protected] Description: This symbolic link points to the PCI hotplug controller driver module that manages the hotplug slot. + +What: /sys/bus/pci/devices/.../label +Date: July 2010 +Contact: Linux PCI developers <[email protected]> +Description: + Reading this attribute will provide the firmware + given name of the PCI device. The attribute will + be created only if the firmware has given a name + to the PCI device. +Users: + Userspace applications interested in knowing the + firmware assigned name of the PCI device. + +What: /sys/bus/pci/devices/.../index +Date: July 2010 +Contact: Linux PCI developers <[email protected]> +Description: + Reading this attribute will provide the firmware + given instance of the PCI device. The attribute will + be created only if the firmware has given a device + type instance to the PCI device. +Users: + Userspace applications interested in knowing the + firmware assigned device type instance of the PCI + device that can help in understanding the firmware + intended order of the PCI device.
drivers/firmware/dmi_scan.c +25 -0
@@ -277,6 +277,29 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm)list_add_tail (&dev->list, &dmi_devices); } +static void __init dmi_save_dev_onboard (int instance,int segment,int bus, +int devfn,const char *name) +{ +struct dmi_dev_onboard *onboard_dev; + + onboard_dev =dmi_alloc (sizeof (*onboard_dev) +strlen (name) +1 ); +if (!onboard_dev) { +printk (KERN_ERR "dmi_save_dev_onboard: out of memory.\n" ); +return ; + } + onboard_dev->instance = instance; + onboard_dev->segment = segment; + onboard_dev->bus = bus; + onboard_dev->devfn = devfn; + +strcpy ((char *)&onboard_dev[1 ], name); + onboard_dev->dev.type =DMI_DEV_TYPE_DEV_ONBOARD ; + onboard_dev->dev.name = (char *)&onboard_dev[1 ]; + onboard_dev->dev.device_data = onboard_dev; + +list_add (&onboard_dev->dev.list, &dmi_devices); +} +static void __init dmi_save_extended_devices (const struct dmi_header *dm) {const u8 *d = (u8 *) dm +5 ;
@@ -285,6 +308,8 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)if ((*d &0x80 ) =0 )return ; +dmi_save_dev_onboard (*(d+1 ), *(u16 *)(d+2 ), *(d+4 ), *(d+5 ), +dmi_string_nosave (dm, *(d-1 )));dmi_save_one_device (*d &0x7f ,dmi_string_nosave (dm, *(d -1 ))); }
drivers/pci/Makefile +3 -0
@@ -55,6 +55,9 @@ obj-$(CONFIG_MICROBLAZE) += setup-bus.o # obj-$(CONFIG_ACPI) += pci-acpi.o +# SMBIOS provided firmware instance and labels +obj-$(CONFIG_DMI) += pci-label.o + # Cardbus & CompactPCI use setup-bus obj-$(CONFIG_HOTPLUG) += setup-bus.o
drivers/pci/pci-label.c new file +143 -0
143 lines not on this page · raw message
drivers/pci/pci-sysfs.c +5 -0
@@ -1132,6 +1132,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)pci_create_slot_links (pdev); +pci_create_firmware_label_files (pdev); +return 0 ; err_vga_file:
@@ -1201,6 +1203,9 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)sysfs_remove_bin_file (&pdev->dev.kobj, pdev->rom_attr);kfree (pdev->rom_attr); } + +pci_remove_firmware_label_files (pdev); + }static int __init pci_sysfs_init (void )
drivers/pci/pci.h +9 -0
@@ -11,6 +11,15 @@extern int pci_uevent (struct device *dev,struct kobj_uevent_env *env);extern int pci_create_sysfs_dev_files (struct pci_dev *pdev);extern void pci_remove_sysfs_dev_files (struct pci_dev *pdev); +#ifndef CONFIG_DMI +static inline void pci_create_firmware_label_files (struct pci_dev *pdev) +{return 0 ; } +static inline void pci_remove_firmware_label_files (struct pci_dev *pdev) +{return 0 ; } +#else +extern void pci_create_firmware_label_files (struct pci_dev *pdev); +extern void pci_remove_firmware_label_files (struct pci_dev *pdev); +#endif extern void pci_cleanup_rom (struct pci_dev *dev);#ifdef HAVE_PCI_MMAP extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
include/linux/dmi.h +9 -0
@@ -20,6 +20,7 @@ enum dmi_device_type {DMI_DEV_TYPE_SAS ,DMI_DEV_TYPE_IPMI =-1 ,DMI_DEV_TYPE_OEM_STRING =-2 , + DMI_DEV_TYPE_DEV_ONBOARD = -3, }; struct dmi_header {
@@ -37,6 +38,14 @@ struct dmi_device {#ifdef CONFIG_DMI +struct dmi_dev_onboard { +struct dmi_device dev; +int instance; +int segment; +int bus; +int devfn; +}; +extern int dmi_check_system (const struct dmi_system_id *list);const struct dmi_system_id *dmi_first_match (const struct dmi_system_id *list);extern const char *dmi_get_system_info (int field);
Signature · 4 lines
1.6.5.2 With regards, Narendra K
Quoted 40 lines · Narendra K
Hello,
Resubmitting the patch with suggested changes -
V2 -> V3:
1. Added documentation about the sysfs attributes in
Documentation/ABIdirectory.
2. Changed the type of parameter 'attribute' of the function 'find_smbios_instance_string' from int to enum.
3. Changed the return type of the functions 'pci_create_firmware_label_files' and 'pci_remove_firmware_label_files' from int to voidPlease find the patch with above changes -
From: Narendra K <[email protected]>
Subject: [PATCH] Export SMBIOS provided firmware instance and label to sysfsThis patch exports SMBIOS provided firmware instance and label of onboard pci devices to sysfs
Signed-off-by Jordan Hargrave <[email protected]>Signed-off-by Narendra K <[email protected]>--- Documentation/ABI/testing/sysfs-bus-pci | 26 ++++++ drivers/firmware/dmi_scan.c | 25 ++++++ drivers/pci/Makefile | 3 + drivers/pci/pci-label.c | 143 +++++++++++++++++++++++++++++++ drivers/pci/pci-sysfs.c | 5 + drivers/pci/pci.h | 9 ++ include/linux/dmi.h | 9 ++ 7 files changed, 220 insertions(+), 0 deletions(-) create mode 100644 drivers/pci/pci-label.cDocumentation/ABI/testing/sysfs-bus-pci +0
-0
Documentation/ABI/testing/sysfs-bus-pci Contact: [email protected] · line 185
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-pci +4
-0@@ -179,3 +179,29 @@ Contact: [email protected] Description: This symbolic link points to the PCI hotplug controller driver module that manages the hotplug slot. + +What: /sys/bus/pci/devices/.../label +Date: July 2010 +Contact: Linux PCI developers <[email protected]>
Why not contact you?
Documentation/ABI/testing/sysfs-bus-pci Contact: [email protected] · line 190
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-pci +5
-0+Description: + Reading this attribute will provide the firmware + given name of the PCI device. The attribute will + be created only if the firmware has given a name + to the PCI device.
Where does that "name" come from? Please describe this.
Documentation/ABI/testing/sysfs-bus-pci Contact: [email protected] · line 202
Quoted 12 lines
Documentation/ABI/testing/sysfs-bus-pci +12
-0+Users: + Userspace applications interested in knowing the + firmware assigned name of the PCI device. + +What: /sys/bus/pci/devices/.../index +Date: July 2010 +Contact: Linux PCI developers <[email protected]> +Description: + Reading this attribute will provide the firmware + given instance of the PCI device. The attribute will + be created only if the firmware has given a device + type instance to the PCI device.
Same comments as above.
thanks,
greg k-h