@@ -276,21 +276,14 @@ irq_gc_init_mask_cache(struct irq_chip_generic *gc, enum irq_gc_flags flags)
276
276
}
277
277
278
278
/**
279
- * __irq_alloc_domain_generic_chips - Allocate generic chips for an irq domain
280
- * @d: irq domain for which to allocate chips
281
- * @irqs_per_chip: Number of interrupts each chip handles (max 32)
282
- * @num_ct: Number of irq_chip_type instances associated with this
283
- * @name: Name of the irq chip
284
- * @handler: Default flow handler associated with these chips
285
- * @clr: IRQ_* bits to clear in the mapping function
286
- * @set: IRQ_* bits to set in the mapping function
287
- * @gcflags: Generic chip specific setup flags
279
+ * irq_domain_alloc_generic_chips - Allocate generic chips for an irq domain
280
+ * @d: irq domain for which to allocate chips
281
+ * @info: Generic chip information
282
+ *
283
+ * Return: 0 on success, negative error code on failure
288
284
*/
289
- int __irq_alloc_domain_generic_chips (struct irq_domain * d , int irqs_per_chip ,
290
- int num_ct , const char * name ,
291
- irq_flow_handler_t handler ,
292
- unsigned int clr , unsigned int set ,
293
- enum irq_gc_flags gcflags )
285
+ int irq_domain_alloc_generic_chips (struct irq_domain * d ,
286
+ const struct irq_domain_chip_generic_info * info )
294
287
{
295
288
struct irq_domain_chip_generic * dgc ;
296
289
struct irq_chip_generic * gc ;
@@ -304,35 +297,36 @@ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
304
297
if (d -> gc )
305
298
return - EBUSY ;
306
299
307
- numchips = DIV_ROUND_UP (d -> revmap_size , irqs_per_chip );
300
+ numchips = DIV_ROUND_UP (d -> revmap_size , info -> irqs_per_chip );
308
301
if (!numchips )
309
302
return - EINVAL ;
310
303
311
304
/* Allocate a pointer, generic chip and chiptypes for each chip */
312
- gc_sz = struct_size (gc , chip_types , num_ct );
305
+ gc_sz = struct_size (gc , chip_types , info -> num_ct );
313
306
dgc_sz = struct_size (dgc , gc , numchips );
314
307
sz = dgc_sz + numchips * gc_sz ;
315
308
316
309
tmp = dgc = kzalloc (sz , GFP_KERNEL );
317
310
if (!dgc )
318
311
return - ENOMEM ;
319
- dgc -> irqs_per_chip = irqs_per_chip ;
312
+ dgc -> irqs_per_chip = info -> irqs_per_chip ;
320
313
dgc -> num_chips = numchips ;
321
- dgc -> irq_flags_to_set = set ;
322
- dgc -> irq_flags_to_clear = clr ;
323
- dgc -> gc_flags = gcflags ;
314
+ dgc -> irq_flags_to_set = info -> irq_flags_to_set ;
315
+ dgc -> irq_flags_to_clear = info -> irq_flags_to_clear ;
316
+ dgc -> gc_flags = info -> gc_flags ;
324
317
d -> gc = dgc ;
325
318
326
319
/* Calc pointer to the first generic chip */
327
320
tmp += dgc_sz ;
328
321
for (i = 0 ; i < numchips ; i ++ ) {
329
322
/* Store the pointer to the generic chip */
330
323
dgc -> gc [i ] = gc = tmp ;
331
- irq_init_generic_chip (gc , name , num_ct , i * irqs_per_chip ,
332
- NULL , handler );
324
+ irq_init_generic_chip (gc , info -> name , info -> num_ct ,
325
+ i * dgc -> irqs_per_chip , NULL ,
326
+ info -> handler );
333
327
334
328
gc -> domain = d ;
335
- if (gcflags & IRQ_GC_BE_IO ) {
329
+ if (dgc -> gc_flags & IRQ_GC_BE_IO ) {
336
330
gc -> reg_readl = & irq_readl_be ;
337
331
gc -> reg_writel = & irq_writel_be ;
338
332
}
@@ -345,6 +339,57 @@ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
345
339
}
346
340
return 0 ;
347
341
}
342
+ EXPORT_SYMBOL_GPL (irq_domain_alloc_generic_chips );
343
+
344
+ /**
345
+ * irq_domain_remove_generic_chips - Remove generic chips from an irq domain
346
+ * @d: irq domain for which generic chips are to be removed
347
+ */
348
+ void irq_domain_remove_generic_chips (struct irq_domain * d )
349
+ {
350
+ struct irq_domain_chip_generic * dgc = d -> gc ;
351
+ unsigned int i ;
352
+
353
+ if (!dgc )
354
+ return ;
355
+
356
+ for (i = 0 ; i < dgc -> num_chips ; i ++ )
357
+ irq_remove_generic_chip (dgc -> gc [i ], ~0U , 0 , 0 );
358
+
359
+ d -> gc = NULL ;
360
+ kfree (dgc );
361
+ }
362
+ EXPORT_SYMBOL_GPL (irq_domain_remove_generic_chips );
363
+
364
+ /**
365
+ * __irq_alloc_domain_generic_chips - Allocate generic chips for an irq domain
366
+ * @d: irq domain for which to allocate chips
367
+ * @irqs_per_chip: Number of interrupts each chip handles (max 32)
368
+ * @num_ct: Number of irq_chip_type instances associated with this
369
+ * @name: Name of the irq chip
370
+ * @handler: Default flow handler associated with these chips
371
+ * @clr: IRQ_* bits to clear in the mapping function
372
+ * @set: IRQ_* bits to set in the mapping function
373
+ * @gcflags: Generic chip specific setup flags
374
+ */
375
+ int __irq_alloc_domain_generic_chips (struct irq_domain * d , int irqs_per_chip ,
376
+ int num_ct , const char * name ,
377
+ irq_flow_handler_t handler ,
378
+ unsigned int clr , unsigned int set ,
379
+ enum irq_gc_flags gcflags )
380
+ {
381
+ struct irq_domain_chip_generic_info info = {
382
+ .irqs_per_chip = irqs_per_chip ,
383
+ .num_ct = num_ct ,
384
+ .name = name ,
385
+ .handler = handler ,
386
+ .irq_flags_to_clear = clr ,
387
+ .irq_flags_to_set = set ,
388
+ .gc_flags = gcflags ,
389
+ };
390
+
391
+ return irq_domain_alloc_generic_chips (d , & info );
392
+ }
348
393
EXPORT_SYMBOL_GPL (__irq_alloc_domain_generic_chips );
349
394
350
395
static struct irq_chip_generic *
0 commit comments