PCI: Remove unnecessary "if" statement
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 10 Sep 2015 10:40:31 +0000 (18:40 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 18 Sep 2015 20:55:07 +0000 (15:55 -0500)
In store_remove_id(), set the default return value to -ENODEV, and
overwrite it with the input buffer size if we find a matching list entry.
Then we don't need to test whether to return an error or the count.

No functional change.

[bhelgaas: changelog]
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci-driver.c

index dd652f2ae03db964ed539c5d369092173ab9ab33..2865ba37e2954c90ba9f796b8284c86d74f08c6a 100644 (file)
@@ -172,7 +172,7 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
        __u32 vendor, device, subvendor = PCI_ANY_ID,
                subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
        int fields = 0;
-       int retval = -ENODEV;
+       size_t retval = -ENODEV;
 
        fields = sscanf(buf, "%x %x %x %x %x %x",
                        &vendor, &device, &subvendor, &subdevice,
@@ -190,15 +190,13 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
                    !((id->class ^ class) & class_mask)) {
                        list_del(&dynid->node);
                        kfree(dynid);
-                       retval = 0;
+                       retval = count;
                        break;
                }
        }
        spin_unlock(&pdrv->dynids.lock);
 
-       if (retval)
-               return retval;
-       return count;
+       return retval;
 }
 static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);