Skip to content

Commit 40e47e2

Browse files
morimotobroonie
authored andcommitted
ASoC: rename rtd->num to rtd->id
Current rtd has "num". It sounds/looks like size of rtd or something, but it will be mainly used at snd_pcm_new() as "device index". This naming is confusable. Let's rename it to "id" Some drivers are using rtd->num, so let's keep it so far, and remove it if all user was switched. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/87zfmub85z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0196105 commit 40e47e2

6 files changed

Lines changed: 30 additions & 28 deletions

File tree

include/sound/soc-dai.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
217217
void snd_soc_dai_suspend(struct snd_soc_dai *dai);
218218
void snd_soc_dai_resume(struct snd_soc_dai *dai);
219219
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
220-
struct snd_soc_pcm_runtime *rtd, int num);
220+
struct snd_soc_pcm_runtime *rtd, int id);
221221
bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int stream);
222222
void snd_soc_dai_action(struct snd_soc_dai *dai,
223223
int stream, int action);
@@ -275,7 +275,7 @@ struct snd_soc_dai_ops {
275275
int (*probe)(struct snd_soc_dai *dai);
276276
int (*remove)(struct snd_soc_dai *dai);
277277
/* compress dai */
278-
int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num);
278+
int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int id);
279279
/* Optional Callback used at pcm creation*/
280280
int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,
281281
struct snd_soc_dai *dai);

include/sound/soc.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
486486
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
487487
const char *driver_name);
488488

489-
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
489+
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int id);
490490
#ifdef CONFIG_SND_SOC_COMPRESS
491-
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
491+
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int id);
492492
#else
493-
static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
493+
static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int id)
494494
{
495495
return 0;
496496
}
@@ -1195,7 +1195,8 @@ struct snd_soc_pcm_runtime {
11951195
struct dentry *debugfs_dpcm_root;
11961196
#endif
11971197

1198-
unsigned int num; /* 0-based and monotonic increasing */
1198+
unsigned int num; /* REMOVE ME */
1199+
unsigned int id; /* 0-based and monotonic increasing */
11991200
struct list_head list; /* rtd list of the soc card */
12001201

12011202
/* function mark */

sound/soc/soc-compress.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,11 @@ static struct snd_compr_ops soc_compr_dyn_ops = {
537537
* snd_soc_new_compress - create a new compress.
538538
*
539539
* @rtd: The runtime for which we will create compress
540-
* @num: the device index number (zero based - shared with normal PCMs)
540+
* @id: the device index number (zero based - shared with normal PCMs)
541541
*
542542
* Return: 0 for success, else error.
543543
*/
544-
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
544+
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int id)
545545
{
546546
struct snd_soc_component *component;
547547
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
@@ -617,7 +617,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
617617
snprintf(new_name, sizeof(new_name), "(%s)",
618618
rtd->dai_link->stream_name);
619619

620-
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
620+
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, id,
621621
playback, capture, &be_pcm);
622622
if (ret < 0) {
623623
dev_err(rtd->card->dev,
@@ -638,7 +638,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
638638
memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
639639
} else {
640640
snprintf(new_name, sizeof(new_name), "%s %s-%d",
641-
rtd->dai_link->stream_name, codec_dai->name, num);
641+
rtd->dai_link->stream_name, codec_dai->name, id);
642642

643643
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
644644
}
@@ -652,7 +652,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
652652
break;
653653
}
654654

