Skip to content

Commit 7641d54

Browse files
committed
ALSA: firewire: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191209192422.23902-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 8f32630 commit 7641d54

9 files changed

Lines changed: 29 additions & 79 deletions

File tree

‎sound/firewire/bebob/bebob_pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
212212
struct snd_pcm_hw_params *hw_params)
213213
{
214214
struct snd_bebob *bebob = substream->private_data;
215-
int err;
216-
217-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
218-
if (err < 0)
219-
return err;
215+
int err = 0;
220216

221217
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
222218
unsigned int rate = params_rate(hw_params);
@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
247243

248244
mutex_unlock(&bebob->mutex);
249245

250-
return snd_pcm_lib_free_pages(substream);
246+
return 0;
251247
}
252248

253249
static int
@@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
377373
"%s PCM", bebob->card->shortname);
378374
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
379375
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
380-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
381-
NULL, 0, 0);
376+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
382377
end:
383378
return err;
384379
}

‎sound/firewire/dice/dice-pcm.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
264264
struct snd_pcm_hw_params *hw_params)
265265
{
266266
struct snd_dice *dice = substream->private_data;
267-
int err;
268-
269-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
270-
if (err < 0)
271-
return err;
267+
int err = 0;
272268

273269
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
274270
unsigned int rate = params_rate(hw_params);
@@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
304300

305301
mutex_unlock(&dice->mutex);
306302

307-
return snd_pcm_lib_free_pages(substream);
303+
return 0;
308304
}
309305

310306
static int capture_prepare(struct snd_pcm_substream *substream)
@@ -457,9 +453,8 @@ int snd_dice_create_pcm(struct snd_dice *dice)
457453
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
458454
&playback_ops);
459455

460-
snd_pcm_lib_preallocate_pages_for_all(pcm,
461-
SNDRV_DMA_TYPE_VMALLOC,
462-
NULL, 0, 0);
456+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
457+
NULL, 0, 0);
463458
}
464459

465460
return 0;

‎sound/firewire/digi00x/digi00x-pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
188188
struct snd_pcm_hw_params *hw_params)
189189
{
190190
struct snd_dg00x *dg00x = substream->private_data;
191-
int err;
192-
193-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
194-
if (err < 0)
195-
return err;
191+
int err = 0;
196192

197193
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
198194
unsigned int rate = params_rate(hw_params);
@@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
223219

224220
mutex_unlock(&dg00x->mutex);
225221

226-
return snd_pcm_lib_free_pages(substream);
222+
return 0;
227223
}
228224

229225
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
360356
"%s PCM", dg00x->card->shortname);
361357
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
362358
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
363-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
364-
NULL, 0, 0);
359+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
365360

366361
return 0;
367362
}

‎sound/firewire/fireface/ff-pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
228228
struct snd_pcm_hw_params *hw_params)
229229
{
230230
struct snd_ff *ff = substream->private_data;
231-
int err;
232-
233-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
234-
if (err < 0)
235-
return err;
231+
int err = 0;
236232

237233
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
238234
unsigned int rate = params_rate(hw_params);
@@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
263259

264260
mutex_unlock(&ff->mutex);
265261

266-
return snd_pcm_lib_free_pages(substream);
262+
return 0;
267263
}
268264

269265
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
400396
"%s PCM", ff->card->shortname);
401397
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops);
402398
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops);
403-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
404-
NULL, 0, 0);
399+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
405400

406401
return 0;
407402
}

‎sound/firewire/fireworks/fireworks_pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
248248
struct snd_pcm_hw_params *hw_params)
249249
{
250250
struct snd_efw *efw = substream->private_data;
251-
int err;
252-
253-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
254-
if (err < 0)
255-
return err;
251+
int err = 0;
256252

257253
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
258254
unsigned int rate = params_rate(hw_params);
@@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
283279

284280
mutex_unlock(&efw->mutex);
285281

286-
return snd_pcm_lib_free_pages(substream);
282+
return 0;
287283
}
288284

289285
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
406402
snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname);
407403
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
408404
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
409-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
410-
NULL, 0, 0);
405+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
411406
end:
412407
return err;
413408
}

‎sound/firewire/isight.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
286286
struct snd_pcm_hw_params *hw_params)
287287
{
288288
struct isight *isight = substream->private_data;
289-
int err;
290-
291-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
292-
if (err < 0)
293-
return err;
294289

295290
WRITE_ONCE(isight->pcm_active, true);
296291

@@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
336331
isight_stop_streaming(isight);
337332
mutex_unlock(&isight->mutex);
338333

339-
return snd_pcm_lib_free_pages(substream);
334+
return 0;
340335
}
341336

342337
static int isight_start_streaming(struct isight *isight)
@@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight)
463458
strcpy(pcm->name, "iSight");
464459
isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
465460
isight->pcm->ops = &ops;
466-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
467-
NULL, 0, 0);
461+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
468462

469463
return 0;
470464
}

‎sound/firewire/motu/motu-pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
212212
struct snd_pcm_hw_params *hw_params)
213213
{
214214
struct snd_motu *motu = substream->private_data;
215-
int err;
216-
217-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
218-
if (err < 0)
219-
return err;
215+
int err = 0;
220216

221217
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
222218
unsigned int rate = params_rate(hw_params);
@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
247243

248244
mutex_unlock(&motu->mutex);
249245

250-
return snd_pcm_lib_free_pages(substream);
246+
return 0;
251247
}
252248

253249
static int capture_prepare(struct snd_pcm_substream *substream)
@@ -374,8 +370,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
374370

375371
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
376372
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
377-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
378-
NULL, 0, 0);
373+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
379374

380375
return 0;
381376
}

‎sound/firewire/oxfw/oxfw-pcm.c‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream,
237237
struct snd_pcm_hw_params *hw_params)
238238
{
239239
struct snd_oxfw *oxfw = substream->private_data;
240-
int err;
241-
242-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
243-
if (err < 0)
244-
return err;
240+
int err = 0;
245241

246242
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
247243
unsigned int rate = params_rate(hw_params);
@@ -264,11 +260,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
264260
struct snd_pcm_hw_params *hw_params)
265261
{
266262
struct snd_oxfw *oxfw = substream->private_data;
267-
int err;
268-
269-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
270-
if (err < 0)
271-
return err;
263+
int err = 0;
272264

273265
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
274266
unsigned int rate = params_rate(hw_params);
@@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
301293

302294
mutex_unlock(&oxfw->mutex);
303295

304-
return snd_pcm_lib_free_pages(substream);
296+
return 0;
305297
}
306298
static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
307299
{
@@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
316308

317309
mutex_unlock(&oxfw->mutex);
318310

319-
return snd_pcm_lib_free_pages(substream);
311+
return 0;
320312
}
321313

322314
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
454446
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
455447
if (cap > 0)
456448
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
457-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
458-
NULL, 0, 0);
449+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
459450

460451
return 0;
461452
}

‎sound/firewire/tascam/tascam-pcm.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
117117
struct snd_pcm_hw_params *hw_params)
118118
{
119119
struct snd_tscm *tscm = substream->private_data;
120-
int err;
121-
122-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
123-
if (err < 0)
124-
return err;
120+
int err = 0;
125121

126122
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
127123
unsigned int rate = params_rate(hw_params);
@@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
152148

153149
mutex_unlock(&tscm->mutex);
154150

155-
return snd_pcm_lib_free_pages(substream);
151+
return 0;
156152
}
157153

158154
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm)
289285
"%s PCM", tscm->card->shortname);
290286
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
291287
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
292-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
293-
NULL, 0, 0);
288+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
294289

295290
return 0;
296291
}

0 commit comments

Comments
 (0)