Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6997974imu; Mon, 3 Dec 2018 06:14:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/WHdo4/kXKlJi3aI0n5zxi743E2y/fikOE1ENN+L2sqAKIXpFYfFiRiGPmB/UbjqjQQVLpx X-Received: by 2002:a17:902:bb05:: with SMTP id l5mr16407130pls.230.1543846480758; Mon, 03 Dec 2018 06:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543846480; cv=none; d=google.com; s=arc-20160816; b=Sbbco2Zy1mROPPlwvvHmYswHWWsv2VDexPbO7Em6GxDc0Ah6r+/4RQWqK2LyokF2O3 ckWk8eIRHYbYV06R3c9mI89OP3LvzqPtJ9yiXUy8bXCX5DCUNyJ2bn/qoXeHiYFQgUAW /MxU1BIS+v/tcD0cei0nnvtORNJ+FyN2xenTTNnnF+d4sM4xm2L0+KGEOsKaX+4xlPGJ yMWwuf+ITxrs6Xtz3VZgCkL5g8Q2N25H0r/yYnaZMH+dpTxn1U9ohZAqe925rHo11T/F Wyh8tiLjOES5A2qiBuqQabD7wK9wKLNrKN9p6PNK50R7WxT+QbievcmULO2zSRWeebSY j5Tw== 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; bh=r+D58vqhoh1PK9pBBnsuKM3XPy+YTPos1Cpkelo8ArQ=; b=iMiWAkEgmjAIU2U3j5QRs5GcfYPpg27UDeQqAkCAgQb9YZC9nvY441t1I4qYg+boES daBU0JDz5GPjPaWxfZ4QUQLkSsxW3vgdUuqUOsx+YA+AMjUfAnPmTzB9DJvZTjb7I7z7 t8qleXbsT3mukIaXgmvLlWW95TVzmvLM1KG8URI9tJOUvCVCez/bDFKb+aHJYDG9NLxY b8qmh59zaa0DNbbrK01CkgnLFH1zYiEwILnCq2LpAOJX3FH8qRzCS0lZfmhwf77W91Le 6rpFJmnDQ5fBNCBN+oV/veWdSFuBqOtRcyujUlpOBtdQ22y7zWToUVfzRTUelf0ID340 Mk9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iiw8v5KF; 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 d189si13282413pfa.70.2018.12.03.06.14.25; Mon, 03 Dec 2018 06:14:40 -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=iiw8v5KF; 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 S1726347AbeLCOOu (ORCPT + 99 others); Mon, 3 Dec 2018 09:14:50 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37889 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbeLCOOt (ORCPT ); Mon, 3 Dec 2018 09:14:49 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so5772640pgc.5; Mon, 03 Dec 2018 06:13:38 -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=r+D58vqhoh1PK9pBBnsuKM3XPy+YTPos1Cpkelo8ArQ=; b=iiw8v5KF2Di3Lm67csx1jvKUP/vKMEXNRC27Ewx1JbFt67jPECxNgMjMyFbwYO2vMN Op3iCcthLh4q07rXVBDjmuPqMCuMpsE4ZYf9CGsgCrlSmyfSlIX8tW7iOBHeuYrbzrsi nQ6Jw9PSvU3dMWvBHtnO/mF/Qvqj1mir7h/922NO6PbcZVPX1YADt/knqlPQo4XZpsTG usMd6Y9MgqAr4cnkuVmqoC1OiGYToxjbh3v/ffgyc1tTMoCrUax5SD6BoUK+ayv4nPgp WSuLLzCV7kolpXUA5XFmpoXZl3E9Nh8E6Y32/IUzmR/6Fp+0Eqb3utWymIdJgG5GLNMd EHKw== 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=r+D58vqhoh1PK9pBBnsuKM3XPy+YTPos1Cpkelo8ArQ=; b=Wzdq4nCf3Qsil9H4fUI9V3TIsO0meJWZ7ZNnpyrpfTvD5FlojQxHxCikxxhdR2zlty tiAlvDGlKMFynLXmUDPyjndIoF1IjstU5wrqvBIA9jGSl2Ne6WEyDFi7eAuwniRsu2SZ kTwRtmXiolKl/ZhpALa5QyVIzkSRwjBqJZwEaIaGaHRSol1iyoK2Z2+qT09JJNZ4xsx8 QHJvfxZM/XklUwMvJPJB5gJRbQ6hGIi6A695FeoBzt/UkyQ1ewIW/WYoOzRl/l+DJYeS gPt8Y4wo6J9/BR575kx1i+mpWdNsMf1qKdMRUI1JXmn2j9EXDaBV980OsyIKG1wYegk6 7nOg== X-Gm-Message-State: AA+aEWZgUew7vRk2p0Ry3eExGLz2+cU/7B8SYot8sLwyfYci9HARUxSY Uo4VYeDeTm9eg2cm+AtbdT8= X-Received: by 2002:a62:60c5:: with SMTP id u188mr16104283pfb.4.1543846418408; Mon, 03 Dec 2018 06:13:38 -0800 (PST) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id b9sm19205995pfi.118.2018.12.03.06.13.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 06:13:37 -0800 (PST) From: Yangtao Li To: jakub.kicinski@netronome.com, davem@davemloft.net, nick.viljoen@netronome.com, joe@perches.com Cc: oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] nfp: convert to DEFINE_SHOW_ATTRIBUTE Date: Mon, 3 Dec 2018 09:13:35 -0500 Message-Id: <20181203141335.12928-1-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li --- .../ethernet/netronome/nfp/nfp_net_debugfs.c | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c index 69b1c9b62e3d..f314cc9966b3 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c @@ -8,7 +8,7 @@ static struct dentry *nfp_dir; -static int nfp_net_debugfs_rx_q_read(struct seq_file *file, void *data) +static int nfp_rx_q_show(struct seq_file *file, void *data) { struct nfp_net_r_vector *r_vec = file->private; struct nfp_net_rx_ring *rx_ring; @@ -65,31 +65,9 @@ static int nfp_net_debugfs_rx_q_read(struct seq_file *file, void *data) rtnl_unlock(); return 0; } +DEFINE_SHOW_ATTRIBUTE(nfp_rx_q); -static int nfp_net_debugfs_rx_q_open(struct inode *inode, struct file *f) -{ - return single_open(f, nfp_net_debugfs_rx_q_read, inode->i_private); -} - -static const struct file_operations nfp_rx_q_fops = { - .owner = THIS_MODULE, - .open = nfp_net_debugfs_rx_q_open, - .release = single_release, - .read = seq_read, - .llseek = seq_lseek -}; - -static int nfp_net_debugfs_tx_q_open(struct inode *inode, struct file *f); - -static const struct file_operations nfp_tx_q_fops = { - .owner = THIS_MODULE, - .open = nfp_net_debugfs_tx_q_open, - .release = single_release, - .read = seq_read, - .llseek = seq_lseek -}; - -static int nfp_net_debugfs_tx_q_read(struct seq_file *file, void *data) +static int nfp_tx_q_show(struct seq_file *file, void *data) { struct nfp_net_r_vector *r_vec = file->private; struct nfp_net_tx_ring *tx_ring; @@ -157,19 +135,13 @@ static int nfp_net_debugfs_tx_q_read(struct seq_file *file, void *data) rtnl_unlock(); return 0; } +DEFINE_SHOW_ATTRIBUTE(nfp_tx_q); -static int nfp_net_debugfs_tx_q_open(struct inode *inode, struct file *f) +static int nfp_xdp_q_show(struct seq_file *file, void *data) { - return single_open(f, nfp_net_debugfs_tx_q_read, inode->i_private); + return nfp_tx_q_show(file, data); } - -static const struct file_operations nfp_xdp_q_fops = { - .owner = THIS_MODULE, - .open = nfp_net_debugfs_tx_q_open, - .release = single_release, - .read = seq_read, - .llseek = seq_lseek -}; +DEFINE_SHOW_ATTRIBUTE(nfp_xdp_q); void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir) { -- 2.17.0