diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:59 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-23 13:55:59 -0400 |
commit | 8a69580e1ea9516caada5eed202afd39546e9809 (patch) | |
tree | fb300fb7d67e09470a2654811baaa7832fec2fae /drivers/ide/legacy | |
parent | 18de10170df31d34b342612f1c896a16a52f0a5c (diff) |
ide: add ide_host_free() helper (take 2)
* Add ide_host_free() helper and convert ide_host_remove() to use it.
* Fix handling of ide_host_register() failure in ide_host_add(),
icside.c, ide-generic.c, falconide.c and sgiioc4.c.
While at it:
* Fix handling of ide_host_alloc_all() failure in ide-generic.c.
* Fix handling of ide_host_alloc() failure in falconide.c
(also return the correct error value if no device is found).
v2:
* falconide build fix. (From Stephen Rothwell)
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/legacy')
-rw-r--r-- | drivers/ide/legacy/falconide.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 4eb5c3f9fecc..724f95073d80 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -114,9 +114,10 @@ static int __init falconide_init(void) | |||
114 | { | 114 | { |
115 | struct ide_host *host; | 115 | struct ide_host *host; |
116 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 116 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
117 | int rc; | ||
117 | 118 | ||
118 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) | 119 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) |
119 | return 0; | 120 | return -ENODEV; |
120 | 121 | ||
121 | printk(KERN_INFO "ide: Falcon IDE controller\n"); | 122 | printk(KERN_INFO "ide: Falcon IDE controller\n"); |
122 | 123 | ||
@@ -128,13 +129,24 @@ static int __init falconide_init(void) | |||
128 | falconide_setup_ports(&hw); | 129 | falconide_setup_ports(&hw); |
129 | 130 | ||
130 | host = ide_host_alloc(&falconide_port_info, hws); | 131 | host = ide_host_alloc(&falconide_port_info, hws); |
131 | if (host) { | 132 | if (host == NULL) { |
132 | ide_get_lock(NULL, NULL); | 133 | rc = -ENOMEM; |
133 | ide_host_register(host, &falconide_port_info, hws); | 134 | goto err; |
134 | ide_release_lock(); | ||
135 | } | 135 | } |
136 | 136 | ||
137 | ide_get_lock(NULL, NULL); | ||
138 | rc = ide_host_register(host, &falconide_port_info, hws); | ||
139 | ide_release_lock(); | ||
140 | |||
141 | if (rc) | ||
142 | goto err_free; | ||
143 | |||
137 | return 0; | 144 | return 0; |
145 | err_free: | ||
146 | ide_host_free(host); | ||
147 | err: | ||
148 | release_mem_region(ATA_HD_BASE, 0x40); | ||
149 | return rc; | ||
138 | } | 150 | } |
139 | 151 | ||
140 | module_init(falconide_init); | 152 | module_init(falconide_init); |