Commit 82a97c46 authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] region handling cleanups for gscd driver

The usual check_region -> request_region work, plus freeing
of resources on failure path.
parent 85d4331c
...@@ -941,7 +941,7 @@ void __exit exit_gscd(void) ...@@ -941,7 +941,7 @@ void __exit exit_gscd(void)
return; return;
} }
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
release_region(gscd_port, 4); release_region(gscd_port, GSCD_IO_EXTENT);
printk(KERN_INFO "GoldStar-module released.\n"); printk(KERN_INFO "GoldStar-module released.\n");
} }
...@@ -964,16 +964,16 @@ int __init my_gscd_init(void) ...@@ -964,16 +964,16 @@ int __init my_gscd_init(void)
{ {
int i; int i;
int result; int result;
int ret=0;
printk(KERN_INFO "GSCD: version %s\n", GSCD_VERSION); printk(KERN_INFO "GSCD: version %s\n", GSCD_VERSION);
printk(KERN_INFO printk(KERN_INFO
"GSCD: Trying to detect a Goldstar R420 CD-ROM drive at 0x%X.\n", "GSCD: Trying to detect a Goldstar R420 CD-ROM drive at 0x%X.\n",
gscd_port); gscd_port);
if (check_region(gscd_port, 4)) { if (!request_region(gscd_port, GSCD_IO_EXTENT, "gscd")) {
printk printk(KERN_WARNING "GSCD: Init failed, I/O port (%X) already"
("GSCD: Init failed, I/O port (%X) already in use.\n", " in use.\n", gscd_port);
gscd_port);
return -EIO; return -EIO;
} }
...@@ -981,24 +981,27 @@ int __init my_gscd_init(void) ...@@ -981,24 +981,27 @@ int __init my_gscd_init(void)
/* check for card */ /* check for card */
result = wait_drv_ready(); result = wait_drv_ready();
if (result == 0x09) { if (result == 0x09) {
printk("GSCD: DMA kann ich noch nicht!\n"); printk(KERN_WARNING "GSCD: DMA kann ich noch nicht!\n");
return -EIO; ret = -EIO;
goto err_out1;
} }
if (result == 0x0b) { if (result == 0x0b) {
drv_mode = result; drv_mode = result;
i = find_drives(); i = find_drives();
if (i == 0) { if (i == 0) {
printk printk(KERN_WARNING "GSCD: GoldStar CD-ROM Drive is"
("GSCD: GoldStar CD-ROM Drive is not found.\n"); " not found.\n");
return -EIO; ret = -EIO;
goto err_out1;
} }
} }
if ((result != 0x0b) && (result != 0x09)) { if ((result != 0x0b) && (result != 0x09)) {
printk printk(KERN_WARNING "GSCD: GoldStar Interface Adapter does not "
("GSCD: GoldStar Interface Adapter does not exist or H/W error\n"); "exist or H/W error\n");
return -EIO; ret = -EIO;
goto err_out1;
} }
/* reset all drives */ /* reset all drives */
...@@ -1012,10 +1015,10 @@ int __init my_gscd_init(void) ...@@ -1012,10 +1015,10 @@ int __init my_gscd_init(void)
} }
if (devfs_register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0) { if (devfs_register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0) {
printk printk(KERN_WARNING "GSCD: Unable to get major %d for GoldStar "
("GSCD: Unable to get major %d for GoldStar CD-ROM\n", "CD-ROM\n", MAJOR_NR);
MAJOR_NR); ret = -EIO;
return -EIO; goto err_out1;
} }
devfs_register(NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0, devfs_register(NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL); S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL);
...@@ -1025,11 +1028,13 @@ int __init my_gscd_init(void) ...@@ -1025,11 +1028,13 @@ int __init my_gscd_init(void)
disk_state = 0; disk_state = 0;
gscdPresent = 1; gscdPresent = 1;
request_region(gscd_port, 4, "gscd");
register_disk(NULL, mk_kdev(MAJOR_NR, 0), 1, &gscd_fops, 0); register_disk(NULL, mk_kdev(MAJOR_NR, 0), 1, &gscd_fops, 0);
printk(KERN_INFO "GSCD: GoldStar CD-ROM Drive found.\n"); printk(KERN_INFO "GSCD: GoldStar CD-ROM Drive found.\n");
return 0; return 0;
err_out1:
release_region(gscd_port, GSCD_IO_EXTENT);
return ret;
} }
static void gscd_hsg2msf(long hsg, struct msf *msf) static void gscd_hsg2msf(long hsg, struct msf *msf)
......
...@@ -15,11 +15,10 @@ ...@@ -15,11 +15,10 @@
Appropriate settings are: 0x300, 0x310, 0x320, 0x330, 0x340, 0x350, 0x360 Appropriate settings are: 0x300, 0x310, 0x320, 0x330, 0x340, 0x350, 0x360
0x370, 0x380, 0x390, 0x3A0, 0x3B0, 0x3C0, 0x3D0, 0x3E0, 0x3F0 */ 0x370, 0x380, 0x390, 0x3A0, 0x3B0, 0x3C0, 0x3D0, 0x3E0, 0x3F0 */
/* insert here the I/O port address */ /* insert here the I/O port address and extent */
#define GSCD_BASE_ADDR 0x340 #define GSCD_BASE_ADDR 0x340
#define GSCD_IO_EXTENT 4
/* change this to set the dma-channel */
#define GSCD_DMA_CHANNEL 3 /* not used */
/************** nothing to set up below here *********************/ /************** nothing to set up below here *********************/
......
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