staging: line6: avoid __sync_fetch_and_{and,or}

__sync_fetch_and_and and __sync_fetch_and_or are functions that are provided
by gcc and depending on the target architecture may be implemented in libgcc,
which is not always available in the kernel. This leads to a build failure
on ARMv5:

drivers/built-in.o: In function `line6_pcm_release':
:(.text+0x3bfe80): undefined reference to `__sync_fetch_and_and_4'
drivers/built-in.o: In function `line6_pcm_acquire':
:(.text+0x3bff30): undefined reference to `__sync_fetch_and_or_4'

To work around this, we can use the kernel-provided cmpxchg macro.

Build-tested only.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Markus Grabner <grabner@icg.tugraz.at>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Arnd Bergmann 2013-06-21 21:55:35 +02:00 committed by Greg Kroah-Hartman
parent 5c1f62a75c
commit 9f61360148

View File

@ -107,11 +107,15 @@ static bool test_flags(unsigned long flags0, unsigned long flags1,
int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
{ {
unsigned long flags_old = unsigned long flags_old, flags_new, flags_final;
__sync_fetch_and_or(&line6pcm->flags, channels); int err;
unsigned long flags_new = flags_old | channels;
unsigned long flags_final = flags_old; do {
int err = 0; flags_old = ACCESS_ONCE(line6pcm->flags);
flags_new = flags_old | channels;
} while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old);
flags_final = flags_old;
line6pcm->prev_fbuf = NULL; line6pcm->prev_fbuf = NULL;
@ -197,9 +201,12 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels)
{ {
unsigned long flags_old = unsigned long flags_old, flags_new;
__sync_fetch_and_and(&line6pcm->flags, ~channels);
unsigned long flags_new = flags_old & ~channels; do {
flags_old = ACCESS_ONCE(line6pcm->flags);
flags_new = flags_old & ~channels;
} while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old);
if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM))
line6_unlink_audio_in_urbs(line6pcm); line6_unlink_audio_in_urbs(line6pcm);