From patchwork Fri Feb 9 14:43:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 10209371 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 10C8960245 for ; Fri, 9 Feb 2018 14:52:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48CC528C8F for ; Fri, 9 Feb 2018 14:52:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D43E28E43; Fri, 9 Feb 2018 14:52: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 735D128C8F for ; Fri, 9 Feb 2018 14:52:45 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 133B02677FE; Fri, 9 Feb 2018 15:44:25 +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 F34802677FF; Fri, 9 Feb 2018 15:44:22 +0100 (CET) Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) by alsa0.perex.cz (Postfix) with ESMTP id 04A26266E55 for ; Fri, 9 Feb 2018 15:44:20 +0100 (CET) Received: by mail-qt0-f195.google.com with SMTP id q18so4030052qtl.3 for ; Fri, 09 Feb 2018 06:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jPzOM/eYW1Iw/HpfHIchJjVjKueFenXoIiJqHsXskw0=; b=joq51qVFVmbHlYUBA9VmO3tyH3bvQrr8Zg2GJAFsV3I3/B+Not0YkLadI8kSah3B70 iwYgTAkUARSryB6Ldvx95HO6hPTvC5QMRgTL3OISjWFf0eJR3VwQnpHUgwBDwWF7FP50 UvYD5vEgPhtkQjOUTQFg2+kQmj+V9nKPpRHU1Dzpd8bn7Fv9N8Df2DU8uEDU/Ee5plex O6WBTEZQTtnheq1zcdypLfZQ69z4PrvfXIy83j2sNozhDIaQCiOZJxkOnc6U42k6bZTf oi3oDum7sQaY3X7gtzYrdRn0DY/M5PA1b/zj2GyBtd6dBSnAU4hYgW3DJadXshpSfC++ c9+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jPzOM/eYW1Iw/HpfHIchJjVjKueFenXoIiJqHsXskw0=; b=fnks3nyj3SmAOAARwJp0UUIb2fOxfrFELBrMpeb/vEuRjWLiBbulOXEGZJpav5w3eF C30FiH+wsmQ4kENp1EEygWT3kQGPRuajNfJg1h29lCaqrtHVB6WGNDy/MfWWDyfMxIqv I6bKvY6lPHj2FkVxwf4LIyHKY6LO5l1VjPPQgwG6wjqCZh+LpCnbTWC9xJPEdIFivwHB 4mgu5WV4g112ET6HJVcoaiz5VBqHi+29WQufUlEj0h45SfnIjfcVVR3lnWKyS5RaxJCe 4+TomyU7UiyBfjIU+J3yyJPM3aBn8N3HmFWFtrlPnilF7b64bfksLcDfr1uRpWHSdiu2 VeNg== X-Gm-Message-State: APf1xPB511LIQGQb6L7FABt6uNgj0kCHWXqbwGnajRHNjphl7G4TPK5/ KmYdZHkH3CG5xDNS2jP9UVh+PrwF7ux4LHffc/g= X-Google-Smtp-Source: AH8x226GJpizy3/NMZSjLm8c5v32EevvjNwHtKcmX9wQdd8+uZYXilC/E40QXzw5eJabiCqGjLe7kxXvPfpQ9F9pEwM= X-Received: by 10.200.35.188 with SMTP id q57mr4599884qtq.73.1518187459080; Fri, 09 Feb 2018 06:44:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.45 with HTTP; Fri, 9 Feb 2018 06:43:58 -0800 (PST) In-Reply-To: References: From: Donglin Peng Date: Fri, 9 Feb 2018 22:43:58 +0800 Message-ID: To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Cc: ALSA Development Mailing List , Linux Kernel Mailing List Subject: [alsa-devel] [PATCH v2] 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 --- 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;