lib: irqchip/plic: Factor out a context init function
authorSamuel Holland <samuel@sholland.org>
Mon, 13 Jun 2022 01:03:50 +0000 (20:03 -0500)
committerAnup Patel <anup@brainfault.org>
Mon, 13 Jun 2022 06:24:06 +0000 (11:54 +0530)
commit8c362e7d065eaf4d55da23a190a464ba870f89aa
tree0e329ebde4ba12c1119e7dfc299d63bcf33b0588
parent2ea7799d563ed9bbaf3b677728e928a6cd8f580c
lib: irqchip/plic: Factor out a context init function

This simplifies both the callers and the callees by removing duplicated
code and consolidating the error handling. It also fixes two bugs in the
process:
  1) ie_words was one too large when plic->num_src was a multiple of 32.
  2) plic_set_ie takes a 32-bit mask, not a Boolean value, so the FPGA
     platforms previously only enabled one out of every 32 interrupts.

Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
include/sbi_utils/irqchip/plic.h
lib/utils/irqchip/plic.c
platform/fpga/ariane/platform.c
platform/fpga/openpiton/platform.c