devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Clément Léger" <clement.leger@bootlin.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"Russell King" <linux@armlinux.org.uk>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
	"Jose Abreu" <joabreu@synopsys.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Herve Codina" <herve.codina@bootlin.com>,
	"Miquèl Raynal" <miquel.raynal@bootlin.com>,
	"Milan Stevanovic" <milan.stevanovic@se.com>,
	"Jimmy Lalande" <jimmy.lalande@se.com>,
	"Pascal Eberhard" <pascal.eberhard@se.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver
Date: Thu, 16 Jun 2022 09:12:22 +0200	[thread overview]
Message-ID: <20220616091222.4dbf9de3@fixe.home> (raw)
In-Reply-To: <20220614223109.603935fb@kernel.org>

Le Tue, 14 Jun 2022 22:31:09 -0700,
Jakub Kicinski <kuba@kernel.org> a écrit :

> On Fri, 10 Jun 2022 12:37:01 +0200 Clément Léger wrote:
> > Subject: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver
> > 
> > Add a PCS driver for the MII converter that is present on the Renesas
> > RZ/N1 SoC. This MII converter is reponsible for converting MII to
> > RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to
> > reuse it in both the switch driver and the stmmac driver. Currently,
> > this driver only allows the PCS to be used by the dual Cortex-A7
> > subsystem since the register locking system is not used.  
> 
> Could someone with MII &| PCS knowledge cast an eye over this code?
> All I can do is point out error path issues...
> 
> > +struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)
> > +{
> > +	struct platform_device *pdev;
> > +	struct miic_port *miic_port;
> > +	struct device_node *pcs_np;
> > +	struct miic *miic;
> > +	u32 port;
> > +
> > +	if (!of_device_is_available(np))
> > +		return ERR_PTR(-ENODEV);
> > +
> > +	if (of_property_read_u32(np, "reg", &port))
> > +		return ERR_PTR(-EINVAL);
> > +
> > +	if (port > MIIC_MAX_NR_PORTS || port < 1)
> > +		return ERR_PTR(-EINVAL);
> > +
> > +	/* The PCS pdev is attached to the parent node */
> > +	pcs_np = of_get_parent(np);  
> 
> of_get_parent()? ..
> 
> > +	if (!pcs_np)
> > +		return ERR_PTR(-ENODEV);
> > +
> > +	if (!of_device_is_available(pcs_np))
> > +		return ERR_PTR(-ENODEV);  
> 
> .. more like of_leak_parent()

Indeed, I'll fix that.

> 
> > +	pdev = of_find_device_by_node(pcs_np);
> > +	if (!pdev || !platform_get_drvdata(pdev))
> > +		return ERR_PTR(-EPROBE_DEFER);
> > +
> > +	miic_port = kzalloc(sizeof(*miic_port), GFP_KERNEL);
> > +	if (!miic_port)
> > +		return ERR_PTR(-ENOMEM);
> > +
> > +	miic = platform_get_drvdata(pdev);
> > +	device_link_add(dev, miic->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
> > +
> > +	miic_port->miic = miic;
> > +	miic_port->port = port - 1;
> > +	miic_port->pcs.ops = &miic_phylink_ops;
> > +
> > +	return &miic_port->pcs;
> > +}
> > +EXPORT_SYMBOL(miic_create);  
> 
> > +static int miic_parse_dt(struct device *dev, u32 *mode_cfg)
> > +{
> > +	s8 dt_val[MIIC_MODCTRL_CONF_CONV_NUM];
> > +	struct device_node *np = dev->of_node;
> > +	struct device_node *conv;
> > +	u32 conf;
> > +	int port;
> > +
> > +	memset(dt_val, MIIC_MODCTRL_CONF_NONE, sizeof(dt_val));
> > +
> > +	of_property_read_u32(np, "renesas,miic-switch-portin", &conf);
> > +	dt_val[0] = conf;
> > +
> > +	for_each_child_of_node(np, conv) {
> > +		if (of_property_read_u32(conv, "reg", &port))
> > +			continue;
> > +
> > +		if (!of_device_is_available(conv))
> > +			continue;
> > +
> > +		if (of_property_read_u32(conv, "renesas,miic-input", &conf) == 0)
> > +			dt_val[port] = conf;
> > +
> > +		of_node_put(conv);  
> 
> Don't these iteration functions put() the current before taking the
> next one all by themselves? Or is there supposed to be a "break" here?

Yes, of_node_put() should actually only be called in case of early exit.
I'll fix that.


-- 
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com

  reply	other threads:[~2022-06-16  7:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 10:36 [PATCH RESEND net-next v7 00/16] add support for Renesas RZ/N1 ethernet subsystem devices Clément Léger
2022-06-10 10:36 ` [PATCH RESEND net-next v7 01/16] net: dsa: allow port_bridge_join() to override extack message Clément Léger
2022-06-14 21:49   ` Florian Fainelli
2022-06-10 10:36 ` [PATCH RESEND net-next v7 02/16] net: dsa: add support for ethtool get_rmon_stats() Clément Léger
2022-06-10 10:36 ` [PATCH RESEND net-next v7 03/16] net: dsa: add Renesas RZ/N1 switch tag driver Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 04/16] dt-bindings: net: pcs: add bindings for Renesas RZ/N1 MII converter Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver Clément Léger
2022-06-15  5:31   ` Jakub Kicinski
2022-06-16  7:12     ` Clément Léger [this message]
2022-06-10 10:37 ` [PATCH RESEND net-next v7 06/16] dt-bindings: net: dsa: add bindings for Renesas RZ/N1 Advanced 5 port switch Clément Léger
2022-06-14 21:51   ` Florian Fainelli
2022-06-10 10:37 ` [PATCH RESEND net-next v7 07/16] net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 08/16] net: dsa: rzn1-a5psw: add statistics support Clément Léger
2022-06-14 22:38   ` Florian Fainelli
2022-06-10 10:37 ` [PATCH RESEND net-next v7 09/16] net: dsa: rzn1-a5psw: add FDB support Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 10/16] dt-bindings: net: snps,dwmac: add "power-domains" property Clément Léger
2022-06-14 21:50   ` Florian Fainelli
2022-06-10 10:37 ` [PATCH RESEND net-next v7 11/16] dt-bindings: net: snps,dwmac: add "renesas,rzn1" compatible Clément Léger
2022-06-14 20:52   ` Rob Herring
2022-06-14 21:50   ` Florian Fainelli
2022-06-10 10:37 ` [PATCH RESEND net-next v7 12/16] ARM: dts: r9a06g032: describe MII converter Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 13/16] ARM: dts: r9a06g032: describe GMAC2 Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 14/16] ARM: dts: r9a06g032: describe switch Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 15/16] ARM: dts: r9a06g032-rzn1d400-db: add switch description Clément Léger
2022-06-10 10:37 ` [PATCH RESEND net-next v7 16/16] MAINTAINERS: add Renesas RZ/N1 switch related driver entry Clément Léger

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=20220616091222.4dbf9de3@fixe.home \
    --to=clement.leger@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=herve.codina@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=jimmy.lalande@se.com \
    --cc=joabreu@synopsys.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=magnus.damm@gmail.com \
    --cc=milan.stevanovic@se.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pascal.eberhard@se.com \
    --cc=peppe.cavallaro@st.com \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vivien.didelot@gmail.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).