Commit 049cbf98 authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] aztech CD driver janitor work

o printk levels
o check_region -> request_region cleanups
o allocated region releasing on failure
parent f77c18c6
...@@ -1724,16 +1724,18 @@ int __init aztcd_init(void) ...@@ -1724,16 +1724,18 @@ int __init aztcd_init(void)
long int count, max_count; long int count, max_count;
unsigned char result[50]; unsigned char result[50];
int st; int st;
void* status = NULL;
int i = 0; int i = 0;
int ret = 0;
if (azt_port == 0) { if (azt_port == 0) {
printk("aztcd: no Aztech CD-ROM Initialization"); printk(KERN_INFO "aztcd: no Aztech CD-ROM Initialization");
return -EIO; return -EIO;
} }
printk printk(KERN_INFO "aztcd: AZTECH, ORCHID, OKANO, WEARNES, TXC, CyDROM "
("aztcd: AZTECH, ORCHID, OKANO, WEARNES, TXC, CyDROM CD-ROM Driver\n"); "CD-ROM Driver\n");
printk("aztcd: (C) 1994-98 W.Zimmermann\n"); printk(KERN_INFO "aztcd: (C) 1994-98 W.Zimmermann\n");
if (azt_port == -1) { if (azt_port == -1) {
printk printk
("aztcd: KernelVersion=%s DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n", ("aztcd: KernelVersion=%s DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n",
...@@ -1742,8 +1744,8 @@ int __init aztcd_init(void) ...@@ -1742,8 +1744,8 @@ int __init aztcd_init(void)
printk printk
("aztcd: DriverVersion=%s BaseAddress=0x%x For IDE/ATAPI-drives use ide-cd.c\n", ("aztcd: DriverVersion=%s BaseAddress=0x%x For IDE/ATAPI-drives use ide-cd.c\n",
AZT_VERSION, azt_port); AZT_VERSION, azt_port);
printk printk(KERN_INFO "aztcd: If you have problems, read /usr/src/linux/"
("aztcd: If you have problems, read /usr/src/linux/Documentation/cdrom/aztcd\n"); "Documentation/cdrom/aztcd\n");
#ifdef AZT_SW32 /*CDROM connected to Soundwave32 card */ #ifdef AZT_SW32 /*CDROM connected to Soundwave32 card */
...@@ -1764,15 +1766,15 @@ int __init aztcd_init(void) ...@@ -1764,15 +1766,15 @@ int __init aztcd_init(void)
/* check for presence of drive */ /* check for presence of drive */
if (azt_port == -1) { /* autoprobing */ if (azt_port == -1) { /* autoprobing for proprietary interface */
for (i = 0; (azt_port_auto[i] != 0) && (i < 16); i++) { for (i = 0; (azt_port_auto[i] != 0) && (i < 16); i++) {
azt_port = azt_port_auto[i]; azt_port = azt_port_auto[i];
printk("aztcd: Autoprobing BaseAddress=0x%x \n", printk(KERN_INFO "aztcd: Autoprobing BaseAddress=0x%x"
azt_port); "\n", azt_port);
st = check_region(azt_port, 4); /*proprietary interfaces need 4 bytes */ /*proprietary interfaces need 4 bytes */
if (st) if (!request_region(azt_port, 4, "aztcd")) {
continue; continue;
}
outb(POLLED, MODE_PORT); outb(POLLED, MODE_PORT);
inb(CMD_PORT); inb(CMD_PORT);
inb(CMD_PORT); inb(CMD_PORT);
...@@ -1785,22 +1787,25 @@ int __init aztcd_init(void) ...@@ -1785,22 +1787,25 @@ int __init aztcd_init(void)
if (aztTimeOutCount >= AZT_FAST_TIMEOUT) if (aztTimeOutCount >= AZT_FAST_TIMEOUT)
break; break;
} while (aztIndatum & AFL_STATUS); } while (aztIndatum & AFL_STATUS);
if (inb(DATA_PORT) == AFL_OP_OK) if (inb(DATA_PORT) == AFL_OP_OK) { /* OK drive found */
break; break;
}
else { /* Drive not found on this port - try next one */
release_region(azt_port, 4);
}
} }
if ((azt_port_auto[i] == 0) || (i == 16)) { if ((azt_port_auto[i] == 0) || (i == 16)) {
printk("aztcd: no AZTECH CD-ROM drive found\n"); printk(KERN_INFO "aztcd: no AZTECH CD-ROM drive found\n");
return -EIO; return -EIO;
} }
} else { /* no autoprobing */ } else { /* no autoprobing */
if ((azt_port == 0x1f0) || (azt_port == 0x170)) if ((azt_port == 0x1f0) || (azt_port == 0x170))
st = check_region(azt_port, 8); /*IDE-interfaces need 8 bytes */ status = request_region(azt_port, 8, "aztcd"); /*IDE-interfaces need 8 bytes */
else else
st = check_region(azt_port, 4); /*proprietary interfaces need 4 bytes */ status = request_region(azt_port, 4, "aztcd"); /*proprietary interfaces need 4 bytes */
if (st) { if (!status) {
printk printk(KERN_WARNING "aztcd: conflict, I/O port (%X) "
("aztcd: conflict, I/O port (%X) already used\n", "already used\n", azt_port);
azt_port);
return -EIO; return -EIO;
} }
...@@ -1823,17 +1828,19 @@ int __init aztcd_init(void) ...@@ -1823,17 +1828,19 @@ int __init aztcd_init(void)
if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? If not, reset and try again */ if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? If not, reset and try again */
#ifndef MODULE #ifndef MODULE
if (azt_cont != 0x79) { if (azt_cont != 0x79) {
printk printk(KERN_WARNING "aztcd: no AZTECH CD-ROM "
("aztcd: no AZTECH CD-ROM drive found-Try boot parameter aztcd=<BaseAddress>,0x79\n"); "drive found-Try boot parameter aztcd="
return -EIO; "<BaseAddress>,0x79\n");
ret = -EIO;
goto err_out;
} }
#else #else
if (0) { if (0) {
} }
#endif #endif
else { else {
printk printk(KERN_INFO "aztcd: drive reset - "
("aztcd: drive reset - please wait\n"); "please wait\n");
for (count = 0; count < 50; count++) { for (count = 0; count < 50; count++) {
inb(STATUS_PORT); /*removing all data from earlier tries */ inb(STATUS_PORT); /*removing all data from earlier tries */
inb(DATA_PORT); inb(DATA_PORT);
...@@ -1845,9 +1852,10 @@ int __init aztcd_init(void) ...@@ -1845,9 +1852,10 @@ int __init aztcd_init(void)
outb(ACMD_SOFT_RESET, CMD_PORT); /*send reset */ outb(ACMD_SOFT_RESET, CMD_PORT); /*send reset */
STEN_LOW; STEN_LOW;
if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? */ if (inb(DATA_PORT) != AFL_OP_OK) { /*OP_OK? */
printk printk(KERN_WARNING "aztcd: no AZTECH "
("aztcd: no AZTECH CD-ROM drive found\n"); "CD-ROM drive found\n");
return -EIO; ret = -EIO;
goto err_out;
} }
for (count = 0; count < AZT_TIMEOUT; for (count = 0; count < AZT_TIMEOUT;
...@@ -1855,13 +1863,13 @@ int __init aztcd_init(void) ...@@ -1855,13 +1863,13 @@ int __init aztcd_init(void)
barrier(); /* Stop gcc 2.96 being smart */ barrier(); /* Stop gcc 2.96 being smart */
if ((st = getAztStatus()) == -1) { if ((st = getAztStatus()) == -1) {
printk printk(KERN_WARNING "aztcd: Drive Status"
("aztcd: Drive Status Error Status=%x\n", " Error Status=%x\n", st);
st); ret = -EIO;
return -EIO; goto err_out;
} }
#ifdef AZT_DEBUG #ifdef AZT_DEBUG
printk("aztcd: Status = %x\n", st); printk(KERN_DEBUG "aztcd: Status = %x\n", st);
#endif #endif
outb(POLLED, MODE_PORT); outb(POLLED, MODE_PORT);
inb(CMD_PORT); inb(CMD_PORT);
...@@ -1916,29 +1924,34 @@ int __init aztcd_init(void) ...@@ -1916,29 +1924,34 @@ int __init aztcd_init(void)
printk("%c", result[count]); printk("%c", result[count]);
printk("<<>> "); printk("<<>> ");
printk("Aborted\n"); printk("Aborted\n");
return -EIO; ret = -EIO;
goto err_out;
} }
} }
devfs_register(NULL, "aztcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0, devfs_register(NULL, "aztcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
S_IFBLK | S_IRUGO | S_IWUGO, &azt_fops, NULL); S_IFBLK | S_IRUGO | S_IWUGO, &azt_fops, NULL);
if (devfs_register_blkdev(MAJOR_NR, "aztcd", &azt_fops) != 0) { if (devfs_register_blkdev(MAJOR_NR, "aztcd", &azt_fops) != 0) {
printk("aztcd: Unable to get major %d for Aztech CD-ROM\n", printk(KERN_WARNING "aztcd: Unable to get major %d for Aztech"
MAJOR_NR); " CD-ROM\n", MAJOR_NR);
return -EIO; ret = -EIO;
goto err_out;
} }
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_aztcd_request, &aztSpin); blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_aztcd_request, &aztSpin);
blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), 2048); blk_queue_hardsect_size(BLK_DEFAULT_QUEUE(MAJOR_NR), 2048);
register_disk(NULL, mk_kdev(MAJOR_NR, 0), 1, &azt_fops, 0); register_disk(NULL, mk_kdev(MAJOR_NR, 0), 1, &azt_fops, 0);
if ((azt_port == 0x1f0) || (azt_port == 0x170))
request_region(azt_port, 8, "aztcd"); /*IDE-interface */
else
request_region(azt_port, 4, "aztcd"); /*proprietary interface */
azt_invalidate_buffers(); azt_invalidate_buffers();
aztPresent = 1; aztPresent = 1;
aztCloseDoor(); aztCloseDoor();
return (0); return (0);
err_out:
if ((azt_port == 0x1f0) || (azt_port == 0x170)) {
SWITCH_IDE_MASTER;
release_region(azt_port, 8); /*IDE-interface */
} else
release_region(azt_port, 4); /*proprietary interface */
return ret;
} }
void __exit aztcd_exit(void) void __exit aztcd_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment