Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp199331lqb; Tue, 28 May 2024 12:50:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWogqVJUNesF0a/LxgK6TM8YwWsK47ZUijPmjoKxt5Ab9yJBmmtwuXpcckwyh1rbAAm/+p+Pkn0Mv54ILmEJOlrfNGepR3zNZ2zIhLdDA== X-Google-Smtp-Source: AGHT+IFtzJn+sqBmOsX7demFlY9lk3BjuU5wN/yQJwxgXeyMkFLysFtE4RZ5ti5N0Dt308rB1kzE X-Received: by 2002:a05:6214:3907:b0:6ab:8e06:f5e5 with SMTP id 6a1803df08f44-6abcd19dcc7mr144922676d6.43.1716925822610; Tue, 28 May 2024 12:50:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716925822; cv=pass; d=google.com; s=arc-20160816; b=kCwvr0Y8Gy6TzUS7bU5VmKHyjOhEEn79irufwPjQubI9Za7HPFuJiW5F2Er6bylpp3 1mWN4aZGSCi+0LqHr/TP+qpgYwo6vB5sxu61FYL1sNJGzrwXGvZ3mBxLtgn43myEwZZv apyJX2nVqL7NMZzKhKCSP9YI5/k3jQHYskbukdNp8+CTyXm+toDm9kmr4/8mf2k4cDps JweLthHqG3juy4LWTKYCbtbc4z4b/OYkAMh1Lh6buq84NzOQ3rSSn4S48EI3LAyShhwf 40ZcZiSo5K3ckVknR/mQVZKBwbNidsqpM/zAqpmetLN0fIVez2guHsxKYl9nCPPUwkfV 4yKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ZJVLD03TSbh0EX+KgNnmIHIuhindXa+wgSQyJxdLtmU=; fh=7i0PP+tNNxhEqCNt1DaWuCxUYRb0M4WDBE9BrWIvsBQ=; b=DZw6rbro2yqOWyg+42iLGw1SE93nRwQbJJPoe+6Eo3/mLwik5GjVef3zC8EZg+WCAC BFWa2xuqaXfZgkb9v15osjwtXETZJZrSXb/UTp92dzCbCzKROcMwGGbv9XPRwN6PYN+6 FL5SM+R+rC7Uerhr5C0tRnp8f8y3WtXE6lPgF0e2TFuFL4rG+yl5RWbFfFozkJYg6uZn vYnnqhjFx/rnFV0w6Exa44iUhV/GuKl2QnNoPoar+bDWF5Rn199NPcoJmQDuqOnPj13g gR/PqZL+xC8rGtBjMvwAPj5tH6dutMt3xrPMk6yrXT0ykd8AIz5kQo/87WJLcobN4ju7 8gEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-192976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ad759d396dsi79514836d6.143.2024.05.28.12.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 12:50:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-192976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 59E871C269E9 for ; Tue, 28 May 2024 19:50:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C06DB178CEC; Tue, 28 May 2024 19:50:01 +0000 (UTC) Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99F0B17838B for ; Tue, 28 May 2024 19:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925801; cv=none; b=eXoRLMIUYolYsMFVddAT5Vr7SrBXY0/ducgvpLph6Ga6g90VXmH6yqIvjvIPJnCPLD6Or6aYWOPmBp7DwrldNw3LaBTFcmLath8JAI6ctsOrgbdl2mU+tgIDaPdG4qIdDoK+0+54bMZyhc0fC/oIRRZCPF9fGSIN4s7ddS983t0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716925801; c=relaxed/simple; bh=UUNlZAPD7ufWrtpQqrGWyMeB5Qmh9EtgLPVDRPhTSwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oyCvU5H+rbiJVwM8nd6CNekGYNjA2vaMDcXikUlfWmm65djT1pnAFQBpdMLOLfH54bBoKTKmCnYSl4R/thh7/rD9tGcKiDxYBX/bzgUn47THZnor3lUiKoOTPPw8ffrT0fRXkMWhYCBK4Gw/dMcCrH5dxUpV+fyGU+nxCR9nYz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-26-230.elisa-laajakaista.fi [88.113.26.230]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 76055e70-1d2b-11ef-8d3a-005056bd6ce9; Tue, 28 May 2024 22:49:57 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Daniel Golle , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-mips@vger.kernel.org Cc: Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Sascha Hauer , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Paul Cercueil , Lakshmi Sowjanya D , Andy Shevchenko Subject: [PATCH v2 02/11] pinctrl: equilibrium: Make use of struct pinfunction Date: Tue, 28 May 2024 22:44:53 +0300 Message-ID: <20240528194951.1489887-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240528194951.1489887-1-andy.shevchenko@gmail.com> References: <20240528194951.1489887-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andy Shevchenko Since pin control provides a generic data type for the pin function, use it in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-equilibrium.c | 24 +++++++++++++----------- drivers/pinctrl/pinctrl-equilibrium.h | 12 ------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index 6e1be38865c3..a6d089eaaae5 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -566,8 +566,8 @@ static const struct pinconf_ops eqbr_pinconf_ops = { .pin_config_config_dbg_show = pinconf_generic_dump_config, }; -static bool is_func_exist(struct eqbr_pmx_func *funcs, const char *name, - unsigned int nr_funcs, unsigned int *idx) +static bool is_func_exist(struct pinfunction *funcs, const char *name, + unsigned int nr_funcs, unsigned int *idx) { int i; @@ -584,13 +584,14 @@ static bool is_func_exist(struct eqbr_pmx_func *funcs, const char *name, return false; } -static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, +static int funcs_utils(struct device *dev, struct pinfunction *funcs, unsigned int *nr_funcs, funcs_util_ops op) { struct device_node *node = dev->of_node; struct device_node *np; struct property *prop; const char *fn_name; + const char **groups; unsigned int fid; int i, j; @@ -620,15 +621,16 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, case OP_COUNT_NR_FUNC_GRPS: if (is_func_exist(funcs, fn_name, *nr_funcs, &fid)) - funcs[fid].nr_groups++; + funcs[fid].ngroups++; break; case OP_ADD_FUNC_GRPS: if (is_func_exist(funcs, fn_name, *nr_funcs, &fid)) { - for (j = 0; j < funcs[fid].nr_groups; j++) - if (!funcs[fid].groups[j]) + groups = (const char **)funcs[fid].groups; + for (j = 0; j < funcs[fid].ngroups; j++) + if (!groups[j]) break; - funcs[fid].groups[j] = prop->value; + groups[j] = prop->value; } break; @@ -645,7 +647,7 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata) { struct device *dev = drvdata->dev; - struct eqbr_pmx_func *funcs = NULL; + struct pinfunction *funcs = NULL; unsigned int nr_funcs = 0; int i, ret; @@ -666,9 +668,9 @@ static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata) return ret; for (i = 0; i < nr_funcs; i++) { - if (!funcs[i].nr_groups) + if (!funcs[i].ngroups) continue; - funcs[i].groups = devm_kcalloc(dev, funcs[i].nr_groups, + funcs[i].groups = devm_kcalloc(dev, funcs[i].ngroups, sizeof(*(funcs[i].groups)), GFP_KERNEL); if (!funcs[i].groups) @@ -688,7 +690,7 @@ static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata) ret = pinmux_generic_add_function(drvdata->pctl_dev, funcs[i].name, funcs[i].groups, - funcs[i].nr_groups, + funcs[i].ngroups, drvdata); if (ret < 0) { dev_err(dev, "Failed to register function %s\n", diff --git a/drivers/pinctrl/pinctrl-equilibrium.h b/drivers/pinctrl/pinctrl-equilibrium.h index 83768cc8b3db..b4d149bde39d 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.h +++ b/drivers/pinctrl/pinctrl-equilibrium.h @@ -67,18 +67,6 @@ struct gpio_irq_type { unsigned int logic_type; }; -/** - * struct eqbr_pmx_func: represent a pin function. - * @name: name of the pin function, used to lookup the function. - * @groups: one or more names of pin groups that provide this function. - * @nr_groups: number of groups included in @groups. - */ -struct eqbr_pmx_func { - const char *name; - const char **groups; - unsigned int nr_groups; -}; - /** * struct eqbr_pin_bank: represent a pin bank. * @membase: base address of the pin bank register. -- 2.45.1