14 #include <linux/module.h>
20 #define DRIVER_AUTHOR "Tilman Schmidt"
21 #define DRIVER_DESC "Serial Driver for Gigaset 307x using Siemens M101"
23 #define GIGASET_MINORS 1
24 #define GIGASET_MINOR 0
25 #define GIGASET_MODULENAME "ser_gigaset"
26 #define GIGASET_DEVNAME "ttyGS"
29 #define IF_WRITEBUF 264
58 static void flush_send_queue(
struct cardstate *);
70 if (!tty || !tty->
driver || !skb)
81 sent = tty->
ops->write(tty, skb->
data, skb->
len);
125 flush_send_queue(cs);
134 while (cb && !cb->
len) {
146 spin_unlock_irqrestore(&cs->
cmdlock, flags);
161 static void gigaset_modem_fill(
unsigned long data)
193 (
unsigned long) bcs->
tx_skb);
198 if (write_modem(cs) < 0)
205 static void flush_send_queue(
struct cardstate *cs)
221 spin_unlock_irqrestore(&cs->
cmdlock, flags);
250 "CMD Transmit", cb->
len, cb->
buf);
262 spin_unlock_irqrestore(&cs->
cmdlock, flags);
267 spin_unlock_irqrestore(&cs->
lock, flags);
279 static int gigaset_write_room(
struct cardstate *cs)
295 static int gigaset_chars_in_buffer(
struct cardstate *cs)
307 static int gigaset_brkchars(
struct cardstate *cs,
const unsigned char buf[6])
317 static int gigaset_init_bchannel(
struct bc_state *bcs)
320 gigaset_bchannel_up(bcs);
328 static int gigaset_close_bchannel(
struct bc_state *bcs)
331 gigaset_bchannel_down(bcs);
339 static int gigaset_initbcshw(
struct bc_state *bcs)
350 static void gigaset_freebcshw(
struct bc_state *bcs)
359 static void gigaset_reinitbcshw(
struct bc_state *bcs)
368 static void gigaset_freecshw(
struct cardstate *cs)
379 static void gigaset_device_release(
struct device *
dev)
392 static int gigaset_initcshw(
struct cardstate *cs)
399 pr_err(
"out of memory\n");
406 cs->
hw.
ser->dev.dev.release = gigaset_device_release;
409 pr_err(
"error %d registering platform device\n", rc);
417 gigaset_modem_fill, (
unsigned long) cs);
429 static int gigaset_set_modem_ctrl(
struct cardstate *cs,
unsigned old_state,
433 unsigned int set,
clear;
435 if (!tty || !tty->
driver || !tty->
ops->tiocmset)
437 set = new_state & ~old_state;
438 clear = old_state & ~new_state;
442 return tty->
ops->tiocmset(tty,
set, clear);
445 static int gigaset_baud_rate(
struct cardstate *cs,
unsigned cflag)
450 static int gigaset_set_line_ctrl(
struct cardstate *cs,
unsigned cflag)
458 gigaset_chars_in_buffer,
460 gigaset_init_bchannel,
461 gigaset_close_bchannel,
467 gigaset_set_modem_ctrl,
469 gigaset_set_line_ctrl,
483 if (!cs || !cs->
hw.
ser) {
512 pr_err(
"%s: no driver structure\n", __func__);
524 cs->
hw.
ser->tty = tty;
526 init_completion(&cs->
hw.
ser->dead_cmp);
571 pr_err(
"%s: no hw cardstate\n", __func__);
581 flush_send_queue(cs);
594 static int gigaset_tty_hangup(
struct tty_struct *tty)
596 gigaset_tty_close(tty);
606 unsigned char __user *
buf,
size_t count)
617 const unsigned char *
buf,
size_t count)
629 unsigned int cmd,
unsigned long arg)
654 flush_send_queue(cs);
681 gigaset_tty_receive(
struct tty_struct *tty,
const unsigned char *
buf,
716 "inbuf overflow, discarding %d bytes\n",
729 gigaset_schedule_event(cs);
751 .name =
"ser_gigaset",
752 .open = gigaset_tty_open,
753 .close = gigaset_tty_close,
754 .hangup = gigaset_tty_hangup,
755 .read = gigaset_tty_read,
756 .write = gigaset_tty_write,
757 .ioctl = gigaset_tty_ioctl,
758 .receive_buf = gigaset_tty_receive,
759 .write_wakeup = gigaset_tty_wakeup,
766 static int __init ser_gigaset_init(
void)
773 pr_err(
"error %d registering platform driver\n", rc);
786 pr_err(
"error %d registering line discipline\n", rc);
801 static void __exit ser_gigaset_exit(
void)
814 pr_err(
"error %d unregistering line discipline\n", rc);