Re: [PATCH] USB: serial: option: reimplement interface masking

2018-03-12 Thread Johan Hovold
On Wed, Mar 07, 2018 at 11:54:47AM -0800, Greg Kroah-Hartman wrote:
> On Wed, Mar 07, 2018 at 05:40:48PM +0100, Johan Hovold wrote:
> > Reimplement interface masking using device flags stored directly in the
> > device-id table. This will make it easier to add and maintain device-id
> > entries by using a more compact and readable notation compared to the
> > current implementation (which manages pairs of masks in separate
> > blacklist structs).
> > 
> > Two convenience macros are used to flag an interface as either reserved
> > or as not supporting modem-control requests:
> > 
> > { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
> >   .driver_info = NCTRL(0) | RSVD(3) },
> > 
> > For now, we limit the highest maskable interface number to seven, which
> > allows for (up to 16) additional device flags to be added later should
> > need arise.
> > 
> > Note that this will likely need to be backported to stable in order to
> > make future device-id backports more manageable.
> > 
> > Signed-off-by: Johan Hovold 
> 
> Reviewed-by: Greg Kroah-Hartman 

Thanks for the review. Now applied for -next.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: serial: option: reimplement interface masking

2018-03-07 Thread Greg Kroah-Hartman
On Wed, Mar 07, 2018 at 05:40:48PM +0100, Johan Hovold wrote:
> Reimplement interface masking using device flags stored directly in the
> device-id table. This will make it easier to add and maintain device-id
> entries by using a more compact and readable notation compared to the
> current implementation (which manages pairs of masks in separate
> blacklist structs).
> 
> Two convenience macros are used to flag an interface as either reserved
> or as not supporting modem-control requests:
> 
>   { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
> .driver_info = NCTRL(0) | RSVD(3) },
> 
> For now, we limit the highest maskable interface number to seven, which
> allows for (up to 16) additional device flags to be added later should
> need arise.
> 
> Note that this will likely need to be backported to stable in order to
> make future device-id backports more manageable.
> 
> Signed-off-by: Johan Hovold 

Reviewed-by: Greg Kroah-Hartman 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: serial: option: reimplement interface masking

2018-03-07 Thread Johan Hovold
Reimplement interface masking using device flags stored directly in the
device-id table. This will make it easier to add and maintain device-id
entries by using a more compact and readable notation compared to the
current implementation (which manages pairs of masks in separate
blacklist structs).

Two convenience macros are used to flag an interface as either reserved
or as not supporting modem-control requests:

{ USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
  .driver_info = NCTRL(0) | RSVD(3) },

For now, we limit the highest maskable interface number to seven, which
allows for (up to 16) additional device flags to be added later should
need arise.

Note that this will likely need to be backported to stable in order to
make future device-id backports more manageable.

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/option.c | 446 +++-
 1 file changed, 152 insertions(+), 294 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 2d8d9150da0c..b331baec3a0b 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -548,151 +548,15 @@ static void option_instat_callback(struct urb *urb);
 #define WETELECOM_PRODUCT_6802 0x6802
 #define WETELECOM_PRODUCT_WMD300   0x6803
 
-struct option_blacklist_info {
-   /* bitmask of interface numbers blacklisted for send_setup */
-   const unsigned long sendsetup;
-   /* bitmask of interface numbers that are reserved */
-   const unsigned long reserved;
-};
 
-static const struct option_blacklist_info four_g_w14_blacklist = {
-   .sendsetup = BIT(0) | BIT(1),
-};
+/* Device flags */
 
-static const struct option_blacklist_info four_g_w100_blacklist = {
-   .sendsetup = BIT(1) | BIT(2),
-   .reserved = BIT(3),
-};
+/* Interface does not support modem-control requests */
+#define NCTRL(ifnum)   ((BIT(ifnum) & 0xff) << 8)
 
-static const struct option_blacklist_info alcatel_x200_blacklist = {
-   .sendsetup = BIT(0) | BIT(1),
-   .reserved = BIT(4),
-};
+/* Interface is reserved */
+#define RSVD(ifnum)((BIT(ifnum) & 0xff) << 0)
 
-static const struct option_blacklist_info zte_0037_blacklist = {
-   .sendsetup = BIT(0) | BIT(1),
-};
-
-static const struct option_blacklist_info zte_k3765_z_blacklist = {
-   .sendsetup = BIT(0) | BIT(1) | BIT(2),
-   .reserved = BIT(4),
-};
-
-static const struct option_blacklist_info zte_ad3812_z_blacklist = {
-   .sendsetup = BIT(0) | BIT(1) | BIT(2),
-};
-
-static const struct option_blacklist_info zte_mc2718_z_blacklist = {
-   .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
-};
-
-static const struct option_blacklist_info zte_mc2716_z_blacklist = {
-   .sendsetup = BIT(1) | BIT(2) | BIT(3),
-};
-
-static const struct option_blacklist_info zte_me3620_mbim_blacklist = {
-   .reserved = BIT(2) | BIT(3) | BIT(4),
-};
-
-static const struct option_blacklist_info zte_me3620_xl_blacklist = {
-   .reserved = BIT(3) | BIT(4) | BIT(5),
-};
-
-static const struct option_blacklist_info zte_zm8620_x_blacklist = {
-   .reserved = BIT(3) | BIT(4) | BIT(5),
-};
-
-static const struct option_blacklist_info huawei_cdc12_blacklist = {
-   .reserved = BIT(1) | BIT(2),
-};
-
-static const struct option_blacklist_info net_intf0_blacklist = {
-   .reserved = BIT(0),
-};
-
-static const struct option_blacklist_info net_intf1_blacklist = {
-   .reserved = BIT(1),
-};
-
-static const struct option_blacklist_info net_intf2_blacklist = {
-   .reserved = BIT(2),
-};
-
-static const struct option_blacklist_info net_intf3_blacklist = {
-   .reserved = BIT(3),
-};
-
-static const struct option_blacklist_info net_intf4_blacklist = {
-   .reserved = BIT(4),
-};
-
-static const struct option_blacklist_info net_intf5_blacklist = {
-   .reserved = BIT(5),
-};
-
-static const struct option_blacklist_info net_intf6_blacklist = {
-   .reserved = BIT(6),
-};
-
-static const struct option_blacklist_info zte_mf626_blacklist = {
-   .sendsetup = BIT(0) | BIT(1),
-   .reserved = BIT(4),
-};
-
-static const struct option_blacklist_info zte_1255_blacklist = {
-   .reserved = BIT(3) | BIT(4),
-};
-
-static const struct option_blacklist_info simcom_sim7100e_blacklist = {
-   .reserved = BIT(5) | BIT(6),
-};
-
-static const struct option_blacklist_info telit_me910_blacklist = {
-   .sendsetup = BIT(0),
-   .reserved = BIT(1) | BIT(3),
-};
-
-static const struct option_blacklist_info telit_me910_dual_modem_blacklist = {
-   .sendsetup = BIT(0),
-   .reserved = BIT(3),
-};
-
-static const struct option_blacklist_info telit_le910_blacklist = {
-   .sendsetup = BIT(0),
-   .reserved = BIT(1) | BIT(2),
-};
-
-static const struct option_blacklist_info telit_le920_blacklist = {
-   .sendsetup = BIT(0),
-   .reserved = BIT(1) | BIT(5),
-};
-
-static const struct