]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
PCI: Remove assignment from "if" conditions
authorQuentin Lambert <lambert.quentin@gmail.com>
Sun, 7 Sep 2014 18:03:32 +0000 (20:03 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 24 Sep 2014 13:50:53 +0000 (07:50 -0600)
The following Coccinelle semantic patch was used to find and correct cases
of assignments in "if" conditions:

@@
expression var, expr;
statement S;
@@

+ var = expr;
  if(
- (var = expr)
+ var
  ) S

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/hotplug/acpi_pcihp.c
drivers/pci/hotplug/cpci_hotplug_core.c
drivers/pci/hotplug/cpcihp_zt5550.c
drivers/pci/hotplug/ibmphp_core.c
drivers/pci/hotplug/ibmphp_pci.c
drivers/pci/hotplug/ibmphp_res.c
drivers/pci/hotplug/shpchp_ctrl.c
drivers/pci/hotplug/shpchp_hpc.c
drivers/pci/pci.c

index a94d850ae228c377387d036fd0f3af7e656130c6..2cac54802567ece345141f5cb2eb2888781d4077 100644 (file)
@@ -433,7 +433,8 @@ int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle)
 {
        acpi_handle bridge_handle, parent_handle;
 
-       if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus)))
+       bridge_handle = acpi_pci_get_bridge_handle(pbus);
+       if (!bridge_handle)
                return 0;
        if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle))))
                return 0;
index 8359e29156eadf78db0063a2dee50862b84d3b19..a5a7fd8332ac1cb7557285298d2824a05f127f00 100644 (file)
@@ -125,7 +125,8 @@ disable_slot(struct hotplug_slot *hotplug_slot)
 
        /* Unconfigure device */
        dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
-       if ((retval = cpci_unconfigure_slot(slot))) {
+       retval = cpci_unconfigure_slot(slot);
+       if (retval) {
                err("%s - could not unconfigure slot %s",
                    __func__, slot_name(slot));
                goto disable_error;
@@ -141,9 +142,11 @@ disable_slot(struct hotplug_slot *hotplug_slot)
        }
        cpci_led_on(slot);
 
-       if (controller->ops->set_power)
-               if ((retval = controller->ops->set_power(slot, 0)))
+       if (controller->ops->set_power) {
+               retval = controller->ops->set_power(slot, 0);
+               if (retval)
                        goto disable_error;
+       }
 
        if (update_adapter_status(slot->hotplug_slot, 0))
                warn("failure to update adapter file");
index cfd01e93e1375196b1622de1477909fd5a897c76..7ecf34e76a61eb73ebe6418eb4b1f904a997a90f 100644 (file)
@@ -237,8 +237,9 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
        dbg("registered controller");
 
        /* Look for first device matching cPCI bus's bridge vendor and device IDs */
-       if (!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
-                                        PCI_DEVICE_ID_DEC_21154, NULL))) {
+       bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
+                                 PCI_DEVICE_ID_DEC_21154, NULL);
+       if (!bus0_dev) {
                status = -ENODEV;
                goto init_register_error;
        }
index cfe2afe6e7aa05347f0794840bf26e56943d2ef7..3efaf4c38528adc35fc693240d5b4ddb52c6d5cf 100644 (file)
@@ -1023,7 +1023,8 @@ static int enable_slot(struct hotplug_slot *hs)
        debug("ENABLING SLOT........\n");
        slot_cur = hs->private;
 
