Skip to content

Commit d3185a2

Browse files
committed
Merge remote-tracking branch 'asoc/for-7.1' into asoc-linus
2 parents cf81b26 + e4c60a1 commit d3185a2

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

sound/soc/loongson/loongson_dma.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ loongson_idma_pcm_pointer(struct snd_soc_component *component,
199199
struct snd_pcm_substream *substream)
200200
{
201201
struct snd_pcm_runtime *runtime = substream->runtime;
202+
struct device *dev = substream->pcm->card->dev;
202203
struct loongson_runtime_data *prtd = runtime->private_data;
203204
struct loongson_idma_desc *desc;
204205
snd_pcm_uframes_t x;
@@ -207,9 +208,16 @@ loongson_idma_pcm_pointer(struct snd_soc_component *component,
207208
desc = dma_desc_save(prtd);
208209
addr = ((u64)desc->saddr_hi << 32) | desc->saddr;
209210

210-
x = bytes_to_frames(runtime, addr - runtime->dma_addr);
211-
if (x == runtime->buffer_size)
211+
if (addr < runtime->dma_addr ||
212+
addr > runtime->dma_addr + runtime->dma_bytes) {
213+
dev_warn(dev, "WARNING! dma_addr:0x%llx\n", addr);
212214
x = 0;
215+
} else {
216+
x = bytes_to_frames(runtime, addr - runtime->dma_addr);
217+
if (x == runtime->buffer_size)
218+
x = 0;
219+
}
220+
213221
return x;
214222
}
215223

sound/soc/sdca/sdca_function_device.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ static struct sdca_dev *sdca_dev_register(struct device *parent,
8282

8383
static void sdca_dev_unregister(struct sdca_dev *sdev)
8484
{
85+
if (!sdev)
86+
return;
87+
8588
auxiliary_device_delete(&sdev->auxdev);
8689
auxiliary_device_uninit(&sdev->auxdev);
8790
}
@@ -90,14 +93,24 @@ int sdca_dev_register_functions(struct sdw_slave *slave)
9093
{
9194
struct sdca_device_data *sdca_data = &slave->sdca_data;
9295
int i;
96+
int ret;
9397

9498
for (i = 0; i < sdca_data->num_functions; i++) {
9599
struct sdca_dev *func_dev;
96100

97101
func_dev = sdca_dev_register(&slave->dev,
98102
&sdca_data->function[i]);
99-
if (IS_ERR(func_dev))
100-
return PTR_ERR(func_dev);
103+
if (IS_ERR(func_dev)) {
104+
ret = PTR_ERR(func_dev);
105+
/*
106+
* Unregister functions that were successfully
107+
* registered before this failure. This also
108+
* sets func_dev to NULL so the caller will not
109+
* try to unregister them again.
110+
*/
111+
sdca_dev_unregister_functions(slave);
112+
return ret;
113+
}
101114

102115
sdca_data->function[i].func_dev = func_dev;
103116
}
@@ -111,7 +124,12 @@ void sdca_dev_unregister_functions(struct sdw_slave *slave)
111124
struct sdca_device_data *sdca_data = &slave->sdca_data;
112125
int i;
113126

114-
for (i = 0; i < sdca_data->num_functions; i++)
127+
for (i = 0; i < sdca_data->num_functions; i++) {
128+
if (!sdca_data->function[i].func_dev)
129+
continue;
130+
115131
sdca_dev_unregister(sdca_data->function[i].func_dev);
132+
sdca_data->function[i].func_dev = NULL;
133+
}
116134
}
117135
EXPORT_SYMBOL_NS(sdca_dev_unregister_functions, "SND_SOC_SDCA");

0 commit comments

Comments
 (0)