@@ -40,7 +40,7 @@ struct xgene_msi {
40
40
};
41
41
42
42
/* Global data */
43
- static struct xgene_msi xgene_msi_ctrl ;
43
+ static struct xgene_msi * xgene_msi_ctrl ;
44
44
45
45
/*
46
46
* X-Gene v1 has 16 groups of MSI termination registers MSInIRx, where
@@ -253,18 +253,18 @@ static void xgene_free_domains(struct xgene_msi *msi)
253
253
irq_domain_remove (msi -> inner_domain );
254
254
}
255
255
256
- static int xgene_msi_init_allocator (struct xgene_msi * xgene_msi )
256
+ static int xgene_msi_init_allocator (struct device * dev )
257
257
{
258
- xgene_msi -> bitmap = bitmap_zalloc ( NR_MSI_VEC , GFP_KERNEL );
259
- if (!xgene_msi -> bitmap )
258
+ xgene_msi_ctrl -> bitmap = devm_bitmap_zalloc ( dev , NR_MSI_VEC , GFP_KERNEL );
259
+ if (!xgene_msi_ctrl -> bitmap )
260
260
return - ENOMEM ;
261
261
262
- mutex_init (& xgene_msi -> bitmap_lock );
262
+ mutex_init (& xgene_msi_ctrl -> bitmap_lock );
263
263
264
- xgene_msi -> msi_groups = kcalloc ( NR_HW_IRQS ,
265
- sizeof (struct xgene_msi_group ),
266
- GFP_KERNEL );
267
- if (!xgene_msi -> msi_groups )
264
+ xgene_msi_ctrl -> msi_groups = devm_kcalloc ( dev , NR_HW_IRQS ,
265
+ sizeof (struct xgene_msi_group ),
266
+ GFP_KERNEL );
267
+ if (!xgene_msi_ctrl -> msi_groups )
268
268
return - ENOMEM ;
269
269
270
270
return 0 ;
@@ -273,15 +273,14 @@ static int xgene_msi_init_allocator(struct xgene_msi *xgene_msi)
273
273
static void xgene_msi_isr (struct irq_desc * desc )
274
274
{
275
275
struct irq_chip * chip = irq_desc_get_chip (desc );
276
+ struct xgene_msi * xgene_msi = xgene_msi_ctrl ;
276
277
struct xgene_msi_group * msi_groups ;
277
- struct xgene_msi * xgene_msi ;
278
278
int msir_index , msir_val , hw_irq , ret ;
279
279
u32 intr_index , grp_select , msi_grp ;
280
280
281
281
chained_irq_enter (chip , desc );
282
282
283
283
msi_groups = irq_desc_get_handler_data (desc );
284
- xgene_msi = msi_groups -> msi ;
285
284
msi_grp = msi_groups -> msi_grp ;
286
285
287
286
/*
@@ -344,15 +343,12 @@ static void xgene_msi_remove(struct platform_device *pdev)
344
343
345
344
kfree (msi -> msi_groups );
346
345
347
- bitmap_free (msi -> bitmap );
348
- msi -> bitmap = NULL ;
349
-
350
346
xgene_free_domains (msi );
351
347
}
352
348
353
349
static int xgene_msi_hwirq_alloc (unsigned int cpu )
354
350
{
355
- struct xgene_msi * msi = & xgene_msi_ctrl ;
351
+ struct xgene_msi * msi = xgene_msi_ctrl ;
356
352
struct xgene_msi_group * msi_group ;
357
353
int i ;
358
354
int err ;
@@ -381,7 +377,7 @@ static int xgene_msi_hwirq_alloc(unsigned int cpu)
381
377
382
378
static int xgene_msi_hwirq_free (unsigned int cpu )
383
379
{
384
- struct xgene_msi * msi = & xgene_msi_ctrl ;
380
+ struct xgene_msi * msi = xgene_msi_ctrl ;
385
381
struct xgene_msi_group * msi_group ;
386
382
int i ;
387
383
@@ -406,7 +402,12 @@ static int xgene_msi_probe(struct platform_device *pdev)
406
402
int virt_msir ;
407
403
u32 msi_val , msi_idx ;
408
404
409
- xgene_msi = & xgene_msi_ctrl ;
405
+ xgene_msi_ctrl = devm_kzalloc (& pdev -> dev , sizeof (* xgene_msi_ctrl ),
406
+ GFP_KERNEL );
407
+ if (!xgene_msi_ctrl )
408
+ return - ENOMEM ;
409
+
410
+ xgene_msi = xgene_msi_ctrl ;
410
411
411
412
platform_set_drvdata (pdev , xgene_msi );
412
413
@@ -417,7 +418,7 @@ static int xgene_msi_probe(struct platform_device *pdev)
417
418
}
418
419
xgene_msi -> msi_addr = res -> start ;
419
420
420
- rc = xgene_msi_init_allocator (xgene_msi );
421
+ rc = xgene_msi_init_allocator (& pdev -> dev );
421
422
if (rc ) {
422
423
dev_err (& pdev -> dev , "Error allocating MSI bitmap\n" );
423
424
goto error ;
0 commit comments