All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] catpt: Switch to use list_entry_is_head() helper
@ 2020-12-08 10:26 Andy Shevchenko
  2020-12-14  9:14 ` Rojewski, Cezary
  2020-12-28 16:03 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-12-08 10:26 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	alsa-devel, Mark Brown
  Cc: Andy Shevchenko

Since we got list_entry_is_head() helper in the generic header,
we may switch catpt to use it. It removes the need in additional variable.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/catpt/pcm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
index e5d54bb1c42a..1c7260db3238 100644
--- a/sound/soc/intel/catpt/pcm.c
+++ b/sound/soc/intel/catpt/pcm.c
@@ -331,10 +331,10 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
 {
 	struct catpt_dev *cdev = dev_get_drvdata(dai->dev);
 	struct snd_soc_component *component = dai->component;
-	struct snd_kcontrol *pos, *kctl = NULL;
 	const char *name;
 	int ret;
 	u32 id = stream->info.stream_hw_id;
+	struct snd_kcontrol *pos;
 
 	/* only selected streams have individual controls */
 	switch (id) {
@@ -356,17 +356,15 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
 
 	list_for_each_entry(pos, &component->card->snd_card->controls, list) {
 		if (pos->private_data == component &&
-		    !strncmp(name, pos->id.name, sizeof(pos->id.name))) {
-			kctl = pos;
+		    !strncmp(name, pos->id.name, sizeof(pos->id.name)))
 			break;
-		}
 	}
-	if (!kctl)
+	if (list_entry_is_head(pos, &component->card->snd_card->controls, list))
 		return -ENOENT;
 
 	if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK)
-		return catpt_set_dspvol(cdev, id, (long *)kctl->private_value);
-	ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)kctl->private_value);
+		return catpt_set_dspvol(cdev, id, (long *)pos->private_value);
+	ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)pos->private_value);
 	if (ret)
 		return CATPT_IPC_ERROR(ret);
 	return 0;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH v1] catpt: Switch to use list_entry_is_head() helper
  2020-12-08 10:26 [PATCH v1] catpt: Switch to use list_entry_is_head() helper Andy Shevchenko
@ 2020-12-14  9:14 ` Rojewski, Cezary
  2020-12-14 15:37   ` Andy Shevchenko
  2020-12-28 16:03 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Rojewski, Cezary @ 2020-12-14  9:14 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Liam Girdwood, alsa-devel, Mark Brown, Jie Yang, Pierre-Louis Bossart

On 2020-12-08 11:26 AM, Andy Shevchenko wrote:
> Since we got list_entry_is_head() helper in the generic header,
> we may switch catpt to use it. It removes the need in additional variable.

Thanks for the patch, Andy. One nitpick below.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   sound/soc/intel/catpt/pcm.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
> index e5d54bb1c42a..1c7260db3238 100644
> --- a/sound/soc/intel/catpt/pcm.c
> +++ b/sound/soc/intel/catpt/pcm.c
> @@ -331,10 +331,10 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
>   {
>   	struct catpt_dev *cdev = dev_get_drvdata(dai->dev);
>   	struct snd_soc_component *component = dai->component;
> -	struct snd_kcontrol *pos, *kctl = NULL;
>   	const char *name;
>   	int ret;
>   	u32 id = stream->info.stream_hw_id;
> +	struct snd_kcontrol *pos;

Shouldn't structs be declared before any primitive-types?

>   
>   	/* only selected streams have individual controls */
>   	switch (id) {
> @@ -356,17 +356,15 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
>   
>   	list_for_each_entry(pos, &component->card->snd_card->controls, list) {
>   		if (pos->private_data == component &&
> -		    !strncmp(name, pos->id.name, sizeof(pos->id.name))) {
> -			kctl = pos;
> +		    !strncmp(name, pos->id.name, sizeof(pos->id.name)))
>   			break;
> -		}
>   	}
> -	if (!kctl)
> +	if (list_entry_is_head(pos, &component->card->snd_card->controls, list))
>   		return -ENOENT;
>   
>   	if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK)
> -		return catpt_set_dspvol(cdev, id, (long *)kctl->private_value);
> -	ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)kctl->private_value);
> +		return catpt_set_dspvol(cdev, id, (long *)pos->private_value);
> +	ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)pos->private_value);
>   	if (ret)
>   		return CATPT_IPC_ERROR(ret);
>   	return 0;
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] catpt: Switch to use list_entry_is_head() helper
  2020-12-14  9:14 ` Rojewski, Cezary
