powerpc/eeh: atomic_dec_if_positive() to update passthru count
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Thu, 27 Aug 2015 05:58:27 +0000 (15:58 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Oct 2015 09:31:58 +0000 (20:31 +1100)
No need to have two atomic opertions (update and fetch/check) when
decreasing PE's number of passed devices as one atomic operation
is enough.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/eeh.c

index 00ba5de12256c7d7d15d786ff82ba78cd7185d8a..893978c980da169160c25827289ab1a304c75db1 100644 (file)
@@ -1412,8 +1412,7 @@ void eeh_dev_release(struct pci_dev *pdev)
                goto out;
 
        /* Decrease PE's pass through count */
-       atomic_dec(&edev->pe->pass_dev_cnt);
-       WARN_ON(atomic_read(&edev->pe->pass_dev_cnt) < 0);
+       WARN_ON(atomic_dec_if_positive(&edev->pe->pass_dev_cnt) < 0);
        eeh_pe_change_owner(edev->pe);
 out:
        mutex_unlock(&eeh_dev_mutex);