-       if ((rc = validate(slot_cur, ENABLE))) {
+       rc = validate(slot_cur, ENABLE);
+       if (rc) {
                err("validate function failed\n");
                goto error_nopower;
        }
@@ -1335,17 +1336,20 @@ static int __init ibmphp_init(void)
        for (i = 0; i < 16; i++)
                irqs[i] = 0;
 
-       if ((rc = ibmphp_access_ebda()))
+       rc = ibmphp_access_ebda();
+       if (rc)
                goto error;
        debug("after ibmphp_access_ebda()\n");
 
-       if ((rc = ibmphp_rsrc_init()))
+       rc = ibmphp_rsrc_init();
+       if (rc)
                goto error;
        debug("AFTER Resource & EBDA INITIALIZATIONS\n");
 
        max_slots = get_max_slots();
 
-       if ((rc = ibmphp_register_pci()))
+       rc = ibmphp_register_pci();
+       if (rc)
                goto error;
 
        if (init_ops()) {
@@ -1354,7 +1358,8 @@ static int __init ibmphp_init(void)
        }
 
        ibmphp_print_test();
-       if ((rc = ibmphp_hpc_start_poll_thread()))
+       rc = ibmphp_hpc_start_poll_thread();
+       if (rc)
                goto error;
 
 exit:
index 2fd296706ce7f7a056ba5a2813c97f11d68ecdd1..814cea22a9fa5f599fdd44e0af479a0552d8f274 100644 (file)
@@ -145,7 +145,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
                                case PCI_HEADER_TYPE_NORMAL:
                                        debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class);
                                        assign_alt_irq (cur_func, class_code);
-                                       if ((rc = configure_device (cur_func)) < 0) {
+                                       rc = configure_device(cur_func);
+                                       if (rc < 0) {
                                                /* We need to do this in case some other BARs were properly inserted */
                                                err ("was not able to configure devfunc %x on bus %x.\n",
                                                     cur_func->device, cur_func->busno);
@@ -157,7 +158,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
                                        break;
                                case PCI_HEADER_TYPE_MULTIDEVICE:
                                        assign_alt_irq (cur_func, class_code);
-                                       if ((rc = configure_device (cur_func)) < 0) {
+                                       rc = configure_device(cur_func);
+                                       if (rc < 0) {
                                                /* We need to do this in case some other BARs were properly inserted */
                                                err ("was not able to configure devfunc %x on bus %x...bailing out\n",
                                                     cur_func->device, cur_func->busno);
index 78cf442e36d6d23b17cf7c912703f4ce94a3ceaf..2f2fcc8f7f8beb14ca2bed0f556d92c113be49ff 100644 (file)
@@ -224,7 +224,8 @@ int __init ibmphp_rsrc_init (void)
                        if ((curr->rsrc_type & RESTYPE) == MMASK) {
                                /* no bus structure exists in place yet */
                                if (list_empty (&gbuses)) {
-                                       if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1)))
+                                       rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
+                                       if (rc)
                                                return rc;
                                        list_add_tail (&newbus->bus_list, &gbuses);
                                        debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -237,7 +238,8 @@ int __init ibmphp_rsrc_init (void)
                                                        return rc;
                                        } else {
                                                /* went through all the buses and didn't find ours, need to create a new bus node */
-                                               if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1)))
+                                               rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
+                                               if (rc)
                                                        return rc;
 
                                                list_add_tail (&newbus->bus_list, &gbuses);
