1 #include <linux/types.h>
4 #include <linux/slab.h>
18 static void hvsi_start_handshake(
struct hvsi_priv *pv)
32 hvsi_send_packet(pv, &
q.hdr);
35 static int hvsi_send_close(
struct hvsi_priv *pv)
44 return hvsi_send_packet(pv, &
ctrl.hdr);
47 static void hvsi_cd_change(
struct hvsi_priv *pv,
int cd)
61 pr_devel(
"HVSI@%x Carrier lost, hanging up !\n",
68 static void hvsi_got_control(
struct hvsi_priv *pv)
75 hvsi_start_handshake(pv);
84 static void hvsi_got_query(
struct hvsi_priv *pv)
93 pr_devel(
"HVSI@%x: Got version query, sending response...\n",
101 r.query_seqno = pkt->
hdr.seqno;
102 hvsi_send_packet(pv, &
r.hdr);
108 static void hvsi_got_response(
struct hvsi_priv *pv)
121 static int hvsi_check_packet(
struct hvsi_priv *pv)
128 if (pv->
inbuf[0] < 0xfc) {
139 pr_devel(
"HVSI@%x: Got packet type %x len %d bytes:\n",
149 hvsi_got_control(pv);
155 hvsi_got_response(pv);
165 static int hvsi_get_packet(
struct hvsi_priv *pv)
177 return hvsi_check_packet(pv);
183 unsigned int tries,
read = 0;
199 for (tries = 1; count && tries < 2; tries++) {
221 if (hvsi_get_packet(pv))
242 rc = hvsi_send_packet(pv, &dp.
hdr);
248 static void maybe_msleep(
unsigned long ms)
262 pr_devel(
"HVSI@%x: Querying modem control status...\n",
270 rc = hvsi_send_packet(pv, &q.
hdr);
277 for (timeout = 0; timeout < 20; timeout++) {
282 if (!hvsi_get_packet(pv))
291 unsigned short mctrl;
298 if (mctrl == pv->
mctrl)
303 dtr ?
"Setting" :
"Clearing");
310 return hvsi_send_packet(pv, &ctrl.
hdr);
322 for (timeout = 0; timeout < 20; timeout++) {
325 if (!hvsi_get_packet(pv))
340 hvsi_start_handshake(pv);
345 for (timeout = 0; timeout < 20; timeout++) {
348 if (!hvsi_get_packet(pv))
353 pr_devel(
"HVSI@%x: Timeout handshaking, giving up !\n",
360 pr_devel(
"HVSI@%x: ... established, reading mctrl\n", pv->
termno);
394 pr_devel(
"HVSI@%x: Not a console, tearing down\n",
400 spin_unlock_irqrestore(&hp->
lock, flags);
403 if (!pv->
tty || (pv->
tty->termios.c_cflag &
HUPCL))
417 int (*put_chars)(
uint32_t termno,
const char *buf,
419 int termno,
int is_console)
421 memset(pv, 0,
sizeof(*pv));