diff options
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r-- | drivers/usb/serial/mos7840.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index a0d5ea545982..7e998081e1cd 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -2142,13 +2142,21 @@ static int mos7840_ioctl(struct tty_struct *tty, | |||
2142 | static int mos7810_check(struct usb_serial *serial) | 2142 | static int mos7810_check(struct usb_serial *serial) |
2143 | { | 2143 | { |
2144 | int i, pass_count = 0; | 2144 | int i, pass_count = 0; |
2145 | u8 *buf; | ||
2145 | __u16 data = 0, mcr_data = 0; | 2146 | __u16 data = 0, mcr_data = 0; |
2146 | __u16 test_pattern = 0x55AA; | 2147 | __u16 test_pattern = 0x55AA; |
2148 | int res; | ||
2149 | |||
2150 | buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL); | ||
2151 | if (!buf) | ||
2152 | return 0; /* failed to identify 7810 */ | ||
2147 | 2153 | ||
2148 | /* Store MCR setting */ | 2154 | /* Store MCR setting */ |
2149 | usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 2155 | res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
2150 | MCS_RDREQ, MCS_RD_RTYPE, 0x0300, MODEM_CONTROL_REGISTER, | 2156 | MCS_RDREQ, MCS_RD_RTYPE, 0x0300, MODEM_CONTROL_REGISTER, |
2151 | &mcr_data, VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); | 2157 | buf, VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); |
2158 | if (res == VENDOR_READ_LENGTH) | ||
2159 | mcr_data = *buf; | ||
2152 | 2160 | ||
2153 | for (i = 0; i < 16; i++) { | 2161 | for (i = 0; i < 16; i++) { |
2154 | /* Send the 1-bit test pattern out to MCS7810 test pin */ | 2162 | /* Send the 1-bit test pattern out to MCS7810 test pin */ |
@@ -2158,9 +2166,12 @@ static int mos7810_check(struct usb_serial *serial) | |||
2158 | MODEM_CONTROL_REGISTER, NULL, 0, MOS_WDR_TIMEOUT); | 2166 | MODEM_CONTROL_REGISTER, NULL, 0, MOS_WDR_TIMEOUT); |
2159 | 2167 | ||
2160 | /* Read the test pattern back */ | 2168 | /* Read the test pattern back */ |
2161 | usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 2169 | res = usb_control_msg(serial->dev, |
2162 | MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, &data, | 2170 | usb_rcvctrlpipe(serial->dev, 0), MCS_RDREQ, |
2163 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); | 2171 | MCS_RD_RTYPE, 0, GPIO_REGISTER, buf, |
2172 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); | ||
2173 | if (res == VENDOR_READ_LENGTH) | ||
2174 | data = *buf; | ||
2164 | 2175 | ||
2165 | /* If this is a MCS7810 device, both test patterns must match */ | 2176 | /* If this is a MCS7810 device, both test patterns must match */ |
2166 | if (((test_pattern >> i) ^ (~data >> 1)) & 0x0001) | 2177 | if (((test_pattern >> i) ^ (~data >> 1)) & 0x0001) |
@@ -2174,6 +2185,8 @@ static int mos7810_check(struct usb_serial *serial) | |||
2174 | MCS_WR_RTYPE, 0x0300 | mcr_data, MODEM_CONTROL_REGISTER, NULL, | 2185 | MCS_WR_RTYPE, 0x0300 | mcr_data, MODEM_CONTROL_REGISTER, NULL, |
2175 | 0, MOS_WDR_TIMEOUT); | 2186 | 0, MOS_WDR_TIMEOUT); |
2176 | 2187 | ||
2188 | kfree(buf); | ||
2189 | |||
2177 | if (pass_count == 16) | 2190 | if (pass_count == 16) |
2178 | return 1; | 2191 | return 1; |
2179 | 2192 | ||
@@ -2183,11 +2196,17 @@ static int mos7810_check(struct usb_serial *serial) | |||
2183 | static int mos7840_calc_num_ports(struct usb_serial *serial) | 2196 | static int mos7840_calc_num_ports(struct usb_serial *serial) |
2184 | { | 2197 | { |
2185 | __u16 data = 0x00; | 2198 | __u16 data = 0x00; |
2199 | u8 *buf; | ||
2186 | int mos7840_num_ports; | 2200 | int mos7840_num_ports; |
2187 | 2201 | ||
2188 | usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 2202 | buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL); |
2189 | MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, &data, | 2203 | if (buf) { |
2190 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); | 2204 | usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
2205 | MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, buf, | ||
2206 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); | ||
2207 | data = *buf; | ||
2208 | kfree(buf); | ||
2209 | } | ||
2191 | 2210 | ||
2192 | if (serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7810 || | 2211 | if (serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7810 || |
2193 | serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7820) { | 2212 | serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7820) { |