Re: [PATCH 2/2] usb: serial: xr_serial: Add gpiochip support

From: Johan Hovold
Date: Tue May 19 2020 - 05:09:01 EST


On Wed, Apr 29, 2020 at 11:17:27PM +0530, Manivannan Sadhasivam wrote:

> On Wed, Apr 29, 2020 at 01:26:51AM +0530, mani@xxxxxxxxxx wrote:
> > From: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> >
> > Add gpiochip support for Maxlinear/Exar USB to serial converter
> > for controlling the available gpios.
> >
> > Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
> > Cc: linux-gpio@xxxxxxxxxxxxxxx
> > Signed-off-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>

> > static int xr_port_probe(struct usb_serial_port *port)
> > {
> > struct usb_serial *serial = port->serial;
> > @@ -495,13 +678,14 @@ static int xr_port_probe(struct usb_serial_port *port)
> >
> > usb_set_serial_port_data(port, port_priv);
> >
> > - return 0;
> > + return xr_gpio_init(port);
>
> Just realised that the gpiochip is registered for 2 interfaces exposed by
> this chip. This is due to the fact that this chip presents CDC-ACM model,
> so there are 2 interfaces (interrupt and bulk IN/OUT).
>
> We shouldn't need gpiochip for interface 0. So what is the recommended way
> to filter that?

Your driver should only bind to the data interface, but also claim the
control interface (i.e. the reverse of what cdc-acm is doing).

This CDC model doesn't really fit the assumptions of usb-serial core,
but it might be doable. Try returning 1 from the attach callback for the
control interface so that core claims it but doesn't register a tty
device.

Johan