From patchwork Thu Dec 16 16:22:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 524769 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 AADD2C433EF for ; Thu, 16 Dec 2021 16:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239536AbhLPQWP (ORCPT ); Thu, 16 Dec 2021 11:22:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239574AbhLPQWO (ORCPT ); Thu, 16 Dec 2021 11:22:14 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F838C061574 for ; Thu, 16 Dec 2021 08:22:14 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id k2so39287743lji.4 for ; Thu, 16 Dec 2021 08:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4lWtkWUkkW3ND3RjcGaqJdo8TrrjuOiBcKkAeDb9fTo=; b=X19CCWSHn+YUHSaTyIW1WkzS0qn/tl30Lmbqg5N7OydTWstDVDYHDH22bqmTE4S4Rk 5U0jsh8xNoewi0aeZ8t3LbOALo5ol45GHayFSqWcgvO1q1p2zXwHxD79ClnJPmlDPMgQ 0TJ/LQ3mKJTaWy/tNmXDdGCaQvRNE0rAYzxPav3wRBLSnUZh9s7/vvMp26kTog9mQql/ oexJaqt8KdTpN2iRmXEbWgA4ij/rjeDjSRYz/tRgvFYA60JLCiWfmrBGvfbfWdIZHNJ1 No6qAASzU1mJZZL2Pf90U0jWc1fI/1S/ohuiwXZG+boKRlTTZMBsniLW5n+Nz+1y1zi2 IVsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4lWtkWUkkW3ND3RjcGaqJdo8TrrjuOiBcKkAeDb9fTo=; b=o7MC5xzHT+2c6AeYRuAaBmwVvvbi2MGEUTASEiOTc36zy7bF728xKYUNjhplg9+7UL pt21oVgbpLs7HW2EYJRAxTvB9NCShbne6h07xf9a+xS2SibOgGKvRtDXAI6V0qIZwuma vFa2LADACT6QLdMc8v6L1AwI2+yc4gvV0qrywFmWxgy7GsVX8TxXfZQ9XT4rTmzWYV61 dcb5/z65UBiln9/+IYodDwqqJb64Z09pHVAqCwinYLxrFhzsTghuxgw4RECMzzmJgmI4 8RgBS6bY+YOzqQc8hHPdjyq3ZnkCbFrCpYRc0IjJp/wk2nr/Zx5H4QVmoc6NGsqvGISX QrCQ== X-Gm-Message-State: AOAM530I6jSUruUyNCYdoFfv0Pi12rZlqMlZlFGiUm1aQD4SIJIfWFuu UTWa86p7HSEIYhWoBcNWZwMXB5CIr+4= X-Google-Smtp-Source: ABdhPJw7w293M7f00o/g7bhxbJz0jq9qzwJ29MYFqBPAHxUkJMWnG8RqduvBa2CVLAnpR9T+cSbrfQ== X-Received: by 2002:a2e:8502:: with SMTP id j2mr16129822lji.191.1639671732555; Thu, 16 Dec 2021 08:22:12 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm938623lfg.126.2021.12.16.08.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:22:12 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Linus Walleij Cc: Dong Aisheng , Fabio Estevam , Shawn Guo , Stefan Agner , Pengutronix Kernel Team , Sascha Hauer , NXP Linux Team , Lakshmi Sowjanya D , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 1/4] pinctrl: imx: prepare for making "group_names" in "function_desc" const Date: Thu, 16 Dec 2021 17:22:03 +0100 Message-Id: <20211216162206.8027-1-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Rafał Miłecki The plan for "struct function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data. This imx change is required to avoid: drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinctrl_parse_functions': drivers/pinctrl/freescale/pinctrl-imx.c:672:24: error: assignment of read-only location '*(func->group_names + (sizetype)(i * 4))' 672 | func->group_names[i] = child->name; | ^ Signed-off-by: Rafał Miłecki --- drivers/pinctrl/freescale/pinctrl-imx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index daf28bc5661d..47b2ab1a14d0 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -648,6 +648,7 @@ static int imx_pinctrl_parse_functions(struct device_node *np, struct device_node *child; struct function_desc *func; struct group_desc *grp; + const char **group_names; u32 i = 0; dev_dbg(pctl->dev, "parse function(%d): %pOFn\n", index, np); @@ -663,14 +664,16 @@ static int imx_pinctrl_parse_functions(struct device_node *np, dev_err(ipctl->dev, "no groups defined in %pOF\n", np); return -EINVAL; } - func->group_names = devm_kcalloc(ipctl->dev, func->num_group_names, - sizeof(char *), GFP_KERNEL); + + group_names = devm_kcalloc(ipctl->dev, func->num_group_names, + sizeof(char *), GFP_KERNEL); if (!func->group_names) return -ENOMEM; + for_each_child_of_node(np, child) + group_names[i] = child->name; + func->group_names = group_names; for_each_child_of_node(np, child) { - func->group_names[i] = child->name; - grp = devm_kzalloc(ipctl->dev, sizeof(struct group_desc), GFP_KERNEL); if (!grp) { From patchwork Thu Dec 16 16:22:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 525297 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 2E7C7C433EF for ; Thu, 16 Dec 2021 16:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233360AbhLPQWR (ORCPT ); Thu, 16 Dec 2021 11:22:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239495AbhLPQWQ (ORCPT ); Thu, 16 Dec 2021 11:22:16 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACA3C061574 for ; Thu, 16 Dec 2021 08:22:16 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id bt1so8043750lfb.13 for ; Thu, 16 Dec 2021 08:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eh4pCHYG63YtXHQZCJTnWwo2iBYp9kjwNNdMHaucw5Q=; b=fPLe2/u42DDLMx0iB16nZYh9AfEYpFp4s0rh8zfujdC2CePA9JZTqXTRWa04yVyTxW HscHKgsLTAHi8xckF3aDAKxM4dEOFzP6cDlrhDF9cZpoq8jBCIpy5dWwQCrn7TI4XRog 7E7+914InnilU9q5yc/iYZApYbFTd8iCdymmJrawOAgbNulgzEtKL3ufm4Gz2rlCnQ7z zImCdFy9uRPTxnUxN2zp8wLBHIL/sSK0GLHcusj5qkD1XECIg7ceApYU6/Uceo7PvW7Z TbUy0lzy/PT5Zx+dRPgw2PmECGCabB1UTyE2po+MQag46KmtjpfZEl5xzPqPSj6aOQcW vPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eh4pCHYG63YtXHQZCJTnWwo2iBYp9kjwNNdMHaucw5Q=; b=O3xUryt8d98zbivTc0YwtrO32Qs4EU7vBpnpboAfPObiTgI9mP1mqORgJvKznggpfd DU/1CP1aUta18lBQiL41TICbvQ5pTglUb/ec5scHDPuX7lSht/c/R+Yonk0OROXRWCyS GwIZbMDNwdHdqyN08WpAu2JYctw+FzXklgrTLQrbwUoV1nznV4IMsxF25VmWqL+KQUno +PhMYYsTIK0Ozf293W3t9aEpyDSikH51q9SOp3dnzlGCCsnfHcqF+xiqzu62LcGk37bb PzF7ba4JMAeGI8vhbiycrsUBKZ0uhDVjEh7gXKZXUDyrwxrkgimNvfQKeLEBk6Bhl+RU U8Eg== X-Gm-Message-State: AOAM531IDq1g6zh3xe+PzSICFkMoljS61hG3oSNevYhhjTM6accDNw29 Kjn0kh0AtjmDfIJS5Rs3ULg= X-Google-Smtp-Source: ABdhPJxMjbzMoRUBrzIg94c1Lw32sycpZUKjsGYCnfQFZX3Qb970kRzwEpOc8A2H2v43VveauqE8LQ== X-Received: by 2002:a05:6512:3a91:: with SMTP id q17mr14672499lfu.425.1639671734417; Thu, 16 Dec 2021 08:22:14 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm938623lfg.126.2021.12.16.08.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:22:14 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Linus Walleij Cc: Dong Aisheng , Fabio Estevam , Shawn Guo , Stefan Agner , Pengutronix Kernel Team , Sascha Hauer , NXP Linux Team , Lakshmi Sowjanya D , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 2/4] pinctrl: keembay: comment process of building functions a bit Date: Thu, 16 Dec 2021 17:22:04 +0100 Message-Id: <20211216162206.8027-2-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211216162206.8027-1-zajec5@gmail.com> References: <20211216162206.8027-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Rafał Miłecki This should make code a bit easier to follow. While at it use some "for" loops to simplify array iteration loops. Signed-off-by: Rafał Miłecki --- drivers/pinctrl/pinctrl-keembay.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c index 2bce563d5b8b..9a602abad8df 100644 --- a/drivers/pinctrl/pinctrl-keembay.c +++ b/drivers/pinctrl/pinctrl-keembay.c @@ -1617,37 +1617,38 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc) struct function_desc *keembay_funcs, *new_funcs; int i; - /* Allocate total number of functions */ + /* + * Allocate maximum possible number of functions. Assume every pin + * being part of 8 (hw maximum) globally unique muxes. + */ kpc->nfuncs = 0; keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL); if (!keembay_funcs) return -ENOMEM; - /* Find total number of functions and each's properties */ + /* Setup 1 function for each unique mux */ for (i = 0; i < kpc->npins; i++) { const struct pinctrl_pin_desc *pdesc = keembay_pins + i; - struct keembay_mux_desc *mux = pdesc->drv_data; + struct keembay_mux_desc *mux; - while (mux->name) { - struct function_desc *fdesc = keembay_funcs; + for (mux = pdesc->drv_data; mux->name; mux++) { + struct function_desc *fdesc; - while (fdesc->name) { + /* Check if we already have function for this mux */ + for (fdesc = keembay_funcs; fdesc->name; fdesc++) { if (!strcmp(mux->name, fdesc->name)) { fdesc->num_group_names++; break; } - - fdesc++; } + /* Setup new function for this mux we didn't see before */ if (!fdesc->name) { fdesc->name = mux->name; fdesc->num_group_names = 1; fdesc->data = &mux->mode; kpc->nfuncs++; } - - mux++; } } From patchwork Thu Dec 16 16:22:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 524768 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 D021BC433F5 for ; Thu, 16 Dec 2021 16:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239495AbhLPQWY (ORCPT ); Thu, 16 Dec 2021 11:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239566AbhLPQWS (ORCPT ); Thu, 16 Dec 2021 11:22:18 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 873ABC061401 for ; Thu, 16 Dec 2021 08:22:17 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 207so39278164ljf.10 for ; Thu, 16 Dec 2021 08:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lUnqODC8l6jXMRXSjWHaW3K51f2Zp3o4i2EaGR4+YbQ=; b=lvXiAF1d3Vs6sdW3IGqJJAUJXmkC98UgqlCJXdWz4XRv6C+B2cDS1Bf41kUY0g2Zkz xYZiJ+HHUlS4YHH4irezA1s/Xn+KoDL/90rVDnGDTT2oHgjhwqlmlSy6cNxnvxCmw9lO vFJlw0d5k4Oj5l64lX3jLconjiLdN2tEcyHmnUuH3Rcqdow/Rm841YmWY7Awofrw+RIh 1kZHNv+RMH2gYu8zKPOiMijlsd6RYSAv4g5ocOwpMStnlo/T3wEOXp6aOx6/tcbtfJNO V3Zh0jJQkwhculKk8tpYf4EqFP6MnmJRJ2Cn9v97qeNzMfDNimWbJ1u8zbKQJ92rtnrs YTUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lUnqODC8l6jXMRXSjWHaW3K51f2Zp3o4i2EaGR4+YbQ=; b=D3bOGZ9VBtvKFqkCkvFrqUDTNZxQ65OuXhyLU6+YJV1VPyFGr1W4/S5TQcixidUisx cl26raVXj0lNMEU8Zm37+6BCp26BPFdy954s3klAMj1pUgVCn2LIfony/cZMznTO5oOW plcib0YkT7HuXi/sM7RTss8FYXxhLS1PlQZ1t2dmvxk/D9cPDaQ2zbe7iOaImblefLZe /yuj1ihxvuy//Bbg0t0pEFr5aYb1tR+SJiV9WAtKJ0RUr7tkqF9CH3wQkjYB43ZjtWmw qqkTf0ruE/01sHKQOaUZN1gkw9WOxaE+Uf28Ewdudjd4UEFjDJfb/U7WHrPiXl0KhPdM genA== X-Gm-Message-State: AOAM533igyuI7CVuJ+lWLJ0Pc47jO+9wOz025x9xHM+IR5F+/bc7rlaF YaW/z1AgAGWNPdVHQV0JXvw= X-Google-Smtp-Source: ABdhPJwCahoizSn2WH15Q57HOXkXWNpk/FmVvJXcE9B0YnDgR8bHY5REokQAOeCUiLKOMPZGnP+GsA== X-Received: by 2002:a2e:5d6:: with SMTP id 205mr15153216ljf.270.1639671735855; Thu, 16 Dec 2021 08:22:15 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm938623lfg.126.2021.12.16.08.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:22:15 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Linus Walleij Cc: Dong Aisheng , Fabio Estevam , Shawn Guo , Stefan Agner , Pengutronix Kernel Team , Sascha Hauer , NXP Linux Team , Lakshmi Sowjanya D , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 3/4] pinctrl: keembay: rework loops looking for groups names Date: Thu, 16 Dec 2021 17:22:05 +0100 Message-Id: <20211216162206.8027-3-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211216162206.8027-1-zajec5@gmail.com> References: <20211216162206.8027-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Rafał Miłecki Make the outer loop iterate over functions as that's the real subject. This simplifies code (and reduces amount of lines of code) as allocating memory for names doesn't require extra checks anymore. While at it use local "group_names" variable. The plan for "struct function_desc" is to make its "group_names" /double/ const. That will allow drivers to use it with static const data. This keembay "group_names" change is required to avoid: drivers/pinctrl/pinctrl-keembay.c: In function 'keembay_add_functions': drivers/pinctrl/pinctrl-keembay.c:1594:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 1594 | grp = func->group_names; | ^ Signed-off-by: Rafał Miłecki --- This has been runtime tested. I verified that output of /sys/kernel/debug/pinctrl/*/pinmux-functions is the same without and with my patches. --- drivers/pinctrl/pinctrl-keembay.c | 66 ++++++++++++------------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c index 9a602abad8df..152c35bce8ec 100644 --- a/drivers/pinctrl/pinctrl-keembay.c +++ b/drivers/pinctrl/pinctrl-keembay.c @@ -1555,58 +1555,42 @@ static int keembay_pinctrl_reg(struct keembay_pinctrl *kpc, struct device *dev) } static int keembay_add_functions(struct keembay_pinctrl *kpc, - struct function_desc *function) + struct function_desc *functions) { unsigned int i; /* Assign the groups for each function */ - for (i = 0; i < kpc->npins; i++) { - const struct pinctrl_pin_desc *pdesc = keembay_pins + i; - struct keembay_mux_desc *mux = pdesc->drv_data; - - while (mux->name) { - struct function_desc *func; - const char **grp; - size_t grp_size; - u32 j, grp_num; - - for (j = 0; j < kpc->nfuncs; j++) { - if (!strcmp(mux->name, function[j].name)) - break; - } - - if (j == kpc->nfuncs) - return -EINVAL; - - func = function + j; - grp_num = func->num_group_names; - grp_size = sizeof(*func->group_names); - - if (!func->group_names) { - func->group_names = devm_kcalloc(kpc->dev, - grp_num, - grp_size, - GFP_KERNEL); - if (!func->group_names) - return -ENOMEM; + for (i = 0; i < kpc->nfuncs; i++) { + struct function_desc *func = &functions[i]; + const char **group_names; + unsigned int grp_idx = 0; + int j; + + group_names = devm_kcalloc(kpc->dev, func->num_group_names, + sizeof(*group_names), GFP_KERNEL); + if (!group_names) + return -ENOMEM; + + for (j = 0; j < kpc->npins; j++) { + const struct pinctrl_pin_desc *pdesc = &keembay_pins[j]; + struct keembay_mux_desc *mux; + + for (mux = pdesc->drv_data; mux->name; mux++) { + if (!strcmp(mux->name, func->name)) + group_names[grp_idx++] = pdesc->name; } - - grp = func->group_names; - while (*grp) - grp++; - - *grp = pdesc->name; - mux++; } + + func->group_names = group_names; } /* Add all functions */ for (i = 0; i < kpc->nfuncs; i++) { pinmux_generic_add_function(kpc->pctrl, - function[i].name, - function[i].group_names, - function[i].num_group_names, - function[i].data); + functions[i].name, + functions[i].group_names, + functions[i].num_group_names, + functions[i].data); } return 0; From patchwork Thu Dec 16 16:22:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 525296 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 6DCC6C433FE for ; Thu, 16 Dec 2021 16:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239542AbhLPQWZ (ORCPT ); Thu, 16 Dec 2021 11:22:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239599AbhLPQWW (ORCPT ); Thu, 16 Dec 2021 11:22:22 -0500 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 67038C061748 for ; Thu, 16 Dec 2021 08:22:19 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id 207so39278266ljf.10 for ; Thu, 16 Dec 2021 08:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JUJgiOCeEkvWRBfsS4oHMEMSHGIv4GiMwDTH+LmBGxo=; b=IoU2buhjcjWp2q7dTYztQ+qpX9khq7w3X58Xw/LgcxE4PGjKWNNhJYajACUrAVTjAV 0pAehz9KDe0vabDtPwrPpT5+5cx+ekArogFvQRRudrAEWggcwLdZ9jDNqkfX2O7EeYVj VXLvZmB/auujRtxBKEHPiF6EEMSOYd/nEJJMPgB6kgGx2Q+TTohdHLGqTj/EK8/ACs5B qqm/a36vKUR5A3lsXy1FMwKyEZ0YhoCgw3aiidLX52s9PVy2Uy8rleHC+KwfQqeTYfc2 30yXUfz4MzD+gAr1XW3ghh9tEAPdLXsn7sJR5hhgn4lJYW4+eeg5AWWBs+W9MPVFrBT1 mCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JUJgiOCeEkvWRBfsS4oHMEMSHGIv4GiMwDTH+LmBGxo=; b=QbxmYIaFC25ikzVjOR6z0ubf2K6oEXBP772FjbPHUfpDzNKDfhvEceWxF/sS31h42y c27jUEyuwM48Qhbrsy3phvME1EJRf9EytWRHqTgphmoBPVQbtsktV/TbmE4u+3Px9el5 gVwMGssdGoRfrtFv982XiHeRJ7e+QQvqZluBg/h4IjnfnZi7NlgdIoxeA3Xgk5xW6Iah AUvvQ/n7sA3vMTpKxzPqt1VajNqsJee6lwkxDo7zPdcNzPnGQFrUE6d9l3GsIbHzGCjW EHZyICe70S+yhKTakuWYgtfst2j8K7F8guW6p0SpJy4gQv+3xDLW7j7PUqpnyjWas/xF EiAg== X-Gm-Message-State: AOAM533zV4zsWVAZq/by/XEdZ5Wd0YN6J8bUnWNYh+656tbdEHd5iGCJ QxKDfFn4G49kEk770NooAOc= X-Google-Smtp-Source: ABdhPJyrGXI7ioAaKnKKAK2OC5i6FS7Rxk9DNehos53wIcXBnCY1INj+5OTISTqtn/SLfMS9qHQipg== X-Received: by 2002:a2e:bd0e:: with SMTP id n14mr15323654ljq.159.1639671737725; Thu, 16 Dec 2021 08:22:17 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm938623lfg.126.2021.12.16.08.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:22:17 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Linus Walleij Cc: Dong Aisheng , Fabio Estevam , Shawn Guo , Stefan Agner , Pengutronix Kernel Team , Sascha Hauer , NXP Linux Team , Lakshmi Sowjanya D , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 4/4] pinctrl: add one more "const" for generic function groups Date: Thu, 16 Dec 2021 17:22:06 +0100 Message-Id: <20211216162206.8027-4-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211216162206.8027-1-zajec5@gmail.com> References: <20211216162206.8027-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Rafał Miłecki Generic code doesn't modify those strings and .get_function_groups callback has that extra "const" as well. This allows more flexibility in GENERIC_PINMUX_FUNCTIONS users. Signed-off-by: Rafał Miłecki --- drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/pinmux.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 6cdbd9ccf2f0..f94d43b082d9 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -875,7 +875,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function); */ int pinmux_generic_add_function(struct pinctrl_dev *pctldev, const char *name, - const char **groups, + const char * const *groups, const unsigned int num_groups, void *data) { diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h index 78c3a31be882..72fcf03eaa43 100644 --- a/drivers/pinctrl/pinmux.h +++ b/drivers/pinctrl/pinmux.h @@ -129,7 +129,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot, */ struct function_desc { const char *name; - const char **group_names; + const char * const *group_names; int num_group_names; void *data; }; @@ -150,7 +150,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev, int pinmux_generic_add_function(struct pinctrl_dev *pctldev, const char *name, - const char **groups, + const char * const *groups, unsigned const num_groups, void *data);