Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc87dad7 authored by Jack Pham's avatar Jack Pham
Browse files

usb: misc: lvstest: allow specifying port for compliance mode



In some cases when connecting to a test fixture the host port
might not have triggered a connect change. As a result, dev->portnum
does not get updated and an attempt to enable the port for
compliance mode will pass 0 as the port number to the HCD, which is
invalid. Instead allow the user to pass an explicit port number
from the command line to specify the port to act on. Otherwise, if
omitted, the behavior is the same as before.

Change-Id: I2e323c9016915b2d535ac227fd6f3d5846aa4026
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 099e9fc7
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -184,10 +184,13 @@ static ssize_t warm_reset_store(struct device *dev,
	struct usb_interface *intf = to_usb_interface(dev);
	struct usb_interface *intf = to_usb_interface(dev);
	struct usb_device *hdev = interface_to_usbdev(intf);
	struct usb_device *hdev = interface_to_usbdev(intf);
	struct lvs_rh *lvs = usb_get_intfdata(intf);
	struct lvs_rh *lvs = usb_get_intfdata(intf);
	int port;
	int ret;
	int ret;


	ret = lvs_rh_set_port_feature(hdev, lvs->portnum,
	if (kstrtoint(buf, 0, &port) || port < 1 || port > 255)
			USB_PORT_FEAT_BH_PORT_RESET);
		port = lvs->portnum;

	ret = lvs_rh_set_port_feature(hdev, port, USB_PORT_FEAT_BH_PORT_RESET);
	if (ret < 0) {
	if (ret < 0) {
		dev_err(dev, "can't issue warm reset %d\n", ret);
		dev_err(dev, "can't issue warm reset %d\n", ret);
		return ret;
		return ret;
@@ -299,10 +302,14 @@ static ssize_t enable_compliance_store(struct device *dev,
	struct usb_interface *intf = to_usb_interface(dev);
	struct usb_interface *intf = to_usb_interface(dev);
	struct usb_device *hdev = interface_to_usbdev(intf);
	struct usb_device *hdev = interface_to_usbdev(intf);
	struct lvs_rh *lvs = usb_get_intfdata(intf);
	struct lvs_rh *lvs = usb_get_intfdata(intf);
	int port;
	int ret;
	int ret;


	if (kstrtoint(buf, 0, &port) || port < 1 || port > 255)
		port = lvs->portnum;

	ret = lvs_rh_set_port_feature(hdev,
	ret = lvs_rh_set_port_feature(hdev,
			lvs->portnum | USB_SS_PORT_LS_COMP_MOD << 3,
			port | (USB_SS_PORT_LS_COMP_MOD << 3),
			USB_PORT_FEAT_LINK_STATE);
			USB_PORT_FEAT_LINK_STATE);
	if (ret < 0) {
	if (ret < 0) {
		dev_err(dev, "can't enable compliance mode %d\n", ret);
		dev_err(dev, "can't enable compliance mode %d\n", ret);