From: Jijie Shao <shaojijie@huawei.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <shaojijie@huawei.com>, <yisen.zhuang@huawei.com>,
<salil.mehta@huawei.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <shenjian15@huawei.com>,
<wangpeiyang1@huawei.com>, <liuyonglong@huawei.com>,
<sudongming1@huawei.com>, <xujunsheng@huawei.com>,
<shiyongbang@huawei.com>, <jdamato@fastly.com>,
<jonathan.cameron@huawei.com>,
<shameerali.kolothum.thodi@huawei.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH V2 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module
Date: Fri, 16 Aug 2024 11:07:45 +0800 [thread overview]
Message-ID: <e2f0e003-b5a4-4068-b923-eda6f7accd63@huawei.com> (raw)
In-Reply-To: <23628b1a-d3ea-47ed-8289-60e455a90b72@lunn.ch>
on 2024/8/16 10:14, Andrew Lunn wrote:
>> +int hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
>> +{
>> + if (speed != HBG_PORT_MODE_SGMII_10M &&
>> + speed != HBG_PORT_MODE_SGMII_100M &&
>> + speed != HBG_PORT_MODE_SGMII_1000M)
>> + return -EOPNOTSUPP;
>> +
>> + if (duplex != DUPLEX_FULL && duplex != DUPLEX_HALF)
>> + return -EOPNOTSUPP;
>
> Can this happen? We try to avoid defensive code, preferring to ensure
> it can never happen. So long as you have told phylib the limits of
> your hardware, it should enforce these.
Ok, I'll delete these.
>
>> @@ -26,11 +27,11 @@ static int hbg_init(struct hbg_priv *priv)
>> return dev_err_probe(dev, PTR_ERR(regmap), "failed to init regmap\n");
>>
>> priv->regmap = regmap;
>> - ret = hbg_hw_event_notify(priv, HBG_HW_EVENT_INIT);
>> + ret = hbg_hw_init(priv);
>> if (ret)
>> return ret;
>>
>> - return hbg_hw_dev_specs_init(priv);
>> + return hbg_mdio_init(priv);
> I've not read the previous patches, but that looks odd. Why is code
> you just added in previous patches getting replaced?
In previous patch, we did not introduce the hbg_hw_init().
In this patch, the hbg_hw_init() is introduced,
and the hbg_hw_event_notify() and hbg_hw_dev_specs_init() functions are moved to hbg_hw_init().
hbg_hw_init() can be moved to the previous patch.
>
>> +static int hbg_phy_connect(struct hbg_priv *priv)
>> +{
>> + struct phy_device *phydev = priv->mac.phydev;
>> + struct device *dev = &priv->pdev->dev;
>> + struct hbg_mac *mac = &priv->mac;
>> + int ret;
>> +
>> + ret = phy_connect_direct(priv->netdev, mac->phydev, hbg_phy_adjust_link,
>> + PHY_INTERFACE_MODE_SGMII);
>> + if (ret)
>> + return dev_err_probe(dev, -ENOMEM, "failed to connect phy\n");
> Don't replace the error code. Doing so actually makes dev_err_probe()
> pointless because it is not going to see the EPROBE_DEFER.
>
Sorry, It is a mistake.
I'll fix it in the next version.
>> +int hbg_mdio_init(struct hbg_priv *priv)
>> +{
>> + struct device *dev = &priv->pdev->dev;
>> + struct hbg_mac *mac = &priv->mac;
>> + struct phy_device *phydev;
>> + struct mii_bus *mdio_bus;
>> + int ret;
>> +
>> + mac->phy_addr = priv->dev_specs.phy_addr;
>> + mdio_bus = devm_mdiobus_alloc(dev);
>> + if (!mdio_bus)
>> + return dev_err_probe(dev, -ENOMEM, "failed to alloc MDIO bus\n");
>> +
>> + mdio_bus->parent = dev;
>> + mdio_bus->priv = priv;
>> + mdio_bus->phy_mask = ~(1 << mac->phy_addr);
>> + mdio_bus->name = "hibmcge mii bus";
>> + mac->mdio_bus = mdio_bus;
>> +
>> + mdio_bus->read = hbg_mdio_read22;
>> + mdio_bus->write = hbg_mdio_write22;
>> + snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s-%s", "mii", dev_name(dev));
>> +
>> + ret = devm_mdiobus_register(dev, mdio_bus);
>> + if (ret)
>> + return dev_err_probe(dev, ret, "failed to register MDIO bus\n");
>> +
>> + phydev = mdiobus_get_phy(mdio_bus, mac->phy_addr);
>> + if (!phydev)
>> + return dev_err_probe(dev, -EIO, "failed to get phy device\n");
> ENODEV is probably better, since the device does not exist.
>
> Andrew
Thanks a lot!
Jijie Shao
next prev parent reply other threads:[~2024-08-16 3:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 13:56 [RFC PATCH V2 net-next 00/11] Add support of HIBMCGE Ethernet Driver Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 01/11] net: hibmcge: Add pci table supported in this module Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 02/11] net: hibmcge: Add read/write registers supported through the bar space Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module Jijie Shao
2024-08-16 2:14 ` Andrew Lunn
2024-08-16 3:07 ` Jijie Shao [this message]
2024-08-16 2:25 ` Andrew Lunn
2024-08-16 6:10 ` Jijie Shao
2024-08-16 21:04 ` Andrew Lunn
2024-08-17 1:11 ` Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 04/11] net: hibmcge: Add interrupt " Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 05/11] net: hibmcge: Implement some .ndo functions Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 08/11] net: hibmcge: Implement some ethtool_ops functions Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 09/11] net: hibmcge: Add a Makefile and update Kconfig for hibmcge Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 10/11] net: hibmcge: Add maintainer " Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 11/11] net: add is_valid_ether_addr check in dev_set_mac_address Jijie Shao
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=e2f0e003-b5a4-4068-b923-eda6f7accd63@huawei.com \
--to=shaojijie@huawei.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=jonathan.cameron@huawei.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shenjian15@huawei.com \
--cc=shiyongbang@huawei.com \
--cc=sudongming1@huawei.com \
--cc=wangpeiyang1@huawei.com \
--cc=xujunsheng@huawei.com \
--cc=yisen.zhuang@huawei.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®