aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/speedtch.c
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2006-01-13 04:52:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-31 20:23:40 -0500
commit6f7494759870ec6fbb066f7202c5585fe36fbe82 (patch)
tree1fcff14ece062fefba2712b55ab4bddd05866425 /drivers/usb/atm/speedtch.c
parent227d77611b31df5d9afa572b984f73640f54d490 (diff)
[PATCH] USBATM: measure buffer size in bytes; force valid sizes
Change the module parameters rcv_buf_size and snd_buf_size to specify buffer sizes in bytes rather than ATM cells. Since there is some danger that users may not notice this change, the parameters are renamed to rcv_buf_bytes etc. The transmit buffer needs to be a multiple of the ATM cell size in length, while the receive buffer should be a multiple of the endpoint maxpacket size (this wasn't enforced before, which causes trouble with isochronous transfers), so enforce these restrictions. Now that the usbatm probe method inspects the endpoint maxpacket size, minidriver bind routines need to set the correct alternate setting for the interface in their bind routine. This is the reason for the speedtch changes. Signed-off-by: Duncan Sands <baldrick@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/atm/speedtch.c')
-rw-r--r--drivers/usb/atm/speedtch.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 43ec758b92b5..0e981672f149 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -89,6 +89,7 @@ MODULE_PARM_DESC(sw_buffering,
89 "Enable software buffering (default: " 89 "Enable software buffering (default: "
90 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); 90 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
91 91
92#define INTERFACE_DATA 1
92#define ENDPOINT_INT 0x81 93#define ENDPOINT_INT 0x81
93#define ENDPOINT_DATA 0x07 94#define ENDPOINT_DATA 0x07
94#define ENDPOINT_FIRMWARE 0x05 95#define ENDPOINT_FIRMWARE 0x05
@@ -98,6 +99,8 @@ MODULE_PARM_DESC(sw_buffering,
98struct speedtch_instance_data { 99struct speedtch_instance_data {
99 struct usbatm_data *usbatm; 100 struct usbatm_data *usbatm;
100 101
102 unsigned int altsetting;
103
101 struct work_struct status_checker; 104 struct work_struct status_checker;
102 105
103 unsigned char last_status; 106 unsigned char last_status;
@@ -270,6 +273,11 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
270 because we're in our own kernel thread anyway. */ 273 because we're in our own kernel thread anyway. */
271 msleep_interruptible(1000); 274 msleep_interruptible(1000);
272 275
276 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
277 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret);
278 goto out_free;
279 }
280
273 /* Enable software buffering, if requested */ 281 /* Enable software buffering, if requested */
274 if (sw_buffering) 282 if (sw_buffering)
275 speedtch_set_swbuff(instance, 1); 283 speedtch_set_swbuff(instance, 1);
@@ -586,11 +594,6 @@ static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_de
586 594
587 atm_dbg(usbatm, "%s entered\n", __func__); 595 atm_dbg(usbatm, "%s entered\n", __func__);
588 596
589 if ((ret = usb_set_interface(usb_dev, 1, altsetting)) < 0) {
590 atm_dbg(usbatm, "%s: usb_set_interface returned %d!\n", __func__, ret);
591 return ret;
592 }
593
594 /* Set MAC address, it is stored in the serial number */ 597 /* Set MAC address, it is stored in the serial number */
595 memset(atm_dev->esi, 0, sizeof(atm_dev->esi)); 598 memset(atm_dev->esi, 0, sizeof(atm_dev->esi));
596 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) { 599 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) {
@@ -725,6 +728,23 @@ static int speedtch_bind(struct usbatm_data *usbatm,
725 728
726 instance->usbatm = usbatm; 729 instance->usbatm = usbatm;
727 730
731 /* altsetting may change at any moment, so take a snapshot */
732 instance->altsetting = altsetting;
733
734 if (instance->altsetting)
735 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
736 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret);
737 instance->altsetting = 0; /* fall back to default */
738 }
739
740 if (!instance->altsetting) {
741 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ALTSETTING)) < 0) {
742 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ALTSETTING, ret);
743 goto fail_free;
744 }
745 instance->altsetting = DEFAULT_ALTSETTING;
746 }
747
728 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 748 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance);
729 749
730 instance->status_checker.timer.function = speedtch_status_poll; 750 instance->status_checker.timer.function = speedtch_status_poll;