[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65bbcb5e.050a0220.52fda.0654@mx.google.com>
Date: Thu, 1 Feb 2024 17:48:26 +0100
From: Christian Marangi <ansuelsmth@...il.com>
To: Antoine Tenart <atenart@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, Bjorn Andersson <andersson@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Frank Rowand <frowand.list@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Paolo Abeni <pabeni@...hat.com>, Rob Herring <robh+dt@...nel.org>,
Robert Marko <robert.marko@...tura.hr>,
Russell King <linux@...linux.org.uk>, devicetree@...r.kernel.org,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [net-next PATCH v5 3/9] net: phy: add devm/of_phy_package_join
helper
On Thu, Feb 01, 2024 at 05:40:28PM +0100, Antoine Tenart wrote:
> Quoting Christian Marangi (2024-02-01 16:17:29)
> > +/**
> > + * of_phy_package_join - join a common PHY group in PHY package
> > + * @phydev: target phy_device struct
> > + * @priv_size: if non-zero allocate this amount of bytes for private data
> > + *
> > + * This is a variant of phy_package_join for PHY package defined in DT.
> > + *
> > + * The parent node of the @phydev is checked as a valid PHY package node
> > + * structure (by matching the node name "ethernet-phy-package") and the
> > + * base_addr for the PHY package is passed to phy_package_join.
> > + *
> > + * With this configuration the shared struct will also have the np value
> > + * filled to use additional DT defined properties in PHY specific
> > + * probe_once and config_init_once PHY package OPs.
> > + *
> > + * Returns < 1 on error, 0 on success. Esp. calling phy_package_join()
>
> So, < 0 on error ?
>
> > +int of_phy_package_join(struct phy_device *phydev, size_t priv_size)
> > +{
> > + struct device_node *node = phydev->mdio.dev.of_node;
> > + struct device_node *package_node;
> > + u32 base_addr;
> > + int ret;
> > +
> > + if (!node)
> > + return -EINVAL;
> > +
> > + package_node = of_get_parent(node);
>
> Is the node put on package leave?
>
Didn't read the get_parent was incrementing the refcount... Will update
the leave accordingly!
> > + if (!package_node)
> > + return -EINVAL;
> > +
> > + if (!of_node_name_eq(package_node, "ethernet-phy-package")
>
> of_put_node? + below.
>
> > + return -EINVAL;
> > +
> > + if (of_property_read_u32(package_node, "reg", &base_addr))
> > + return -EINVAL;
> > +
> > + ret = phy_package_join(phydev, base_addr, priv_size);
> > + if (ret)
> > + return ret;
> > +
> > + phydev->shared->np = package_node;
>
> Just looked quickly, looks like ->np is uninitialized in the !of join
> case.
>
Correct, I will update the non of variant to inizialize ->np to NULL.
(in theory we alloc every struct as zero so it should not be a problem
but you are right with being safe on this.)
Thanks!
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(of_phy_package_join);
--
Ansuel
Powered by blists - more mailing lists