diff mbox series

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

Message ID 20230727162255.21551-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 27, 2023, 4:22 p.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 | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andi Shyti July 27, 2023, 5:13 p.m. UTC | #1
Hi Harry,

On Thu, Jul 27, 2023 at 05:22:55PM +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>
> ---
>  drivers/i2c/busses/i2c-tiny-usb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
> index d1fa9ff5aeab..1bffe36c40ad 100644
> --- a/drivers/i2c/busses/i2c-tiny-usb.c
> +++ b/drivers/i2c/busses/i2c-tiny-usb.c
> @@ -222,6 +222,10 @@ 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;
> +

Thanks for resending it!

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi
Andi Shyti Aug. 2, 2023, 8:02 p.m. UTC | #2
Hi

On Thu, 27 Jul 2023 17:22:55 +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.
> 
> 

Applied to i2c/andi-for-current on

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Please note that this patch may still undergo further evaluation
and the final decision will be made in collaboration with
Wolfram.

Thank you,
Andi

Patches applied
===============
[1/1] i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver
      commit: c6607c0c7118ab96dcbc57df67fe316e871666a1
Wolfram Sang Aug. 14, 2023, 1:17 p.m. UTC | #3
> Please note that this patch may still undergo further evaluation
> and the final decision will be made in collaboration with
> Wolfram.

I chose to apply it to for-next. I don't know how many clones are out
there and if they all have the same FunctionClass. So, I'd like to give
this some testing in -next and during the next release cycle.

Applied to for-next, thanks! Thanks for backing me up, Andi!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index d1fa9ff5aeab..1bffe36c40ad 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -222,6 +222,10 @@  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 */