Re: [PATCH v3] mfd: ch341: add driver for the WCH CH341 in I2C/GPIO mode

From: Greg Kroah-Hartman
Date: Tue Mar 15 2022 - 10:30:31 EST


On Sun, Mar 13, 2022 at 10:09:37PM -0500, frank zago wrote:
> +static int ch341_usb_probe(struct usb_interface *iface,
> + const struct usb_device_id *usb_id)
> +{
> + struct usb_host_endpoint *endpoints;
> + struct ch341_device *dev;
> + int rc;
> +
> + dev = kzalloc(sizeof(struct ch341_device), GFP_KERNEL);
> + if (!dev)
> + return -ENOMEM;
> +
> + dev->usb_dev = usb_get_dev(interface_to_usbdev(iface));
> + dev->iface = iface;
> + mutex_init(&dev->usb_lock);
> +
> + if (iface->cur_altsetting->desc.bNumEndpoints != 3) {
> + rc = -EIO;

-ENODEV is the proper one here.

> + goto free_dev;
> + }
> +
> + endpoints = iface->cur_altsetting->endpoint;
> + if (!usb_endpoint_is_bulk_in(&endpoints[0].desc) ||
> + !usb_endpoint_is_bulk_out(&endpoints[1].desc) ||
> + !usb_endpoint_xfer_int(&endpoints[2].desc)) {
> + rc = -EIO;

Same here.

thanks,

greg k-h