usbtest.c (141d3b1daacd11bdbd6fa74c2b163093e10d17ee) usbtest.c (d9e1e1484ade396b3a979ba6c68798dbaceed1b9)
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kernel.h>
2#include <linux/errno.h>
3#include <linux/init.h>
4#include <linux/slab.h>
5#include <linux/mm.h>
6#include <linux/module.h>
7#include <linux/moduleparam.h>
8#include <linux/scatterlist.h>

--- 1001 unchanged lines hidden (view full) ---

1010 return (retval < 0) ? retval : -EDOM;
1011 }
1012 }
1013 }
1014 }
1015 /* FIXME fetch strings from at least the device descriptor */
1016
1017 /* [9.4.5] get_status always works */
2#include <linux/kernel.h>
3#include <linux/errno.h>
4#include <linux/init.h>
5#include <linux/slab.h>
6#include <linux/mm.h>
7#include <linux/module.h>
8#include <linux/moduleparam.h>
9#include <linux/scatterlist.h>

--- 1001 unchanged lines hidden (view full) ---

1011 return (retval < 0) ? retval : -EDOM;
1012 }
1013 }
1014 }
1015 }
1016 /* FIXME fetch strings from at least the device descriptor */
1017
1018 /* [9.4.5] get_status always works */
1018 retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf);
1019 retval = usb_get_std_status(udev, USB_RECIP_DEVICE, 0, dev->buf);
1019 if (retval) {
1020 dev_err(&iface->dev, "get dev status --> %d\n", retval);
1021 return retval;
1022 }
1023
1024 /* FIXME configuration.bmAttributes says if we could try to set/clear
1025 * the device's remote wakeup feature ... if we can, test that here
1026 */
1027
1020 if (retval) {
1021 dev_err(&iface->dev, "get dev status --> %d\n", retval);
1022 return retval;
1023 }
1024
1025 /* FIXME configuration.bmAttributes says if we could try to set/clear
1026 * the device's remote wakeup feature ... if we can, test that here
1027 */
1028
1028 retval = usb_get_status(udev, USB_RECIP_INTERFACE,
1029 retval = usb_get_std_status(udev, USB_RECIP_INTERFACE,
1029 iface->altsetting[0].desc.bInterfaceNumber, dev->buf);
1030 if (retval) {
1031 dev_err(&iface->dev, "get interface status --> %d\n", retval);
1032 return retval;
1033 }
1034 /* FIXME get status for each endpoint in the interface */
1035
1036 return 0;

--- 572 unchanged lines hidden (view full) ---

1609/*-------------------------------------------------------------------------*/
1610
1611static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1612{
1613 int retval;
1614 u16 status;
1615
1616 /* shouldn't look or act halted */
1030 iface->altsetting[0].desc.bInterfaceNumber, dev->buf);
1031 if (retval) {
1032 dev_err(&iface->dev, "get interface status --> %d\n", retval);
1033 return retval;
1034 }
1035 /* FIXME get status for each endpoint in the interface */
1036
1037 return 0;

--- 572 unchanged lines hidden (view full) ---

1610/*-------------------------------------------------------------------------*/
1611
1612static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1613{
1614 int retval;
1615 u16 status;
1616
1617 /* shouldn't look or act halted */
1617 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1618 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1618 if (retval < 0) {
1619 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
1620 ep, retval);
1621 return retval;
1622 }
1623 if (status != 0) {
1624 ERROR(tdev, "ep %02x bogus status: %04x != 0\n", ep, status);
1625 return -EINVAL;

--- 5 unchanged lines hidden (view full) ---

1631}
1632
1633static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1634{
1635 int retval;
1636 u16 status;
1637
1638 /* should look and act halted */
1619 if (retval < 0) {
1620 ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
1621 ep, retval);
1622 return retval;
1623 }
1624 if (status != 0) {
1625 ERROR(tdev, "ep %02x bogus status: %04x != 0\n", ep, status);
1626 return -EINVAL;

--- 5 unchanged lines hidden (view full) ---

1632}
1633
1634static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
1635{
1636 int retval;
1637 u16 status;
1638
1639 /* should look and act halted */
1639 retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1640 retval = usb_get_std_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
1640 if (retval < 0) {
1641 ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
1642 ep, retval);
1643 return retval;
1644 }
1645 if (status != 1) {
1646 ERROR(tdev, "ep %02x bogus status: %04x != 1\n", ep, status);
1647 return -EINVAL;

--- 256 unchanged lines hidden (view full) ---

1904 unsigned offset
1905)
1906{
1907 struct urb *urb;
1908 unsigned i, maxp, packets;
1909
1910 if (bytes < 0 || !desc)
1911 return NULL;
1641 if (retval < 0) {
1642 ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
1643 ep, retval);
1644 return retval;
1645 }
1646 if (status != 1) {
1647 ERROR(tdev, "ep %02x bogus status: %04x != 1\n", ep, status);
1648 return -EINVAL;

--- 256 unchanged lines hidden (view full) ---

1905 unsigned offset
1906)
1907{
1908 struct urb *urb;
1909 unsigned i, maxp, packets;
1910
1911 if (bytes < 0 || !desc)
1912 return NULL;
1912 maxp = 0x7ff & usb_endpoint_maxp(desc);
1913 maxp = usb_endpoint_maxp(desc);
1913 maxp *= usb_endpoint_maxp_mult(desc);
1914 packets = DIV_ROUND_UP(bytes, maxp);
1915
1916 urb = usb_alloc_urb(packets, GFP_KERNEL);
1917 if (!urb)
1918 return urb;
1919 urb->dev = udev;
1920 urb->pipe = pipe;

--- 1045 unchanged lines hidden ---
1914 maxp *= usb_endpoint_maxp_mult(desc);
1915 packets = DIV_ROUND_UP(bytes, maxp);
1916
1917 urb = usb_alloc_urb(packets, GFP_KERNEL);
1918 if (!urb)
1919 return urb;
1920 urb->dev = udev;
1921 urb->pipe = pipe;

--- 1045 unchanged lines hidden ---