All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: Jian Shen <shenjian15@huawei.com>,
	Salil Mehta <salil.mehta@huawei.com>,
	Jijie Shao <shaojijie@huawei.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	Geetha sowjanya <gakula@marvell.com>,
	Subbaraya Sundeep <sbhatta@marvell.com>,
	Bharat Bhushan <bbhushan2@marvell.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Brett Creeley <brett.creeley@amd.com>,
	Paul Barker <paul@pbarker.dev>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	linux-renesas-soc@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Simon Horman <horms@kernel.org>,
	Jacob Keller <jacob.e.keller@intel.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next 4/6] net: ravb: convert to ndo_hwtstamp API
Date: Thu, 16 Oct 2025 20:17:37 +0200	[thread overview]
Message-ID: <20251016181737.GD856714@ragnatech.se> (raw)
In-Reply-To: <20251016180727.3511399-5-vadim.fedorenko@linux.dev>

Hi Vadim,

Thanks for your work.

On 2025-10-16 18:07:25 +0000, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_set()/.ndo_hwtstamp_get callbacks.
> ravb_do_ioctl() becomes pure phy_do_ioctl_running(), remove it and
> replace in callbacks.
> 
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 61 ++++++++----------------
>  1 file changed, 19 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 9d3bd65b85ff..113d7c7bd921 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2390,41 +2390,38 @@ static int ravb_close(struct net_device *ndev)
>  	return 0;
>  }
>  
> -static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req)
> +static int ravb_hwtstamp_get(struct net_device *ndev,
> +			     struct kernel_hwtstamp_config *config)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> -	struct hwtstamp_config config;
>  
> -	config.flags = 0;
> -	config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON :
> -						HWTSTAMP_TX_OFF;
> +	config->flags = 0;
> +	config->tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON :
> +						 HWTSTAMP_TX_OFF;
>  	switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) {
>  	case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT:
> -		config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> +		config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
>  		break;
>  	case RAVB_RXTSTAMP_TYPE_ALL:
> -		config.rx_filter = HWTSTAMP_FILTER_ALL;
> +		config->rx_filter = HWTSTAMP_FILTER_ALL;
>  		break;
>  	default:
> -		config.rx_filter = HWTSTAMP_FILTER_NONE;
> +		config->rx_filter = HWTSTAMP_FILTER_NONE;
>  	}
>  
> -	return copy_to_user(req->ifr_data, &config, sizeof(config)) ?
> -		-EFAULT : 0;
> +	return 0;
>  }
>  
>  /* Control hardware time stamping */
> -static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)
> +static int ravb_hwtstamp_set(struct net_device *ndev,
> +			     struct kernel_hwtstamp_config *config,
> +			     struct netlink_ext_ack *extack)
>  {
>  	struct ravb_private *priv = netdev_priv(ndev);
> -	struct hwtstamp_config config;
>  	u32 tstamp_rx_ctrl = RAVB_RXTSTAMP_ENABLED;
>  	u32 tstamp_tx_ctrl;
>  
> -	if (copy_from_user(&config, req->ifr_data, sizeof(config)))
> -		return -EFAULT;
> -
> -	switch (config.tx_type) {
> +	switch (config->tx_type) {
>  	case HWTSTAMP_TX_OFF:
>  		tstamp_tx_ctrl = 0;
>  		break;
> @@ -2435,7 +2432,7 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)
>  		return -ERANGE;
>  	}
>  
> -	switch (config.rx_filter) {
> +	switch (config->rx_filter) {
>  	case HWTSTAMP_FILTER_NONE:
>  		tstamp_rx_ctrl = 0;
>  		break;
> @@ -2443,36 +2440,14 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)
>  		tstamp_rx_ctrl |= RAVB_RXTSTAMP_TYPE_V2_L2_EVENT;
>  		break;
>  	default:
> -		config.rx_filter = HWTSTAMP_FILTER_ALL;
> +		config->rx_filter = HWTSTAMP_FILTER_ALL;
>  		tstamp_rx_ctrl |= RAVB_RXTSTAMP_TYPE_ALL;
>  	}
>  
>  	priv->tstamp_tx_ctrl = tstamp_tx_ctrl;
>  	priv->tstamp_rx_ctrl = tstamp_rx_ctrl;
>  
> -	return copy_to_user(req->ifr_data, &config, sizeof(config)) ?
> -		-EFAULT : 0;
> -}
> -
> -/* ioctl to device function */
> -static int ravb_do_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
> -{
> -	struct phy_device *phydev = ndev->phydev;
> -
> -	if (!netif_running(ndev))
> -		return -EINVAL;
> -
> -	if (!phydev)
> -		return -ENODEV;
> -
> -	switch (cmd) {
> -	case SIOCGHWTSTAMP:
> -		return ravb_hwtstamp_get(ndev, req);
> -	case SIOCSHWTSTAMP:
> -		return ravb_hwtstamp_set(ndev, req);
> -	}
> -
> -	return phy_mii_ioctl(phydev, req, cmd);
> +	return 0;
>  }
>  
>  static int ravb_change_mtu(struct net_device *ndev, int new_mtu)
> @@ -2608,11 +2583,13 @@ static const struct net_device_ops ravb_netdev_ops = {
>  	.ndo_get_stats		= ravb_get_stats,
>  	.ndo_set_rx_mode	= ravb_set_rx_mode,
>  	.ndo_tx_timeout		= ravb_tx_timeout,
> -	.ndo_eth_ioctl		= ravb_do_ioctl,
> +	.ndo_eth_ioctl		= phy_do_ioctl_running,
>  	.ndo_change_mtu		= ravb_change_mtu,
>  	.ndo_validate_addr	= eth_validate_addr,
>  	.ndo_set_mac_address	= eth_mac_addr,
>  	.ndo_set_features	= ravb_set_features,
> +	.ndo_hwtstamp_get	= ravb_hwtstamp_get,
> +	.ndo_hwtstamp_set	= ravb_hwtstamp_set,
>  };
>  
>  /* MDIO bus init function */
> -- 
> 2.47.3
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2025-10-16 18:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 18:07 [PATCH net-next 0/6] convert net drivers to ndo_hwtstamp API part 2 Vadim Fedorenko
2025-10-16 18:07 ` [PATCH net-next 1/6] octeontx2: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-16 18:14   ` Jacob Keller
2025-10-16 18:07 ` [PATCH net-next 2/6] mlx4: " Vadim Fedorenko
2025-10-16 18:16   ` Jacob Keller
2025-10-16 18:07 ` [PATCH net-next 3/6] ionic: " Vadim Fedorenko
2025-10-16 18:17   ` Jacob Keller
2025-10-16 18:07 ` [PATCH net-next 4/6] net: ravb: " Vadim Fedorenko
2025-10-16 18:17   ` Niklas Söderlund [this message]
2025-10-16 18:17   ` Jacob Keller
2025-10-16 18:07 ` [PATCH net-next 5/6] net: renesas: rswitch: " Vadim Fedorenko
2025-10-16 18:18   ` Jacob Keller
2025-10-16 18:07 ` [PATCH net-next 6/6] net: hns3: add hwtstamp_get/hwtstamp_set ops Vadim Fedorenko
2025-10-16 18:19   ` Jacob Keller
2025-10-17  9:15   ` Simon Horman
2025-10-17 10:22     ` Vadim Fedorenko
2025-10-17 11:19   ` kernel test robot
2025-10-16 18:20 ` [PATCH net-next 0/6] convert net drivers to ndo_hwtstamp API part 2 Jacob Keller

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=20251016181737.GD856714@ragnatech.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=andrew+netdev@lunn.ch \
    --cc=bbhushan2@marvell.com \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --cc=richardcochran@gmail.com \
    --cc=salil.mehta@huawei.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=tariqt@nvidia.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vladimir.oltean@nxp.com \
    --cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.