brcm2708: organize kernel patches
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.19 / 950-0394-staging-bcm2835-audio-Remove-redundant-substream-mas.patch
diff --git a/target/linux/brcm2708/patches-4.19/950-0394-staging-bcm2835-audio-Remove-redundant-substream-mas.patch b/target/linux/brcm2708/patches-4.19/950-0394-staging-bcm2835-audio-Remove-redundant-substream-mas.patch
new file mode 100644 (file)
index 0000000..b2af974
--- /dev/null
@@ -0,0 +1,111 @@
+From 1120b4699738a3ee748314c433a96e45182a3411 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Tue, 4 Sep 2018 17:58:33 +0200
+Subject: [PATCH] staging: bcm2835-audio: Remove redundant substream
+ mask checks
+
+commit 14b1f4cba853a11c7b381ad919622f38eb194bd7 upstream.
+
+The avail_substreams bit mask is checked for the possible racy
+accesses, but this cannot happen in practice; i.e. the assignment and
+the check are superfluous.
+
+Let's rip them off.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ .../vc04_services/bcm2835-audio/bcm2835-ctl.c   |  2 --
+ .../vc04_services/bcm2835-audio/bcm2835-pcm.c   |  8 --------
+ .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 17 +++++++----------
+ .../vc04_services/bcm2835-audio/bcm2835.c       |  5 +----
+ .../vc04_services/bcm2835-audio/bcm2835.h       |  2 --
+ 5 files changed, 8 insertions(+), 26 deletions(-)
+
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
+@@ -64,8 +64,6 @@ static int snd_bcm2835_ctl_get(struct sn
+       mutex_lock(&chip->audio_mutex);
+-      BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
+-
+       if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
+               ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
+       else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+@@ -118,14 +118,6 @@ static int snd_bcm2835_playback_open_gen
+               goto out;
+       }
+-      /* Check if we are ready */
+-      if (!(chip->avail_substreams & (1 << idx))) {
+-              /* We are not ready yet */
+-              audio_error("substream(%d) device is not ready yet\n", idx);
+-              err = -EAGAIN;
+-              goto out;
+-      }
+-
+       alsa_stream = kzalloc(sizeof(*alsa_stream), GFP_KERNEL);
+       if (!alsa_stream) {
+               err = -ENOMEM;
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
+@@ -523,16 +523,13 @@ int bcm2835_audio_set_ctls(struct bcm283
+       /* change ctls for all substreams */
+       for (i = 0; i < MAX_SUBSTREAMS; i++) {
+-              if (chip->avail_substreams & (1 << i)) {
+-                      if (!chip->alsa_stream[i]) {
+-                              LOG_DBG(" No ALSA stream available?! %i:%p (%x)\n", i, chip->alsa_stream[i], chip->avail_substreams);
+-                              ret = 0;
+-                      } else if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) {
+-                              LOG_ERR("Couldn't set the controls for stream %d\n", i);
+-                              ret = -1;
+-                      } else {
+-                              LOG_DBG(" Controls set for stream %d\n", i);
+-                      }
++              if (!chip->alsa_stream[i])
++                      continue;
++              if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) {
++                      LOG_ERR("Couldn't set the controls for stream %d\n", i);
++                      ret = -1;
++              } else {
++                      LOG_DBG(" Controls set for stream %d\n", i);
+               }
+       }
+       return ret;
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
+@@ -280,7 +280,7 @@ static int snd_add_child_device(struct d
+       struct snd_card *card;
+       struct device *child;
+       struct bcm2835_chip *chip;
+-      int err, i;
++      int err;
+       child = snd_create_device(device, &audio_driver->driver,
+                                 audio_driver->driver.name);
+@@ -325,9 +325,6 @@ static int snd_add_child_device(struct d
+               return err;
+       }
+-      for (i = 0; i < numchans; i++)
+-              chip->avail_substreams |= (1 << i);
+-
+       err = snd_card_register(card);
+       if (err) {
+               dev_err(child, "Failed to register card, error %d\n", err);
+--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
++++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
+@@ -98,8 +98,6 @@ struct bcm2835_chip {
+       struct snd_card *card;
+       struct snd_pcm *pcm;
+       struct snd_pcm *pcm_spdif;
+-      /* Bitmat for valid reg_base and irq numbers */
+-      unsigned int avail_substreams;
+       struct device *dev;
+       struct bcm2835_alsa_stream *alsa_stream[MAX_SUBSTREAMS];