1 From ec788d7c115d3ec59b39b6aac17d57ad86b7fbfe 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] staging: bcm2835-audio: Use standard error print
7 commit b7584b64168208ebc14160770c0966b8b12fc16b upstream.
9 For making the whole code more consistent, replace the home-made debug
10 print macros with the standard dev_err() & co.
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>
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(-)
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
27 if (idx >= MAX_SUBSTREAMS) {
29 - ("substream(%d) device doesn't exist max(%d) substreams allowed\n",
31 + "substream(%d) device doesn't exist max(%d) substreams allowed\n",
35 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
36 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
39 /* ---- Private Constants and Types ------------------------------------------ */
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)
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)
54 struct bcm2835_audio_instance {
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,
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",
69 @@ -84,10 +73,12 @@ static int bcm2835_audio_send_msg_locked
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);
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);
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");
91 bcm2835_playback_fifo(instance->alsa_stream,
94 - LOG_ERR("unexpected callback type=%d\n", m.type);
95 + dev_err(instance->dev, "unexpected callback type=%d\n", m.type);
99 @@ -173,8 +164,9 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_
100 &instance->vchi_handle);
103 - LOG_ERR("%s: failed to open VCHI service connection (status=%d)\n",
105 + dev_err(instance->dev,
106 + "failed to open VCHI service connection (status=%d)\n",
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);
115 - LOG_DBG("%s: failed to close VCHI service connection (status=%d)\n",
117 + dev_err(instance->dev,
118 + "failed to close VCHI service connection (status=%d)\n",
122 mutex_unlock(&instance->vchi_mutex);
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)
130 /* Initialize and create a VCHI connection */
131 ret = vchi_initialise(&vchi_ctx->vchi_instance);
133 - LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n",
136 + dev_err(dev, "failed to initialise VCHI instance (ret=%d)\n",
141 ret = vchi_connect(NULL, 0, vchi_ctx->vchi_instance);
143 - LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n",
145 + dev_dbg(dev, "failed to connect VCHI instance (ret=%d)\n",
148 kfree(vchi_ctx->vchi_instance);
149 vchi_ctx->vchi_instance = NULL;
150 @@ -248,6 +240,7 @@ int bcm2835_audio_open(struct bcm2835_al
153 mutex_init(&instance->vchi_mutex);
154 + instance->dev = alsa_stream->chip->dev;
155 instance->alsa_stream = alsa_stream;
156 alsa_stream->instance = instance;
158 @@ -394,7 +387,8 @@ int bcm2835_audio_write(struct bcm2835_a
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",
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
172 memset(vchi_ctx, 0, sizeof(*vchi_ctx));
174 - ret = bcm2835_new_vchi_ctx(vchi_ctx);
175 + ret = bcm2835_new_vchi_ctx(dev, vchi_ctx);
177 devres_free(vchi_ctx);
179 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
180 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h
183 #include "interface/vchi/vchi.h"
186 - * #define AUDIO_DEBUG_ENABLE
187 - * #define AUDIO_VERBOSE_DEBUG_ENABLE
192 -#ifdef AUDIO_DEBUG_ENABLE
193 -#ifdef AUDIO_VERBOSE_DEBUG_ENABLE
195 -#define audio_debug(fmt, arg...) \
196 - pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
198 -#define audio_info(fmt, arg...) \
199 - pr_info("%s:%d " fmt, __func__, __LINE__, ##arg)
203 -#define audio_debug(fmt, arg...)
205 -#define audio_info(fmt, arg...)
207 -#endif /* AUDIO_VERBOSE_DEBUG_ENABLE */
211 -#define audio_debug(fmt, arg...)
213 -#define audio_info(fmt, arg...)
215 -#endif /* AUDIO_DEBUG_ENABLE */
217 -#define audio_error(fmt, arg...) \
218 - pr_err("%s:%d " fmt, __func__, __LINE__, ##arg)
220 -#define audio_warning(fmt, arg...) \
221 - pr_warn("%s:%d " fmt, __func__, __LINE__, ##arg)
223 -#define audio_alert(fmt, arg...) \
224 - pr_alert("%s:%d " fmt, __func__, __LINE__, ##arg)
226 #define MAX_SUBSTREAMS (8)
227 #define AVAIL_SUBSTREAMS_MASK (0xff)
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);
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);
237 int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream);