Re: [PATCH] [RFC PATCH] Set NTB format again after altsetting switch for Huawei devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you Enrico and Bjørn. 

I will test it monday when I get access to my devices again.

> @@ -856,6 +858,33 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
> 		goto error2;
> 	}
> 
> +	/*
> +	 * Some Huawei devices have been observed to come out of reset in NDP32 mode.
> +	 * Let's check if this is the case, and set the device to NDP16 mode again if
> +	 * needed.
> +	*/
> +	if (ctx->drvflags & CDC_NCM_FLAG_RESET_NDP16) {
> +		err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_FORMAT,
> +				      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
> +				      0, iface_no, &curr_ntb_format, 2);
> +		if (err < 0) {
> +			printk("Error reading: %d\n.",err);
> +			goto error2;
> +		}
> +
> +		if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) {
> +			dev_info(&intf->dev, "resetting NDp format to 16-bit");
> +			err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
> +					       USB_TYPE_CLASS | USB_DIR_OUT
> +					       | USB_RECIP_INTERFACE,
> +					       USB_CDC_NCM_NTB16_FORMAT,
> +					       iface_no, NULL, 0);
> +
> +			if (err < 0)
> +				goto error2;
> +		}
> +	}
> +
> 	/* initialize basic device settings */
> 	if (cdc_ncm_init(dev))
> 		goto error2;

Even though I cannot test it, I already suspect that this will not work. 

The check + reset to 16 bit needs to happen somewhere after cdc_ncm_init, as the main problem is that the 318 firmware resets back to 32-bit mode once it is switched back with alt setting 1. The proposed patch will check if it is in 32 bit mode after switching to alt setting 0. An then it will switch to 16-bit mode. Then switch once again (without any checks) inside cdc_ncm_init.

I think the correct place is somewhere after the code below. But I can provide more insights to this next week.

	/* configure data interface */
	temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
	if (temp) {
		dev_dbg(&intf->dev, "set interface failed\n");
		goto error2;
	}

Christian

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux