Lines Matching refs:dev_fd
39 static int dev_fd; variable
57 void read_firmware_version(int dev_fd) in read_firmware_version() argument
64 UIM_VER(" wrote %d bytes", (int)write(dev_fd, buffer, 4)); in read_firmware_version()
65 UIM_VER(" reading %d bytes", (int)read(dev_fd, resp_buffer, 15)); in read_firmware_version()
199 static int set_baud_rate(int dev_fd) in set_baud_rate() argument
204 tcflush(dev_fd, TCIOFLUSH); in set_baud_rate()
207 if (tcgetattr(dev_fd, &ti) < 0) { in set_baud_rate()
222 tcsetattr(dev_fd, TCSANOW, &ti); in set_baud_rate()
227 tcsetattr(dev_fd, TCSANOW, &ti); in set_baud_rate()
229 tcflush(dev_fd, TCIOFLUSH); in set_baud_rate()
241 static int set_custom_baud_rate(int dev_fd, int baud_rate, int flow_ctrl) in set_custom_baud_rate() argument
248 tcflush(dev_fd, TCIOFLUSH); in set_custom_baud_rate()
250 if (tcgetattr(dev_fd, &ti) < 0) { in set_custom_baud_rate()
265 if (tcsetattr(dev_fd, TCSANOW, &ti) < 0) { in set_custom_baud_rate()
270 tcflush(dev_fd, TCIOFLUSH); in set_custom_baud_rate()
273 ioctl(dev_fd, TCGETS2, &ti2); in set_custom_baud_rate()
277 ioctl(dev_fd, TCSETS2, &ti2); in set_custom_baud_rate()
347 dev_fd = open(uart_dev_name, O_RDWR); in st_uart_config()
348 if (dev_fd < 0) { in st_uart_config()
357 if (set_baud_rate(dev_fd) < 0) { in st_uart_config()
359 close(dev_fd); in st_uart_config()
363 fcntl(dev_fd, F_SETFL,fcntl(dev_fd, F_GETFL) | O_NONBLOCK); in st_uart_config()
378 len = write(dev_fd, &cmd, sizeof(cmd)); in st_uart_config()
381 close(dev_fd); in st_uart_config()
386 if (read_command_complete(dev_fd, HCI_HDR_OPCODE) < 0) { in st_uart_config()
387 close(dev_fd); in st_uart_config()
393 if (set_custom_baud_rate(dev_fd, cust_baud_rate, flow_ctrl) < 0) { in st_uart_config()
395 close(dev_fd); in st_uart_config()
413 len = write(dev_fd, &addr_cmd, sizeof(addr_cmd)); in st_uart_config()
416 close(dev_fd); in st_uart_config()
421 if (read_command_complete(dev_fd, WRITE_BD_ADDR_OPCODE) < 0) { in st_uart_config()
422 close(dev_fd); in st_uart_config()
428 read_firmware_version(dev_fd); in st_uart_config()
436 if (ioctl(dev_fd, TIOCSETD, &ldisc) < 0) { in st_uart_config()
438 close(dev_fd); in st_uart_config()
447 close(dev_fd); in st_uart_config()