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

Harry Geyer posted 1 patch 2 years, 4 months ago
There is a newer version of this series
drivers/i2c/busses/i2c-tiny-usb.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver
Posted by Harry Geyer 2 years, 4 months ago
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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index d1fa9ff5aeab..d6578e8908ac 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -222,6 +222,9 @@ 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 */
-- 
2.34.1
Re: [PATCH] i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver
Posted by Andi Shyti 2 years, 4 months ago
Hi Harry,

On Thu, Jul 27, 2023 at 09:33:54AM +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 | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
> index d1fa9ff5aeab..d6578e8908ac 100644
> --- a/drivers/i2c/busses/i2c-tiny-usb.c
> +++ b/drivers/i2c/busses/i2c-tiny-usb.c
> @@ -222,6 +222,9 @@ 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)

I'm sorry, I meant the same column, my bad here!
Would you please be so kind to resend it as


	if (interface->intf_assoc &&
	    interface->intf_assoc->bFunctionClass != USB_CLASS_VENDOR_SPEC)

It's a nitpick, though.

On the other hand, checkpatch is OK with lines up to 100
characters and this one looks like it's withing that length. So,
up to your personal preference.

If you resend it, you can add my r-b.

Thank you and again, sorry,
Andi

PS Next time, please add a changelog and a versioning to
   following patches.

> +		return -ENODEV;
> +
>  	dev_dbg(&interface->dev, "probing usb device\n");
>  
>  	/* allocate memory for our device state and initialize it */
> -- 
> 2.34.1
>
Re: [PATCH] i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver
Posted by Harry Geyer 2 years, 4 months ago
Hi Andi,

On 27/07/2023 12:30, Andi Shyti wrote:
> On the other hand, checkpatch is OK with lines up to 100
> characters and this one looks like it's withing that length. So,
> up to your personal preference.
I am happy to resend the patch.
> If you resend it, you can add my r-b.
Not sure what you mean, I am sorry. Please, can you explain what you 
want me to do.

Thank you,

Harry.
Re: [PATCH] i2c: tiny-usb: check usb base class before assuming the interface on device is for this driver
Posted by Andi Shyti 2 years, 4 months ago
On Thu, Jul 27, 2023 at 02:54:42PM +0100, Harry Geyer wrote:
> Hi Andi,
> 
> On 27/07/2023 12:30, Andi Shyti wrote:
> > On the other hand, checkpatch is OK with lines up to 100
> > characters and this one looks like it's withing that length. So,
> > up to your personal preference.
> I am happy to resend the patch.

Thanks!

> > If you resend it, you can add my r-b.
> Not sure what you mean, I am sorry. Please, can you explain what you want me
> to do.

I was meaning that you could add my Reviewed-by:... you can
also ignore it, I can r-b it later.

Thanks,
Andi

PS r-b = Reviewed-by, if this was the reason of confusion :)