summaryrefslogtreecommitdiff
path: root/drivers/s390/cio
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2017-10-26 17:36:45 +0300
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2017-11-03 10:00:28 +0300
commit648a6f4495b183d4e0d8983ff768facb9a2185bb (patch)
treea8ea80bbc79bfe42948ecf2ce46ee2c754b31c76 /drivers/s390/cio
parent2a2d7befd40c95fd0d27d14edd0ec3b479fcf21f (diff)
downloadlinux-648a6f4495b183d4e0d8983ff768facb9a2185bb.tar.xz
s390/qdio: use atomic_cmpxchg
qdio uses atomic_read to find an unused indicator and atomic_set to flag it as used. This could lead to multiple users getting the same indicator. Use atomic_cmpxchg instead. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Acked-by: Ursula Braun <ubraun@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/cio')
-rw-r--r--drivers/s390/cio/qdio_thinint.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
index c61164f4528e..3e587bf426b0 100644
--- a/drivers/s390/cio/qdio_thinint.c
+++ b/drivers/s390/cio/qdio_thinint.c
@@ -56,10 +56,8 @@ static u32 *get_indicator(void)
int i;
for (i = 0; i < TIQDIO_NR_NONSHARED_IND; i++)
- if (!atomic_read(&q_indicators[i].count)) {
- atomic_set(&q_indicators[i].count, 1);
+ if (!atomic_cmpxchg(&q_indicators[i].count, 0, 1))
return &q_indicators[i].ind;
- }
/* use the shared indicator */
atomic_inc(&q_indicators[TIQDIO_SHARED_IND].count);