| 1 |
// SPDX-License-Identifier: GPL-2.0+ |
| 2 |
/****************************************************************************** |
| 3 |
* speedtch.c - Alcatel SpeedTouch USB xDSL modem driver |
| 4 |
* |
| 5 |
* Copyright (C) 2001, Alcatel |
| 6 |
* Copyright (C) 2003, Duncan Sands |
| 7 |
* Copyright (C) 2004, David Woodhouse |
| 8 |
* |
| 9 |
* Based on "modem_run.c", copyright (C) 2001, Benoit Papillault |
| 10 |
******************************************************************************/ |
| 11 |
|
| 12 |
#include <asm/page.h> |
| 13 |
#include <linux/device.h> |
| 14 |
#include <linux/errno.h> |
| 15 |
#include <linux/firmware.h> |
| 16 |
#include <linux/hex.h> |
| 17 |
#include <linux/kernel.h> |
| 18 |
#include <linux/module.h> |
| 19 |
#include <linux/moduleparam.h> |
| 20 |
#include <linux/slab.h> |
| 21 |
#include <linux/stat.h> |
| 22 |
#include <linux/timer.h> |
| 23 |
#include <linux/types.h> |
| 24 |
#include <linux/usb/ch9.h> |
| 25 |
#include <linux/workqueue.h> |
| 26 |
|
| 27 |
#include "usbatm.h" |
| 28 |
|
| 29 |
#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands <[email protected]>" |
| 30 |
#define DRIVER_DESC "Alcatel SpeedTouch USB driver" |
| 31 |
|
| 32 |
static const char speedtch_driver_name[] = "speedtch"; |
| 33 |
|
| 34 |
#define CTRL_TIMEOUT 2000 /* milliseconds */ |
| 35 |
#define DATA_TIMEOUT 2000 /* milliseconds */ |
| 36 |
|
| 37 |
#define OFFSET_7 0 /* size 1 */ |
| 38 |
#define OFFSET_b 1 /* size 8 */ |
| 39 |
#define OFFSET_d 9 /* size 4 */ |
| 40 |
#define OFFSET_e 13 /* size 1 */ |
| 41 |
#define OFFSET_f 14 /* size 1 */ |
| 42 |
|
| 43 |
#define SIZE_7 1 |
| 44 |
#define SIZE_b 8 |
| 45 |
#define SIZE_d 4 |
| 46 |
#define SIZE_e 1 |
| 47 |
#define SIZE_f 1 |
| 48 |
|
| 49 |
#define MIN_POLL_DELAY 5000 /* milliseconds */ |
| 50 |
#define MAX_POLL_DELAY 60000 /* milliseconds */ |
| 51 |
|
| 52 |
#define RESUBMIT_DELAY 1000 /* milliseconds */ |
| 53 |
|
| 54 |
#define DEFAULT_BULK_ALTSETTING 1 |
| 55 |
#define DEFAULT_ISOC_ALTSETTING 3 |
| 56 |
#define DEFAULT_DL_512_FIRST 0 |
| 57 |
#define DEFAULT_ENABLE_ISOC 0 |
| 58 |
#define DEFAULT_SW_BUFFERING 0 |
| 59 |
|
| 60 |
static unsigned int altsetting = 0; /* zero means: use the default */ |
| 61 |
static bool dl_512_first = DEFAULT_DL_512_FIRST; |
| 62 |
static bool enable_isoc = DEFAULT_ENABLE_ISOC; |
| 63 |
static bool sw_buffering = DEFAULT_SW_BUFFERING; |
| 64 |
|
| 65 |
#define DEFAULT_B_MAX_DSL 8128 |
| 66 |
#define DEFAULT_MODEM_MODE 11 |
| 67 |
#define MODEM_OPTION_LENGTH 16 |
| 68 |
static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = { |
| 69 |
0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 70 |
}; |
| 71 |
|
| 72 |
static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL; |
| 73 |
static unsigned char ModemMode = DEFAULT_MODEM_MODE; |
| 74 |
static unsigned char ModemOption[MODEM_OPTION_LENGTH]; |
| 75 |
static unsigned int num_ModemOption; |
| 76 |
|
| 77 |
module_param(altsetting, uint, S_IRUGO | S_IWUSR); |
| 78 |
MODULE_PARM_DESC(altsetting, |
| 79 |
"Alternative setting for data interface (bulk_default: " |
| 80 |
__MODULE_STRING(DEFAULT_BULK_ALTSETTING) "; isoc_default: " |
| 81 |
__MODULE_STRING(DEFAULT_ISOC_ALTSETTING) ")"); |
| 82 |
|
| 83 |
module_param(dl_512_first, bool, S_IRUGO | S_IWUSR); |
| 84 |
MODULE_PARM_DESC(dl_512_first, |
| 85 |
"Read 512 bytes before sending firmware (default: " |
| 86 |
__MODULE_STRING(DEFAULT_DL_512_FIRST) ")"); |
| 87 |
|
| 88 |
module_param(enable_isoc, bool, S_IRUGO | S_IWUSR); |
| 89 |
MODULE_PARM_DESC(enable_isoc, |
| 90 |
"Use isochronous transfers if available (default: " |
| 91 |
__MODULE_STRING(DEFAULT_ENABLE_ISOC) ")"); |
| 92 |
|
| 93 |
module_param(sw_buffering, bool, S_IRUGO | S_IWUSR); |
| 94 |
MODULE_PARM_DESC(sw_buffering, |
| 95 |
"Enable software buffering (default: " |
| 96 |
__MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); |
| 97 |
|
| 98 |
module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR); |
| 99 |
MODULE_PARM_DESC(BMaxDSL, |
| 100 |
"default: " __MODULE_STRING(DEFAULT_B_MAX_DSL)); |
| 101 |
|
| 102 |
module_param(ModemMode, byte, S_IRUGO | S_IWUSR); |
| 103 |
MODULE_PARM_DESC(ModemMode, |
| 104 |
"default: " __MODULE_STRING(DEFAULT_MODEM_MODE)); |
| 105 |
|
| 106 |
module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO); |
| 107 |
MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20"); |
| 108 |
|
| 109 |
#define INTERFACE_DATA 1 |
| 110 |
#define ENDPOINT_INT 0x81 |
| 111 |
#define ENDPOINT_BULK_DATA 0x07 |
| 112 |
#define ENDPOINT_ISOC_DATA 0x07 |
| 113 |
#define ENDPOINT_FIRMWARE 0x05 |
| 114 |
|
| 115 |
struct speedtch_params { |
| 116 |
unsigned int altsetting; |
| 117 |
unsigned int BMaxDSL; |
| 118 |
unsigned char ModemMode; |
| 119 |
unsigned char ModemOption[MODEM_OPTION_LENGTH]; |
| 120 |
}; |
| 121 |
|
| 122 |
struct speedtch_instance_data { |
| 123 |
struct usbatm_data *usbatm; |
| 124 |
|
| 125 |
struct speedtch_params params; /* set in probe, constant afterwards */ |
| 126 |
|
| 127 |
struct timer_list status_check_timer; |
| 128 |
struct work_struct status_check_work; |
| 129 |
|
| 130 |
unsigned char last_status; |
| 131 |
|
| 132 |
int poll_delay; /* milliseconds */ |
| 133 |
|
| 134 |
struct timer_list resubmit_timer; |
| 135 |
struct urb *int_urb; |
| 136 |
unsigned char int_data[16]; |
| 137 |
|
| 138 |
unsigned char scratch_buffer[16]; |
| 139 |
}; |
| 140 |
|
| 141 |
/*************** |
| 142 |
** firmware ** |
| 143 |
***************/ |
| 144 |
|
| 145 |
static void speedtch_set_swbuff(struct speedtch_instance_data *instance, int state) |
| 146 |
{ |
| 147 |
struct usbatm_data *usbatm = instance->usbatm; |
| 148 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 149 |
int ret; |
| 150 |
|
| 151 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 152 |
0x32, 0x40, state ? 0x01 : 0x00, 0x00, NULL, 0, CTRL_TIMEOUT); |
| 153 |
if (ret < 0) |
| 154 |
usb_warn(usbatm, |
| 155 |
"%sabling SW buffering: usb_control_msg returned %d\n", |
| 156 |
state ? "En" : "Dis", ret); |
| 157 |
else |
| 158 |
usb_dbg(usbatm, "speedtch_set_swbuff: %sbled SW buffering\n", state ? "En" : "Dis"); |
| 159 |
} |
| 160 |
|
| 161 |
static void speedtch_test_sequence(struct speedtch_instance_data *instance) |
| 162 |
{ |
| 163 |
struct usbatm_data *usbatm = instance->usbatm; |
| 164 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 165 |
unsigned char *buf = instance->scratch_buffer; |
| 166 |
int ret; |
| 167 |
|
| 168 |
/* URB 147 */ |
| 169 |
buf[0] = 0x1c; |
| 170 |
buf[1] = 0x50; |
| 171 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 172 |
0x01, 0x40, 0x0b, 0x00, buf, 2, CTRL_TIMEOUT); |
| 173 |
if (ret < 0) |
| 174 |
usb_warn(usbatm, "%s failed on URB147: %d\n", __func__, ret); |
| 175 |
|
| 176 |
/* URB 148 */ |
| 177 |
buf[0] = 0x32; |
| 178 |
buf[1] = 0x00; |
| 179 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 180 |
0x01, 0x40, 0x02, 0x00, buf, 2, CTRL_TIMEOUT); |
| 181 |
if (ret < 0) |
| 182 |
usb_warn(usbatm, "%s failed on URB148: %d\n", __func__, ret); |
| 183 |
|
| 184 |
/* URB 149 */ |
| 185 |
buf[0] = 0x01; |
| 186 |
buf[1] = 0x00; |
| 187 |
buf[2] = 0x01; |
| 188 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 189 |
0x01, 0x40, 0x03, 0x00, buf, 3, CTRL_TIMEOUT); |
| 190 |
if (ret < 0) |
| 191 |
usb_warn(usbatm, "%s failed on URB149: %d\n", __func__, ret); |
| 192 |
|
| 193 |
/* URB 150 */ |
| 194 |
buf[0] = 0x01; |
| 195 |
buf[1] = 0x00; |
| 196 |
buf[2] = 0x01; |
| 197 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 198 |
0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT); |
| 199 |
if (ret < 0) |
| 200 |
usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret); |
| 201 |
|
| 202 |
/* Extra initialisation in recent drivers - gives higher speeds */ |
| 203 |
|
| 204 |
/* URBext1 */ |
| 205 |
buf[0] = instance->params.ModemMode; |
| 206 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 207 |
0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT); |
| 208 |
if (ret < 0) |
| 209 |
usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret); |
| 210 |
|
| 211 |
/* URBext2 */ |
| 212 |
/* This seems to be the one which actually triggers the higher sync |
| 213 |
rate -- it does require the new firmware too, although it works OK |
| 214 |
with older firmware */ |
| 215 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 216 |
0x01, 0x40, 0x14, 0x00, |
| 217 |
instance->params.ModemOption, |
| 218 |
MODEM_OPTION_LENGTH, CTRL_TIMEOUT); |
| 219 |
if (ret < 0) |
| 220 |
usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret); |
| 221 |
|
| 222 |
/* URBext3 */ |
| 223 |
buf[0] = instance->params.BMaxDSL & 0xff; |
| 224 |
buf[1] = instance->params.BMaxDSL >> 8; |
| 225 |
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), |
| 226 |
0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT); |
| 227 |
if (ret < 0) |
| 228 |
usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret); |
| 229 |
} |
| 230 |
|
| 231 |
static int speedtch_upload_firmware(struct speedtch_instance_data *instance, |
| 232 |
const struct firmware *fw1, |
| 233 |
const struct firmware *fw2) |
| 234 |
{ |
| 235 |
unsigned char *buffer; |
| 236 |
struct usbatm_data *usbatm = instance->usbatm; |
| 237 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 238 |
int actual_length; |
| 239 |
int ret = 0; |
| 240 |
int offset; |
| 241 |
|
| 242 |
usb_dbg(usbatm, "%s entered\n", __func__); |
| 243 |
|
| 244 |
buffer = (unsigned char *)__get_free_page(GFP_KERNEL); |
| 245 |
if (!buffer) { |
| 246 |
ret = -ENOMEM; |
| 247 |
usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__); |
| 248 |
goto out; |
| 249 |
} |
| 250 |
|
| 251 |
if (!usb_ifnum_to_if(usb_dev, 2)) { |
| 252 |
ret = -ENODEV; |
| 253 |
usb_dbg(usbatm, "%s: interface not found!\n", __func__); |
| 254 |
goto out_free; |
| 255 |
} |
| 256 |
|
| 257 |
/* URB 7 */ |
| 258 |
if (dl_512_first) { /* some modems need a read before writing the firmware */ |
| 259 |
ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE), |
| 260 |
buffer, 0x200, &actual_length, 2000); |
| 261 |
|
| 262 |
if (ret < 0 && ret != -ETIMEDOUT) |
| 263 |
usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); |
| 264 |
else |
| 265 |
usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret); |
| 266 |
} |
| 267 |
|
| 268 |
/* URB 8 : both leds are static green */ |
| 269 |
for (offset = 0; offset < fw1->size; offset += PAGE_SIZE) { |
| 270 |
int thislen = min_t(int, PAGE_SIZE, fw1->size - offset); |
| 271 |
memcpy(buffer, fw1->data + offset, thislen); |
| 272 |
|
| 273 |
ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, ENDPOINT_FIRMWARE), |
| 274 |
buffer, thislen, &actual_length, DATA_TIMEOUT); |
| 275 |
|
| 276 |
if (ret < 0) { |
| 277 |
usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); |
| 278 |
goto out_free; |
| 279 |
} |
| 280 |
usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); |
| 281 |
} |
| 282 |
|
| 283 |
/* USB led blinking green, ADSL led off */ |
| 284 |
|
| 285 |
/* URB 11 */ |
| 286 |
ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE), |
| 287 |
buffer, 0x200, &actual_length, DATA_TIMEOUT); |
| 288 |
|
| 289 |
if (ret < 0) { |
| 290 |
usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); |
| 291 |
goto out_free; |
| 292 |
} |
| 293 |
usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length); |
| 294 |
|
| 295 |
/* URBs 12 to 139 - USB led blinking green, ADSL led off */ |
| 296 |
for (offset = 0; offset < fw2->size; offset += PAGE_SIZE) { |
| 297 |
int thislen = min_t(int, PAGE_SIZE, fw2->size - offset); |
| 298 |
memcpy(buffer, fw2->data + offset, thislen); |
| 299 |
|
| 300 |
ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, ENDPOINT_FIRMWARE), |
| 301 |
buffer, thislen, &actual_length, DATA_TIMEOUT); |
| 302 |
|
| 303 |
if (ret < 0) { |
| 304 |
usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); |
| 305 |
goto out_free; |
| 306 |
} |
| 307 |
} |
| 308 |
usb_dbg(usbatm, "%s: BLOCK3 uploaded (%zu bytes)\n", __func__, fw2->size); |
| 309 |
|
| 310 |
/* USB led static green, ADSL led static red */ |
| 311 |
|
| 312 |
/* URB 142 */ |
| 313 |
ret = usb_bulk_msg(usb_dev, usb_rcvbulkpipe(usb_dev, ENDPOINT_FIRMWARE), |
| 314 |
buffer, 0x200, &actual_length, DATA_TIMEOUT); |
| 315 |
|
| 316 |
if (ret < 0) { |
| 317 |
usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); |
| 318 |
goto out_free; |
| 319 |
} |
| 320 |
|
| 321 |
/* success */ |
| 322 |
usb_dbg(usbatm, "%s: BLOCK4 downloaded (%d bytes)\n", __func__, actual_length); |
| 323 |
|
| 324 |
/* Delay to allow firmware to start up. We can do this here |
| 325 |
because we're in our own kernel thread anyway. */ |
| 326 |
msleep_interruptible(1000); |
| 327 |
|
| 328 |
if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) { |
| 329 |
usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret); |
| 330 |
goto out_free; |
| 331 |
} |
| 332 |
|
| 333 |
/* Enable software buffering, if requested */ |
| 334 |
if (sw_buffering) |
| 335 |
speedtch_set_swbuff(instance, 1); |
| 336 |
|
| 337 |
/* Magic spell; don't ask us what this does */ |
| 338 |
speedtch_test_sequence(instance); |
| 339 |
|
| 340 |
ret = 0; |
| 341 |
|
| 342 |
out_free: |
| 343 |
free_page((unsigned long)buffer); |
| 344 |
out: |
| 345 |
return ret; |
| 346 |
} |
| 347 |
|
| 348 |
static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf, |
| 349 |
int phase, const struct firmware **fw_p) |
| 350 |
{ |
| 351 |
struct device *dev = &intf->dev; |
| 352 |
const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); |
| 353 |
const u8 major_revision = bcdDevice >> 8; |
| 354 |
const u8 minor_revision = bcdDevice & 0xff; |
| 355 |
char buf[24]; |
| 356 |
|
| 357 |
sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); |
| 358 |
usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf); |
| 359 |
|
| 360 |
if (request_firmware(fw_p, buf, dev)) { |
| 361 |
sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); |
| 362 |
usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf); |
| 363 |
|
| 364 |
if (request_firmware(fw_p, buf, dev)) { |
| 365 |
sprintf(buf, "speedtch-%d.bin", phase); |
| 366 |
usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf); |
| 367 |
|
| 368 |
if (request_firmware(fw_p, buf, dev)) { |
| 369 |
usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase); |
| 370 |
return -ENOENT; |
| 371 |
} |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
usb_info(usbatm, "found stage %d firmware %s\n", phase, buf); |
| 376 |
|
| 377 |
return 0; |
| 378 |
} |
| 379 |
|
| 380 |
static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface *intf) |
| 381 |
{ |
| 382 |
const struct firmware *fw1, *fw2; |
| 383 |
struct speedtch_instance_data *instance = usbatm->driver_data; |
| 384 |
int ret; |
| 385 |
|
| 386 |
if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0) |
| 387 |
return ret; |
| 388 |
|
| 389 |
if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) { |
| 390 |
release_firmware(fw1); |
| 391 |
return ret; |
| 392 |
} |
| 393 |
|
| 394 |
if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0) |
| 395 |
usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret); |
| 396 |
|
| 397 |
release_firmware(fw2); |
| 398 |
release_firmware(fw1); |
| 399 |
|
| 400 |
return ret; |
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
/********** |
| 405 |
** ATM ** |
| 406 |
**********/ |
| 407 |
|
| 408 |
static int speedtch_read_status(struct speedtch_instance_data *instance) |
| 409 |
{ |
| 410 |
struct usbatm_data *usbatm = instance->usbatm; |
| 411 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 412 |
unsigned char *buf = instance->scratch_buffer; |
| 413 |
int ret; |
| 414 |
|
| 415 |
memset(buf, 0, 16); |
| 416 |
|
| 417 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 418 |
0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7, |
| 419 |
CTRL_TIMEOUT); |
| 420 |
if (ret < 0) { |
| 421 |
atm_dbg(usbatm, "%s: MSG 7 failed\n", __func__); |
| 422 |
return ret; |
| 423 |
} |
| 424 |
|
| 425 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 426 |
0x12, 0xc0, 0x0b, 0x00, buf + OFFSET_b, SIZE_b, |
| 427 |
CTRL_TIMEOUT); |
| 428 |
if (ret < 0) { |
| 429 |
atm_dbg(usbatm, "%s: MSG B failed\n", __func__); |
| 430 |
return ret; |
| 431 |
} |
| 432 |
|
| 433 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 434 |
0x12, 0xc0, 0x0d, 0x00, buf + OFFSET_d, SIZE_d, |
| 435 |
CTRL_TIMEOUT); |
| 436 |
if (ret < 0) { |
| 437 |
atm_dbg(usbatm, "%s: MSG D failed\n", __func__); |
| 438 |
return ret; |
| 439 |
} |
| 440 |
|
| 441 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 442 |
0x01, 0xc0, 0x0e, 0x00, buf + OFFSET_e, SIZE_e, |
| 443 |
CTRL_TIMEOUT); |
| 444 |
if (ret < 0) { |
| 445 |
atm_dbg(usbatm, "%s: MSG E failed\n", __func__); |
| 446 |
return ret; |
| 447 |
} |
| 448 |
|
| 449 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 450 |
0x01, 0xc0, 0x0f, 0x00, buf + OFFSET_f, SIZE_f, |
| 451 |
CTRL_TIMEOUT); |
| 452 |
if (ret < 0) { |
| 453 |
atm_dbg(usbatm, "%s: MSG F failed\n", __func__); |
| 454 |
return ret; |
| 455 |
} |
| 456 |
|
| 457 |
return 0; |
| 458 |
} |
| 459 |
|
| 460 |
static int speedtch_start_synchro(struct speedtch_instance_data *instance) |
| 461 |
{ |
| 462 |
struct usbatm_data *usbatm = instance->usbatm; |
| 463 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 464 |
unsigned char *buf = instance->scratch_buffer; |
| 465 |
int ret; |
| 466 |
|
| 467 |
atm_dbg(usbatm, "%s entered\n", __func__); |
| 468 |
|
| 469 |
memset(buf, 0, 2); |
| 470 |
|
| 471 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 472 |
0x12, 0xc0, 0x04, 0x00, |
| 473 |
buf, 2, CTRL_TIMEOUT); |
| 474 |
|
| 475 |
if (ret < 0) |
| 476 |
atm_warn(usbatm, "failed to start ADSL synchronisation: %d\n", ret); |
| 477 |
else |
| 478 |
atm_dbg(usbatm, "%s: modem prodded. %d bytes returned: %02x %02x\n", |
| 479 |
__func__, ret, buf[0], buf[1]); |
| 480 |
|
| 481 |
return ret; |
| 482 |
} |
| 483 |
|
| 484 |
static void speedtch_check_status(struct work_struct *work) |
| 485 |
{ |
| 486 |
struct speedtch_instance_data *instance = |
| 487 |
container_of(work, struct speedtch_instance_data, |
| 488 |
status_check_work); |
| 489 |
struct usbatm_data *usbatm = instance->usbatm; |
| 490 |
struct atm_dev *atm_dev = usbatm->atm_dev; |
| 491 |
unsigned char *buf = instance->scratch_buffer; |
| 492 |
int down_speed, up_speed, ret; |
| 493 |
unsigned char status; |
| 494 |
|
| 495 |
#ifdef VERBOSE_DEBUG |
| 496 |
atm_dbg(usbatm, "%s entered\n", __func__); |
| 497 |
#endif |
| 498 |
|
| 499 |
ret = speedtch_read_status(instance); |
| 500 |
if (ret < 0) { |
| 501 |
atm_warn(usbatm, "error %d fetching device status\n", ret); |
| 502 |
instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY); |
| 503 |
return; |
| 504 |
} |
| 505 |
|
| 506 |
instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY); |
| 507 |
|
| 508 |
status = buf[OFFSET_7]; |
| 509 |
|
| 510 |
if ((status != instance->last_status) || !status) { |
| 511 |
atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status); |
| 512 |
|
| 513 |
switch (status) { |
| 514 |
case 0: |
| 515 |
atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST); |
| 516 |
if (instance->last_status) |
| 517 |
atm_info(usbatm, "ADSL line is down\n"); |
| 518 |
/* It may never resync again unless we ask it to... */ |
| 519 |
ret = speedtch_start_synchro(instance); |
| 520 |
break; |
| 521 |
|
| 522 |
case 0x08: |
| 523 |
atm_dev_signal_change(atm_dev, ATM_PHY_SIG_UNKNOWN); |
| 524 |
atm_info(usbatm, "ADSL line is blocked?\n"); |
| 525 |
break; |
| 526 |
|
| 527 |
case 0x10: |
| 528 |
atm_dev_signal_change(atm_dev, ATM_PHY_SIG_LOST); |
| 529 |
atm_info(usbatm, "ADSL line is synchronising\n"); |
| 530 |
break; |
| 531 |
|
| 532 |
case 0x20: |
| 533 |
down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8) |
| 534 |
| (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24); |
| 535 |
up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8) |
| 536 |
| (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24); |
| 537 |
|
| 538 |
if (!(down_speed & 0x0000ffff) && !(up_speed & 0x0000ffff)) { |
| 539 |
down_speed >>= 16; |
| 540 |
up_speed >>= 16; |
| 541 |
} |
| 542 |
|
| 543 |
atm_dev->link_rate = down_speed * 1000 / 424; |
| 544 |
atm_dev_signal_change(atm_dev, ATM_PHY_SIG_FOUND); |
| 545 |
|
| 546 |
atm_info(usbatm, |
| 547 |
"ADSL line is up (%d kb/s down | %d kb/s up)\n", |
| 548 |
down_speed, up_speed); |
| 549 |
break; |
| 550 |
|
| 551 |
default: |
| 552 |
atm_dev_signal_change(atm_dev, ATM_PHY_SIG_UNKNOWN); |
| 553 |
atm_info(usbatm, "unknown line state %02x\n", status); |
| 554 |
break; |
| 555 |
} |
| 556 |
|
| 557 |
instance->last_status = status; |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
static void speedtch_status_poll(struct timer_list *t) |
| 562 |
{ |
| 563 |
struct speedtch_instance_data *instance = timer_container_of(instance, |
| 564 |
t, |
| 565 |
status_check_timer); |
| 566 |
|
| 567 |
schedule_work(&instance->status_check_work); |
| 568 |
|
| 569 |
/* The following check is racy, but the race is harmless */ |
| 570 |
if (instance->poll_delay < MAX_POLL_DELAY) |
| 571 |
mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay)); |
| 572 |
else |
| 573 |
atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); |
| 574 |
} |
| 575 |
|
| 576 |
static void speedtch_resubmit_int(struct timer_list *t) |
| 577 |
{ |
| 578 |
struct speedtch_instance_data *instance = timer_container_of(instance, |
| 579 |
t, |
| 580 |
resubmit_timer); |
| 581 |
struct urb *int_urb = instance->int_urb; |
| 582 |
int ret; |
| 583 |
|
| 584 |
atm_dbg(instance->usbatm, "%s entered\n", __func__); |
| 585 |
|
| 586 |
if (int_urb) { |
| 587 |
ret = usb_submit_urb(int_urb, GFP_ATOMIC); |
| 588 |
if (!ret) |
| 589 |
schedule_work(&instance->status_check_work); |
| 590 |
else { |
| 591 |
atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); |
| 592 |
mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); |
| 593 |
} |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
static void speedtch_handle_int(struct urb *int_urb) |
| 598 |
{ |
| 599 |
struct speedtch_instance_data *instance = int_urb->context; |
| 600 |
struct usbatm_data *usbatm = instance->usbatm; |
| 601 |
unsigned int count = int_urb->actual_length; |
| 602 |
int status = int_urb->status; |
| 603 |
int ret; |
| 604 |
|
| 605 |
/* The magic interrupt for "up state" */ |
| 606 |
static const unsigned char up_int[6] = { 0xa1, 0x00, 0x01, 0x00, 0x00, 0x00 }; |
| 607 |
/* The magic interrupt for "down state" */ |
| 608 |
static const unsigned char down_int[6] = { 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 609 |
|
| 610 |
atm_dbg(usbatm, "%s entered\n", __func__); |
| 611 |
|
| 612 |
if (status < 0) { |
| 613 |
atm_dbg(usbatm, "%s: nonzero urb status %d!\n", __func__, status); |
| 614 |
goto fail; |
| 615 |
} |
| 616 |
|
| 617 |
if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { |
| 618 |
timer_delete(&instance->status_check_timer); |
| 619 |
atm_info(usbatm, "DSL line goes up\n"); |
| 620 |
} else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { |
| 621 |
atm_info(usbatm, "DSL line goes down\n"); |
| 622 |
} else { |
| 623 |
int i; |
| 624 |
|
| 625 |
atm_dbg(usbatm, "%s: unknown interrupt packet of length %d:", __func__, count); |
| 626 |
for (i = 0; i < count; i++) |
| 627 |
printk(" %02x", instance->int_data[i]); |
| 628 |
printk("\n"); |
| 629 |
goto fail; |
| 630 |
} |
| 631 |
|
| 632 |
int_urb = instance->int_urb; |
| 633 |
if (int_urb) { |
| 634 |
ret = usb_submit_urb(int_urb, GFP_ATOMIC); |
| 635 |
schedule_work(&instance->status_check_work); |
| 636 |
if (ret < 0) { |
| 637 |
atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); |
| 638 |
goto fail; |
| 639 |
} |
| 640 |
} |
| 641 |
|
| 642 |
return; |
| 643 |
|
| 644 |
fail: |
| 645 |
int_urb = instance->int_urb; |
| 646 |
if (int_urb) |
| 647 |
mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); |
| 648 |
} |
| 649 |
|
| 650 |
static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_dev) |
| 651 |
{ |
| 652 |
struct usb_device *usb_dev = usbatm->usb_dev; |
| 653 |
struct speedtch_instance_data *instance = usbatm->driver_data; |
| 654 |
int i, ret; |
| 655 |
unsigned char mac_str[13]; |
| 656 |
|
| 657 |
atm_dbg(usbatm, "%s entered\n", __func__); |
| 658 |
|
| 659 |
/* Set MAC address, it is stored in the serial number */ |
| 660 |
memset(atm_dev->esi, 0, sizeof(atm_dev->esi)); |
| 661 |
if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) { |
| 662 |
for (i = 0; i < 6; i++) |
| 663 |
atm_dev->esi[i] = (hex_to_bin(mac_str[i * 2]) << 4) + |
| 664 |
hex_to_bin(mac_str[i * 2 + 1]); |
| 665 |
} |
| 666 |
|
| 667 |
/* Start modem synchronisation */ |
| 668 |
ret = speedtch_start_synchro(instance); |
| 669 |
|
| 670 |
/* Set up interrupt endpoint */ |
| 671 |
if (instance->int_urb) { |
| 672 |
ret = usb_submit_urb(instance->int_urb, GFP_KERNEL); |
| 673 |
if (ret < 0) { |
| 674 |
/* Doesn't matter; we'll poll anyway */ |
| 675 |
atm_dbg(usbatm, "%s: submission of interrupt URB failed (%d)!\n", __func__, ret); |
| 676 |
usb_free_urb(instance->int_urb); |
| 677 |
instance->int_urb = NULL; |
| 678 |
} |
| 679 |
} |
| 680 |
|
| 681 |
/* Start status polling */ |
| 682 |
mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000)); |
| 683 |
|
| 684 |
return 0; |
| 685 |
} |
| 686 |
|
| 687 |
static void speedtch_atm_stop(struct usbatm_data *usbatm, struct atm_dev *atm_dev) |
| 688 |
{ |
| 689 |
struct speedtch_instance_data *instance = usbatm->driver_data; |
| 690 |
struct urb *int_urb = instance->int_urb; |
| 691 |
|
| 692 |
atm_dbg(usbatm, "%s entered\n", __func__); |
| 693 |
|
| 694 |
timer_delete_sync(&instance->status_check_timer); |
| 695 |
|
| 696 |
/* |
| 697 |
* Since resubmit_timer and int_urb can schedule themselves and |
| 698 |
* each other, shutting them down correctly takes some care |
| 699 |
*/ |
| 700 |
instance->int_urb = NULL; /* signal shutdown */ |
| 701 |
mb(); |
| 702 |
usb_kill_urb(int_urb); |
| 703 |
timer_delete_sync(&instance->resubmit_timer); |
| 704 |
/* |
| 705 |
* At this point, speedtch_handle_int and speedtch_resubmit_int |
| 706 |
* can run or be running, but instance->int_urb == NULL means that |
| 707 |
* they will not reschedule |
| 708 |
*/ |
| 709 |
usb_kill_urb(int_urb); |
| 710 |
timer_delete_sync(&instance->resubmit_timer); |
| 711 |
usb_free_urb(int_urb); |
| 712 |
|
| 713 |
flush_work(&instance->status_check_work); |
| 714 |
} |
| 715 |
|
| 716 |
static int speedtch_pre_reset(struct usb_interface *intf) |
| 717 |
{ |
| 718 |
return 0; |
| 719 |
} |
| 720 |
|
| 721 |
static int speedtch_post_reset(struct usb_interface *intf) |
| 722 |
{ |
| 723 |
return 0; |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
/********** |
| 728 |
** USB ** |
| 729 |
**********/ |
| 730 |
|
| 731 |
static const struct usb_device_id speedtch_usb_ids[] = { |
| 732 |
{USB_DEVICE(0x06b9, 0x4061)}, |
| 733 |
{} |
| 734 |
}; |
| 735 |
|
| 736 |
MODULE_DEVICE_TABLE(usb, speedtch_usb_ids); |
| 737 |
|
| 738 |
static int speedtch_usb_probe(struct usb_interface *, const struct usb_device_id *); |
| 739 |
|
| 740 |
static struct usb_driver speedtch_usb_driver = { |
| 741 |
.name = speedtch_driver_name, |
| 742 |
.probe = speedtch_usb_probe, |
| 743 |
.disconnect = usbatm_usb_disconnect, |
| 744 |
.pre_reset = speedtch_pre_reset, |
| 745 |
.post_reset = speedtch_post_reset, |
| 746 |
.id_table = speedtch_usb_ids |
| 747 |
}; |
| 748 |
|
| 749 |
static void speedtch_release_interfaces(struct usb_device *usb_dev, |
| 750 |
int num_interfaces) |
| 751 |
{ |
| 752 |
struct usb_interface *cur_intf; |
| 753 |
int i; |
| 754 |
|
| 755 |
for (i = 0; i < num_interfaces; i++) { |
| 756 |
cur_intf = usb_ifnum_to_if(usb_dev, i); |
| 757 |
if (cur_intf) { |
| 758 |
usb_set_intfdata(cur_intf, NULL); |
| 759 |
usb_driver_release_interface(&speedtch_usb_driver, cur_intf); |
| 760 |
} |
| 761 |
} |
| 762 |
} |
| 763 |
|
| 764 |
static int speedtch_bind(struct usbatm_data *usbatm, |
| 765 |
struct usb_interface *intf, |
| 766 |
const struct usb_device_id *id) |
| 767 |
{ |
| 768 |
struct usb_device *usb_dev = interface_to_usbdev(intf); |
| 769 |
struct usb_interface *cur_intf, *data_intf; |
| 770 |
struct speedtch_instance_data *instance; |
| 771 |
int ifnum = intf->altsetting->desc.bInterfaceNumber; |
| 772 |
int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces; |
| 773 |
int i, ret; |
| 774 |
int use_isoc; |
| 775 |
|
| 776 |
usb_dbg(usbatm, "%s entered\n", __func__); |
| 777 |
|
| 778 |
/* sanity checks */ |
| 779 |
|
| 780 |
if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { |
| 781 |
usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); |
| 782 |
return -ENODEV; |
| 783 |
} |
| 784 |
|
| 785 |
data_intf = usb_ifnum_to_if(usb_dev, INTERFACE_DATA); |
| 786 |
if (!data_intf) { |
| 787 |
usb_err(usbatm, "%s: data interface not found!\n", __func__); |
| 788 |
return -ENODEV; |
| 789 |
} |
| 790 |
|
| 791 |
/* claim all interfaces */ |
| 792 |
|
| 793 |
for (i = 0; i < num_interfaces; i++) { |
| 794 |
cur_intf = usb_ifnum_to_if(usb_dev, i); |
| 795 |
|
| 796 |
if ((i != ifnum) && cur_intf) { |
| 797 |
ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm); |
| 798 |
|
| 799 |
if (ret < 0) { |
| 800 |
usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret); |
| 801 |
speedtch_release_interfaces(usb_dev, i); |
| 802 |
return ret; |
| 803 |
} |
| 804 |
} |
| 805 |
} |
| 806 |
|
| 807 |
instance = kzalloc_obj(*instance); |
| 808 |
|
| 809 |
if (!instance) { |
| 810 |
ret = -ENOMEM; |
| 811 |
goto fail_release; |
| 812 |
} |
| 813 |
|
| 814 |
instance->usbatm = usbatm; |
| 815 |
|
| 816 |
/* module parameters may change at any moment, so take a snapshot */ |
| 817 |
instance->params.altsetting = altsetting; |
| 818 |
instance->params.BMaxDSL = BMaxDSL; |
| 819 |
instance->params.ModemMode = ModemMode; |
| 820 |
memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH); |
| 821 |
memcpy(instance->params.ModemOption, ModemOption, num_ModemOption); |
| 822 |
use_isoc = enable_isoc; |
| 823 |
|
| 824 |
if (instance->params.altsetting) |
| 825 |
if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) { |
| 826 |
usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret); |
| 827 |
instance->params.altsetting = 0; /* fall back to default */ |
| 828 |
} |
| 829 |
|
| 830 |
if (!instance->params.altsetting && use_isoc) |
| 831 |
if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) { |
| 832 |
usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret); |
| 833 |
use_isoc = 0; /* fall back to bulk */ |
| 834 |
} |
| 835 |
|
| 836 |
if (use_isoc) { |
| 837 |
const struct usb_host_interface *desc = data_intf->cur_altsetting; |
| 838 |
const __u8 target_address = USB_DIR_IN | usbatm->driver->isoc_in; |
| 839 |
|
| 840 |
use_isoc = 0; /* fall back to bulk if endpoint not found */ |
| 841 |
|
| 842 |
for (i = 0; i < desc->desc.bNumEndpoints; i++) { |
| 843 |
const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; |
| 844 |
|
| 845 |
if ((endpoint_desc->bEndpointAddress == target_address)) { |
| 846 |
use_isoc = |
| 847 |
usb_endpoint_xfer_isoc(endpoint_desc); |
| 848 |
break; |
| 849 |
} |
| 850 |
} |
| 851 |
|
| 852 |
if (!use_isoc) |
| 853 |
usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); |
| 854 |
} |
| 855 |
|
| 856 |
if (!use_isoc && !instance->params.altsetting) |
| 857 |
if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) { |
| 858 |
usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret); |
| 859 |
goto fail_free; |
| 860 |
} |
| 861 |
|
| 862 |
if (!instance->params.altsetting) |
| 863 |
instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; |
| 864 |
|
| 865 |
usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); |
| 866 |
|
| 867 |
INIT_WORK(&instance->status_check_work, speedtch_check_status); |
| 868 |
timer_setup(&instance->status_check_timer, speedtch_status_poll, 0); |
| 869 |
instance->last_status = 0xff; |
| 870 |
instance->poll_delay = MIN_POLL_DELAY; |
| 871 |
|
| 872 |
timer_setup(&instance->resubmit_timer, speedtch_resubmit_int, 0); |
| 873 |
|
| 874 |
instance->int_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 875 |
|
| 876 |
if (instance->int_urb) |
| 877 |
usb_fill_int_urb(instance->int_urb, usb_dev, |
| 878 |
usb_rcvintpipe(usb_dev, ENDPOINT_INT), |
| 879 |
instance->int_data, sizeof(instance->int_data), |
| 880 |
speedtch_handle_int, instance, 16); |
| 881 |
else |
| 882 |
usb_dbg(usbatm, "%s: no memory for interrupt urb!\n", __func__); |
| 883 |
|
| 884 |
/* check whether the modem already seems to be alive */ |
| 885 |
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), |
| 886 |
0x12, 0xc0, 0x07, 0x00, |
| 887 |
instance->scratch_buffer + OFFSET_7, SIZE_7, 500); |
| 888 |
|
| 889 |
usbatm->flags |= (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0); |
| 890 |
|
| 891 |
usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "already" : "not"); |
| 892 |
|
| 893 |
if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT)) |
| 894 |
if ((ret = usb_reset_device(usb_dev)) < 0) { |
| 895 |
usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret); |
| 896 |
goto fail_free; |
| 897 |
} |
| 898 |
|
| 899 |
usbatm->driver_data = instance; |
| 900 |
|
| 901 |
return 0; |
| 902 |
|
| 903 |
fail_free: |
| 904 |
usb_free_urb(instance->int_urb); |
| 905 |
kfree(instance); |
| 906 |
fail_release: |
| 907 |
speedtch_release_interfaces(usb_dev, num_interfaces); |
| 908 |
return ret; |
| 909 |
} |
| 910 |
|
| 911 |
static void speedtch_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) |
| 912 |
{ |
| 913 |
struct usb_device *usb_dev = interface_to_usbdev(intf); |
| 914 |
struct speedtch_instance_data *instance = usbatm->driver_data; |
| 915 |
|
| 916 |
usb_dbg(usbatm, "%s entered\n", __func__); |
| 917 |
|
| 918 |
speedtch_release_interfaces(usb_dev, usb_dev->actconfig->desc.bNumInterfaces); |
| 919 |
usb_free_urb(instance->int_urb); |
| 920 |
kfree(instance); |
| 921 |
} |
| 922 |
|
| 923 |
|
| 924 |
/*********** |
| 925 |
** init ** |
| 926 |
***********/ |
| 927 |
|
| 928 |
static struct usbatm_driver speedtch_usbatm_driver = { |
| 929 |
.driver_name = speedtch_driver_name, |
| 930 |
.bind = speedtch_bind, |
| 931 |
.heavy_init = speedtch_heavy_init, |
| 932 |
.unbind = speedtch_unbind, |
| 933 |
.atm_start = speedtch_atm_start, |
| 934 |
.atm_stop = speedtch_atm_stop, |
| 935 |
.bulk_in = ENDPOINT_BULK_DATA, |
| 936 |
.bulk_out = ENDPOINT_BULK_DATA, |
| 937 |
.isoc_in = ENDPOINT_ISOC_DATA |
| 938 |
}; |
| 939 |
|
| 940 |
static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 941 |
{ |
| 942 |
return usbatm_usb_probe(intf, id, &speedtch_usbatm_driver); |
| 943 |
} |
| 944 |
|
| 945 |
module_usb_driver(speedtch_usb_driver); |
| 946 |
|
| 947 |
MODULE_AUTHOR(DRIVER_AUTHOR); |
| 948 |
MODULE_DESCRIPTION(DRIVER_DESC); |
| 949 |
MODULE_LICENSE("GPL"); |