public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: remove DEBUGFS_RO_ATTR()
@ 2018-12-01 10:48 Yangtao Li
  2018-12-01 23:24 ` kbuild test robot
  2018-12-01 23:29 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Yangtao Li @ 2018-12-01 10:48 UTC (permalink / raw)
  To: robert.jarzmik, dwmw2, computersforpeace, boris.brezillon,
	marek.vasut, richard, miquel.raynal, keescook, shreeya.patel23498
  Cc: linux-mtd, linux-kernel, Yangtao Li

We already have the DEFINE_SHOW_ATTRIBUTE.There is no need to define
such a macro,so remove DEBUGFS_RO_ATTR.Also use DEFINE_SHOW_ATTRIBUTE
to simplify some code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/mtd/devices/docg3.c    | 15 +++++++++------
 drivers/mtd/devices/docg3.h    | 11 -----------
 drivers/mtd/mtdswap.c          | 12 +-----------
 drivers/mtd/nand/raw/nandsim.c | 16 +++-------------
 4 files changed, 13 insertions(+), 41 deletions(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 512bd4c2eec0..51d2c6e68f39 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,10 @@ static int dbg_flashctrl_show(struct seq_file *s, void *p)
 
 	return 0;
 }
-DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show);
 
-static int dbg_asicmode_show(struct seq_file *s, void *p)
+DEFINE_SHOW_ATTRIBUTE(flashcontrol);
+
+static int asic_mode_show(struct seq_file *s, void *p)
 {
 	struct docg3 *docg3 = (struct docg3 *)s->private;
 
@@ -1660,7 +1661,8 @@ 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)
 {
@@ -1676,7 +1678,7 @@ static int dbg_device_id_show(struct seq_file *s, void *p)
 }
 DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
 
-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 +1728,8 @@ 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..3afda6c95d62 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1266,17 +1266,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..2d5532042803 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;
@@ -495,17 +495,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 +521,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;
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: remove DEBUGFS_RO_ATTR()
  2018-12-01 10:48 [PATCH] mtd: remove DEBUGFS_RO_ATTR() Yangtao Li
@ 2018-12-01 23:24 ` kbuild test robot
  2018-12-01 23:29 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-12-01 23:24 UTC (permalink / raw)
  To: Yangtao Li
  Cc: kbuild-all, robert.jarzmik, dwmw2, computersforpeace,
	boris.brezillon, marek.vasut, richard, miquel.raynal, keescook,
	shreeya.patel23498, linux-mtd, linux-kernel, Yangtao Li

[-- Attachment #1: Type: text/plain, Size: 9219 bytes --]

Hi Yangtao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mtd/master]
[also build test ERROR on v4.20-rc4 next-20181130]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yangtao-Li/mtd-remove-DEBUGFS_RO_ATTR/20181202-065958
base:   git://git.infradead.org/linux-mtd.git master
config: x86_64-randconfig-x013-201848 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

>> drivers/mtd/devices/docg3.c:1679:1: warning: data definition has no type or storage class
    DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
    ^~~~~~~~~~~~~~~
>> drivers/mtd/devices/docg3.c:1679:1: error: type defaults to 'int' in declaration of 'DEBUGFS_RO_ATTR' [-Werror=implicit-int]
>> drivers/mtd/devices/docg3.c:1679:1: warning: parameter names (without types) in function declaration
   drivers/mtd/devices/docg3.c: In function 'doc_dbg_register':
>> drivers/mtd/devices/docg3.c:1752:9: error: 'device_id_fops' undeclared (first use in this function); did you mean 'device_add_groups'?
           &device_id_fops);
            ^~~~~~~~~~~~~~
            device_add_groups
   drivers/mtd/devices/docg3.c:1752:9: note: each undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/mtd/devices/docg3.c:1667:12: warning: 'dbg_device_id_show' defined but not used [-Wunused-function]
    static int dbg_device_id_show(struct seq_file *s, void *p)
               ^~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +1679 drivers/mtd/devices/docg3.c

