Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <ubizjak@gmail.com>
Link: https://lore.kernel.org/r/20220713151946.4743-1-ubizjak@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Uros Bizjak and committed by
Takashi Iwai
89422df9 281dee67

+1 -1
+1 -1
sound/usb/endpoint.c
··· 133 133 134 134 static inline bool ep_state_update(struct snd_usb_endpoint *ep, int old, int new) 135 135 { 136 - return atomic_cmpxchg(&ep->state, old, new) == old; 136 + return atomic_try_cmpxchg(&ep->state, &old, new); 137 137 } 138 138 139 139 /**