From patchwork Fri Feb 9 06:52:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 10208345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E76A7602D8 for ; Fri, 9 Feb 2018 07:07:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71EF2932B for ; Fri, 9 Feb 2018 07:07:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBBA328B7C; Fri, 9 Feb 2018 07:07:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2591628A8E for ; Fri, 9 Feb 2018 07:07:45 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E497F2677A2; Fri, 9 Feb 2018 07:52:48 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1D28C2677A8; Fri, 9 Feb 2018 07:52:47 +0100 (CET) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by alsa0.perex.cz (Postfix) with ESMTP id 9D17D267767 for ; Fri, 9 Feb 2018 07:52:43 +0100 (CET) Received: by mail-pg0-f66.google.com with SMTP id l18so3024319pgc.5 for ; Thu, 08 Feb 2018 22:52:43 -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=WYWbmU4mJHsDZ6h3remO9JQttcZCdEd7Yl5aYEEyPNY=; b=Bk3d2MgUhJxfDKbwfS9z6Tu2+uujc/jFoCNMJ/neh+FhZUUHAmJFE2OFAu0KSeXdP1 n7b3OyTM68Ql/w8kF4wjH94lkVFFLVF/CepzGAizb02UXnacmao6Kwk4diIOnX86kcZP VSVn2AflrkUnTFvntNxj3XPlGX8vBFEJ7D8CUaH7yThFx0K3k3ePYY3mB5RtT0NWDC9M wAclbJnJ2AQB9Y9dOps5uFBpLj2mMYaTFxVKOZqXTUmETEfO6mMOZAkPdNFXxGu5Tlkf 6GbAfzmULbusFI3eh6bJPMXgYCY/WO9gh526dvC6rtDFS9zC4Kqc5UCRUjNR1QVfDFlF aUVg== 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=WYWbmU4mJHsDZ6h3remO9JQttcZCdEd7Yl5aYEEyPNY=; b=hlmMg4V+xKKzDHu42VzgQ2JPJB942c8QMBgwMC/tnfu+XPdTS1NNsmJnrHWr3EpUjJ 8SUxmz5PR8NKo8+/lJr1KaTsGsupPpAFqeRl0eChDAY/zshypgViL+Ff3Ddki+l5F15z mn3yGoNTOw0nRBZU4pKQqTxKbLxbRlWnpTdaV81Ik0lG5lpnWt+r7Kw6LpsucSerQO+G 326Eyos28rzzjOlj+E/xlku4T7xMZQ9MFLmxGP95Jt0HvhEmCW5ffF0tHLHnLxz8OSBa DdnjtvmzRNPjEhuA/jJK+ABWBkNvXwEJtAscP0sKdPLfbhBQvFUC9+xusij9o9vTWSuC YntQ== X-Gm-Message-State: APf1xPDsgolbaPWsBOUccSSuUgWH51vqw/Ojwoz3BBNrcuyE2y+YGOpz kB51u60n80F6NiOcBxswm88= X-Google-Smtp-Source: AH8x2262C6Jar37YrCJvWQ0p9r47exg9Lg0pC58l+s5DS6AW35tu9+zg4Lh8tPThuuMao4qGww6ERQ== X-Received: by 10.99.134.65 with SMTP id x62mr1463233pgd.291.1518159162042; Thu, 08 Feb 2018 22:52:42 -0800 (PST) Received: from localhost ([111.207.121.248]) by smtp.gmail.com with ESMTPSA id h18sm3354631pfi.174.2018.02.08.22.52.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 08 Feb 2018 22:52:41 -0800 (PST) From: Peng Donglin To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, andy.shevchenko@gmail.com Date: Fri, 9 Feb 2018 14:52:05 +0800 Message-Id: <20180209065206.15543-1-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.16.1 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Peng Donglin Subject: [alsa-devel] [PATCH] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {