* [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
@ 2018-01-18 5:31 Donglin Peng
2018-01-23 17:08 ` Andy Shevchenko
0 siblings, 1 reply; 9+ messages in thread
From: Donglin Peng @ 2018-01-18 5:31 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai; +Cc: alsa-devel, linux-kernel, Donglin Peng
Now the debugfs files dais/platforms/codecs have a size limit PAGE_SIZE and
the user can not see the whole contents of dai_list/platform_list/codec_list
when they are larger than this limit.
This patch uses seq_file instead to make sure dais/platforms/codecs show the
full contents of dai_list/platform_list/codec_list.
Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
---
Changelog
v2
-fix commit log error
sound/soc/soc-core.c | 111 +++++++++++++++++----------------------------------
1 file changed, 37 insertions(+), 74 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c0edac80df34..7b582112e3fc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -349,120 +349,84 @@ static void soc_init_codec_debugfs(struct snd_soc_component *component)
"ASoC: Failed to create codec register debugfs file\n");
}
-static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
+static int codec_list_seq_show(struct seq_file *m, void *v)
{
- char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t len, ret = 0;
struct snd_soc_codec *codec;
- if (!buf)
- return -ENOMEM;
-
mutex_lock(&client_mutex);
- list_for_each_entry(codec, &codec_list, list) {
- len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
- codec->component.name);
- if (len >= 0)
- ret += len;
- if (ret > PAGE_SIZE) {
- ret = PAGE_SIZE;
- break;
- }
- }
+ list_for_each_entry(codec, &codec_list, list)
+ seq_printf(m, "%s\n", codec->component.name);
mutex_unlock(&client_mutex);
- if (ret >= 0)
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
- kfree(buf);
+ return 0;
+}
- return ret;
+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 = {
- .read = codec_list_read_file,
- .llseek = default_llseek,/* read accesses f_pos */
+ .open = codec_list_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
};
-static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
+static int dai_list_seq_show(struct seq_file *m, void *v)
{
- char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t len, ret = 0;
struct snd_soc_component *component;
struct snd_soc_dai *dai;
- if (!buf)
- return -ENOMEM;
-
mutex_lock(&client_mutex);
- list_for_each_entry(component, &component_list, list) {
- list_for_each_entry(dai, &component->dai_list, list) {
- len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
- dai->name);
- if (len >= 0)
- ret += len;
- if (ret > PAGE_SIZE) {
- ret = PAGE_SIZE;
- break;
- }
- }
- }
+ list_for_each_entry(component, &component_list, list)
+ list_for_each_entry(dai, &component->dai_list, list)
+ seq_printf(m, "%s\n", dai->name);
mutex_unlock(&client_mutex);
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
- kfree(buf);
+ return 0;
+}
- return ret;
+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 = {
- .read = dai_list_read_file,
- .llseek = default_llseek,/* read accesses f_pos */
+ .open = dai_list_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
};
-static ssize_t platform_list_read_file(struct file *file,
- char __user *user_buf,
- size_t count, loff_t *ppos)
+static int platform_list_seq_show(struct seq_file *m, void *v)
{
- char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t len, ret = 0;
struct snd_soc_platform *platform;
- if (!buf)
- return -ENOMEM;
-
mutex_lock(&client_mutex);
- list_for_each_entry(platform, &platform_list, list) {
- len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
- platform->component.name);
- if (len >= 0)
- ret += len;
- if (ret > PAGE_SIZE) {
- ret = PAGE_SIZE;
- break;
- }
- }
+ list_for_each_entry(platform, &platform_list, list)
+ seq_printf(m, "%s\n", platform->component.name);
mutex_unlock(&client_mutex);
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
- kfree(buf);
+ return 0;
+}
- return ret;
+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 = {
- .read = platform_list_read_file,
- .llseek = default_llseek,/* read accesses f_pos */
+ .open = platform_list_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
};
static void soc_init_card_debugfs(struct snd_soc_card *card)
@@ -491,7 +455,6 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
debugfs_remove_recursive(card->debugfs_card_root);
}
-
static void snd_soc_debugfs_init(void)
{
snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
--
2.15.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-18 5:31 [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list Donglin Peng
@ 2018-01-23 17:08 ` Andy Shevchenko
2018-01-23 17:37 ` Mark Brown
0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2018-01-23 17:08 UTC (permalink / raw)
To: Donglin Peng
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
On Thu, Jan 18, 2018 at 7:31 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
> Now the debugfs files dais/platforms/codecs have a size limit PAGE_SIZE and
> the user can not see the whole contents of dai_list/platform_list/codec_list
> when they are larger than this limit.
>
> This patch uses seq_file instead to make sure dais/platforms/codecs show the
> full contents of dai_list/platform_list/codec_list.
If it's not critical, I would suggest to wait till v4.16-rc1, where I
would like to push [1], and switch to DEFINE_SHOW_ATTRIBUTE() macro.
> +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,
> };
This will be just
DEFINE_SHOW_ATTRIBUTE(codec_list_seq);
> +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,
> };
Ditto.
> +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,
> };
Ditto.
[1]: https://patchwork.kernel.org/patch/10178813/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-23 17:08 ` Andy Shevchenko
@ 2018-01-23 17:37 ` Mark Brown
2018-01-26 7:16 ` Donglin Peng
0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2018-01-23 17:37 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Donglin Peng, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 299 bytes --]
On Tue, Jan 23, 2018 at 07:08:15PM +0200, Andy Shevchenko wrote:
> If it's not critical, I would suggest to wait till v4.16-rc1, where I
> would like to push [1], and switch to DEFINE_SHOW_ATTRIBUTE() macro.
Too late, I already applied this - a further conversion for the new
macro would be good.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-23 17:37 ` Mark Brown
@ 2018-01-26 7:16 ` Donglin Peng
2018-01-26 11:28 ` Mark Brown
2018-02-08 14:25 ` Andy Shevchenko
0 siblings, 2 replies; 9+ messages in thread
From: Donglin Peng @ 2018-01-26 7:16 UTC (permalink / raw)
To: Mark Brown
Cc: Andy Shevchenko, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
On Wed, Jan 24, 2018 at 1:37 AM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Jan 23, 2018 at 07:08:15PM +0200, Andy Shevchenko wrote:
>
>> If it's not critical, I would suggest to wait till v4.16-rc1, where I
>> would like to push [1], and switch to DEFINE_SHOW_ATTRIBUTE() macro.
>
> Too late, I already applied this - a further conversion for the new
> macro would be good.
I can send another patch after the following patch is merged:
https://patchwork.kernel.org/patch/10178813/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-26 7:16 ` Donglin Peng
@ 2018-01-26 11:28 ` Mark Brown
2018-02-07 14:15 ` Andy Shevchenko
2018-02-08 14:25 ` Andy Shevchenko
1 sibling, 1 reply; 9+ messages in thread
From: Mark Brown @ 2018-01-26 11:28 UTC (permalink / raw)
To: Donglin Peng
Cc: Andy Shevchenko, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 378 bytes --]
On Fri, Jan 26, 2018 at 03:16:00PM +0800, Donglin Peng wrote:
> On Wed, Jan 24, 2018 at 1:37 AM, Mark Brown <broonie@kernel.org> wrote:
> > Too late, I already applied this - a further conversion for the new
> > macro would be good.
> I can send another patch after the following patch is merged:
> https://patchwork.kernel.org/patch/10178813/
Yes, please - that'd be great!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-26 11:28 ` Mark Brown
@ 2018-02-07 14:15 ` Andy Shevchenko
0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2018-02-07 14:15 UTC (permalink / raw)
To: Mark Brown
Cc: Donglin Peng, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
On Fri, Jan 26, 2018 at 1:28 PM, Mark Brown <broonie@kernel.org> wrote:
> On Fri, Jan 26, 2018 at 03:16:00PM +0800, Donglin Peng wrote:
>> On Wed, Jan 24, 2018 at 1:37 AM, Mark Brown <broonie@kernel.org> wrote:
>
>> > Too late, I already applied this - a further conversion for the new
>> > macro would be good.
>
>> I can send another patch after the following patch is merged:
>> https://patchwork.kernel.org/patch/10178813/
>
> Yes, please - that'd be great!
I have sent PR to Linus. If everything goes fine, it will be in
upstream today evening.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-01-26 7:16 ` Donglin Peng
2018-01-26 11:28 ` Mark Brown
@ 2018-02-08 14:25 ` Andy Shevchenko
2018-02-08 15:42 ` Mark Brown
1 sibling, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2018-02-08 14:25 UTC (permalink / raw)
To: Donglin Peng
Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
On Fri, Jan 26, 2018 at 9:16 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
> On Wed, Jan 24, 2018 at 1:37 AM, Mark Brown <broonie@kernel.org> wrote:
>> On Tue, Jan 23, 2018 at 07:08:15PM +0200, Andy Shevchenko wrote:
>>
>>> If it's not critical, I would suggest to wait till v4.16-rc1, where I
>>> would like to push [1], and switch to DEFINE_SHOW_ATTRIBUTE() macro.
>>
>> Too late, I already applied this - a further conversion for the new
>> macro would be good.
> I can send another patch after the following patch is merged:
> https://patchwork.kernel.org/patch/10178813/
It's merged. I think whenever Mark switched his repositories for new
cycle you may be able to submit a patch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-02-08 14:25 ` Andy Shevchenko
@ 2018-02-08 15:42 ` Mark Brown
2018-02-08 16:07 ` Donglin Peng
0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2018-02-08 15:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Donglin Peng, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
On Thu, Feb 08, 2018 at 04:25:10PM +0200, Andy Shevchenko wrote:
> On Fri, Jan 26, 2018 at 9:16 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
> > I can send another patch after the following patch is merged:
> > https://patchwork.kernel.org/patch/10178813/
> It's merged. I think whenever Mark switched his repositories for new
> cycle you may be able to submit a patch.
Send it any time, I'll just not apply it until after -rc1 comes out.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list
2018-02-08 15:42 ` Mark Brown
@ 2018-02-08 16:07 ` Donglin Peng
0 siblings, 0 replies; 9+ messages in thread
From: Donglin Peng @ 2018-02-08 16:07 UTC (permalink / raw)
To: Mark Brown
Cc: Andy Shevchenko, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
ALSA Development Mailing List, Linux Kernel Mailing List
Okay, I will send it later.
On Thu, Feb 8, 2018 at 11:42 PM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 08, 2018 at 04:25:10PM +0200, Andy Shevchenko wrote:
>> On Fri, Jan 26, 2018 at 9:16 AM, Donglin Peng <dolinux.peng@gmail.com> wrote:
>
>> > I can send another patch after the following patch is merged:
>> > https://patchwork.kernel.org/patch/10178813/
>
>> It's merged. I think whenever Mark switched his repositories for new
>> cycle you may be able to submit a patch.
>
> Send it any time, I'll just not apply it until after -rc1 comes out.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-02-08 16:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 5:31 [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list Donglin Peng
2018-01-23 17:08 ` Andy Shevchenko
2018-01-23 17:37 ` Mark Brown
2018-01-26 7:16 ` Donglin Peng
2018-01-26 11:28 ` Mark Brown
2018-02-07 14:15 ` Andy Shevchenko
2018-02-08 14:25 ` Andy Shevchenko
2018-02-08 15:42 ` Mark Brown
2018-02-08 16:07 ` Donglin Peng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®