lib: sbi_irqchip: Associate 32-bit unique ID for each irqchip device

Allow locating irqchip device instance using a unique 32-bit ID. This
32-bit unique ID can be set by the irqchip driver at the time of adding
irqchip device.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260213055342.3124872-8-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Anup Patel
2026-02-13 11:23:41 +05:30
committed by Anup Patel
parent e82d20122d
commit e8ebd1fbc6
5 changed files with 24 additions and 0 deletions

View File

@@ -30,6 +30,18 @@ int sbi_irqchip_process(void)
return hd->chip->process_hwirqs(hd->chip);
}
struct sbi_irqchip_device *sbi_irqchip_find_device(u32 id)
{
struct sbi_irqchip_device *chip;
sbi_list_for_each_entry(chip, &irqchip_list, node) {
if (chip->id == id)
return chip;
}
return NULL;
}
int sbi_irqchip_add_device(struct sbi_irqchip_device *chip)
{
struct sbi_irqchip_hart_data *hd;
@@ -39,6 +51,9 @@ int sbi_irqchip_add_device(struct sbi_irqchip_device *chip)
if (!chip || !sbi_hartmask_weight(&chip->target_harts))
return SBI_EINVAL;
if (sbi_irqchip_find_device(chip->id))
return SBI_EALREADY;
if (chip->process_hwirqs) {
sbi_hartmask_for_each_hartindex(h, &chip->target_harts) {
scratch = sbi_hartindex_to_scratch(h);