arch/xtensa/espressif: Add IRQ lookup by interrupt handle.

Add esp_get_irq() to retrieve the IRQ associated with an interrupt
handle.

This allows the ESP OS abstraction to recover the IRQ when freeing an
interrupt from its handle.

The corresponding change in esp-hal-3rdparty is required to use this
API when freeing interrupts.

Related: #20216

Signed-off-by: Ahmed Ashraf NourEldeen <a.programmer55559@gmail.com>
This commit is contained in:
Ahmed Ashraf NourEldeen 2026-09-22 07:38:39 +03:00 • committed by Xiang Xiao
parent 162369111e
commit af65d2e04a
2 changed files with 56 additions and 1 deletions

View file

@ -788,7 +788,13 @@ int esp_setup_irq_with_flags_intrstatus(int source,
* CPU information, so no additional mapping is needed.
*/
esp_set_handle(this_cpu(), irq, ret_handle);
ret = esp_set_handle(this_cpu(), irq, ret_handle);
if (ret < 0)
{
esp_intr_free(ret_handle);
kmm_free(isr_adapter_args);
return ret;
}
return cpuint;
}
@ -888,6 +894,37 @@ intr_handle_t esp_get_handle(int cpu, int irq)
return g_handle_map[cpu][irq];
}
/****************************************************************************
* Name: esp_get_irq
*
* Description:
* This function gets the IRQ associated with a handle
*
* Input Parameters:
* cpu - The CPU associated with the IRQ
* handle - The handle associated with a CPU interrupt
*
* Returned Value:
* The irq associated with the handle or negative value if no irq is
* associated with the handle.
*
****************************************************************************/
int esp_get_irq(int cpu, intr_handle_t handle)
{
int irq;
for (irq = 0; irq < NR_IRQS; irq++)
{
if (g_handle_map[cpu][irq] == handle)
{
return irq;
}
}
return -EINVAL;
}
/****************************************************************************
* Name: esp_clear_handle
*

View file

@ -231,6 +231,24 @@ int esp_set_handle(int cpu, int irq, intr_handle_t handle);
intr_handle_t esp_get_handle(int cpu, int irq);
/****************************************************************************
* Name: esp_get_irq
*
* Description:
* This function gets the IRQ associated with a handle
*
* Input Parameters:
* cpu - The CPU associated with the IRQ
* handle - The handle associated with a CPU interrupt
*
* Returned Value:
* The irq associated with the handle or negative value if no irq is
* associated with the handle.
*
****************************************************************************/
int esp_get_irq(int cpu, intr_handle_t handle);
/****************************************************************************
* Name: esp_cpuint_initialize
*