staging: bcm2835-audio: refactor code for compaction
Subsystems (3)
v2 cover staging: bcm2835-audio: refactor code for compaction
This patch fixes two code style issues:
- Merge two if condiitonals doing the same work
- Removes initialisation of unused semaphores
Changes in v2:
- Removed the semaphores from struct bcm2835_alsa_stream and not just their initialisation
Aishwarya Pant (2):
staging: bcm2835-audio: merge two if conditions into one
staging: bcm2835-audio: remove unused semaphores
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 8 ++------ drivers/staging/vc04_services/bcm2835-audio/bcm2835.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/2 staging: bcm2835-audio: merge two if conditions into one
Patch merges two if conditions doing the same work into one.
--- drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +2 -4
@@ -122,10 +122,8 @@ static int snd_bcm2835_playback_open_generic(audio_info ("Alsa open (%d)\n" , substream->number); idx = substream->number; -if (spdif && chip->opened) { - err = -EBUSY ; - goto out; - }else if (!spdif && (chip->opened & (1 << idx))) { +if ((spdif && chip->opened) || + (!spdif && (chip->opened & (1 << idx)))) { err = -EBUSY ; goto out; }
Signature · 1 line
2.7.4
PATCH v2 2/2 staging: bcm2835-audio: remove unused semaphores
In reply to Aishwarya PantThis patch removes unused semaphores alsa_stream->buffers_update_sem and alsa_stream->control_sem from struct bcm2835_alsa_stream
---
Changes in v2:
- Remove the unused semaphores from struct bcm2835_alsa_stream
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 2 -- drivers/staging/vc04_services/bcm2835-audio/bcm2835.h | 2 -- 2 files changed, 4 deletions(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +0 -2
@@ -154,8 +154,6 @@ static int snd_bcm2835_playback_open_generic( alsa_stream->substream = substream; alsa_stream->idx = idx; -sema_init (&alsa_stream->buffers_update_sem,0 ); -sema_init (&alsa_stream->control_sem,0 );spin_lock_init (&alsa_stream->lock); err =bcm2835_audio_open (alsa_stream);
drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +0 -2
@@ -122,8 +122,6 @@ struct bcm2835_alsa_stream {struct snd_pcm_substream *substream;struct snd_pcm_indirect pcm_indirect; -struct semaphore buffers_update_sem; -struct semaphore control_sem;spinlock_t lock;volatile unsigned int control;volatile unsigned int status;
Signature · 1 line
2.7.4
Greg Kroah-Hartman
maintainerRe: [Outreachy kernel] [PATCH v2 1/2] staging: bcm2835-audio: merge two if conditions into one
In reply to Aishwarya PantQuoted 12 lines · Aishwarya Pant
Patch merges two if conditions doing the same work into one.
Signed-off-by Aishwarya Pant <[email protected]>--- drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +0
-0
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c static int snd_bcm2835_playback_open_generic( · line 126
Quoted 9 lines
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +2
-4@@ -122,10 +122,8 @@ static int snd_bcm2835_playback_open_generic(audio_info ("Alsa open (%d)\n" , substream->number); idx = substream->number; -if (spdif && chip->opened) { - err = -EBUSY ; - goto out; - }else if (!spdif && (chip->opened & (1 << idx))) { +if ((spdif && chip->opened) || + (!spdif && (chip->opened & (1 << idx)))) {
But now it's a lot harder to read and understand, right? Please keep the original, it's not incorrect.
There are _so_ many real things to fix in this driver, don't make minor tweaks for no reason.
thanks,
greg k-h