Re: [PATCH] net: pch_gbe: return errors from MIIM accesses

From: Maxime Chevallier

Date: Thu Jun 25 2026 - 03:37:55 EST




On 6/25/26 05:05, Pengpeng Hou wrote:
> pch_gbe_mac_ctrl_miim() polls for the MIIM controller to become ready,
> but returns zero on the initial ready timeout and ignores the completion
> timeout after issuing the operation. MDIO and PHY helpers can then report
> success with zero or stale data.
>
> Make the MIIM helper return an errno and pass read data through an output
> parameter. Propagate the error through the MDIO read path, the probe-time
> PHY discovery path, and the internal PHY register helpers that already
> return an error status.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> .../net/ethernet/oki-semi/pch_gbe/pch_gbe.h | 4 +-
> .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 54 ++++++++++++++-----
> .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.c | 22 +++++---
> 3 files changed, 57 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
> index 108f312bc542..4bdf0afca462 100644
> --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
> +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
> @@ -619,6 +619,6 @@ void pch_gbe_set_ethtool_ops(struct net_device *netdev);
>
> /* pch_gbe_mac.c */
> s32 pch_gbe_mac_force_mac_fc(struct pch_gbe_hw *hw);
> -u16 pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,
> - u16 data);
> +int pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,
> + u16 data, u16 *read_data);

You should look and replicate what other mdio accessors do, that is return a
negative value on error, and the actual value otherwise.

Maxime