Skip to contentSkip to conversation

fix 16550A for 2.4

PATCH Applied Jan Kiszka 2 participants 2 messages Dec 18, 2005

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 fix 16550A for 2.4

Hi,

it takes more to get the serial driver running on 2.4 kernels. The current trunk version does not let the user set any module parameter (effectively commented out). This patch fixes it.

Jan

drivers/16550A/16550A.c +25 -12
Index: ksrc/drivers/16550A/16550A.c
===================================================================
@@ -114,26 +114,34 @@
 static struct rtdm_device   *device[MAX_DEVICES];
 
 static unsigned long        ioaddr[MAX_DEVICES];
-static int                  ioaddr_c;
 static unsigned int         irq[MAX_DEVICES];
-static int                  irq_c;
 static unsigned int         baud_base[MAX_DEVICES];
-static int                  baud_base_c;
 static int                  tx_fifo[MAX_DEVICES];
-static int                  tx_fifo_c;
 static unsigned int         start_index;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+static int                  ioaddr_c;
+static int                  irq_c;
+static int                  baud_base_c;
+static int                  tx_fifo_c;
+
 module_param_array(ioaddr, ulong, &ioaddr_c, 0400);
+module_param_array(irq, uint, &irq_c, 0400);
+module_param_array(baud_base, uint, &baud_base_c, 0400);
+module_param_array(tx_fifo, int, &tx_fifo_c, 0400);
+#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
+MODULE_PARM(ioaddr, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(baud_base, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(tx_fifo, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
+
 MODULE_PARM_DESC(ioaddr, "I/O addresses of the serial devices");
-module_param_array(irq, uint, &irq_c, 0400);
 MODULE_PARM_DESC(irq, "IRQ numbers of the serial devices");
-module_param_array(baud_base, uint, &baud_base_c, 0400);
 MODULE_PARM_DESC(baud_base,
     "Maximum baud rate of the serial device (internal clock rate / 16)");
-module_param_array(tx_fifo, int, &tx_fifo_c, 0400);
 MODULE_PARM_DESC(tx_fifo, "Transmitter FIFO size");
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
+
 module_param(start_index, uint, 0400);
 MODULE_PARM_DESC(start_index, "First device instance number to be used");
 
@@ -1026,7 +1034,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "xeno_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 2),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
@@ -1040,10 +1048,15 @@
     int                 i;
 
 
-    if (irq_c < ioaddr_c)
-        return -EINVAL;
+    for (i = 0; i < MAX_DEVICES; i++) {
+        if (!ioaddr[i])
+            continue;
 
-    for (i = 0; i < ioaddr_c; i++) {
+        ret = -EINVAL;
+        if (!irq[i]) {
+            goto cleanup_out;
+        }
+
         dev = kmalloc(sizeof(struct rtdm_device), GFP_KERNEL);
         ret = -ENOMEM;
         if (!dev)
#1 lore raw
Quoted 5 lines · Jan Kiszka

Hi,

it takes more to get the serial driver running on 2.4 kernels. The current trunk version does not let the user set any module parameter (effectively commented out). This patch fixes it.

Applied, thanks.

Quoted 91 lines

Jan

------------------------------------------------------------------------

Index: ksrc/drivers/16550A/16550A.c
===================================================================

drivers/16550A/16550A.c +25 -13
@@ -114,26 +114,34 @@
 static struct rtdm_device   *device[MAX_DEVICES];
 
 static unsigned long        ioaddr[MAX_DEVICES];
-static int                  ioaddr_c;
 static unsigned int         irq[MAX_DEVICES];
-static int                  irq_c;
 static unsigned int         baud_base[MAX_DEVICES];
-static int                  baud_base_c;
 static int                  tx_fifo[MAX_DEVICES];
-static int                  tx_fifo_c;
 static unsigned int         start_index;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+static int                  ioaddr_c;
+static int                  irq_c;
+static int                  baud_base_c;
+static int                  tx_fifo_c;
+
 module_param_array(ioaddr, ulong, &ioaddr_c, 0400);
+module_param_array(irq, uint, &irq_c, 0400);
+module_param_array(baud_base, uint, &baud_base_c, 0400);
+module_param_array(tx_fifo, int, &tx_fifo_c, 0400);
+#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
+MODULE_PARM(ioaddr, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(baud_base, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+MODULE_PARM(tx_fifo, "1-" __MODULE_STRING(MAX_DEVICES) "i");
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
+
 MODULE_PARM_DESC(ioaddr, "I/O addresses of the serial devices");
-module_param_array(irq, uint, &irq_c, 0400);
 MODULE_PARM_DESC(irq, "IRQ numbers of the serial devices");
-module_param_array(baud_base, uint, &baud_base_c, 0400);
 MODULE_PARM_DESC(baud_base,
     "Maximum baud rate of the serial device (internal clock rate / 16)");
-module_param_array(tx_fifo, int, &tx_fifo_c, 0400);
 MODULE_PARM_DESC(tx_fifo, "Transmitter FIFO size");
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
+
 module_param(start_index, uint, 0400);
 MODULE_PARM_DESC(start_index, "First device instance number to be used");
 
@@ -1026,7 +1034,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "xeno_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 2),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
@@ -1040,10 +1048,15 @@
     int                 i;
 
 
-    if (irq_c < ioaddr_c)
-        return -EINVAL;
+    for (i = 0; i < MAX_DEVICES; i++) {
+        if (!ioaddr[i])
+            continue;
 
-    for (i = 0; i < ioaddr_c; i++) {
+        ret = -EINVAL;
+        if (!irq[i]) {
+            goto cleanup_out;
+        }
+
         dev = kmalloc(sizeof(struct rtdm_device), GFP_KERNEL);
         ret = -ENOMEM;
         if (!dev)
 
 
 
------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.