Skip to contentSkip to conversation

gdth: fix Error: Driver 'gdth' is already registered, aborting...

PATCH In review James Bottomley 2 participants 3 messages May 5, 2008 SCSI

lore
Share & tools
lore

James Bottomley

author maintainer
#0 lore raw

PATCH 2/2 gdth: fix Error: Driver 'gdth' is already registered, aborting...

This message appears on modprobe/rmmod/modprobe of the driver. It's caused because if the driver has no instances, it returns an error from gdth_init, which causes the module to fail to load. Unfortunately, the module's pci driver is still registered at this point.

Fix this by making gdth behave like a modern driver and insert even if it doesn't find any instances (in case of hot plug or software driven binding).

---
 drivers/scsi/gdth.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/gdth.c +8 -5
index 16785a2..46771d4 100644
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr)
 #endif /* CONFIG_ISA */
 
 #ifdef CONFIG_PCI
-static bool gdth_pci_registered;
 
 static bool gdth_search_vortex(ushort device)
 {
@@ -5157,8 +5156,13 @@ static int __init gdth_init(void)
 
 #ifdef CONFIG_PCI
 	/* scanning for PCI controllers */
-	if (pci_register_driver(&gdth_pci_driver) == 0)
-		gdth_pci_registered = true;
+	if (pci_register_driver(&gdth_pci_driver)) {
+		gdth_ha_str *ha;
+
+		list_for_each_entry(ha, &gdth_instances, list)
+			gdth_remove_one(ha);
+		return -ENODEV;
+	}
 #endif /* CONFIG_PCI */
 
 	TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
@@ -5181,8 +5185,7 @@ static void __exit gdth_exit(void)
 #endif
 
 #ifdef CONFIG_PCI
-	if (gdth_pci_registered)
-		pci_unregister_driver(&gdth_pci_driver);
+	pci_unregister_driver(&gdth_pci_driver);
 #endif
 
 	list_for_each_entry(ha, &gdth_instances, list)
Signature · 1 line
1.5.4.4
#1 lore raw
Quoted 33 lines · James Bottomley

This message appears on modprobe/rmmod/modprobe of the driver. It's caused because if the driver has no instances, it returns an error from gdth_init, which causes the module to fail to load. Unfortunately, the module's pci driver is still registered at this point.

Fix this by making gdth behave like a modern driver and insert even if it doesn't find any instances (in case of hot plug or software driven binding).

---
 drivers/scsi/gdth.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/gdth.c +0 -3
index 16785a2..46771d4 100644
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr)
 #endif /* CONFIG_ISA */
 
 #ifdef CONFIG_PCI
-static bool gdth_pci_registered;
 
 static bool gdth_search_vortex(ushort device)
 {
@@ -5157,8 +5156,13 @@ static int __init gdth_init(void)
 
 #ifdef CONFIG_PCI
 	/* scanning for PCI controllers */
-	if (pci_register_driver(&gdth_pci_driver) == 0)
-		gdth_pci_registered = true;

drivers/scsi/gdth.c static int __init gdth_init(void) · line 5168

Quoted 10 lines
drivers/scsi/gdth.c +7 -0
+	if (pci_register_driver(&gdth_pci_driver)) {
+		gdth_ha_str *ha;
+
+		list_for_each_entry(ha, &gdth_instances, list)
+			gdth_remove_one(ha);
+		return -ENODEV;
+	}
 #endif /* CONFIG_PCI */
 
 	TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));

Wouldn't it be better to return the error code that pci_register_driver() sent back?

Eike

author maintainer
#2 lore raw
Quoted 43 lines · Rolf Eike Beer
Quoted 42 lines · James Bottomley

This message appears on modprobe/rmmod/modprobe of the driver. It's caused because if the driver has no instances, it returns an error from gdth_init, which causes the module to fail to load. Unfortunately, the module's pci driver is still registered at this point.

Fix this by making gdth behave like a modern driver and insert even if it doesn't find any instances (in case of hot plug or software driven binding).

---
 drivers/scsi/gdth.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/gdth.c +7 -3
index 16785a2..46771d4 100644
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr)
 #endif /* CONFIG_ISA */
 
 #ifdef CONFIG_PCI
-static bool gdth_pci_registered;
 
 static bool gdth_search_vortex(ushort device)
 {
@@ -5157,8 +5156,13 @@ static int __init gdth_init(void)
 
 #ifdef CONFIG_PCI
 	/* scanning for PCI controllers */
-	if (pci_register_driver(&gdth_pci_driver) == 0)
-		gdth_pci_registered = true;
+	if (pci_register_driver(&gdth_pci_driver)) {
+		gdth_ha_str *ha;
+
+		list_for_each_entry(ha, &gdth_instances, list)
+			gdth_remove_one(ha);
+		return -ENODEV;
+	}
 #endif /* CONFIG_PCI */
 
Quoted 4 lines

drivers/scsi/gdth.c static int __init gdth_init(void) · line 5168

Quoted 1 line
drivers/scsi/gdth.c +0 -0
 	TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));

Wouldn't it be better to return the error code that pci_register_driver() sent back?

Not really it's just a redo of the original behaviour.

James