From patchwork Mon Jan 2 22:18:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13087027 X-Patchwork-Delegate: geert@linux-m68k.org 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 519B1C5479D for ; Mon, 2 Jan 2023 22:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232182AbjABWSd (ORCPT ); Mon, 2 Jan 2023 17:18:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbjABWSc (ORCPT ); Mon, 2 Jan 2023 17:18:32 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C150E95AB; Mon, 2 Jan 2023 14:18:30 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id bk16so14354033wrb.11; Mon, 02 Jan 2023 14:18:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=kCEtTHiR9P25/MahGBhdYLRuSe7FIhD6edeJkbM8vCk=; b=YqEIRGFcf2s2llJhfFfahgwrHH1990lEdX6TaPnFol9D6H9zwGWYQddAG+TS9/BHib 0DjJ4rwCQrLjoii0jED2rK+ova8L/Ufo95wgZnrDUcflZP5hmeuwCDpjDaEjYKoAiRLE PdG950kADq1yZZTTQg8iSgJJg1cQTjcsD93KkG0a6Scx/uZqzCSjV/RNoAX/Br0suVoF FIpiak6U9cHL97ky14eBH/igEzwyt3JXKHJBFrZEvWYMNvFTciQu8w3QHHTUK81a0SRF KFT2zPH44t8ZzGIU4ZssUcVj4YEiiEoMqwTetROfD0xb2zUr8wx5JQUsEf44ktv88DPE 0+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kCEtTHiR9P25/MahGBhdYLRuSe7FIhD6edeJkbM8vCk=; b=VdDs8uTz6FXdjIykTMoQdCpeTHtLaUg4ENycmbNDXn/LjuIVb11is8FY5abgzc1u+a t6AcVZzmJMpe31tmiSeO/kPsHStEzy2li4VneargCt5TivLazQffdLShDa+5O9LCgozy FA1cVhO8iq8XwzkSdWBCLFchTfDVpiINhgBn1fYm7gRO8GbAVYLokK377+/M27cwAtWX VFpPMkpVqwiJ5KrLA32zRn7/UeApNziBkyyJ+RXVZ2Mk/F3xjb8hCgnbbUH+ty5nZx7O lrjD6uHzCEjvInBSS2U+bkQaUi02QWaYveubcC9721yHlS9E9quhXEeG1Qc1edIJr0v0 m4Ig== X-Gm-Message-State: AFqh2kp1zqqlMF2GS4xVX8n5mqQvzKZiq6CPve0aT5ZWLhBP6jaflmbW x6CCvwfQ/slCBtIYkNVfAT4= X-Google-Smtp-Source: AMrXdXt/pm8wOQbm2+iT2ucpjvtK4gdYjTXztTckgkxYOwBwdRAngIa+Xe9M09uZ66YKs2k614PXVg== X-Received: by 2002:a5d:6e08:0:b0:236:84b5:6658 with SMTP id h8-20020a5d6e08000000b0023684b56658mr26519706wrz.64.1672697908889; Mon, 02 Jan 2023 14:18:28 -0800 (PST) Received: from prasmi.home ([2a00:23c8:2501:c701:8a7:e535:b020:566a]) by smtp.gmail.com with ESMTPSA id n14-20020adfe34e000000b002366dd0e030sm29872463wrj.68.2023.01.02.14.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 14:18:28 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Magnus Damm , Linus Walleij Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v3 3/6] pinctrl: renesas: rzg2l: Add BUILD_BUG_ON() checks Date: Mon, 2 Jan 2023 22:18:12 +0000 Message-Id: <20230102221815.273719-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230102221815.273719-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20230102221815.273719-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org From: Lad Prabhakar Add BUILD_BUG_ON() checks to avoid overflows for GPIO configs for each supported SoC. While at it, for readability set n_port_pins based on the GPIO pin configs and not on GPIO names for r9a07g044_data as done for r9a07g043_data. Suggested-by: Geert Uytterhoeven Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- v2 -> v3 * No change v1 -> v2 * New patch --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 6f762097557a..04b31f0c6b34 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -1468,6 +1468,12 @@ static int rzg2l_pinctrl_probe(struct platform_device *pdev) struct rzg2l_pinctrl *pctrl; int ret; + BUILD_BUG_ON(ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT > + ARRAY_SIZE(rzg2l_gpio_names)); + + BUILD_BUG_ON(ARRAY_SIZE(r9a07g043_gpio_configs) * RZG2L_PINS_PER_PORT > + ARRAY_SIZE(rzg2l_gpio_names)); + pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); if (!pctrl) return -ENOMEM; @@ -1531,7 +1537,7 @@ static struct rzg2l_pinctrl_data r9a07g044_data = { .port_pin_configs = rzg2l_gpio_configs, .n_ports = ARRAY_SIZE(rzg2l_gpio_configs), .dedicated_pins = rzg2l_dedicated_pins.common, - .n_port_pins = ARRAY_SIZE(rzg2l_gpio_names), + .n_port_pins = ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT, .n_dedicated_pins = ARRAY_SIZE(rzg2l_dedicated_pins.common) + ARRAY_SIZE(rzg2l_dedicated_pins.rzg2l_pins), };