cp210x.c (befc28a720362cb2b14601b5ba3d1f4c600ffaec) cp210x.c (33a61d2cc731d1c8a763f147528fc5e46978599f)
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

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

1140 if (ret) {
1141 dev_err(&port->dev, "failed to disable events: %d\n", ret);
1142 return;
1143 }
1144
1145 port_priv->event_mode = false;
1146}
1147
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

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

1140 if (ret) {
1141 dev_err(&port->dev, "failed to disable events: %d\n", ret);
1142 return;
1143 }
1144
1145 port_priv->event_mode = false;
1146}
1147
1148static int cp210x_set_chars(struct usb_serial_port *port,
1149 struct cp210x_special_chars *chars)
1150{
1151 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
1152 struct usb_serial *serial = port->serial;
1153 void *dmabuf;
1154 int result;
1155
1156 dmabuf = kmemdup(chars, sizeof(*chars), GFP_KERNEL);
1157 if (!dmabuf)
1158 return -ENOMEM;
1159
1160 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1161 CP210X_SET_CHARS, REQTYPE_HOST_TO_INTERFACE, 0,
1162 port_priv->bInterfaceNumber,
1163 dmabuf, sizeof(*chars), USB_CTRL_SET_TIMEOUT);
1164
1165 kfree(dmabuf);
1166
1167 if (result < 0)
1168 return result;
1169
1170 return 0;
1171}
1172
1173static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b)
1174{
1175 bool iflag_change, cc_change;
1176
1177 iflag_change = ((a->c_iflag ^ b->c_iflag) & (INPCK | IXON | IXOFF));
1178 cc_change = a->c_cc[VSTART] != b->c_cc[VSTART] ||
1179 a->c_cc[VSTOP] != b->c_cc[VSTOP];
1180

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

1212 }
1213
1214 if (I_IXON(tty) || I_IXOFF(tty)) {
1215 memset(&chars, 0, sizeof(chars));
1216
1217 chars.bXonChar = START_CHAR(tty);
1218 chars.bXoffChar = STOP_CHAR(tty);
1219
1148static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b)
1149{
1150 bool iflag_change, cc_change;
1151
1152 iflag_change = ((a->c_iflag ^ b->c_iflag) & (INPCK | IXON | IXOFF));
1153 cc_change = a->c_cc[VSTART] != b->c_cc[VSTART] ||
1154 a->c_cc[VSTOP] != b->c_cc[VSTOP];
1155

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

1187 }
1188
1189 if (I_IXON(tty) || I_IXOFF(tty)) {
1190 memset(&chars, 0, sizeof(chars));
1191
1192 chars.bXonChar = START_CHAR(tty);
1193 chars.bXoffChar = STOP_CHAR(tty);
1194
1220 ret = cp210x_set_chars(port, &chars);
1195 ret = cp210x_write_reg_block(port, CP210X_SET_CHARS, &chars,
1196 sizeof(chars));
1221 if (ret) {
1222 dev_err(&port->dev, "failed to set special chars: %d\n",
1223 ret);
1224 }
1225 }
1226
1227 mutex_lock(&port_priv->mutex);
1228

--- 960 unchanged lines hidden ---
1197 if (ret) {
1198 dev_err(&port->dev, "failed to set special chars: %d\n",
1199 ret);
1200 }
1201 }
1202
1203 mutex_lock(&port_priv->mutex);
1204

--- 960 unchanged lines hidden ---