Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

staging: most: Use managed buffer allocation

Clean up the driver with the new managed buffer allocation API.
Also remove the unnecessary checks of channels in hw_params callback
as this is guaranteed by the hw constraints in anyway.
After these cleanups, the hw_params and hw_free callbacks became
empty, hence dropped.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20191210141356.18074-2-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Takashi Iwai and committed by
Greg Kroah-Hartman
7e6d24d9 0988161a

+1 -43
+1 -43
drivers/staging/most/sound/sound.c
··· 323 323 } 324 324 325 325 /** 326 - * pcm_hw_params - implements hw_params callback function for PCM middle layer 327 - * @substream: sub-stream pointer 328 - * @hw_params: contains the hardware parameters set by the application 329 - * 330 - * This is called when the hardware parameters is set by the application, that 331 - * is, once when the buffer size, the period size, the format, etc. are defined 332 - * for the PCM substream. Many hardware setups should be done is this callback, 333 - * including the allocation of buffers. 334 - * 335 - * Returns 0 on success or error code otherwise. 336 - */ 337 - static int pcm_hw_params(struct snd_pcm_substream *substream, 338 - struct snd_pcm_hw_params *hw_params) 339 - { 340 - struct channel *channel = substream->private_data; 341 - 342 - if ((params_channels(hw_params) > channel->pcm_hardware.channels_max) || 343 - (params_channels(hw_params) < channel->pcm_hardware.channels_min)) { 344 - pr_err("Requested number of channels not supported.\n"); 345 - return -EINVAL; 346 - } 347 - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 348 - } 349 - 350 - /** 351 - * pcm_hw_free - implements hw_free callback function for PCM middle layer 352 - * @substream: substream pointer 353 - * 354 - * This is called to release the resources allocated via hw_params. 355 - * This function will be always called before the close callback is called. 356 - * 357 - * Returns 0 on success or error code otherwise. 358 - */ 359 - static int pcm_hw_free(struct snd_pcm_substream *substream) 360 - { 361 - return snd_pcm_lib_free_pages(substream); 362 - } 363 - 364 - /** 365 326 * pcm_prepare - implements prepare callback function for PCM middle layer 366 327 * @substream: substream pointer 367 328 * ··· 424 463 .open = pcm_open, 425 464 .close = pcm_close, 426 465 .ioctl = snd_pcm_lib_ioctl, 427 - .hw_params = pcm_hw_params, 428 - .hw_free = pcm_hw_free, 429 466 .prepare = pcm_prepare, 430 467 .trigger = pcm_trigger, 431 468 .pointer = pcm_pointer, ··· 620 661 pcm->private_data = channel; 621 662 strscpy(pcm->name, device_name, sizeof(pcm->name)); 622 663 snd_pcm_set_ops(pcm, direction, &pcm_ops); 623 - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, 624 - NULL, 0, 0); 664 + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); 625 665 626 666 return 0; 627 667