From: Uros Bizjak Date: Wed, 13 Jul 2022 15:19:46 +0000 (+0200) Subject: ALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update X-Git-Tag: v6.0-rc1~93^2~9^2~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89422df9548002adfffb73799cebe4909cfc8902;p=thirdparty%2Fkernel%2Flinux.git ALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update 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 Link: https://lore.kernel.org/r/20220713151946.4743-1-ubizjak@gmail.com Signed-off-by: Takashi Iwai --- diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index f9c921683948d..0d7b73bf79450 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -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); } /**