Received: by 10.223.148.5 with SMTP id 5csp6909922wrq; Wed, 17 Jan 2018 21:32:40 -0800 (PST) X-Google-Smtp-Source: ACJfBothAiqkpSFdhZr8UUebcL9GjdPpbat2vL4sTnLFbY9KQ02qKXNdhHoTvIBXzBfuw6rF9C4Q X-Received: by 10.84.254.71 with SMTP id a7mr26079135pln.317.1516253560823; Wed, 17 Jan 2018 21:32:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516253560; cv=none; d=google.com; s=arc-20160816; b=Fv5sh1bdEjSE/PcdkNtw8pO/saZLlyo30lidEBF1IkBrZc3eJwGTmSJ7R5u1qj1Ap2 2Pyl6gdiN4l6c9W9fyxCr9Sesj2B6eUauiCgxJ/Y+/uDa2cY4vPtO8yPeo9i8SUi6glv 4J6Hx+7mV1/VkH/20BfZ+0uxCt3m1G2ufrmxOaJYoHI9cva0nC6nxdJjIqja/p/hzJve V+xIoF7YJPMwublCxgWpj1aQdRW7kReg+7ximDs6UZKU1vRogDwqVj9N0q7GQsMLlflA iqKy5KXYKrQvl+gn5cUArZ6F4ydJ6KHB120dOl6HVgmxaMWJlfQe3TM9wYJA/3OHu3aD xOeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=jo2Z0BmyF8wUY2tGJ0zlD/M2Lq5H5ZsRkv2Ei1+rxbw=; b=oW/D1sOGYzvGxa8I2HYWlWWffehMiE8cASm028ePf3bbJ/i85JedFCYzrjRLFVuoUp 95lHVR4F9OgOzYcXYd8UOxDHa+0oy/yMQIeG3sNwSvIwCGtQAc/6Azu6G8qJCOl/yoDf 1OVd38sAFcCsFgexK65rxHzHBkxxoeEMgwTbCRHY+VLWVgcgwceNsVwOHHuKEuF+BJd7 OOONuaahAZ75J51OIyZNXcfjhQZj3fAkvZMy14Cn241T1RGIkrTGG+qnz+5WsxVanX9Y rG+usKXHSLibSocDuwNkwDfrbZBVIX9peU74YMZB+jGe9kEIoOLBD9VSnab9Kk9AeiGQ 7mTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=auIzltWZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16si5833893pfg.325.2018.01.17.21.32.26; Wed, 17 Jan 2018 21:32:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=auIzltWZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754572AbeARFcB (ORCPT + 99 others); Thu, 18 Jan 2018 00:32:01 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45262 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754170AbeARFb7 (ORCPT ); Thu, 18 Jan 2018 00:31:59 -0500 Received: by mail-pg0-f66.google.com with SMTP id c194so13117943pga.12 for ; Wed, 17 Jan 2018 21:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jo2Z0BmyF8wUY2tGJ0zlD/M2Lq5H5ZsRkv2Ei1+rxbw=; b=auIzltWZUi5gjjKKxQlA1NNV5DfFr5cMmSCHkoajFfz7jkTmPuUnahz4xnq0m5IyZy ByKXlZqTUwM/krKVj7Zb9ebVjLDKV5G0Sxcvliz6XGlamET7avt07nAQjxudFV24cw5V hoNxeTELz5MVQuShIKnfS5jQSYRcQv6PbN8rzw21p4W0GVxp7oUvBNs64rhkx3c8SwGO J9NEVqlMGfQMvixcA00LFhpKhty66BN1/CNVkthYhHk4Byv6ziLOHImmDHmtNQYZLLZz ht1WCBn5MhsQerYEpS48CwvRDb2MwPbLY368/EloyzA59/B/s8gkenE49Bmyi4Pq9eln xHfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jo2Z0BmyF8wUY2tGJ0zlD/M2Lq5H5ZsRkv2Ei1+rxbw=; b=NENednRknjAxzI8bw9VWICEINRltZkcBv+VBCnc3BKaz+DzV0QRV4nbSXbRmmM6dFu WanWP/UoBQXCZCs1noWSPoBUZkIIOJIHEZjsCCN0oxrdYYHKu8pPx50Sw+Pkd7/Vcku8 B5z8XtWThv4/1otFmfD0eZnA2ygRBjAPKvMUNuCjlehaGMF9uLkib5+ZS7T36D909qiW 6Osg1nTOKQXahDApMwXiP+QUpmVm/svaNhJd/I5mWqQEpHgY16lLdPtsHiflLgfL7El6 6/hyZ3kNxkM0vB55FYZLnPOyERCWjC2IzaFvhGiv8l+xjahWVqGupdqdcEs0vjkGFPa5 j21A== X-Gm-Message-State: AKwxytdzDFqrJDcUCB8E7r716Ae7i7nw3nR0cKfVn1vK7HVeiVU9OgcR LRhGqtTx3P3riO2stOwxyhc= X-Received: by 10.84.235.73 with SMTP id g9mr20406924plt.9.1516253518895; Wed, 17 Jan 2018 21:31:58 -0800 (PST) Received: from localhost.localdomain ([111.207.121.248]) by smtp.gmail.com with ESMTPSA id k62sm9263880pga.42.2018.01.17.21.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 21:31:58 -0800 (PST) From: Donglin Peng To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Donglin Peng Subject: [PATCH v2] ASoC: use seq_file to dump the contents of dai_list,platform_list and codec_list Date: Thu, 18 Jan 2018 13:31:26 +0800 Message-Id: <20180118053126.22082-1-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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