655-
ret = snd_compress_new(rtd->card->snd_card, num, direction,
655+
ret = snd_compress_new(rtd->card->snd_card, id, direction,
656656
new_name, compr);
657657
if (ret < 0) {
658658
component = snd_soc_rtd_to_codec(rtd, 0)->component;

sound/soc/soc-core.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
558558
*/
559559
rtd->card = card;
560560
rtd->dai_link = dai_link;
561-
rtd->num = card->num_rtd++;
561+
rtd->id = card->num_rtd++;
562+
rtd->num = rtd->id; /* REMOVE ME */
562563
rtd->pmdown_time = pmdown_time; /* default power off timeout */
563564

564565
/* see for_each_card_rtds */
@@ -1458,7 +1459,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14581459
struct snd_soc_dai_link *dai_link = rtd->dai_link;
14591460
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
14601461
struct snd_soc_component *component;
1461-
int ret, num, i;
1462+
int ret, id, i;
14621463

14631464
/* do machine specific initialization */
14641465
ret = snd_soc_link_init(rtd);
@@ -1473,7 +1474,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14731474
/* add DPCM sysfs entries */
14741475
soc_dpcm_debugfs_add(rtd);
14751476

1476-
num = rtd->num;
1477+
id = rtd->id;
14771478

14781479
/*
14791480
* most drivers will register their PCMs using DAI link ordering but
@@ -1485,18 +1486,18 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14851486
continue;
14861487

14871488
if (rtd->dai_link->no_pcm)
1488-
num += component->driver->be_pcm_base;
1489+
id += component->driver->be_pcm_base;
14891490
else
1490-
num = rtd->dai_link->id;
1491+
id = rtd->dai_link->id;
14911492
}
14921493

14931494
/* create compress_device if possible */
1494-
ret = snd_soc_dai_compress_new(cpu_dai, rtd, num);
1495+
ret = snd_soc_dai_compress_new(cpu_dai, rtd, id);
14951496
if (ret != -ENOTSUPP)
14961497
goto err;
14971498

14981499
/* create the pcm */
1499-
ret = soc_new_pcm(rtd, num);
1500+
ret = soc_new_pcm(rtd, id);
15001501
if (ret < 0) {
15011502
dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
15021503
dai_link->stream_name, ret);

sound/soc/soc-dai.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,12 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
457457
}
458458

459459
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
460-
struct snd_soc_pcm_runtime *rtd, int num)
460+
struct snd_soc_pcm_runtime *rtd, int id)
461461
{
462462
int ret = -ENOTSUPP;
463463
if (dai->driver->ops &&
464464
dai->driver->ops->compress_new)
465-
ret = dai->driver->ops->compress_new(rtd, num);
465+
ret = dai->driver->ops->compress_new(rtd, id);
466466
return soc_dai_ret(dai, ret);
467467
}
468468

sound/soc/soc-pcm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
28912891

28922892
static int soc_create_pcm(struct snd_pcm **pcm,
28932893
struct snd_soc_pcm_runtime *rtd,
2894-
int playback, int capture, int num)
2894+
int playback, int capture, int id)
28952895
{
28962896
char new_name[64];
28972897
int ret;
@@ -2901,13 +2901,13 @@ static int soc_create_pcm(struct snd_pcm **pcm,
29012901
snprintf(new_name, sizeof(new_name), "codec2codec(%s)",
29022902
rtd->dai_link->stream_name);
29032903

2904-
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2904+
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, id,
29052905
playback, capture, pcm);
29062906
} else if (rtd->dai_link->no_pcm) {
29072907
snprintf(new_name, sizeof(new_name), "(%s)",
29082908
rtd->dai_link->stream_name);
29092909

2910-
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2910+
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, id,
29112911
playback, capture, pcm);
29122912
} else {
29132913
if (rtd->dai_link->dynamic)
@@ -2916,23 +2916,23 @@ static int soc_create_pcm(struct snd_pcm **pcm,
29162916
else
29172917
snprintf(new_name, sizeof(new_name), "%s %s-%d",
29182918
rtd->dai_link->stream_name,
2919-
soc_codec_dai_name(rtd), num);
2919+
soc_codec_dai_name(rtd), id);
29202920

2921-
ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback,
2921+
ret = snd_pcm_new(rtd->card->snd_card, new_name, id, playback,
29222922
capture, pcm);
29232923
}
29242924
if (ret < 0) {
29252925
dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n",
29262926
new_name, rtd->dai_link->name, ret);
29272927
return ret;
29282928
}
2929-
dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name);
2929+
dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n", id, new_name);
29302930

29312931
return 0;
29322932
}
29332933

29342934
/* create a new pcm */
2935-
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2935+
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int id)
29362936
{
29372937
struct snd_soc_component *component;
29382938
struct snd_pcm *pcm;
@@ -2943,7 +2943,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
29432943
if (ret < 0)
29442944
return ret;
29452945

2946-
ret = soc_create_pcm(&pcm, rtd, playback, capture, num);
2946+
ret = soc_create_pcm(&pcm, rtd, playback, capture, id);
29472947
if (ret < 0)
29482948
return ret;
29492949

0 commit comments

Comments
 (0)