From patchwork Wed Feb 14 14:48:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 10219185 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 BEF09601C2 for ; Wed, 14 Feb 2018 14:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21DF28ED0 for ; Wed, 14 Feb 2018 14:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6E2528FDF; Wed, 14 Feb 2018 14:48:25 +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 DB6AB28ED0 for ; Wed, 14 Feb 2018 14:48:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4369C267AE8; Wed, 14 Feb 2018 15:48:23 +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 11C16267AEB; Wed, 14 Feb 2018 15:48:22 +0100 (CET) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by alsa0.perex.cz (Postfix) with ESMTP id DD258266EDF for ; Wed, 14 Feb 2018 15:48:19 +0100 (CET) Received: by mail-pl0-f67.google.com with SMTP id x24so95473pll.13 for ; Wed, 14 Feb 2018 06:48:19 -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=oQJHWh1213Rl+OPYmq2msgAUKCXWAy73BLUbQ5CCMZA=; b=Z7+MjRf4HMevilxPtRy1yWUA786NfY01JWH3yEtYN+FfGWhZ8RxfK3qOcwEOjnzsXR G3/HPyFcI03j3hlFvRO4sZBp6D0IKwHSI66BN2zX0hOJXmoKCGLc8nUq4wWXTKayVdTX KvfuCftA8Z+pAHKifyH7tfwRgX0CFDUJxKQb0WKom28mVNOyRPEgV01YbParMV8AtPe5 Mpj1Q99e4hTuW2zJIuihUUTvsueeq4aehWT221OpLCfr3rQUKRB+bB7Hx/D+UcC2cm+m Lo+j/z/Zcuqq57p80uHSKCaIQOnNke2lVDbMvaXo28DykNNnJqcVPaoDdVIeAHz6+h7S Z+ZA== 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=oQJHWh1213Rl+OPYmq2msgAUKCXWAy73BLUbQ5CCMZA=; b=epJiRFcb6nv7uESlIg75LkZuEnRKdUgljEmozdoQ1O5Jyr2Az4XrJlg1FgOIkIulqc yNFczm0dy05A+KFUYh2krbHScS6e3cxZgrOt9LvvmrAXX8v5CkPxy5lkfmz3D8kRuyZB 6+caDjijy3yKNVnZncMQdgInZ/ENFXQYiSuFuW/rxOE2xWJ5oeOVVrAmwSJF4MX0eDdJ gtuWdGPmlR6D05qmkQHKIeG8Z8Tv2TKbQsTF6reQnnQ80rRhBTZvs0KE47X2pemcKKKo E6aKbELLGuR2wAs6Q6O44mvs9nMJ0cuXDgPiVqi8D8MMuI04ha3fQsJkmZaedMF0u4Hy y+QQ== X-Gm-Message-State: APf1xPDaDvSmoiQCTnyGlQqepY2dTy7gqcny8decUQ5piYI9ag1tFIuL FiKso/hgZsYx/7u9tYmSwWQ= X-Google-Smtp-Source: AH8x224/0PCmizXwiQfZL0kT8tR5Kb7KaribNRMZXbXOrsDF5E9NlDDJ4Yy5OBNFmobtxK0uYRwEdA== X-Received: by 2002:a17:902:5814:: with SMTP id m20-v6mr4714372pli.389.1518619698491; Wed, 14 Feb 2018 06:48:18 -0800 (PST) Received: from localhost ([118.73.14.134]) by smtp.gmail.com with ESMTPSA id o62sm50204098pfk.177.2018.02.14.06.48.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 06:48:17 -0800 (PST) From: Peng Donglin To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, andy.shevchenko@gmail.com Date: Wed, 14 Feb 2018 22:48:07 +0800 Message-Id: <1518619687-31442-1-git-send-email-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Peng Donglin Subject: [alsa-devel] [PATCH v4] 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 Reviewed-by: Andy Shevchenko --- v4: * resend patch using outlook email, because I can't disable gmail word wrap in plain text mode v3: [addressed comments from Andy] * add missing tag v2: [addressed comments from Andy] * modify code change description * do not rename m -> s --- sound/soc/soc-core.c | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6..f372f34 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -349,7 +349,7 @@ 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 *m, void *v) { struct snd_soc_codec *codec; @@ -362,20 +362,9 @@ static int codec_list_seq_show(struct seq_file *m, void *v) 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 *m, void *v) { struct snd_soc_component *component; struct snd_soc_dai *dai; @@ -390,20 +379,9 @@ static int dai_list_seq_show(struct seq_file *m, void *v) 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 *m, void *v) { struct snd_soc_platform *platform; @@ -416,18 +394,7 @@ static int platform_list_seq_show(struct seq_file *m, void *v) 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) {