From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Paolo Abeni <pabeni@redhat.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Madalin Bucur <madalin.bucur@nxp.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com
Subject: Re: [PATCH net-next] net: pcs: pcs-lynx: remove lynx_get_mdio_device() and refactor cleanup
Date: Mon, 30 Jan 2023 19:14:41 +0100 [thread overview]
Message-ID: <20230130191441.7aa46ea9@pc-7.home> (raw)
In-Reply-To: <20230128015841.rotwc2arwgn2csef@skbuf>
Hello Vlad,
On Sat, 28 Jan 2023 03:58:41 +0200
Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
> On Fri, Jan 27, 2023 at 03:07:58PM +0100, Maxime Chevallier wrote:
> > However this current patch still makes sense though right ?
>
> I have a pretty hard time saying yes; TL;DR yes it's less code, but
> it's structured that way with a reason.
>
> I don't think it's lynx_pcs_destroy()'s responsibility to call
> mdio_device_free(), just like it isn't lynx_pcs_create()'s
> responsibility to call mdio_device_create() (or whatever). In fact
> that's the reason why the mdiodev isn't completely absorbed by the
> lynx_pcs - because there isn't a unified way to get a reference to it
> - some platforms have a hardcoded address, others have a phandle in
> the device tree.
I get you and I actually agree, I've been also thinking about that this
weekend and indeed it would create an asymetry that can easily lead to
leaky code.
Let's drop that patch then, thanks a lot for the thourough review and
comments, I appreciate it.
Best regards,
Maxime
> I know this is entirely subjective, but to me, having functions
> organized in pairs which undo precisely what the other has done, and
> not more, really helps with spotting resource leakage issues. I
> realize that it's not the same for everybody. For example, while
> reviewing your patch, I noticed this in the existing code:
>
> static struct phylink_pcs *memac_pcs_create(struct device_node
> *mac_node, int index)
> {
> struct device_node *node;
> struct mdio_device *mdiodev = NULL;
> struct phylink_pcs *pcs;
>
> node = of_parse_phandle(mac_node, "pcsphy-handle", index);
> if (node && of_device_is_available(node))
> mdiodev = of_mdio_find_device(node);
> of_node_put(node);
>
> if (!mdiodev)
> return ERR_PTR(-EPROBE_DEFER);
>
> pcs = lynx_pcs_create(mdiodev); // if this fails, we miss
> calling mdio_device_free() return pcs;
> }
>
> and it's clear that what is obvious to me was not obvious to the
> author of commit a7c2a32e7f22 ("net: fman: memac: Use lynx pcs
> driver"), since this organization scheme didn't work for him.
prev parent reply other threads:[~2023-01-30 18:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 13:40 Maxime Chevallier
2023-01-27 13:43 ` Vladimir Oltean
2023-01-27 14:07 ` Maxime Chevallier
2023-01-28 1:58 ` Vladimir Oltean
2023-01-30 18:14 ` Maxime Chevallier [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=20230130191441.7aa46ea9@pc-7.home \
--to=maxime.chevallier@bootlin.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.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
all inboxes | Powered by JetHome®