From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH v5 01/14] ASoC: SOF: Add Sound Open Firmware driver core Date: Fri, 29 Mar 2019 17:04:31 +0100 Message-ID: References: <20190321161016.26515-1-pierre-louis.bossart@linux.intel.com> <20190321161016.26515-2-pierre-louis.bossart@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190321161016.26515-2-pierre-louis.bossart@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, Alan Cox , Daniel Baluta , liam.r.girdwood@linux.intel.com, vkoul@kernel.org, broonie@kernel.org, andriy.shevchenko@linux.intel.com, sound-open-firmware@alsa-project.org List-Id: alsa-devel@alsa-project.org On Thu, 21 Mar 2019 17:10:03 +0100, Pierre-Louis Bossart wrote: > > From: Liam Girdwood > > 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