[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c1d557b6-7f11-449e-aff7-dad974e1c7c9@lunn.ch>
Date: Thu, 13 Feb 2025 21:13:05 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jijie Shao <shaojijie@...wei.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org,
shenjian15@...wei.com, wangpeiyang1@...wei.com,
liuyonglong@...wei.com, chenhao418@...wei.com,
sudongming1@...wei.com, xujunsheng@...wei.com,
shiyongbang@...wei.com, libaihan@...wei.com,
jonathan.cameron@...wei.com, shameerali.kolothum.thodi@...wei.com,
salil.mehta@...wei.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 7/7] net: hibmcge: Add ioctl supported in this
module
On Thu, Feb 13, 2025 at 11:55:29AM +0800, Jijie Shao wrote:
> This patch implements the ioctl interface to
> read and write the PHY register.
>
> Signed-off-by: Jijie Shao <shaojijie@...wei.com>
> ---
> .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 18 ++++++++++++++++++
> .../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 10 ++++++++++
> .../net/ethernet/hisilicon/hibmcge/hbg_mdio.h | 2 ++
> 3 files changed, 30 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
> index 78999d41f41d..afd04ed65eee 100644
> --- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
> +++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
> @@ -273,6 +273,23 @@ static netdev_features_t hbg_net_fix_features(struct net_device *netdev,
> return features & HBG_SUPPORT_FEATURES;
> }
>
> +static int hbg_net_eth_ioctl(struct net_device *dev, struct ifreq *ifr, s32 cmd)
> +{
> + struct hbg_priv *priv = netdev_priv(dev);
> +
> + if (test_bit(HBG_NIC_STATE_RESETTING, &priv->state))
> + return -EBUSY;
> +
> + switch (cmd) {
> + case SIOCGMIIPHY:
> + case SIOCGMIIREG:
> + case SIOCSMIIREG:
> + return hbg_mdio_ioctl(priv, ifr, cmd);
> + default:
> + return -EOPNOTSUPP;
> + }
No need for this switch statement. phy_mii_ioctl() will return
EOPNOTSUPP for any it does not support.
The general structure of an IOCTL handler is to have a switch
statements for any IOCTL which are handled at this level and the
default: case then calls into the next layer down.
> +int hbg_mdio_ioctl(struct hbg_priv *priv, struct ifreq *ifr, int cmd)
> +{
> + struct hbg_mac *mac = &priv->mac;
> +
> + if (!mac->phydev)
> + return -ENODEV;
> +
> + return phy_mii_ioctl(mac->phydev, ifr, cmd);
phy_do_ioctl(). This is assuming you follow the normal pattern of
keeping the phydev pointer in the net_device structure.
Andrew
Powered by blists - more mailing lists