From: Alexey Charkov <alchark@gmail.com>
To: Jacobe Zang <jacobe.zang@wesion.com>,
robh@kernel.org, krzk+dt@kernel.org, heiko@sntech.de,
kvalo@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, conor+dt@kernel.org,
linux-rockchip@lists.infradead.org
Cc: efectn@protonmail.com, dsimic@manjaro.org, jagan@edgeble.ai,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
arend@broadcom.com, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, megi@xff.cz, duoming@zju.edu.cn,
bhelgaas@google.com, minipli@grsecurity.net,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
nick@khadas.com, Sai Krishna <saikrishnag@marvell.com>,
Arend van Spriel <arend.vanspriel@broadcom.com>
Subject: Re: [PATCH v10 4/5] wifi: brcmfmac: Add optional lpo clock enable support
Date: Wed, 14 Aug 2024 11:47:09 +0300 [thread overview]
Message-ID: <2269063.vFx2qVVIhK@latitude-fedora> (raw)
In-Reply-To: <721da64c-42ec-4be6-8ad3-e2685a84823a@broadcom.com>
Hi Arend, Jacobe,
On Tuesday, August 13, 2024 2:57:28 PM GMT+3 Arend van Spriel wrote:
> On 8/13/2024 10:20 AM, Jacobe Zang wrote:
> > WiFi modules often require 32kHz clock to function. Add support to
> > enable the clock to PCIe driver and move "brcm,bcm4329-fmac" check
> > to the top of brcmf_of_probe. Change function prototypes from void
> > to int and add appropriate errno's for return values that will be
> > send to bus when error occurred.
>
> I was going to say it looks good to me, but....
>
> > Co-developed-by: Ondrej Jirman <megi@xff.cz>
> > Signed-off-by: Ondrej Jirman <megi@xff.cz>
> > Co-developed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> > Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> > Reviewed-by: Sai Krishna <saikrishnag@marvell.com>
> > Signed-off-by: Jacobe Zang <jacobe.zang@wesion.com>
> > ---
> >
> > .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 4 +-
> > .../broadcom/brcm80211/brcmfmac/common.c | 3 +-
> > .../wireless/broadcom/brcm80211/brcmfmac/of.c | 53 +++++++++++--------
> > .../wireless/broadcom/brcm80211/brcmfmac/of.h | 9 ++--
> > .../broadcom/brcm80211/brcmfmac/pcie.c | 3 ++
> > .../broadcom/brcm80211/brcmfmac/sdio.c | 22 +++++---
> > .../broadcom/brcm80211/brcmfmac/usb.c | 3 ++
> > 7 files changed, 61 insertions(+), 36 deletions(-)
>
> [...]
>
> > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> > b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c index
> > e406e11481a62..f19dc7355e0e8 100644
> > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
>
> [...]
>
> > @@ -113,33 +118,39 @@ void brcmf_of_probe(struct device *dev, enum
> > brcmf_bus_type bus_type,>
> > of_node_put(root);
> >
> > }
> >
> > - if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
> > - return;
> > -
> >
> > err = brcmf_of_get_country_codes(dev, settings);
> > if (err)
> >
> > brcmf_err("failed to get OF country code map (err=%d)
\n", err);
> >
> > of_get_mac_address(np, settings->mac);
> >
> > - if (bus_type != BRCMF_BUSTYPE_SDIO)
> > - return;
> > + if (bus_type == BRCMF_BUSTYPE_SDIO) {
>
> Don't like the fact that this now has an extra indentation level and it
> offers no extra benefit. Just keep the original if-statement and return
> 0. Consequently the LPO clock code should move just before the if-statement.
> > + if (of_property_read_u32(np, "brcm,drive-strength",
&val) == 0)
> > + sdio->drive_strength = val;
> >
> > - if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
> > - sdio->drive_strength = val;
> > + /* make sure there are interrupts defined in the node */
> > + if (!of_property_present(np, "interrupts"))
> > + return 0;
> >
> > - /* make sure there are interrupts defined in the node */
> > - if (!of_property_present(np, "interrupts"))
> > - return;
> > + irq = irq_of_parse_and_map(np, 0);
> > + if (!irq) {
> > + brcmf_err("interrupt could not be
mapped\n");
> > + return 0;
> > + }
> > + irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
> > +
> > + sdio->oob_irq_supported = true;
> > + sdio->oob_irq_nr = irq;
> > + sdio->oob_irq_flags = irqf;
> > + }
> >
> > - irq = irq_of_parse_and_map(np, 0);
> > - if (!irq) {
> > - brcmf_err("interrupt could not be mapped\n");
> > - return;
> > + clk = devm_clk_get_optional_enabled(dev, "lpo");
> > + if (!IS_ERR_OR_NULL(clk)) {
> > + brcmf_dbg(INFO, "enabling 32kHz clock\n");
> > + return clk_set_rate(clk, 32768);
> > + } else {
> > + return PTR_ERR_OR_ZERO(clk);
> >
> > }
>
> Change this to:
> > + clk = devm_clk_get_optional_enabled(dev, "lpo");
> > + if (IS_ERR_OR_NULL(clk)) {
> > + return PTR_ERR_OR_ZERO(clk);
Perhaps in this case we should go for IS_ERR and PTR_ERR respectively.
devm_clk_get_optional_enabled would return NULL when the optional clock is not
found, so NULL is not an error state but serves as a dummy clock that can be
used with clk_set_rate.
This way we won't skip over the interrupts initialization below in case the
clock is absent.
> > + }
> > + brcmf_dbg(INFO, "enabling 32kHz clock\n");
> > + clk_set_rate(clk, 32768);
>
> As said above this should be moved before the if-statement:
> > - if (bus_type != BRCMF_BUSTYPE_SDIO)
> > - return 0;
> >
> > - irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
> >
> > - sdio->oob_irq_supported = true;
> > - sdio->oob_irq_nr = irq;
> > - sdio->oob_irq_flags = irqf;
> > + return 0;
> >
> > }
Best regards,
Alexey
next prev parent reply other threads:[~2024-08-14 8:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 8:20 [PATCH v10 0/5] Add AP6275P wireless support Jacobe Zang
2024-08-13 8:20 ` [PATCH v10 1/5] dt-bindings: net: wireless: brcm4329-fmac: add pci14e4,449d Jacobe Zang
2024-08-13 17:04 ` Arend Van Spriel
2024-08-14 8:53 ` Krzysztof Kozlowski
2024-08-14 9:12 ` Jacobe Zang
2024-08-14 10:38 ` Krzysztof Kozlowski
2024-08-14 10:08 ` Arend van Spriel
2024-08-14 10:39 ` Krzysztof Kozlowski
2024-08-14 10:59 ` Arend van Spriel
2024-08-14 11:15 ` Krzysztof Kozlowski
2024-08-14 14:08 ` Krzysztof Kozlowski
2024-08-14 16:47 ` Arend Van Spriel
2024-08-15 9:38 ` Kalle Valo
2024-08-13 8:20 ` [PATCH v10 2/5] dt-bindings: net: wireless: brcm4329-fmac: add clock description for AP6275P Jacobe Zang
2024-08-13 8:20 ` [PATCH v10 3/5] arm64: dts: rockchip: Add AP6275P wireless support to Khadas Edge 2 Jacobe Zang
2024-08-13 8:20 ` [PATCH v10 4/5] wifi: brcmfmac: Add optional lpo clock enable support Jacobe Zang
2024-08-13 11:57 ` Arend van Spriel
2024-08-13 18:31 ` Arend van Spriel
2024-08-14 8:47 ` Alexey Charkov [this message]
2024-08-14 9:26 ` Jacobe Zang
2024-08-14 9:48 ` Alexey Charkov
2024-08-14 10:44 ` Arend van Spriel
2024-08-13 8:20 ` [PATCH v10 5/5] wifi: brcmfmac: add flag for random seed during firmware download Jacobe Zang
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=2269063.vFx2qVVIhK@latitude-fedora \
--to=alchark@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=arend@broadcom.com \
--cc=bhelgaas@google.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dsimic@manjaro.org \
--cc=duoming@zju.edu.cn \
--cc=edumazet@google.com \
--cc=efectn@protonmail.com \
--cc=heiko@sntech.de \
--cc=jacobe.zang@wesion.com \
--cc=jagan@edgeble.ai \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=megi@xff.cz \
--cc=minipli@grsecurity.net \
--cc=netdev@vger.kernel.org \
--cc=nick@khadas.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=saikrishnag@marvell.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).