Move the NETIF_F_HW_TC capability check and the runtime PM suspend guard from macb_setup_taprio() into the common macb_setup_tc() entry point. These preconditions apply to all hardware TC offload paths routed through ndo_setup_tc(), not just TAPRIO. Centralizing them avoids duplicating the same checks as new TC qdisc types are added. Signed-off-by: Vineeth Karumanchi --- drivers/net/ethernet/cadence/macb_main.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 29c93df1444c..508d952e2ae7 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4499,18 +4499,8 @@ static void macb_taprio_destroy(struct net_device *ndev) static int macb_setup_taprio(struct net_device *ndev, struct tc_taprio_qopt_offload *taprio) { - struct macb *bp = netdev_priv(ndev); int err = 0; - if (unlikely(!(ndev->hw_features & NETIF_F_HW_TC))) - return -EOPNOTSUPP; - - /* Check if Device is in runtime suspend */ - if (unlikely(pm_runtime_suspended(&bp->pdev->dev))) { - netdev_err(ndev, "Device is in runtime suspend\n"); - return -EOPNOTSUPP; - } - switch (taprio->cmd) { case TAPRIO_CMD_REPLACE: err = macb_taprio_setup_replace(ndev, taprio); @@ -4528,9 +4518,22 @@ static int macb_setup_taprio(struct net_device *ndev, static int macb_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) { + struct macb *bp; + if (!dev || !type_data) return -EINVAL; + bp = netdev_priv(dev); + + if (unlikely(!(dev->hw_features & NETIF_F_HW_TC))) + return -EOPNOTSUPP; + + /* Check if Device is in runtime suspend */ + if (unlikely(pm_runtime_suspended(&bp->pdev->dev))) { + netdev_err(dev, "Device is in runtime suspend\n"); + return -EOPNOTSUPP; + } + switch (type) { case TC_SETUP_QDISC_TAPRIO: return macb_setup_taprio(dev, type_data); -- 2.44.4