提交 8b86ed07 编写于 作者: K Keith Packard 提交者: Greg Kroah-Hartman

usb: Fix warnings in chaoskey driver

>    drivers/usb/misc/chaoskey.c: In function 'chaoskey_read':
> >> drivers/usb/misc/chaoskey.c:412:3: error: implicit declaration of function 'copy_to_user'
> >> [-Werror=implicit-function-declaration]
>       remain = copy_to_user(buffer, dev->buf + dev->used, this_time);

I was unable to reproduce this locally, but added an explicit

	#include <linux/uaccess.h>

which should ensure the definition on all architectures.

> sparse warnings: (new ones prefixed by >>)
>
> >> drivers/usb/misc/chaoskey.c:117:30: sparse: incorrect type in assignment (different base types)
>    drivers/usb/misc/chaoskey.c:117:30:    expected int [signed] size
>    drivers/usb/misc/chaoskey.c:117:30:    got restricted __le16 [usertype] wMaxPacketSize

Switched the code to using the USB descriptor accessor functions.
Signed-off-by: NKeith Packard <keithp@keithp.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 f4ea80a6
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/hw_random.h> #include <linux/hw_random.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
static struct usb_driver chaoskey_driver; static struct usb_driver chaoskey_driver;
static struct usb_class_driver chaoskey_class; static struct usb_class_driver chaoskey_class;
...@@ -113,8 +115,8 @@ static int chaoskey_probe(struct usb_interface *interface, ...@@ -113,8 +115,8 @@ static int chaoskey_probe(struct usb_interface *interface,
/* Find the first bulk IN endpoint and its packet size */ /* Find the first bulk IN endpoint and its packet size */
for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) { if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) {
in_ep = altsetting->endpoint[i].desc.bEndpointAddress; in_ep = usb_endpoint_num(&altsetting->endpoint[i].desc);
size = altsetting->endpoint[i].desc.wMaxPacketSize; size = usb_endpoint_maxp(&altsetting->endpoint[i].desc);
break; break;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册