Skip to contentSkip to conversation

PCI: add PCI Express Port Bus Driver subsystem

PATCH long 2 participants 2 messages Jan 18, 2005

lore
Share & tools
lore

long

author
#0 lore raw
Quoted 25 lines · On Mon, 17 Jan 2005 15:49:08 -0800 Greg KH wrote:
Quoted 25 lines
(quoted diff) +25 -0
+int pcie_port_device_register(struct pci_dev *dev)
+{
+	struct pcie_device *parent;
+	int status, type, capabilities, irq_mode, i;
+	int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
+	u16 reg16;
+
+	/* Get port type */
+	pci_read_config_word(dev, 
+		pci_find_capability(dev, PCI_CAP_ID_EXP) + 
+		PCIE_CAPABILITIES_REG, &reg16);
+	type = (reg16 >> 4) & PORT_TYPE_MASK;
+
+	/* Now get port services */
+	capabilities = get_port_device_capability(dev);
+	irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
+
+	/* Allocate parent */
+	parent = alloc_pcie_device(NULL, dev, type, 0, dev->irq, irq_mode);
+	if (!parent) 
+		return -ENOMEM;
+	
+	status = device_register(&parent->device);
+	if (status) {
+		kfree(parent);
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return status;
+	}

This puts all of the pcie "port" structures in /sys/devices/ Shouldn't you make the parent of the device you create point to the pci_dev structure that's passed into this function? That would make the sysfs tree a lot saner I think.

The patch makes the parent of the device point to the pci_dev structure that is passed into this function. If you think it is cleaner that the patch should not, I will update the patch to reflect your input.

Thanks,
Long

#1 lore raw
Quoted 35 lines · long
Quoted 25 lines · On Mon, 17 Jan 2005 15:49:08 -0800 Greg KH wrote:
Quoted 25 lines
(quoted diff) +25 -0
+int pcie_port_device_register(struct pci_dev *dev)
+{
+	struct pcie_device *parent;
+	int status, type, capabilities, irq_mode, i;
+	int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
+	u16 reg16;
+
+	/* Get port type */
+	pci_read_config_word(dev, 
+		pci_find_capability(dev, PCI_CAP_ID_EXP) + 
+		PCIE_CAPABILITIES_REG, &reg16);
+	type = (reg16 >> 4) & PORT_TYPE_MASK;
+
+	/* Now get port services */
+	capabilities = get_port_device_capability(dev);
+	irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
+
+	/* Allocate parent */
+	parent = alloc_pcie_device(NULL, dev, type, 0, dev->irq, irq_mode);
+	if (!parent) 
+		return -ENOMEM;
+	
+	status = device_register(&parent->device);
+	if (status) {
+		kfree(parent);
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return status;
+	}

This puts all of the pcie "port" structures in /sys/devices/ Shouldn't you make the parent of the device you create point to the pci_dev structure that's passed into this function? That would make the sysfs tree a lot saner I think.

Quoted 3 lines

The patch makes the parent of the device point to the pci_dev structure that is passed into this function. If you think it is cleaner that the patch should not, I will update the patch to reflect your input.

That would be great, but it doesn't show up that way on my box. All of the portX devices are in /sys/devices/ which is what I don't think you want. I would love for them to have the parent of the pci_dev structure :)

thanks,

greg k-h