Skip to content

Commit 85c7863

Browse files
committed
Merge branch 'vcap_get_rule-return-value'
Ruan Jinjie says: ==================== net: Update and fix return value check for vcap_get_rule() As Simon Horman suggests, update vcap_get_rule() to always return an ERR_PTR() and update the error detection conditions to use IS_ERR(), which would be more cleaner. So se IS_ERR() to update the return value and fix the issue in lan966x_ptp_add_trap(). Changes in v2: - Update vcap_get_rule() to always return an ERR_PTR(). - Update the return value fix in lan966x_ptp_add_trap(). - Update the return value check in sparx5_tc_free_rule_resources(). ==================== Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 44a696d + 95b358e commit 85c7863

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int lan966x_ptp_add_trap(struct lan966x_port *port,
5959
int err;
6060

6161
vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
62-
if (vrule) {
62+
if (!IS_ERR(vrule)) {
6363
u32 value, mask;
6464

6565
/* Just modify the ingress port mask and exit */
@@ -106,7 +106,7 @@ static int lan966x_ptp_del_trap(struct lan966x_port *port,
106106
int err;
107107

108108
vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
109-
if (!vrule)
109+
if (IS_ERR(vrule))
110110
return -EEXIST;
111111

112112
vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK, &value, &mask);

drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ static int sparx5_tc_free_rule_resources(struct net_device *ndev,
12741274
int ret = 0;
12751275

12761276
vrule = vcap_get_rule(vctrl, rule_id);
1277-
if (!vrule || IS_ERR(vrule))
1277+
if (IS_ERR(vrule))
12781278
return -EINVAL;
12791279

12801280
sparx5_tc_free_psfp_resources(sparx5, vrule);

drivers/net/ethernet/microchip/vcap/vcap_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id)
24292429

24302430
elem = vcap_get_locked_rule(vctrl, id);
24312431
if (!elem)
2432-
return NULL;
2432+
return ERR_PTR(-ENOENT);
24332433

24342434
rule = vcap_decode_rule(elem);
24352435
mutex_unlock(&elem->admin->lock);

0 commit comments

Comments
 (0)