@@ -26,53 +26,31 @@ static struct device_type mfd_dev_type = {
26
26
int mfd_cell_enable (struct platform_device * pdev )
27
27
{
28
28
const struct mfd_cell * cell = mfd_get_cell (pdev );
29
- int err = 0 ;
30
29
31
30
if (!cell -> enable ) {
32
31
dev_dbg (& pdev -> dev , "No .enable() call-back registered\n" );
33
32
return 0 ;
34
33
}
35
34
36
- /* only call enable hook if the cell wasn't previously enabled */
37
- if (atomic_inc_return (cell -> usage_count ) == 1 )
38
- err = cell -> enable (pdev );
39
-
40
- /* if the enable hook failed, decrement counter to allow retries */
41
- if (err )
42
- atomic_dec (cell -> usage_count );
43
-
44
- return err ;
35
+ return cell -> enable (pdev );
45
36
}
46
37
EXPORT_SYMBOL (mfd_cell_enable );
47
38
48
39
int mfd_cell_disable (struct platform_device * pdev )
49
40
{
50
41
const struct mfd_cell * cell = mfd_get_cell (pdev );
51
- int err = 0 ;
52
42
53
43
if (!cell -> disable ) {
54
44
dev_dbg (& pdev -> dev , "No .disable() call-back registered\n" );
55
45
return 0 ;
56
46
}
57
47
58
- /* only disable if no other clients are using it */
59
- if (atomic_dec_return (cell -> usage_count ) == 0 )
60
- err = cell -> disable (pdev );
61
-
62
- /* if the disable hook failed, increment to allow retries */
63
- if (err )
64
- atomic_inc (cell -> usage_count );
65
-
66
- /* sanity check; did someone call disable too many times? */
67
- WARN_ON (atomic_read (cell -> usage_count ) < 0 );
68
-
69
- return err ;
48
+ return cell -> disable (pdev );
70
49
}
71
50
EXPORT_SYMBOL (mfd_cell_disable );
72
51
73
52
static int mfd_platform_add_cell (struct platform_device * pdev ,
74
- const struct mfd_cell * cell ,
75
- atomic_t * usage_count )
53
+ const struct mfd_cell * cell )
76
54
{
77
55
if (!cell )
78
56
return 0 ;
@@ -81,7 +59,6 @@ static int mfd_platform_add_cell(struct platform_device *pdev,
81
59
if (!pdev -> mfd_cell )
82
60
return - ENOMEM ;
83
61
84
- pdev -> mfd_cell -> usage_count = usage_count ;
85
62
return 0 ;
86
63
}
87
64
@@ -144,7 +121,7 @@ static inline void mfd_acpi_add_device(const struct mfd_cell *cell,
144
121
#endif
145
122
146
123
static int mfd_add_device (struct device * parent , int id ,
147
- const struct mfd_cell * cell , atomic_t * usage_count ,
124
+ const struct mfd_cell * cell ,
148
125
struct resource * mem_base ,
149
126
int irq_base , struct irq_domain * domain )
150
127
{
@@ -206,7 +183,7 @@ static int mfd_add_device(struct device *parent, int id,
206
183
goto fail_alias ;
207
184
}
208
185
209
- ret = mfd_platform_add_cell (pdev , cell , usage_count );
186
+ ret = mfd_platform_add_cell (pdev , cell );
210
187
if (ret )
211
188
goto fail_alias ;
212
189
@@ -296,16 +273,9 @@ int mfd_add_devices(struct device *parent, int id,
296
273
{
297
274
int i ;
298
275
int ret ;
299
- atomic_t * cnts ;
300
-
301
- /* initialize reference counting for all cells */
302
- cnts = kcalloc (n_devs , sizeof (* cnts ), GFP_KERNEL );
303
- if (!cnts )
304
- return - ENOMEM ;
305
276
306
277
for (i = 0 ; i < n_devs ; i ++ ) {
307
- atomic_set (& cnts [i ], 0 );
308
- ret = mfd_add_device (parent , id , cells + i , cnts + i , mem_base ,
278
+ ret = mfd_add_device (parent , id , cells + i , mem_base ,
309
279
irq_base , domain );
310
280
if (ret )
311
281
goto fail ;
@@ -316,17 +286,15 @@ int mfd_add_devices(struct device *parent, int id,
316
286
fail :
317
287
if (i )
318
288
mfd_remove_devices (parent );
319
- else
320
- kfree (cnts );
289
+
321
290
return ret ;
322
291
}
323
292
EXPORT_SYMBOL (mfd_add_devices );
324
293
325
- static int mfd_remove_devices_fn (struct device * dev , void * c )
294
+ static int mfd_remove_devices_fn (struct device * dev , void * data )
326
295
{
327
296
struct platform_device * pdev ;
328
297
const struct mfd_cell * cell ;
329
- atomic_t * * usage_count = c ;
330
298
331
299
if (dev -> type != & mfd_dev_type )
332
300
return 0 ;
@@ -337,20 +305,13 @@ static int mfd_remove_devices_fn(struct device *dev, void *c)
337
305
regulator_bulk_unregister_supply_alias (dev , cell -> parent_supplies ,
338
306
cell -> num_parent_supplies );
339
307
340
- /* find the base address of usage_count pointers (for freeing) */
341
- if (!* usage_count || (cell -> usage_count < * usage_count ))
342
- * usage_count = cell -> usage_count ;
343
-
344
308
platform_device_unregister (pdev );
345
309
return 0 ;
346
310
}
347
311
348
312
void mfd_remove_devices (struct device * parent )
349
313
{
350
- atomic_t * cnts = NULL ;
351
-
352
- device_for_each_child_reverse (parent , & cnts , mfd_remove_devices_fn );
353
- kfree (cnts );
314
+ device_for_each_child_reverse (parent , NULL , mfd_remove_devices_fn );
354
315
}
355
316
EXPORT_SYMBOL (mfd_remove_devices );
356
317
0 commit comments