pci: struct device - replace bus_id with dev_name(), dev_set_name()
This patch is part of a larger patch series which will remove the "char bus_id[20]" name string from struct device. The device name is managed in the kobject anyway, and without any size limitation, and just needlessly copied into "struct device".
To set and read the device name dev_name(dev) and dev_set_name(dev) must be used. If your code uses static kobjects, which it shouldn't do, "const char *init_name" can be used to statically provide the name the registered device should have. At registration time, the init_name field is cleared, to enforce the use of dev_name(dev) to access the device name at a later time.
We need to get rid of all occurrences of bus_id in the entire tree to be able to enable the new interface. Please apply this patch, and possibly convert any remaining remaining occurrences of bus_id.
We want to submit a patch to -next, which will remove bus_id from "struct device", to find the remaining pieces to convert, and finally switch over to the new api, which will remove the 20 bytes array and does no longer have a size limitation.
Thanks,
Kay
From: Kay Sievers <[email protected]>
Subject: pci: struct device - replace bus_id with dev_name(), dev_set_name()
---
drivers/pci/hotplug/acpiphp_ibm.c +1 -1
@@ -271,7 +271,7 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)dbg ("%s: generationg bus event\n" , __func__);acpi_bus_generate_proc_event (note->device, note->event, detail);acpi_bus_generate_netlink_event (note->device->pnp.device_class, - note->device->dev.bus_id, +dev_name (¬e->device->dev), note->event, detail); }else note->event = event;
drivers/pci/irq.c +1 -1
@@ -15,7 +15,7 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)dev_printk (KERN_ERR , &pdev->dev,"Potentially misrouted IRQ (Bridge %s %04x:%04x)\n" , - parent->dev.bus_id, parent->vendor, parent->device); +dev_name (&parent->dev), parent->vendor, parent->device);dev_printk (KERN_ERR , &pdev->dev,"%s\n" , reason);dev_printk (KERN_ERR , &pdev->dev,"Please report to [email protected]\n" );WARN_ON (1 );
drivers/pci/pci-acpi.c +1 -1
@@ -371,7 +371,7 @@ static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle)* The string should be the same as root bridge's name * Please look at 'pci_scan_bus_parented' */ - num =sscanf (dev->bus_id,"pci%04x:%02x" , &seg, &bus); + num =sscanf (dev_name (dev),"pci%04x:%02x" , &seg, &bus);if (num !=2 )return -ENODEV ; *handle =acpi_get_pci_rootbridge_handle (seg, bus);
drivers/pci/pcie/portdrv_core.c +1 -1
@@ -224,7 +224,7 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev, device->driver =NULL ; device->driver_data =NULL ; device->release = release_pcie_device;/* callback to free pcie dev */ -snprintf (device->bus_id,sizeof (device->bus_id),"%s:pcie%02x" , +dev_set_name (device,"%s:pcie%02x" ,pci_name (parent),get_descriptor_id (port_type, service_type)); device->parent = &parent->dev; }
drivers/pci/probe.c +3 -3
@@ -412,7 +412,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,* registered later in pci_bus_add_devices() */ child->dev.class = &pcibus_class; -sprintf (child->dev.bus_id,"%04x:%02x" ,pci_domain_nr (child), busnr); +dev_set_name (&child->dev,"%04x:%02x" ,pci_domain_nr (child), busnr);/* * Set up the primary, secondary and subordinate
@@ -1130,7 +1130,7 @@ struct pci_bus * pci_create_bus(struct device *parent,memset (dev,0 ,sizeof (*dev)); dev->parent = parent; dev->release = pci_release_bus_bridge_dev; -sprintf (dev->bus_id,"pci%04x:%02x" ,pci_domain_nr (b), bus); +dev_set_name (dev,"pci%04x:%02x" ,pci_domain_nr (b), bus); error =device_register (dev);if (error) goto dev_reg_err;
@@ -1141,7 +1141,7 @@ struct pci_bus * pci_create_bus(struct device *parent, b->dev.class = &pcibus_class; b->dev.parent = b->bridge; -sprintf (b->dev.bus_id,"%04x:%02x" ,pci_domain_nr (b), bus); +dev_set_name (&b->dev,"%04x:%02x" ,pci_domain_nr (b), bus); error =device_register (&b->dev);if (error) goto class_dev_reg_err;
arch/x86/kernel/pci-dma.c +1 -1
@@ -40,7 +40,7 @@ EXPORT_SYMBOL(bad_dma_address);be probably a smaller DMA mask, but this is bug-to-bug compatible to older i386. */ struct device x86_dma_fallback_dev = { - .bus_id ="fallback device" , + .init_name ="fallback device" , .coherent_dma_mask =DMA_32BIT_MASK , .dma_mask = &x86_dma_fallback_dev.coherent_dma_mask, };
Jesse Barnes
AppliedQuoted 12 lines · Kay Sievers
This patch is part of a larger patch series which will remove the "char bus_id[20]" name string from struct device. The device name is managed in the kobject anyway, and without any size limitation, and just needlessly copied into "struct device".
To set and read the device name
dev_name(dev)anddev_set_name(dev)must be used. If your code uses static kobjects, which it shouldn't do, "const char*init_name" can be used to statically provide the name the registered device should have. At registration time, theinit_namefield is cleared, to enforce the use ofdev_name(dev)to access the device name at a later time.
Quoted 8 lines
We need to get rid of all occurrences of
bus_idin the entire tree to be able to enable the new interface. Please apply this patch, and possibly convert any remaining remaining occurrences ofbus_id.We want to submit a patch to -next, which will remove
bus_idfrom "struct device", to find the remaining pieces to convert, and finally switch over to the new api, which will remove the 20 bytes array and does no longer have a size limitation.
Applied to linux-next, thanks.
Jesse