All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
@ 2018-02-09  6:52 Peng Donglin
  0 siblings, 0 replies; 6+ messages in thread
From: Peng Donglin @ 2018-02-09  6:52 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, andy.shevchenko
  Cc: alsa-devel, linux-kernel, Peng Donglin

There is some duplicate code in soc-core.c,and the kernel provides
DEFINE_SHOW_ATTRIBUTE() helper macro to decrease it in seq_file.h.

Signed-off-by: Peng Donglin <dolinux.peng@gmail.com>
---
 sound/soc/soc-core.c | 51 +++++++++------------------------------------------
 1 file changed, 9 insertions(+), 42 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 96c44f6576c9..cb52d1e8e0b9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -349,33 +349,22 @@ static void soc_init_codec_debugfs(struct snd_soc_component *component)
 			"ASoC: Failed to create codec register debugfs file\n");
 }
 
-static int codec_list_seq_show(struct seq_file *m, void *v)
+static int codec_list_show(struct seq_file *s, void *v)
 {
 	struct snd_soc_codec *codec;
 
 	mutex_lock(&client_mutex);
 
 	list_for_each_entry(codec, &codec_list, list)
-		seq_printf(m, "%s\n", codec->component.name);
+		seq_printf(s, "%s\n", codec->component.name);
 
 	mutex_unlock(&client_mutex);
 
 	return 0;
 }
+DEFINE_SHOW_ATTRIBUTE(codec_list);
 
