Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1161655lqb; Thu, 30 May 2024 02:01:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEdPu18EpLWi65yaPbtnxIHZDTQNdvTjWtNbj+gU+sjUXDcx7Iv7aEsbi9gjCQcCEzkgOhwYbuyeZ6qfDNuGlZSLHNX+1FGVUgCg/esg== X-Google-Smtp-Source: AGHT+IHNbYuknKnXCOygUijkn1wKz9TEe2+99ZWbP+7LeEovo78KevfGCYvSh1t3MSBAB8gM4jrH X-Received: by 2002:a05:6808:2b07:b0:3d1:de07:eaac with SMTP id 5614622812f47-3d1de07ef46mr781126b6e.20.1717059665210; Thu, 30 May 2024 02:01:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717059665; cv=pass; d=google.com; s=arc-20160816; b=FftkJE3KQYtmVUvY1yuKbVvncsWURE9oZN/syJaxTTADo+cx2QHOFgzcrcxozvvq9L r5+vw7iGJqpp38ZUhcvMp8MKTBq3K9QpdZT9veFIDKAp59mte0IWwb3UFwdtWOE724CD sipnohk2R7bRKPju2ig0X9SZbAO++aiV1dOxHaFyu/d8rFX3FqC9cYCjTjiasT8+Ly/B leTxsjamqy7ChZSStGga3OcvPvuBmV2c5BSlv/jTL3edtgwkeus+6motyEABwY+tYTZk mAswtyMBUbN4QOkHlEIql5KLg2LhnBo6lCEaWs8cJIsx9EwJm0l6D7odTn0uPhz4UkQS 7mYQ== 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=65bVKmnTFATSk9bGG8ZGO/Zm5BvxobMQO14oyJZlvZg=; b=rLMxNOdGlJfOs3P4XooUdml/EkskzeNBkEKPPMMmAM6otHTSOxE0GaWCiG6j2pHr58 Wvop2e8DWm4XmPlQzhJd1hbrAdsfeHfNOxloe1XVjIAIpOen8O00Xc27w/PSQ0w/uwS+ qhZWZJftoMv5gUHz93ujDDRu6RMbyJaezRJ/PHxsxUFlWmNYYDpjuwVeKvE3sRuhOg96 aMxaOLeePeaBqi22smq4wih/QxOxF6eOJOwn4Sj4KphZjxPj48S3Mx0kCgsCD8YXyidr NMg0ss/YIj3f6QTGO5JXbepG2ODDI0R8ThtwLSGKmwn7n0NAzOBYsctTE8+GeYEWocP6 N96Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-195115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195115-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-6ad7527ac7dsi8794356d6.187.2024.05.30.02.01.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 02:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195115-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-195115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195115-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 B6A171C23073 for ; Thu, 30 May 2024 09:01:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A7A517C7BC; Thu, 30 May 2024 08:58:11 +0000 (UTC) Received: from fgw22-7.mail.saunalahti.fi (fgw22-7.mail.saunalahti.fi [62.142.5.83]) (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 BE62C176AC2 for ; Thu, 30 May 2024 08:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.83 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717059490; cv=none; b=u56A5/oYAWOD6SeNXWBM9mgKm161r1KOaxgF2JPZhlZbl6vI5bULJfot14xq+o562Dxc06MZQa3ZLk/Ys5IBheTqUSki9QhrRrcXRSR93Zh5vtQ1bSjzzCpC8ygqnRdF+SHdsyZ2dZetQqC9bavt8wZ9mbpxp/ILG9iHgKaMS8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717059490; c=relaxed/simple; bh=UUNlZAPD7ufWrtpQqrGWyMeB5Qmh9EtgLPVDRPhTSwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hFS5aZdCcMw2P9ry/XaDKeExdRPgtTDYVCLxZ1Q1nETTBTotxTULq5Hw+r8XeDbewcgW6fUA4ZahGCDQmZid6uVWSoKFM6iRW7qSFYaS4s/QamOyuI9NH1+chcdKEaGv8i4iz6oWNQbJne9kH7QqmurAsrayc+i8MNZgDsZIJUQ= 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.83 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 fgw22.mail.saunalahti.fi (Halon) with ESMTP id bac30c71-1e62-11ef-8e2e-005056bdf889; Thu, 30 May 2024 11:58:06 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , AngeloGioacchino Del Regno , 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 , Paul Cercueil , Lakshmi Sowjanya D , Andy Shevchenko Subject: [PATCH v3 02/11] pinctrl: equilibrium: Make use of struct pinfunction Date: Thu, 30 May 2024 11:55:11 +0300 Message-ID: <20240530085745.1539925-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240530085745.1539925-1-andy.shevchenko@gmail.com> References: <20240530085745.1539925-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