From: Oliver Neukum <oneukum@suse.com>
To: himadrispandya@gmail.com, gregKH@linuxfoundation.org,
stern@rowland.harvard.edu, linux-usb@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Subject: [RFC 07/14] Revert "USB: legousbtower: use usb_control_msg_recv()"
Date: Wed, 23 Sep 2020 15:43:41 +0200 [thread overview]
Message-ID: <20200923134348.23862-8-oneukum@suse.com> (raw)
In-Reply-To: <20200923134348.23862-1-oneukum@suse.com>
This reverts commit be40c366416bf6ff74b25fd02e38cb6eaba497d1.
The API has to be changed.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/usb/misc/legousbtower.c | 60 ++++++++++++++++++++++++++++-------------
1 file changed, 41 insertions(+), 19 deletions(-)
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index c3583df4c324..f922544056de 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -308,9 +308,15 @@ static int tower_open(struct inode *inode, struct file *file)
int subminor;
int retval = 0;
struct usb_interface *interface;
- struct tower_reset_reply reset_reply;
+ struct tower_reset_reply *reset_reply;
int result;
+ reset_reply = kmalloc(sizeof(*reset_reply), GFP_KERNEL);
+ if (!reset_reply) {
+ retval = -ENOMEM;
+ goto exit;
+ }
+
nonseekable_open(inode, file);
subminor = iminor(inode);
@@ -341,11 +347,15 @@ static int tower_open(struct inode *inode, struct file *file)
}
/* reset the tower */
- result = usb_control_msg_recv(dev->udev, 0,
- LEGO_USB_TOWER_REQUEST_RESET,
- USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
- 0, 0,
- &reset_reply, sizeof(reset_reply), 1000);
+ result = usb_control_msg(dev->udev,
+ usb_rcvctrlpipe(dev->udev, 0),
+ LEGO_USB_TOWER_REQUEST_RESET,
+ USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
+ 0,
+ 0,
+ reset_reply,
+ sizeof(*reset_reply),
+ 1000);
if (result < 0) {
dev_err(&dev->udev->dev,
"LEGO USB Tower reset control request failed\n");
@@ -384,6 +394,7 @@ static int tower_open(struct inode *inode, struct file *file)
mutex_unlock(&dev->lock);
exit:
+ kfree(reset_reply);
return retval;
}
@@ -742,7 +753,7 @@ 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;
- struct tower_get_version_reply get_version_reply;
+ struct tower_get_version_reply *get_version_reply = NULL;
int retval = -ENOMEM;
int result;
@@ -787,25 +798,34 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_
dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
+ get_version_reply = kmalloc(sizeof(*get_version_reply), GFP_KERNEL);
+ if (!get_version_reply) {
+ retval = -ENOMEM;
+ goto error;
+ }
+
/* get the firmware version and log it */
- result = usb_control_msg_recv(udev, 0,
- LEGO_USB_TOWER_REQUEST_GET_VERSION,
- USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
- 0,
- 0,
- &get_version_reply,
- sizeof(get_version_reply),
- 1000);
- if (!result) {
+ result = usb_control_msg(udev,
+ usb_rcvctrlpipe(udev, 0),
+ LEGO_USB_TOWER_REQUEST_GET_VERSION,
+ USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
+ 0,
+ 0,
+ get_version_reply,
+ sizeof(*get_version_reply),
+ 1000);
+ if (result != sizeof(*get_version_reply)) {
+ if (result >= 0)
+ result = -EIO;
dev_err(idev, "get version request failed: %d\n", result);
retval = result;
goto error;
}
dev_info(&interface->dev,
"LEGO USB Tower firmware version is %d.%d build %d\n",
- get_version_reply.major,
- get_version_reply.minor,
- le16_to_cpu(get_version_reply.build_no));
+ get_version_reply->major,
+ get_version_reply->minor,
+ le16_to_cpu(get_version_reply->build_no));
/* we can register the device now, as it is ready */
usb_set_intfdata(interface, dev);
@@ -824,9 +844,11 @@ static int tower_probe(struct usb_interface *interface, const struct usb_device_
USB_MAJOR, dev->minor);
exit:
+ kfree(get_version_reply);
return retval;
error:
+ kfree(get_version_reply);
tower_delete(dev);
return retval;
}
--
2.16.4
next prev parent reply other threads:[~2020-09-23 13:44 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 13:43 [RFC] change the new message to provide for memory allocations Oliver Neukum
2020-09-23 13:43 ` [RFC 01/14] Revert "USB: core: hub.c: use usb_control_msg_send() in a few places" Oliver Neukum
2020-09-23 13:43 ` [RFC 02/14] Revert "Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv()" Oliver Neukum
2020-09-23 13:43 ` [RFC 03/14] Revert "sound: hiface: move to use usb_control_msg_send()" Oliver Neukum
2020-09-23 13:43 ` [RFC 04/14] Revert "sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv()" Oliver Neukum
2020-09-23 13:43 ` [RFC 05/14] Revert "sound: 6fire: " Oliver Neukum
2020-09-23 13:43 ` [RFC 06/14] Revert "sound: usx2y: move to use usb_control_msg_send()" Oliver Neukum
2020-09-23 13:43 ` Oliver Neukum [this message]
2020-09-23 13:43 ` [RFC 08/14] USB: correct API of usb_control_msg_send/recv Oliver Neukum
2020-09-25 9:31 ` [PATCH 0/2] [usb] Petko Manolov
2020-09-25 9:31 ` [PATCH 1/2] net: pegasus: convert control messages to the new send/recv scheme Petko Manolov
2020-09-25 14:37 ` Greg KH
2020-09-25 16:01 ` [PATCH 0/2] [patch v2] utilize the new control message send and receive API Petko Manolov
2020-09-25 16:01 ` [PATCH 1/2] net: pegasus: convert control messages to the new send/recv scheme Petko Manolov
2020-09-26 5:44 ` Greg KH
2020-09-26 8:21 ` Petko Manolov
2020-09-26 12:45 ` Greg KH
2020-09-25 16:02 ` [PATCH 2/2] net: rtl8150: " Petko Manolov
2020-09-25 20:14 ` kernel test robot
2020-09-25 16:05 ` [PATCH 1/2] net: pegasus: " Petko Manolov
2020-09-26 5:45 ` Greg KH
2020-09-25 9:31 ` [PATCH 2/2] net: rtl8150: " Petko Manolov
2020-09-25 14:37 ` Greg KH
2020-09-26 9:13 ` [PATCH v3 0/2] Use the new usb control message API Petko Manolov
2020-09-26 9:13 ` [PATCH v3 1/2] net: pegasus: " Petko Manolov
2020-09-26 9:13 ` [PATCH v3 2/2] net: rtl8150: " Petko Manolov
2020-09-27 10:16 ` [PATCH v3 0/2] " Greg KH
2020-09-27 12:56 ` Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND " Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND v3 1/2] net: pegasus: " Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND v3 2/2] net: rtl8150: " Petko Manolov
2020-09-28 23:00 ` [PATCH RESEND v3 0/2] " David Miller
2020-09-29 4:59 ` Petko Manolov
2020-09-29 19:58 ` David Miller
2020-09-30 6:23 ` Greg KH
2020-09-23 13:43 ` [RFC 09/14] sound: usx2y: move to use usb_control_msg_send() Oliver Neukum
2020-09-25 14:32 ` Greg KH
2020-09-23 13:43 ` [RFC 10/14] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 11/14] USB: legousbtower: use usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 12/14] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 13/14] sound: hiface: move to use usb_control_msg_send() Oliver Neukum
2020-09-23 13:43 ` [RFC 14/14] Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 17:21 ` [RFC] change the new message to provide for memory allocations Greg KH
2020-09-23 17:32 ` Oliver Neukum
2020-09-23 17:46 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200923134348.23862-8-oneukum@suse.com \
--to=oneukum@suse.com \
--cc=gregKH@linuxfoundation.org \
--cc=himadrispandya@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).