Lines Matching refs:cs

63 static int write_modem(struct cardstate *cs)  in write_modem()  argument
65 struct tty_struct *tty = cs->hw.ser->tty; in write_modem()
66 struct bc_state *bcs = &cs->bcs[0]; /* only one channel */ in write_modem()
84 flush_send_queue(cs); in write_modem()
104 static int send_cb(struct cardstate *cs) in send_cb() argument
106 struct tty_struct *tty = cs->hw.ser->tty; in send_cb()
113 cb = cs->cmdbuf; in send_cb()
123 flush_send_queue(cs); in send_cb()
129 sent, cb->len, cs->cmdbytes); in send_cb()
133 spin_lock_irqsave(&cs->cmdlock, flags); in send_cb()
134 cs->cmdbytes -= cs->curlen; in send_cb()
136 cs->cmdbuf = cb = cb->next; in send_cb()
139 cs->curlen = cb->len; in send_cb()
141 cs->lastcmdbuf = NULL; in send_cb()
142 cs->curlen = 0; in send_cb()
144 spin_unlock_irqrestore(&cs->cmdlock, flags); in send_cb()
161 struct cardstate *cs = (struct cardstate *) data; in gigaset_modem_fill() local
166 if (!cs) { in gigaset_modem_fill()
170 bcs = cs->bcs; in gigaset_modem_fill()
177 sent = send_cb(cs); in gigaset_modem_fill()
196 if (write_modem(cs) < 0) in gigaset_modem_fill()
203 static void flush_send_queue(struct cardstate *cs) in flush_send_queue() argument
210 spin_lock_irqsave(&cs->cmdlock, flags); in flush_send_queue()
211 while ((cb = cs->cmdbuf) != NULL) { in flush_send_queue()
212 cs->cmdbuf = cb->next; in flush_send_queue()
217 cs->cmdbuf = cs->lastcmdbuf = NULL; in flush_send_queue()
218 cs->cmdbytes = cs->curlen = 0; in flush_send_queue()
219 spin_unlock_irqrestore(&cs->cmdlock, flags); in flush_send_queue()
222 if (cs->bcs->tx_skb) in flush_send_queue()
223 dev_kfree_skb_any(cs->bcs->tx_skb); in flush_send_queue()
224 while ((skb = skb_dequeue(&cs->bcs->squeue)) != NULL) in flush_send_queue()
242 static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb) in gigaset_write_cmd() argument
246 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? in gigaset_write_cmd()
250 spin_lock_irqsave(&cs->cmdlock, flags); in gigaset_write_cmd()
251 cb->prev = cs->lastcmdbuf; in gigaset_write_cmd()
252 if (cs->lastcmdbuf) in gigaset_write_cmd()
253 cs->lastcmdbuf->next = cb; in gigaset_write_cmd()
255 cs->cmdbuf = cb; in gigaset_write_cmd()
256 cs->curlen = cb->len; in gigaset_write_cmd()
258 cs->cmdbytes += cb->len; in gigaset_write_cmd()
259 cs->lastcmdbuf = cb; in gigaset_write_cmd()
260 spin_unlock_irqrestore(&cs->cmdlock, flags); in gigaset_write_cmd()
262 spin_lock_irqsave(&cs->lock, flags); in gigaset_write_cmd()
263 if (cs->connected) in gigaset_write_cmd()
264 tasklet_schedule(&cs->write_tasklet); in gigaset_write_cmd()
265 spin_unlock_irqrestore(&cs->lock, flags); in gigaset_write_cmd()
277 static int gigaset_write_room(struct cardstate *cs) in gigaset_write_room() argument
281 bytes = cs->cmdbytes; in gigaset_write_room()
293 static int gigaset_chars_in_buffer(struct cardstate *cs) in gigaset_chars_in_buffer() argument
295 return cs->cmdbytes; in gigaset_chars_in_buffer()
305 static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) in gigaset_brkchars() argument
366 static void gigaset_freecshw(struct cardstate *cs) in gigaset_freecshw() argument
368 tasklet_kill(&cs->write_tasklet); in gigaset_freecshw()
369 if (!cs->hw.ser) in gigaset_freecshw()
371 platform_device_unregister(&cs->hw.ser->dev); in gigaset_freecshw()
376 struct cardstate *cs = dev_get_drvdata(dev); in gigaset_device_release() local
378 if (!cs) in gigaset_device_release()
381 kfree(cs->hw.ser); in gigaset_device_release()
382 cs->hw.ser = NULL; in gigaset_device_release()
389 static int gigaset_initcshw(struct cardstate *cs) in gigaset_initcshw() argument
399 cs->hw.ser = scs; in gigaset_initcshw()
401 cs->hw.ser->dev.name = GIGASET_MODULENAME; in gigaset_initcshw()
402 cs->hw.ser->dev.id = cs->minor_index; in gigaset_initcshw()
403 cs->hw.ser->dev.dev.release = gigaset_device_release; in gigaset_initcshw()
404 rc = platform_device_register(&cs->hw.ser->dev); in gigaset_initcshw()
407 kfree(cs->hw.ser); in gigaset_initcshw()
408 cs->hw.ser = NULL; in gigaset_initcshw()
411 dev_set_drvdata(&cs->hw.ser->dev.dev, cs); in gigaset_initcshw()
413 tasklet_init(&cs->write_tasklet, in gigaset_initcshw()
414 gigaset_modem_fill, (unsigned long) cs); in gigaset_initcshw()
426 static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, in gigaset_set_modem_ctrl() argument
429 struct tty_struct *tty = cs->hw.ser->tty; in gigaset_set_modem_ctrl()
444 static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) in gigaset_baud_rate() argument
449 static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) in gigaset_set_line_ctrl() argument
480 struct cardstate *cs = tty->disc_data; in cs_get() local
482 if (!cs || !cs->hw.ser) { in cs_get()
486 atomic_inc(&cs->hw.ser->refcnt); in cs_get()
487 return cs; in cs_get()
490 static void cs_put(struct cardstate *cs) in cs_put() argument
492 if (atomic_dec_and_test(&cs->hw.ser->refcnt)) in cs_put()
493 complete(&cs->hw.ser->dead_cmp); in cs_put()
503 struct cardstate *cs; in gigaset_tty_open() local
516 cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME); in gigaset_tty_open()
517 if (!cs) { in gigaset_tty_open()
522 cs->dev = &cs->hw.ser->dev.dev; in gigaset_tty_open()
523 cs->hw.ser->tty = tty; in gigaset_tty_open()
524 atomic_set(&cs->hw.ser->refcnt, 1); in gigaset_tty_open()
525 init_completion(&cs->hw.ser->dead_cmp); in gigaset_tty_open()
526 tty->disc_data = cs; in gigaset_tty_open()
542 cs->mstate = MS_LOCKED; in gigaset_tty_open()
543 rc = gigaset_start(cs); in gigaset_tty_open()
545 tasklet_kill(&cs->write_tasklet); in gigaset_tty_open()
555 gigaset_freecs(cs); in gigaset_tty_open()
566 struct cardstate *cs = tty->disc_data; in gigaset_tty_close() local
570 if (!cs) { in gigaset_tty_close()
578 if (!cs->hw.ser) in gigaset_tty_close()
582 if (!atomic_dec_and_test(&cs->hw.ser->refcnt)) in gigaset_tty_close()
583 wait_for_completion(&cs->hw.ser->dead_cmp); in gigaset_tty_close()
587 gigaset_stop(cs); in gigaset_tty_close()
588 tasklet_kill(&cs->write_tasklet); in gigaset_tty_close()
589 flush_send_queue(cs); in gigaset_tty_close()
590 cs->dev = NULL; in gigaset_tty_close()
591 gigaset_freecs(cs); in gigaset_tty_close()
617 struct cardstate *cs = cs_get(tty); in gigaset_tty_ioctl() local
621 if (!cs) in gigaset_tty_ioctl()
640 flush_send_queue(cs); in gigaset_tty_ioctl()
650 cs_put(cs); in gigaset_tty_ioctl()
670 struct cardstate *cs = cs_get(tty); in gigaset_tty_receive() local
674 if (!cs) in gigaset_tty_receive()
676 inbuf = cs->inbuf; in gigaset_tty_receive()
678 dev_err(cs->dev, "%s: no inbuf\n", __func__); in gigaset_tty_receive()
679 cs_put(cs); in gigaset_tty_receive()
701 dev_err(cs->dev, in gigaset_tty_receive()
715 gigaset_schedule_event(cs); in gigaset_tty_receive()
716 cs_put(cs); in gigaset_tty_receive()
725 struct cardstate *cs = cs_get(tty); in gigaset_tty_wakeup() local
728 if (!cs) in gigaset_tty_wakeup()
730 tasklet_schedule(&cs->write_tasklet); in gigaset_tty_wakeup()
731 cs_put(cs); in gigaset_tty_wakeup()