|
6 | 6 | * for more details. |
7 | 7 | */ |
8 | 8 |
|
| 9 | +#include <linux/err.h> |
9 | 10 | #include <linux/init.h> |
10 | 11 | #include <linux/platform_device.h> |
11 | 12 | #include <linux/zorro.h> |
@@ -46,18 +47,25 @@ static const struct resource zorro_resources[] __initconst = { |
46 | 47 |
|
47 | 48 | static int __init amiga_init_bus(void) |
48 | 49 | { |
| 50 | + struct platform_device *pdev; |
| 51 | + unsigned int n; |
| 52 | + |
49 | 53 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) |
50 | 54 | return -ENODEV; |
51 | 55 |
|
52 | | - platform_device_register_simple("amiga-zorro", -1, zorro_resources, |
53 | | - AMIGAHW_PRESENT(ZORRO3) ? 4 : 2); |
| 56 | + n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; |
| 57 | + pdev = platform_device_register_simple("amiga-zorro", -1, |
| 58 | + zorro_resources, n); |
| 59 | + if (IS_ERR(pdev)) |
| 60 | + return PTR_ERR(pdev); |
| 61 | + |
54 | 62 | return 0; |
55 | 63 | } |
56 | 64 |
|
57 | 65 | subsys_initcall(amiga_init_bus); |
58 | 66 |
|
59 | 67 |
|
60 | | -static int z_dev_present(zorro_id id) |
| 68 | +static int __init z_dev_present(zorro_id id) |
61 | 69 | { |
62 | 70 | unsigned int i; |
63 | 71 |
|
@@ -126,72 +134,122 @@ static const struct resource amiga_rtc_resource __initconst = { |
126 | 134 | static int __init amiga_init_devices(void) |
127 | 135 | { |
128 | 136 | struct platform_device *pdev; |
| 137 | + int error; |
129 | 138 |
|
130 | 139 | if (!MACH_IS_AMIGA) |
131 | 140 | return -ENODEV; |
132 | 141 |
|
133 | 142 | /* video hardware */ |
134 | | - if (AMIGAHW_PRESENT(AMI_VIDEO)) |
135 | | - platform_device_register_simple("amiga-video", -1, NULL, 0); |
| 143 | + if (AMIGAHW_PRESENT(AMI_VIDEO)) { |
| 144 | + pdev = platform_device_register_simple("amiga-video", -1, NULL, |
| 145 | + 0); |
| 146 | + if (IS_ERR(pdev)) |
| 147 | + return PTR_ERR(pdev); |
| 148 | + } |
136 | 149 |
|
137 | 150 |
|
138 | 151 | /* sound hardware */ |
139 | | - if (AMIGAHW_PRESENT(AMI_AUDIO)) |
140 | | - platform_device_register_simple("amiga-audio", -1, NULL, 0); |
| 152 | + if (AMIGAHW_PRESENT(AMI_AUDIO)) { |
| 153 | + pdev = platform_device_register_simple("amiga-audio", -1, NULL, |
| 154 | + 0); |
| 155 | + if (IS_ERR(pdev)) |
| 156 | + return PTR_ERR(pdev); |
| 157 | + } |
141 | 158 |
|
142 | 159 |
|
143 | 160 | /* storage interfaces */ |
144 | | - if (AMIGAHW_PRESENT(AMI_FLOPPY)) |
145 | | - platform_device_register_simple("amiga-floppy", -1, NULL, 0); |
| 161 | + if (AMIGAHW_PRESENT(AMI_FLOPPY)) { |
| 162 | + pdev = platform_device_register_simple("amiga-floppy", -1, |
| 163 | + NULL, 0); |
| 164 | + if (IS_ERR(pdev)) |
| 165 | + return PTR_ERR(pdev); |
| 166 | + } |
146 | 167 |
|
147 | | - if (AMIGAHW_PRESENT(A3000_SCSI)) |
148 | | - platform_device_register_simple("amiga-a3000-scsi", -1, |
149 | | - &a3000_scsi_resource, 1); |
| 168 | + if (AMIGAHW_PRESENT(A3000_SCSI)) { |
| 169 | + pdev = platform_device_register_simple("amiga-a3000-scsi", -1, |
| 170 | + &a3000_scsi_resource, 1); |
| 171 | + if (IS_ERR(pdev)) |
| 172 | + return PTR_ERR(pdev); |
| 173 | + } |
150 | 174 |
|
151 | | - if (AMIGAHW_PRESENT(A4000_SCSI)) |
152 | | - platform_device_register_simple("amiga-a4000t-scsi", -1, |
153 | | - &a4000t_scsi_resource, 1); |
| 175 | + if (AMIGAHW_PRESENT(A4000_SCSI)) { |
| 176 | + pdev = platform_device_register_simple("amiga-a4000t-scsi", -1, |
| 177 | + &a4000t_scsi_resource, |
| 178 | + 1); |
| 179 | + if (IS_ERR(pdev)) |
| 180 | + return PTR_ERR(pdev); |
| 181 | + } |
154 | 182 |
|
155 | 183 | if (AMIGAHW_PRESENT(A1200_IDE) || |
156 | 184 | z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { |
157 | 185 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
158 | 186 | &a1200_ide_resource, 1); |
159 | | - platform_device_add_data(pdev, &a1200_ide_pdata, |
160 | | - sizeof(a1200_ide_pdata)); |
| 187 | + if (IS_ERR(pdev)) |
| 188 | + return PTR_ERR(pdev); |
| 189 | + error = platform_device_add_data(pdev, &a1200_ide_pdata, |
| 190 | + sizeof(a1200_ide_pdata)); |
| 191 | + if (error) |
| 192 | + return error; |
161 | 193 | } |
162 | 194 |
|
163 | 195 | if (AMIGAHW_PRESENT(A4000_IDE)) { |
164 | 196 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
165 | 197 | &a4000_ide_resource, 1); |
166 | | - platform_device_add_data(pdev, &a4000_ide_pdata, |
167 | | - sizeof(a4000_ide_pdata)); |
| 198 | + if (IS_ERR(pdev)) |
| 199 | + return PTR_ERR(pdev); |
| 200 | + error = platform_device_add_data(pdev, &a4000_ide_pdata, |
| 201 | + sizeof(a4000_ide_pdata)); |
| 202 | + if (error) |
| 203 | + return error; |
168 | 204 | } |
169 | 205 |
|
170 | 206 |
|
171 | 207 | /* other I/O hardware */ |
172 | | - if (AMIGAHW_PRESENT(AMI_KEYBOARD)) |
173 | | - platform_device_register_simple("amiga-keyboard", -1, NULL, 0); |
| 208 | + if (AMIGAHW_PRESENT(AMI_KEYBOARD)) { |
| 209 | + pdev = platform_device_register_simple("amiga-keyboard", -1, |
| 210 | + NULL, 0); |
| 211 | + if (IS_ERR(pdev)) |
| 212 | + return PTR_ERR(pdev); |
| 213 | + } |
174 | 214 |
|
175 | | - if (AMIGAHW_PRESENT(AMI_MOUSE)) |
176 | | - platform_device_register_simple("amiga-mouse", -1, NULL, 0); |
| 215 | + if (AMIGAHW_PRESENT(AMI_MOUSE)) { |
| 216 | + pdev = platform_device_register_simple("amiga-mouse", -1, NULL, |
| 217 | + 0); |
| 218 | + if (IS_ERR(pdev)) |
| 219 | + return PTR_ERR(pdev); |
| 220 | + } |
177 | 221 |
|
178 | | - if (AMIGAHW_PRESENT(AMI_SERIAL)) |
179 | | - platform_device_register_simple("amiga-serial", -1, NULL, 0); |
| 222 | + if (AMIGAHW_PRESENT(AMI_SERIAL)) { |
| 223 | + pdev = platform_device_register_simple("amiga-serial", -1, |
| 224 | + NULL, 0); |
| 225 | + if (IS_ERR(pdev)) |
| 226 | + return PTR_ERR(pdev); |
| 227 | + } |
180 | 228 |
|
181 | | - if (AMIGAHW_PRESENT(AMI_PARALLEL)) |
182 | | - platform_device_register_simple("amiga-parallel", -1, NULL, 0); |
| 229 | + if (AMIGAHW_PRESENT(AMI_PARALLEL)) { |
| 230 | + pdev = platform_device_register_simple("amiga-parallel", -1, |
| 231 | + NULL, 0); |
| 232 | + if (IS_ERR(pdev)) |
| 233 | + return PTR_ERR(pdev); |
| 234 | + } |
183 | 235 |
|
184 | 236 |
|
185 | 237 | /* real time clocks */ |
186 | | - if (AMIGAHW_PRESENT(A2000_CLK)) |
187 | | - platform_device_register_simple("rtc-msm6242", -1, |
188 | | - &amiga_rtc_resource, 1); |
| 238 | + if (AMIGAHW_PRESENT(A2000_CLK)) { |
| 239 | + pdev = platform_device_register_simple("rtc-msm6242", -1, |
| 240 | + &amiga_rtc_resource, 1); |
| 241 | + if (IS_ERR(pdev)) |
| 242 | + return PTR_ERR(pdev); |
| 243 | + } |
189 | 244 |
|
190 | | - if (AMIGAHW_PRESENT(A3000_CLK)) |
191 | | - platform_device_register_simple("rtc-rp5c01", -1, |
192 | | - &amiga_rtc_resource, 1); |
| 245 | + if (AMIGAHW_PRESENT(A3000_CLK)) { |
| 246 | + pdev = platform_device_register_simple("rtc-rp5c01", -1, |
| 247 | + &amiga_rtc_resource, 1); |
| 248 | + if (IS_ERR(pdev)) |
| 249 | + return PTR_ERR(pdev); |
| 250 | + } |
193 | 251 |
|
194 | 252 | return 0; |
195 | 253 | } |
196 | 254 |
|
197 | | -device_initcall(amiga_init_devices); |
| 255 | +arch_initcall(amiga_init_devices); |
0 commit comments