From: Bjorn Helgaas <helgaas@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: "Vignesh Raghavendra" <vigneshr@ti.com>,
"Siddharth Vadapalli" <s-vadapalli@ti.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Minghuan Lian" <minghuan.Lian@nxp.com>,
"Mingkai Hu" <mingkai.hu@nxp.com>, "Roy Zang" <roy.zang@nxp.com>,
linux-omap@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
imx@lists.linux.dev
Subject: Re: [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args
Date: Wed, 15 Jan 2025 17:04:30 -0600 [thread overview]
Message-ID: <20250115230430.GA560547@bhelgaas> (raw)
In-Reply-To: <20250112-syscon-phandle-args-pci-v1-1-fcb6ebcc0afc@linaro.org>
On Sun, Jan 12, 2025 at 02:39:02PM +0100, Krzysztof Kozlowski wrote:
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument. Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
>
> There is also no real benefit in printing errors on missing syscon
> argument, because this is done just too late: runtime check on
> static/build-time data. Dtschema and Devicetree bindings offer the
> static/build-time check for this already.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/pci/controller/dwc/pci-dra7xx.c | 27 ++++++---------------------
> 1 file changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
> index 5c62e1a3ba52919afe96fbcbc6edaf70775a69cb..33d6bf460ffe5bb724a061558dd93ec7bdadc336 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -635,30 +635,20 @@ static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
> {
> int ret;
> struct device_node *np = dev->of_node;
> - struct of_phandle_args args;
> + unsigned int args[2];
> struct regmap *regmap;
>
> - regmap = syscon_regmap_lookup_by_phandle(np,
> - "ti,syscon-unaligned-access");
> + regmap = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-unaligned-access",
> + 2, args);
> if (IS_ERR(regmap)) {
> dev_dbg(dev, "can't get ti,syscon-unaligned-access\n");
> return -EINVAL;
> }
>
> - ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-unaligned-access",
> - 2, 0, &args);
> - if (ret) {
> - dev_err(dev, "failed to parse ti,syscon-unaligned-access\n");
> - return ret;
> - }
> -
> - ret = regmap_update_bits(regmap, args.args[0], args.args[1],
> - args.args[1]);
> + ret = regmap_update_bits(regmap, args[0], args[1], args[1]);
> if (ret)
> dev_err(dev, "failed to enable unaligned access\n");
>
> - of_node_put(args.np);
> -
> return ret;
> }
>
> @@ -671,18 +661,13 @@ static int dra7xx_pcie_configure_two_lane(struct device *dev,
> u32 mask;
> u32 val;
>
> - pcie_syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-lane-sel");
> + pcie_syscon = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-lane-sel",
> + 1, &pcie_reg);
> if (IS_ERR(pcie_syscon)) {
> dev_err(dev, "unable to get ti,syscon-lane-sel\n");
> return -EINVAL;
> }
>
> - if (of_property_read_u32_index(np, "ti,syscon-lane-sel", 1,
> - &pcie_reg)) {
> - dev_err(dev, "couldn't get lane selection reg offset\n");
> - return -EINVAL;
> - }
Wow. I believe you that syscon_regmap_lookup_by_phandle_args() is
equivalent to both:
- syscon_regmap_lookup_by_phandle() followed by
of_parse_phandle_with_fixed_args(), and
- syscon_regmap_lookup_by_phandle() followed by
of_property_read_u32_index()
but I can't say it's obvious to this syscon- and OF-naive reviewer,
even after tracing a few layers in :)
Bjorn
next prev parent reply other threads:[~2025-01-15 23:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 13:39 [PATCH 0/2] PCI: Simplify few things Krzysztof Kozlowski
2025-01-12 13:39 ` [PATCH 1/2] PCI: dwc: dra7xx: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
2025-01-15 23:04 ` Bjorn Helgaas [this message]
2025-01-12 13:39 ` [PATCH 2/2] PCI: dwc: layerscape: " Krzysztof Kozlowski
2025-01-13 16:02 ` Frank Li
2025-01-15 1:15 ` Roy Zang
2025-01-15 12:03 ` [PATCH 0/2] PCI: Simplify few things Krzysztof Wilczyński
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=20250115230430.GA560547@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=imx@lists.linux.dev \
--cc=krzysztof.kozlowski@linaro.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=minghuan.Lian@nxp.com \
--cc=mingkai.hu@nxp.com \
--cc=robh@kernel.org \
--cc=roy.zang@nxp.com \
--cc=s-vadapalli@ti.com \
--cc=vigneshr@ti.com \
/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).