Re: [PATCH net-next v4 4/6] net: ravb: Move the update of ndev->features to ravb_set_features()

From: Sergey Shtylyov
Date: Wed Feb 14 2024 - 11:55:50 EST


On 2/14/24 4:57 PM, Claudiu wrote:

> From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
>
> Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth")
> introduced support for setting GbEth features. With this the IP-specific
> features update functions update the ndev->features individually.
>
> Next commits add runtime PM support for the ravb driver. The runtime PM
> implementation will enable/disable the IP clocks on
> the ravb_open()/ravb_close() functions. Accessing the IP registers with
> clocks disabled blocks the system.
>
> The ravb_set_features() function could be executed when the Ethernet
> interface is closed so we need to ensure we don't access IP registers while
> the interface is down when runtime PM support will be in place.
>
> For these, move the update of ndev->features to ravb_set_features(). In
> this way we update the ndev->features only when the IP-specific features
> set function returns success and we can avoid code duplication when
> introducing runtime PM registers protection.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
[...]

Reviewed-by: Sergey Shtylyov <s.shtylyov@xxxxxx>

> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 7a7f743a1fef..ac23779d1cc5 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -2567,8 +2564,15 @@ static int ravb_set_features(struct net_device *ndev,
> {
> struct ravb_private *priv = netdev_priv(ndev);
> const struct ravb_hw_info *info = priv->info;
> + int ret;

I'd use 'error' here, it would fit well... :-)

> +
> + ret = info->set_feature(ndev, features);
> + if (ret)
> + return ret;
>
> - return info->set_feature(ndev, features);
> + ndev->features = features;
> +
> + return 0;
> }
>
> static const struct net_device_ops ravb_netdev_ops = {

MBR, Sergey