|
@@ -1425,16 +1425,13 @@ static int write_latency_timer(struct usb_serial_port *port)
|
|
return rv;
|
|
return rv;
|
|
}
|
|
}
|
|
|
|
|
|
-static int read_latency_timer(struct usb_serial_port *port)
|
|
|
|
|
|
+static int _read_latency_timer(struct usb_serial_port *port)
|
|
{
|
|
{
|
|
struct ftdi_private *priv = usb_get_serial_port_data(port);
|
|
struct ftdi_private *priv = usb_get_serial_port_data(port);
|
|
struct usb_device *udev = port->serial->dev;
|
|
struct usb_device *udev = port->serial->dev;
|
|
unsigned char *buf;
|
|
unsigned char *buf;
|
|
int rv;
|
|
int rv;
|
|
|
|
|
|
- if (priv->chip_type == SIO || priv->chip_type == FT8U232AM)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
buf = kmalloc(1, GFP_KERNEL);
|
|
buf = kmalloc(1, GFP_KERNEL);
|
|
if (!buf)
|
|
if (!buf)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
@@ -1446,11 +1443,10 @@ static int read_latency_timer(struct usb_serial_port *port)
|
|
0, priv->interface,
|
|
0, priv->interface,
|
|
buf, 1, WDR_TIMEOUT);
|
|
buf, 1, WDR_TIMEOUT);
|
|
if (rv < 1) {
|
|
if (rv < 1) {
|
|
- dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
|
|
|
|
if (rv >= 0)
|
|
if (rv >= 0)
|
|
rv = -EIO;
|
|
rv = -EIO;
|
|
} else {
|
|
} else {
|
|
- priv->latency = buf[0];
|
|
|
|
|
|
+ rv = buf[0];
|
|
}
|
|
}
|
|
|
|
|
|
kfree(buf);
|
|
kfree(buf);
|
|
@@ -1458,6 +1454,25 @@ static int read_latency_timer(struct usb_serial_port *port)
|
|
return rv;
|
|
return rv;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int read_latency_timer(struct usb_serial_port *port)
|
|
|
|
+{
|
|
|
|
+ struct ftdi_private *priv = usb_get_serial_port_data(port);
|
|
|
|
+ int rv;
|
|
|
|
+
|
|
|
|
+ if (priv->chip_type == SIO || priv->chip_type == FT8U232AM)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ rv = _read_latency_timer(port);
|
|
|
|
+ if (rv < 0) {
|
|
|
|
+ dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
|
|
|
|
+ return rv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ priv->latency = rv;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
static int get_serial_info(struct usb_serial_port *port,
|
|
static int get_serial_info(struct usb_serial_port *port,
|
|
struct serial_struct __user *retinfo)
|
|
struct serial_struct __user *retinfo)
|
|
{
|
|
{
|
|
@@ -1609,9 +1624,19 @@ static void ftdi_determine_type(struct usb_serial_port *port)
|
|
priv->baud_base = 12000000 / 16;
|
|
priv->baud_base = 12000000 / 16;
|
|
} else if (version < 0x400) {
|
|
} else if (version < 0x400) {
|
|
/* Assume it's an FT8U232AM (or FT8U245AM) */
|
|
/* Assume it's an FT8U232AM (or FT8U245AM) */
|
|
- /* (It might be a BM because of the iSerialNumber bug,
|
|
|
|
- * but it will still work as an AM device.) */
|
|
|
|
priv->chip_type = FT8U232AM;
|
|
priv->chip_type = FT8U232AM;
|
|
|
|
+ /*
|
|
|
|
+ * It might be a BM type because of the iSerialNumber bug.
|
|
|
|
+ * If iSerialNumber==0 and the latency timer is readable,
|
|
|
|
+ * assume it is BM type.
|
|
|
|
+ */
|
|
|
|
+ if (udev->descriptor.iSerialNumber == 0 &&
|
|
|
|
+ _read_latency_timer(port) >= 0) {
|
|
|
|
+ dev_dbg(&port->dev,
|
|
|
|
+ "%s: has latency timer so not an AM type\n",
|
|
|
|
+ __func__);
|
|
|
|
+ priv->chip_type = FT232BM;
|
|
|
|
+ }
|
|
} else if (version < 0x600) {
|
|
} else if (version < 0x600) {
|
|
/* Assume it's an FT232BM (or FT245BM) */
|
|
/* Assume it's an FT232BM (or FT245BM) */
|
|
priv->chip_type = FT232BM;
|
|
priv->chip_type = FT232BM;
|