diff mbox series

i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver

Message ID 20230719113838.17714-1-harry.geyer@devtank.co.uk
State Superseded
Headers show
Series i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver | expand

Commit Message

Harry Geyer July 19, 2023, 11:38 a.m. UTC
Patch allows usb devices with multiple interfaces to use this driver without
this driver assuming all interfaces are i2c-tiny-usb.

Signed-off-by: Harry Geyer <harry.geyer@devtank.co.uk>
---
 drivers/i2c/busses/i2c-tiny-usb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Andi Shyti July 26, 2023, 4:08 p.m. UTC | #1
Hi Harry,

it's OK, just few little adjustments...

On Wed, Jul 19, 2023 at 12:38:38PM +0100, Harry Geyer wrote:
> Patch allows usb devices with multiple interfaces to use this driver without
> this driver assuming all interfaces are i2c-tiny-usb.
> 
> Signed-off-by: Harry Geyer <harry.geyer@devtank.co.uk>

Please add:

Fixes: e8c76eed2ecd ("i2c: New i2c-tiny-usb bus driver")
Cc: Till Harbaum <till@harbaum.org>
Cc: <stable@vger.kernel.org> # v2.6.22+

> ---
>  drivers/i2c/busses/i2c-tiny-usb.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
> index d1fa9ff5aeab..fc194c65e50e 100644
> --- a/drivers/i2c/busses/i2c-tiny-usb.c
> +++ b/drivers/i2c/busses/i2c-tiny-usb.c
> @@ -222,6 +222,11 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
>  	int retval = -ENOMEM;
>  	u16 version;
>  
> +	if (interface->intf_assoc &&
> +		interface->intf_assoc->bFunctionClass != USB_CLASS_VENDOR_SPEC) {

please fix the indentation here ('interface' and 'interface'
should go on the same line)

> +		return -ENODEV;
> +	}

please drop the brackets.

Andi

> +
>  	dev_dbg(&interface->dev, "probing usb device\n");
>  
>  	/* allocate memory for our device state and initialize it */
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index d1fa9ff5aeab..fc194c65e50e 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -222,6 +222,11 @@  static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	int retval = -ENOMEM;
 	u16 version;
 
+	if (interface->intf_assoc &&
+		interface->intf_assoc->bFunctionClass != USB_CLASS_VENDOR_SPEC) {
+		return -ENODEV;
+	}
+
 	dev_dbg(&interface->dev, "probing usb device\n");
 
 	/* allocate memory for our device state and initialize it */