992e25acd484eccf56ff666fc4b3d53727ecc708
[oweals/openwrt.git] /
1 From ccb1027324d96202cc4703d714b30f734b98df66 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Tue, 4 Sep 2018 17:58:37 +0200
4 Subject: [PATCH 441/782] staging: bcm2835-audio: Drop useless running flag and
5  check
6
7 commit 02f2376321d75e78117f39ff81f215254ee6b4ef upstream.
8
9 The running flag of alsa_stream is basically useless.  The running
10 state is strictly controlled in ALSA PCM core side, hence the check in
11 PCM trigger and close callbacks are superfluous.
12
13 Also, the prefill ack at trigger start became superfluous nowadays
14 with the ALSA PCM core update.
15
16 Let's rip them off.
17
18 Signed-off-by: Takashi Iwai <tiwai@suse.de>
19 Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 ---
22  .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 46 ++++---------------
23  .../vc04_services/bcm2835-audio/bcm2835.h     |  1 -
24  2 files changed, 8 insertions(+), 39 deletions(-)
25
26 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
27 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
28 @@ -187,19 +187,6 @@ static int snd_bcm2835_playback_close(st
29  
30         audio_info("Alsa close\n");
31  
32 -       /*
33 -        * Call stop if it's still running. This happens when app
34 -        * is force killed and we don't get a stop trigger.
35 -        */
36 -       if (alsa_stream->running) {
37 -               int err;
38 -
39 -               err = bcm2835_audio_stop(alsa_stream);
40 -               alsa_stream->running = 0;
41 -               if (err)
42 -                       audio_error(" Failed to STOP alsa device\n");
43 -       }
44 -
45         alsa_stream->period_size = 0;
46         alsa_stream->buffer_size = 0;
47  
48 @@ -324,27 +311,13 @@ static int snd_bcm2835_pcm_trigger(struc
49  
50         switch (cmd) {
51         case SNDRV_PCM_TRIGGER_START:
52 -               audio_debug("bcm2835_AUDIO_TRIGGER_START running=%d\n",
53 -                       alsa_stream->running);
54 -               if (!alsa_stream->running) {
55 -                       err = bcm2835_audio_start(alsa_stream);
56 -                       if (!err) {
57 -                               alsa_stream->pcm_indirect.hw_io =
58 -                                       alsa_stream->pcm_indirect.hw_data =
59 -                                       bytes_to_frames(runtime,
60 -                                       alsa_stream->pos);
61 -                               substream->ops->ack(substream);
62 -                               alsa_stream->running = 1;
63 -                               alsa_stream->draining = 1;
64 -                       } else {
65 -                               audio_error(" Failed to START alsa device (%d)\n", err);
66 -                       }
67 -               }
68 +               err = bcm2835_audio_start(alsa_stream);
69 +               if (!err)
70 +                       alsa_stream->draining = 1;
71 +               else
72 +                       audio_error(" Failed to START alsa device (%d)\n", err);
73                 break;
74         case SNDRV_PCM_TRIGGER_STOP:
75 -               audio_debug
76 -                       ("bcm2835_AUDIO_TRIGGER_STOP running=%d draining=%d\n",
77 -                       alsa_stream->running, runtime->status->state == SNDRV_PCM_STATE_DRAINING);
78                 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
79                         audio_info("DRAINING\n");
80                         alsa_stream->draining = 1;
81 @@ -352,12 +325,9 @@ static int snd_bcm2835_pcm_trigger(struc
82                         audio_info("DROPPING\n");
83                         alsa_stream->draining = 0;
84                 }
85 -               if (alsa_stream->running) {
86 -                       err = bcm2835_audio_stop(alsa_stream);
87 -                       if (err != 0)
88 -                               audio_error(" Failed to STOP alsa device (%d)\n", err);
89 -                       alsa_stream->running = 0;
90 -               }
91 +               err = bcm2835_audio_stop(alsa_stream);
92 +               if (err != 0)
93 +                       audio_error(" Failed to STOP alsa device (%d)\n", err);
94                 break;
95         default:
96                 err = -EINVAL;
97 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
98 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
99 @@ -121,7 +121,6 @@ struct bcm2835_alsa_stream {
100  
101         spinlock_t lock;
102  
103 -       int running;
104         int draining;
105  
106         int channels;