Commit 4feb0f37 authored by Tuomas Tynkkynen's avatar Tuomas Tynkkynen Committed by Greg Kroah-Hartman

staging: bcm2835-audio: Check if workqueue allocation failed

Currently, if allocating a workqueue fails, the driver will probe
successfully but it will silently do nothing, which is rather silly.
So instead bail out with -ENOMEM in bcm2835_audio_open() if
alloc_workqueue() fails, and remove the now pointless checks for a NULL
workqueue.

While at it, get rid of the rather pointless one-line function
my_workqueue_init().
Signed-off-by: default avatarTuomas Tynkkynen <tuomas@tuxera.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 81f34e96
...@@ -117,7 +117,6 @@ static void my_wq_function(struct work_struct *work) ...@@ -117,7 +117,6 @@ static void my_wq_function(struct work_struct *work)
int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream) int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream)
{ {
if (alsa_stream->my_wq) {
struct bcm2835_audio_work *work; struct bcm2835_audio_work *work;
work = kmalloc(sizeof(*work), GFP_ATOMIC); work = kmalloc(sizeof(*work), GFP_ATOMIC);
...@@ -133,13 +132,11 @@ int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream) ...@@ -133,13 +132,11 @@ int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream)
kfree(work); kfree(work);
return -EBUSY; return -EBUSY;
} }
}
return 0; return 0;
} }
int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream) int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream)
{ {
if (alsa_stream->my_wq) {
struct bcm2835_audio_work *work; struct bcm2835_audio_work *work;
work = kmalloc(sizeof(*work), GFP_ATOMIC); work = kmalloc(sizeof(*work), GFP_ATOMIC);
...@@ -155,14 +152,12 @@ int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream) ...@@ -155,14 +152,12 @@ int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream)
kfree(work); kfree(work);
return -EBUSY; return -EBUSY;
} }
}
return 0; return 0;
} }
int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream,
unsigned int count, void *src) unsigned int count, void *src)
{ {
if (alsa_stream->my_wq) {
struct bcm2835_audio_work *work; struct bcm2835_audio_work *work;
work = kmalloc(sizeof(*work), GFP_ATOMIC); work = kmalloc(sizeof(*work), GFP_ATOMIC);
...@@ -180,22 +175,14 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, ...@@ -180,22 +175,14 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream,
kfree(work); kfree(work);
return -EBUSY; return -EBUSY;
} }
}
return 0; return 0;
} }
static void my_workqueue_init(struct bcm2835_alsa_stream *alsa_stream)
{
alsa_stream->my_wq = alloc_workqueue("my_queue", WQ_HIGHPRI, 1);
}
static void my_workqueue_quit(struct bcm2835_alsa_stream *alsa_stream) static void my_workqueue_quit(struct bcm2835_alsa_stream *alsa_stream)
{ {
if (alsa_stream->my_wq) {
flush_workqueue(alsa_stream->my_wq); flush_workqueue(alsa_stream->my_wq);
destroy_workqueue(alsa_stream->my_wq); destroy_workqueue(alsa_stream->my_wq);
alsa_stream->my_wq = NULL; alsa_stream->my_wq = NULL;
}
} }
static void audio_vchi_callback(void *param, static void audio_vchi_callback(void *param,
...@@ -436,7 +423,9 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) ...@@ -436,7 +423,9 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
int status; int status;
int ret; int ret;
my_workqueue_init(alsa_stream); alsa_stream->my_wq = alloc_workqueue("my_queue", WQ_HIGHPRI, 1);
if (!alsa_stream->my_wq)
return -ENOMEM;
ret = bcm2835_audio_open_connection(alsa_stream); ret = bcm2835_audio_open_connection(alsa_stream);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment