linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] hwrng: core: do not use multiple blank lines
@ 2016-12-09 14:21 Corentin Labbe
  2016-12-09 14:21 ` [PATCH 2/7] hwrng: core: rewrite better comparison to NULL Corentin Labbe
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

This patch fix the checkpatch warning "Please don't use multiple blank lines"

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index d2d2c89..00cbb81 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -30,7 +30,6 @@
 
  */
 
-
 #include <linux/device.h>
 #include <linux/hw_random.h>
 #include <linux/module.h>
@@ -45,12 +44,10 @@
 #include <linux/err.h>
 #include <asm/uaccess.h>
 
-
 #define RNG_MODULE_NAME		"hw_random"
 #define PFX			RNG_MODULE_NAME ": "
 #define RNG_MISCDEV_MINOR	183 /* official */
 
-
 static struct hwrng *current_rng;
 static struct task_struct *hwrng_fill;
 static LIST_HEAD(rng_list);
@@ -296,7 +293,6 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
 	goto out;
 }
 
-
 static const struct file_operations rng_chrdev_ops = {
 	.owner		= THIS_MODULE,
 	.open		= rng_dev_open,
@@ -314,7 +310,6 @@ static struct miscdevice rng_miscdev = {
 	.groups		= rng_dev_groups,
 };
 
-
 static ssize_t hwrng_attr_current_store(struct device *dev,
 					struct device_attribute *attr,
 					const char *buf, size_t len)
-- 
2.7.3

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

* [PATCH 2/7] hwrng: core: rewrite better comparison to NULL
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 14:21 ` [PATCH 3/7] hwrng: core: Rewrite the header Corentin Labbe
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

This patch fix the checkpatch warning "Comparison to NULL could be written "!ptr"

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 00cbb81..7029246 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -439,8 +439,7 @@ int hwrng_register(struct hwrng *rng)
 	int err = -EINVAL;
 	struct hwrng *old_rng, *tmp;
 
-	if (rng->name == NULL ||
-	    (rng->data_read == NULL && rng->read == NULL))
+	if (!rng->name || (!rng->data_read && !rng->read))
 		goto out;
 
 	mutex_lock(&rng_mutex);
-- 
2.7.3

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

* [PATCH 3/7] hwrng: core: Rewrite the header
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
  2016-12-09 14:21 ` [PATCH 2/7] hwrng: core: rewrite better comparison to NULL Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 14:21 ` [PATCH 4/7] hwrng: core: Replace asm/uaccess.h by linux/uaccess.h Corentin Labbe
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

checkpatch have lot of complaint about header.
Furthermore, the header have some offtopic/useless information.

This patch rewrite a proper header.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 7029246..a8e63ae 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -1,33 +1,13 @@
 /*
-        Added support for the AMD Geode LX RNG
-	(c) Copyright 2004-2005 Advanced Micro Devices, Inc.
-
-	derived from
-
- 	Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
-	(c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
-
- 	derived from
-
-        Hardware driver for the AMD 768 Random Number Generator (RNG)
-        (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
-
- 	derived from
-
-	Hardware driver for Intel i810 Random Number Generator (RNG)
-	Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
-	Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
-
-	Added generic RNG API
-	Copyright 2006 Michael Buesch <m@bues.ch>
-	Copyright 2005 (c) MontaVista Software, Inc.
-
-	Please read Documentation/hw_random.txt for details on use.
-
-	----------------------------------------------------------
-	This software may be used and distributed according to the terms
-        of the GNU General Public License, incorporated herein by reference.
-
+ * hw_random/core.c: HWRNG core API
+ *
+ * Copyright 2006 Michael Buesch <m@bues.ch>
+ * Copyright 2005 (c) MontaVista Software, Inc.
+ *
+ * Please read Documentation/hw_random.txt for details on use.
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
  */
 
 #include <linux/device.h>
-- 
2.7.3

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

* [PATCH 4/7] hwrng: core: Replace asm/uaccess.h by linux/uaccess.h
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
  2016-12-09 14:21 ` [PATCH 2/7] hwrng: core: rewrite better comparison to NULL Corentin Labbe
  2016-12-09 14:21 ` [PATCH 3/7] hwrng: core: Rewrite the header Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 14:21 ` [PATCH 5/7] hwrng: core: Move hwrng miscdev minor number to include/linux/miscdevice.h Corentin Labbe
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

This patch fix the checkpatch warning about asm/uaccess.h.
In the same time, we sort the headers in alphabetical order.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index a8e63ae..7a2e496 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -10,19 +10,19 @@
  * of the GNU General Public License, incorporated herein by reference.
  */
 
+#include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/err.h>
+#include <linux/fs.h>
 #include <linux/hw_random.h>
-#include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/sched.h>
-#include <linux/miscdevice.h>
 #include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
 #include <linux/random.h>
-#include <linux/err.h>
-#include <asm/uaccess.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
 
 #define RNG_MODULE_NAME		"hw_random"
 #define PFX			RNG_MODULE_NAME ": "
-- 
2.7.3

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

* [PATCH 5/7] hwrng: core: Move hwrng miscdev minor number to include/linux/miscdevice.h
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
                   ` (2 preceding siblings ...)
  2016-12-09 14:21 ` [PATCH 4/7] hwrng: core: Replace asm/uaccess.h by linux/uaccess.h Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 14:21 ` [PATCH 6/7] hwrng: core: remove unused PFX macro Corentin Labbe
  2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
  5 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

This patch move the define for hwrng's miscdev minor number to
include/linux/miscdevice.h.
It's better that all minor number are in the same place.
Rename it to HWRNG_MINOR (from RNG_MISCDEV_MINOR) in he process since
no other miscdev define have MISCDEV in their name.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 3 +--
 include/linux/miscdevice.h    | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 7a2e496..1e1e385 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -26,7 +26,6 @@
 
 #define RNG_MODULE_NAME		"hw_random"
 #define PFX			RNG_MODULE_NAME ": "