@ 2020-12-14 15:37   ` Andy Shevchenko
  2020-12-14 16:26     ` Rojewski, Cezary
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-12-14 15:37 UTC (permalink / raw)
  To: Rojewski, Cezary
  Cc: Liam Girdwood, alsa-devel, Mark Brown, Jie Yang, Pierre-Louis Bossart

On Mon, Dec 14, 2020 at 09:14:13AM +0000, Rojewski, Cezary wrote:
> On 2020-12-08 11:26 AM, Andy Shevchenko wrote:
> > Since we got list_entry_is_head() helper in the generic header,
> > we may switch catpt to use it. It removes the need in additional variable.
> 
> Thanks for the patch, Andy. One nitpick below.

...

> >   	struct catpt_dev *cdev = dev_get_drvdata(dai->dev);
> >   	struct snd_soc_component *component = dai->component;
> > -	struct snd_kcontrol *pos, *kctl = NULL;
> >   	const char *name;
> >   	int ret;
> >   	u32 id = stream->info.stream_hw_id;
> > +	struct snd_kcontrol *pos;
> 
> Shouldn't structs be declared before any primitive-types?

Good question. I consider the length of the line is more important
(to keep reversed xmas tree order).

If you think we should leave as is tell me, I'll send v2.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v1] catpt: Switch to use list_entry_is_head() helper
  2020-12-14 15:37   ` Andy Shevchenko
@ 2020-12-14 16:26     ` Rojewski, Cezary
  0 siblings, 0 replies; 5+ messages in thread
From: Rojewski, Cezary @ 2020-12-14 16:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Liam Girdwood, alsa-devel, Mark Brown, Jie Yang, Pierre-Louis Bossart

On 2020-12-14 4:37 PM, Andy Shevchenko wrote:
> On Mon, Dec 14, 2020 at 09:14:13AM +0000, Rojewski, Cezary wrote:
>> On 2020-12-08 11:26 AM, Andy Shevchenko wrote:
>>> Since we got list_entry_is_head() helper in the generic header,
>>> we may switch catpt to use it. It removes the need in additional variable.
>>
>> Thanks for the patch, Andy. One nitpick below.

...

>>>    	struct catpt_dev *cdev = dev_get_drvdata(dai->dev);
>>>    	struct snd_soc_component *component = dai->component;
>>> -	struct snd_kcontrol *pos, *kctl = NULL;
>>>    	const char *name;
>>>    	int ret;
>>>    	u32 id = stream->info.stream_hw_id;
>>> +	struct snd_kcontrol *pos;
>>
>> Shouldn't structs be declared before any primitive-types?
> 
> Good question. I consider the length of the line is more important
> (to keep reversed xmas tree order).
> 
> If you think we should leave as is tell me, I'll send v2.
> 

I'm not in favor or against either of options: it comes down to the
coding style of the project - sticking to same one makes code
cohesive (by project I mean Linux-kernel).

However, to switch entire catpt to reversed xmas tree, more code changes
are required (even this very function is an example of that). Leaving as
is in this update while considering the subject in other series might be
the better outcome.

Czarek


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] catpt: Switch to use list_entry_is_head() helper
  2020-12-08 10:26 [PATCH v1] catpt: Switch to use list_entry_is_head() helper Andy Shevchenko
  2020-12-14  9:14 ` Rojewski, Cezary
@ 2020-12-28 16:03 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2020-12-28 16:03 UTC (permalink / raw)
  To: Liam Girdwood, Jie Yang, Pierre-Louis Bossart, Cezary Rojewski,
	Andy Shevchenko, alsa-devel

On Tue, 8 Dec 2020 12:26:37 +0200, Andy Shevchenko wrote:
> Since we got list_entry_is_head() helper in the generic header,
> we may switch catpt to use it. It removes the need in additional variable.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] catpt: Switch to use list_entry_is_head() helper
      commit: a9830fc388817c90282925694474fae005fec990

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-28 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 10:26 [PATCH v1] catpt: Switch to use list_entry_is_head() helper Andy Shevchenko
2020-12-14  9:14 ` Rojewski, Cezary
2020-12-14 15:37   ` Andy Shevchenko
2020-12-14 16:26     ` Rojewski, Cezary
2020-12-28 16:03 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.