/* Ioctl on the tty. Called in process context only. May be re-entered by multiple ioctl calling threads.  */
static int gigaset_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
/* Ioctl on the tty. Called in process context only. May be re-entered by multiple ioctl calling threads.  */
static int gigaset_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
{
	struct cardstate *cs = cs_get(tty);
	int rc, val;
	int __user *p = (int __user *)arg;
	if (!cs)
		return -ENXIO;
	switch (cmd) {
	case FIONREAD:
		val = 0;
		rc = put_user(val, p);
		break;
	case TCFLSH:
		switch (arg) {
		case TCIFLUSH:
			break;
		case TCIOFLUSH:
		case TCOFLUSH:
			flush_send_queue(cs);
			break;
		}
	default:
		rc = n_tty_ioctl_helper(tty, file, cmd, arg);
		break;
	}
	cs_put(cs);
	return rc;
}