All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Gorski <jonas.gorski@gmail.com>
To: Daniel Golle <daniel@makrotopia.org>
Cc: linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ryder Lee <ryder.lee@mediatek.com>,
	Shayne Chen <shayne.chen@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>, Kalle Valo <kvalo@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	John Crispin <john@phrozen.org>
Subject: Re: [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes
Date: Wed, 26 Jul 2023 18:04:18 +0200	[thread overview]
Message-ID: <CAOiHx=m5jRYd70ymvX=-9Xh4ZDApJ04G39j9+U0YB18W1QPv7A@mail.gmail.com> (raw)
In-Reply-To: <ZK9mXE00xEHZV4fi@makrotopia.org>

Hi,

On Thu, 13 Jul 2023 at 04:53, Daniel Golle <daniel@makrotopia.org> wrote:
>
> With dual-band-dual-congruent front-ends which appear as two independent
> radios it is desirable to assign a per-band MAC address from device-tree,
> eg. using nvmem-cells.
> Support specifying MAC-address related properties in band-specific child
> nodes, e.g.
>         mt7915@0,0 {
>                 reg = <0x0000 0 0 0 0>;
>                 #addr-cells = <1>;
>                 #size-cells = <0>;
>
>                 band@0 {
>                         /* 2.4 GHz */
>                         reg = <0>;
>                         nvmem-cells = <&macaddr 2>;
>                         nvmem-cell-names = "mac-address";
>                 };
>
>                 band@1 {
>                         /* 5 GHz */
>                         reg = <1>;
>                         nvmem-cells = <&macaddr 3>;
>                         nvmem-cell-names = "mac-address";
>                 };
>         };
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
>  drivers/net/wireless/mediatek/mt76/eeprom.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
> index dce851d42e083..90ee138843a55 100644
> --- a/drivers/net/wireless/mediatek/mt76/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
> @@ -106,7 +106,20 @@ void
>  mt76_eeprom_override(struct mt76_phy *phy)
>  {
>         struct mt76_dev *dev = phy->dev;
> -       struct device_node *np = dev->dev->of_node;
> +       struct device_node *child_np, *np = dev->dev->of_node;
> +       u32 reg;
> +       int ret;
> +
> +       for_each_child_of_node(np, child_np) {
> +               ret = of_property_read_u32(child_np, "reg", &reg);
> +               if (ret)
> +                       continue;
> +
> +               if (reg == phy->band_idx) {
> +                       np = child_np;
> +                       break;

When breaking out of the loop here you still hold an additional
reference to child_np, so you need to call of_node_put() for it,
probably after calling of_get_mac_address().

> +               }
> +       }
>
>         of_get_mac_address(np, phy->macaddr);
>

probably just add a of_node_put(child_np); here, of_node_put() seems
to be NULL safe.


Regards,
Jonas

      parent reply	other threads:[~2023-07-26 16:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13  2:50 [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes Daniel Golle
2023-07-13  2:50 ` Daniel Golle
2023-07-26 13:53 ` Shiji Yang
2023-07-26 16:04 ` Jonas Gorski [this message]

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='CAOiHx=m5jRYd70ymvX=-9Xh4ZDApJ04G39j9+U0YB18W1QPv7A@mail.gmail.com' \
    --to=jonas.gorski@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=ansuelsmth@gmail.com \
    --cc=daniel@makrotopia.org \
    --cc=john@phrozen.org \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.