@@ -248,7 +250,8 @@ int __init ibmphp_rsrc_init (void)
                                /* prefetchable memory */
                                if (list_empty (&gbuses)) {
                                        /* no bus structure exists in place yet */
-                                       if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1)))
+                                       rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
+                                       if (rc)
                                                return rc;
                                        list_add_tail (&newbus->bus_list, &gbuses);
                                        debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -261,7 +264,8 @@ int __init ibmphp_rsrc_init (void)
                                                        return rc;
                                        } else {
                                                /* went through all the buses and didn't find ours, need to create a new bus node */
-                                               if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1)))
+                                               rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
+                                               if (rc)
                                                        return rc;
                                                list_add_tail (&newbus->bus_list, &gbuses);
                                                debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -271,7 +275,8 @@ int __init ibmphp_rsrc_init (void)
                                /* IO */
                                if (list_empty (&gbuses)) {
                                        /* no bus structure exists in place yet */
-                                       if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1)))
+                                       rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
+                                       if (rc)
                                                return rc;
                                        list_add_tail (&newbus->bus_list, &gbuses);
                                        debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -283,7 +288,8 @@ int __init ibmphp_rsrc_init (void)
                                                        return rc;
                                        } else {
                                                /* went through all the buses and didn't find ours, need to create a new bus node */
-                                               if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1)))
+                                               rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
+                                               if (rc)
                                                        return rc;
                                                list_add_tail (&newbus->bus_list, &gbuses);
                                                debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -1153,7 +1159,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
                                }
                        } else {
                                /* in the same range */
-                               if ((len_tmp = res_cur->start - 1 - res_prev->end - 1) >= res->len) {
+                               len_tmp = res_cur->start - 1 - res_prev->end - 1;
+
+                               if (len_tmp >= res->len) {
                                        if ((len_tmp < len_cur) || (len_cur == 0)) {
                                                if (((res_prev->end + 1) % tmp_divide) == 0) {
                                                        /* just perfect, starting address's divisible by length */
@@ -1212,7 +1220,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
                                break;
                }
                while (range) {
-                       if ((len_tmp = range->end - range->start) >= res->len) {
+                       len_tmp = range->end - range->start;
+
+                       if (len_tmp >= res->len) {
                                if ((len_tmp < len_cur) || (len_cur == 0)) {
                                        if ((range->start % tmp_divide) == 0) {
                                                /* just perfect, starting address's divisible by length */
@@ -1276,7 +1286,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
                                        break;
                        }
                        while (range) {
-                               if ((len_tmp = range->end - range->start) >= res->len) {
+                               len_tmp = range->end - range->start;
+
+                               if (len_tmp >= res->len) {
                                        if ((len_tmp < len_cur) || (len_cur == 0)) {
                                                if ((range->start % tmp_divide) == 0) {
                                                        /* just perfect, starting address's divisible by length */
index 764650b4de3ff464f30b1d3e6ba99b23368f4538..10c7927599b32aa1d67d67d3f299f079333b5c8c 100644 (file)
@@ -195,7 +195,8 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
        int rc = 0;
 
        ctrl_dbg(ctrl, "Change speed to %d\n", speed);
-       if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
+       rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed);
+       if (rc) {
                ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
                         __func__);
                return WRONG_BUS_FREQUENCY;
@@ -261,14 +262,16 @@ static int board_added(struct slot *p_slot)
        }
 
        if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
-               if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
+               rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz);
+               if (rc) {
                        ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
                                 __func__);
                        return WRONG_BUS_FREQUENCY;
                }
 
                /* turn on board, blink green LED, turn off Amber LED */
-               if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
+               rc = p_slot->hpc_ops->slot_enable(p_slot);
+               if (rc) {
                        ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
                        return rc;
                }
@@ -296,7 +299,8 @@ static int board_added(struct slot *p_slot)
                return rc;
 
        /* turn on board, blink green LED, turn off Amber LED */
-       if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
+       rc = p_slot->hpc_ops->slot_enable(p_slot);
+       if (rc) {
                ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
                return rc;
        }
index 1d89916351ed06a190fe42797b57e6f72678caa9..7d223e9080efb34aef5b1d02f77732c77b812402 100644 (file)
@@ -466,7 +466,8 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
        u8 m66_cap  = !!(slot_reg & MHZ66_CAP);
        u8 pi, pcix_cap;
 
-       if ((retval = hpc_get_prog_int(slot, &pi)))
+       retval = hpc_get_prog_int(slot, &pi);
+       if (retval)
                return retval;
 
        switch (pi) {
index 2c9ac70254e2dc480a868f4717319b4d01294a02..8b63a5b11fc67856d018d5a3ec282812ba91e5c3 100644 (file)
@@ -1003,12 +1003,19 @@ int pci_save_state(struct pci_dev *dev)
        for (i = 0; i < 16; i++)
                pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);
        dev->state_saved = true;
-       if ((i = pci_save_pcie_state(dev)) != 0)
+
+       i = pci_save_pcie_state(dev);
+       if (i != 0)
                return i;
-       if ((i = pci_save_pcix_state(dev)) != 0)
+
+       i = pci_save_pcix_state(dev);
+       if (i != 0)
                return i;
-       if ((i = pci_save_vc_state(dev)) != 0)
+
+       i = pci_save_vc_state(dev);
+       if (i != 0)
                return i;
+
        return 0;
 }
 EXPORT_SYMBOL(pci_save_state);