From: Simon Horman <horms@kernel.org>
To: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
corbet@lwn.net, steen.hegelund@microchip.com,
rdunlap@infradead.org, casper.casan@gmail.com, andrew@lunn.ch,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
horatiu.vultur@microchip.com, Woojung.Huh@microchip.com,
Nicolas.Ferre@microchip.com, UNGLinuxDriver@microchip.com,
Thorsten.Kummermehr@microchip.com
Subject: Re: [RFC PATCH net-next 5/6] microchip: lan865x: add driver support for Microchip's LAN865X MACPHY
Date: Sun, 10 Sep 2023 19:44:53 +0200 [thread overview]
Message-ID: <20230910174453.GK775887@kernel.org> (raw)
In-Reply-To: <20230908142919.14849-6-Parthiban.Veerasooran@microchip.com>
On Fri, Sep 08, 2023 at 07:59:18PM +0530, Parthiban Veerasooran wrote:
> The LAN8650/1 is designed to conform to the OPEN Alliance 10BASE‑T1x
> MAC‑PHY Serial Interface specification, Version 1.1. The IEEE Clause 4
> MAC integration provides the low pin count standard SPI interface to any
> microcontroller therefore providing Ethernet functionality without
> requiring MAC integration within the microcontroller. The LAN8650/1
> operates as an SPI client supporting SCLK clock rates up to a maximum of
> 25 MHz. This SPI interface supports the transfer of both data (Ethernet
> frames) and control (register access).
>
> By default, the chunk data payload is 64 bytes in size. A smaller payload
> data size of 32 bytes is also supported and may be configured in the
> Chunk Payload Size (CPS) field of the Configuration 0 (OA_CONFIG0)
> register. Changing the chunk payload size requires the LAN8650/1 be reset
> and shall not be done during normal operation.
>
> The Ethernet Media Access Controller (MAC) module implements a 10 Mbps
> half duplex Ethernet MAC, compatible with the IEEE 802.3 standard.
> 10BASE-T1S physical layer transceiver integrated into the LAN8650/1. The
> PHY and MAC are connected via an internal Media Independent Interface
> (MII).
>
> Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
Hi Parthiban,
thanks for your patches.
Some minor feedback on this one follows.
...
> diff --git a/drivers/net/ethernet/microchip/lan865x.c b/drivers/net/ethernet/microchip/lan865x.c
...
> +static int lan865x_set_hw_macaddr(struct net_device *netdev)
> +{
> + u32 regval;
> + bool ret;
> + struct lan865x_priv *priv = netdev_priv(netdev);
> + const u8 *mac = netdev->dev_addr;
Please arrange local variables in Networking code in reverse xmas tree
order - longest line to shortest.
This tool can be of assistance here:
https://github.com/ecree-solarflare/xmastree
...
> +static int lan865x_probe(struct spi_device *spi)
> +{
> + struct net_device *netdev;
> + struct lan865x_priv *priv;
> + u32 regval;
> + int ret;
> +
> + netdev = alloc_etherdev(sizeof(struct lan865x_priv));
> + if (!netdev)
> + return -ENOMEM;
> +
> + priv = netdev_priv(netdev);
> + priv->netdev = netdev;
> + priv->spi = spi;
> + priv->msg_enable = 0;
> + spi_set_drvdata(spi, priv);
> + SET_NETDEV_DEV(netdev, &spi->dev);
> +
> + ret = lan865x_get_dt_data(priv);
> + if (ret)
> + return ret;
> +
> + spi->rt = true;
> + spi_setup(spi);
> +
> + priv->tc6 = oa_tc6_init(spi, netdev);
> + if (!priv->tc6) {
> + ret = -ENOMEM;
> + goto error_oa_tc6_init;
> + }
> +
> + if (priv->cps == 32) {
> + regval = CCS_Q0_TX_CFG_32;
> + ret = oa_tc6_write_register(priv->tc6, CCS_Q0_TX_CFG, ®val, 1);
> + if (ret)
> + return ret;
> +
> + regval = CCS_Q0_RX_CFG_32;
> + ret = oa_tc6_write_register(priv->tc6, CCS_Q0_RX_CFG, ®val, 1);
> + if (ret)
> + return ret;
> + }
> +
> + if (oa_tc6_configure(priv->tc6, priv->cps, priv->protected, priv->txcte,
> + priv->rxcte))
> + goto err_macphy_config;
Jumping to err_macphy_config will result in this function returning ret.
However, ret will be 0 at this point. Perhaps it should be set to an
error value.
Flagged by Smatch.
> +
> + ret = lan865x_phy_init(priv);
> + if (ret)
> + goto error_phy;
> +
> + if (device_get_ethdev_address(&spi->dev, netdev))
> + eth_hw_addr_random(netdev);
> +
> + ret = lan865x_set_hw_macaddr(netdev);
> + if (ret) {
> + if (netif_msg_probe(priv))
> + dev_err(&spi->dev, "Failed to configure MAC");
> + goto error_set_mac;
> + }
> +
> + netdev->if_port = IF_PORT_10BASET;
> + netdev->irq = spi->irq;
> + netdev->netdev_ops = &lan865x_netdev_ops;
> + netdev->watchdog_timeo = TX_TIMEOUT;
> + netdev->ethtool_ops = &lan865x_ethtool_ops;
> + ret = register_netdev(netdev);
> + if (ret) {
> + if (netif_msg_probe(priv))
> + dev_err(&spi->dev, "Register netdev failed (ret = %d)",
> + ret);
> + goto error_netdev_register;
> + }
> +
> + phy_start(priv->phydev);
> + return 0;
> +
> +error_netdev_register:
> +error_set_mac:
> + phy_disconnect(priv->phydev);
> + mdiobus_unregister(priv->mdiobus);
> + mdiobus_free(priv->mdiobus);
> +error_phy:
> +err_macphy_config:
> + oa_tc6_deinit(priv->tc6);
> +error_oa_tc6_init:
> + free_netdev(priv->netdev);
> + return ret;
> +}
...
next prev parent reply other threads:[~2023-09-10 17:45 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 14:29 [RFC PATCH net-next 0/6] Add support for OPEN Alliance 10BASE-T1x MACPHY Serial Interface Parthiban Veerasooran
2023-09-08 14:29 ` [RFC PATCH net-next 1/6] net: ethernet: implement OPEN Alliance control transaction interface Parthiban Veerasooran
2023-09-09 13:33 ` Andrew Lunn
2023-09-12 13:03 ` Parthiban.Veerasooran
2023-09-13 1:32 ` Andrew Lunn
2023-09-21 12:27 ` Parthiban.Veerasooran
2023-09-21 19:16 ` Andrew Lunn
2023-09-22 4:31 ` Parthiban.Veerasooran
2023-09-13 1:36 ` Andrew Lunn
2023-09-19 11:40 ` Parthiban.Veerasooran
2023-09-13 2:11 ` Andrew Lunn
2023-09-19 11:38 ` Parthiban.Veerasooran
2023-09-19 15:13 ` Andrew Lunn
2023-09-20 12:40 ` Parthiban.Veerasooran
2023-09-20 13:37 ` Andrew Lunn
2023-09-21 9:15 ` Parthiban.Veerasooran
2023-09-13 2:16 ` Andrew Lunn
2023-09-19 11:13 ` Parthiban.Veerasooran
2023-09-19 12:58 ` Andrew Lunn
2023-09-21 12:36 ` Parthiban.Veerasooran
2023-09-21 19:19 ` Andrew Lunn
2023-09-22 4:39 ` Parthiban.Veerasooran
2023-09-26 12:54 ` Fwd: " Parthiban.Veerasooran
2023-09-08 14:29 ` [RFC PATCH net-next 2/6] net: ethernet: add mac-phy interrupt support with reset complete handling Parthiban Veerasooran
2023-09-09 13:39 ` Andrew Lunn
2023-09-12 12:44 ` Parthiban.Veerasooran
2023-09-13 2:19 ` Andrew Lunn
2023-09-19 11:04 ` Parthiban.Veerasooran
2023-09-11 12:51 ` Ziyang Xuan (William)
2023-09-12 12:10 ` Andrew Lunn
2023-09-12 12:28 ` Parthiban.Veerasooran
2023-09-13 2:39 ` Andrew Lunn
2023-09-19 13:07 ` Parthiban.Veerasooran
2023-09-19 13:21 ` Lukasz Majewski
2023-09-13 8:44 ` Lukasz Majewski
2023-09-13 12:36 ` Andrew Lunn
2023-09-13 13:26 ` Lukasz Majewski
2023-09-19 13:40 ` Parthiban.Veerasooran
2023-09-19 13:51 ` Lukasz Majewski
2023-09-08 14:29 ` [RFC PATCH net-next 3/6] net: ethernet: implement OA TC6 configuration function Parthiban Veerasooran
2023-09-14 0:46 ` Andrew Lunn
2023-09-19 10:57 ` Parthiban.Veerasooran
2023-09-19 12:54 ` Andrew Lunn
2023-09-20 12:42 ` Parthiban.Veerasooran
2023-09-08 14:29 ` [RFC PATCH net-next 4/6] net: ethernet: implement data transaction interface Parthiban Veerasooran
2023-09-10 17:58 ` Simon Horman
2023-09-12 13:47 ` Parthiban.Veerasooran
2023-09-11 12:59 ` Ziyang Xuan (William)
2023-09-12 10:32 ` Parthiban.Veerasooran
2023-09-14 1:18 ` Andrew Lunn
2023-09-18 10:02 ` Parthiban.Veerasooran
2023-09-18 13:01 ` Andrew Lunn
2023-09-19 10:12 ` Parthiban.Veerasooran
2023-09-08 14:29 ` [RFC PATCH net-next 5/6] microchip: lan865x: add driver support for Microchip's LAN865X MACPHY Parthiban Veerasooran
2023-09-10 17:44 ` Simon Horman [this message]
2023-09-12 10:53 ` Parthiban.Veerasooran
2023-09-11 13:17 ` Ziyang Xuan (William)
2023-09-12 11:41 ` Parthiban.Veerasooran
2023-09-14 1:51 ` Andrew Lunn
2023-09-19 9:18 ` Parthiban.Veerasooran
2023-09-19 12:50 ` Andrew Lunn
2023-09-20 12:53 ` Parthiban.Veerasooran
2023-09-14 1:55 ` Andrew Lunn
2023-09-18 11:23 ` Parthiban.Veerasooran
2023-09-15 13:01 ` David Wretman
2023-09-18 11:22 ` Parthiban.Veerasooran
2023-09-08 14:29 ` [RFC PATCH net-next 6/6] microchip: lan865x: add device-tree " Parthiban Veerasooran
2023-09-10 10:55 ` Krzysztof Kozlowski
2023-09-12 12:15 ` Parthiban.Veerasooran
2023-09-12 13:17 ` Krzysztof Kozlowski
2023-09-19 10:51 ` Parthiban.Veerasooran
2023-09-14 2:07 ` Andrew Lunn
2023-09-19 10:40 ` Parthiban.Veerasooran
2023-09-10 10:55 ` [RFC PATCH net-next 0/6] Add support for OPEN Alliance 10BASE-T1x MACPHY Serial Interface Krzysztof Kozlowski
2023-09-13 13:26 ` Parthiban.Veerasooran
2023-09-13 15:45 ` Krzysztof Kozlowski
2023-09-18 9:23 ` Parthiban.Veerasooran
2023-09-15 13:56 ` Alexander Dahl
2023-09-15 14:22 ` Andrew Lunn
2023-09-18 6:16 ` Parthiban.Veerasooran
2023-09-18 6:12 ` Parthiban.Veerasooran
2023-09-18 9:02 ` Fwd: " Parthiban.Veerasooran
2023-09-19 9:03 ` Parthiban.Veerasooran
2023-09-19 16:23 ` Jay Monkman
2023-09-19 18:09 ` Hennerich, Michael
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=20230910174453.GK775887@kernel.org \
--to=horms@kernel.org \
--cc=Nicolas.Ferre@microchip.com \
--cc=Parthiban.Veerasooran@microchip.com \
--cc=Thorsten.Kummermehr@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=casper.casan@gmail.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horatiu.vultur@microchip.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=steen.hegelund@microchip.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).