diff options
Diffstat (limited to 'drivers/block/xd.c')
-rw-r--r-- | drivers/block/xd.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/block/xd.c b/drivers/block/xd.c index 0877d3628fda..d1fd032e7514 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c | |||
@@ -169,13 +169,6 @@ static int __init xd_init(void) | |||
169 | 169 | ||
170 | init_timer (&xd_watchdog_int); xd_watchdog_int.function = xd_watchdog; | 170 | init_timer (&xd_watchdog_int); xd_watchdog_int.function = xd_watchdog; |
171 | 171 | ||
172 | if (!xd_dma_buffer) | ||
173 | xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200); | ||
174 | if (!xd_dma_buffer) { | ||
175 | printk(KERN_ERR "xd: Out of memory.\n"); | ||
176 | return -ENOMEM; | ||
177 | } | ||
178 | |||
179 | err = -EBUSY; | 172 | err = -EBUSY; |
180 | if (register_blkdev(XT_DISK_MAJOR, "xd")) | 173 | if (register_blkdev(XT_DISK_MAJOR, "xd")) |
181 | goto out1; | 174 | goto out1; |
@@ -202,6 +195,19 @@ static int __init xd_init(void) | |||
202 | xd_drives,xd_drives == 1 ? "" : "s",xd_irq,xd_dma); | 195 | xd_drives,xd_drives == 1 ? "" : "s",xd_irq,xd_dma); |
203 | } | 196 | } |
204 | 197 | ||
198 | /* | ||
199 | * With the drive detected, xd_maxsectors should now be known. | ||
200 | * If xd_maxsectors is 0, nothing was detected and we fall through | ||
201 | * to return -ENODEV | ||
202 | */ | ||
203 | if (!xd_dma_buffer && xd_maxsectors) { | ||
204 | xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200); | ||
205 | if (!xd_dma_buffer) { | ||
206 | printk(KERN_ERR "xd: Out of memory.\n"); | ||
207 | goto out3; | ||
208 | } | ||
209 | } | ||
210 | |||
205 | err = -ENODEV; | 211 | err = -ENODEV; |
206 | if (!xd_drives) | 212 | if (!xd_drives) |
207 | goto out3; | 213 | goto out3; |
@@ -249,15 +255,17 @@ out4: | |||
249 | for (i = 0; i < xd_drives; i++) | 255 | for (i = 0; i < xd_drives; i++) |
250 | put_disk(xd_gendisk[i]); | 256 | put_disk(xd_gendisk[i]); |
251 | out3: | 257 | out3: |
252 | release_region(xd_iobase,4); | 258 | if (xd_maxsectors) |
259 | release_region(xd_iobase,4); | ||
260 | |||
261 | if (xd_dma_buffer) | ||
262 | xd_dma_mem_free((unsigned long)xd_dma_buffer, | ||
263 | xd_maxsectors * 0x200); | ||
253 | out2: | 264 | out2: |
254 | blk_cleanup_queue(xd_queue); | 265 | blk_cleanup_queue(xd_queue); |
255 | out1a: | 266 | out1a: |
256 | unregister_blkdev(XT_DISK_MAJOR, "xd"); | 267 | unregister_blkdev(XT_DISK_MAJOR, "xd"); |
257 | out1: | 268 | out1: |
258 | if (xd_dma_buffer) | ||
259 | xd_dma_mem_free((unsigned long)xd_dma_buffer, | ||
260 | xd_maxsectors * 0x200); | ||
261 | return err; | 269 | return err; |
262 | Enomem: | 270 | Enomem: |
263 | err = -ENOMEM; | 271 | err = -ENOMEM; |