-#define RNG_MISCDEV_MINOR	183 /* official */
 
 static struct hwrng *current_rng;
 static struct task_struct *hwrng_fill;
@@ -283,7 +282,7 @@ static const struct file_operations rng_chrdev_ops = {
 static const struct attribute_group *rng_dev_groups[];
 
 static struct miscdevice rng_miscdev = {
-	.minor		= RNG_MISCDEV_MINOR,
+	.minor		= HWRNG_MINOR,
 	.name		= RNG_MODULE_NAME,
 	.nodename	= "hwrng",
 	.fops		= &rng_chrdev_ops,
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 722698a..659f586 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -31,6 +31,7 @@
 #define SGI_MMTIMER		153
 #define STORE_QUEUE_MINOR	155	/* unused */
 #define I2O_MINOR		166
+#define HWRNG_MINOR		183
 #define MICROCODE_MINOR		184
 #define VFIO_MINOR		196
 #define TUN_MINOR		200
-- 
2.7.3

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

* [PATCH 6/7] hwrng: core: remove unused PFX macro
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
                   ` (3 preceding siblings ...)
  2016-12-09 14:21 ` [PATCH 5/7] hwrng: core: Move hwrng miscdev minor number to include/linux/miscdevice.h Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
  5 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

This patch remove the unused PFX macro.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 1e1e385..5c654b5 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -25,7 +25,6 @@
 #include <linux/uaccess.h>
 
 #define RNG_MODULE_NAME		"hw_random"
-#define PFX			RNG_MODULE_NAME ": "
 
 static struct hwrng *current_rng;
 static struct task_struct *hwrng_fill;
-- 
2.7.3

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

* [PATCH 7/7] hwrng: core: Remove two unused include
  2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
                   ` (4 preceding siblings ...)
  2016-12-09 14:21 ` [PATCH 6/7] hwrng: core: remove unused PFX macro Corentin Labbe
@ 2016-12-09 14:21 ` Corentin Labbe
  2016-12-09 18:24   ` Corentin Labbe
                     ` (2 more replies)
  5 siblings, 3 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 14:21 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel, Corentin Labbe

linux/fs.h and linux/sched.h are useless for hw_random/core.c.
This patch remove them.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/char/hw_random/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 5c654b5..85c9ab3 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -13,14 +13,12 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
-#include <linux/fs.h>
 #include <linux/hw_random.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/random.h>
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 
-- 
2.7.3

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

* Re: [PATCH 7/7] hwrng: core: Remove two unused include
  2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
@ 2016-12-09 18:24   ` Corentin Labbe
  2016-12-10  1:27   ` kbuild test robot
  2016-12-10  5:31   ` kbuild test robot
  2 siblings, 0 replies; 10+ messages in thread
From: Corentin Labbe @ 2016-12-09 18:24 UTC (permalink / raw)
  To: mpm, herbert, arnd, gregkh; +Cc: linux-crypto, linux-kernel

On Fri, Dec 09, 2016 at 03:21:39PM +0100, Corentin Labbe wrote:
> linux/fs.h and linux/sched.h are useless for hw_random/core.c.
> This patch remove them.
> 
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> ---
>  drivers/char/hw_random/core.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index 5c654b5..85c9ab3 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -13,14 +13,12 @@
>  #include <linux/delay.h>
>  #include <linux/device.h>
>  #include <linux/err.h>
> -#include <linux/fs.h>
>  #include <linux/hw_random.h>
>  #include <linux/kernel.h>
>  #include <linux/kthread.h>
>  #include <linux/miscdevice.h>
>  #include <linux/module.h>
>  #include <linux/random.h>
> -#include <linux/sched.h>
>  #include <linux/slab.h>
>  #include <linux/uaccess.h>
>  
> -- 
> 2.7.3
> 

Sorry forget this patch, it is buggy.
linux/fs.h is needed.

Regards

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

* Re: [PATCH 7/7] hwrng: core: Remove two unused include
  2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
  2016-12-09 18:24   ` Corentin Labbe
@ 2016-12-10  1:27   ` kbuild test robot
  2016-12-10  5:31   ` kbuild test robot
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2016-12-10  1:27 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: kbuild-all, mpm, herbert, arnd, gregkh, linux-crypto,
	linux-kernel, Corentin Labbe

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

Hi Corentin,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.9-rc8 next-20161209]
[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/Corentin-Labbe/hwrng-core-do-not-use-multiple-blank-lines/20161210-072632
config: i386-randconfig-x007-201649 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

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

   In file included from include/linux/linkage.h:4:0,
                    from include/linux/kernel.h:6,
                    from include/linux/delay.h:10,
                    from drivers/char/hw_random/core.c:13:
   drivers/char/hw_random/core.c: In function 'rng_dev_open':
>> drivers/char/hw_random/core.c:169:11: error: dereferencing pointer to incomplete type 'struct file'
     if ((filp->f_mode & FMODE_READ) == 0)
              ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/char/hw_random/core.c:169:2: note: in expansion of macro 'if'
     if ((filp->f_mode & FMODE_READ) == 0)
     ^~
>> drivers/char/hw_random/core.c:169:22: error: 'FMODE_READ' undeclared (first use in this function)
     if ((filp->f_mode & FMODE_READ) == 0)
                         ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/char/hw_random/core.c:169:2: note: in expansion of macro 'if'
     if ((filp->f_mode & FMODE_READ) == 0)
     ^~
   drivers/char/hw_random/core.c:169:22: note: each undeclared identifier is reported only once for each function it appears in
     if ((filp->f_mode & FMODE_READ) == 0)
                         ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/char/hw_random/core.c:169:2: note: in expansion of macro 'if'
     if ((filp->f_mode & FMODE_READ) == 0)
     ^~
>> drivers/char/hw_random/core.c:171:21: error: 'FMODE_WRITE' undeclared (first use in this function)
     if (filp->f_mode & FMODE_WRITE)
                        ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers/char/hw_random/core.c:171:2: note: in expansion of macro 'if'
     if (filp->f_mode & FMODE_WRITE)
     ^~
   drivers/char/hw_random/core.c: In function 'rng_dev_read':
>> drivers/char/hw_random/core.c:221:23: error: 'O_NONBLOCK' undeclared (first use in this function)
        !(filp->f_flags & O_NONBLOCK));
                          ^~~~~~~~~~
   drivers/char/hw_random/core.c: At top level:
>> drivers/char/hw_random/core.c:272:21: error: variable 'rng_chrdev_ops' has initializer but incomplete type
    static const struct file_operations rng_chrdev_ops = {
                        ^~~~~~~~~~~~~~~
>> drivers/char/hw_random/core.c:273:2: error: unknown field 'owner' specified in initializer
     .owner  = THIS_MODULE,
     ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/linux/delay.h:10,
                    from drivers/char/hw_random/core.c:13:
   include/linux/export.h:37:21: warning: excess elements in struct initializer
    #define THIS_MODULE ((struct module *)0)
                        ^
>> drivers/char/hw_random/core.c:273:12: note: in expansion of macro 'THIS_MODULE'
     .owner  = THIS_MODULE,
               ^~~~~~~~~~~
   include/linux/export.h:37:21: note: (near initialization for 'rng_chrdev_ops')
    #define THIS_MODULE ((struct module *)0)
                        ^
>> drivers/char/hw_random/core.c:273:12: note: in expansion of macro 'THIS_MODULE'
     .owner  = THIS_MODULE,
               ^~~~~~~~~~~
>> drivers/char/hw_random/core.c:274:2: error: unknown field 'open' specified in initializer
     .open  = rng_dev_open,
     ^
>> drivers/char/hw_random/core.c:274:11: warning: excess elements in struct initializer
     .open  = rng_dev_open,
              ^~~~~~~~~~~~
   drivers/char/hw_random/core.c:274:11: note: (near initialization for 'rng_chrdev_ops')
>> drivers/char/hw_random/core.c:275:2: error: unknown field 'read' specified in initializer
     .read  = rng_dev_read,
     ^
   drivers/char/hw_random/core.c:275:11: warning: excess elements in struct initializer
     .read  = rng_dev_read,
              ^~~~~~~~~~~~
   drivers/char/hw_random/core.c:275:11: note: (near initialization for 'rng_chrdev_ops')
>> drivers/char/hw_random/core.c:276:2: error: unknown field 'llseek' specified in initializer
     .llseek  = noop_llseek,
     ^
>> drivers/char/hw_random/core.c:276:13: error: 'noop_llseek' undeclared here (not in a function)
     .llseek  = noop_llseek,
                ^~~~~~~~~~~
   drivers/char/hw_random/core.c:276:13: warning: excess elements in struct initializer
   drivers/char/hw_random/core.c:276:13: note: (near initialization for 'rng_chrdev_ops')
>> drivers/char/hw_random/core.c:272:37: error: storage size of 'rng_chrdev_ops' isn't known
    static const struct file_operations rng_chrdev_ops = {
                                        ^~~~~~~~~~~~~~

vim +169 drivers/char/hw_random/core.c

92c7987e7 Corentin Labbe    2016-12-09    7   * Please read Documentation/hw_random.txt for details on use.
92c7987e7 Corentin Labbe    2016-12-09    8   *
92c7987e7 Corentin Labbe    2016-12-09    9   * This software may be used and distributed according to the terms
92c7987e7 Corentin Labbe    2016-12-09   10   * of the GNU General Public License, incorporated herein by reference.
844dd05fe Michael Buesch    2006-06-26   11   */
844dd05fe Michael Buesch    2006-06-26   12  
b70f09c75 Corentin Labbe    2016-12-09  @13  #include <linux/delay.h>
844dd05fe Michael Buesch    2006-06-26   14  #include <linux/device.h>
b70f09c75 Corentin Labbe    2016-12-09   15  #include <linux/err.h>
844dd05fe Michael Buesch    2006-06-26   16  #include <linux/hw_random.h>
844dd05fe Michael Buesch    2006-06-26   17  #include <linux/kernel.h>
be4000bc4 Torsten Duwe      2014-06-14   18  #include <linux/kthread.h>
b70f09c75 Corentin Labbe    2016-12-09   19  #include <linux/miscdevice.h>
b70f09c75 Corentin Labbe    2016-12-09   20  #include <linux/module.h>
d9e797261 Kees Cook         2014-03-03   21  #include <linux/random.h>
b70f09c75 Corentin Labbe    2016-12-09   22  #include <linux/slab.h>
b70f09c75 Corentin Labbe    2016-12-09   23  #include <linux/uaccess.h>
844dd05fe Michael Buesch    2006-06-26   24  
844dd05fe Michael Buesch    2006-06-26   25  #define RNG_MODULE_NAME		"hw_random"
844dd05fe Michael Buesch    2006-06-26   26  
844dd05fe Michael Buesch    2006-06-26   27  static struct hwrng *current_rng;
be4000bc4 Torsten Duwe      2014-06-14   28  static struct task_struct *hwrng_fill;
844dd05fe Michael Buesch    2006-06-26   29  static LIST_HEAD(rng_list);
9372b35e1 Rusty Russell     2014-12-08   30  /* Protects rng_list and current_rng */
844dd05fe Michael Buesch    2006-06-26   31  static DEFINE_MUTEX(rng_mutex);
9372b35e1 Rusty Russell     2014-12-08   32  /* Protects rng read functions, data_avail, rng_buffer and rng_fillbuf */
9372b35e1 Rusty Russell     2014-12-08   33  static DEFINE_MUTEX(reading_mutex);
9996508b3 Ian Molton        2009-12-01   34  static int data_avail;
be4000bc4 Torsten Duwe      2014-06-14   35  static u8 *rng_buffer, *rng_fillbuf;
0f734e6e7 Torsten Duwe      2014-06-14   36  static unsigned short current_quality;
0f734e6e7 Torsten Duwe      2014-06-14   37  static unsigned short default_quality; /* = 0; default to "off" */
be4000bc4 Torsten Duwe      2014-06-14   38  
be4000bc4 Torsten Duwe      2014-06-14   39  module_param(current_quality, ushort, 0644);
be4000bc4 Torsten Duwe      2014-06-14   40  MODULE_PARM_DESC(current_quality,
be4000bc4 Torsten Duwe      2014-06-14   41  		 "current hwrng entropy estimation per mill");
0f734e6e7 Torsten Duwe      2014-06-14   42  module_param(default_quality, ushort, 0644);
0f734e6e7 Torsten Duwe      2014-06-14   43  MODULE_PARM_DESC(default_quality,
0f734e6e7 Torsten Duwe      2014-06-14   44  		 "default entropy content of hwrng per mill");
be4000bc4 Torsten Duwe      2014-06-14   45  
ff77c150f Herbert Xu        2014-12-23   46  static void drop_current_rng(void);
90ac41bd4 Herbert Xu        2014-12-23   47  static int hwrng_init(struct hwrng *rng);
be4000bc4 Torsten Duwe      2014-06-14   48  static void start_khwrngd(void);
f7f154f12 Rusty Russell     2013-03-05   49  
d3cc79964 Amit Shah         2014-07-10   50  static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
d3cc79964 Amit Shah         2014-07-10   51  			       int wait);
d3cc79964 Amit Shah         2014-07-10   52  
f7f154f12 Rusty Russell     2013-03-05   53  static size_t rng_buffer_size(void)
f7f154f12 Rusty Russell     2013-03-05   54  {
f7f154f12 Rusty Russell     2013-03-05   55  	return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES;
f7f154f12 Rusty Russell     2013-03-05   56  }
844dd05fe Michael Buesch    2006-06-26   57  
d3cc79964 Amit Shah         2014-07-10   58  static void add_early_randomness(struct hwrng *rng)
d3cc79964 Amit Shah         2014-07-10   59  {
d3cc79964 Amit Shah         2014-07-10   60  	int bytes_read;
6d4952d9d Andrew Lutomirski 2016-10-17   61  	size_t size = min_t(size_t, 16, rng_buffer_size());
d3cc79964 Amit Shah         2014-07-10   62  
9372b35e1 Rusty Russell     2014-12-08   63  	mutex_lock(&reading_mutex);
6d4952d9d Andrew Lutomirski 2016-10-17   64  	bytes_read = rng_get_data(rng, rng_buffer, size, 1);
9372b35e1 Rusty Russell     2014-12-08   65  	mutex_unlock(&reading_mutex);
d3cc79964 Amit Shah         2014-07-10   66  	if (bytes_read > 0)
6d4952d9d Andrew Lutomirski 2016-10-17   67  		add_device_randomness(rng_buffer, bytes_read);
d3cc79964 Amit Shah         2014-07-10   68  }
d3cc79964 Amit Shah         2014-07-10   69  
3a2c0ba5a Rusty Russell     2014-12-08   70  static inline void cleanup_rng(struct kref *kref)
3a2c0ba5a Rusty Russell     2014-12-08   71  {
3a2c0ba5a Rusty Russell     2014-12-08   72  	struct hwrng *rng = container_of(kref, struct hwrng, ref);
3a2c0ba5a Rusty Russell     2014-12-08   73  
3a2c0ba5a Rusty Russell     2014-12-08   74  	if (rng->cleanup)
3a2c0ba5a Rusty Russell     2014-12-08   75  		rng->cleanup(rng);
a027f30d7 Rusty Russell     2014-12-08   76  
77584ee57 Herbert Xu        2014-12-23   77  	complete(&rng->cleanup_done);
3a2c0ba5a Rusty Russell     2014-12-08   78  }
3a2c0ba5a Rusty Russell     2014-12-08   79  
90ac41bd4 Herbert Xu        2014-12-23   80  static int set_current_rng(struct hwrng *rng)
3a2c0ba5a Rusty Russell     2014-12-08   81  {
90ac41bd4 Herbert Xu        2014-12-23   82  	int err;
90ac41bd4 Herbert Xu        2014-12-23   83  
3a2c0ba5a Rusty Russell     2014-12-08   84  	BUG_ON(!mutex_is_locked(&rng_mutex));
90ac41bd4 Herbert Xu        2014-12-23   85  
90ac41bd4 Herbert Xu        2014-12-23   86  	err = hwrng_init(rng);
90ac41bd4 Herbert Xu        2014-12-23   87  	if (err)
90ac41bd4 Herbert Xu        2014-12-23   88  		return err;
90ac41bd4 Herbert Xu        2014-12-23   89  
ff77c150f Herbert Xu        2014-12-23   90  	drop_current_rng();
3a2c0ba5a Rusty Russell     2014-12-08   91  	current_rng = rng;
90ac41bd4 Herbert Xu        2014-12-23   92  
90ac41bd4 Herbert Xu        2014-12-23   93  	return 0;
3a2c0ba5a Rusty Russell     2014-12-08   94  }
3a2c0ba5a Rusty Russell     2014-12-08   95  
3a2c0ba5a Rusty Russell     2014-12-08   96  static void drop_current_rng(void)
3a2c0ba5a Rusty Russell     2014-12-08   97  {
3a2c0ba5a Rusty Russell     2014-12-08   98  	BUG_ON(!mutex_is_locked(&rng_mutex));
3a2c0ba5a Rusty Russell     2014-12-08   99  	if (!current_rng)
3a2c0ba5a Rusty Russell     2014-12-08  100  		return;
3a2c0ba5a Rusty Russell     2014-12-08  101  
3a2c0ba5a Rusty Russell     2014-12-08  102  	/* decrease last reference for triggering the cleanup */
3a2c0ba5a Rusty Russell     2014-12-08  103  	kref_put(&current_rng->ref, cleanup_rng);
3a2c0ba5a Rusty Russell     2014-12-08  104  	current_rng = NULL;
3a2c0ba5a Rusty Russell     2014-12-08  105  }
3a2c0ba5a Rusty Russell     2014-12-08  106  
3a2c0ba5a Rusty Russell     2014-12-08  107  /* Returns ERR_PTR(), NULL or refcounted hwrng */
3a2c0ba5a Rusty Russell     2014-12-08  108  static struct hwrng *get_current_rng(void)
3a2c0ba5a Rusty Russell     2014-12-08  109  {
3a2c0ba5a Rusty Russell     2014-12-08  110  	struct hwrng *rng;
3a2c0ba5a Rusty Russell     2014-12-08  111  
3a2c0ba5a Rusty Russell     2014-12-08  112  	if (mutex_lock_interruptible(&rng_mutex))
3a2c0ba5a Rusty Russell     2014-12-08  113  		return ERR_PTR(-ERESTARTSYS);
3a2c0ba5a Rusty Russell     2014-12-08  114  
3a2c0ba5a Rusty Russell     2014-12-08  115  	rng = current_rng;
3a2c0ba5a Rusty Russell     2014-12-08  116  	if (rng)
3a2c0ba5a Rusty Russell     2014-12-08  117  		kref_get(&rng->ref);
3a2c0ba5a Rusty Russell     2014-12-08  118  
3a2c0ba5a Rusty Russell     2014-12-08  119  	mutex_unlock(&rng_mutex);
3a2c0ba5a Rusty Russell     2014-12-08  120  	return rng;
3a2c0ba5a Rusty Russell     2014-12-08  121  }
3a2c0ba5a Rusty Russell     2014-12-08  122  
3a2c0ba5a Rusty Russell     2014-12-08  123  static void put_rng(struct hwrng *rng)
3a2c0ba5a Rusty Russell     2014-12-08  124  {
3a2c0ba5a Rusty Russell     2014-12-08  125  	/*
3a2c0ba5a Rusty Russell     2014-12-08  126  	 * Hold rng_mutex here so we serialize in case they set_current_rng
3a2c0ba5a Rusty Russell     2014-12-08  127  	 * on rng again immediately.
3a2c0ba5a Rusty Russell     2014-12-08  128  	 */
3a2c0ba5a Rusty Russell     2014-12-08  129  	mutex_lock(&rng_mutex);
3a2c0ba5a Rusty Russell     2014-12-08  130  	if (rng)
3a2c0ba5a Rusty Russell     2014-12-08  131  		kref_put(&rng->ref, cleanup_rng);
3a2c0ba5a Rusty Russell     2014-12-08  132  	mutex_unlock(&rng_mutex);
3a2c0ba5a Rusty Russell     2014-12-08  133  }
3a2c0ba5a Rusty Russell     2014-12-08  134  
90ac41bd4 Herbert Xu        2014-12-23  135  static int hwrng_init(struct hwrng *rng)
844dd05fe Michael Buesch    2006-06-26  136  {
15b66cd54 Herbert Xu        2014-12-23  137  	if (kref_get_unless_zero(&rng->ref))
15b66cd54 Herbert Xu        2014-12-23  138  		goto skip_init;
15b66cd54 Herbert Xu        2014-12-23  139  
d3cc79964 Amit Shah         2014-07-10  140  	if (rng->init) {
d3cc79964 Amit Shah         2014-07-10  141  		int ret;
d3cc79964 Amit Shah         2014-07-10  142  
d3cc79964 Amit Shah         2014-07-10  143  		ret =  rng->init(rng);
d3cc79964 Amit Shah         2014-07-10  144  		if (ret)
d3cc79964 Amit Shah         2014-07-10  145  			return ret;
d3cc79964 Amit Shah         2014-07-10  146  	}
15b66cd54 Herbert Xu        2014-12-23  147  
15b66cd54 Herbert Xu        2014-12-23  148  	kref_init(&rng->ref);
15b66cd54 Herbert Xu        2014-12-23  149  	reinit_completion(&rng->cleanup_done);
15b66cd54 Herbert Xu        2014-12-23  150  
15b66cd54 Herbert Xu        2014-12-23  151  skip_init:
d3cc79964 Amit Shah         2014-07-10  152  	add_early_randomness(rng);
be4000bc4 Torsten Duwe      2014-06-14  153  
0f734e6e7 Torsten Duwe      2014-06-14  154  	current_quality = rng->quality ? : default_quality;
506bf0c04 Keith Packard     2015-03-18  155  	if (current_quality > 1024)
506bf0c04 Keith Packard     2015-03-18  156  		current_quality = 1024;
0f734e6e7 Torsten Duwe      2014-06-14  157  
0f734e6e7 Torsten Duwe      2014-06-14  158  	if (current_quality == 0 && hwrng_fill)
0f734e6e7 Torsten Duwe      2014-06-14  159  		kthread_stop(hwrng_fill);
be4000bc4 Torsten Duwe      2014-06-14  160  	if (current_quality > 0 && !hwrng_fill)
be4000bc4 Torsten Duwe      2014-06-14  161  		start_khwrngd();
be4000bc4 Torsten Duwe      2014-06-14  162  
844dd05fe Michael Buesch    2006-06-26  163  	return 0;
844dd05fe Michael Buesch    2006-06-26  164  }
844dd05fe Michael Buesch    2006-06-26  165  
844dd05fe Michael Buesch    2006-06-26  166  static int rng_dev_open(struct inode *inode, struct file *filp)
844dd05fe Michael Buesch    2006-06-26  167  {
844dd05fe Michael Buesch    2006-06-26  168  	/* enforce read-only access to this chrdev */
844dd05fe Michael Buesch    2006-06-26 @169  	if ((filp->f_mode & FMODE_READ) == 0)
844dd05fe Michael Buesch    2006-06-26  170  		return -EINVAL;
844dd05fe Michael Buesch    2006-06-26 @171  	if (filp->f_mode & FMODE_WRITE)
844dd05fe Michael Buesch    2006-06-26  172  		return -EINVAL;
844dd05fe Michael Buesch    2006-06-26  173  	return 0;
844dd05fe Michael Buesch    2006-06-26  174  }
844dd05fe Michael Buesch    2006-06-26  175  
9996508b3 Ian Molton        2009-12-01  176  static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
9996508b3 Ian Molton        2009-12-01  177  			int wait) {
9996508b3 Ian Molton        2009-12-01  178  	int present;
9996508b3 Ian Molton        2009-12-01  179  
9372b35e1 Rusty Russell     2014-12-08  180  	BUG_ON(!mutex_is_locked(&reading_mutex));
9996508b3 Ian Molton        2009-12-01  181  	if (rng->read)
9996508b3 Ian Molton        2009-12-01  182  		return rng->read(rng, (void *)buffer, size, wait);
9996508b3 Ian Molton        2009-12-01  183  
9996508b3 Ian Molton        2009-12-01  184  	if (rng->data_present)
9996508b3 Ian Molton        2009-12-01  185  		present = rng->data_present(rng, wait);
9996508b3 Ian Molton        2009-12-01  186  	else
9996508b3 Ian Molton        2009-12-01  187  		present = 1;
9996508b3 Ian Molton        2009-12-01  188  
9996508b3 Ian Molton        2009-12-01  189  	if (present)
9996508b3 Ian Molton        2009-12-01  190  		return rng->data_read(rng, (u32 *)buffer);
9996508b3 Ian Molton        2009-12-01  191  
9996508b3 Ian Molton        2009-12-01  192  	return 0;
9996508b3 Ian Molton        2009-12-01  193  }
9996508b3 Ian Molton        2009-12-01  194  
844dd05fe Michael Buesch    2006-06-26  195  static ssize_t rng_dev_read(struct file *filp, char __user *buf,
844dd05fe Michael Buesch    2006-06-26  196  			    size_t size, loff_t *offp)
844dd05fe Michael Buesch    2006-06-26  197  {
844dd05fe Michael Buesch    2006-06-26  198  	ssize_t ret = 0;
984e976f5 Patrick McHardy   2007-11-21  199  	int err = 0;
9996508b3 Ian Molton        2009-12-01  200  	int bytes_read, len;
3a2c0ba5a Rusty Russell     2014-12-08  201  	struct hwrng *rng;
844dd05fe Michael Buesch    2006-06-26  202  
844dd05fe Michael Buesch    2006-06-26  203  	while (size) {
3a2c0ba5a Rusty Russell     2014-12-08  204  		rng = get_current_rng();
3a2c0ba5a Rusty Russell     2014-12-08  205  		if (IS_ERR(rng)) {
3a2c0ba5a Rusty Russell     2014-12-08  206  			err = PTR_ERR(rng);
844dd05fe Michael Buesch    2006-06-26  207  			goto out;
9996508b3 Ian Molton        2009-12-01  208  		}
3a2c0ba5a Rusty Russell     2014-12-08  209  		if (!rng) {
844dd05fe Michael Buesch    2006-06-26  210  			err = -ENODEV;
3a2c0ba5a Rusty Russell     2014-12-08  211  			goto out;
844dd05fe Michael Buesch    2006-06-26  212  		}
984e976f5 Patrick McHardy   2007-11-21  213  
1ab87298c Jiri Slaby        2015-11-27  214  		if (mutex_lock_interruptible(&reading_mutex)) {
1ab87298c Jiri Slaby        2015-11-27  215  			err = -ERESTARTSYS;
1ab87298c Jiri Slaby        2015-11-27  216  			goto out_put;
1ab87298c Jiri Slaby        2015-11-27  217  		}
9996508b3 Ian Molton        2009-12-01  218  		if (!data_avail) {
3a2c0ba5a Rusty Russell     2014-12-08  219  			bytes_read = rng_get_data(rng, rng_buffer,
f7f154f12 Rusty Russell     2013-03-05  220  				rng_buffer_size(),
9996508b3 Ian Molton        2009-12-01 @221  				!(filp->f_flags & O_NONBLOCK));
893f11286 Ralph Wuerthner   2008-04-17  222  			if (bytes_read < 0) {
893f11286 Ralph Wuerthner   2008-04-17  223  				err = bytes_read;
9372b35e1 Rusty Russell     2014-12-08  224  				goto out_unlock_reading;
9996508b3 Ian Molton        2009-12-01  225  			}
9996508b3 Ian Molton        2009-12-01  226  			data_avail = bytes_read;
893f11286 Ralph Wuerthner   2008-04-17  227  		}
844dd05fe Michael Buesch    2006-06-26  228  
9996508b3 Ian Molton        2009-12-01  229  		if (!data_avail) {
9996508b3 Ian Molton        2009-12-01  230  			if (filp->f_flags & O_NONBLOCK) {
9996508b3 Ian Molton        2009-12-01  231  				err = -EAGAIN;
9372b35e1 Rusty Russell     2014-12-08  232  				goto out_unlock_reading;
9996508b3 Ian Molton        2009-12-01  233  			}
9996508b3 Ian Molton        2009-12-01  234  		} else {
9996508b3 Ian Molton        2009-12-01  235  			len = data_avail;
9996508b3 Ian Molton        2009-12-01  236  			if (len > size)
9996508b3 Ian Molton        2009-12-01  237  				len = size;
9996508b3 Ian Molton        2009-12-01  238  
9996508b3 Ian Molton        2009-12-01  239  			data_avail -= len;
9996508b3 Ian Molton        2009-12-01  240  
9996508b3 Ian Molton        2009-12-01  241  			if (copy_to_user(buf + ret, rng_buffer + data_avail,
9996508b3 Ian Molton        2009-12-01  242  								len)) {
844dd05fe Michael Buesch    2006-06-26  243  				err = -EFAULT;
9372b35e1 Rusty Russell     2014-12-08  244  				goto out_unlock_reading;
9996508b3 Ian Molton        2009-12-01  245  			}
9996508b3 Ian Molton        2009-12-01  246  
9996508b3 Ian Molton        2009-12-01  247  			size -= len;
9996508b3 Ian Molton        2009-12-01  248  			ret += len;
844dd05fe Michael Buesch    2006-06-26  249  		}
844dd05fe Michael Buesch    2006-06-26  250  
9372b35e1 Rusty Russell     2014-12-08  251  		mutex_unlock(&reading_mutex);
3a2c0ba5a Rusty Russell     2014-12-08  252  		put_rng(rng);
9996508b3 Ian Molton        2009-12-01  253  
844dd05fe Michael Buesch    2006-06-26  254  		if (need_resched())
844dd05fe Michael Buesch    2006-06-26  255  			schedule_timeout_interruptible(1);
9996508b3 Ian Molton        2009-12-01  256  
9996508b3 Ian Molton        2009-12-01  257  		if (signal_pending(current)) {
844dd05fe Michael Buesch    2006-06-26  258  			err = -ERESTARTSYS;
844dd05fe Michael Buesch    2006-06-26  259  			goto out;
844dd05fe Michael Buesch    2006-06-26  260  		}
9996508b3 Ian Molton        2009-12-01  261  	}
844dd05fe Michael Buesch    2006-06-26  262  out:
844dd05fe Michael Buesch    2006-06-26  263  	return ret ? : err;
3a2c0ba5a Rusty Russell     2014-12-08  264  
9372b35e1 Rusty Russell     2014-12-08  265  out_unlock_reading:
9372b35e1 Rusty Russell     2014-12-08  266  	mutex_unlock(&reading_mutex);
1ab87298c Jiri Slaby        2015-11-27  267  out_put:
3a2c0ba5a Rusty Russell     2014-12-08  268  	put_rng(rng);
3a2c0ba5a Rusty Russell     2014-12-08  269  	goto out;
844dd05fe Michael Buesch    2006-06-26  270  }
844dd05fe Michael Buesch    2006-06-26  271  
62322d255 Arjan van de Ven  2006-07-03 @272  static const struct file_operations rng_chrdev_ops = {
844dd05fe Michael Buesch    2006-06-26 @273  	.owner		= THIS_MODULE,
844dd05fe Michael Buesch    2006-06-26 @274  	.open		= rng_dev_open,
844dd05fe Michael Buesch    2006-06-26 @275  	.read		= rng_dev_read,
6038f373a Arnd Bergmann     2010-08-15 @276  	.llseek		= noop_llseek,
844dd05fe Michael Buesch    2006-06-26  277  };
844dd05fe Michael Buesch    2006-06-26  278  
0daa7a0af Takashi Iwai      2015-02-02  279  static const struct attribute_group *rng_dev_groups[];

:::::: The code at line 169 was first introduced by commit
:::::: 844dd05fec172d98b0dacecd9b9e9f6595204c13 [PATCH] Add new generic HW RNG core

:::::: TO: Michael Buesch <mb@bu3sch.de>
:::::: CC: Linus Torvalds <torvalds@g5.osdl.org>

---
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: 17496 bytes --]

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

* Re: [PATCH 7/7] hwrng: core: Remove two unused include
  2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
  2016-12-09 18:24   ` Corentin Labbe
  2016-12-10  1:27   ` kbuild test robot
@ 2016-12-10  5:31   ` kbuild test robot
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2016-12-10  5:31 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: kbuild-all, mpm, herbert, arnd, gregkh, linux-crypto,
	linux-kernel, Corentin Labbe

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

Hi Corentin,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.9-rc8 next-20161209]
[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/Corentin-Labbe/hwrng-core-do-not-use-multiple-blank-lines/20161210-072632
config: i386-randconfig-i0-201649 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/char/hw_random/core.c: In function 'rng_dev_open':
>> drivers/char/hw_random/core.c:169:11: error: dereferencing pointer to incomplete type
     if ((filp->f_mode & FMODE_READ) == 0)
              ^
   drivers/char/hw_random/core.c:169:22: error: 'FMODE_READ' undeclared (first use in this function)
     if ((filp->f_mode & FMODE_READ) == 0)
                         ^
   drivers/char/hw_random/core.c:169:22: note: each undeclared identifier is reported only once for each function it appears in
   drivers/char/hw_random/core.c:171:10: error: dereferencing pointer to incomplete type
     if (filp->f_mode & FMODE_WRITE)
             ^
   drivers/char/hw_random/core.c:171:21: error: 'FMODE_WRITE' undeclared (first use in this function)
     if (filp->f_mode & FMODE_WRITE)
                        ^
   drivers/char/hw_random/core.c: In function 'rng_dev_read':
   drivers/char/hw_random/core.c:221:11: error: dereferencing pointer to incomplete type
        !(filp->f_flags & O_NONBLOCK));
              ^
   drivers/char/hw_random/core.c:221:23: error: 'O_NONBLOCK' undeclared (first use in this function)
        !(filp->f_flags & O_NONBLOCK));
                          ^
   drivers/char/hw_random/core.c:230:12: error: dereferencing pointer to incomplete type
       if (filp->f_flags & O_NONBLOCK) {
               ^
   drivers/char/hw_random/core.c: At top level:
   drivers/char/hw_random/core.c:272:21: error: variable 'rng_chrdev_ops' has initializer but incomplete type
    static const struct file_operations rng_chrdev_ops = {
                        ^
   drivers/char/hw_random/core.c:273:2: error: unknown field 'owner' specified in initializer
     .owner  = THIS_MODULE,
     ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/linux/delay.h:10,
                    from drivers/char/hw_random/core.c:13:
   include/linux/export.h:37:30: warning: excess elements in struct initializer [enabled by default]
    #define THIS_MODULE ((struct module *)0)
                                 ^
   drivers/char/hw_random/core.c:273:12: note: in expansion of macro 'THIS_MODULE'
     .owner  = THIS_MODULE,
               ^
   include/linux/export.h:37:30: warning: (near initialization for 'rng_chrdev_ops') [enabled by default]
    #define THIS_MODULE ((struct module *)0)
                                 ^
   drivers/char/hw_random/core.c:273:12: note: in expansion of macro 'THIS_MODULE'
     .owner  = THIS_MODULE,
               ^
   drivers/char/hw_random/core.c:274:2: error: unknown field 'open' specified in initializer
     .open  = rng_dev_open,
     ^
   drivers/char/hw_random/core.c:274:2: warning: excess elements in struct initializer [enabled by default]
   drivers/char/hw_random/core.c:274:2: warning: (near initialization for 'rng_chrdev_ops') [enabled by default]
   drivers/char/hw_random/core.c:275:2: error: unknown field 'read' specified in initializer
     .read  = rng_dev_read,
     ^
   drivers/char/hw_random/core.c:275:2: warning: excess elements in struct initializer [enabled by default]
   drivers/char/hw_random/core.c:275:2: warning: (near initialization for 'rng_chrdev_ops') [enabled by default]
   drivers/char/hw_random/core.c:276:2: error: unknown field 'llseek' specified in initializer
     .llseek  = noop_llseek,
     ^
   drivers/char/hw_random/core.c:276:13: error: 'noop_llseek' undeclared here (not in a function)
     .llseek  = noop_llseek,
                ^
   drivers/char/hw_random/core.c:276:2: warning: excess elements in struct initializer [enabled by default]
     .llseek  = noop_llseek,
     ^
   drivers/char/hw_random/core.c:276:2: warning: (near initialization for 'rng_chrdev_ops') [enabled by default]

vim +169 drivers/char/hw_random/core.c

844dd05f Michael Buesch 2006-06-26  163  	return 0;
844dd05f Michael Buesch 2006-06-26  164  }
844dd05f Michael Buesch 2006-06-26  165  
844dd05f Michael Buesch 2006-06-26  166  static int rng_dev_open(struct inode *inode, struct file *filp)
844dd05f Michael Buesch 2006-06-26  167  {
844dd05f Michael Buesch 2006-06-26  168  	/* enforce read-only access to this chrdev */
844dd05f Michael Buesch 2006-06-26 @169  	if ((filp->f_mode & FMODE_READ) == 0)
844dd05f Michael Buesch 2006-06-26  170  		return -EINVAL;
844dd05f Michael Buesch 2006-06-26  171  	if (filp->f_mode & FMODE_WRITE)
844dd05f Michael Buesch 2006-06-26  172  		return -EINVAL;

:::::: The code at line 169 was first introduced by commit
:::::: 844dd05fec172d98b0dacecd9b9e9f6595204c13 [PATCH] Add new generic HW RNG core

:::::: TO: Michael Buesch <mb@bu3sch.de>
:::::: CC: Linus Torvalds <torvalds@g5.osdl.org>

---
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: 26603 bytes --]

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

end of thread, other threads:[~2016-12-10  5:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-09 14:21 [PATCH 1/7] hwrng: core: do not use multiple blank lines Corentin Labbe
2016-12-09 14:21 ` [PATCH 2/7] hwrng: core: rewrite better comparison to NULL Corentin Labbe
2016-12-09 14:21 ` [PATCH 3/7] hwrng: core: Rewrite the header Corentin Labbe
2016-12-09 14:21 ` [PATCH 4/7] hwrng: core: Replace asm/uaccess.h by linux/uaccess.h Corentin Labbe
2016-12-09 14:21 ` [PATCH 5/7] hwrng: core: Move hwrng miscdev minor number to include/linux/miscdevice.h Corentin Labbe
2016-12-09 14:21 ` [PATCH 6/7] hwrng: core: remove unused PFX macro Corentin Labbe
2016-12-09 14:21 ` [PATCH 7/7] hwrng: core: Remove two unused include Corentin Labbe
2016-12-09 18:24   ` Corentin Labbe
2016-12-10  1:27   ` kbuild test robot
2016-12-10  5:31   ` 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;
as well as URLs for NNTP newsgroup(s).