diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2007-10-18 06:06:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-18 17:37:26 -0400 |
commit | 7aeb95daf37dbd72f63cdd52d86a8b5d89e59394 (patch) | |
tree | d388792d58283d08874ead1bd8b5b212a31639e3 | |
parent | d941ea7d496db914205c3872942fd1ff0e7dccef (diff) |
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>
-rw-r--r-- | drivers/char/moxa.c | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 5000b3bd091e..3bc8c6826cd4 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -166,7 +166,6 @@ struct moxa_port { | |||
166 | 166 | ||
167 | #define WAKEUP_CHARS 256 | 167 | #define WAKEUP_CHARS 256 |
168 | 168 | ||
169 | static int verbose = 0; | ||
170 | static int ttymajor = MOXAMAJOR; | 169 | static int ttymajor = MOXAMAJOR; |
171 | /* Variables for insmod */ | 170 | /* Variables for insmod */ |
172 | #ifdef MODULE | 171 | #ifdef MODULE |
@@ -184,7 +183,6 @@ module_param_array(baseaddr, int, NULL, 0); | |||
184 | module_param_array(numports, int, NULL, 0); | 183 | module_param_array(numports, int, NULL, 0); |
185 | #endif | 184 | #endif |
186 | module_param(ttymajor, int, 0); | 185 | module_param(ttymajor, int, 0); |
187 | module_param(verbose, bool, 0644); | ||
188 | 186 | ||
189 | /* | 187 | /* |
190 | * static functions: | 188 | * static functions: |
@@ -283,8 +281,10 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, | |||
283 | int retval; | 281 | int retval; |
284 | 282 | ||
285 | retval = pci_enable_device(pdev); | 283 | retval = pci_enable_device(pdev); |
286 | if (retval) | 284 | if (retval) { |
285 | dev_err(&pdev->dev, "can't enable pci device\n"); | ||
287 | goto err; | 286 | goto err; |
287 | } | ||
288 | 288 | ||
289 | for (i = 0; i < MAX_BOARDS; i++) | 289 | for (i = 0; i < MAX_BOARDS; i++) |
290 | if (moxa_boards[i].basemem == NULL) | 290 | if (moxa_boards[i].basemem == NULL) |
@@ -292,16 +292,17 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, | |||
292 | 292 | ||
293 | retval = -ENODEV; | 293 | retval = -ENODEV; |
294 | if (i >= MAX_BOARDS) { | 294 | if (i >= MAX_BOARDS) { |
295 | if (verbose) | 295 | dev_warn(&pdev->dev, "more than %u MOXA Intellio family boards " |
296 | printk("More than %d MOXA Intellio family boards " | ||
297 | "found. Board is ignored.\n", MAX_BOARDS); | 296 | "found. Board is ignored.\n", MAX_BOARDS); |
298 | goto err; | 297 | goto err; |
299 | } | 298 | } |
300 | 299 | ||
301 | board = &moxa_boards[i]; | 300 | board = &moxa_boards[i]; |
302 | board->basemem = pci_iomap(pdev, 2, 0x4000); | 301 | board->basemem = pci_iomap(pdev, 2, 0x4000); |
303 | if (board->basemem == NULL) | 302 | if (board->basemem == NULL) { |
303 | dev_err(&pdev->dev, "can't remap io space 2\n"); | ||
304 | goto err; | 304 | goto err; |
305 | } | ||
305 | 306 | ||
306 | board->boardType = board_type; | 307 | board->boardType = board_type; |
307 | switch (board_type) { | 308 | switch (board_type) { |
@@ -347,7 +348,8 @@ static int __init moxa_init(void) | |||
347 | int i, numBoards, retval = 0; | 348 | int i, numBoards, retval = 0; |
348 | struct moxa_port *ch; | 349 | struct moxa_port *ch; |
349 | 350 | ||
350 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION); | 351 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", |
352 | MOXA_VERSION); | ||
351 | moxaDriver = alloc_tty_driver(MAX_PORTS + 1); | 353 | moxaDriver = alloc_tty_driver(MAX_PORTS + 1); |
352 | if (!moxaDriver) | 354 | if (!moxaDriver) |
353 | return -ENOMEM; | 355 | return -ENOMEM; |
@@ -378,7 +380,7 @@ static int __init moxa_init(void) | |||
378 | (unsigned long)ch); | 380 | (unsigned long)ch); |
379 | } | 381 | } |
380 | 382 | ||
381 | printk("Tty devices major number = %d\n", ttymajor); | 383 | pr_debug("Moxa tty devices major number = %d\n", ttymajor); |
382 | 384 | ||
383 | if (tty_register_driver(moxaDriver)) { | 385 | if (tty_register_driver(moxaDriver)) { |
384 | printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n"); | 386 | printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n"); |
@@ -400,11 +402,10 @@ static int __init moxa_init(void) | |||
400 | moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts; | 402 | moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts; |
401 | moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA; | 403 | moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA; |
402 | moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr; | 404 | moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr; |
403 | if (verbose) | 405 | pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", |
404 | printk("Board %2d: %s board(baseAddr=%lx)\n", | 406 | numBoards + 1, |
405 | numBoards + 1, | 407 | moxa_brdname[moxa_boards[numBoards].boardType-1], |
406 | moxa_brdname[moxa_boards[numBoards].boardType - 1], | 408 | moxa_boards[numBoards].baseAddr); |
407 | moxa_boards[numBoards].baseAddr); | ||
408 | numBoards++; | 409 | numBoards++; |
409 | } | 410 | } |
410 | } | 411 | } |
@@ -413,14 +414,13 @@ static int __init moxa_init(void) | |||
413 | for (i = 0; i < MAX_BOARDS; i++) { | 414 | for (i = 0; i < MAX_BOARDS; i++) { |
414 | if ((type[i] == MOXA_BOARD_C218_ISA) || | 415 | if ((type[i] == MOXA_BOARD_C218_ISA) || |
415 | (type[i] == MOXA_BOARD_C320_ISA)) { | 416 | (type[i] == MOXA_BOARD_C320_ISA)) { |
416 | if (verbose) | 417 | pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", |
417 | printk("Board %2d: %s board(baseAddr=%lx)\n", | 418 | numBoards + 1, moxa_brdname[type[i] - 1], |
418 | numBoards + 1, | 419 | (unsigned long)baseaddr[i]); |
419 | moxa_brdname[type[i] - 1], | ||
420 | (unsigned long) baseaddr[i]); | ||
421 | if (numBoards >= MAX_BOARDS) { | 420 | if (numBoards >= MAX_BOARDS) { |
422 | if (verbose) | 421 | printk(KERN_WARNING "More than %d MOXA " |
423 | printk("More than %d MOXA Intellio family boards found. Board is ignored.", MAX_BOARDS); | 422 | "Intellio family boards found. Board " |
423 | "is ignored.\n", MAX_BOARDS); | ||
424 | continue; | 424 | continue; |
425 | } | 425 | } |
426 | moxa_boards[numBoards].boardType = type[i]; | 426 | moxa_boards[numBoards].boardType = type[i]; |
@@ -456,16 +456,14 @@ static void __exit moxa_exit(void) | |||
456 | { | 456 | { |
457 | int i; | 457 | int i; |
458 | 458 | ||
459 | if (verbose) | ||
460 | printk("Unloading module moxa ...\n"); | ||
461 | |||
462 | del_timer_sync(&moxaTimer); | 459 | del_timer_sync(&moxaTimer); |
463 | 460 | ||
464 | for (i = 0; i < MAX_PORTS; i++) | 461 | for (i = 0; i < MAX_PORTS; i++) |
465 | del_timer_sync(&moxa_ports[i].emptyTimer); | 462 | del_timer_sync(&moxa_ports[i].emptyTimer); |
466 | 463 | ||
467 | if (tty_unregister_driver(moxaDriver)) | 464 | if (tty_unregister_driver(moxaDriver)) |
468 | printk("Couldn't unregister MOXA Intellio family serial driver\n"); | 465 | printk(KERN_ERR "Couldn't unregister MOXA Intellio family " |
466 | "serial driver\n"); | ||
469 | put_tty_driver(moxaDriver); | 467 | put_tty_driver(moxaDriver); |
470 | 468 | ||
471 | #ifdef CONFIG_PCI | 469 | #ifdef CONFIG_PCI |
@@ -475,9 +473,6 @@ static void __exit moxa_exit(void) | |||
475 | for (i = 0; i < MAX_BOARDS; i++) | 473 | for (i = 0; i < MAX_BOARDS; i++) |
476 | if (moxa_boards[i].basemem) | 474 | if (moxa_boards[i].basemem) |
477 | iounmap(moxa_boards[i].basemem); | 475 | iounmap(moxa_boards[i].basemem); |
478 | |||
479 | if (verbose) | ||
480 | printk("Done\n"); | ||
481 | } | 476 | } |
482 | 477 | ||
483 | module_init(moxa_init); | 478 | module_init(moxa_init); |
@@ -532,9 +527,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) | |||
532 | return; | 527 | return; |
533 | } | 528 | } |
534 | if (!MoxaPortIsValid(port)) { | 529 | if (!MoxaPortIsValid(port)) { |
535 | #ifdef SERIAL_DEBUG_CLOSE | 530 | pr_debug("Invalid portno in moxa_close\n"); |
536 | printk("Invalid portno in moxa_close\n"); | ||
537 | #endif | ||
538 | tty->driver_data = NULL; | 531 | tty->driver_data = NULL; |
539 | return; | 532 | return; |
540 | } | 533 | } |
@@ -547,13 +540,13 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) | |||
547 | ch = (struct moxa_port *) tty->driver_data; | 540 | ch = (struct moxa_port *) tty->driver_data; |
548 | 541 | ||
549 | if ((tty->count == 1) && (ch->count != 1)) { | 542 | if ((tty->count == 1) && (ch->count != 1)) { |
550 | printk("moxa_close: bad serial port count; tty->count is 1, " | 543 | printk(KERN_WARNING "moxa_close: bad serial port count; " |
551 | "ch->count is %d\n", ch->count); | 544 | "tty->count is 1, ch->count is %d\n", ch->count); |
552 | ch->count = 1; | 545 | ch->count = 1; |
553 | } | 546 | } |
554 | if (--ch->count < 0) { | 547 | if (--ch->count < 0) { |
555 | printk("moxa_close: bad serial port count, device=%s\n", | 548 | printk(KERN_WARNING "moxa_close: bad serial port count, " |
556 | tty->name); | 549 | "device=%s\n", tty->name); |
557 | ch->count = 0; | 550 | ch->count = 0; |
558 | } | 551 | } |
559 | if (ch->count) { | 552 | if (ch->count) { |
@@ -971,10 +964,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, | |||
971 | */ | 964 | */ |
972 | retval = 0; | 965 | retval = 0; |
973 | add_wait_queue(&ch->open_wait, &wait); | 966 | add_wait_queue(&ch->open_wait, &wait); |
974 | #ifdef SERIAL_DEBUG_OPEN | 967 | pr_debug("block_til_ready before block: ttys%d, count = %d\n", |
975 | printk("block_til_ready before block: ttys%d, count = %d\n", | 968 | ch->port, ch->count); |
976 | ch->line, ch->count); | ||
977 | #endif | ||
978 | spin_lock_irqsave(&moxa_lock, flags); | 969 | spin_lock_irqsave(&moxa_lock, flags); |
979 | if (!tty_hung_up_p(filp)) | 970 | if (!tty_hung_up_p(filp)) |
980 | ch->count--; | 971 | ch->count--; |
@@ -1013,10 +1004,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, | |||
1013 | ch->count++; | 1004 | ch->count++; |
1014 | ch->blocked_open--; | 1005 | ch->blocked_open--; |
1015 | spin_unlock_irqrestore(&moxa_lock, flags); | 1006 | spin_unlock_irqrestore(&moxa_lock, flags); |
1016 | #ifdef SERIAL_DEBUG_OPEN | 1007 | pr_debug("block_til_ready after blocking: ttys%d, count = %d\n", |
1017 | printk("block_til_ready after blocking: ttys%d, count = %d\n", | 1008 | ch->port, ch->count); |
1018 | ch->line, ch->count); | ||
1019 | #endif | ||
1020 | if (retval) | 1009 | if (retval) |
1021 | return (retval); | 1010 | return (retval); |
1022 | /* FIXME: review to see if we need to use set_bit on these */ | 1011 | /* FIXME: review to see if we need to use set_bit on these */ |