From fd22e4c96c585a384f713d52a2b2cc9e14ec4a05 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 24 Apr 2013 13:40:53 +0200 Subject: [PATCH] ALSA: bcm2835: don't use magic numbers on audio start/stop workqueue The bcm2835 driver uses a workqueue to defer PCM playback start and stop. Commands are passed to the function as magic numbers so is more readable to use macro constants. Also, while being there change the generic name "x" to "cmd" for the var used to pass the start/stop commands. Signed-off-by: Javier Martinez Canillas --- sound/arm/bcm2835-vchiq.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sound/arm/bcm2835-vchiq.c b/sound/arm/bcm2835-vchiq.c index c7ccc154d64252..c839546284265f 100755 --- a/sound/arm/bcm2835-vchiq.c +++ b/sound/arm/bcm2835-vchiq.c @@ -38,6 +38,9 @@ /* ---- Private Constants and Types ------------------------------------------ */ +#define BCM2835_AUDIO_STOP 0 +#define BCM2835_AUDIO_START 1 + /* Logging macros (for remapping to other logging mechanisms, i.e., printf) */ #ifdef AUDIO_DEBUG_ENABLE #define LOG_ERR( fmt, arg... ) pr_err( "%s:%d " fmt, __func__, __LINE__, ##arg) @@ -75,23 +78,23 @@ static int bcm2835_audio_start_worker(bcm2835_alsa_stream_t * alsa_stream); typedef struct { struct work_struct my_work; bcm2835_alsa_stream_t *alsa_stream; - int x; + int cmd; } my_work_t; static void my_wq_function(struct work_struct *work) { my_work_t *w = (my_work_t *) work; int ret = -9; - LOG_DBG(" .. IN %p:%d\n", w->alsa_stream, w->x); - switch (w->x) { - case 1: + LOG_DBG(" .. IN %p:%d\n", w->alsa_stream, w->cmd); + switch (w->cmd) { + case BCM2835_AUDIO_START: ret = bcm2835_audio_start_worker(w->alsa_stream); break; - case 2: + case BCM2835_AUDIO_STOP: ret = bcm2835_audio_stop_worker(w->alsa_stream); break; default: - LOG_ERR(" Unexpected work: %p:%d\n", w->alsa_stream, w->x); + LOG_ERR(" Unexpected work: %p:%d\n", w->alsa_stream, w->cmd); break; } kfree((void *)work); @@ -108,7 +111,7 @@ int bcm2835_audio_start(bcm2835_alsa_stream_t * alsa_stream) if (work) { INIT_WORK((struct work_struct *)work, my_wq_function); work->alsa_stream = alsa_stream; - work->x = 1; + work->cmd = BCM2835_AUDIO_START; if (queue_work (alsa_stream->my_wq, (struct work_struct *)work)) ret = 0; @@ -129,7 +132,7 @@ int bcm2835_audio_stop(bcm2835_alsa_stream_t * alsa_stream) if (work) { INIT_WORK((struct work_struct *)work, my_wq_function); work->alsa_stream = alsa_stream; - work->x = 2; + work->cmd = BCM2835_AUDIO_STOP; if (queue_work (alsa_stream->my_wq, (struct work_struct *)work)) ret = 0;