mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
Char: moxa, cleanup prints
- use dev_* where pdev is available (probe function) - add some printks on fail paths - add KERN_ macros otherwise - remove useless verbose variable - wrap lines to 80 cols at most Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d941ea7d49
commit
7aeb95daf3
1 changed files with 31 additions and 42 deletions
|
@ -166,7 +166,6 @@ struct moxa_port {
|
||||||
|
|
||||||
#define WAKEUP_CHARS 256
|
#define WAKEUP_CHARS 256
|
||||||
|
|
||||||
static int verbose = 0;
|
|
||||||
static int ttymajor = MOXAMAJOR;
|
static int ttymajor = MOXAMAJOR;
|
||||||
/* Variables for insmod */
|
/* Variables for insmod */
|
||||||
#ifdef MODULE
|
#ifdef MODULE
|
||||||
|
@ -184,7 +183,6 @@ module_param_array(baseaddr, int, NULL, 0);
|
||||||
module_param_array(numports, int, NULL, 0);
|
module_param_array(numports, int, NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
module_param(ttymajor, int, 0);
|
module_param(ttymajor, int, 0);
|
||||||
module_param(verbose, bool, 0644);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* static functions:
|
* static functions:
|
||||||
|
@ -283,8 +281,10 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = pci_enable_device(pdev);
|
retval = pci_enable_device(pdev);
|
||||||
if (retval)
|
if (retval) {
|
||||||
|
dev_err(&pdev->dev, "can't enable pci device\n");
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_BOARDS; i++)
|
for (i = 0; i < MAX_BOARDS; i++)
|
||||||
if (moxa_boards[i].basemem == NULL)
|
if (moxa_boards[i].basemem == NULL)
|
||||||
|
@ -292,16 +292,17 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
|
||||||
|
|
||||||
retval = -ENODEV;
|
retval = -ENODEV;
|
||||||
if (i >= MAX_BOARDS) {
|
if (i >= MAX_BOARDS) {
|
||||||
if (verbose)
|
dev_warn(&pdev->dev, "more than %u MOXA Intellio family boards "
|
||||||
printk("More than %d MOXA Intellio family boards "
|
|
||||||
"found. Board is ignored.\n", MAX_BOARDS);
|
"found. Board is ignored.\n", MAX_BOARDS);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
board = &moxa_boards[i];
|
board = &moxa_boards[i];
|
||||||
board->basemem = pci_iomap(pdev, 2, 0x4000);
|
board->basemem = pci_iomap(pdev, 2, 0x4000);
|
||||||
if (board->basemem == NULL)
|
if (board->basemem == NULL) {
|
||||||
|
dev_err(&pdev->dev, "can't remap io space 2\n");
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
board->boardType = board_type;
|
board->boardType = board_type;
|
||||||
switch (board_type) {
|
switch (board_type) {
|
||||||
|
@ -347,7 +348,8 @@ static int __init moxa_init(void)
|
||||||
int i, numBoards, retval = 0;
|
int i, numBoards, retval = 0;
|
||||||
struct moxa_port *ch;
|
struct moxa_port *ch;
|
||||||
|
|
||||||
printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION);
|
printk(KERN_INFO "MOXA Intellio family driver version %s\n",
|
||||||
|
MOXA_VERSION);
|
||||||
moxaDriver = alloc_tty_driver(MAX_PORTS + 1);
|
moxaDriver = alloc_tty_driver(MAX_PORTS + 1);
|
||||||
if (!moxaDriver)
|
if (!moxaDriver)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -378,7 +380,7 @@ static int __init moxa_init(void)
|
||||||
(unsigned long)ch);
|
(unsigned long)ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
printk("Tty devices major number = %d\n", ttymajor);
|
pr_debug("Moxa tty devices major number = %d\n", ttymajor);
|
||||||
|
|
||||||
if (tty_register_driver(moxaDriver)) {
|
if (tty_register_driver(moxaDriver)) {
|
||||||
printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n");
|
printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n");
|
||||||
|
@ -400,11 +402,10 @@ static int __init moxa_init(void)
|
||||||
moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts;
|
moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts;
|
||||||
moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA;
|
moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA;
|
||||||
moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr;
|
moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr;
|
||||||
if (verbose)
|
pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n",
|
||||||
printk("Board %2d: %s board(baseAddr=%lx)\n",
|
numBoards + 1,
|
||||||
numBoards + 1,
|
moxa_brdname[moxa_boards[numBoards].boardType-1],
|
||||||
moxa_brdname[moxa_boards[numBoards].boardType - 1],
|
moxa_boards[numBoards].baseAddr);
|
||||||
moxa_boards[numBoards].baseAddr);
|
|
||||||
numBoards++;
|
numBoards++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,14 +414,13 @@ static int __init moxa_init(void)
|
||||||
for (i = 0; i < MAX_BOARDS; i++) {
|
for (i = 0; i < MAX_BOARDS; i++) {
|
||||||
if ((type[i] == MOXA_BOARD_C218_ISA) ||
|
if ((type[i] == MOXA_BOARD_C218_ISA) ||
|
||||||
(type[i] == MOXA_BOARD_C320_ISA)) {
|
(type[i] == MOXA_BOARD_C320_ISA)) {
|
||||||
if (verbose)
|
pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n",
|
||||||
printk("Board %2d: %s board(baseAddr=%lx)\n",
|
numBoards + 1, moxa_brdname[type[i] - 1],
|
||||||
numBoards + 1,
|
(unsigned long)baseaddr[i]);
|
||||||
moxa_brdname[type[i] - 1],
|
|
||||||
(unsigned long) baseaddr[i]);
|
|
||||||
if (numBoards >= MAX_BOARDS) {
|
if (numBoards >= MAX_BOARDS) {
|
||||||
if (verbose)
|
printk(KERN_WARNING "More than %d MOXA "
|
||||||
printk("More than %d MOXA Intellio family boards found. Board is ignored.", MAX_BOARDS);
|
"Intellio family boards found. Board "
|
||||||
|
"is ignored.\n", MAX_BOARDS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
moxa_boards[numBoards].boardType = type[i];
|
moxa_boards[numBoards].boardType = type[i];
|
||||||
|
@ -456,16 +456,14 @@ static void __exit moxa_exit(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
printk("Unloading module moxa ...\n");
|
|
||||||
|
|
||||||
del_timer_sync(&moxaTimer);
|
del_timer_sync(&moxaTimer);
|
||||||
|
|
||||||
for (i = 0; i < MAX_PORTS; i++)
|
for (i = 0; i < MAX_PORTS; i++)
|
||||||
del_timer_sync(&moxa_ports[i].emptyTimer);
|
del_timer_sync(&moxa_ports[i].emptyTimer);
|
||||||
|
|
||||||
if (tty_unregister_driver(moxaDriver))
|
if (tty_unregister_driver(moxaDriver))
|
||||||
printk("Couldn't unregister MOXA Intellio family serial driver\n");
|
printk(KERN_ERR "Couldn't unregister MOXA Intellio family "
|
||||||
|
"serial driver\n");
|
||||||
put_tty_driver(moxaDriver);
|
put_tty_driver(moxaDriver);
|
||||||
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
|
@ -475,9 +473,6 @@ static void __exit moxa_exit(void)
|
||||||
for (i = 0; i < MAX_BOARDS; i++)
|
for (i = 0; i < MAX_BOARDS; i++)
|
||||||
if (moxa_boards[i].basemem)
|
if (moxa_boards[i].basemem)
|
||||||
iounmap(moxa_boards[i].basemem);
|
iounmap(moxa_boards[i].basemem);
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
printk("Done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(moxa_init);
|
module_init(moxa_init);
|
||||||
|
@ -532,9 +527,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MoxaPortIsValid(port)) {
|
if (!MoxaPortIsValid(port)) {
|
||||||
#ifdef SERIAL_DEBUG_CLOSE
|
pr_debug("Invalid portno in moxa_close\n");
|
||||||
printk("Invalid portno in moxa_close\n");
|
|
||||||
#endif
|
|
||||||
tty->driver_data = NULL;
|
tty->driver_data = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -547,13 +540,13 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
|
||||||
ch = (struct moxa_port *) tty->driver_data;
|
ch = (struct moxa_port *) tty->driver_data;
|
||||||
|
|
||||||
if ((tty->count == 1) && (ch->count != 1)) {
|
if ((tty->count == 1) && (ch->count != 1)) {
|
||||||
printk("moxa_close: bad serial port count; tty->count is 1, "
|
printk(KERN_WARNING "moxa_close: bad serial port count; "
|
||||||
"ch->count is %d\n", ch->count);
|
"tty->count is 1, ch->count is %d\n", ch->count);
|
||||||
ch->count = 1;
|
ch->count = 1;
|
||||||
}
|
}
|
||||||
if (--ch->count < 0) {
|
if (--ch->count < 0) {
|
||||||
printk("moxa_close: bad serial port count, device=%s\n",
|
printk(KERN_WARNING "moxa_close: bad serial port count, "
|
||||||
tty->name);
|
"device=%s\n", tty->name);
|
||||||
ch->count = 0;
|
ch->count = 0;
|
||||||
}
|
}
|
||||||
if (ch->count) {
|
if (ch->count) {
|
||||||
|
@ -971,10 +964,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
|
||||||
*/
|
*/
|
||||||
retval = 0;
|
retval = 0;
|
||||||
add_wait_queue(&ch->open_wait, &wait);
|
add_wait_queue(&ch->open_wait, &wait);
|
||||||
#ifdef SERIAL_DEBUG_OPEN
|
pr_debug("block_til_ready before block: ttys%d, count = %d\n",
|
||||||
printk("block_til_ready before block: ttys%d, count = %d\n",
|
ch->port, ch->count);
|
||||||
ch->line, ch->count);
|
|
||||||
#endif
|
|
||||||
spin_lock_irqsave(&moxa_lock, flags);
|
spin_lock_irqsave(&moxa_lock, flags);
|
||||||
if (!tty_hung_up_p(filp))
|
if (!tty_hung_up_p(filp))
|
||||||
ch->count--;
|
ch->count--;
|
||||||
|
@ -1013,10 +1004,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
|
||||||
ch->count++;
|
ch->count++;
|
||||||
ch->blocked_open--;
|
ch->blocked_open--;
|
||||||
spin_unlock_irqrestore(&moxa_lock, flags);
|
spin_unlock_irqrestore(&moxa_lock, flags);
|
||||||
#ifdef SERIAL_DEBUG_OPEN
|
pr_debug("block_til_ready after blocking: ttys%d, count = %d\n",
|
||||||
printk("block_til_ready after blocking: ttys%d, count = %d\n",
|
ch->port, ch->count);
|
||||||
ch->line, ch->count);
|
|
||||||
#endif
|
|
||||||
if (retval)
|
if (retval)
|
||||||
return (retval);
|
return (retval);
|
||||||
/* FIXME: review to see if we need to use set_bit on these */
|
/* FIXME: review to see if we need to use set_bit on these */
|
||||||
|
|
Loading…
Reference in a new issue