Skip to content

Commit 002fca5

Browse files
AxelLinKAGA-KOKO
authored andcommitted
genirq: generic chip: Use DIV_ROUND_UP to calculate numchips
The number of interrupts in a domain may be not divisible by the number of interrupts each chip handles. Integer division may truncate the result, thus use DIV_ROUND_UP to count numchips. Seems all users of irq_alloc_domain_generic_chips() in current code do not have this issue. I just found the issue while reading the code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Cc: Grant Likely <grant.likely@linaro.org> Cc: Tony Lindgren <tony@atomide.com> Cc: Arnd Bergmann <arnd@arndb.de> Link: http://lkml.kernel.org/r/1373015592.18252.2.camel@phoenix Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 5b8aae4 commit 002fca5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/irq/generic-chip.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
278278
if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR)
279279
return -EINVAL;
280280

281-
numchips = d->revmap_data.linear.size / irqs_per_chip;
281+
numchips = DIV_ROUND_UP(d->revmap_data.linear.size, irqs_per_chip);
282282
if (!numchips)
283283
return -EINVAL;
284284

0 commit comments

Comments
 (0)