Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176494
b: refs/heads/master
c: a3b8d92
h: refs/heads/master
v: v3
  • Loading branch information
Mel Gorman authored and Jens Axboe committed Dec 9, 2009
1 parent 5eabd7b commit 80af9fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8b43aebdaa4fa3348dafd6f2f5f526bd3e8b84ac
refs/heads/master: a3b8d92d25212c5b6534ae9b347ed2858de78336
30 changes: 19 additions & 11 deletions trunk/drivers/block/xd.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ static int __init xd_init(void)

init_timer (&xd_watchdog_int); xd_watchdog_int.function = xd_watchdog;

if (!xd_dma_buffer)
xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200);
if (!xd_dma_buffer) {
printk(KERN_ERR "xd: Out of memory.\n");
return -ENOMEM;
}

err = -EBUSY;
if (register_blkdev(XT_DISK_MAJOR, "xd"))
goto out1;
Expand All @@ -202,6 +195,19 @@ static int __init xd_init(void)
xd_drives,xd_drives == 1 ? "" : "s",xd_irq,xd_dma);
}

/*
* With the drive detected, xd_maxsectors should now be known.
* If xd_maxsectors is 0, nothing was detected and we fall through
* to return -ENODEV
*/
if (!xd_dma_buffer && xd_maxsectors) {
xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200);
if (!xd_dma_buffer) {
printk(KERN_ERR "xd: Out of memory.\n");
goto out3;
}
}

err = -ENODEV;
if (!xd_drives)
goto out3;
Expand Down Expand Up @@ -249,15 +255,17 @@ static int __init xd_init(void)
for (i = 0; i < xd_drives; i++)
put_disk(xd_gendisk[i]);
out3:
release_region(xd_iobase,4);
if (xd_maxsectors)
release_region(xd_iobase,4);

if (xd_dma_buffer)
xd_dma_mem_free((unsigned long)xd_dma_buffer,
xd_maxsectors * 0x200);
out2:
blk_cleanup_queue(xd_queue);
out1a:
unregister_blkdev(XT_DISK_MAJOR, "xd");
out1:
if (xd_dma_buffer)
xd_dma_mem_free((unsigned long)xd_dma_buffer,
xd_maxsectors * 0x200);
return err;
Enomem:
err = -ENOMEM;
Expand Down

0 comments on commit 80af9fa

Please sign in to comment.