public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops
@ 2022-03-27  3:58 wujunwen
  2022-03-27  5:35 ` kernel test robot
  2022-03-27  6:16 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: wujunwen @ 2022-03-27  3:58 UTC (permalink / raw)
  To: arnd, gregkh; +Cc: linux-kernel, wujunwen

DEFINE_PROC_SHOW_ATTRIBUTE is used to simply seq_file flow ,so
we can use it to simplify misc proc_fops.

Signed-off-by: wujunwen <wudaemon@163.com>
---
 drivers/char/misc.c | 37 ++++++++++---------------------------
 1 file changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index ca5141ed5ef3..f215f964a972 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -64,40 +64,23 @@ static DEFINE_MUTEX(misc_mtx);
 static DECLARE_BITMAP(misc_minors, DYNAMIC_MINORS);
 
 #ifdef CONFIG_PROC_FS
-static void *misc_seq_start(struct seq_file *seq, loff_t *pos)
-{
-	mutex_lock(&misc_mtx);
-	return seq_list_start(&misc_list, *pos);
-}
 
-static void *misc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+static int misc_show(struct seq_file *seq, void *v)
 {
-	return seq_list_next(v, &misc_list, pos);
-}
+	const struct miscdevice *p;
 
-static void misc_seq_stop(struct seq_file *seq, void *v)
-{
+	mutex_lock(&misc_mtx);
+	list_for_each_entry(p, &misc_list, list) {
+		seq_printf(seq, "%3i %s\n", p->minor, p->name ? p->name : "");
+	}
 	mutex_unlock(&misc_mtx);
-}
-
-static int misc_seq_show(struct seq_file *seq, void *v)
-{
-	const struct miscdevice *p = list_entry(v, struct miscdevice, list);
-
-	seq_printf(seq, "%3i %s\n", p->minor, p->name ? p->name : "");
 	return 0;
 }
 
-
-static const struct seq_operations misc_seq_ops = {
-	.start = misc_seq_start,
-	.next  = misc_seq_next,
-	.stop  = misc_seq_stop,
-	.show  = misc_seq_show,
-};
+DEFINE_PROC_SHOW_ATTRIBUTE(misc);
 #endif
 
-static int misc_open(struct inode *inode, struct file *file)
+static int misc_fops_open(struct inode *inode, struct file *file)
 {
 	int minor = iminor(inode);
 	struct miscdevice *c;
@@ -148,7 +131,7 @@ static struct class *misc_class;
 
 static const struct file_operations misc_fops = {
 	.owner		= THIS_MODULE,
-	.open		= misc_open,
+	.open		= misc_fops_open,
 	.llseek		= noop_llseek,
 };
 
@@ -268,7 +251,7 @@ static int __init misc_init(void)
 	int err;
 	struct proc_dir_entry *ret;
 
-	ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
+	ret = proc_create("misc", 0, NULL, &misc_proc_ops);
 	misc_class = class_create(THIS_MODULE, "misc");
 	err = PTR_ERR(misc_class);
 	if (IS_ERR(misc_class))
-- 
2.25.1


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

* Re: [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops
  2022-03-27  3:58 [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops wujunwen
@ 2022-03-27  5:35 ` kernel test robot
  2022-03-27  6:16 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-03-27  5:35 UTC (permalink / raw)
  To: wujunwen, arnd, gregkh; +Cc: kbuild-all, linux-kernel, wujunwen

Hi wujunwen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on soc/for-next linux/master linus/master v5.17 next-20220325]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/wujunwen/char-misc-use-DEFINE_PROC_SHOW_ATTRIBUTE-micro-to-simplify-misc-proc_fops/20220327-120053
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 37fd83916da2e4cae03d350015c82a67b1b334c4
config: xtensa-randconfig-m031-20220327 (https://download.01.org/0day-ci/archive/20220327/202203271316.pktWRsr4-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/738cb3f8808411f37ad8cb6c2529c6686a87eddf
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review wujunwen/char-misc-use-DEFINE_PROC_SHOW_ATTRIBUTE-micro-to-simplify-misc-proc_fops/20220327-120053
        git checkout 738cb3f8808411f37ad8cb6c2529c6686a87eddf
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=xtensa SHELL=/bin/bash drivers/char/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/char/misc.c: In function 'misc_init':
>> drivers/char/misc.c:254:45: error: 'misc_proc_ops' undeclared (first use in this function); did you mean 'misc_fops'?
     254 |         ret = proc_create("misc", 0, NULL, &misc_proc_ops);
         |                                             ^~~~~~~~~~~~~
         |                                             misc_fops
   drivers/char/misc.c:254:45: note: each undeclared identifier is reported only once for each function it appears in


vim +254 drivers/char/misc.c

   248	
   249	static int __init misc_init(void)
   250	{
   251		int err;
   252		struct proc_dir_entry *ret;
   253	
 > 254		ret = proc_create("misc", 0, NULL, &misc_proc_ops);

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops
  2022-03-27  3:58 [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops wujunwen
  2022-03-27  5:35 ` kernel test robot
@ 2022-03-27  6:16 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-03-27  6:16 UTC (permalink / raw)
  To: wujunwen, arnd, gregkh; +Cc: llvm, kbuild-all, linux-kernel, wujunwen

Hi wujunwen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on soc/for-next linux/master linus/master v5.17 next-20220325]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/wujunwen/char-misc-use-DEFINE_PROC_SHOW_ATTRIBUTE-micro-to-simplify-misc-proc_fops/20220327-120053
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 37fd83916da2e4cae03d350015c82a67b1b334c4
config: hexagon-randconfig-r045-20220327 (https://download.01.org/0day-ci/archive/20220327/202203271414.XUS8IhaO-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/738cb3f8808411f37ad8cb6c2529c6686a87eddf
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review wujunwen/char-misc-use-DEFINE_PROC_SHOW_ATTRIBUTE-micro-to-simplify-misc-proc_fops/20220327-120053
        git checkout 738cb3f8808411f37ad8cb6c2529c6686a87eddf
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/char/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/char/misc.c:254:38: error: use of undeclared identifier 'misc_proc_ops'; did you mean 'misc_fops'?
           ret = proc_create("misc", 0, NULL, &misc_proc_ops);
                                               ^~~~~~~~~~~~~
                                               misc_fops
   drivers/char/misc.c:132:37: note: 'misc_fops' declared here
   static const struct file_operations misc_fops = {
                                       ^
   1 error generated.


vim +254 drivers/char/misc.c

   248	
   249	static int __init misc_init(void)
   250	{
   251		int err;
   252		struct proc_dir_entry *ret;
   253	
 > 254		ret = proc_create("misc", 0, NULL, &misc_proc_ops);

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

end of thread, other threads:[~2022-03-27  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-27  3:58 [PATCH v1] char: misc:use DEFINE_PROC_SHOW_ATTRIBUTE micro to simplify misc proc_fops wujunwen
2022-03-27  5:35 ` kernel test robot
2022-03-27  6:16 ` kernel test robot

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