Re: jsm: two or more 4/8-port boards can not initialize portsproperly

From: Alexander Y. Fomichev
Date: Wed May 13 2009 - 17:58:28 EST


On Wed, 13 May 2009 01:24:31 +0100
Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:

> > +struct jsm_board *jsm_boards[MAXBOARDS];
> > +
>
> adapter_count increments each time regardless of boards present so that
> doesn't work after a few hotplugs it seems ?

it's true, i missing hotplug at all tnx.
as of hotplug it seems easier to do this allocating/deallocating
line numbers one by one storing assigned numbers in bitmap (though
it could lead to sparse ttyns belonging to a sigle board)
could you pls take a look on the patch bellow?


> > brd->boardnum = adapter_count++;
> > + jsm_boards[brd->boardnum] = brd;
> > brd->pci_dev = pdev;

diff -urNp a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
--- a/drivers/serial/jsm/jsm.h 2009-05-12 17:29:02.117674090 +0400
+++ b/drivers/serial/jsm/jsm.h 2009-05-13 15:52:56.152889038 +0400
@@ -61,6 +61,7 @@ enum {
if ((DBG_##nlevel & jsm_debug)) \
dev_printk(KERN_##klevel, pdev->dev, fmt, ## args)

+#define MAXLINES 256
#define MAXPORTS 8
#define MAX_STOPS_SENT 5

diff -urNp a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
--- a/drivers/serial/jsm/jsm_tty.c 2009-05-12 17:28:51.849172254 +0400
+++ b/drivers/serial/jsm/jsm_tty.c 2009-05-14 01:15:02.542589990 +0400
@@ -33,6 +33,8 @@

#include "jsm.h"

+static DECLARE_BITMAP(linemap,MAXLINES);
+
static void jsm_carrier(struct jsm_channel *ch);

static inline int jsm_get_mstat(struct jsm_channel *ch)
@@ -433,6 +435,7 @@ int __devinit jsm_tty_init(struct jsm_bo
int __devinit jsm_uart_port_init(struct jsm_board *brd)
{
int i;
+ unsigned int line;
struct jsm_channel *ch;

if (!brd)
@@ -459,7 +462,13 @@ int __devinit jsm_uart_port_init(struct
brd->channels[i]->uart_port.membase = brd->re_map_membase;
brd->channels[i]->uart_port.fifosize = 16;
brd->channels[i]->uart_port.ops = &jsm_ops;
- brd->channels[i]->uart_port.line = brd->channels[i]->ch_portnum + brd->boardnum * 2;
+ line = find_first_zero_bit(linemap,MAXLINES);
+ if (line >= MAXLINES) {
+ printk(KERN_INFO "linemap is full, added device failed\n");
+ continue;
+ } else
+ __set_bit((int)line, linemap);
+ brd->channels[i]->uart_port.line = line;
if (uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port))
printk(KERN_INFO "Added device failed\n");
else
@@ -494,6 +503,7 @@ int jsm_remove_uart_port(struct jsm_boar

ch = brd->channels[i];

+ __clear_bit((int)(ch->uart_port.line), linemap);
uart_remove_one_port(&jsm_uart_driver, &brd->channels[i]->uart_port);
}

--
Best regards
Alexander Y. Fomichev <git.user@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/