From: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
To: <linusw@kernel.org>
Cc: <Shyam-sundar.S-k@amd.com>, <Matt.Devillier@amd.com>,
<Guruvendra.Punugupati@amd.com>, <linux-gpio@vger.kernel.org>,
"Basavaraj Natikar" <Basavaraj.Natikar@amd.com>
Subject: [PATCH v2 2/3] pinctrl: amd: Factor out optional named resource lookup
Date: Mon, 21 Sep 2026 10:57:44 +0530 [thread overview]
Message-ID: <20260921052745.1056249-3-Basavaraj.Natikar@amd.com> (raw)
In-Reply-To: <20260921052745.1056249-1-Basavaraj.Natikar@amd.com>
The optional iomux resource is looked up by name. A following patch
needs the same lookup for another optional resource, along with a
minimum size check. Factor it out into a helper that also rejects a
resource smaller than a caller-supplied size. No functional change for
iomux.
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
drivers/pinctrl/pinctrl-amd.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 543733c2aae0..18fce75fe86c 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -1137,28 +1137,31 @@ static struct pinctrl_desc amd_pinctrl_desc = {
.owner = THIS_MODULE,
};
-static void amd_get_iomux_res(struct amd_gpio *gpio_dev)
+static void __iomem *amd_get_named_res(struct device *dev, struct platform_device *pdev,
+ const char *name, resource_size_t minsz)
{
- struct pinctrl_desc *desc = &amd_pinctrl_desc;
- struct device *dev = &gpio_dev->pdev->dev;
+ struct resource *res;
+ void __iomem *base;
int index;
- index = device_property_match_string(dev, "pinctrl-resource-names", "iomux");
+ index = device_property_match_string(dev, "pinctrl-resource-names", name);
if (index < 0) {
- dev_dbg(dev, "iomux not supported\n");
- goto out_no_pinmux;
+ dev_dbg(dev, "%s not supported\n", name);
+ return NULL;
}
- gpio_dev->iomux_base = devm_platform_ioremap_resource(gpio_dev->pdev, index);
- if (IS_ERR(gpio_dev->iomux_base)) {
- dev_dbg(dev, "iomux not supported %d io resource\n", index);
- goto out_no_pinmux;
+ base = devm_platform_get_and_ioremap_resource(pdev, index, &res);
+ if (IS_ERR(base)) {
+ dev_dbg(dev, "%s not supported %d io resource\n", name, index);
+ return NULL;
}
- return;
+ if (resource_size(res) < minsz) {
+ dev_err(dev, "%s resource too small\n", name);
+ return NULL;
+ }
-out_no_pinmux:
- desc->pmxops = NULL;
+ return base;
}
static int amd_gpio_probe(struct platform_device *pdev)
@@ -1213,7 +1216,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
gpio_dev->ngroups = ARRAY_SIZE(kerncz_groups);
amd_pinctrl_desc.name = dev_name(&pdev->dev);
- amd_get_iomux_res(gpio_dev);
+ gpio_dev->iomux_base = amd_get_named_res(&pdev->dev, pdev, "iomux", 0);
+ if (!gpio_dev->iomux_base)
+ amd_pinctrl_desc.pmxops = NULL;
gpio_dev->pctrl = devm_pinctrl_register(&pdev->dev, &amd_pinctrl_desc,
gpio_dev);
if (IS_ERR(gpio_dev->pctrl)) {
--
2.34.1
next prev parent reply other threads:[~2026-09-21 5:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 5:27 [PATCH v2 0/3] pinctrl: amd: Add Remote GPIO (RGPIO) bank support Basavaraj Natikar
2026-09-21 5:27 ` [PATCH v2 1/3] pinctrl: amd: Centralize per-pin register access Basavaraj Natikar
2026-09-21 5:27 ` Basavaraj Natikar [this message]
2026-09-21 5:27 ` [PATCH v2 3/3] pinctrl: amd: Add support for the Remote GPIO (RGPIO) bank Basavaraj Natikar
2026-10-01 6:48 ` [PATCH v2 0/3] pinctrl: amd: Add Remote GPIO (RGPIO) bank support Linus Walleij
2026-10-01 13:32 ` Mario Limonciello
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=20260921052745.1056249-3-Basavaraj.Natikar@amd.com \
--to=basavaraj.natikar@amd.com \
--cc=Guruvendra.Punugupati@amd.com \
--cc=Matt.Devillier@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.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