]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update
authorUros Bizjak <ubizjak@gmail.com>
Wed, 13 Jul 2022 15:19:46 +0000 (17:19 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Jul 2022 08:49:25 +0000 (10:49 +0200)
Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old in
ep_state_update. x86 CMPXCHG instruction returns success in ZF flag,
so this change saves a compare after cmpxchg (and related move instruction
in front of cmpxchg).

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Link: https://lore.kernel.org/r/20220713151946.4743-1-ubizjak@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/endpoint.c

index f9c921683948d1b8e45db3a1773161960495826f..0d7b73bf7945063cda7bd50d81c65327dde5ef2a 100644 (file)
@@ -133,7 +133,7 @@ static inline bool ep_state_running(struct snd_usb_endpoint *ep)
 
 static inline bool ep_state_update(struct snd_usb_endpoint *ep, int old, int new)
 {
-       return atomic_cmpxchg(&ep->state, old, new) == old;
+       return atomic_try_cmpxchg(&ep->state, &old, new);
 }
 
 /**