b2af97443caaee5b989e2e8b0cefb181e6d90874
[openwrt/staging/ldir.git] /
1 From 1120b4699738a3ee748314c433a96e45182a3411 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Tue, 4 Sep 2018 17:58:33 +0200
4 Subject: [PATCH] staging: bcm2835-audio: Remove redundant substream
5 mask checks
6
7 commit 14b1f4cba853a11c7b381ad919622f38eb194bd7 upstream.
8
9 The avail_substreams bit mask is checked for the possible racy
10 accesses, but this cannot happen in practice; i.e. the assignment and
11 the check are superfluous.
12
13 Let's rip them off.
14
15 Signed-off-by: Takashi Iwai <tiwai@suse.de>
16 Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 ---
19 .../vc04_services/bcm2835-audio/bcm2835-ctl.c | 2 --
20 .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 8 --------
21 .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 17 +++++++----------
22 .../vc04_services/bcm2835-audio/bcm2835.c | 5 +----
23 .../vc04_services/bcm2835-audio/bcm2835.h | 2 --
24 5 files changed, 8 insertions(+), 26 deletions(-)
25
26 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
27 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
28 @@ -64,8 +64,6 @@ static int snd_bcm2835_ctl_get(struct sn
29
30 mutex_lock(&chip->audio_mutex);
31
32 - BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
33 -
34 if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
35 ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
36 else if (kcontrol->private_value == PCM_PLAYBACK_MUTE)
37 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
38 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
39 @@ -118,14 +118,6 @@ static int snd_bcm2835_playback_open_gen
40 goto out;
41 }
42
43 - /* Check if we are ready */
44 - if (!(chip->avail_substreams & (1 << idx))) {
45 - /* We are not ready yet */
46 - audio_error("substream(%d) device is not ready yet\n", idx);
47 - err = -EAGAIN;
48 - goto out;
49 - }
50 -
51 alsa_stream = kzalloc(sizeof(*alsa_stream), GFP_KERNEL);
52 if (!alsa_stream) {
53 err = -ENOMEM;
54 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
55 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
56 @@ -523,16 +523,13 @@ int bcm2835_audio_set_ctls(struct bcm283
57
58 /* change ctls for all substreams */
59 for (i = 0; i < MAX_SUBSTREAMS; i++) {
60 - if (chip->avail_substreams & (1 << i)) {
61 - if (!chip->alsa_stream[i]) {
62 - LOG_DBG(" No ALSA stream available?! %i:%p (%x)\n", i, chip->alsa_stream[i], chip->avail_substreams);
63 - ret = 0;
64 - } else if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) {
65 - LOG_ERR("Couldn't set the controls for stream %d\n", i);
66 - ret = -1;
67 - } else {
68 - LOG_DBG(" Controls set for stream %d\n", i);
69 - }
70 + if (!chip->alsa_stream[i])
71 + continue;
72 + if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) {
73 + LOG_ERR("Couldn't set the controls for stream %d\n", i);
74 + ret = -1;
75 + } else {
76 + LOG_DBG(" Controls set for stream %d\n", i);
77 }
78 }
79 return ret;
80 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
81 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
82 @@ -280,7 +280,7 @@ static int snd_add_child_device(struct d
83 struct snd_card *card;
84 struct device *child;
85 struct bcm2835_chip *chip;
86 - int err, i;
87 + int err;
88
89 child = snd_create_device(device, &audio_driver->driver,
90 audio_driver->driver.name);
91 @@ -325,9 +325,6 @@ static int snd_add_child_device(struct d
92 return err;
93 }
94
95 - for (i = 0; i < numchans; i++)
96 - chip->avail_substreams |= (1 << i);
97 -
98 err = snd_card_register(card);
99 if (err) {
100 dev_err(child, "Failed to register card, error %d\n", err);
101 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
102 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
103 @@ -98,8 +98,6 @@ struct bcm2835_chip {
104 struct snd_card *card;
105 struct snd_pcm *pcm;
106 struct snd_pcm *pcm_spdif;
107 - /* Bitmat for valid reg_base and irq numbers */
108 - unsigned int avail_substreams;
109 struct device *dev;
110 struct bcm2835_alsa_stream *alsa_stream[MAX_SUBSTREAMS];
111