[PATCH] specialix: check_region/request_region related cleanups From: Christoph Hellwig * Remove trivial wrappers to check_region(), request_region(), release_region(). * Fix error codes of probe routine. * Switch deprecated check_region() to request_region(). Signed-off-by: Christoph Hellwig Index: linux-kj/drivers/char/specialix.c =================================================================== --- linux-kj.orig/drivers/char/specialix.c 2005-10-11 18:37:41.000000000 +0400 +++ linux-kj/drivers/char/specialix.c 2005-10-11 18:38:18.000000000 +0400 @@ -333,32 +333,6 @@ static inline void sx_wait_CCR_off(struc printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp)); } - -/* - * specialix IO8+ IO range functions. - */ - -static inline int sx_check_io_range(struct specialix_board * bp) -{ - return check_region (bp->base, SX_IO_SPACE); -} - - -static inline void sx_request_io_range(struct specialix_board * bp) -{ - request_region(bp->base, - bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE, - "specialix IO8+" ); -} - - -static inline void sx_release_io_range(struct specialix_board * bp) -{ - release_region(bp->base, - bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE); -} - - /* Must be called with enabled interrupts */ /* Ugly. Very ugly. Don't use this for anything else than initialization code */ @@ -492,13 +466,13 @@ static int sx_probe(struct specialix_boa #endif int rev; int chip; + int error = -ENODEV; func_enter(); - if (sx_check_io_range(bp)) { - func_exit(); - return 1; - } + if (!request_region(bp->base, (bp->flags & SX_BOARD_IS_PCI) ? + SX_PCI_IO_SPACE : SX_IO_SPACE, "specialix IO8+")) + goto out; /* Are the I/O ports here ? */ sx_out_off(bp, CD186x_PPRL, 0x5a); @@ -509,12 +483,10 @@ static int sx_probe(struct specialix_boa short_pause (); val2 = sx_in_off(bp, CD186x_PPRL); - if ((val1 != 0x5a) || (val2 != 0xa5)) { printk(KERN_INFO "sx%d: specialix IO8+ Board at 0x%03x not found.\n", board_No(bp), bp->base); - func_exit(); - return 1; + goto out_release_region; } /* Check the DSR lines that Specialix uses as board @@ -532,8 +504,7 @@ static int sx_probe(struct specialix_boa if (val1 != val2) { printk(KERN_INFO "sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n", board_No(bp), val2, bp->base, val1); - func_exit(); - return 1; + goto out_release_region; } @@ -569,8 +540,7 @@ static int sx_probe(struct specialix_boa if (irqs <= 0) { printk(KERN_ERR "sx%d: Can't find IRQ for specialix IO8+ board at 0x%03x.\n", board_No(bp), bp->base); - func_exit(); - return 1; + goto out_release_region; } #endif printk (KERN_INFO "Started with irq=%d, but now have irq=%d.\n", bp->irq, irqs); @@ -579,11 +549,11 @@ static int sx_probe(struct specialix_boa #endif /* Reset CD186x again */ if (!sx_init_CD186x(bp)) { - func_exit(); - return -EIO; + error = -EIO; + goto out_release_region; } - sx_request_io_range(bp); + bp->flags |= SX_BOARD_PRESENT; /* Chip revcode pkgtype @@ -621,6 +591,13 @@ static int sx_probe(struct specialix_boa func_exit(); return 0; + +out_release_region: + release_region(bp->base, (bp->flags & SX_BOARD_IS_PCI) ? + SX_PCI_IO_SPACE : SX_IO_SPACE); +out: + func_exit(); + return error; } /* @@ -2591,9 +2568,14 @@ static void __exit specialix_exit_module func_enter(); sx_release_drivers(); - for (i = 0; i < SX_NBOARD; i++) - if (sx_board[i].flags & SX_BOARD_PRESENT) - sx_release_io_range(&sx_board[i]); + for (i = 0; i < SX_NBOARD; i++) { + struct specialix_board *bp = &sx_board[i]; + + if (bp->flags & SX_BOARD_PRESENT) + release_region(bp->base, (bp->flags & SX_BOARD_IS_PCI) ? + SX_PCI_IO_SPACE : SX_IO_SPACE); + } + #ifdef SPECIALIX_TIMER del_timer (&missed_irq_timer); #endif