From patchwork Fri Feb 9 06:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 10208323 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 1EE0A60247 for ; Fri, 9 Feb 2018 06:58:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D589291A9 for ; Fri, 9 Feb 2018 06:58:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0173A293B6; Fri, 9 Feb 2018 06:58:48 +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 2F4E2291A9 for ; Fri, 9 Feb 2018 06:58:47 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2E4222677AD; Fri, 9 Feb 2018 07:58:44 +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 A1ED52677B5; Fri, 9 Feb 2018 07:58:42 +0100 (CET) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by alsa0.perex.cz (Postfix) with ESMTP id A0500267767 for ; Fri, 9 Feb 2018 07:58:40 +0100 (CET) Received: by mail-qk0-f195.google.com with SMTP id m130so8836991qke.1 for ; Thu, 08 Feb 2018 22:58:40 -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=ZJI5r/5N/SSV3nvLTsvm5X881CfSMGHhNReviYn8s30=; b=Pmb6on5Bqsai0/cW6aa9i6hqW/CWgxkQ/e3wHwn9YU+fnoYjNanaQQz8uDULiLLi8L Vnnt0z+tzqmyqN5L0k6rLJdMDwl3uiY5X0JQTmK5D7W8DjTOeDVARh2hPXXSxqY4ysOU dQOiVCHl/H44qHbqA6n470q47imn2Ye74ZqqO5s+yCJFAUny0h2RiUX55v+7Dzg1LkyR nUI1m2P62TmBNqXsTRzU9NWJLsrHQK2KCfbyb0I7opHYWIxIIYtVAg4O+2cYf+vBhvww ZU949DzB5syn15A7ANR5tNev0aithBliA2KYQiZtSdR7bXCzs7o4mOb8uqNgs6o7HA8O +yCw== 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=ZJI5r/5N/SSV3nvLTsvm5X881CfSMGHhNReviYn8s30=; b=KDOJm5zWt9oEXAZ9P0BbRN2Tbskm7m5f26R50l6tVICK/cbLpehVp0HuFfWe4JWNhq /1n9BB4Z9z1Za+/9B/u3NQBRoYvPyAnEwDAVjfQPe0Vd1Gu5dhhW14GPdO+3DrrIUHXL 5sHPeU91L5dD9R9JQ/rwiGRrIJhacKQ7mrpefC+3v/mr3/o4v3+GUHMKtu0uGVztVUJB 8G/eZlNQeKe50xenOswCBEGQ91OfgrMi4kpiPMgzOGE+pdNEqRTA0xfz37wnXPPD5c1n gQXMiZPlhLC+MMXNOOW0/c2PQRvmSIWCsjW/xRP7livwCvRw3QQUn7dJ7WdmVaqreLbB farg== X-Gm-Message-State: APf1xPDz9YydwXWnC8+uHZa2tKq+Xi2JlMJGcsvxKGFZ+bVzDJkdcSl1 ukGkrORj/g4ahjsGDrgATxEHNbuB80AmgEh5rRY= X-Google-Smtp-Source: AH8x22778d3QlP7at2PW71HxO3GKJ8lOVAt5TUeqcIsvKdI8/qE6EJnaK8WMQKajZNXhgKH2NEITjFXKhM4Dg6Q4IqY= X-Received: by 10.55.217.28 with SMTP id u28mr21803qki.148.1518159519205; Thu, 08 Feb 2018 22:58:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.45 with HTTP; Thu, 8 Feb 2018 22:58:18 -0800 (PST) From: Donglin Peng Date: Fri, 9 Feb 2018 14:58:18 +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] 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 Reviewed-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Peng Donglin --- sound/soc/soc-core.c | 51 +++++++++------------------------------------------ 1 file changed, 9 insertions(+), 42 deletions(-) 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) { 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;