thunderbolt: Get rid of redundant 'else'
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 27 Mar 2023 17:20:16 +0000 (20:20 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 29 Mar 2023 08:05:05 +0000 (11:05 +0300)
In the snippets like the following

if (...)
return / goto / break / continue ...;
else
...

the 'else' is redundant. Get rid of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/acpi.c
drivers/thunderbolt/ctl.c
drivers/thunderbolt/nhi.c
drivers/thunderbolt/switch.c
drivers/thunderbolt/usb4.c
drivers/thunderbolt/xdomain.c

index 628225deb8fef2f0b44cb95205edebdd246ea021..3514bf65b7a49e7c825b8191d8c61e636db06a9f 100644 (file)
@@ -341,7 +341,7 @@ static struct acpi_device *tb_acpi_find_companion(struct device *dev)
         */
        if (tb_is_switch(dev))
                return tb_acpi_switch_find_companion(tb_to_switch(dev));
-       else if (tb_is_usb4_port_device(dev))
+       if (tb_is_usb4_port_device(dev))
                return acpi_find_child_by_adr(ACPI_COMPANION(dev->parent),
                                              tb_to_usb4_port_device(dev)->port->port);
        return NULL;
index 6e7d28e8d81aaffa064c02ec40b0288f9a6d876c..3a213322ec7a9dae5082bdfe5de970494c30f015 100644 (file)
@@ -1033,7 +1033,7 @@ static int tb_cfg_get_error(struct tb_ctl *ctl, enum tb_cfg_space space,
 
        if (res->tb_error == TB_CFG_ERROR_LOCK)
                return -EACCES;
-       else if (res->tb_error == TB_CFG_ERROR_PORT_NOT_CONNECTED)
+       if (res->tb_error == TB_CFG_ERROR_PORT_NOT_CONNECTED)
                return -ENOTCONN;
 
        return -EIO;
index 4dce2edd86ea0f9a4d223f2f6047e8a7db03d42e..4400e1383e3ea516c2839903c815c314af402a4b 100644 (file)
@@ -515,7 +515,8 @@ static int nhi_alloc_hop(struct tb_nhi *nhi, struct tb_ring *ring)
                         ring->hop);
                ret = -EBUSY;
                goto err_unlock;
-       } else if (!ring->is_tx && nhi->rx_rings[ring->hop]) {
+       }
+       if (!ring->is_tx && nhi->rx_rings[ring->hop]) {
                dev_warn(&nhi->pdev->dev, "RX hop %d already allocated\n",
                         ring->hop);
                ret = -EBUSY;
index 3370e18ba05f9348c37ec526bbd7641f2673225b..0a34880a66363b6a1b9a08b1d076544313e14677 100644 (file)
@@ -271,9 +271,9 @@ static int nvm_authenticate(struct tb_switch *sw, bool auth_only)
                }
                sw->nvm->authenticating = true;
                return usb4_switch_nvm_authenticate(sw);
-       } else if (auth_only) {
-               return -EOPNOTSUPP;
        }
+       if (auth_only)
+               return -EOPNOTSUPP;
 
        sw->nvm->authenticating = true;
        if (!tb_route(sw)) {
index 1e5e9c147a310da3627f38f11296d0345e7f529c..28e3ec2d7633fc6b447ad680b4a73dc02163ee82 100644 (file)
@@ -851,7 +851,7 @@ bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in)
         */
        if (ret == -EOPNOTSUPP)
                return true;
-       else if (ret)
+       if (ret)
                return false;
 
        return !status;
@@ -877,7 +877,7 @@ int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in)
                             &status);
        if (ret == -EOPNOTSUPP)
                return 0;
-       else if (ret)
+       if (ret)
                return ret;
 
        return status ? -EBUSY : 0;
@@ -900,7 +900,7 @@ int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in)
                             &status);
        if (ret == -EOPNOTSUPP)
                return 0;
-       else if (ret)
+       if (ret)
                return ret;
 
        return status ? -EIO : 0;
index a48335c95d39be5efca46eb6a2dbdae501044df1..e2b54887d3313e6a7adc6f9dc3e5bbf7a5946056 100644 (file)
@@ -1178,9 +1178,8 @@ static int tb_xdomain_get_uuid(struct tb_xdomain *xd)
                if (xd->state_retries-- > 0) {
                        dev_dbg(&xd->dev, "failed to request UUID, retrying\n");
                        return -EAGAIN;
-               } else {
-                       dev_dbg(&xd->dev, "failed to read remote UUID\n");
                }
+               dev_dbg(&xd->dev, "failed to read remote UUID\n");
                return ret;
        }
 
@@ -1367,12 +1366,10 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd)
                        dev_dbg(&xd->dev,
                                "failed to request remote properties, retrying\n");
                        return -EAGAIN;
-               } else {
-                       /* Give up now */
-                       dev_err(&xd->dev,
-                               "failed read XDomain properties from %pUb\n",
-                               xd->remote_uuid);
                }
+               /* Give up now */
+               dev_err(&xd->dev, "failed read XDomain properties from %pUb\n",
+                       xd->remote_uuid);
 
                return ret;
        }
@@ -2179,13 +2176,12 @@ static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw,
                                if (xd->remote_uuid &&
                                    uuid_equal(xd->remote_uuid, lookup->uuid))
                                        return xd;
-                       } else if (lookup->link &&
-                                  lookup->link == xd->link &&
-                                  lookup->depth == xd->depth) {
-                               return xd;
-                       } else if (lookup->route &&
-                                  lookup->route == xd->route) {
-                               return xd;
+                       } else {
+                               if (lookup->link && lookup->link == xd->link &&
+                                   lookup->depth == xd->depth)
+                                       return xd;
+                               if (lookup->route && lookup->route == xd->route)
+                                       return xd;
                        }
                } else if (tb_port_has_remote(port)) {
                        xd = switch_find_xdomain(port->remote->sw, lookup);