cp210x.c (33a61d2cc731d1c8a763f147528fc5e46978599f) cp210x.c (33fb934a0992440e3d645d3965e71217c185fd6d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
4 *
5 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
6 * Copyright (C) 2010-2021 Johan Hovold (johan@kernel.org)
7 *
8 * Support to set flow control line levels using TIOCMGET and TIOCMSET

--- 2078 unchanged lines hidden (view full) ---

2087 dev_dbg(&serial->interface->dev, "%s - %d.%d.%d\n", __func__,
2088 ver[0], ver[1], ver[2]);
2089
2090 priv->fw_version = ver[0] << 16 | ver[1] << 8 | ver[2];
2091
2092 return 0;
2093}
2094
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
4 *
5 * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
6 * Copyright (C) 2010-2021 Johan Hovold (johan@kernel.org)
7 *
8 * Support to set flow control line levels using TIOCMGET and TIOCMSET

--- 2078 unchanged lines hidden (view full) ---

2087 dev_dbg(&serial->interface->dev, "%s - %d.%d.%d\n", __func__,
2088 ver[0], ver[1], ver[2]);
2089
2090 priv->fw_version = ver[0] << 16 | ver[1] << 8 | ver[2];
2091
2092 return 0;
2093}
2094
2095static void cp210x_determine_quirks(struct usb_serial *serial)
2095static void cp210x_determine_type(struct usb_serial *serial)
2096{
2097 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
2098 int ret;
2099
2096{
2097 struct cp210x_serial_private *priv = usb_get_serial_data(serial);
2098 int ret;
2099
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
2100 switch (priv->partnum) {
2101 case CP210X_PARTNUM_CP2102N_QFN28:
2102 case CP210X_PARTNUM_CP2102N_QFN24:
2103 case CP210X_PARTNUM_CP2102N_QFN20:
2104 ret = cp210x_get_fw_version(serial, CP210X_GET_FW_VER_2N);
2105 if (ret)
2106 break;
2107 if (priv->fw_version <= 0x10004)

--- 8 unchanged lines hidden (view full) ---

2116{
2117 int result;
2118 struct cp210x_serial_private *priv;
2119
2120 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
2121 if (!priv)
2122 return -ENOMEM;
2123
2110 switch (priv->partnum) {
2111 case CP210X_PARTNUM_CP2102N_QFN28:
2112 case CP210X_PARTNUM_CP2102N_QFN24:
2113 case CP210X_PARTNUM_CP2102N_QFN20:
2114 ret = cp210x_get_fw_version(serial, CP210X_GET_FW_VER_2N);
2115 if (ret)
2116 break;
2117 if (priv->fw_version <= 0x10004)

--- 8 unchanged lines hidden (view full) ---

2126{
2127 int result;
2128 struct cp210x_serial_private *priv;
2129
2130 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
2131 if (!priv)
2132 return -ENOMEM;
2133
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
2133 usb_set_serial_data(serial, priv);
2134
2134 usb_set_serial_data(serial, priv);
2135
2135 cp210x_determine_quirks(serial);
2136 cp210x_determine_type(serial);
2136 cp210x_init_max_speed(serial);
2137
2138 result = cp210x_gpio_init(serial);
2139 if (result < 0) {
2140 dev_err(&serial->interface->dev, "GPIO initialisation failed: %d\n",
2141 result);
2142 }
2143

--- 21 unchanged lines hidden ---
2137 cp210x_init_max_speed(serial);
2138
2139 result = cp210x_gpio_init(serial);
2140 if (result < 0) {
2141 dev_err(&serial->interface->dev, "GPIO initialisation failed: %d\n",
2142 result);
2143 }
2144

--- 21 unchanged lines hidden ---