Skip to content

Commit 33fb934

Browse files
committed
USB: serial: cp210x: clean up type detection
Clean up attach somewhat by moving type detection into the quirk helper and giving it a more generic name. Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent 33a61d2 commit 33fb934

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/usb/serial/cp210x.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,11 +2092,21 @@ static int cp210x_get_fw_version(struct usb_serial *serial, u16 value)
20922092
return 0;
20932093
}
20942094

2095-
static void cp210x_determine_quirks(struct usb_serial *serial)
2095+
static void cp210x_determine_type(struct usb_serial *serial)
20962096
{
20972097
struct cp210x_serial_private *priv = usb_get_serial_data(serial);
20982098
int ret;
20992099

2100+
ret = cp210x_read_vendor_block(serial, REQTYPE_DEVICE_TO_HOST,
2101+
CP210X_GET_PARTNUM, &priv->partnum,
2102+
sizeof(priv->partnum));
2103+
if (ret < 0) {
2104+
dev_warn(&serial->interface->dev,
2105+
"querying part number failed\n");
2106+
priv->partnum = CP210X_PARTNUM_UNKNOWN;
2107+
return;
2108+
}
2109+
21002110
switch (priv->partnum) {
21012111
case CP210X_PARTNUM_CP2102N_QFN28:
21022112
case CP210X_PARTNUM_CP2102N_QFN24:
@@ -2121,18 +2131,9 @@ static int cp210x_attach(struct usb_serial *serial)
21212131
if (!priv)
21222132
return -ENOMEM;
21232133

2124-
result = cp210x_read_vendor_block(serial, REQTYPE_DEVICE_TO_HOST,
2125-
CP210X_GET_PARTNUM, &priv->partnum,
2126-
sizeof(priv->partnum));
2127-
if (result < 0) {
2128-
dev_warn(&serial->interface->dev,
2129-
"querying part number failed\n");
2130-
priv->partnum = CP210X_PARTNUM_UNKNOWN;
2131-
}
2132-
21332134
usb_set_serial_data(serial, priv);
21342135

2135-
cp210x_determine_quirks(serial);
2136+
cp210x_determine_type(serial);
21362137
cp210x_init_max_speed(serial);
21372138

21382139
result = cp210x_gpio_init(serial);

0 commit comments

Comments
 (0)