Commit a6526483 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov

drm/msm/dpu: extract dpu_core_irq_is_valid() helper

In preparation to reworking IRQ indices, move irq_idx validation to
a separate helper.
Reviewed-by: default avatarMarijn Suijten <marijn.suijten@somainline.org>
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/550929/
Link: https://lore.kernel.org/r/20230802100426.4184892-4-dmitry.baryshkov@linaro.org
parent e75e45c2
......@@ -200,6 +200,12 @@ static const struct dpu_intr_reg dpu_intr_set_7xxx[] = {
#define DPU_IRQ_REG(irq_idx) (irq_idx / 32)
#define DPU_IRQ_MASK(irq_idx) (BIT(irq_idx % 32))
static inline bool dpu_core_irq_is_valid(struct dpu_hw_intr *intr,
int irq_idx)
{
return irq_idx >= 0 && irq_idx < intr->total_irqs;
}
/**
* dpu_core_irq_callback_handler - dispatch core interrupts
* @dpu_kms: Pointer to DPU's KMS structure
......@@ -291,7 +297,7 @@ static int dpu_hw_intr_enable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)
if (!intr)
return -EINVAL;
if (irq_idx < 0 || irq_idx >= intr->total_irqs) {
if (!dpu_core_irq_is_valid(intr, irq_idx)) {
pr_err("invalid IRQ index: [%d]\n", irq_idx);
return -EINVAL;
}
......@@ -344,7 +350,7 @@ static int dpu_hw_intr_disable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)
if (!intr)
return -EINVAL;
if (irq_idx < 0 || irq_idx >= intr->total_irqs) {
if (!dpu_core_irq_is_valid(intr, irq_idx)) {
pr_err("invalid IRQ index: [%d]\n", irq_idx);
return -EINVAL;
}
......@@ -429,13 +435,7 @@ u32 dpu_core_irq_read(struct dpu_kms *dpu_kms, int irq_idx)
if (!intr)
return 0;
if (irq_idx < 0) {
DPU_ERROR("[%pS] invalid irq_idx=%d\n",
__builtin_return_address(0), irq_idx);
return 0;
}
if (irq_idx < 0 || irq_idx >= intr->total_irqs) {
if (!dpu_core_irq_is_valid(intr, irq_idx)) {
pr_err("invalid IRQ index: [%d]\n", irq_idx);
return 0;
}
......@@ -518,7 +518,7 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,
return -EINVAL;
}
if (irq_idx < 0 || irq_idx >= dpu_kms->hw_intr->total_irqs) {
if (!dpu_core_irq_is_valid(dpu_kms->hw_intr, irq_idx)) {
DPU_ERROR("invalid IRQ index: [%d]\n", irq_idx);
return -EINVAL;
}
......@@ -555,7 +555,7 @@ int dpu_core_irq_unregister_callback(struct dpu_kms *dpu_kms, int irq_idx)
unsigned long irq_flags;
int ret;
if (irq_idx < 0 || irq_idx >= dpu_kms->hw_intr->total_irqs) {
if (!dpu_core_irq_is_valid(dpu_kms->hw_intr, irq_idx)) {
DPU_ERROR("invalid IRQ index: [%d]\n", irq_idx);
return -EINVAL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment