17 #include <linux/module.h>
38 cs->
ops->set_line_ctrl(cs,
CS8);
48 gigaset_schedule_event(cs);
60 static int if_version(
struct cardstate *cs,
unsigned arg[4])
64 unsigned cmd = arg[0];
70 memcpy(arg, version,
sizeof version);
73 memcpy(arg, compat,
sizeof compat);
82 gigaset_schedule_event(cs);
95 static int if_config(
struct cardstate *cs,
int *arg)
106 pr_err(
"%s: not connected\n", __func__);
120 unsigned int cmd,
unsigned long arg);
121 static int if_write_room(
struct tty_struct *tty);
122 static int if_chars_in_buffer(
struct tty_struct *tty);
123 static void if_throttle(
struct tty_struct *tty);
124 static void if_unthrottle(
struct tty_struct *tty);
126 static int if_tiocmget(
struct tty_struct *tty);
127 static int if_tiocmset(
struct tty_struct *tty,
128 unsigned int set,
unsigned int clear);
130 const unsigned char *
buf,
int count);
137 .write_room = if_write_room,
138 .chars_in_buffer = if_chars_in_buffer,
139 .set_termios = if_set_termios,
140 .throttle = if_throttle,
141 .unthrottle = if_unthrottle,
142 .tiocmget = if_tiocmget,
143 .tiocmset = if_tiocmset,
154 if (!cs || !try_module_get(cs->
driver->owner))
158 module_put(cs->
driver->owner);
165 if (cs->
port.count == 1) {
189 else if (!cs->
port.count)
190 dev_warn(cs->
dev,
"%s: device not opened\n", __func__);
191 else if (!--cs->
port.count)
196 module_put(cs->
driver->owner);
200 unsigned int cmd,
unsigned long arg)
205 unsigned char buf[6];
220 retval =
get_user(int_arg, (
int __user *) arg);
222 retval =
if_lock(cs, &int_arg);
224 retval =
put_user(int_arg, (
int __user *) arg);
227 retval =
get_user(int_arg, (
int __user *) arg);
229 retval = if_config(cs, &int_arg);
231 retval =
put_user(int_arg, (
int __user *) arg);
235 (
const unsigned char __user *) arg, 6)
239 6, (
const unsigned char *) arg);
240 retval = cs->
ops->brkchars(cs, buf);
245 (
unsigned __user *) arg,
sizeof version)
248 retval = if_version(cs, version);
251 version,
sizeof version)
266 static int if_tiocmget(
struct tty_struct *tty)
283 static int if_tiocmset(
struct tty_struct *tty,
284 unsigned int set,
unsigned int clear)
310 static int if_write(
struct tty_struct *tty,
const unsigned char *buf,
int count)
327 dev_warn(cs->
dev,
"can't write to unlocked device\n");
339 dev_err(cs->
dev,
"%s: out of memory\n", __func__);
349 retval = cs->
ops->write_cmd(cs, cb);
355 static int if_write_room(
struct tty_struct *tty)
369 dev_warn(cs->
dev,
"can't write to unlocked device\n");
372 retval = cs->
ops->write_room(cs);
379 static int if_chars_in_buffer(
struct tty_struct *tty)
391 dev_warn(cs->
dev,
"can't write to unlocked device\n");
393 retval = cs->
ops->chars_in_buffer(cs);
400 static void if_throttle(
struct tty_struct *tty)
416 static void if_unthrottle(
struct tty_struct *tty)
437 unsigned int old_cflag;
449 iflag = tty->termios.c_iflag;
450 cflag = tty->termios.c_cflag;
466 if ((old_cflag &
CBAUD) ==
B0) {
473 (new_state &
TIOCM_RTS) ?
" only" :
"/RTS");
474 cs->
ops->set_modem_ctrl(cs, control_state, new_state);
478 cs->
ops->baud_rate(cs, cflag & CBAUD);
480 if ((cflag & CBAUD) ==
B0) {
484 cs->
ops->set_modem_ctrl(cs, control_state, new_state);
492 cs->
ops->set_line_ctrl(cs, cflag);
503 static void if_wake(
unsigned long data)
528 cs->minor_index,
NULL);
530 if (!IS_ERR(cs->tty_dev))
533 pr_warning(
"could not register device to the tty subsystem\n");
563 unsigned char *
buffer,
size_t len)
572 tty_insert_flip_string(tty, buffer, len);
593 drv->
tty = tty = alloc_tty_driver(drv->
minors);
611 pr_err(
"error %d registering tty driver\n", ret);
619 pr_err(
"out of memory\n");