Received: by 10.223.185.116 with SMTP id b49csp773044wrg; Wed, 14 Feb 2018 06:49:46 -0800 (PST) X-Google-Smtp-Source: AH8x225FUPm8FusU+CHiB11xFeH4YQW3jTOMNoCoFY6iu4li5g7/kVYw4TlP4me5nmaOxPBKvsW5 X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr4698202plk.212.1518619786054; Wed, 14 Feb 2018 06:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518619786; cv=none; d=google.com; s=arc-20160816; b=LW1I8uGgFHqtqLAtITXhsuwvvqsOA9auAD+czps5hEon+TOVuD49cE/CKTFuyL5O24 OiUIGgPt17UpokmoTaF/cJ5mEJzofbEaMDr2Mxt8QzV32+tJwSSF8Xdprt+CbyD1X1IK PRWEfxaSFXoLzfqE+m/ppu0/IrgKe4ml64MA+KL0bmLRzS9dRaL59qDF8gwDzL8U2WrM Y6G7n6fKxOJh8iVOpkxejuaNJhenW2rRHwr3/PpSJCGF+JQ07foUsByILD5ZEYW4UyBf HrGHR6QQgZvvEaeNPdJFnaN77YyOhHD/QpjGOjzb3r5R1dlSCnJKZHqro0fvDqYTr6O+ v2Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=oQJHWh1213Rl+OPYmq2msgAUKCXWAy73BLUbQ5CCMZA=; b=j+Osd+LvaES91Rc9PlVMLaik1W9x8oyoQ9vJ9dg/Wd0y11DIB5lPf6k1/03gKSlZb3 rMfunD+n/8k5mBRQYCvrx6JBvgMSN4AJgyccg/ZAjsSZERZAqapS9Za5sPxqtTabahqc Na0ibnaONmzu7BHBDLFqlJ0GgBbupJolIS8LGj4WS0/30FCPTlNV2pHopP/1zM1eOnm2 ELOhAX2bpu7unrqqS1n70HEAhaB7lZ5iU5zDOFu9vTNQ462r+ZftEvCMbGVUoeqWH/BY x2V3tT1HRQk2u+Nxjizt6t2j95LGUA4w2JDnoLYGWiw1c8IgbRVH6aV68hQte2h5v7qk pD4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z7+MjRf4; 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 b3-v6si188543pli.440.2018.02.14.06.49.31; Wed, 14 Feb 2018 06:49:46 -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=Z7+MjRf4; 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 S1030687AbeBNOsV (ORCPT + 99 others); Wed, 14 Feb 2018 09:48:21 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:35436 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030617AbeBNOsS (ORCPT ); Wed, 14 Feb 2018 09:48:18 -0500 Received: by mail-pl0-f66.google.com with SMTP id o11so5020508pls.2 for ; Wed, 14 Feb 2018 06:48:18 -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=dtNtj0saM6tHhUFaJBq8kxa8lZeh+cdSqcAY08lvxoietIkXxg3BiV/U6sWDADnXjD 9/5xZgzX1rdRyh2iZKiVNH558c7hLtGAw99ury+AXY0hH8YA86Ri/lvr2LYbG6QNXWqv QCBmuXomfS4fci9mKBlC2vALHwi7H3cGb9GAJcN3JxZY81cvVGNKEsMjbrEztwRZHOCE T5/mRcE3bX19/QhQH3KUHHm+VvbaRp4RKzKenWTDYSB1gQnGTIZbG/L+nWxbcXfCpw17 pe9l4J3qIJ/PUE+GbdtrAc8ERRMboBidnCrGKdq06uzcWEEoXmIQhJWM7+w5Qe3ViN9e +K3w== X-Gm-Message-State: APf1xPAtEy8WeiXFKH8QUBR7lbhfrMm2UZXH1q2tnj7fHgFGLnl6o9YE sco79wYoTDae7X5gjVO34Ck= 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 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Peng Donglin Subject: [PATCH v4] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication 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 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 --- 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) { -- 2.7.4