Skip to content

Commit c0ea089

Browse files
morimotobroonie
authored andcommitted
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID, but, this ID portion might confusable. For example currently, CTU ID is 0 to 7, but using 00 to 13 (= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet. In the future, we will support BUSIFn, but it will be more complicated numbering. To avoid future confusable code, this patch modify rsnd_mod_name() to return understandable name. To avoid using pointless memory, it uses static char and snprintf, thus, rsnd_mod_name() user should use it immediately, and shouldn't keep its pointer. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c16015f commit c0ea089

File tree

6 files changed

+57
-47
lines changed

6 files changed

+57
-47
lines changed

sound/soc/sh/rcar/core.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type)
123123
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
124124
struct device *dev = rsnd_priv_to_dev(priv);
125125

126-
dev_warn(dev, "%s[%d] is not your expected module\n",
127-
rsnd_mod_name(mod), rsnd_mod_id(mod));
126+
dev_warn(dev, "%s is not your expected module\n",
127+
rsnd_mod_name(mod));
128128
}
129129
}
130130

@@ -137,6 +137,30 @@ struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
137137
return mod->ops->dma_req(io, mod);
138138
}
139139

140+
#define MOD_NAME_SIZE 16
141+
char *rsnd_mod_name(struct rsnd_mod *mod)
142+
{
143+
static char name[MOD_NAME_SIZE];
144+
145+
/*
146+
* Let's use same char to avoid pointlessness memory
147+
* Thus, rsnd_mod_name() should be used immediately
148+
* Don't keep pointer
149+
*/
150+
if ((mod)->ops->id_sub) {
151+
snprintf(name, MOD_NAME_SIZE, "%s[%d%d]",
152+
mod->ops->name,
153+
rsnd_mod_id(mod),
154+
rsnd_mod_id_sub(mod));
155+
} else {
156+
snprintf(name, MOD_NAME_SIZE, "%s[%d]",
157+
mod->ops->name,
158+
rsnd_mod_id(mod));
159+
}
160+
161+
return name;
162+
}
163+
140164
u32 *rsnd_mod_get_status(struct rsnd_mod *mod,
141165
struct rsnd_dai_stream *io,
142166
enum rsnd_mod_type type)
@@ -494,15 +518,14 @@ static int rsnd_status_update(u32 *status,
494518
__rsnd_mod_shift_##fn, \
495519
__rsnd_mod_add_##fn, \
496520
__rsnd_mod_call_##fn); \
497-
rsnd_dbg_dai_call(dev, "%s[%d]\t0x%08x %s\n", \
498-
rsnd_mod_name(mod), rsnd_mod_id(mod), *status, \
521+
rsnd_dbg_dai_call(dev, "%s\t0x%08x %s\n", \
522+
rsnd_mod_name(mod), *status, \
499523
(func_call && (mod)->ops->fn) ? #fn : ""); \
500524
if (func_call && (mod)->ops->fn) \
501525
tmp = (mod)->ops->fn(mod, io, param); \
502526
if (tmp && (tmp != -EPROBE_DEFER)) \
503-
dev_err(dev, "%s[%d] : %s error %d\n", \
504-
rsnd_mod_name(mod), rsnd_mod_id(mod), \
505-
#fn, tmp); \
527+
dev_err(dev, "%s : %s error %d\n", \
528+
rsnd_mod_name(mod), #fn, tmp); \
506529
ret |= tmp; \
507530
} \
508531
ret; \
@@ -529,8 +552,8 @@ int rsnd_dai_connect(struct rsnd_mod *mod,
529552

530553
io->mod[type] = mod;
531554

532-
dev_dbg(dev, "%s[%d] is connected to io (%s)\n",
533-
rsnd_mod_name(mod), rsnd_mod_id(mod),
555+
dev_dbg(dev, "%s is connected to io (%s)\n",
556+
rsnd_mod_name(mod),
534557
rsnd_io_is_play(io) ? "Playback" : "Capture");
535558

536559
return 0;

sound/soc/sh/rcar/dma.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ static int rsnd_dmaen_start(struct rsnd_mod *mod,
174174
cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
175175
cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
176176

177-
dev_dbg(dev, "%s[%d] %pad -> %pad\n",
178-
rsnd_mod_name(mod), rsnd_mod_id(mod),
177+
dev_dbg(dev, "%s %pad -> %pad\n",
178+
rsnd_mod_name(mod),
179179
&cfg.src_addr, &cfg.dst_addr);
180180

181181
ret = dmaengine_slave_config(dmaen->chan, &cfg);
@@ -369,8 +369,7 @@ static u32 rsnd_dmapp_get_id(struct rsnd_dai_stream *io,
369369
if ((!entry) || (size <= id)) {
370370
struct device *dev = rsnd_priv_to_dev(rsnd_io_to_priv(io));
371371

372-
dev_err(dev, "unknown connection (%s[%d])\n",
373-
rsnd_mod_name(mod), rsnd_mod_id(mod));
372+
dev_err(dev, "unknown connection (%s)\n", rsnd_mod_name(mod));
374373

375374
/* use non-prohibited SRS number as error */
376375
return 0x00; /* SSI00 */
@@ -692,12 +691,10 @@ static void rsnd_dma_of_path(struct rsnd_mod *this,
692691
*mod_to = mod[1];
693692
}
694693

695-
dev_dbg(dev, "module connection (this is %s[%d])\n",
696-
rsnd_mod_name(this), rsnd_mod_id(this));
694+
dev_dbg(dev, "module connection (this is %s)\n", rsnd_mod_name(this));
697695
for (i = 0; i <= idx; i++) {
698-
dev_dbg(dev, " %s[%d]%s\n",
696+
dev_dbg(dev, " %s%s\n",
699697
rsnd_mod_name(mod[i] ? mod[i] : &mem),
700-
rsnd_mod_id (mod[i] ? mod[i] : &mem),
701698
(mod[i] == *mod_from) ? " from" :
702699
(mod[i] == *mod_to) ? " to" : "");
703700
}
@@ -762,12 +759,10 @@ static int rsnd_dma_alloc(struct rsnd_dai_stream *io, struct rsnd_mod *mod,
762759
if (ret < 0)
763760
return ret;
764761

765-
dev_dbg(dev, "%s[%d] %s[%d] -> %s[%d]\n",
766-
rsnd_mod_name(*dma_mod), rsnd_mod_id(*dma_mod),
762+
dev_dbg(dev, "%s %s -> %s\n",
763+
rsnd_mod_name(*dma_mod),
767764
rsnd_mod_name(mod_from ? mod_from : &mem),
768-
rsnd_mod_id (mod_from ? mod_from : &mem),
769-
rsnd_mod_name(mod_to ? mod_to : &mem),
770-
rsnd_mod_id (mod_to ? mod_to : &mem));
765+
rsnd_mod_name(mod_to ? mod_to : &mem));
771766

772767
ret = attach(io, dma, mod_from, mod_to);
773768
if (ret < 0)

sound/soc/sh/rcar/gen.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ u32 rsnd_read(struct rsnd_priv *priv,
8383

8484
regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val);
8585

86-
dev_dbg(dev, "r %s[%d] - %-18s (%4d) : %08x\n",
87-
rsnd_mod_name(mod), rsnd_mod_id(mod),
86+
dev_dbg(dev, "r %s - %-18s (%4d) : %08x\n",
87+
rsnd_mod_name(mod),
8888
rsnd_reg_name(gen, reg), reg, val);
8989

9090
return val;
@@ -102,8 +102,8 @@ void rsnd_write(struct rsnd_priv *priv,
102102

103103
regmap_fields_force_write(gen->regs[reg], rsnd_mod_id(mod), data);
104104

105-
dev_dbg(dev, "w %s[%d] - %-18s (%4d) : %08x\n",
106-
rsnd_mod_name(mod), rsnd_mod_id(mod),
105+
dev_dbg(dev, "w %s - %-18s (%4d) : %08x\n",
106+
rsnd_mod_name(mod),
107107
rsnd_reg_name(gen, reg), reg, data);
108108
}
109109

@@ -119,8 +119,8 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
119119
regmap_fields_force_update_bits(gen->regs[reg],
120120
rsnd_mod_id(mod), mask, data);
121121

122-
dev_dbg(dev, "b %s[%d] - %-18s (%4d) : %08x/%08x\n",
123-
rsnd_mod_name(mod), rsnd_mod_id(mod),
122+
dev_dbg(dev, "b %s - %-18s (%4d) : %08x/%08x\n",
123+
rsnd_mod_name(mod),
124124
rsnd_reg_name(gen, reg), reg, data, mask);
125125

126126
}

sound/soc/sh/rcar/rsnd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ struct rsnd_mod {
377377
#define __rsnd_mod_call_pointer 0
378378

379379
#define rsnd_mod_to_priv(mod) ((mod)->priv)
380-
#define rsnd_mod_name(mod) ((mod)->ops->name)
381380
#define rsnd_mod_power_on(mod) clk_enable((mod)->clk)
382381
#define rsnd_mod_power_off(mod) clk_disable((mod)->clk)
383382
#define rsnd_mod_get(ip) (&(ip)->mod)
@@ -400,6 +399,7 @@ u32 *rsnd_mod_get_status(struct rsnd_mod *mod,
400399
int rsnd_mod_id(struct rsnd_mod *mod);
401400
int rsnd_mod_id_raw(struct rsnd_mod *mod);
402401
int rsnd_mod_id_sub(struct rsnd_mod *mod);
402+
char *rsnd_mod_name(struct rsnd_mod *mod);
403403
struct rsnd_mod *rsnd_mod_next(int *iterator,
404404
struct rsnd_dai_stream *io,
405405
enum rsnd_mod_type *array,

sound/soc/sh/rcar/src.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ static bool rsnd_src_error_occurred(struct rsnd_mod *mod)
349349
status0 = rsnd_mod_read(mod, SCU_SYS_STATUS0);
350350
status1 = rsnd_mod_read(mod, SCU_SYS_STATUS1);
351351
if ((status0 & val0) || (status1 & val1)) {
352-
rsnd_dbg_irq_status(dev, "%s[%d] err status : 0x%08x, 0x%08x\n",
353-
rsnd_mod_name(mod), rsnd_mod_id(mod),
354-
status0, status1);
352+
rsnd_dbg_irq_status(dev, "%s err status : 0x%08x, 0x%08x\n",
353+
rsnd_mod_name(mod), status0, status1);
355354

356355
ret = true;
357356
}

sound/soc/sh/rcar/ssi.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ static void rsnd_ssi_status_check(struct rsnd_mod *mod,
181181
udelay(5);
182182
}
183183

184-
dev_warn(dev, "%s[%d] status check failed\n",
185-
rsnd_mod_name(mod), rsnd_mod_id(mod));
184+
dev_warn(dev, "%s status check failed\n", rsnd_mod_name(mod));
186185
}
187186

188187
static u32 rsnd_ssi_multi_slaves(struct rsnd_dai_stream *io)
@@ -346,9 +345,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod,
346345
ssi->rate = rate;
347346
ssi->chan = chan;
348347

349-
dev_dbg(dev, "%s[%d] outputs %u Hz\n",
350-
rsnd_mod_name(mod),
351-
rsnd_mod_id(mod), rate);
348+
dev_dbg(dev, "%s outputs %u Hz\n", rsnd_mod_name(mod), rate);
352349

353350
return 0;
354351
}
@@ -494,8 +491,7 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
494491
return 0;
495492

496493
if (!ssi->usrcnt) {
497-
dev_err(dev, "%s[%d] usrcnt error\n",
498-
rsnd_mod_name(mod), rsnd_mod_id(mod));
494+
dev_err(dev, "%s usrcnt error\n", rsnd_mod_name(mod));
499495
return -EIO;
500496
}
501497

@@ -654,8 +650,8 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
654650

655651
/* DMA only */
656652
if (is_dma && (status & (UIRQ | OIRQ))) {
657-
rsnd_dbg_irq_status(dev, "%s[%d] err status : 0x%08x\n",
658-
rsnd_mod_name(mod), rsnd_mod_id(mod), status);
653+
rsnd_dbg_irq_status(dev, "%s err status : 0x%08x\n",
654+
rsnd_mod_name(mod), status);
659655

660656
stop = true;
661657
}
@@ -964,8 +960,7 @@ static int rsnd_ssi_fallback(struct rsnd_mod *mod,
964960
*/
965961
mod->ops = &rsnd_ssi_pio_ops;
966962

967-
dev_info(dev, "%s[%d] fallback to PIO mode\n",
968-
rsnd_mod_name(mod), rsnd_mod_id(mod));
963+
dev_info(dev, "%s fallback to PIO mode\n", rsnd_mod_name(mod));
969964

970965
return 0;
971966
}
@@ -1085,15 +1080,13 @@ static void __rsnd_ssi_parse_hdmi_connection(struct rsnd_priv *priv,
10851080
/* HDMI0 */
10861081
if (strstr(remote_node->full_name, "hdmi@fead0000")) {
10871082
rsnd_flags_set(ssi, RSND_SSI_HDMI0);
1088-
dev_dbg(dev, "%s[%d] connected to HDMI0\n",
1089-
rsnd_mod_name(mod), rsnd_mod_id(mod));
1083+
dev_dbg(dev, "%s connected to HDMI0\n", rsnd_mod_name(mod));
10901084
}
10911085

10921086
/* HDMI1 */
10931087
if (strstr(remote_node->full_name, "hdmi@feae0000")) {
10941088
rsnd_flags_set(ssi, RSND_SSI_HDMI1);
1095-
dev_dbg(dev, "%s[%d] connected to HDMI1\n",
1096-
rsnd_mod_name(mod), rsnd_mod_id(mod));
1089+
dev_dbg(dev, "%s connected to HDMI1\n", rsnd_mod_name(mod));
10971090
}
10981091
}
10991092

0 commit comments

Comments
 (0)