From: Florian Fainelli <f.fainelli@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Michal Kubecek <mkubecek@suse.cz>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v2 3/3] net: ethtool: Remove PHYLIB direct dependency
Date: Mon, 6 Jul 2020 11:45:38 -0700 [thread overview]
Message-ID: <262dbde0-2a0e-6820-fd69-157b7f05a8c4@gmail.com> (raw)
In-Reply-To: <20200706114000.223e27eb@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 7/6/2020 11:40 AM, Jakub Kicinski wrote:
> On Sun, 5 Jul 2020 21:27:58 -0700 Florian Fainelli wrote:
>> + ops = ethtool_phy_ops;
>> + if (!ops || !ops->start_cable_test) {
>
> nit: don't think member-by-member checking is necessary. We don't
> expect there to be any alternative versions of the ops, right?
There could be, a network device driver not using PHYLIB could register
its own operations and only implement a subset of these operations.
>
>> + ret = -EOPNOTSUPP;
>> + goto out_rtnl;
>> + }
>> +
>> ret = ethnl_ops_begin(dev);
>> if (ret < 0)
>> goto out_rtnl;
>>
>> - ret = phy_start_cable_test(dev->phydev, info->extack);
>> + ret = ops->start_cable_test(dev->phydev, info->extack);
>
> nit: my personal preference would be to hide checking the ops and
> calling the member in a static inline helper.
>
> Note that we should be able to remove this from phy.h now:
I would prefer to keep thsose around in case a network device driver
cannot punt entirely onto PHYLIB and instead needs to wrap those calls
around.
>
> #if IS_ENABLED(CONFIG_PHYLIB)
> int phy_start_cable_test(struct phy_device *phydev,
> struct netlink_ext_ack *extack);
> int phy_start_cable_test_tdr(struct phy_device *phydev,
> struct netlink_ext_ack *extack,
> const struct phy_tdr_config *config);
> #else
> static inline
> int phy_start_cable_test(struct phy_device *phydev,
> struct netlink_ext_ack *extack)
> {
> NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
> return -EOPNOTSUPP;
> }
> static inline
> int phy_start_cable_test_tdr(struct phy_device *phydev,
> struct netlink_ext_ack *extack,
> const struct phy_tdr_config *config)
> {
> NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
> return -EOPNOTSUPP;
> }
> #endif
>
>
> We could even risk a direct call:
>
> #if IS_REACHABLE(CONFIG_PHYLIB)
> static inline int do_x()
> {
> return __do_x();
> }
> #else
> static inline int do_x()
> {
> if (!ops)
> return -EOPNOTSUPP;
> return ops->do_x();
> }
> #endif
>
> But that's perhaps doing too much...
Fine either way with me, let us see what Michal and Andrew think about that.
--
Florian
next prev parent reply other threads:[~2020-07-06 18:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 4:27 [PATCH net-next v2 0/3] net: ethtool: Untangle PHYLIB dependency Florian Fainelli
2020-07-06 4:27 ` [PATCH net-next v2 1/3] net: ethtool: Introduce ethtool_phy_ops Florian Fainelli
2020-07-06 4:27 ` [PATCH net-next v2 2/3] net: phy: Register ethtool PHY operations Florian Fainelli
2020-07-06 4:27 ` [PATCH net-next v2 3/3] net: ethtool: Remove PHYLIB direct dependency Florian Fainelli
2020-07-06 18:40 ` Jakub Kicinski
2020-07-06 18:45 ` Florian Fainelli [this message]
2020-07-06 18:54 ` Jakub Kicinski
2020-07-06 19:56 ` Andrew Lunn
2020-07-07 12:52 ` Michal Kubecek
2020-07-06 13:46 ` [PATCH net-next v2 0/3] net: ethtool: Untangle PHYLIB dependency Andrew Lunn
2020-07-07 22:41 ` David Miller
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=262dbde0-2a0e-6820-fd69-157b7f05a8c4@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
/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).