diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2012-01-22 06:44:25 -0500 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2012-04-22 14:16:48 -0400 |
commit | eeed227966daed8c4171fe8bdd4e2275ab2cf94d (patch) | |
tree | 577d7f83bd61ea3045b26bfeb9f2d5f93e903934 /arch/m68k/amiga/platform.c | |
parent | 943ce30806b93f69736270e5948e694e715f57a5 (diff) |
m68k/amiga: Add error checks when registering platform devices
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/amiga/platform.c')
-rw-r--r-- | arch/m68k/amiga/platform.c | 122 |
1 files changed, 90 insertions, 32 deletions
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index 1b8db5cc3c5a..28728918b295 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * for more details. | 6 | * for more details. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/err.h> | ||
9 | #include <linux/init.h> | 10 | #include <linux/init.h> |
10 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
11 | #include <linux/zorro.h> | 12 | #include <linux/zorro.h> |
@@ -46,11 +47,18 @@ static const struct resource zorro_resources[] __initconst = { | |||
46 | 47 | ||
47 | static int __init amiga_init_bus(void) | 48 | static int __init amiga_init_bus(void) |
48 | { | 49 | { |
50 | struct platform_device *pdev; | ||
51 | unsigned int n; | ||
52 | |||
49 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) | 53 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) |
50 | return -ENODEV; | 54 | return -ENODEV; |
51 | 55 | ||
52 | platform_device_register_simple("amiga-zorro", -1, zorro_resources, | 56 | n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; |
53 | 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 | return 0; | 62 | return 0; |
55 | } | 63 | } |
56 | 64 | ||
@@ -126,70 +134,120 @@ static const struct resource amiga_rtc_resource __initconst = { | |||
126 | static int __init amiga_init_devices(void) | 134 | static int __init amiga_init_devices(void) |
127 | { | 135 | { |
128 | struct platform_device *pdev; | 136 | struct platform_device *pdev; |
137 | int error; | ||
129 | 138 | ||
130 | if (!MACH_IS_AMIGA) | 139 | if (!MACH_IS_AMIGA) |
131 | return -ENODEV; | 140 | return -ENODEV; |
132 | 141 | ||
133 | /* video hardware */ | 142 | /* video hardware */ |
134 | if (AMIGAHW_PRESENT(AMI_VIDEO)) | 143 | if (AMIGAHW_PRESENT(AMI_VIDEO)) { |
135 | platform_device_register_simple("amiga-video", -1, NULL, 0); | 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 | /* sound hardware */ | 151 | /* sound hardware */ |
139 | if (AMIGAHW_PRESENT(AMI_AUDIO)) | 152 | if (AMIGAHW_PRESENT(AMI_AUDIO)) { |
140 | platform_device_register_simple("amiga-audio", -1, NULL, 0); | 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 | /* storage interfaces */ | 160 | /* storage interfaces */ |
144 | if (AMIGAHW_PRESENT(AMI_FLOPPY)) | 161 | if (AMIGAHW_PRESENT(AMI_FLOPPY)) { |
145 | platform_device_register_simple("amiga-floppy", -1, NULL, 0); | 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)) | 168 | if (AMIGAHW_PRESENT(A3000_SCSI)) { |
148 | platform_device_register_simple("amiga-a3000-scsi", -1, | 169 | pdev = platform_device_register_simple("amiga-a3000-scsi", -1, |
149 | &a3000_scsi_resource, 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)) | 175 | if (AMIGAHW_PRESENT(A4000_SCSI)) { |
152 | platform_device_register_simple("amiga-a4000t-scsi", -1, | 176 | pdev = platform_device_register_simple("amiga-a4000t-scsi", -1, |
153 | &a4000t_scsi_resource, 1); | 177 | &a4000t_scsi_resource, |
178 | 1); | ||
179 | if (IS_ERR(pdev)) | ||
180 | return PTR_ERR(pdev); | ||
181 | } | ||
154 | 182 | ||
155 | if (AMIGAHW_PRESENT(A1200_IDE) || | 183 | if (AMIGAHW_PRESENT(A1200_IDE) || |
156 | z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { | 184 | z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { |
157 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, | 185 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
158 | &a1200_ide_resource, 1); | 186 | &a1200_ide_resource, 1); |
159 | platform_device_add_data(pdev, &a1200_ide_pdata, | 187 | if (IS_ERR(pdev)) |
160 | sizeof(a1200_ide_pdata)); | 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 | if (AMIGAHW_PRESENT(A4000_IDE)) { | 195 | if (AMIGAHW_PRESENT(A4000_IDE)) { |
164 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, | 196 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
165 | &a4000_ide_resource, 1); | 197 | &a4000_ide_resource, 1); |
166 | platform_device_add_data(pdev, &a4000_ide_pdata, | 198 | if (IS_ERR(pdev)) |
167 | sizeof(a4000_ide_pdata)); | 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 | /* other I/O hardware */ | 207 | /* other I/O hardware */ |
172 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) | 208 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) { |
173 | platform_device_register_simple("amiga-keyboard", -1, NULL, 0); | 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)) | 215 | if (AMIGAHW_PRESENT(AMI_MOUSE)) { |
176 | platform_device_register_simple("amiga-mouse", -1, NULL, 0); | 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)) | 222 | if (AMIGAHW_PRESENT(AMI_SERIAL)) { |
179 | platform_device_register_simple("amiga-serial", -1, NULL, 0); | 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)) | 229 | if (AMIGAHW_PRESENT(AMI_PARALLEL)) { |
182 | platform_device_register_simple("amiga-parallel", -1, NULL, 0); | 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 | /* real time clocks */ | 237 | /* real time clocks */ |
186 | if (AMIGAHW_PRESENT(A2000_CLK)) | 238 | if (AMIGAHW_PRESENT(A2000_CLK)) { |
187 | platform_device_register_simple("rtc-msm6242", -1, | 239 | pdev = platform_device_register_simple("rtc-msm6242", -1, |
188 | &amiga_rtc_resource, 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)) | 245 | if (AMIGAHW_PRESENT(A3000_CLK)) { |
191 | platform_device_register_simple("rtc-rp5c01", -1, | 246 | pdev = platform_device_register_simple("rtc-rp5c01", -1, |
192 | &amiga_rtc_resource, 1); | 247 | &amiga_rtc_resource, 1); |
248 | if (IS_ERR(pdev)) | ||
249 | return PTR_ERR(pdev); | ||
250 | } | ||
193 | 251 | ||
194 | return 0; | 252 | return 0; |
195 | } | 253 | } |