@@ -183,46 +183,39 @@ static int bbc_beep_probe(struct platform_device *op)
183
183
struct sparcspkr_state * state ;
184
184
struct bbc_beep_info * info ;
185
185
struct device_node * dp ;
186
- int err = - ENOMEM ;
186
+ int err ;
187
187
188
- state = kzalloc ( sizeof (* state ), GFP_KERNEL );
188
+ state = devm_kzalloc ( & op -> dev , sizeof (* state ), GFP_KERNEL );
189
189
if (!state )
190
- goto out_err ;
190
+ return - ENOMEM ;
191
191
192
192
state -> name = "Sparc BBC Speaker" ;
193
193
state -> event = bbc_spkr_event ;
194
194
spin_lock_init (& state -> lock );
195
195
196
196
dp = of_find_node_by_path ("/" );
197
- err = - ENODEV ;
198
197
if (!dp )
199
- goto out_free ;
198
+ return - ENODEV ;
200
199
201
200
info = & state -> u .bbc ;
202
201
info -> clock_freq = of_getintprop_default (dp , "clock-frequency" , 0 );
203
202
of_node_put (dp );
204
203
if (!info -> clock_freq )
205
- goto out_free ;
204
+ return - ENODEV ;
206
205
207
206
info -> regs = of_ioremap (& op -> resource [0 ], 0 , 6 , "bbc beep" );
208
207
if (!info -> regs )
209
- goto out_free ;
208
+ return - ENODEV ;
210
209
211
210
platform_set_drvdata (op , state );
212
211
213
212
err = sparcspkr_probe (& op -> dev );
214
- if (err )
215
- goto out_clear_drvdata ;
213
+ if (err ) {
214
+ of_iounmap (& op -> resource [0 ], info -> regs , 6 );
215
+ return err ;
216
+ }
216
217
217
218
return 0 ;
218
-
219
- out_clear_drvdata :
220
- of_iounmap (& op -> resource [0 ], info -> regs , 6 );
221
-
222
- out_free :
223
- kfree (state );
224
- out_err :
225
- return err ;
226
219
}
227
220
228
221
static void bbc_remove (struct platform_device * op )
@@ -237,8 +230,6 @@ static void bbc_remove(struct platform_device *op)
237
230
input_unregister_device (input_dev );
238
231
239
232
of_iounmap (& op -> resource [0 ], info -> regs , 6 );
240
-
241
- kfree (state );
242
233
}
243
234
244
235
static const struct of_device_id bbc_beep_match [] = {
@@ -266,9 +257,9 @@ static int grover_beep_probe(struct platform_device *op)
266
257
struct grover_beep_info * info ;
267
258
int err = - ENOMEM ;
268
259
269
- state = kzalloc ( sizeof (* state ), GFP_KERNEL );
260
+ state = devm_kzalloc ( & op -> dev , sizeof (* state ), GFP_KERNEL );
270
261
if (!state )
271
- goto out_err ;
262
+ return err ;
272
263
273
264
state -> name = "Sparc Grover Speaker" ;
274
265
state -> event = grover_spkr_event ;
@@ -277,7 +268,7 @@ static int grover_beep_probe(struct platform_device *op)
277
268
info = & state -> u .grover ;
278
269
info -> freq_regs = of_ioremap (& op -> resource [2 ], 0 , 2 , "grover beep freq" );
279
270
if (!info -> freq_regs )
280
- goto out_free ;
271
+ return err ;
281
272
282
273
info -> enable_reg = of_ioremap (& op -> resource [3 ], 0 , 1 , "grover beep enable" );
283
274
if (!info -> enable_reg )
@@ -296,9 +287,7 @@ static int grover_beep_probe(struct platform_device *op)
296
287
297
288
out_unmap_freq_regs :
298
289
of_iounmap (& op -> resource [2 ], info -> freq_regs , 2 );
299
- out_free :
300
- kfree (state );
301
- out_err :
290
+
302
291
return err ;
303
292
}
304
293
@@ -315,8 +304,6 @@ static void grover_remove(struct platform_device *op)
315
304
316
305
of_iounmap (& op -> resource [3 ], info -> enable_reg , 1 );
317
306
of_iounmap (& op -> resource [2 ], info -> freq_regs , 2 );
318
-
319
- kfree (state );
320
307
}
321
308
322
309
static const struct of_device_id grover_beep_match [] = {
0 commit comments