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()
85 flush_send_queue(cs); in write_modem()
105 static int send_cb(struct cardstate *cs) in send_cb() argument
107 struct tty_struct *tty = cs->hw.ser->tty; in send_cb()
115 cb = cs->cmdbuf; in send_cb()
125 flush_send_queue(cs); in send_cb()
131 sent, cb->len, cs->cmdbytes); in send_cb()
135 spin_lock_irqsave(&cs->cmdlock, flags); in send_cb()
136 cs->cmdbytes -= cs->curlen; in send_cb()
138 cs->cmdbuf = cb = cb->next; in send_cb()
141 cs->curlen = cb->len; in send_cb()
143 cs->lastcmdbuf = NULL; in send_cb()
144 cs->curlen = 0; in send_cb()
146 spin_unlock_irqrestore(&cs->cmdlock, flags); in send_cb()
163 struct cardstate *cs = (struct cardstate *) data; in gigaset_modem_fill() local
168 if (!cs) { in gigaset_modem_fill()
172 bcs = cs->bcs; in gigaset_modem_fill()
179 sent = send_cb(cs); in gigaset_modem_fill()
198 if (write_modem(cs) < 0) in gigaset_modem_fill()
205 static void flush_send_queue(struct cardstate *cs) in flush_send_queue() argument
212 spin_lock_irqsave(&cs->cmdlock, flags); in flush_send_queue()
213 while ((cb = cs->cmdbuf) != NULL) { in flush_send_queue()
214 cs->cmdbuf = cb->next; in flush_send_queue()
219 cs->cmdbuf = cs->lastcmdbuf = NULL; in flush_send_queue()
220 cs->cmdbytes = cs->curlen = 0; in flush_send_queue()
221 spin_unlock_irqrestore(&cs->cmdlock, flags); in flush_send_queue()
224 if (cs->bcs->tx_skb) in flush_send_queue()
225 dev_kfree_skb_any(cs->bcs->tx_skb); in flush_send_queue()
226 while ((skb = skb_dequeue(&cs->bcs->squeue)) != NULL) in flush_send_queue()
244 static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb) in gigaset_write_cmd() argument
248 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? in gigaset_write_cmd()
252 spin_lock_irqsave(&cs->cmdlock, flags); in gigaset_write_cmd()
253 cb->prev = cs->lastcmdbuf; in gigaset_write_cmd()
254 if (cs->lastcmdbuf) in gigaset_write_cmd()
255 cs->lastcmdbuf->next = cb; in gigaset_write_cmd()
257 cs->cmdbuf = cb; in gigaset_write_cmd()
258 cs->curlen = cb->len; in gigaset_write_cmd()
260 cs->cmdbytes += cb->len; in gigaset_write_cmd()
261 cs->lastcmdbuf = cb; in gigaset_write_cmd()
262 spin_unlock_irqrestore(&cs->cmdlock, flags); in gigaset_write_cmd()
264 spin_lock_irqsave(&cs->lock, flags); in gigaset_write_cmd()
265 if (cs->connected) in gigaset_write_cmd()
266 tasklet_schedule(&cs->write_tasklet); in gigaset_write_cmd()
267 spin_unlock_irqrestore(&cs->lock, flags); in gigaset_write_cmd()
279 static int gigaset_write_room(struct cardstate *cs) in gigaset_write_room() argument
283 bytes = cs->cmdbytes; in gigaset_write_room()
295 static int gigaset_chars_in_buffer(struct cardstate *cs) in gigaset_chars_in_buffer() argument
297 return cs->cmdbytes; in gigaset_chars_in_buffer()
307 static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) in gigaset_brkchars() argument
368 static void gigaset_freecshw(struct cardstate *cs) in gigaset_freecshw() argument
370 tasklet_kill(&cs->write_tasklet); in gigaset_freecshw()
371 if (!cs->hw.ser) in gigaset_freecshw()
373 dev_set_drvdata(&cs->hw.ser->dev.dev, NULL); in gigaset_freecshw()
374 platform_device_unregister(&cs->hw.ser->dev); in gigaset_freecshw()
375 kfree(cs->hw.ser); in gigaset_freecshw()
376 cs->hw.ser = NULL; in gigaset_freecshw()
392 static int gigaset_initcshw(struct cardstate *cs) in gigaset_initcshw() argument
402 cs->hw.ser = scs; in gigaset_initcshw()
404 cs->hw.ser->dev.name = GIGASET_MODULENAME; in gigaset_initcshw()
405 cs->hw.ser->dev.id = cs->minor_index; in gigaset_initcshw()
406 cs->hw.ser->dev.dev.release = gigaset_device_release; in gigaset_initcshw()
407 rc = platform_device_register(&cs->hw.ser->dev); in gigaset_initcshw()
410 kfree(cs->hw.ser); in gigaset_initcshw()
411 cs->hw.ser = NULL; in gigaset_initcshw()
414 dev_set_drvdata(&cs->hw.ser->dev.dev, cs); in gigaset_initcshw()
416 tasklet_init(&cs->write_tasklet, in gigaset_initcshw()
417 gigaset_modem_fill, (unsigned long) cs); in gigaset_initcshw()
429 static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, in gigaset_set_modem_ctrl() argument
432 struct tty_struct *tty = cs->hw.ser->tty; in gigaset_set_modem_ctrl()
445 static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) in gigaset_baud_rate() argument
450 static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) in gigaset_set_line_ctrl() argument
481 struct cardstate *cs = tty->disc_data; in cs_get() local
483 if (!cs || !cs->hw.ser) { in cs_get()
487 atomic_inc(&cs->hw.ser->refcnt); in cs_get()
488 return cs; in cs_get()
491 static void cs_put(struct cardstate *cs) in cs_put() argument
493 if (atomic_dec_and_test(&cs->hw.ser->refcnt)) in cs_put()
494 complete(&cs->hw.ser->dead_cmp); in cs_put()
504 struct cardstate *cs; in gigaset_tty_open() local
517 cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME); in gigaset_tty_open()
518 if (!cs) { in gigaset_tty_open()
523 cs->dev = &cs->hw.ser->dev.dev; in gigaset_tty_open()
524 cs->hw.ser->tty = tty; in gigaset_tty_open()
525 atomic_set(&cs->hw.ser->refcnt, 1); in gigaset_tty_open()
526 init_completion(&cs->hw.ser->dead_cmp); in gigaset_tty_open()
527 tty->disc_data = cs; in gigaset_tty_open()
543 cs->mstate = MS_LOCKED; in gigaset_tty_open()
544 rc = gigaset_start(cs); in gigaset_tty_open()
546 tasklet_kill(&cs->write_tasklet); in gigaset_tty_open()
556 gigaset_freecs(cs); in gigaset_tty_open()
567 struct cardstate *cs = tty->disc_data; in gigaset_tty_close() local
571 if (!cs) { in gigaset_tty_close()
579 if (!cs->hw.ser) in gigaset_tty_close()
583 if (!atomic_dec_and_test(&cs->hw.ser->refcnt)) in gigaset_tty_close()
584 wait_for_completion(&cs->hw.ser->dead_cmp); in gigaset_tty_close()
588 gigaset_stop(cs); in gigaset_tty_close()
589 tasklet_kill(&cs->write_tasklet); in gigaset_tty_close()
590 flush_send_queue(cs); in gigaset_tty_close()
591 cs->dev = NULL; in gigaset_tty_close()
592 gigaset_freecs(cs); in gigaset_tty_close()
640 struct cardstate *cs = cs_get(tty); in gigaset_tty_ioctl() local
644 if (!cs) in gigaset_tty_ioctl()
663 flush_send_queue(cs); in gigaset_tty_ioctl()
673 cs_put(cs); in gigaset_tty_ioctl()
693 struct cardstate *cs = cs_get(tty); in gigaset_tty_receive() local
697 if (!cs) in gigaset_tty_receive()
699 inbuf = cs->inbuf; in gigaset_tty_receive()
701 dev_err(cs->dev, "%s: no inbuf\n", __func__); in gigaset_tty_receive()
702 cs_put(cs); in gigaset_tty_receive()
724 dev_err(cs->dev, in gigaset_tty_receive()
738 gigaset_schedule_event(cs); in gigaset_tty_receive()
739 cs_put(cs); in gigaset_tty_receive()
748 struct cardstate *cs = cs_get(tty); in gigaset_tty_wakeup() local
751 if (!cs) in gigaset_tty_wakeup()
753 tasklet_schedule(&cs->write_tasklet); in gigaset_tty_wakeup()
754 cs_put(cs); in gigaset_tty_wakeup()