-static int codec_list_seq_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, codec_list_seq_show, NULL);
-}
-
-static const struct file_operations codec_list_fops = {
-	.open = codec_list_seq_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static int dai_list_seq_show(struct seq_file *m, void *v)
+static int dai_list_show(struct seq_file *s, void *v)
 {
 	struct snd_soc_component *component;
 	struct snd_soc_dai *dai;
@@ -384,50 +373,28 @@ static int dai_list_seq_show(struct seq_file *m, void *v)
 
 	list_for_each_entry(component, &component_list, list)
 		list_for_each_entry(dai, &component->dai_list, list)
-			seq_printf(m, "%s\n", dai->name);
+			seq_printf(s, "%s\n", dai->name);
 
 	mutex_unlock(&client_mutex);
 
 	return 0;
 }
+DEFINE_SHOW_ATTRIBUTE(dai_list);
 
-static int dai_list_seq_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dai_list_seq_show, NULL);
-}
-
-static const struct file_operations dai_list_fops = {
-	.open = dai_list_seq_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-static int platform_list_seq_show(struct seq_file *m, void *v)
+static int platform_list_show(struct seq_file *s, void *v)
 {
 	struct snd_soc_platform *platform;
 
 	mutex_lock(&client_mutex);
 
 	list_for_each_entry(platform, &platform_list, list)
-		seq_printf(m, "%s\n", platform->component.name);
+		seq_printf(s, "%s\n", platform->component.name);
 
 	mutex_unlock(&client_mutex);
 
 	return 0;
 }
-
-static int platform_list_seq_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, platform_list_seq_show, NULL);
-}
-
-static const struct file_operations platform_list_fops = {
-	.open = platform_list_seq_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(platform_list);
 
 static void soc_init_card_debugfs(struct snd_soc_card *card)
 {
-- 
2.16.1

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

* Re: [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
  2018-02-09 13:21   ` Andy Shevchenko
@ 2018-02-09 14:21     ` Donglin Peng
  -1 siblings, 0 replies; 6+ messages in thread
From: Donglin Peng @ 2018-02-09 14:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	ALSA Development Mailing List, Linux Kernel Mailing List

On Fri, Feb 9, 2018 at 9:21 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Feb 9, 2018 at 8:58 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
>> There is some duplicate code in soc-core.c,and the kernel provides
>
> 'core.c,and' -> 'core.c, and'
>
>> +static int codec_list_show(struct seq_file *s, void *v)
>
> No need to rename m -> s.
>
>> +static int dai_list_show(struct seq_file *s, void *v)
>
> Ditto.
>
>> +static int platform_list_show(struct seq_file *s, void *v)
>
> Ditto.
>
> After addressing above,
>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> --
> With Best Regards,
> Andy Shevchenko
Thanks for review, and I will send a patch v2.

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

* Re: [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
@ 2018-02-09 14:21     ` Donglin Peng
  0 siblings, 0 replies; 6+ messages in thread
From: Donglin Peng @ 2018-02-09 14:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: ALSA Development Mailing List, Liam Girdwood,
	Linux Kernel Mailing List, Takashi Iwai, Mark Brown

On Fri, Feb 9, 2018 at 9:21 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Feb 9, 2018 at 8:58 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
>> There is some duplicate code in soc-core.c,and the kernel provides
>
> 'core.c,and' -> 'core.c, and'
>
>> +static int codec_list_show(struct seq_file *s, void *v)
>
> No need to rename m -> s.
>
>> +static int dai_list_show(struct seq_file *s, void *v)
>
> Ditto.
>
>> +static int platform_list_show(struct seq_file *s, void *v)
>
> Ditto.
>
> After addressing above,
>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> --
> With Best Regards,
> Andy Shevchenko
Thanks for review, and I will send a patch v2.

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

* Re: [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
  2018-02-09  6:58 Donglin Peng
@ 2018-02-09 13:21   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-09 13:21 UTC (permalink / raw)
  To: Donglin Peng
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	ALSA Development Mailing List, Linux Kernel Mailing List

On Fri, Feb 9, 2018 at 8:58 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
> There is some duplicate code in soc-core.c,and the kernel provides

'core.c,and' -> 'core.c, and'

> +static int codec_list_show(struct seq_file *s, void *v)

No need to rename m -> s.

> +static int dai_list_show(struct seq_file *s, void *v)

Ditto.

> +static int platform_list_show(struct seq_file *s, void *v)

Ditto.

After addressing above,

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
@ 2018-02-09 13:21   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-09 13:21 UTC (permalink / raw)
  To: Donglin Peng
  Cc: ALSA Development Mailing List, Liam Girdwood,
	Linux Kernel Mailing List, Takashi Iwai, Mark Brown

On Fri, Feb 9, 2018 at 8:58 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
> There is some duplicate code in soc-core.c,and the kernel provides

'core.c,and' -> 'core.c, and'

> +static int codec_list_show(struct seq_file *s, void *v)

No need to rename m -> s.

> +static int dai_list_show(struct seq_file *s, void *v)

Ditto.

> +static int platform_list_show(struct seq_file *s, void *v)

Ditto.

After addressing above,

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

-- 
With Best Regards,
Andy Shevchenko

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

* [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication
@ 2018-02-09  6:58 Donglin Peng
  2018-02-09 13:21   ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Donglin Peng @ 2018-02-09  6:58 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Andy Shevchenko
  Cc: ALSA Development Mailing List, Linux Kernel Mailing List

There is some duplicate code in soc-core.c,and the kernel provides
DEFINE_SHOW_ATTRIBUTE() helper macro to decrease it in seq_file.h.

Signed-off-by: Peng Donglin <dolinux.peng@gmail.com>
---
 sound/soc/soc-core.c | 51 +++++++++------------------------------------------
 1 file changed, 9 insertions(+), 42 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 96c44f6576c9..cb52d1e8e0b9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -349,33 +349,22 @@ static void soc_init_codec_debugfs(struct
snd_soc_component *component)
             "ASoC: Failed to create codec register debugfs file\n");
 }

-static int codec_list_seq_show(struct seq_file *m, void *v)
+static int codec_list_show(struct seq_file *s, void *v)
 {
     struct snd_soc_codec *codec;

     mutex_lock(&client_mutex);

     list_for_each_entry(codec, &codec_list, list)
-        seq_printf(m, "%s\n", codec->component.name);
+        seq_printf(s, "%s\n", codec->component.name);

     mutex_unlock(&client_mutex);

     return 0;
 }
+DEFINE_SHOW_ATTRIBUTE(codec_list);

-static int codec_list_seq_open(struct inode *inode, struct file *file)
-{
-    return single_open(file, codec_list_seq_show, NULL);
-}
-
-static const struct file_operations codec_list_fops = {
-    .open = codec_list_seq_open,
-    .read = seq_read,
-    .llseek = seq_lseek,
-    .release = single_release,
-};
-
-static int dai_list_seq_show(struct seq_file *m, void *v)
+static int dai_list_show(struct seq_file *s, void *v)
 {
     struct snd_soc_component *component;
     struct snd_soc_dai *dai;
@@ -384,50 +373,28 @@ static int dai_list_seq_show(struct seq_file *m, void *v)

     list_for_each_entry(component, &component_list, list)
         list_for_each_entry(dai, &component->dai_list, list)
-            seq_printf(m, "%s\n", dai->name);
+            seq_printf(s, "%s\n", dai->name);

     mutex_unlock(&client_mutex);

     return 0;
 }
+DEFINE_SHOW_ATTRIBUTE(dai_list);

-static int dai_list_seq_open(struct inode *inode, struct file *file)
-{
-    return single_open(file, dai_list_seq_show, NULL);
-}
-
-static const struct file_operations dai_list_fops = {
-    .open = dai_list_seq_open,
-    .read = seq_read,
-    .llseek = seq_lseek,
-    .release = single_release,
-};
-
-static int platform_list_seq_show(struct seq_file *m, void *v)
+static int platform_list_show(struct seq_file *s, void *v)
 {
     struct snd_soc_platform *platform;

     mutex_lock(&client_mutex);

     list_for_each_entry(platform, &platform_list, list)
-        seq_printf(m, "%s\n", platform->component.name);
+        seq_printf(s, "%s\n", platform->component.name);

     mutex_unlock(&client_mutex);

     return 0;
 }
-
-static int platform_list_seq_open(struct inode *inode, struct file *file)
-{
-    return single_open(file, platform_list_seq_show, NULL);
-}
-
-static const struct file_operations platform_list_fops = {
-    .open = platform_list_seq_open,
-    .read = seq_read,
-    .llseek = seq_lseek,
-    .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(platform_list);

 static void soc_init_card_debugfs(struct snd_soc_card *card)
 {
-- 
2.16.1

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

end of thread, other threads:[~2018-02-09 14:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09  6:52 [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication Peng Donglin
2018-02-09  6:58 Donglin Peng
2018-02-09 13:21 ` Andy Shevchenko
2018-02-09 13:21   ` Andy Shevchenko
2018-02-09 14:21   ` Donglin Peng
2018-02-09 14:21     ` Donglin Peng

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.