]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mlxsw: spectrum_span: Reduce nesting in mlxsw_sp_span_entry_configure()
authorAmit Cohen <amitc@mellanox.com>
Fri, 24 Apr 2020 15:43:41 +0000 (18:43 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Apr 2020 22:41:51 +0000 (15:41 -0700)
Use early return to avoid unnecessary nesting.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c

index 9fb2e9d93929c6ea10d969783c32f1ff491a22e2..e7be1bfe7f75727f72d80aa3608670b7fe1523ba 100644 (file)
@@ -622,18 +622,27 @@ mlxsw_sp_span_entry_configure(struct mlxsw_sp *mlxsw_sp,
                              struct mlxsw_sp_span_entry *span_entry,
                              struct mlxsw_sp_span_parms sparms)
 {
-       if (sparms.dest_port) {
-               if (sparms.dest_port->mlxsw_sp != mlxsw_sp) {
-                       netdev_err(span_entry->to_dev, "Cannot mirror to %s, which belongs to a different mlxsw instance",
-                                  sparms.dest_port->dev->name);
-                       sparms.dest_port = NULL;
-               } else if (span_entry->ops->configure(span_entry, sparms)) {
-                       netdev_err(span_entry->to_dev, "Failed to offload mirror to %s",
-                                  sparms.dest_port->dev->name);
-                       sparms.dest_port = NULL;
-               }
+       int err;
+
+       if (!sparms.dest_port)
+               goto set_parms;
+
+       if (sparms.dest_port->mlxsw_sp != mlxsw_sp) {
+               netdev_err(span_entry->to_dev, "Cannot mirror to %s, which belongs to a different mlxsw instance",
+                          sparms.dest_port->dev->name);
+               sparms.dest_port = NULL;
+               goto set_parms;
+       }
+
+       err = span_entry->ops->configure(span_entry, sparms);
+       if (err) {
+               netdev_err(span_entry->to_dev, "Failed to offload mirror to %s",
+                          sparms.dest_port->dev->name);
+               sparms.dest_port = NULL;
+               goto set_parms;
        }
 
+set_parms:
        span_entry->parms = sparms;
 }