[patch] usb-serial, ti_usb: fix usb configuration changing

Oleg Verych <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Palacky University in Olomouc, experimental physics department.
Message-ID <[email protected]>
usb-serial, ti_usb: fix usb configuration changing

 Remove bogus error messages, comments with script.
 Use new usb-configuration interface for usb-interface drivers.

Cc: Al Borchers <[email protected]>
Signed-off-by: Oleg Verych
---
  Magic numbers and some commnets were removed.
  Return status is honored.

  Maybe this one worth being in 2.6.21?

> I tried this on 3410 and 5052 with and without firmware--worked
> great.
> 
> Please
> 
> 1) Change return value to 1, rather than 0xO1E and 0xA1B.
>    (Clever, but it will just confuse readers.)
> 
> 2) Drop (void) cast on usb_driver_set_configuration.
> 
> 3) Resend the patch with a signed-off line.
> 
> Thanks for doing this--so glad we can get rid of the hotplug
> script!
> 
> -- Al

 drivers/usb/serial/ti_usb_3410_5052.c |   68 +++++-----------------------------
 1 file changed, 11 insertions(+), 57 deletions(-)

Index: linux-2.6.21-rc5/drivers/usb/serial/ti_usb_3410_5052.c
===================================================================
--- linux-2.6.21-rc5.orig/drivers/usb/serial/ti_usb_3410_5052.c	2007-03-27 08:00:26.338095634 +0200
+++ linux-2.6.21-rc5/drivers/usb/serial/ti_usb_3410_5052.c	2007-03-27 08:09:36.803596727 +0200
@@ -1,4 +1,3 @@
-/* vi: ts=8 sw=8
- *
+/*
  * TI 3410/5052 USB Serial Driver
  *
@@ -17,54 +16,4 @@
  * technical support, or Al Borchers <[email protected]>, or
  * Peter Berger <[email protected]>.
- * 
- * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052
- * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device
- * configuration.
- *
- * #!/bin/bash
- *
- * BOOT_CONFIG=1
- * ACTIVE_CONFIG=2
- *
- * if [[ "$ACTION" != "add" ]]
- * then
- * 	exit
- * fi
- *
- * CONFIG_PATH=/sys${DEVPATH%/?*}/bConfigurationValue
- *
- * if [[ 0`cat $CONFIG_PATH` -ne $BOOT_CONFIG ]]
- * then
- * 	exit
- * fi
- *
- * PRODUCT=${PRODUCT%/?*}		# delete version
- * VENDOR_ID=`printf "%d" 0x${PRODUCT%/?*}`
- * PRODUCT_ID=`printf "%d" 0x${PRODUCT#*?/}`
- *
- * PARAM_PATH=/sys/module/ti_usb_3410_5052/parameters
- *
- * function scan() {
- * 	s=$1
- * 	shift
- * 	for i
- * 	do
- * 		if [[ $s -eq $i ]]
- * 		then
- * 			return 0
- * 		fi
- * 	done
- * 	return 1
- * }
- *
- * IFS=$IFS,
- *
- * if (scan $VENDOR_ID 1105 `cat $PARAM_PATH/vendor_3410` &&
- * scan $PRODUCT_ID 13328 `cat $PARAM_PATH/product_3410`) ||
- * (scan $VENDOR_ID 1105 `cat $PARAM_PATH/vendor_5052` &&
- * scan $PRODUCT_ID 20562 20818 20570 20575 `cat $PARAM_PATH/product_5052`)
- * then
- * 	echo $ACTIVE_CONFIG > $CONFIG_PATH
- * fi
  */
 
@@ -452,11 +401,16 @@ static int ti_startup(struct usb_serial 
 		}
 
-		status = -ENODEV;
+		status = 1; /* positive status -- device to be reconfigured */
 		goto free_tdev;
-	} 
+	}
 
-	/* the second configuration must be set (in sysfs by hotplug script) */
+	/* active configuration must be set */
 	if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) {
-		status = -ENODEV;
+		dev_info(&dev->dev, "setting configuration #%u (activating)\n",
+			 TI_ACTIVE_CONFIG);
+
+		status = usb_driver_set_configuration(dev, TI_ACTIVE_CONFIG);
+		status = status ? status: 1;
+
 		goto free_tdev;
 	}
@@ -488,5 +442,5 @@ static int ti_startup(struct usb_serial 
 		tport->tp_uart_mode = 0;	/* default is RS232 */
 	}
-	
+
 	return 0;
 
____

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.