Received: by 10.223.176.5 with SMTP id f5csp786694wra; Fri, 9 Feb 2018 07:12:16 -0800 (PST) X-Google-Smtp-Source: AH8x225sRL25qA97vCAAA8ZfDfMuftqoCN3sH6McOfdB9k3xrZpPEbQnlrztFkZp5qbDZEaoOE8p X-Received: by 10.99.114.3 with SMTP id n3mr2625480pgc.225.1518189136473; Fri, 09 Feb 2018 07:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518189136; cv=none; d=google.com; s=arc-20160816; b=vIm10ne6L4AmV/Q8YwZqIgoRmPDqRkLL2mnV0xXBzAYuZSGKKUK11uKdDEI0A1O3Db 2QJwJP0jx1+S61hayfkxHg7H2YZfkxKnHDY6TgKI8IG+GZ7QQRgPjtYgYv4k0bAnsNbg AaHcMwev2yEu80KG5X/1GeXhtm2SurbhO9hagsPWfNMzf7C12Tm7HKHUNlW6sjG8MhO8 crzfyuuhf+9MKHi9t8h/RyWi7O8g3/fFVUQkLyH7NdCO3TG+4IeAiyCECYp6iBwZd1C4 vIV082VfG1JHd1hk1FgSlbi4UrBlE4+Y3UI9qX8S5Cg9Dfa/OaNA4an5WRwLk5EP80Nr Y11g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature:arc-authentication-results; bh=+ABc0f/TpoaKZUk3hEaozIolHOvWihkAvXQigXyfFBU=; b=IuyiWeR8VjdpAfSGYEpmy0U23PEnbX1OZdyVmIFVMoe1DvdiS1b4T2BH0QJq+AXAZu qj4xQkDYvNDJERoHbby8cIgkGGPOhO3EoIHug4IgJGWcvZbl8en0jbX82cm6vOrAF/51 umleeuperMkFAjnyURTutKaqDJojZ+CVXVe2EfmboHm9jyUnP/7CtoE4qef2boHlxnoy GBsDHOMQfiUQJj5gfgB8TXZcCOki6iS9ube4hGrNwQIegCet3wGLgBgcFHN1XJHE7jms /vbzn4S9AS6Bx/TEpkUe1bGx58ReMm4fYk4PNjxa4I3ZCCA8Tan+0+J8NXT0LLULRa7N GD5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WgdRPnhW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si1488754pgf.150.2018.02.09.07.11.58; Fri, 09 Feb 2018 07:12:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WgdRPnhW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751144AbeBIPLS (ORCPT + 99 others); Fri, 9 Feb 2018 10:11:18 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:37736 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeBIPLR (ORCPT ); Fri, 9 Feb 2018 10:11:17 -0500 Received: by mail-qk0-f196.google.com with SMTP id c128so10339177qkb.4 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=S786PTrsew5pd4GRl6SxiJ9QbNiWbKX9CVtr2dWhkA9ARIp1vCC591aeJYo7X7QAPL Ppmdi3+VSXE8mjO+Vg1BeXGEibb4+nBSD64dLYiBxKXb2uBFOswQdk+3JDiFsiU8nt2c AQ34IxiL9ZlFoyhXx9U8D547Miy9zVeLHQYa6pwh7kv8Cvxa72voJ4cJOessSZsUXI8o JGUlZphbskPuAb+fTgZa8Fo9SisADCyvWI7QsA8KNGa5XE6q0w/2hfXI8CkIJ3NJVJe9 2h1UXX+G5th+KvZEsLSedr0jHMI0RqP75raJPhXubVtODUdJhX/ouYAlBu+4zA/ygHni b2OA== X-Gm-Message-State: APf1xPCAt5IiLiUyh6Pw/HnwJp3B2fJwPMrjFgOEq/Jz1D6ovTP2GGSl 4iRUBSsybvn9GEDJ7bX4yugMbVvCHY2YTWFyMHk= 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: Subject: [PATCH v3] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication To: Andy Shevchenko , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: ALSA Development Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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; @@ -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) { -- 2.16.1