Skip to contentSkip to conversation

Let ide interfaces choose a parent device

PATCH In review Benjamin Herrenschmidt 2 participants 2 messages Apr 24, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Let ide interfaces choose a parent device

Hi !

Right now, the parent struct device of IDE interfaces is forced to be either the pci_dev or some not-yet implemented legacy node. This is wrong as non-PCI ide interfaces may well hang off different bus types. For PowerMac, for example, I'm defining a bus type for Apple's "MacIO" ASIC and ide/ppc/pmac.c will hang off a device on that bus.

The following patch will let the HWIF fill the parent pointer and only put it's "default" stuff in there if it's NULL.

drivers/ide/ide-probe.c +6 -4
@@ -696,10 +696,12 @@
 	strncpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
 	snprintf(hwif->gendev.name,DEVICE_NAME_SIZE,"IDE Controller");
 	hwif->gendev.driver_data = hwif;
-	if (hwif->pci_dev)
-		hwif->gendev.parent = &hwif->pci_dev->dev;
-	else
-		hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
+	if (hwif->gendev.parent == NULL) {
+		if (hwif->pci_dev)
+			hwif->gendev.parent = &hwif->pci_dev->dev;
+		else
+			hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
+	}
 	device_register(&hwif->gendev);
 
 	if (hwif->mmio == 2)
#1 lore raw
Quoted 10 lines · Benjamin Herrenschmidt

Hi !

Right now, the parent struct device of IDE interfaces is forced to be either the pci_dev or some not-yet implemented legacy node. This is wrong as non-PCI ide interfaces may well hang off different bus types. For PowerMac, for example, I'm defining a bus type for Apple's "MacIO" ASIC and ide/ppc/pmac.c will hang off a device on that bus.

The following patch will let the HWIF fill the parent pointer and only put it's "default" stuff in there if it's NULL.

It seems PCI HWIFs are already doing this in ide_pci_setup_ports().

For me patch is okay.

--
Bartlomiej

Quoted 19 lines
drivers/ide/ide-probe.c +6 -4
@@ -696,10 +696,12 @@
 	strncpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
 	snprintf(hwif->gendev.name,DEVICE_NAME_SIZE,"IDE Controller");
 	hwif->gendev.driver_data = hwif;
-	if (hwif->pci_dev)
-		hwif->gendev.parent = &hwif->pci_dev->dev;
-	else
-		hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
+	if (hwif->gendev.parent == NULL) {
+		if (hwif->pci_dev)
+			hwif->gendev.parent = &hwif->pci_dev->dev;
+		else
+			hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
+	}
 	device_register(&hwif->gendev);
 
 	if (hwif->mmio == 2)