brcm2708: add linux 4.19 support
[oweals/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0461-staging-bcm2835-audio-Use-standard-error-print-helpe.patch
1 From 1dff63cdd20b6dfc763d01d35dff231b8abe8175 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Tue, 4 Sep 2018 17:58:51 +0200
4 Subject: [PATCH 461/703] staging: bcm2835-audio: Use standard error print
5  helpers
6
7 commit b7584b64168208ebc14160770c0966b8b12fc16b upstream.
8
9 For making the whole code more consistent, replace the home-made debug
10 print macros with the standard dev_err() & co.
11
12 Signed-off-by: Takashi Iwai <tiwai@suse.de>
13 Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 ---
16  .../vc04_services/bcm2835-audio/bcm2835-pcm.c |  4 +-
17  .../bcm2835-audio/bcm2835-vchiq.c             | 52 ++++++++-----------
18  .../vc04_services/bcm2835-audio/bcm2835.c     |  2 +-
19  .../vc04_services/bcm2835-audio/bcm2835.h     | 43 +--------------
20  4 files changed, 27 insertions(+), 74 deletions(-)
21
22 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
23 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
24 @@ -101,8 +101,8 @@ static int snd_bcm2835_playback_open_gen
25                 goto out;
26         }
27         if (idx >= MAX_SUBSTREAMS) {
28 -               audio_error
29 -                       ("substream(%d) device doesn't exist max(%d) substreams allowed\n",
30 +               dev_err(chip->dev,
31 +                       "substream(%d) device doesn't exist max(%d) substreams allowed\n",
32                         idx, MAX_SUBSTREAMS);
33                 err = -ENODEV;
34                 goto out;
35 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
36 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
37 @@ -26,20 +26,8 @@
38  
39  /* ---- Private Constants and Types ------------------------------------------ */
40  
41 -/* Logging macros (for remapping to other logging mechanisms, i.e., printf) */
42 -#ifdef AUDIO_DEBUG_ENABLE
43 -#define LOG_ERR(fmt, arg...)   pr_err("%s:%d " fmt, __func__, __LINE__, ##arg)
44 -#define LOG_WARN(fmt, arg...)  pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
45 -#define LOG_INFO(fmt, arg...)  pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
46 -#define LOG_DBG(fmt, arg...)   pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
47 -#else
48 -#define LOG_ERR(fmt, arg...)   pr_err("%s:%d " fmt, __func__, __LINE__, ##arg)
49 -#define LOG_WARN(fmt, arg...)   no_printk(fmt, ##arg)
50 -#define LOG_INFO(fmt, arg...)   no_printk(fmt, ##arg)
51 -#define LOG_DBG(fmt, arg...)    no_printk(fmt, ##arg)
52 -#endif
53 -
54  struct bcm2835_audio_instance {
55 +       struct device *dev;
56         VCHI_SERVICE_HANDLE_T vchi_handle;
57         struct completion msg_avail_comp;
58         struct mutex vchi_mutex;
59 @@ -76,7 +64,8 @@ static int bcm2835_audio_send_msg_locked
60         status = vchi_queue_kernel_message(instance->vchi_handle,
61                                            m, sizeof(*m));
62         if (status) {
63 -               LOG_ERR("vchi message queue failed: %d, msg=%d\n",
64 +               dev_err(instance->dev,
65 +                       "vchi message queue failed: %d, msg=%d\n",
66                         status, m->type);
67                 return -EIO;
68         }
69 @@ -84,10 +73,12 @@ static int bcm2835_audio_send_msg_locked
70         if (wait) {
71                 if (!wait_for_completion_timeout(&instance->msg_avail_comp,
72                                                  msecs_to_jiffies(10 * 1000))) {
73 -                       LOG_ERR("vchi message timeout, msg=%d\n", m->type);
74 +                       dev_err(instance->dev,
75 +                               "vchi message timeout, msg=%d\n", m->type);
76                         return -ETIMEDOUT;
77                 } else if (instance->result) {
78 -                       LOG_ERR("vchi message response error:%d, msg=%d\n",
79 +                       dev_err(instance->dev,
80 +                               "vchi message response error:%d, msg=%d\n",
81                                 instance->result, m->type);
82                         return -EIO;
83                 }
84 @@ -140,12 +131,12 @@ static void audio_vchi_callback(void *pa
85         } else if (m.type == VC_AUDIO_MSG_TYPE_COMPLETE) {
86                 if (m.u.complete.cookie1 != BCM2835_AUDIO_WRITE_COOKIE1 ||
87                     m.u.complete.cookie2 != BCM2835_AUDIO_WRITE_COOKIE2)
88 -                       LOG_ERR("invalid cookie\n");
89 +                       dev_err(instance->dev, "invalid cookie\n");
90                 else
91                         bcm2835_playback_fifo(instance->alsa_stream,
92                                               m.u.complete.count);
93         } else {
94 -               LOG_ERR("unexpected callback type=%d\n", m.type);
95 +               dev_err(instance->dev, "unexpected callback type=%d\n", m.type);
96         }
97  }
98  
99 @@ -173,8 +164,9 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_
100                                    &instance->vchi_handle);
101  
102         if (status) {
103 -               LOG_ERR("%s: failed to open VCHI service connection (status=%d)\n",
104 -                       __func__, status);
105 +               dev_err(instance->dev,
106 +                       "failed to open VCHI service connection (status=%d)\n",
107 +                       status);
108                 kfree(instance);
109                 return -EPERM;
110         }
111 @@ -195,30 +187,30 @@ static void vc_vchi_audio_deinit(struct
112         /* Close all VCHI service connections */
113         status = vchi_service_close(instance->vchi_handle);
114         if (status) {
115 -               LOG_DBG("%s: failed to close VCHI service connection (status=%d)\n",
116 -                       __func__, status);
117 +               dev_err(instance->dev,
118 +                       "failed to close VCHI service connection (status=%d)\n",
119 +                       status);
120         }
121  
122         mutex_unlock(&instance->vchi_mutex);
123  }
124  
125 -int bcm2835_new_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx)
126 +int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx)
127  {
128         int ret;
129  
130         /* Initialize and create a VCHI connection */
131         ret = vchi_initialise(&vchi_ctx->vchi_instance);
132         if (ret) {
133 -               LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
134 -                       __func__, ret);
135 -
136 +               dev_err(dev, "failed to initialise VCHI instance (ret=%d)\n",
137 +                       ret);
138                 return -EIO;
139         }
140  
141         ret = vchi_connect(NULL, 0, vchi_ctx->vchi_instance);
142         if (ret) {
143 -               LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
144 -                       __func__, ret);
145 +               dev_dbg(dev, "failed to connect VCHI instance (ret=%d)\n",
146 +                       ret);
147  
148                 kfree(vchi_ctx->vchi_instance);
149                 vchi_ctx->vchi_instance = NULL;
150 @@ -248,6 +240,7 @@ int bcm2835_audio_open(struct bcm2835_al
151         if (!instance)
152                 return -ENOMEM;
153         mutex_init(&instance->vchi_mutex);
154 +       instance->dev = alsa_stream->chip->dev;
155         instance->alsa_stream = alsa_stream;
156         alsa_stream->instance = instance;
157  
158 @@ -394,7 +387,8 @@ int bcm2835_audio_write(struct bcm2835_a
159         }
160  
161         if (status) {
162 -               LOG_ERR("failed on %d bytes transfer (status=%d)\n",
163 +               dev_err(instance->dev,
164 +                       "failed on %d bytes transfer (status=%d)\n",
165                         size, status);
166                 err = -EIO;
167         }
168 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
169 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
170 @@ -73,7 +73,7 @@ static int bcm2835_devm_add_vchi_ctx(str
171  
172         memset(vchi_ctx, 0, sizeof(*vchi_ctx));
173  
174 -       ret = bcm2835_new_vchi_ctx(vchi_ctx);
175 +       ret = bcm2835_new_vchi_ctx(dev, vchi_ctx);
176         if (ret) {
177                 devres_free(vchi_ctx);
178                 return ret;
179 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
180 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
181 @@ -17,47 +17,6 @@
182  
183  #include "interface/vchi/vchi.h"
184  
185 -/*
186 - * #define AUDIO_DEBUG_ENABLE
187 - * #define AUDIO_VERBOSE_DEBUG_ENABLE
188 - */
189 -
190 -/* Debug macros */
191 -
192 -#ifdef AUDIO_DEBUG_ENABLE
193 -#ifdef AUDIO_VERBOSE_DEBUG_ENABLE
194 -
195 -#define audio_debug(fmt, arg...) \
196 -       pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
197 -
198 -#define audio_info(fmt, arg...) \
199 -       pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
200 -
201 -#else
202 -
203 -#define audio_debug(fmt, arg...)
204 -
205 -#define audio_info(fmt, arg...)
206 -
207 -#endif /* AUDIO_VERBOSE_DEBUG_ENABLE */
208 -
209 -#else
210 -
211 -#define audio_debug(fmt, arg...)
212 -
213 -#define audio_info(fmt, arg...)
214 -
215 -#endif /* AUDIO_DEBUG_ENABLE */
216 -
217 -#define audio_error(fmt, arg...) \
218 -       pr_err("%s:%d " fmt, __func__, __LINE__, ##arg)
219 -
220 -#define audio_warning(fmt, arg...) \
221 -       pr_warn("%s:%d " fmt, __func__, __LINE__, ##arg)
222 -
223 -#define audio_alert(fmt, arg...) \
224 -       pr_alert("%s:%d " fmt, __func__, __LINE__, ##arg)
225 -
226  #define MAX_SUBSTREAMS   (8)
227  #define AVAIL_SUBSTREAMS_MASK  (0xff)
228  
229 @@ -141,7 +100,7 @@ int snd_bcm2835_new_simple_pcm(struct bc
230  int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip);
231  int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip);
232  
233 -int bcm2835_new_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx);
234 +int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx);
235  void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx);
236  
237  int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream);