Subject: Re: [PATCH net-next v5 01/16] net: Convert PHYs hwtstamp callback to use kernel_hwtstamp_config

From: Simon Horman <[email-masked]>
Date: Tue, 10 Oct 2023 17:37:47 +0200

...

> diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
> index 7ab080ff02df..416484ea6eb3 100644
> --- a/drivers/net/phy/nxp-c45-tja11xx.c
> +++ b/drivers/net/phy/nxp-c45-tja11xx.c
> @@ -1022,24 +1022,21 @@ static bool nxp_c45_rxtstamp(struct mii_timestamper *mii_ts,
>  }
>  
>  static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
> -			    struct ifreq *ifreq)
> +			    struct kernel_hwtstamp_config *config,
> +			    struct netlink_ext_ack *extack)
>  {
>  	struct nxp_c45_phy *priv = container_of(mii_ts, struct nxp_c45_phy,
>  						mii_ts);
>  	struct phy_device *phydev = priv->phydev;
>  	const struct nxp_c45_phy_data *data;
> -	struct hwtstamp_config cfg;
>  
> -	if (copy_from_user(&cfg, ifreq->ifr_data, sizeof(cfg)))
> -		return -EFAULT;
> -
> -	if (cfg.tx_type < 0 || cfg.tx_type > HWTSTAMP_TX_ON)
> +	if (cfg->tx_type < 0 || cfg->tx_type > HWTSTAMP_TX_ON)

Hi Köry,

cfg is removed from this function by this patch, but is used here.

>  		return -ERANGE;
>  
>  	data = nxp_c45_get_data(phydev);
> -	priv->hwts_tx = cfg.tx_type;
> +	priv->hwts_tx = cfg->tx_type;
>  
> -	switch (cfg.rx_filter) {
> +	switch (cfg->rx_filter) {
>  	case HWTSTAMP_FILTER_NONE:
>  		priv->hwts_rx = 0;
>  		break;
> @@ -1047,7 +1044,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
>  	case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
>  	case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
>  		priv->hwts_rx = 1;
> -		cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> +		cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
>  		break;
>  	default:
>  		return -ERANGE;
> @@ -1074,7 +1071,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
>  		nxp_c45_clear_reg_field(phydev, &data->regmap->irq_egr_ts_en);
>  
>  nxp_c45_no_ptp_irq:
> -	return copy_to_user(ifreq->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
> +	return 0;
>  }
>  

...