summaryrefslogtreecommitdiff
path: root/drivers/usb/misc/legousbtower.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2019-11-05 09:41:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-11-07 11:17:49 +0100
commit30da837a4938438a0259a7bc38dc05d66fa77c08 (patch)
treebf9de075cb5b7d85870a28dd9f5af5e20b4260b7 /drivers/usb/misc/legousbtower.c
parent07efa8738853696f100b0495b767823308330b3d (diff)
USB: legousbtower: zero driver data at allocation
Zero the driver data at allocation rather than depend on explicit zeroing, which easy to miss. Also drop an unnecessary driver-data pointer initialisation. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20191105084152.16322-4-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc/legousbtower.c')
-rw-r--r--drivers/usb/misc/legousbtower.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index a3ae843e0a3a..c880d58e8683 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -791,45 +791,24 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
{
struct device *idev = &interface->dev;
struct usb_device *udev = interface_to_usbdev(interface);
- struct lego_usb_tower *dev = NULL;
+ struct lego_usb_tower *dev;
struct tower_get_version_reply *get_version_reply = NULL;
int retval = -ENOMEM;
int result;
/* allocate memory for our device state and initialize it */
-
- dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL);
-
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
goto exit;
mutex_init(&dev->lock);
-
dev->udev = usb_get_dev(udev);
- dev->open_count = 0;
- dev->disconnected = 0;
-
- dev->read_buffer = NULL;
- dev->read_buffer_length = 0;
- dev->read_packet_length = 0;
spin_lock_init (&dev->read_buffer_lock);
dev->packet_timeout_jiffies = msecs_to_jiffies(packet_timeout);
dev->read_last_arrival = jiffies;
-
init_waitqueue_head (&dev->read_wait);
init_waitqueue_head (&dev->write_wait);
- dev->interrupt_in_buffer = NULL;
- dev->interrupt_in_endpoint = NULL;
- dev->interrupt_in_urb = NULL;
- dev->interrupt_in_running = 0;
- dev->interrupt_in_done = 0;
-
- dev->interrupt_out_buffer = NULL;
- dev->interrupt_out_endpoint = NULL;
- dev->interrupt_out_urb = NULL;
- dev->interrupt_out_busy = 0;
-
result = usb_find_common_endpoints_reverse(interface->cur_altsetting,
NULL, NULL,
&dev->interrupt_in_endpoint,