diff options
Diffstat (limited to 'drivers/usb/atm/ueagle-atm.c')
-rw-r--r-- | drivers/usb/atm/ueagle-atm.c | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index f5434b1cbb1e..c137c041f7a4 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -68,7 +68,7 @@ | |||
68 | 68 | ||
69 | #include "usbatm.h" | 69 | #include "usbatm.h" |
70 | 70 | ||
71 | #define EAGLEUSBVERSION "ueagle 1.3" | 71 | #define EAGLEUSBVERSION "ueagle 1.4" |
72 | 72 | ||
73 | 73 | ||
74 | /* | 74 | /* |
@@ -80,14 +80,14 @@ | |||
80 | dev_dbg(&(usb_dev)->dev, \ | 80 | dev_dbg(&(usb_dev)->dev, \ |
81 | "[ueagle-atm dbg] %s: " format, \ | 81 | "[ueagle-atm dbg] %s: " format, \ |
82 | __FUNCTION__, ##args); \ | 82 | __FUNCTION__, ##args); \ |
83 | } while (0) | 83 | } while (0) |
84 | 84 | ||
85 | #define uea_vdbg(usb_dev, format, args...) \ | 85 | #define uea_vdbg(usb_dev, format, args...) \ |
86 | do { \ | 86 | do { \ |
87 | if (debug >= 2) \ | 87 | if (debug >= 2) \ |
88 | dev_dbg(&(usb_dev)->dev, \ | 88 | dev_dbg(&(usb_dev)->dev, \ |
89 | "[ueagle-atm vdbg] " format, ##args); \ | 89 | "[ueagle-atm vdbg] " format, ##args); \ |
90 | } while (0) | 90 | } while (0) |
91 | 91 | ||
92 | #define uea_enters(usb_dev) \ | 92 | #define uea_enters(usb_dev) \ |
93 | uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) | 93 | uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) |
@@ -218,8 +218,8 @@ enum { | |||
218 | #define UEA_CHIP_VERSION(x) \ | 218 | #define UEA_CHIP_VERSION(x) \ |
219 | ((x)->driver_info & 0xf) | 219 | ((x)->driver_info & 0xf) |
220 | 220 | ||
221 | #define IS_ISDN(sc) \ | 221 | #define IS_ISDN(usb_dev) \ |
222 | (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) | 222 | (le16_to_cpu((usb_dev)->descriptor.bcdDevice) & 0x80) |
223 | 223 | ||
224 | #define INS_TO_USBDEV(ins) ins->usb_dev | 224 | #define INS_TO_USBDEV(ins) ins->usb_dev |
225 | 225 | ||
@@ -401,9 +401,8 @@ static int uea_send_modem_cmd(struct usb_device *usb, | |||
401 | int ret = -ENOMEM; | 401 | int ret = -ENOMEM; |
402 | u8 *xfer_buff; | 402 | u8 *xfer_buff; |
403 | 403 | ||
404 | xfer_buff = kmalloc(size, GFP_KERNEL); | 404 | xfer_buff = kmemdup(buff, size, GFP_KERNEL); |
405 | if (xfer_buff) { | 405 | if (xfer_buff) { |
406 | memcpy(xfer_buff, buff, size); | ||
407 | ret = usb_control_msg(usb, | 406 | ret = usb_control_msg(usb, |
408 | usb_sndctrlpipe(usb, 0), | 407 | usb_sndctrlpipe(usb, 0), |
409 | LOAD_INTERNAL, | 408 | LOAD_INTERNAL, |
@@ -595,14 +594,12 @@ static int uea_idma_write(struct uea_softc *sc, void *data, u32 size) | |||
595 | u8 *xfer_buff; | 594 | u8 *xfer_buff; |
596 | int bytes_read; | 595 | int bytes_read; |
597 | 596 | ||
598 | xfer_buff = kmalloc(size, GFP_KERNEL); | 597 | xfer_buff = kmemdup(data, size, GFP_KERNEL); |
599 | if (!xfer_buff) { | 598 | if (!xfer_buff) { |
600 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); | 599 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); |
601 | return ret; | 600 | return ret; |
602 | } | 601 | } |
603 | 602 | ||
604 | memcpy(xfer_buff, data, size); | ||
605 | |||
606 | ret = usb_bulk_msg(sc->usb_dev, | 603 | ret = usb_bulk_msg(sc->usb_dev, |
607 | usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), | 604 | usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), |
608 | xfer_buff, size, &bytes_read, BULK_TIMEOUT); | 605 | xfer_buff, size, &bytes_read, BULK_TIMEOUT); |
@@ -625,12 +622,12 @@ static int request_dsp(struct uea_softc *sc) | |||
625 | char *dsp_name; | 622 | char *dsp_name; |
626 | 623 | ||
627 | if (UEA_CHIP_VERSION(sc) == ADI930) { | 624 | if (UEA_CHIP_VERSION(sc) == ADI930) { |
628 | if (IS_ISDN(sc)) | 625 | if (IS_ISDN(sc->usb_dev)) |
629 | dsp_name = FW_DIR "DSP9i.bin"; | 626 | dsp_name = FW_DIR "DSP9i.bin"; |
630 | else | 627 | else |
631 | dsp_name = FW_DIR "DSP9p.bin"; | 628 | dsp_name = FW_DIR "DSP9p.bin"; |
632 | } else { | 629 | } else { |
633 | if (IS_ISDN(sc)) | 630 | if (IS_ISDN(sc->usb_dev)) |
634 | dsp_name = FW_DIR "DSPei.bin"; | 631 | dsp_name = FW_DIR "DSPei.bin"; |
635 | else | 632 | else |
636 | dsp_name = FW_DIR "DSPep.bin"; | 633 | dsp_name = FW_DIR "DSPep.bin"; |
@@ -744,7 +741,7 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc) | |||
744 | 741 | ||
745 | static inline int wait_cmv_ack(struct uea_softc *sc) | 742 | static inline int wait_cmv_ack(struct uea_softc *sc) |
746 | { | 743 | { |
747 | int ret = wait_event_timeout(sc->cmv_ack_wait, | 744 | int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait, |
748 | sc->cmv_ack, ACK_TIMEOUT); | 745 | sc->cmv_ack, ACK_TIMEOUT); |
749 | sc->cmv_ack = 0; | 746 | sc->cmv_ack = 0; |
750 | 747 | ||
@@ -765,12 +762,11 @@ static int uea_request(struct uea_softc *sc, | |||
765 | u8 *xfer_buff; | 762 | u8 *xfer_buff; |
766 | int ret = -ENOMEM; | 763 | int ret = -ENOMEM; |
767 | 764 | ||
768 | xfer_buff = kmalloc(size, GFP_KERNEL); | 765 | xfer_buff = kmemdup(data, size, GFP_KERNEL); |
769 | if (!xfer_buff) { | 766 | if (!xfer_buff) { |
770 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); | 767 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); |
771 | return ret; | 768 | return ret; |
772 | } | 769 | } |
773 | memcpy(xfer_buff, data, size); | ||
774 | 770 | ||
775 | ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), | 771 | ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), |
776 | UCDC_SEND_ENCAPSULATED_COMMAND, | 772 | UCDC_SEND_ENCAPSULATED_COMMAND, |
@@ -885,7 +881,8 @@ static int uea_stat(struct uea_softc *sc) | |||
885 | break; | 881 | break; |
886 | 882 | ||
887 | case 3: /* fail ... */ | 883 | case 3: /* fail ... */ |
888 | uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); | 884 | uea_info(INS_TO_USBDEV(sc), "modem synchronization failed" |
885 | " (may be try other cmv/dsp)\n"); | ||
889 | return -EAGAIN; | 886 | return -EAGAIN; |
890 | 887 | ||
891 | case 4 ... 6: /* test state */ | 888 | case 4 ... 6: /* test state */ |
@@ -913,12 +910,6 @@ static int uea_stat(struct uea_softc *sc) | |||
913 | release_firmware(sc->dsp_firm); | 910 | release_firmware(sc->dsp_firm); |
914 | sc->dsp_firm = NULL; | 911 | sc->dsp_firm = NULL; |
915 | } | 912 | } |
916 | |||
917 | ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid); | ||
918 | if (ret < 0) | ||
919 | return ret; | ||
920 | uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", | ||
921 | sc->stats.phy.firmid); | ||
922 | } | 913 | } |
923 | 914 | ||
924 | /* always update it as atm layer could not be init when we switch to | 915 | /* always update it as atm layer could not be init when we switch to |
@@ -1033,9 +1024,9 @@ static int request_cmvs(struct uea_softc *sc, | |||
1033 | 1024 | ||
1034 | if (cmv_file[sc->modem_index] == NULL) { | 1025 | if (cmv_file[sc->modem_index] == NULL) { |
1035 | if (UEA_CHIP_VERSION(sc) == ADI930) | 1026 | if (UEA_CHIP_VERSION(sc) == ADI930) |
1036 | file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; | 1027 | file = (IS_ISDN(sc->usb_dev)) ? "CMV9i.bin" : "CMV9p.bin"; |
1037 | else | 1028 | else |
1038 | file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; | 1029 | file = (IS_ISDN(sc->usb_dev)) ? "CMVei.bin" : "CMVep.bin"; |
1039 | } else | 1030 | } else |
1040 | file = cmv_file[sc->modem_index]; | 1031 | file = cmv_file[sc->modem_index]; |
1041 | 1032 | ||
@@ -1131,6 +1122,13 @@ static int uea_start_reset(struct uea_softc *sc) | |||
1131 | if (ret < 0) | 1122 | if (ret < 0) |
1132 | return ret; | 1123 | return ret; |
1133 | 1124 | ||
1125 | /* Dump firmware version */ | ||
1126 | ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid); | ||
1127 | if (ret < 0) | ||
1128 | return ret; | ||
1129 | uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", | ||
1130 | sc->stats.phy.firmid); | ||
1131 | |||
1134 | /* get options */ | 1132 | /* get options */ |
1135 | ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); | 1133 | ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); |
1136 | if (ret < 0) | 1134 | if (ret < 0) |
@@ -1147,6 +1145,8 @@ static int uea_start_reset(struct uea_softc *sc) | |||
1147 | /* Enter in R-ACT-REQ */ | 1145 | /* Enter in R-ACT-REQ */ |
1148 | ret = uea_write_cmv(sc, SA_CNTL, 0, 2); | 1146 | ret = uea_write_cmv(sc, SA_CNTL, 0, 2); |
1149 | uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); | 1147 | uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); |
1148 | uea_info(INS_TO_USBDEV(sc), "Modem started, " | ||
1149 | "waiting synchronization\n"); | ||
1150 | out: | 1150 | out: |
1151 | release_firmware(cmvs_fw); | 1151 | release_firmware(cmvs_fw); |
1152 | sc->reset = 0; | 1152 | sc->reset = 0; |
@@ -1172,7 +1172,10 @@ static int uea_kthread(void *data) | |||
1172 | if (!ret) | 1172 | if (!ret) |
1173 | ret = uea_stat(sc); | 1173 | ret = uea_stat(sc); |
1174 | if (ret != -EAGAIN) | 1174 | if (ret != -EAGAIN) |
1175 | msleep(1000); | 1175 | msleep_interruptible(1000); |
1176 | if (try_to_freeze()) | ||
1177 | uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, " | ||
1178 | "please unplug/replug your modem\n"); | ||
1176 | } | 1179 | } |
1177 | uea_leaves(INS_TO_USBDEV(sc)); | 1180 | uea_leaves(INS_TO_USBDEV(sc)); |
1178 | return ret; | 1181 | return ret; |
@@ -1566,6 +1569,7 @@ UEA_ATTR(uscorr, 0); | |||
1566 | UEA_ATTR(dscorr, 0); | 1569 | UEA_ATTR(dscorr, 0); |
1567 | UEA_ATTR(usunc, 0); | 1570 | UEA_ATTR(usunc, 0); |
1568 | UEA_ATTR(dsunc, 0); | 1571 | UEA_ATTR(dsunc, 0); |
1572 | UEA_ATTR(firmid, 0); | ||
1569 | 1573 | ||
1570 | /* Retrieve the device End System Identifier (MAC) */ | 1574 | /* Retrieve the device End System Identifier (MAC) */ |
1571 | 1575 | ||
@@ -1597,7 +1601,7 @@ static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf) | |||
1597 | { | 1601 | { |
1598 | struct uea_softc *sc = usbatm->driver_data; | 1602 | struct uea_softc *sc = usbatm->driver_data; |
1599 | 1603 | ||
1600 | wait_event(sc->sync_q, IS_OPERATIONAL(sc)); | 1604 | wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc)); |
1601 | 1605 | ||
1602 | return 0; | 1606 | return 0; |
1603 | 1607 | ||
@@ -1639,16 +1643,13 @@ static struct attribute *attrs[] = { | |||
1639 | &dev_attr_stat_dscorr.attr, | 1643 | &dev_attr_stat_dscorr.attr, |
1640 | &dev_attr_stat_usunc.attr, | 1644 | &dev_attr_stat_usunc.attr, |
1641 | &dev_attr_stat_dsunc.attr, | 1645 | &dev_attr_stat_dsunc.attr, |
1646 | &dev_attr_stat_firmid.attr, | ||
1647 | NULL, | ||
1642 | }; | 1648 | }; |
1643 | static struct attribute_group attr_grp = { | 1649 | static struct attribute_group attr_grp = { |
1644 | .attrs = attrs, | 1650 | .attrs = attrs, |
1645 | }; | 1651 | }; |
1646 | 1652 | ||
1647 | static int create_fs_entries(struct usb_interface *intf) | ||
1648 | { | ||
1649 | return sysfs_create_group(&intf->dev.kobj, &attr_grp); | ||
1650 | } | ||
1651 | |||
1652 | static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, | 1653 | static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, |
1653 | const struct usb_device_id *id) | 1654 | const struct usb_device_id *id) |
1654 | { | 1655 | { |
@@ -1708,31 +1709,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, | |||
1708 | } | 1709 | } |
1709 | } | 1710 | } |
1710 | 1711 | ||
1712 | ret = sysfs_create_group(&intf->dev.kobj, &attr_grp); | ||
1713 | if (ret < 0) | ||
1714 | goto error; | ||
1715 | |||
1711 | ret = uea_boot(sc); | 1716 | ret = uea_boot(sc); |
1712 | if (ret < 0) { | 1717 | if (ret < 0) |
1713 | kfree(sc); | 1718 | goto error; |
1714 | return ret; | ||
1715 | } | ||
1716 | 1719 | ||
1717 | ret = create_fs_entries(intf); | ||
1718 | if (ret) { | ||
1719 | uea_stop(sc); | ||
1720 | kfree(sc); | ||
1721 | return ret; | ||
1722 | } | ||
1723 | return 0; | 1720 | return 0; |
1724 | } | 1721 | error: |
1725 | 1722 | kfree(sc); | |
1726 | static void destroy_fs_entries(struct usb_interface *intf) | 1723 | return ret; |
1727 | { | ||
1728 | sysfs_remove_group(&intf->dev.kobj, &attr_grp); | ||
1729 | } | 1724 | } |
1730 | 1725 | ||
1731 | static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) | 1726 | static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) |
1732 | { | 1727 | { |
1733 | struct uea_softc *sc = usbatm->driver_data; | 1728 | struct uea_softc *sc = usbatm->driver_data; |
1734 | 1729 | ||
1735 | destroy_fs_entries(intf); | 1730 | sysfs_remove_group(&intf->dev.kobj, &attr_grp); |
1736 | uea_stop(sc); | 1731 | uea_stop(sc); |
1737 | kfree(sc); | 1732 | kfree(sc); |
1738 | } | 1733 | } |
@@ -1753,10 +1748,10 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1753 | struct usb_device *usb = interface_to_usbdev(intf); | 1748 | struct usb_device *usb = interface_to_usbdev(intf); |
1754 | 1749 | ||
1755 | uea_enters(usb); | 1750 | uea_enters(usb); |
1756 | uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", | 1751 | uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s %s\n", |
1757 | le16_to_cpu(usb->descriptor.idVendor), | 1752 | le16_to_cpu(usb->descriptor.idVendor), |
1758 | le16_to_cpu(usb->descriptor.idProduct), | 1753 | le16_to_cpu(usb->descriptor.idProduct), |
1759 | chip_name[UEA_CHIP_VERSION(id)]); | 1754 | chip_name[UEA_CHIP_VERSION(id)], IS_ISDN(usb)?"isdn":"pots"); |
1760 | 1755 | ||
1761 | usb_reset_device(usb); | 1756 | usb_reset_device(usb); |
1762 | 1757 | ||