From patchwork Fri Jul 28 23:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 708540 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D39BC41513 for ; Fri, 28 Jul 2023 23:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233512AbjG1XcK (ORCPT ); Fri, 28 Jul 2023 19:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjG1XcI (ORCPT ); Fri, 28 Jul 2023 19:32:08 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648FA3C1D for ; Fri, 28 Jul 2023 16:32:04 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b9db1de50cso1839651fa.3 for ; Fri, 28 Jul 2023 16:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690587122; x=1691191922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tz1hKoDY38DT//BIw/FpyOAtOdxg6YreDjToq5km+Ks=; b=abUkMbCTmdB/Bya5vivhruYnFj+FqgrbDwvOXl3qZ9Z07it8CY8xUH0jhGpNJHwgWz Q1X+3c/wC+O4qd2U3Q5fjknnTs/M9g4mjvcDrqeIz7guXgwgsT1ch6aQplMXGwPjE8uX i/ANrXw8oNR04bn4fjJFE+EUyXMQazSisRDmX3oEe/uesrKYWiUSmzyldZGvCEvuEM9h +WC3zLsmH3S9aYrRb/d4Q3DkBPVE5vZjL5KKsTqv/0zoxnn10Nv1g8VZ9Xcyu3UUvdhW ZsQZzqJXFeVjeRRmneKkfBT8GxwtausRHmj92SdhnPmsuLUVLg3QOxgZRF/VlBxe51ar cm3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690587122; x=1691191922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tz1hKoDY38DT//BIw/FpyOAtOdxg6YreDjToq5km+Ks=; b=Mhf7lyiM4O99DJtlVObW2xoSOasrrmQmriBk8qFSeqX3tO9zP7zipmT8wobNy1Lx5g h91301KZUNhJHM7nocFTK8tCjjrZwgUtUjCtPZ16IbRa/Bum7vUP8X09/L6VAv+krtKN y4yAgpOJ+8JK5jzdwXcrNvBuc0aKbpzxyn3wLj+wygQWwQg3v+4m3azoZc5viiedTU5S ctKdTowDiP3QRhw794mowMDkpBHD9JZMjPU7bReHbexdqMLDeoRxFwcThi6kKFYgOtfP dT/8RLTS8Y2AFrGhp1npyU/njY/SCQEj37JqbpvzSrBN6MLSYleHEs8vtPHsIrm5tiHJ sgRA== X-Gm-Message-State: ABy/qLaIWbmTPl+HZ/XmJObLgCjQvHVBK1U1U3tqgmV4JahmQyD837y/ TEi+Tv206Sof1eeNrXMeEcFO6A== X-Google-Smtp-Source: APBJJlEF/t3tbnHJUjTfUgF9okNauvNaBleuclbixZhx2wu2SKBy6OFlfIUp7kHyanVp77Y4HDOGZg== X-Received: by 2002:a05:651c:115:b0:2b7:a64:6c3e with SMTP id a21-20020a05651c011500b002b70a646c3emr2651731ljb.26.1690587122796; Fri, 28 Jul 2023 16:32:02 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id x11-20020a2e9dcb000000b002b6c8cf48bfsm1148289ljj.104.2023.07.28.16.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 16:32:02 -0700 (PDT) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar , Marijn Suijten Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v3 2/6] drm/msm/dpu: extract dpu_core_irq_is_valid() helper Date: Sat, 29 Jul 2023 02:31:56 +0300 Message-Id: <20230728233200.151735-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230728233200.151735-1-dmitry.baryshkov@linaro.org> References: <20230728233200.151735-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In preparation to reworking the IRQ indices, move irq_idx validation to the separate helper. Signed-off-by: Dmitry Baryshkov --- .../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; }