efa2ca73 Robert Jarzmik  2011-10-05  1666  
efa2ca73 Robert Jarzmik  2011-10-05  1667  static int dbg_device_id_show(struct seq_file *s, void *p)
efa2ca73 Robert Jarzmik  2011-10-05  1668  {
efa2ca73 Robert Jarzmik  2011-10-05  1669  	struct docg3 *docg3 = (struct docg3 *)s->private;
7b0e67f6 Robert Jarzmik  2012-03-22  1670  	int id;
7b0e67f6 Robert Jarzmik  2012-03-22  1671  
7b0e67f6 Robert Jarzmik  2012-03-22  1672  	mutex_lock(&docg3->cascade->lock);
7b0e67f6 Robert Jarzmik  2012-03-22  1673  	id = doc_register_readb(docg3, DOC_DEVICESELECT);
7b0e67f6 Robert Jarzmik  2012-03-22  1674  	mutex_unlock(&docg3->cascade->lock);
efa2ca73 Robert Jarzmik  2011-10-05  1675  
8c98d255 Joe Perches     2014-09-29  1676  	seq_printf(s, "DeviceId = %d\n", id);
8c98d255 Joe Perches     2014-09-29  1677  	return 0;
efa2ca73 Robert Jarzmik  2011-10-05  1678  }
efa2ca73 Robert Jarzmik  2011-10-05 @1679  DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
efa2ca73 Robert Jarzmik  2011-10-05  1680  
34e778aa Yangtao Li      2018-12-01  1681  static int protection_show(struct seq_file *s, void *p)
efa2ca73 Robert Jarzmik  2011-10-05  1682  {
efa2ca73 Robert Jarzmik  2011-10-05  1683  	struct docg3 *docg3 = (struct docg3 *)s->private;
dbc26d98 Robert Jarzmik  2011-11-19  1684  	int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high;
dbc26d98 Robert Jarzmik  2011-11-19  1685  
7b0e67f6 Robert Jarzmik  2012-03-22  1686  	mutex_lock(&docg3->cascade->lock);
dbc26d98 Robert Jarzmik  2011-11-19  1687  	protect = doc_register_readb(docg3, DOC_PROTECTION);
dbc26d98 Robert Jarzmik  2011-11-19  1688  	dps0 = doc_register_readb(docg3, DOC_DPS0_STATUS);
dbc26d98 Robert Jarzmik  2011-11-19  1689  	dps0_low = doc_register_readw(docg3, DOC_DPS0_ADDRLOW);
dbc26d98 Robert Jarzmik  2011-11-19  1690  	dps0_high = doc_register_readw(docg3, DOC_DPS0_ADDRHIGH);
dbc26d98 Robert Jarzmik  2011-11-19  1691  	dps1 = doc_register_readb(docg3, DOC_DPS1_STATUS);
dbc26d98 Robert Jarzmik  2011-11-19  1692  	dps1_low = doc_register_readw(docg3, DOC_DPS1_ADDRLOW);
dbc26d98 Robert Jarzmik  2011-11-19  1693  	dps1_high = doc_register_readw(docg3, DOC_DPS1_ADDRHIGH);
7b0e67f6 Robert Jarzmik  2012-03-22  1694  	mutex_unlock(&docg3->cascade->lock);
efa2ca73 Robert Jarzmik  2011-10-05  1695  
8c98d255 Joe Perches     2014-09-29  1696  	seq_printf(s, "Protection = 0x%02x (", protect);
efa2ca73 Robert Jarzmik  2011-10-05  1697  	if (protect & DOC_PROTECT_FOUNDRY_OTP_LOCK)
8c98d255 Joe Perches     2014-09-29  1698  		seq_puts(s, "FOUNDRY_OTP_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1699  	if (protect & DOC_PROTECT_CUSTOMER_OTP_LOCK)
8c98d255 Joe Perches     2014-09-29  1700  		seq_puts(s, "CUSTOMER_OTP_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1701  	if (protect & DOC_PROTECT_LOCK_INPUT)
8c98d255 Joe Perches     2014-09-29  1702  		seq_puts(s, "LOCK_INPUT,");
efa2ca73 Robert Jarzmik  2011-10-05  1703  	if (protect & DOC_PROTECT_STICKY_LOCK)
8c98d255 Joe Perches     2014-09-29  1704  		seq_puts(s, "STICKY_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1705  	if (protect & DOC_PROTECT_PROTECTION_ENABLED)
8c98d255 Joe Perches     2014-09-29  1706  		seq_puts(s, "PROTECTION ON,");
efa2ca73 Robert Jarzmik  2011-10-05  1707  	if (protect & DOC_PROTECT_IPL_DOWNLOAD_LOCK)
8c98d255 Joe Perches     2014-09-29  1708  		seq_puts(s, "IPL_DOWNLOAD_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1709  	if (protect & DOC_PROTECT_PROTECTION_ERROR)
8c98d255 Joe Perches     2014-09-29  1710  		seq_puts(s, "PROTECT_ERR,");
efa2ca73 Robert Jarzmik  2011-10-05  1711  	else
8c98d255 Joe Perches     2014-09-29  1712  		seq_puts(s, "NO_PROTECT_ERR");
8c98d255 Joe Perches     2014-09-29  1713  	seq_puts(s, ")\n");
efa2ca73 Robert Jarzmik  2011-10-05  1714  
8c98d255 Joe Perches     2014-09-29  1715  	seq_printf(s, "DPS0 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
efa2ca73 Robert Jarzmik  2011-10-05  1716  		   dps0, dps0_low, dps0_high,
efa2ca73 Robert Jarzmik  2011-10-05  1717  		   !!(dps0 & DOC_DPS_OTP_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1718  		   !!(dps0 & DOC_DPS_READ_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1719  		   !!(dps0 & DOC_DPS_WRITE_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1720  		   !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
efa2ca73 Robert Jarzmik  2011-10-05  1721  		   !!(dps0 & DOC_DPS_KEY_OK));
8c98d255 Joe Perches     2014-09-29  1722  	seq_printf(s, "DPS1 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
efa2ca73 Robert Jarzmik  2011-10-05  1723  		   dps1, dps1_low, dps1_high,
efa2ca73 Robert Jarzmik  2011-10-05  1724  		   !!(dps1 & DOC_DPS_OTP_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1725  		   !!(dps1 & DOC_DPS_READ_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1726  		   !!(dps1 & DOC_DPS_WRITE_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1727  		   !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
efa2ca73 Robert Jarzmik  2011-10-05  1728  		   !!(dps1 & DOC_DPS_KEY_OK));
8c98d255 Joe Perches     2014-09-29  1729  	return 0;
efa2ca73 Robert Jarzmik  2011-10-05  1730  }
34e778aa Yangtao Li      2018-12-01  1731  
34e778aa Yangtao Li      2018-12-01  1732  DEFINE_SHOW_ATTRIBUTE(protection);
efa2ca73 Robert Jarzmik  2011-10-05  1733  
e8e3edb9 Mario Rugiero   2017-05-29  1734  static void __init doc_dbg_register(struct mtd_info *floor)
efa2ca73 Robert Jarzmik  2011-10-05  1735  {
e8e3edb9 Mario Rugiero   2017-05-29  1736  	struct dentry *root = floor->dbg.dfs_dir;
e8e3edb9 Mario Rugiero   2017-05-29  1737  	struct docg3 *docg3 = floor->priv;
efa2ca73 Robert Jarzmik  2011-10-05  1738  
1530578a Boris Brezillon 2017-11-11  1739  	if (IS_ERR_OR_NULL(root)) {
1530578a Boris Brezillon 2017-11-11  1740  		if (IS_ENABLED(CONFIG_DEBUG_FS) &&
1530578a Boris Brezillon 2017-11-11  1741  		    !IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER))
1530578a Boris Brezillon 2017-11-11  1742  			dev_warn(floor->dev.parent,
1530578a Boris Brezillon 2017-11-11  1743  				 "CONFIG_MTD_PARTITIONED_MASTER must be enabled to expose debugfs stuff\n");
e8e3edb9 Mario Rugiero   2017-05-29  1744  		return;
1530578a Boris Brezillon 2017-11-11  1745  	}
efa2ca73 Robert Jarzmik  2011-10-05  1746  
e8e3edb9 Mario Rugiero   2017-05-29  1747  	debugfs_create_file("docg3_flashcontrol", S_IRUSR, root, docg3,
efa2ca73 Robert Jarzmik  2011-10-05  1748  			    &flashcontrol_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1749  	debugfs_create_file("docg3_asic_mode", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29  1750  			    &asic_mode_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1751  	debugfs_create_file("docg3_device_id", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29 @1752  			    &device_id_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1753  	debugfs_create_file("docg3_protection", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29  1754  			    &protection_fops);
efa2ca73 Robert Jarzmik  2011-10-05  1755  }
efa2ca73 Robert Jarzmik  2011-10-05  1756  

:::::: The code at line 1679 was first introduced by commit
:::::: efa2ca73a7bc1a8f8e66bcfad33391746819ffe6 mtd: Add DiskOnChip G3 support

:::::: TO: Robert Jarzmik <robert.jarzmik@free.fr>
:::::: CC: Artem Bityutskiy <artem.bityutskiy@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26735 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: remove DEBUGFS_RO_ATTR()
  2018-12-01 10:48 [PATCH] mtd: remove DEBUGFS_RO_ATTR() Yangtao Li
  2018-12-01 23:24 ` kbuild test robot
@ 2018-12-01 23:29 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-12-01 23:29 UTC (permalink / raw)
  To: Yangtao Li
  Cc: kbuild-all, robert.jarzmik, dwmw2, computersforpeace,
	boris.brezillon, marek.vasut, richard, miquel.raynal, keescook,
	shreeya.patel23498, linux-mtd, linux-kernel, Yangtao Li

[-- Attachment #1: Type: text/plain, Size: 9333 bytes --]

Hi Yangtao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mtd/master]
[also build test ERROR on v4.20-rc4 next-20181130]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yangtao-Li/mtd-remove-DEBUGFS_RO_ATTR/20181202-065958
base:   git://git.infradead.org/linux-mtd.git master
config: nds32-allyesconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 6.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=6.4.0 make.cross ARCH=nds32 

All errors (new ones prefixed by >>):

   drivers/mtd/devices/docg3.c:1679:1: warning: data definition has no type or storage class
    DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
    ^~~~~~~~~~~~~~~
   drivers/mtd/devices/docg3.c:1679:1: error: type defaults to 'int' in declaration of 'DEBUGFS_RO_ATTR' [-Werror=implicit-int]
   drivers/mtd/devices/docg3.c:1679:1: warning: parameter names (without types) in function declaration
   drivers/mtd/devices/docg3.c: In function 'doc_dbg_register':
>> drivers/mtd/devices/docg3.c:1752:9: error: 'device_id_fops' undeclared (first use in this function)
           &device_id_fops);
            ^~~~~~~~~~~~~~
   drivers/mtd/devices/docg3.c:1752:9: note: each undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/mtd/devices/docg3.c:1667:12: warning: 'dbg_device_id_show' defined but not used [-Wunused-function]
    static int dbg_device_id_show(struct seq_file *s, void *p)
               ^~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/device_id_fops +1752 drivers/mtd/devices/docg3.c

efa2ca73 Robert Jarzmik  2011-10-05  1666  
efa2ca73 Robert Jarzmik  2011-10-05  1667  static int dbg_device_id_show(struct seq_file *s, void *p)
efa2ca73 Robert Jarzmik  2011-10-05  1668  {
efa2ca73 Robert Jarzmik  2011-10-05  1669  	struct docg3 *docg3 = (struct docg3 *)s->private;
7b0e67f6 Robert Jarzmik  2012-03-22  1670  	int id;
7b0e67f6 Robert Jarzmik  2012-03-22  1671  
7b0e67f6 Robert Jarzmik  2012-03-22  1672  	mutex_lock(&docg3->cascade->lock);
7b0e67f6 Robert Jarzmik  2012-03-22  1673  	id = doc_register_readb(docg3, DOC_DEVICESELECT);
7b0e67f6 Robert Jarzmik  2012-03-22  1674  	mutex_unlock(&docg3->cascade->lock);
efa2ca73 Robert Jarzmik  2011-10-05  1675  
8c98d255 Joe Perches     2014-09-29  1676  	seq_printf(s, "DeviceId = %d\n", id);
8c98d255 Joe Perches     2014-09-29  1677  	return 0;
efa2ca73 Robert Jarzmik  2011-10-05  1678  }
efa2ca73 Robert Jarzmik  2011-10-05 @1679  DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
efa2ca73 Robert Jarzmik  2011-10-05  1680  
34e778aa Yangtao Li      2018-12-01  1681  static int protection_show(struct seq_file *s, void *p)
efa2ca73 Robert Jarzmik  2011-10-05  1682  {
efa2ca73 Robert Jarzmik  2011-10-05  1683  	struct docg3 *docg3 = (struct docg3 *)s->private;
dbc26d98 Robert Jarzmik  2011-11-19  1684  	int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high;
dbc26d98 Robert Jarzmik  2011-11-19  1685  
7b0e67f6 Robert Jarzmik  2012-03-22  1686  	mutex_lock(&docg3->cascade->lock);
dbc26d98 Robert Jarzmik  2011-11-19  1687  	protect = doc_register_readb(docg3, DOC_PROTECTION);
dbc26d98 Robert Jarzmik  2011-11-19  1688  	dps0 = doc_register_readb(docg3, DOC_DPS0_STATUS);
dbc26d98 Robert Jarzmik  2011-11-19  1689  	dps0_low = doc_register_readw(docg3, DOC_DPS0_ADDRLOW);
dbc26d98 Robert Jarzmik  2011-11-19  1690  	dps0_high = doc_register_readw(docg3, DOC_DPS0_ADDRHIGH);
dbc26d98 Robert Jarzmik  2011-11-19  1691  	dps1 = doc_register_readb(docg3, DOC_DPS1_STATUS);
dbc26d98 Robert Jarzmik  2011-11-19  1692  	dps1_low = doc_register_readw(docg3, DOC_DPS1_ADDRLOW);
dbc26d98 Robert Jarzmik  2011-11-19  1693  	dps1_high = doc_register_readw(docg3, DOC_DPS1_ADDRHIGH);
7b0e67f6 Robert Jarzmik  2012-03-22  1694  	mutex_unlock(&docg3->cascade->lock);
efa2ca73 Robert Jarzmik  2011-10-05  1695  
8c98d255 Joe Perches     2014-09-29  1696  	seq_printf(s, "Protection = 0x%02x (", protect);
efa2ca73 Robert Jarzmik  2011-10-05  1697  	if (protect & DOC_PROTECT_FOUNDRY_OTP_LOCK)
8c98d255 Joe Perches     2014-09-29  1698  		seq_puts(s, "FOUNDRY_OTP_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1699  	if (protect & DOC_PROTECT_CUSTOMER_OTP_LOCK)
8c98d255 Joe Perches     2014-09-29  1700  		seq_puts(s, "CUSTOMER_OTP_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1701  	if (protect & DOC_PROTECT_LOCK_INPUT)
8c98d255 Joe Perches     2014-09-29  1702  		seq_puts(s, "LOCK_INPUT,");
efa2ca73 Robert Jarzmik  2011-10-05  1703  	if (protect & DOC_PROTECT_STICKY_LOCK)
8c98d255 Joe Perches     2014-09-29  1704  		seq_puts(s, "STICKY_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1705  	if (protect & DOC_PROTECT_PROTECTION_ENABLED)
8c98d255 Joe Perches     2014-09-29  1706  		seq_puts(s, "PROTECTION ON,");
efa2ca73 Robert Jarzmik  2011-10-05  1707  	if (protect & DOC_PROTECT_IPL_DOWNLOAD_LOCK)
8c98d255 Joe Perches     2014-09-29  1708  		seq_puts(s, "IPL_DOWNLOAD_LOCK,");
efa2ca73 Robert Jarzmik  2011-10-05  1709  	if (protect & DOC_PROTECT_PROTECTION_ERROR)
8c98d255 Joe Perches     2014-09-29  1710  		seq_puts(s, "PROTECT_ERR,");
efa2ca73 Robert Jarzmik  2011-10-05  1711  	else
8c98d255 Joe Perches     2014-09-29  1712  		seq_puts(s, "NO_PROTECT_ERR");
8c98d255 Joe Perches     2014-09-29  1713  	seq_puts(s, ")\n");
efa2ca73 Robert Jarzmik  2011-10-05  1714  
8c98d255 Joe Perches     2014-09-29  1715  	seq_printf(s, "DPS0 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
efa2ca73 Robert Jarzmik  2011-10-05  1716  		   dps0, dps0_low, dps0_high,
efa2ca73 Robert Jarzmik  2011-10-05  1717  		   !!(dps0 & DOC_DPS_OTP_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1718  		   !!(dps0 & DOC_DPS_READ_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1719  		   !!(dps0 & DOC_DPS_WRITE_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1720  		   !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
efa2ca73 Robert Jarzmik  2011-10-05  1721  		   !!(dps0 & DOC_DPS_KEY_OK));
8c98d255 Joe Perches     2014-09-29  1722  	seq_printf(s, "DPS1 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
efa2ca73 Robert Jarzmik  2011-10-05  1723  		   dps1, dps1_low, dps1_high,
efa2ca73 Robert Jarzmik  2011-10-05  1724  		   !!(dps1 & DOC_DPS_OTP_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1725  		   !!(dps1 & DOC_DPS_READ_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1726  		   !!(dps1 & DOC_DPS_WRITE_PROTECTED),
efa2ca73 Robert Jarzmik  2011-10-05  1727  		   !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
efa2ca73 Robert Jarzmik  2011-10-05  1728  		   !!(dps1 & DOC_DPS_KEY_OK));
8c98d255 Joe Perches     2014-09-29  1729  	return 0;
efa2ca73 Robert Jarzmik  2011-10-05  1730  }
34e778aa Yangtao Li      2018-12-01  1731  
34e778aa Yangtao Li      2018-12-01  1732  DEFINE_SHOW_ATTRIBUTE(protection);
efa2ca73 Robert Jarzmik  2011-10-05  1733  
e8e3edb9 Mario Rugiero   2017-05-29  1734  static void __init doc_dbg_register(struct mtd_info *floor)
efa2ca73 Robert Jarzmik  2011-10-05  1735  {
e8e3edb9 Mario Rugiero   2017-05-29  1736  	struct dentry *root = floor->dbg.dfs_dir;
e8e3edb9 Mario Rugiero   2017-05-29  1737  	struct docg3 *docg3 = floor->priv;
efa2ca73 Robert Jarzmik  2011-10-05  1738  
1530578a Boris Brezillon 2017-11-11  1739  	if (IS_ERR_OR_NULL(root)) {
1530578a Boris Brezillon 2017-11-11  1740  		if (IS_ENABLED(CONFIG_DEBUG_FS) &&
1530578a Boris Brezillon 2017-11-11  1741  		    !IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER))
1530578a Boris Brezillon 2017-11-11  1742  			dev_warn(floor->dev.parent,
1530578a Boris Brezillon 2017-11-11  1743  				 "CONFIG_MTD_PARTITIONED_MASTER must be enabled to expose debugfs stuff\n");
e8e3edb9 Mario Rugiero   2017-05-29  1744  		return;
1530578a Boris Brezillon 2017-11-11  1745  	}
efa2ca73 Robert Jarzmik  2011-10-05  1746  
e8e3edb9 Mario Rugiero   2017-05-29  1747  	debugfs_create_file("docg3_flashcontrol", S_IRUSR, root, docg3,
efa2ca73 Robert Jarzmik  2011-10-05  1748  			    &flashcontrol_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1749  	debugfs_create_file("docg3_asic_mode", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29  1750  			    &asic_mode_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1751  	debugfs_create_file("docg3_device_id", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29 @1752  			    &device_id_fops);
e8e3edb9 Mario Rugiero   2017-05-29  1753  	debugfs_create_file("docg3_protection", S_IRUSR, root, docg3,
e8e3edb9 Mario Rugiero   2017-05-29  1754  			    &protection_fops);
efa2ca73 Robert Jarzmik  2011-10-05  1755  }
efa2ca73 Robert Jarzmik  2011-10-05  1756  

:::::: The code at line 1752 was first introduced by commit
:::::: e8e3edb95ce6a146bc774b6cfad3553f4383edc8 mtd: create per-device and module-scope debugfs entries

:::::: TO: Mario Rugiero <mrugiero@gmail.com>
:::::: CC: Brian Norris <computersforpeace@gmail.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 48670 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-01 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-01 10:48 [PATCH] mtd: remove DEBUGFS_RO_ATTR() Yangtao Li
2018-12-01 23:24 ` kbuild test robot
2018-12-01 23:29 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox