2011-02-05 19:04:30

by Maciej Szmigiero

[permalink] [raw]
Subject: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

[USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

Samsung decided to reuse USB ID of its old CDMA phone SGH-I500 for the
modem part of some of their Android phones. At least Galaxy Spica
is affected.

This modem needs ACM driver and does not work with visor driver which
binds the conflicting ID for SGH-I500.
Because SGH-I500 is pretty an old hardware its best to add switch to visor
driver in cause somebody still wants to use that phone with Linux.

Note that this is needed only when using the Android phone as modem,
not in USB storage or ADB mode.

Signed-off-by: Maciej Szmigiero <[email protected]>

diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 15a5d89..5e56ab3 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -52,6 +52,7 @@ static int palm_os_4_probe(struct usb_serial *serial,

/* Parameters that may be passed into the module. */
static int debug;
+static int enable_i500;
static __u16 vendor;
static __u16 product;

@@ -479,6 +480,10 @@ static int visor_probe(struct usb_serial *serial,

dbg("%s", __func__);

+ if ((!enable_i500) && (id->idVendor == SAMSUNG_VENDOR_ID) &&
+ (id->idProduct == SAMSUNG_SPH_I500_ID))
+ return -ENODEV;
+
if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
serial->dev->actconfig->desc.bConfigurationValue);
@@ -718,6 +723,11 @@ MODULE_LICENSE("GPL");
module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");

+module_param(enable_i500, bool, S_IRUGO);
+MODULE_PARM_DESC(enable_i500, "Enable support for Samsung SPH-I500. "
+ "Causes USBID conflict with modem in Samsung "
+ "Android phones");
+
module_param(vendor, ushort, 0);
MODULE_PARM_DESC(vendor, "User specified vendor ID");
module_param(product, ushort, 0);


2011-02-05 19:28:35

by Greg KH

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

On Sat, Feb 05, 2011 at 08:04:23PM +0100, Maciej Szmigiero wrote:
> [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver
>
> Samsung decided to reuse USB ID of its old CDMA phone SGH-I500 for the
> modem part of some of their Android phones. At least Galaxy Spica
> is affected.

Ick, no way, that's horrible.

> This modem needs ACM driver and does not work with visor driver which
> binds the conflicting ID for SGH-I500.
> Because SGH-I500 is pretty an old hardware its best to add switch to visor
> driver in cause somebody still wants to use that phone with Linux.
>
> Note that this is needed only when using the Android phone as modem,
> not in USB storage or ADB mode.

If the phone switches to modem mode, does it show up as a ACM class
device?

>
> Signed-off-by: Maciej Szmigiero <[email protected]>
>
> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
> index 15a5d89..5e56ab3 100644
> --- a/drivers/usb/serial/visor.c
> +++ b/drivers/usb/serial/visor.c
> @@ -52,6 +52,7 @@ static int palm_os_4_probe(struct usb_serial *serial,
>
> /* Parameters that may be passed into the module. */
> static int debug;
> +static int enable_i500;
> static __u16 vendor;
> static __u16 product;
>
> @@ -479,6 +480,10 @@ static int visor_probe(struct usb_serial *serial,
>
> dbg("%s", __func__);
>
> + if ((!enable_i500) && (id->idVendor == SAMSUNG_VENDOR_ID) &&
> + (id->idProduct == SAMSUNG_SPH_I500_ID))
> + return -ENODEV;
> +
> if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
> dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
> serial->dev->actconfig->desc.bConfigurationValue);
> @@ -718,6 +723,11 @@ MODULE_LICENSE("GPL");
> module_param(debug, bool, S_IRUGO | S_IWUSR);
> MODULE_PARM_DESC(debug, "Debug enabled or not");
>
> +module_param(enable_i500, bool, S_IRUGO);
> +MODULE_PARM_DESC(enable_i500, "Enable support for Samsung SPH-I500. "
> + "Causes USBID conflict with modem in Samsung "
> + "Android phones");
> +

Is there any way to dynamically detect this? We don't want it to be a
module parameter, as we will never know to set it.

Surely the configuration of the device looks different somehow? If it
reports itself as an ACM device, we should be able to detect that,
right?

thanks,

greg k-h

2011-02-05 19:40:33

by Maciej Szmigiero

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

W dniu 05.02.2011 20:28, Greg KH pisze:
> Surely the configuration of the device looks different somehow? If it
> reports itself as an ACM device, we should be able to detect that,
> right?
>
> thanks,
>
> greg k-h

I will try to look at it, but the modem likes to reset itself (and the bus)
when poked (for example when trying to read configuration strings).

Best regards,
Maciej Szmigiero

2011-02-05 21:41:35

by Maciej Szmigiero

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

New version of patch which autodetects devices with ACM class.
Tested on Galaxy Spica.

Signed-off-by: Maciej Szmigiero <[email protected]>

diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 15a5d89..e1c4527 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -27,6 +27,7 @@
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
#include "visor.h"

/*
@@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,

dbg("%s", __func__);

+ /* some Samsung Android phones in modem mode have the same ID */
+ /* as SPH-I500, but they are ACM devices, so dont bind to them */
+ if ((id->idVendor == SAMSUNG_VENDOR_ID) &&
+ (id->idProduct == SAMSUNG_SPH_I500_ID) &&
+ (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM) &&
+ (serial->dev->descriptor.bDeviceSubClass ==
+ USB_CDC_SUBCLASS_ACM))
+ return -ENODEV;
+
if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
serial->dev->actconfig->desc.bConfigurationValue);

2011-02-05 23:30:41

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

Hello.

On 06.02.2011 0:41, Maciej Szmigiero wrote:

> New version of patch which autodetects devices with ACM class.
> Tested on Galaxy Spica.

> Signed-off-by: Maciej Szmigiero <[email protected]>

> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
> index 15a5d89..e1c4527 100644
> --- a/drivers/usb/serial/visor.c
> +++ b/drivers/usb/serial/visor.c
[...]
> @@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
>
> dbg("%s", __func__);
>
> + /* some Samsung Android phones in modem mode have the same ID */
> + /* as SPH-I500, but they are ACM devices, so dont bind to them */

The preferred style for the multi-line comments is this:

/*
* bla
* bla
*/

> + if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
> + (id->idProduct == SAMSUNG_SPH_I500_ID)&&
> + (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
> + (serial->dev->descriptor.bDeviceSubClass ==
> + USB_CDC_SUBCLASS_ACM))

Parens around == not necessary...

WBR, Sergei

2011-02-06 20:04:26

by Maciej Szmigiero

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

W dniu 06.02.2011 00:29, Sergei Shtylyov pisze:
> Hello.
>
> On 06.02.2011 0:41, Maciej Szmigiero wrote:
>
>> New version of patch which autodetects devices with ACM class.
>> Tested on Galaxy Spica.
>
>> Signed-off-by: Maciej Szmigiero <[email protected]>
>
>> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
>> index 15a5d89..e1c4527 100644
>> --- a/drivers/usb/serial/visor.c
>> +++ b/drivers/usb/serial/visor.c
> [...]
>> @@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
>>
>> dbg("%s", __func__);
>>
>> + /* some Samsung Android phones in modem mode have the same ID */
>> + /* as SPH-I500, but they are ACM devices, so dont bind to them */
>
> The preferred style for the multi-line comments is this:
>
> /*
> * bla
> * bla
> */
>
>> + if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
>> + (id->idProduct == SAMSUNG_SPH_I500_ID)&&
>> + (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
>> + (serial->dev->descriptor.bDeviceSubClass ==
>> + USB_CDC_SUBCLASS_ACM))
>
> Parens around == not necessary...
>
> WBR, Sergei

Thanks for comments, new version of this patch with style fixes follows.

Best regards,
Maciej Szmigiero

Signed-off-by: Maciej Szmigiero <[email protected]>

diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 15a5d89..0f75948 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -27,6 +27,7 @@
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
#include "visor.h"

/*
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,

dbg("%s", __func__);

+ /*
+ * some Samsung Android phones in modem mode have the same ID
+ * as SPH-I500, but they are ACM devices, so dont bind to them
+ */
+ if (id->idVendor == SAMSUNG_VENDOR_ID &&
+ id->idProduct == SAMSUNG_SPH_I500_ID &&
+ serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM &&
+ serial->dev->descriptor.bDeviceSubClass ==
+ USB_CDC_SUBCLASS_ACM)
+ return -ENODEV;
+
if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
serial->dev->actconfig->desc.bConfigurationValue);

2011-02-07 11:26:26

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

Hello.

On 06-02-2011 23:04, Maciej Szmigiero wrote:

>>> New version of patch which autodetects devices with ACM class.
>>> Tested on Galaxy Spica.

>>> Signed-off-by: Maciej Szmigiero<[email protected]>

>>> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
>>> index 15a5d89..e1c4527 100644
>>> --- a/drivers/usb/serial/visor.c
>>> +++ b/drivers/usb/serial/visor.c
>> [...]
>>> @@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
>>>
>>> dbg("%s", __func__);
>>>
>>> + /* some Samsung Android phones in modem mode have the same ID */
>>> + /* as SPH-I500, but they are ACM devices, so dont bind to them */

>> The preferred style for the multi-line comments is this:

>> /*
>> * bla
>> * bla
>> */

>>> + if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
>>> + (id->idProduct == SAMSUNG_SPH_I500_ID)&&
>>> + (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
>>> + (serial->dev->descriptor.bDeviceSubClass ==
>>> + USB_CDC_SUBCLASS_ACM))
>>
>> Parens around == not necessary...

>> WBR, Sergei

> Thanks for comments, new version of this patch with style fixes follows.

> Best regards,
> Maciej Szmigiero

> Signed-off-by: Maciej Szmigiero<[email protected]>

> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
> index 15a5d89..0f75948 100644
> --- a/drivers/usb/serial/visor.c
> +++ b/drivers/usb/serial/visor.c
[...]
> @@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
>
> dbg("%s", __func__);
>
> + /*
> + * some Samsung Android phones in modem mode have the same ID
> + * as SPH-I500, but they are ACM devices, so dont bind to them
> + */

Space is missing. You were close. :-)

WBR, Sergei

2011-02-07 11:42:44

by Maciej Szmigiero

[permalink] [raw]
Subject: Re: [USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

W dniu 07.02.2011 12:25, Sergei Shtylyov pisze:
> Hello.
>
> On 06-02-2011 23:04, Maciej Szmigiero wrote:
>
>>>> New version of patch which autodetects devices with ACM class.
>>>> Tested on Galaxy Spica.
>
>
>> diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
>> index 15a5d89..0f75948 100644
>> --- a/drivers/usb/serial/visor.c
>> +++ b/drivers/usb/serial/visor.c
> [...]
>> @@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
>>
>> dbg("%s", __func__);
>>
>> + /*
>> + * some Samsung Android phones in modem mode have the same ID
>> + * as SPH-I500, but they are ACM devices, so dont bind to them
>> + */
>
> Space is missing. You were close. :-)
>
> WBR, Sergei
>

Damn :)

Signed-off-by: Maciej Szmigiero<[email protected]>

diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 15a5d89..1c11959 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -27,6 +27,7 @@
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
#include "visor.h"

/*
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,

dbg("%s", __func__);

+ /*
+ * some Samsung Android phones in modem mode have the same ID
+ * as SPH-I500, but they are ACM devices, so dont bind to them
+ */
+ if (id->idVendor == SAMSUNG_VENDOR_ID &&
+ id->idProduct == SAMSUNG_SPH_I500_ID &&
+ serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM &&
+ serial->dev->descriptor.bDeviceSubClass ==
+ USB_CDC_SUBCLASS_ACM)
+ return -ENODEV;
+
if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
serial->dev->actconfig->desc.bConfigurationValue);