Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5664539imu; Sun, 2 Dec 2018 00:16:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNfQ5hqwzLKtjvQw17etEfYkQJy0d2af6mRNgqcpYsgYt6kIJ2aCtyq3SzFuvrK2NsN8Yz X-Received: by 2002:a62:d448:: with SMTP id u8mr3069628pfl.105.1543738608031; Sun, 02 Dec 2018 00:16:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543738607; cv=none; d=google.com; s=arc-20160816; b=rjDYIhOBa2Zp+l5ACEkmkQrHCE37mSTYN5beKeXIqrMcB+E46u7U0vbbIpVmQKF/2+ FO9cuSPk/P7ShXQWUAmheXoVlLLlqMI9MHGncqpdMbNiFQANUxT0d1ajvQWTwYfLrOD7 EA4sL58FMh8EHxBJ8ClWPdcwN692eXlk1wGEutNErHtDLcxNRwVABekDXqH3z+6cT9lc +JT9MJDIjT9KSctfohNaJ5MFnoq2P+k63sCT8awtwxU0os9KuPVAzgoDrgDvaxCTD9Zj V9ib0NEKJrxyoqxT6n3F/R0Hg8wP6aFEnOxkx2fCPp4ZdiY3P4PvBcMF1ircXJ6Cn7G/ xJ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=rbZ45x4N3ma/ReWGpvUWv/GvIZ74PMusiFcGmBaRoaU=; b=x8xuUyxDyzMA1T66etKqoLqWx9M9krohtqgAcMDozEn72T3MzyJ6SDPKH2viLOArdd LkZJCQCwzENFMENrkIrLm6J0joicnEpvkOLRRpNls69oeI1eOLhHS2+serDrjNnKVbOF aDbuvQKfkSPcAKgqwCcC2wY+54ty284BYsnd2Tm+A41WcCx8GyuxQZiEc1snpupaXV/t wMkgp4/OGiA8BUNrAD1NYe0w3X1JAxwNq1zkDH6guacYwTg6p8NDZL4eiv7l97dvEc70 JGqLfGAfNnuPlzJc15l9quRZ2iIHWeqIfno6Rjv3Q6mtKJTofC1lA34GjwH2nvQrp19m 3dQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si11233951pfa.6.2018.12.02.00.16.31; Sun, 02 Dec 2018 00:16:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725773AbeLBIP5 (ORCPT + 99 others); Sun, 2 Dec 2018 03:15:57 -0500 Received: from mail.bootlin.com ([62.4.15.54]:33063 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbeLBIP5 (ORCPT ); Sun, 2 Dec 2018 03:15:57 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 0D670207B0; Sun, 2 Dec 2018 09:15:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id B00B7206D8; Sun, 2 Dec 2018 09:15:43 +0100 (CET) Date: Sun, 2 Dec 2018 09:15:43 +0100 From: Boris Brezillon To: Yangtao Li Cc: robert.jarzmik@free.fr, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, richard@nod.at, miquel.raynal@bootlin.com, keescook@chromium.org, shreeya.patel23498@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] mtd: remove DEBUGFS_RO_ATTR() Message-ID: <20181202091543.73c74aea@bbrezillon> In-Reply-To: <20181202073202.10587-1-tiny.windzz@gmail.com> References: <20181202073202.10587-1-tiny.windzz@gmail.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks like getting rid of DEBUGFS_RO_ATTR() is just one of the change you do. I think you should change the subject line: "mtd: use DEFINE_SHOW_ATTRIBUTE() instead of open-coding it" This way it covers all of your changes. On Sun, 2 Dec 2018 02:32:02 -0500 Yangtao Li wrote: > We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define ^ missing space > such a macro,so remove DEBUGFS_RO_ATTR.Also use DEFINE_SHOW_ATTRIBUTE ^ here as well > to simplify some code. If you go for the new subject line, you'll have to change this commit message. > > Signed-off-by: Yangtao Li > --- > changes in v3: > -remove the blank line between the function > definition and DEFINE_SHOW_ATTRIBUTE() > --- > drivers/mtd/devices/docg3.c | 16 ++++++++-------- > drivers/mtd/devices/docg3.h | 11 ----------- > drivers/mtd/mtdswap.c | 13 +------------ > drivers/mtd/nand/raw/nandsim.c | 17 +++-------------- > 4 files changed, 12 insertions(+), 45 deletions(-) > > diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c > index 512bd4c2eec0..4c94fc096696 100644 > --- a/drivers/mtd/devices/docg3.c > +++ b/drivers/mtd/devices/docg3.c > @@ -1603,7 +1603,7 @@ static void doc_unregister_sysfs(struct platform_device *pdev, > /* > * Debug sysfs entries > */ > -static int dbg_flashctrl_show(struct seq_file *s, void *p) > +static int flashcontrol_show(struct seq_file *s, void *p) > { > struct docg3 *docg3 = (struct docg3 *)s->private; > > @@ -1623,9 +1623,9 @@ static int dbg_flashctrl_show(struct seq_file *s, void *p) > > return 0; > } > -DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show); > +DEFINE_SHOW_ATTRIBUTE(flashcontrol); > > -static int dbg_asicmode_show(struct seq_file *s, void *p) > +static int asic_mode_show(struct seq_file *s, void *p) > { > struct docg3 *docg3 = (struct docg3 *)s->private; > > @@ -1660,9 +1660,9 @@ static int dbg_asicmode_show(struct seq_file *s, void *p) > seq_puts(s, ")\n"); > return 0; > } > -DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show); > +DEFINE_SHOW_ATTRIBUTE(asic_mode); > > -static int dbg_device_id_show(struct seq_file *s, void *p) > +static int device_id_show(struct seq_file *s, void *p) > { > struct docg3 *docg3 = (struct docg3 *)s->private; > int id; > @@ -1674,9 +1674,9 @@ static int dbg_device_id_show(struct seq_file *s, void *p) > seq_printf(s, "DeviceId = %d\n", id); > return 0; > } > -DEBUGFS_RO_ATTR(device_id, dbg_device_id_show); > +DEFINE_SHOW_ATTRIBUTE(device_id); > > -static int dbg_protection_show(struct seq_file *s, void *p) > +static int protection_show(struct seq_file *s, void *p) > { > struct docg3 *docg3 = (struct docg3 *)s->private; > int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high; > @@ -1726,7 +1726,7 @@ static int dbg_protection_show(struct seq_file *s, void *p) > !!(dps1 & DOC_DPS_KEY_OK)); > return 0; > } > -DEBUGFS_RO_ATTR(protection, dbg_protection_show); > +DEFINE_SHOW_ATTRIBUTE(protection); > > static void __init doc_dbg_register(struct mtd_info *floor) > { > diff --git a/drivers/mtd/devices/docg3.h b/drivers/mtd/devices/docg3.h > index e99946575398..e16dca23655b 100644 > --- a/drivers/mtd/devices/docg3.h > +++ b/drivers/mtd/devices/docg3.h > @@ -317,17 +317,6 @@ struct docg3 { > #define doc_info(fmt, arg...) dev_info(docg3->dev, (fmt), ## arg) > #define doc_dbg(fmt, arg...) dev_dbg(docg3->dev, (fmt), ## arg) > #define doc_vdbg(fmt, arg...) dev_vdbg(docg3->dev, (fmt), ## arg) > - > -#define DEBUGFS_RO_ATTR(name, show_fct) \ > - static int name##_open(struct inode *inode, struct file *file) \ > - { return single_open(file, show_fct, inode->i_private); } \ > - static const struct file_operations name##_fops = { \ > - .owner = THIS_MODULE, \ > - .open = name##_open, \ > - .llseek = seq_lseek, \ > - .read = seq_read, \ > - .release = single_release \ > - }; > #endif > > /* > diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c > index d9dcb2d051b4..d162d1717fad 100644 > --- a/drivers/mtd/mtdswap.c > +++ b/drivers/mtd/mtdswap.c > @@ -1265,18 +1265,7 @@ static int mtdswap_show(struct seq_file *s, void *data) > > return 0; > } > - > -static int mtdswap_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, mtdswap_show, inode->i_private); > -} > - > -static const struct file_operations mtdswap_fops = { > - .open = mtdswap_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > +DEFINE_SHOW_ATTRIBUTE(mtdswap); > > static int mtdswap_add_debugfs(struct mtdswap_dev *d) > { > diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c > index c452819f6123..ef8721418f2d 100644 > --- a/drivers/mtd/nand/raw/nandsim.c > +++ b/drivers/mtd/nand/raw/nandsim.c > @@ -443,7 +443,7 @@ static unsigned long total_wear = 0; > /* MTD structure for NAND controller */ > static struct mtd_info *nsmtd; > > -static int nandsim_debugfs_show(struct seq_file *m, void *private) > +static int nandsim_show(struct seq_file *m, void *private) > { > unsigned long wmin = -1, wmax = 0, avg; > unsigned long deciles[10], decile_max[10], tot = 0; > @@ -494,18 +494,7 @@ static int nandsim_debugfs_show(struct seq_file *m, void *private) > > return 0; > } > - > -static int nandsim_debugfs_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, nandsim_debugfs_show, inode->i_private); > -} > - > -static const struct file_operations dfs_fops = { > - .open = nandsim_debugfs_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > +DEFINE_SHOW_ATTRIBUTE(nandsim); > > /** > * nandsim_debugfs_create - initialize debugfs > @@ -531,7 +520,7 @@ static int nandsim_debugfs_create(struct nandsim *dev) > } > > dent = debugfs_create_file("nandsim_wear_report", S_IRUSR, > - root, dev, &dfs_fops); > + root, dev, &nandsim_fops); > if (IS_ERR_OR_NULL(dent)) { > NS_ERR("cannot create \"nandsim_wear_report\" debugfs entry\n"); > return -1;