public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alexander Y. Fomichev" <git.user@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: jsm: two or more 4/8-port boards can not initialize ports properly
Date: Thu, 14 May 2009 01:58:00 +0400	[thread overview]
Message-ID: <20090514015800.5c14ecd8.git.user@gmail.com> (raw)
In-Reply-To: <20090513012431.72a9eb83@lxorguk.ukuu.org.uk>

On Wed, 13 May 2009 01:24:31 +0100
Alan Cox <alan@lxorguk.ukuu.org.uk> 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@gmail.com>

      reply	other threads:[~2009-05-13 21:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-12 21:22 jsm: two or more 4/8-port boards can not initialize ports properly Alexander Y. Fomichev
2009-05-12 21:49 ` Alexander Beregalov
2009-05-13 21:54   ` Alexander Y. Fomichev
2009-05-13  0:24 ` Alan Cox
2009-05-13 21:58   ` Alexander Y. Fomichev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090514015800.5c14ecd8.git.user@gmail.com \
    --to=git.user@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox