Re: [PATCH v5 01/14] ASoC: SOF: Add Sound Open Firmware driver core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 21 Mar 2019 17:10:03 +0100,
Pierre-Louis Bossart wrote:
> 
> From: Liam Girdwood <liam.r.girdwood@xxxxxxxxxxxxxxx>
> 
> The Sound Open Firmware driver core is a generic architecture
> independent layer that allows SOF to be used on many different different

One different is enough.

> --- /dev/null
> +++ b/sound/soc/sof/core.c
....
> +struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_sof_dev *sdev,
> +					   char *name)

Make it const char *.

> +{
> +	struct snd_sof_pcm *spcm = NULL;

Superfluous initialization.

> +	list_for_each_entry(spcm, &sdev->pcm_list, list) {
> +		if (strcmp(spcm->pcm.dai_name, name) == 0)
> +			return spcm;
> +
> +		if (strcmp(spcm->pcm.caps[0].name, name) == 0)
> +			return spcm;
> +
> +		if (strcmp(spcm->pcm.caps[1].name, name) == 0)
> +			return spcm;
> +	}
> +
> +	return NULL;
> +}
> +
> +struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_sof_dev *sdev,
> +					   unsigned int comp_id,
> +					   int *direction)
> +{
> +	struct snd_sof_pcm *spcm = NULL;

Ditto, superfluous.

> +	list_for_each_entry(spcm, &sdev->pcm_list, list) {
> +		if (spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].comp_id == comp_id) {
> +			*direction = SNDRV_PCM_STREAM_PLAYBACK;
> +			return spcm;
> +		}
> +		if (spcm->stream[SNDRV_PCM_STREAM_CAPTURE].comp_id == comp_id) {
> +			*direction = SNDRV_PCM_STREAM_CAPTURE;
> +			return spcm;
> +		}
> +	}
> +
> +	return NULL;
> +}
> +
> +struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_sof_dev *sdev,
> +					     unsigned int pcm_id)
> +{
> +	struct snd_sof_pcm *spcm = NULL;

Ditto...  I stop repeating.

> +	list_for_each_entry(spcm, &sdev->pcm_list, list) {
> +		if (le32_to_cpu(spcm->pcm.pcm_id) == pcm_id)
> +			return spcm;
> +	}
> +
> +	return NULL;
> +}
> +
> +struct snd_sof_widget *snd_sof_find_swidget(struct snd_sof_dev *sdev,
> +					    char *name)

const char *.  Some other functions follow the similar pattern...


> +int snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
> +		       u32 tracep_code, void *oops,
> +		       struct sof_ipc_panic_info *panic_info,
> +		       void *stack, size_t stack_words)
> +{
> +	u32 code;
> +	int i;
> +
> +	/* is firmware dead ? */
> +	if ((panic_code & SOF_IPC_PANIC_MAGIC_MASK) != SOF_IPC_PANIC_MAGIC) {
> +		dev_err(sdev->dev, "error: unexpected fault 0x%8.8x trace 0x%8.8x\n",
> +			panic_code, tracep_code);
> +		return 0; /* no fault ? */
> +	}
....
> +out:
> +	dev_err(sdev->dev, "error: panic happen at %s:%d\n",
> +		panic_info->filename, panic_info->linenum);
> +	sof_oops(sdev, oops);
> +	sof_stack(sdev, oops, stack, stack_words);
> +	return -EFAULT;
> +}

So this function returns -EFAULT for the normal operation while 0 for
unexpected case?  I see that no callers actually check the return
value, but it's some what unintuitive.  Worth for adding a comment
about the return code.


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux