aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/speedtch.c
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2006-01-17 05:15:13 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-31 20:23:39 -0500
commit0ec3c7e856319b600311750d784262caa8ed94b9 (patch)
tree86d0b3aa9105a8b92bbfc514c5964c9abe7da0e7 /drivers/usb/atm/speedtch.c
parent7ce08c93e388922e25a96a7d9895784182e4c72c (diff)
[PATCH] USBATM: trivial modifications
Formatting, changes to variable names, comments, log level changes, printk rate limiting. 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.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index c1b47d74e206..211d467311e2 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -205,7 +205,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
205 buffer, 0x200, &actual_length, 2000); 205 buffer, 0x200, &actual_length, 2000);
206 206
207 if (ret < 0 && ret != -ETIMEDOUT) 207 if (ret < 0 && ret != -ETIMEDOUT)
208 usb_dbg(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); 208 usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret);
209 else 209 else
210 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret); 210 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret);
211 } 211 }
@@ -219,7 +219,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
219 buffer, thislen, &actual_length, DATA_TIMEOUT); 219 buffer, thislen, &actual_length, DATA_TIMEOUT);
220 220
221 if (ret < 0) { 221 if (ret < 0) {
222 usb_dbg(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); 222 usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret);
223 goto out_free; 223 goto out_free;
224 } 224 }
225 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); 225 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size);
@@ -232,7 +232,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
232 buffer, 0x200, &actual_length, DATA_TIMEOUT); 232 buffer, 0x200, &actual_length, DATA_TIMEOUT);
233 233
234 if (ret < 0) { 234 if (ret < 0) {
235 usb_dbg(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); 235 usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret);
236 goto out_free; 236 goto out_free;
237 } 237 }
238 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length); 238 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length);
@@ -246,7 +246,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
246 buffer, thislen, &actual_length, DATA_TIMEOUT); 246 buffer, thislen, &actual_length, DATA_TIMEOUT);
247 247
248 if (ret < 0) { 248 if (ret < 0) {
249 usb_dbg(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); 249 usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret);
250 goto out_free; 250 goto out_free;
251 } 251 }
252 } 252 }
@@ -259,7 +259,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
259 buffer, 0x200, &actual_length, DATA_TIMEOUT); 259 buffer, 0x200, &actual_length, DATA_TIMEOUT);
260 260
261 if (ret < 0) { 261 if (ret < 0) {
262 usb_dbg(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); 262 usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret);
263 goto out_free; 263 goto out_free;
264 } 264 }
265 265
@@ -285,8 +285,8 @@ out:
285 return ret; 285 return ret;
286} 286}
287 287
288static int speedtch_find_firmware(struct usb_interface *intf, int phase, 288static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf,
289 const struct firmware **fw_p) 289 int phase, const struct firmware **fw_p)
290{ 290{
291 struct device *dev = &intf->dev; 291 struct device *dev = &intf->dev;
292 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); 292 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice);
@@ -295,24 +295,24 @@ static int speedtch_find_firmware(struct usb_interface *intf, int phase,
295 char buf[24]; 295 char buf[24];
296 296
297 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); 297 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
298 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 298 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
299 299
300 if (request_firmware(fw_p, buf, dev)) { 300 if (request_firmware(fw_p, buf, dev)) {
301 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); 301 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
302 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 302 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
303 303
304 if (request_firmware(fw_p, buf, dev)) { 304 if (request_firmware(fw_p, buf, dev)) {
305 sprintf(buf, "speedtch-%d.bin", phase); 305 sprintf(buf, "speedtch-%d.bin", phase);
306 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 306 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
307 307
308 if (request_firmware(fw_p, buf, dev)) { 308 if (request_firmware(fw_p, buf, dev)) {
309 dev_warn(dev, "no stage %d firmware found!\n", phase); 309 usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
310 return -ENOENT; 310 return -ENOENT;
311 } 311 }
312 } 312 }
313 } 313 }
314 314
315 dev_info(dev, "found stage %d firmware %s\n", phase, buf); 315 usb_info(usbatm, "found stage %d firmware %s\n", phase, buf);
316 316
317 return 0; 317 return 0;
318} 318}
@@ -323,15 +323,16 @@ static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface
323 struct speedtch_instance_data *instance = usbatm->driver_data; 323 struct speedtch_instance_data *instance = usbatm->driver_data;
324 int ret; 324 int ret;
325 325
326 if ((ret = speedtch_find_firmware(intf, 1, &fw1)) < 0) 326 if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0)
327 return ret; 327 return ret;
328 328
329 if ((ret = speedtch_find_firmware(intf, 2, &fw2)) < 0) { 329 if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) {
330 release_firmware(fw1); 330 release_firmware(fw1);
331 return ret; 331 return ret;
332 } 332 }
333 333
334 ret = speedtch_upload_firmware(instance, fw1, fw2); 334 if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0)
335 usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret);
335 336
336 release_firmware(fw2); 337 release_firmware(fw2);
337 release_firmware(fw1); 338 release_firmware(fw1);
@@ -428,7 +429,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
428 int down_speed, up_speed, ret; 429 int down_speed, up_speed, ret;
429 unsigned char status; 430 unsigned char status;
430 431
432#ifdef VERBOSE_DEBUG
431 atm_dbg(usbatm, "%s entered\n", __func__); 433 atm_dbg(usbatm, "%s entered\n", __func__);
434#endif
432 435
433 ret = speedtch_read_status(instance); 436 ret = speedtch_read_status(instance);
434 if (ret < 0) { 437 if (ret < 0) {
@@ -441,9 +444,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
441 444
442 status = buf[OFFSET_7]; 445 status = buf[OFFSET_7];
443 446
444 atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
445
446 if ((status != instance->last_status) || !status) { 447 if ((status != instance->last_status) || !status) {
448 atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status);
449
447 switch (status) { 450 switch (status) {
448 case 0: 451 case 0:
449 atm_dev->signal = ATM_PHY_SIG_LOST; 452 atm_dev->signal = ATM_PHY_SIG_LOST;
@@ -484,7 +487,7 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
484 487
485 default: 488 default:
486 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 489 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
487 atm_info(usbatm, "Unknown line state %02x\n", status); 490 atm_info(usbatm, "unknown line state %02x\n", status);
488 break; 491 break;
489 } 492 }
490 493
@@ -690,8 +693,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
690 693
691 usb_dbg(usbatm, "%s entered\n", __func__); 694 usb_dbg(usbatm, "%s entered\n", __func__);
692 695
696 /* sanity checks */
697
693 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { 698 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) {
694 usb_dbg(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); 699 usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass);
695 return -ENODEV; 700 return -ENODEV;
696 } 701 }
697 702
@@ -704,7 +709,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
704 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm); 709 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm);
705 710
706 if (ret < 0) { 711 if (ret < 0) {
707 usb_dbg(usbatm, "%s: failed to claim interface %d (%d)\n", __func__, i, ret); 712 usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret);
708 speedtch_release_interfaces(usb_dev, i); 713 speedtch_release_interfaces(usb_dev, i);
709 return ret; 714 return ret;
710 } 715 }
@@ -714,7 +719,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
714 instance = kmalloc(sizeof(*instance), GFP_KERNEL); 719 instance = kmalloc(sizeof(*instance), GFP_KERNEL);
715 720
716 if (!instance) { 721 if (!instance) {
717 usb_dbg(usbatm, "%s: no memory for instance data!\n", __func__); 722 usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
718 ret = -ENOMEM; 723 ret = -ENOMEM;
719 goto fail_release; 724 goto fail_release;
720 } 725 }
@@ -754,8 +759,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
754 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already"); 759 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already");
755 760
756 if (*need_heavy_init) 761 if (*need_heavy_init)
757 if ((ret = usb_reset_device(usb_dev)) < 0) 762 if ((ret = usb_reset_device(usb_dev)) < 0) {
763 usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
758 goto fail_free; 764 goto fail_free;
765 }
759 766
760 usbatm->driver_data = instance; 767 usbatm->driver_data = instance;
761 768