Skip to content

Commit

Permalink
jsm: correctly support multiple 4/8-port boards
Browse files Browse the repository at this point in the history
If there are more then one 4/8-port board jsm_uart_port_init
allocate a line numbers of the second and further boards
from range of previous one.

This patch fixed the problem.

Signed-off-by: Alexander Y. Fomichev <git.user@gmail.com>

[printks fixed to add jsm: ]

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Alexander Y. Fomichev authored and Linus Torvalds committed Jun 11, 2009
1 parent 9bb4169 commit 13858d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/serial/jsm/jsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions drivers/serial/jsm/jsm_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -433,6 +435,7 @@ int __devinit jsm_tty_init(struct jsm_board *brd)
int __devinit jsm_uart_port_init(struct jsm_board *brd)
{
int i;
unsigned int line;
struct jsm_channel *ch;

if (!brd)
Expand All @@ -459,9 +462,15 @@ int __devinit jsm_uart_port_init(struct jsm_board *brd)
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 "jsm: 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");
printk(KERN_INFO "jsm: add device failed\n");
else
printk(KERN_INFO "Added device \n");
}
Expand Down Expand Up @@ -494,6 +503,7 @@ int jsm_remove_uart_port(struct jsm_board *brd)

ch = brd->channels[i];

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

Expand Down

0 comments on commit 13858d3

Please sign in to comment.