From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Daniel Golle <daniel@makrotopia.org>,
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 <aisheng.dong@nxp.com>,
Fabio Estevam <festevam@gmail.com>,
Shawn Guo <shawnguo@kernel.org>, Jacky Bai <ping.bai@nxp.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
Sean Wang <sean.wang@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Paul Cercueil <paul@crapouillou.net>,
Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH v2 01/11] pinctrl: berlin: Make use of struct pinfunction
Date: Tue, 28 May 2024 22:44:52 +0300 [thread overview]
Message-ID: <20240528194951.1489887-2-andy.shevchenko@gmail.com> (raw)
In-Reply-To: <20240528194951.1489887-1-andy.shevchenko@gmail.com>
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Since pin control provides a generic data type for the pin function,
use it in the driver.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/pinctrl/berlin/berlin.c | 21 +++++++++------------
drivers/pinctrl/berlin/berlin.h | 6 ------
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index 9550cc8095c2..c372a2a24be4 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -27,7 +27,7 @@ struct berlin_pinctrl {
struct regmap *regmap;
struct device *dev;
const struct berlin_pinctrl_desc *desc;
- struct berlin_pinctrl_function *functions;
+ struct pinfunction *functions;
unsigned nfunctions;
struct pinctrl_dev *pctrl_dev;
};
@@ -120,12 +120,12 @@ static const char *berlin_pinmux_get_function_name(struct pinctrl_dev *pctrl_dev
static int berlin_pinmux_get_function_groups(struct pinctrl_dev *pctrl_dev,
unsigned function,
const char * const **groups,
- unsigned * const num_groups)
+ unsigned * const ngroups)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
*groups = pctrl->functions[function].groups;
- *num_groups = pctrl->functions[function].ngroups;
+ *ngroups = pctrl->functions[function].ngroups;
return 0;
}
@@ -153,7 +153,7 @@ static int berlin_pinmux_set(struct pinctrl_dev *pctrl_dev,
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
const struct berlin_desc_group *group_desc = pctrl->desc->groups + group;
- struct berlin_pinctrl_function *func = pctrl->functions + function;
+ struct pinfunction *func = pctrl->functions + function;
struct berlin_desc_function *function_desc =
berlin_pinctrl_find_function_by_name(pctrl, group_desc,
func->name);
@@ -180,7 +180,7 @@ static const struct pinmux_ops berlin_pinmux_ops = {
static int berlin_pinctrl_add_function(struct berlin_pinctrl *pctrl,
const char *name)
{
- struct berlin_pinctrl_function *function = pctrl->functions;
+ struct pinfunction *function = pctrl->functions;
while (function->name) {
if (!strcmp(function->name, name)) {
@@ -214,8 +214,7 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
}
/* we will reallocate later */
- pctrl->functions = kcalloc(max_functions,
- sizeof(*pctrl->functions), GFP_KERNEL);
+ pctrl->functions = kcalloc(max_functions, sizeof(*pctrl->functions), GFP_KERNEL);
if (!pctrl->functions)
return -ENOMEM;
@@ -242,8 +241,7 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
desc_function = desc_group->functions;
while (desc_function->name) {
- struct berlin_pinctrl_function
- *function = pctrl->functions;
+ struct pinfunction *function = pctrl->functions;
const char **groups;
bool found = false;
@@ -264,16 +262,15 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
function->groups =
devm_kcalloc(&pdev->dev,
function->ngroups,
- sizeof(char *),
+ sizeof(*function->groups),
GFP_KERNEL);
-
if (!function->groups) {
kfree(pctrl->functions);
return -ENOMEM;
}
}
- groups = function->groups;
+ groups = (const char **)function->groups;
while (*groups)
groups++;
diff --git a/drivers/pinctrl/berlin/berlin.h b/drivers/pinctrl/berlin/berlin.h
index d7787754d1ed..231aab61d415 100644
--- a/drivers/pinctrl/berlin/berlin.h
+++ b/drivers/pinctrl/berlin/berlin.h
@@ -28,12 +28,6 @@ struct berlin_pinctrl_desc {
unsigned ngroups;
};
-struct berlin_pinctrl_function {
- const char *name;
- const char **groups;
- unsigned ngroups;
-};
-
#define BERLIN_PINCTRL_GROUP(_name, _offset, _width, _lsb, ...) \
{ \
.name = _name, \
--
2.45.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-05-28 19:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 19:44 [PATCH v2 00/11] pinctrl: pinmux: Embed and reuse struct pinfunction Andy Shevchenko
2024-05-28 19:44 ` Andy Shevchenko [this message]
2024-05-28 19:44 ` [PATCH v2 02/11] pinctrl: equilibrium: Make use of " Andy Shevchenko
2024-05-28 19:44 ` [PATCH v2 03/11] pinctrl: ingenic: Provide a helper macro INGENIC_PIN_FUNCTION() Andy Shevchenko
2024-05-28 19:44 ` [PATCH v2 04/11] pinctrl: mediatek: Provide a helper macro PINCTRL_PIN_FUNCTION() Andy Shevchenko
2024-05-29 8:24 ` AngeloGioacchino Del Regno
2024-05-29 9:15 ` Andy Shevchenko
2024-05-28 19:44 ` [PATCH v2 05/11] pinctrl: pinmux: Add a convenient define PINCTRL_FUNCTION_DESC() Andy Shevchenko
2024-05-28 19:44 ` [PATCH v2 06/11] pinctrl: pinmux: Embed struct pinfunction into struct function_desc Andy Shevchenko
2024-05-28 19:44 ` [PATCH v2 07/11] pinctrl: imx: Convert to use func member Andy Shevchenko
2024-05-30 4:27 ` kernel test robot
2024-05-28 19:44 ` [PATCH v2 08/11] pinctrl: ingenic: " Andy Shevchenko
2024-05-28 19:45 ` [PATCH v2 09/11] pinctrl: keembay: " Andy Shevchenko
2024-05-28 19:45 ` [PATCH v2 10/11] pinctrl: mediatek: " Andy Shevchenko
2024-05-29 8:24 ` AngeloGioacchino Del Regno
2024-05-29 9:16 ` Andy Shevchenko
2024-05-28 19:45 ` [PATCH v2 11/11] pinctrl: pinmux: Remove unused members from struct function_desc Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240528194951.1489887-2-andy.shevchenko@gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=aisheng.dong@nxp.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=daniel@makrotopia.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=lakshmi.sowjanya.d@intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mips@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=paul@crapouillou.net \
--cc=ping.bai@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sean.wang@kernel.org \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).