Lines Matching +full:timeout +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0
12 packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno)); in hvsi_send_packet()
15 return pv->put_chars(pv->termno, (u8 *)packet, packet->len); in hvsi_send_packet()
23 pv->established = 0; in hvsi_start_handshake()
24 atomic_set(&pv->seqno, 0); in hvsi_start_handshake()
26 pr_devel("HVSI@%x: Handshaking started\n", pv->termno); in hvsi_start_handshake()
39 pv->established = 0; in hvsi_send_close()
50 pv->mctrl |= TIOCM_CD; in hvsi_cd_change()
52 pv->mctrl &= ~TIOCM_CD; in hvsi_cd_change()
60 if (!pv->is_console && pv->opened) { in hvsi_cd_change()
62 pv->termno); in hvsi_cd_change()
70 struct hvsi_control *pkt = (struct hvsi_control *)pv->inbuf; in hvsi_got_control()
72 switch (be16_to_cpu(pkt->verb)) { in hvsi_got_control()
79 hvsi_cd_change(pv, be32_to_cpu(pkt->word) & HVSI_TSCD); in hvsi_got_control()
86 struct hvsi_query *pkt = (struct hvsi_query *)pv->inbuf; in hvsi_got_query()
90 if (be16_to_cpu(pkt->verb) != VSV_SEND_VERSION_NUMBER) in hvsi_got_query()
94 pv->termno); in hvsi_got_query()
101 r.query_seqno = pkt->hdr.seqno; in hvsi_got_query()
105 pv->established = 1; in hvsi_got_query()
111 (struct hvsi_query_response *)pv->inbuf; in hvsi_got_response()
113 switch(r->verb) { in hvsi_got_response()
115 hvsi_cd_change(pv, be32_to_cpu(r->u.mctrl_word) & HVSI_TSCD); in hvsi_got_response()
116 pv->mctrl_update = 1; in hvsi_got_response()
128 if (pv->inbuf[0] < 0xfc) { in hvsi_check_packet()
129 pv->inbuf_len = pv->inbuf_pktlen = 0; in hvsi_check_packet()
132 type = pv->inbuf[0]; in hvsi_check_packet()
133 len = pv->inbuf[1]; in hvsi_check_packet()
136 if (pv->inbuf_len < len) in hvsi_check_packet()
140 pv->termno, type, len); in hvsi_check_packet()
145 pv->inbuf_pktlen = len - 4; in hvsi_check_packet()
146 pv->inbuf_cur = 4; in hvsi_check_packet()
160 pv->inbuf_len -= len; in hvsi_check_packet()
161 memmove(pv->inbuf, &pv->inbuf[len], pv->inbuf_len); in hvsi_check_packet()
168 if (pv->inbuf_len < HVSI_INBUF_SIZE) in hvsi_get_packet()
169 pv->inbuf_len += pv->get_chars(pv->termno, in hvsi_get_packet()
170 &pv->inbuf[pv->inbuf_len], in hvsi_get_packet()
171 HVSI_INBUF_SIZE - pv->inbuf_len); in hvsi_get_packet()
176 if (pv->inbuf_len >= 4) in hvsi_get_packet()
187 return -ENXIO; in hvsilib_get_chars()
194 if (!pv->opened) in hvsilib_get_chars()
202 if (pv->inbuf_pktlen) { in hvsilib_get_chars()
203 size_t l = min(count, pv->inbuf_pktlen); in hvsilib_get_chars()
204 memcpy(&buf[read], &pv->inbuf[pv->inbuf_cur], l); in hvsilib_get_chars()
205 pv->inbuf_cur += l; in hvsilib_get_chars()
206 pv->inbuf_pktlen -= l; in hvsilib_get_chars()
207 count -= l; in hvsilib_get_chars()
214 if (pv->inbuf_cur) { in hvsilib_get_chars()
215 pv->inbuf_len -= pv->inbuf_cur; in hvsilib_get_chars()
216 memmove(pv->inbuf, &pv->inbuf[pv->inbuf_cur], in hvsilib_get_chars()
217 pv->inbuf_len); in hvsilib_get_chars()
218 pv->inbuf_cur = 0; in hvsilib_get_chars()
223 tries--; in hvsilib_get_chars()
225 if (!pv->established) { in hvsilib_get_chars()
226 pr_devel("HVSI@%x: returning -EPIPE\n", pv->termno); in hvsilib_get_chars()
227 return -EPIPE; in hvsilib_get_chars()
239 return -ENODEV; in hvsilib_put_chars()
250 static void maybe_msleep(unsigned long ms) in maybe_msleep() argument
254 mdelay(ms); in maybe_msleep()
256 msleep(ms); in maybe_msleep()
262 int rc, timeout; in hvsilib_read_mctrl() local
265 pv->termno); in hvsilib_read_mctrl()
267 pv->mctrl_update = 0; in hvsilib_read_mctrl()
273 pr_devel("HVSI@%x: Error %d...\n", pv->termno, rc); in hvsilib_read_mctrl()
277 /* Try for up to 200ms */ in hvsilib_read_mctrl()
278 for (timeout = 0; timeout < 20; timeout++) { in hvsilib_read_mctrl()
279 if (!pv->established) in hvsilib_read_mctrl()
280 return -ENXIO; in hvsilib_read_mctrl()
281 if (pv->mctrl_update) in hvsilib_read_mctrl()
286 return -EIO; in hvsilib_read_mctrl()
294 mctrl = pv->mctrl; in hvsilib_write_mctrl()
299 if (mctrl == pv->mctrl) in hvsilib_write_mctrl()
301 pv->mctrl = mctrl; in hvsilib_write_mctrl()
303 pr_devel("HVSI@%x: %s DTR...\n", pv->termno, in hvsilib_write_mctrl()
316 int timeout; in hvsilib_establish() local
318 pr_devel("HVSI@%x: Establishing...\n", pv->termno); in hvsilib_establish()
320 /* Try for up to 200ms, there can be a packet to in hvsilib_establish()
323 for (timeout = 0; timeout < 20; timeout++) { in hvsilib_establish()
324 if (pv->established) in hvsilib_establish()
333 pr_devel("HVSI@%x: ... sending close\n", pv->termno); in hvsilib_establish()
339 pr_devel("HVSI@%x: ... restarting handshake\n", pv->termno); in hvsilib_establish()
343 pr_devel("HVSI@%x: ... waiting handshake\n", pv->termno); in hvsilib_establish()
345 /* Try for up to 400ms */ in hvsilib_establish()
346 for (timeout = 0; timeout < 40; timeout++) { in hvsilib_establish()
347 if (pv->established) in hvsilib_establish()
353 if (!pv->established) { in hvsilib_establish()
354 pr_devel("HVSI@%x: Timeout handshaking, giving up !\n", in hvsilib_establish()
355 pv->termno); in hvsilib_establish()
361 pr_devel("HVSI@%x: ... established, reading mctrl\n", pv->termno); in hvsilib_establish()
367 pr_devel("HVSI@%x: ... setting mctrl\n", pv->termno); in hvsilib_establish()
373 pv->opened = 1; in hvsilib_establish()
378 pr_devel("HVSI@%x: open !\n", pv->termno); in hvsilib_open()
381 pv->tty = tty_port_tty_get(&hp->port); in hvsilib_open()
392 pr_devel("HVSI@%x: close !\n", pv->termno); in hvsilib_close()
394 if (!pv->is_console) { in hvsilib_close()
396 pv->termno); in hvsilib_close()
399 spin_lock_irqsave(&hp->lock, flags); in hvsilib_close()
400 pv->opened = 0; in hvsilib_close()
401 spin_unlock_irqrestore(&hp->lock, flags); in hvsilib_close()
404 if (!pv->tty || (pv->tty->termios.c_cflag & HUPCL)) in hvsilib_close()
411 tty_kref_put(pv->tty); in hvsilib_close()
412 pv->tty = NULL; in hvsilib_close()
422 pv->get_chars = get_chars; in hvsilib_init()
423 pv->put_chars = put_chars; in hvsilib_init()
424 pv->termno = termno; in hvsilib_init()
425 pv->is_console = is_console; in hvsilib_init()