* [PATCH] usbnet: ipheth: Simplify device detection
@ 2019-04-24 17:58 Guenter Roeck
2019-04-26 11:27 ` Simon Horman
2019-04-26 15:34 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Guenter Roeck @ 2019-04-24 17:58 UTC (permalink / raw)
To: David S . Miller; +Cc: linux-usb, netdev, linux-kernel, Guenter Roeck
All Apple products use the same protocol for tethering over USB.
To simplify the code and make it future proof, use
USB_VENDOR_AND_INTERFACE_INFO() instead of
USB_DEVICE_AND_INTERFACE_INFO() to automatically detect and support
all existing and future Apple products using the same interface.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Tested with various iPads and iPhones up to X. iPhone 6 and later
up to and including X all use product ID 0x12a8, so this patch is
not strictly required, but it does simplify the code.
drivers/net/usb/ipheth.c | 58 +++---------------------------------------------
1 file changed, 3 insertions(+), 55 deletions(-)
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index 3d8a70d3ea9b..a01a71a7e48d 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -54,17 +54,6 @@
#include <linux/workqueue.h>
#define USB_VENDOR_APPLE 0x05ac
-#define USB_PRODUCT_IPHONE 0x1290
-#define USB_PRODUCT_IPHONE_3G 0x1292
-#define USB_PRODUCT_IPHONE_3GS 0x1294
-#define USB_PRODUCT_IPHONE_4 0x1297
-#define USB_PRODUCT_IPAD 0x129a
-#define USB_PRODUCT_IPAD_2 0x12a2
-#define USB_PRODUCT_IPAD_3 0x12a6
-#define USB_PRODUCT_IPAD_MINI 0x12ab
-#define USB_PRODUCT_IPHONE_4_VZW 0x129c
-#define USB_PRODUCT_IPHONE_4S 0x12a0
-#define USB_PRODUCT_IPHONE_5 0x12a8
#define IPHETH_USBINTF_CLASS 255
#define IPHETH_USBINTF_SUBCLASS 253
@@ -88,50 +77,9 @@
#define IPHETH_CARRIER_ON 0x04
static const struct usb_device_id ipheth_table[] = {
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPAD,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
- { USB_DEVICE_AND_INTERFACE_INFO(
- USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
- IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
- IPHETH_USBINTF_PROTO) },
+ { USB_VENDOR_AND_INTERFACE_INFO(USB_VENDOR_APPLE, IPHETH_USBINTF_CLASS,
+ IPHETH_USBINTF_SUBCLASS,
+ IPHETH_USBINTF_PROTO) },
{ }
};
MODULE_DEVICE_TABLE(usb, ipheth_table);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] usbnet: ipheth: Simplify device detection
2019-04-24 17:58 [PATCH] usbnet: ipheth: Simplify device detection Guenter Roeck
@ 2019-04-26 11:27 ` Simon Horman
2019-04-26 12:13 ` Guenter Roeck
2019-04-26 15:34 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2019-04-26 11:27 UTC (permalink / raw)
To: Guenter Roeck; +Cc: David S . Miller, linux-usb, netdev, linux-kernel
On Wed, Apr 24, 2019 at 10:58:24AM -0700, Guenter Roeck wrote:
> All Apple products use the same protocol for tethering over USB.
> To simplify the code and make it future proof, use
> USB_VENDOR_AND_INTERFACE_INFO() instead of
> USB_DEVICE_AND_INTERFACE_INFO() to automatically detect and support
> all existing and future Apple products using the same interface.
What if future Apple products behave differently?
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Tested with various iPads and iPhones up to X. iPhone 6 and later
> up to and including X all use product ID 0x12a8, so this patch is
> not strictly required, but it does simplify the code.
>
> drivers/net/usb/ipheth.c | 58 +++---------------------------------------------
> 1 file changed, 3 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
> index 3d8a70d3ea9b..a01a71a7e48d 100644
> --- a/drivers/net/usb/ipheth.c
> +++ b/drivers/net/usb/ipheth.c
> @@ -54,17 +54,6 @@
> #include <linux/workqueue.h>
>
> #define USB_VENDOR_APPLE 0x05ac
> -#define USB_PRODUCT_IPHONE 0x1290
> -#define USB_PRODUCT_IPHONE_3G 0x1292
> -#define USB_PRODUCT_IPHONE_3GS 0x1294
> -#define USB_PRODUCT_IPHONE_4 0x1297
> -#define USB_PRODUCT_IPAD 0x129a
> -#define USB_PRODUCT_IPAD_2 0x12a2
> -#define USB_PRODUCT_IPAD_3 0x12a6
> -#define USB_PRODUCT_IPAD_MINI 0x12ab
> -#define USB_PRODUCT_IPHONE_4_VZW 0x129c
> -#define USB_PRODUCT_IPHONE_4S 0x12a0
> -#define USB_PRODUCT_IPHONE_5 0x12a8
>
> #define IPHETH_USBINTF_CLASS 255
> #define IPHETH_USBINTF_SUBCLASS 253
> @@ -88,50 +77,9 @@
> #define IPHETH_CARRIER_ON 0x04
>
> static const struct usb_device_id ipheth_table[] = {
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> - { USB_DEVICE_AND_INTERFACE_INFO(
> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
> - IPHETH_USBINTF_PROTO) },
> + { USB_VENDOR_AND_INTERFACE_INFO(USB_VENDOR_APPLE, IPHETH_USBINTF_CLASS,
> + IPHETH_USBINTF_SUBCLASS,
> + IPHETH_USBINTF_PROTO) },
> { }
> };
> MODULE_DEVICE_TABLE(usb, ipheth_table);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usbnet: ipheth: Simplify device detection
2019-04-26 11:27 ` Simon Horman
@ 2019-04-26 12:13 ` Guenter Roeck
2019-04-26 12:59 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2019-04-26 12:13 UTC (permalink / raw)
To: Simon Horman; +Cc: David S . Miller, linux-usb, netdev, linux-kernel
On 4/26/19 4:27 AM, Simon Horman wrote:
> On Wed, Apr 24, 2019 at 10:58:24AM -0700, Guenter Roeck wrote:
>> All Apple products use the same protocol for tethering over USB.
>> To simplify the code and make it future proof, use
>> USB_VENDOR_AND_INTERFACE_INFO() instead of
>> USB_DEVICE_AND_INTERFACE_INFO() to automatically detect and support
>> all existing and future Apple products using the same interface.
>
> What if future Apple products behave differently?
>
Sure, Apple may decide to use the same device/class/subclass/protocol
identifier for a different protocol. That is unlikely but possible.
If the associated risk is considered higher than the benefit of supporting
new devices announcing the same protocol with a different product id,
please feel free to ignore (or nack) this patch.
Thanks,
Guenter
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> Tested with various iPads and iPhones up to X. iPhone 6 and later
>> up to and including X all use product ID 0x12a8, so this patch is
>> not strictly required, but it does simplify the code.
>>
>> drivers/net/usb/ipheth.c | 58 +++---------------------------------------------
>> 1 file changed, 3 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
>> index 3d8a70d3ea9b..a01a71a7e48d 100644
>> --- a/drivers/net/usb/ipheth.c
>> +++ b/drivers/net/usb/ipheth.c
>> @@ -54,17 +54,6 @@
>> #include <linux/workqueue.h>
>>
>> #define USB_VENDOR_APPLE 0x05ac
>> -#define USB_PRODUCT_IPHONE 0x1290
>> -#define USB_PRODUCT_IPHONE_3G 0x1292
>> -#define USB_PRODUCT_IPHONE_3GS 0x1294
>> -#define USB_PRODUCT_IPHONE_4 0x1297
>> -#define USB_PRODUCT_IPAD 0x129a
>> -#define USB_PRODUCT_IPAD_2 0x12a2
>> -#define USB_PRODUCT_IPAD_3 0x12a6
>> -#define USB_PRODUCT_IPAD_MINI 0x12ab
>> -#define USB_PRODUCT_IPHONE_4_VZW 0x129c
>> -#define USB_PRODUCT_IPHONE_4S 0x12a0
>> -#define USB_PRODUCT_IPHONE_5 0x12a8
>>
>> #define IPHETH_USBINTF_CLASS 255
>> #define IPHETH_USBINTF_SUBCLASS 253
>> @@ -88,50 +77,9 @@
>> #define IPHETH_CARRIER_ON 0x04
>>
>> static const struct usb_device_id ipheth_table[] = {
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> - { USB_DEVICE_AND_INTERFACE_INFO(
>> - USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
>> - IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
>> - IPHETH_USBINTF_PROTO) },
>> + { USB_VENDOR_AND_INTERFACE_INFO(USB_VENDOR_APPLE, IPHETH_USBINTF_CLASS,
>> + IPHETH_USBINTF_SUBCLASS,
>> + IPHETH_USBINTF_PROTO) },
>> { }
>> };
>> MODULE_DEVICE_TABLE(usb, ipheth_table);
>> --
>> 2.7.4
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usbnet: ipheth: Simplify device detection
2019-04-26 12:13 ` Guenter Roeck
@ 2019-04-26 12:59 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2019-04-26 12:59 UTC (permalink / raw)
To: Guenter Roeck; +Cc: David S . Miller, linux-usb, netdev, linux-kernel
On Fri, Apr 26, 2019 at 05:13:17AM -0700, Guenter Roeck wrote:
> On 4/26/19 4:27 AM, Simon Horman wrote:
> > On Wed, Apr 24, 2019 at 10:58:24AM -0700, Guenter Roeck wrote:
> > > All Apple products use the same protocol for tethering over USB.
> > > To simplify the code and make it future proof, use
> > > USB_VENDOR_AND_INTERFACE_INFO() instead of
> > > USB_DEVICE_AND_INTERFACE_INFO() to automatically detect and support
> > > all existing and future Apple products using the same interface.
> >
> > What if future Apple products behave differently?
> >
>
> Sure, Apple may decide to use the same device/class/subclass/protocol
> identifier for a different protocol. That is unlikely but possible.
>
> If the associated risk is considered higher than the benefit of supporting
> new devices announcing the same protocol with a different product id,
> please feel free to ignore (or nack) this patch.
My experience with hardware vendors would lead me to err on the side of
caution. But my experience does not extend to Apple and the benefit you
describe may well be worth the risk in this case.
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usbnet: ipheth: Simplify device detection
2019-04-24 17:58 [PATCH] usbnet: ipheth: Simplify device detection Guenter Roeck
2019-04-26 11:27 ` Simon Horman
@ 2019-04-26 15:34 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2019-04-26 15:34 UTC (permalink / raw)
To: linux; +Cc: linux-usb, netdev, linux-kernel
From: Guenter Roeck <linux@roeck-us.net>
Date: Wed, 24 Apr 2019 10:58:24 -0700
> All Apple products use the same protocol for tethering over USB.
> To simplify the code and make it future proof, use
> USB_VENDOR_AND_INTERFACE_INFO() instead of
> USB_DEVICE_AND_INTERFACE_INFO() to automatically detect and support
> all existing and future Apple products using the same interface.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-26 15:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 17:58 [PATCH] usbnet: ipheth: Simplify device detection Guenter Roeck
2019-04-26 11:27 ` Simon Horman
2019-04-26 12:13 ` Guenter Roeck
2019-04-26 12:59 ` Simon Horman
2019-04-26 15:34 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).