This patch is just a minor cleanup to go through and group all of the
variables into one declaration instead of a long string of single
declarations for each int.  It also changes the direction for a couple
loops as we are able to loop with less code this way as testing against 0
can be done as a part of the decrement operation.

Signed-off-by: Alexander Duyck <adu...@mirantis.com>
---
 drivers/pci/iov.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index cecc242c1af0..c0fc88fa7c4d 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -241,15 +241,11 @@ int __weak pcibios_sriov_disable(struct pci_dev *pdev)
 
 static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 {
-       int rc;
-       int i;
-       int nres;
        u16 offset, stride, initial;
        struct resource *res;
        struct pci_dev *pdev;
        struct pci_sriov *iov = dev->sriov;
-       int bars = 0;
-       int bus;
+       int rc, i, nres, bars, bus;
 
        if (!nr_virtfn)
                return 0;
@@ -271,8 +267,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
        if (!offset || (nr_virtfn > 1 && !stride))
                return -EIO;
 
-       nres = 0;
-       for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
+       for (nres = 0, bars = 0, i = PCI_SRIOV_NUM_BARS; i--;) {
                bars |= (1 << (i + PCI_IOV_RESOURCES));
                res = &dev->resource[i + PCI_IOV_RESOURCES];
                if (res->parent)
@@ -366,13 +361,13 @@ err_pcibios:
 
 static void sriov_disable(struct pci_dev *dev)
 {
-       int i;
        struct pci_sriov *iov = dev->sriov;
+       int i = iov->num_VFs;
 
        if (!iov->num_VFs)
                return;
 
-       for (i = 0; i < iov->num_VFs; i++)
+       while (i--)
                virtfn_remove(dev, i, 0);
 
        pcibios_sriov_disable(dev);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to