Re: [PATCH net-next] net: phy: micrel: Add support for lan8842

From: Andrew Lunn
Date: Mon Jul 21 2025 - 10:23:42 EST


> +static struct lan8842_hw_stat lan8842_hw_stats[] = {
> + { "phy_rx_correct_count", 2, 3, {88, 61, 60}},
> + { "phy_rx_crc_count", 2, 2, {63, 62}},
> + { "phy_tx_correct_count", 2, 3, {89, 85, 84}},
> + { "phy_tx_crc_count", 2, 2, {87, 86}},
> +};

Hi Horatiu

Please could you look at using ethtool_phy_stats via the
.get_phy_stats() phy driver op.

> +static int lan8842_config_init(struct phy_device *phydev)
> +{
> + int val;
> + int ret;
> +
> + /* Reset the PHY */
> + val = lanphy_read_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET);
> + if (val < 0)
> + return val;
> + val |= LAN8814_QSGMII_SOFT_RESET_BIT;
> + lanphy_write_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET, val);

It looks like there are sufficient pairs of
lanphy_read_page_reg()/lanphy_write_page_reg() you would be justified
adding a lanphy_modify_page_reg().

> +}, {
> + .phy_id = PHY_ID_LAN8842,
> + .phy_id_mask = MICREL_PHY_ID_MASK,

I think you could use PHY_ID_MATCH_MODEL() here. It would make it
different to every other PHY, but maybe you could start with some
cleanup patches, adding the _modify_ call etc?

Andrew