aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/message.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2013-07-30 15:35:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-31 20:29:02 -0400
commit15b7336e02d998720c5ace47036f7e539365bb05 (patch)
treedb90ccb73d4b50fdfab0c3a93144b9d803622c46 /drivers/usb/core/message.c
parentb977a3068a284b2ad4612cdb8ca326cbd2a7ffc9 (diff)
USB: simplify the interface of usb_get_status()
This patch simplifies the interface presented by usb_get_status(). Instead of forcing callers to check for the proper data length and convert the status value to host byte order, the function will now do these things itself. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core/message.c')
-rw-r--r--drivers/usb/core/message.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e7ee1e451660..6549a975b0c5 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -934,13 +934,13 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
934 * 934 *
935 * This call is synchronous, and may not be used in an interrupt context. 935 * This call is synchronous, and may not be used in an interrupt context.
936 * 936 *
937 * Returns the number of bytes received on success, or else the status code 937 * Returns 0 and the status value in *@data (in host byte order) on success,
938 * returned by the underlying usb_control_msg() call. 938 * or else the status code from the underlying usb_control_msg() call.
939 */ 939 */
940int usb_get_status(struct usb_device *dev, int type, int target, void *data) 940int usb_get_status(struct usb_device *dev, int type, int target, void *data)
941{ 941{
942 int ret; 942 int ret;
943 u16 *status = kmalloc(sizeof(*status), GFP_KERNEL); 943 __le16 *status = kmalloc(sizeof(*status), GFP_KERNEL);
944 944
945 if (!status) 945 if (!status)
946 return -ENOMEM; 946 return -ENOMEM;
@@ -949,7 +949,12 @@ int usb_get_status(struct usb_device *dev, int type, int target, void *data)
949 USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status, 949 USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status,
950 sizeof(*status), USB_CTRL_GET_TIMEOUT); 950 sizeof(*status), USB_CTRL_GET_TIMEOUT);
951 951
952 *(u16 *)data = *status; 952 if (ret == 2) {
953 *(u16 *) data = le16_to_cpu(*status);
954 ret = 0;
955 } else if (ret >= 0) {
956 ret = -EIO;
957 }
953 kfree(status); 958 kfree(status);
954 return ret; 959 return ret;
955} 960}