From patchwork Fri Feb 9 15:10:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 10209415 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 3980160236 for ; Fri, 9 Feb 2018 15:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28A872964B for ; Fri, 9 Feb 2018 15:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D3032964D; Fri, 9 Feb 2018 15:11:23 +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 7499E29650 for ; Fri, 9 Feb 2018 15:11:22 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AEDB4267198; Fri, 9 Feb 2018 16:11:20 +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 2609B267820; Fri, 9 Feb 2018 16:11:20 +0100 (CET) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by alsa0.perex.cz (Postfix) with ESMTP id 10880266E55 for ; Fri, 9 Feb 2018 16:11:17 +0100 (CET) Received: by mail-qk0-f196.google.com with SMTP id w128so10351887qkb.5 for ; Fri, 09 Feb 2018 07:11:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=+ABc0f/TpoaKZUk3hEaozIolHOvWihkAvXQigXyfFBU=; b=WgdRPnhWlg45zp/Up/nY6evDAALTccYzzgbhjfnhbMSU48SsGhwVmkEIz0s6qQRwiv asq6Q9yUuH7M8o/HHUy3lETMEkCIo7xvWyB5sGXNjbFPSnnw9Ok8tcdnq6TR6XfOyjS9 qmM9R+o9Xs/QVm6mbavDRRuNr90JMfd+jqgyAeC+imBi/Upm638xuIrHygy9kf4zRsfg Ob7MKQA5/sHG/8QdM3V6Cag1Q39ltAS2n92uWL4gJfesk1yrh5VwYLnk20NWCLGMfXj/ pRy/r4tvSDrWEQOMS9NMf/jrM4mHEqyX7zlcLXGIHkqzytQv8+ojjy0sWmi0BXvA9LEC qvaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=+ABc0f/TpoaKZUk3hEaozIolHOvWihkAvXQigXyfFBU=; b=sDo8m+LAGFCakwbYwkHr6KreM+hOvi+mmki2//LO+SyEZBKjYlhdZ7myVvsK+C47XQ HHcV9FX5Bd3fsUh2iG4Tf+1gKfXs+llupQ/BTffREfCGmcHCXq/fCHRyQqV+IBjp9xs8 w8VvDqG9P3x210E5fn4/0fBIy/9B9qtJ02ivs7M0B/E2RMn/dyxtj5IbRR8tt9bQ0Wir HEXBQ5yRqHyvftkq0uJRxMIsp1e9CG68l8T4wGXET4p2n91WRT/hIn4ouZLWb8oWY9cv daTgpyd6vPlTAVS5j5Zovg6EE4TnpiXG3U7KjFnKDBWygwK/c4e/D84anj8o9Bkof1xn pDWA== X-Gm-Message-State: APf1xPA9GQtxTqxk1bLAI5SfgBc8rBi/4yPTIz2Q5Mv7MRNMns/+A+3B 7h3wNFRrsnoDG9qPxli0IGgg8WrC6No/Aog4jRo= X-Google-Smtp-Source: AH8x226SpsIohAf+3UXFzLqWlHbwTj/Ur0S1liQSZ6qdCnq4Kp8VnbuyoEMzDLkzUu6IdGNmiVaOG5FsDVfA8MUZmFY= X-Received: by 10.233.235.87 with SMTP id b84mr4511248qkg.102.1518189076874; Fri, 09 Feb 2018 07:11:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.45 with HTTP; Fri, 9 Feb 2018 07:10:55 -0800 (PST) From: Donglin Peng Date: Fri, 9 Feb 2018 23:10:55 +0800 Message-ID: To: Andy Shevchenko , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: ALSA Development Mailing List , Linux Kernel Mailing List Subject: [alsa-devel] [PATCH v3] 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: , 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 --- 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(-) @@ -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) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6576c9..f372f34d7702 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;