On Mon, Aug 18, 2014 at 11:06:09AM +0530, Subhransu S. Prusty wrote:
On Wed, Aug 13, 2014 at 09:00:12PM +0100, Mark Brown wrote:
On Mon, Aug 04, 2014 at 03:15:56PM +0530, Subhransu S. Prusty wrote:
From: Vinod Koul vinod.koul@intel.com
+static int sst_algo_bytes_ctl_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
+{
- struct sst_algo_control *bc = (void *)kcontrol->private_value;
- struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
- uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
- uinfo->count = bc->max;
- /* allocate space to cache the algo parameters in the driver */
- if (bc->params == NULL) {
bc->params = devm_kzalloc(component->dev, bc->max, GFP_KERNEL);
if (bc->params == NULL)
return -ENOMEM;
- }
- return 0;
+}
I wouldn't expect an info call to be allocating anything - why is it doing that? It's not looking at the alocated data except to see if the allocation succeeded. What happens if someone manages to do a get or set without having first done an info and why aren't we doing any allocation on initialisation?
Will move after control initialization.
As I have to initialize the params, and if it's done in probe after control creation, it's required to iterate over the controls list and match certain pattern to find the control and then initialize. This doesn't look elegant. Instead I would prefer adding an init callback in the control to do this operation. What do you recommend?
--