Re: [PATCH v2] char: xillybus: Check endpoint type before allocing
From: Eli Billauer
Date: Tue May 24 2022 - 08:24:09 EST
On 23/05/22 20:15, Greg KH wrote:
Rather, it works like this: The driver uses the EP 1 IN and OUT endpoints to
> query the device for a data structure, which contains information on the
> device's communication channels. The driver sets up device files
> accordingly, and it also gets informed on which bulk OUT endpoints are
> present.
>
> For what it's worth, I think it's fairly safe to assume that if a device
> returns a legal data structure (which passes a CRC test), it's a XillyUSB
> device.
Why? You still need to verify that the requested endpoints match up
with what the device really has.
OK. So to summarize:
EP 1 IN and EP 1 OUT are always present in XillyUSB devices.
On top of these, there might be additional bulk OUT endpoints. The
driver resolves which ones in setup_channels(), by scanning a data blob
it has received from the device. This takes place in the for-loop inside
this function. When (out_desc & 0x80) is true for a given @i in the
loop, the device has a bulk OUT endpoint with address i+2 (e.g. if this
condition is met for i==2, the device has a bulk OUT EP 4).
So it seems like setup_channels() would be the right place to make this
check, since it's called during the device's probe.
I guess it would likewise make sense to check for EP 1 IN and OUT in
xillyusb_setup_base_eps().
Thanks,
Eli