[PATCH v3 2/6] drm/msm/dpu: extract dpu_core_irq_is_valid() helper

Marijn Suijten marijn.suijten at somainline.org
Sat Jul 29 18:43:54 UTC 2023


On 2023-07-29 02:31:56, Dmitry Baryshkov wrote:
> In preparation to reworking the IRQ indices, move irq_idx validation to
> the separate helper.

Nit: "the" sounds as if "separate helper" is a thing that already
exists, where you just moved it to.  Instead, you created a new helper
that now contains the validation that was open-coded before.

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>

For the contents though:

Reviewed-by: Marijn Suijten <marijn.suijten at somainline.org>

> ---
>  .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 22 +++++++++----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c
> index 01a9ccfcd54b..81d03b6c67d1 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c
> @@ -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;
>  	}
> -- 
> 2.39.2
> 


More information about the dri-devel mailing list