Skip to contentSkip to conversation

/drivers/char/cyclades.c: panic() call removal

PATCH In review Andrey Panin 2 participants 2 messages Mar 11, 2001 – Mar 12, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /drivers/char/cyclades.c: panic() call removal

Hi all,

this patch removes panic() calls and adds MODULE_DEVICE_TABLE to cyclades driver.

Best regards.

Signature · 2 lines
Andrey Panin            | Embedded systems software engineer
[email protected]        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
linux/drivers/char/cyclades.c renamed from linux/drivers/char/cyclades.c.orig +35 -16
@@ -866,17 +866,21 @@
 static unsigned short	cy_isa_nboard;
 static unsigned short	cy_nboard;
 #ifdef CONFIG_PCI
-static unsigned short	cy_pci_dev_id[] = {
-			    PCI_DEVICE_ID_CYCLOM_Y_Lo,	/* PCI < 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_Y_Hi,	/* PCI > 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_4Y_Lo,	/* 4Y PCI < 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_4Y_Hi,	/* 4Y PCI > 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_8Y_Lo,	/* 8Y PCI < 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_8Y_Hi,	/* 8Y PCI > 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_Z_Lo,	/* Z PCI < 1Mb */
-			    PCI_DEVICE_ID_CYCLOM_Z_Hi,	/* Z PCI > 1Mb */
-			    0				/* end of table */
-			};
+#define CYCLADES_DEVICE(x) { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_##x##, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }
+
+static struct pci_device_id cy_pci_dev_id[] = {
+	CYCLADES_DEVICE(Y_Lo),		/* PCI < 1Mb */
+	CYCLADES_DEVICE(Y_Hi),		/* PCI > 1Mb */
+	CYCLADES_DEVICE(4Y_Lo),		/* 4Y PCI < 1Mb */
+	CYCLADES_DEVICE(4Y_Hi),		/* 4Y PCI > 1Mb */
+	CYCLADES_DEVICE(8Y_Lo),		/* 8Y PCI < 1Mb */
+	CYCLADES_DEVICE(8Y_Hi),		/* 8Y PCI > 1Mb */
+	CYCLADES_DEVICE(Z_Lo),		/* Z PCI < 1Mb */
+	CYCLADES_DEVICE(Z_Hi),		/* Z PCI > 1Mb */
+	{ 0, }				/* end of table */
+};
+
+MODULE_DEVICE_TABLE(pci, cy_pci_dev_id);
 #endif
 
 static void cy_start(struct tty_struct *);
@@ -4970,7 +4974,7 @@
 
         for (i = 0; i < NR_CARDS; i++) {
                 /* look for a Cyclades card by vendor and device id */
-                while((device_id = cy_pci_dev_id[dev_index]) != 0) {
+                while((device_id = cy_pci_dev_id[dev_index].device) != 0) {
                         if((pdev = pci_find_device(PCI_VENDOR_ID_CYCLADES,
                                         device_id, pdev)) == NULL) {
                                 dev_index++;    /* try next device id */
@@ -5478,6 +5482,15 @@
     extra ports are ignored.
  */
 
+static void __init cy_cleanup_after_failure(struct tty_driver *tty)
+{
+	unsigned long flags;
+	save_flags(flags); cli();
+	remove_bh(CYCLADES_BH);
+	if (tty) tty_unregister_driver(tty);
+	restore_flags(flags);
+}
+
 int __init
 cy_init(void)
 {
@@ -5544,10 +5557,16 @@
     cy_callout_driver.proc_entry = 0;
 
 
-    if (tty_register_driver(&cy_serial_driver))
-	     panic("Couldn't register Cyclades serial driver\n");
-    if (tty_register_driver(&cy_callout_driver))
-	     panic("Couldn't register Cyclades callout driver\n");
+    if ((i = tty_register_driver(&cy_serial_driver))) {
+	    printk(KERN_ERR "cyclades: Couldn't register Cyclades serial driver\n");
+	    cy_cleanup_after_failure(NULL);
+	    return i;
+    }
+    if ((i = tty_register_driver(&cy_callout_driver))) {
+	    printk(KERN_ERR "cyclades: Couldn't register Cyclades callout driver\n");
+	    cy_cleanup_after_failure(&cy_serial_driver);
+	    return i;
+    }
 
     for (i = 0; i < NR_CARDS; i++) {
             /* base_addr=0 indicates board not found */
#1 lore raw
Quoted 3 lines · Andrey Panin

this patch removes panic() calls and adds MODULE_DEVICE_TABLE to cyclades driver.

Patch looks good. Thanks for the patch, Andrey!

However: Linus, please do not apply this yet. I'll do tests with a new Cyclades driver version we're about to release, and then I'll submit patches to the Cyclades driver once the tests are done (and they'll include Andrey's patch).

Later,
Ivan