static int bcmbt_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { int rc = -1; switch (cmd) { case TIO_ASSERT_BT_WAKE: rc = bcmbt_lpm_assert_bt_wake(); break; case TIO_DEASSERT_BT_WAKE: rc = bcmbt_lpm_deassert_bt_wake(); break; case TIO_GET_BT_WAKE_STATE: rc = bcmbt_get_bt_wake_state(arg); break; case TIO_GET_BT_UART_PORT: pr_err("%s: BLUETOOTH:Enter switch TIO_GET_BT_UART_PORT" \ " => Just break\n", __func__); break; case TIO_GET_BT_FIRMWARE: pr_err("%s: BLUETOOTH:Enter switch TIO_GET_BT_FIRMWARE" \ " => Just break\n", __func__); break; default: pr_debug("%s: BLUETOOTH: switch default\n", __func__); return n_tty_ioctl_helper(tty, file, cmd, arg); } pr_debug("%s: BLUETOOTH:Exit bcmbt_tty_ioctl, cmd=%d\n", __func__, cmd); return rc; }
/** * n_hdlc_tty_ioctl - process IOCTL system call for the tty device. * @tty - pointer to tty instance data * @file - pointer to open file object for device * @cmd - IOCTL command code * @arg - argument for IOCTL call (cmd dependent) * * Returns command dependent result. */ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct n_hdlc *n_hdlc = tty2n_hdlc (tty); int error = 0; int count; unsigned long flags; struct n_hdlc_buf *buf = NULL; if (debuglevel >= DEBUG_LEVEL_INFO) printk("%s(%d)n_hdlc_tty_ioctl() called %d\n", __FILE__,__LINE__,cmd); /* Verify the status of the device */ if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) return -EBADF; switch (cmd) { case FIONREAD: /* report count of read data available */ /* in next available frame (if any) */ spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags); buf = list_first_entry_or_null(&n_hdlc->rx_buf_list.list, struct n_hdlc_buf, list_item); if (buf) count = buf->count; else count = 0; spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags); error = put_user(count, (int __user *)arg); break; case TIOCOUTQ: /* get the pending tx byte count in the driver */ count = tty_chars_in_buffer(tty); /* add size of next output frame in queue */ spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); buf = list_first_entry_or_null(&n_hdlc->tx_buf_list.list, struct n_hdlc_buf, list_item); if (buf) count += buf->count; spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags); error = put_user(count, (int __user *)arg); break; case TCFLSH: switch (arg) { case TCIOFLUSH: case TCOFLUSH: flush_tx_queue(tty); } /* fall through to default */ default: error = n_tty_ioctl_helper(tty, file, cmd, arg); break; } return error; } /* end of n_hdlc_tty_ioctl() */
/* stp_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int stp_uart_tty_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { int err = 0; UART_DBG_FUNC("%s =>\n", __FUNCTION__); switch (cmd) { case HCIUARTSETPROTO: UART_DBG_FUNC("<!!> Set low_latency to TRUE <!!>\n"); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) tty->port->low_latency = 1; #else tty->low_latency = 1; #endif break; default: UART_DBG_FUNC("<!!> n_tty_ioctl_helper <!!>\n"); err = n_tty_ioctl_helper(tty, file, cmd, arg); break; }; UART_DBG_FUNC("%s <=\n", __FUNCTION__); return err; }
/** * uart_tty_ioctl() - Process IOCTL system call for the TTY device. * @tty: Pointer to TTY instance data. * @file: Pointer to open file object for device. * @cmd: IOCTL command code. * @arg: Argument for IOCTL call (cmd dependent). * * Returns: * 0 if there is no error. * -EBADF if supplied TTY struct is not correct. * Error codes from n_tty_iotcl_helper. */ static int uart_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { int err = 0; CG2900_INFO("uart_tty_ioctl cmd %d", cmd); CG2900_DBG("DIR: %d, TYPE: %d, NR: %d, SIZE: %d", _IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd)); switch (cmd) { case HCIUARTSETPROTO: /* Fallthrough */ case HCIUARTGETPROTO: case HCIUARTGETDEVICE: /* * We don't do anything special here, but we have to show we * handle it. */ break; default: err = n_tty_ioctl_helper(tty, file, cmd, arg); break; }; return err; }
/* hci_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { struct hci_uart *hu = (void *)tty->disc_data; int err = 0; BT_DBG(""); /* Verify the status of the device */ if (!hu) return -EBADF; switch (cmd) { case HCIUARTSETPROTO: if (!test_and_set_bit(HCI_UART_PROTO_SET_IN_PROGRESS, &hu->flags) && !test_bit(HCI_UART_PROTO_SET, &hu->flags)) { err = hci_uart_set_proto(hu, arg); if (err) { clear_bit(HCI_UART_PROTO_SET_IN_PROGRESS, &hu->flags); return err; } else { set_bit(HCI_UART_PROTO_SET, &hu->flags); clear_bit(HCI_UART_PROTO_SET_IN_PROGRESS, &hu->flags); } } else return -EBUSY; break; case HCIUARTGETPROTO: if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) return hu->proto->id; return -EUNATCH; case HCIUARTGETDEVICE: if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) return hu->hdev->id; return -EUNATCH; case HCIUARTSETFLAGS: if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) return -EBUSY; hu->hdev_flags = arg; break; case HCIUARTGETFLAGS: return hu->hdev_flags; default: err = n_tty_ioctl_helper(tty, file, cmd, arg); break; }; return err; }
static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct n_hdlc *n_hdlc = tty2n_hdlc (tty); int error = 0; int count; unsigned long flags; if (debuglevel >= DEBUG_LEVEL_INFO) printk("%s(%d)n_hdlc_tty_ioctl() called %d\n", __FILE__,__LINE__,cmd); if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) return -EBADF; switch (cmd) { case FIONREAD: spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags); if (n_hdlc->rx_buf_list.head) count = n_hdlc->rx_buf_list.head->count; else count = 0; spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags); error = put_user(count, (int __user *)arg); break; case TIOCOUTQ: count = tty_chars_in_buffer(tty); spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); if (n_hdlc->tx_buf_list.head) count += n_hdlc->tx_buf_list.head->count; spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags); error = put_user(count, (int __user *)arg); break; case TCFLSH: switch (arg) { case TCIOFLUSH: case TCOFLUSH: flush_tx_queue(tty); } default: error = n_tty_ioctl_helper(tty, file, cmd, arg); break; } return error; }
/* hci_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct hci_uart *hu = tty->disc_data; int err = 0; BT_DBG(""); /* Verify the status of the device */ if (!hu) return -EBADF; switch (cmd) { case HCIUARTSETPROTO: if (!test_and_set_bit(HCI_UART_PROTO_SET, &hu->flags)) { err = hci_uart_set_proto(hu, arg); if (err) clear_bit(HCI_UART_PROTO_SET, &hu->flags); } else err = -EBUSY; break; case HCIUARTGETPROTO: if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) err = hu->proto->id; else err = -EUNATCH; break; case HCIUARTGETDEVICE: if (test_bit(HCI_UART_REGISTERED, &hu->flags)) err = hu->hdev->id; else err = -EUNATCH; break; case HCIUARTSETFLAGS: if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) err = -EBUSY; else err = hci_uart_set_flags(hu, arg); break; case HCIUARTGETFLAGS: err = hu->hdev_flags; break; default: err = n_tty_ioctl_helper(tty, file, cmd, arg); break; } return err; }
static int n_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { int retval; switch (cmd) { case TIOCOUTQ: return put_user(tty_chars_in_buffer(tty), (int __user *) arg); case TIOCINQ: retval = tty->read_cnt; if (L_ICANON(tty)) retval = inq_canon(tty); return put_user(retval, (unsigned int __user *) arg); default: return n_tty_ioctl_helper(tty, file, cmd, arg); } }
/* nci_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int nci_uart_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct nci_uart *nu = (void *)tty->disc_data; int err = 0; switch (cmd) { case NCIUARTSETDRIVER: if (!nu) return nci_uart_set_driver(tty, (unsigned int)arg); else return -EBUSY; break; default: err = n_tty_ioctl_helper(tty, file, cmd, arg); break; } return err; }
/* stp_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int stp_uart_tty_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { int err = 0; UART_DBG_FUNC("%s =>\n", __FUNCTION__); switch (cmd) { case HCIUARTSETPROTO: UART_DBG_FUNC("<!!> Set low_latency to TRUE <!!>\n"); tty->low_latency = 1; break; default: UART_DBG_FUNC("<!!> n_tty_ioctl_helper <!!>\n"); err = n_tty_ioctl_helper(tty, file, cmd, arg); break; }; UART_DBG_FUNC("%s <=\n", __FUNCTION__); return err; }
/* stp_uart_tty_ioctl() * * Process IOCTL system call for the tty device. * * Arguments: * * tty pointer to tty instance data * file pointer to open file object for device * cmd IOCTL command code * arg argument for IOCTL call (cmd dependent) * * Return Value: Command dependent */ static int stp_uart_tty_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { int err = 0; UART_LOUD_FUNC("++ ll(%d)\n", tty->low_latency); switch (cmd) { case HCIUARTSETPROTO: #if LDISC_LOW_LATENCY UART_INFO_FUNC("set low_latency to 1\n"); tty->low_latency = 1; #endif break; default: UART_LOUD_FUNC("redirect to n_tty_ioctl_helper\n"); err = n_tty_ioctl_helper(tty, file, cmd, arg); UART_LOUD_FUNC("n_tty_ioctl_helper result(0x%x %d)\n", cmd, err); break; }; UART_LOUD_FUNC("--\n"); return err; }