这篇教程C++ tty_port_init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tty_port_init函数的典型用法代码示例。如果您正苦于以下问题:C++ tty_port_init函数的具体用法?C++ tty_port_init怎么用?C++ tty_port_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tty_port_init函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: gs_port_allocstatic intgs_port_alloc(unsigned port_num, struct usb_cdc_line_coding *coding){ struct gs_port *port; port = kzalloc(sizeof(struct gs_port), GFP_KERNEL); if (port == NULL) return -ENOMEM; tty_port_init(&port->port); spin_lock_init(&port->port_lock); init_waitqueue_head(&port->drain_wait); tasklet_init(&port->push, gs_rx_push, (unsigned long) port); INIT_LIST_HEAD(&port->read_pool); INIT_LIST_HEAD(&port->read_queue); INIT_LIST_HEAD(&port->write_pool); port->port_num = port_num; port->port_line_coding = *coding; ports[port_num].port = port; return 0;}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:26,
示例2: kgdb_nmi_tty_installstatic int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty){ struct kgdb_nmi_tty_priv *priv; int ret; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; INIT_KFIFO(priv->fifo); setup_timer(&priv->timer, kgdb_nmi_tty_receiver, (unsigned long)priv); tty_port_init(&priv->port); priv->port.ops = &kgdb_nmi_tty_port_ops; tty->driver_data = priv; ret = tty_port_install(&priv->port, drv, tty); if (ret) { pr_err("%s: can't install tty port: %d/n", __func__, ret); goto err; } return 0;err: tty_port_destroy(&priv->port); kfree(priv); return ret;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:26,
示例3: add_ttystatic int add_tty(int j, struct ipw_hardware *hardware, struct ipw_network *network, int channel_idx, int secondary_channel_idx, int tty_type){ ttys[j] = kzalloc(sizeof(struct ipw_tty), GFP_KERNEL); if (!ttys[j]) return -ENOMEM; ttys[j]->index = j; ttys[j]->hardware = hardware; ttys[j]->channel_idx = channel_idx; ttys[j]->secondary_channel_idx = secondary_channel_idx; ttys[j]->network = network; ttys[j]->tty_type = tty_type; mutex_init(&ttys[j]->ipw_tty_mutex); tty_port_init(&ttys[j]->port); tty_port_register_device(&ttys[j]->port, ipw_tty_driver, j, NULL); ipwireless_associate_network_tty(network, channel_idx, ttys[j]); if (secondary_channel_idx != -1) ipwireless_associate_network_tty(network, secondary_channel_idx, ttys[j]); /* check if we provide raw device (if loopback is enabled) */ if (get_tty(j)) printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": registering %s device ttyIPWp%d/n", tty_type_name(tty_type), j); return 0;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:32,
示例4: create_httyint create_htty(char *name,int index,BUFFER *rbuf,BUFFER *wbuf){ char ptr[120]; struct htty_serial *htty; if(index<0 || index>=CMINORS){ return -1; } /* first time accessing this device, let's create it */ htty=htty_table[index]; if(htty==NULL){ htty = kmalloc(sizeof(*htty), GFP_KERNEL); if (!htty) return -ENOMEM; //init_MUTEX(&htty->sem); sema_init(&htty->sem,1); htty_table[index] = htty; } memcpy(&htty->termios,&tty_std_termios,sizeof(struct termios)); htty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; htty->open_count = 0; htty->minor=index; tty_port_init(&tty_port[index]); sprintf(ptr,"htty_%s",name); tty_driver->name=ptr; sprintf(htty->name,"%s",ptr); htty->port=&tty_port[index]; tty_port_register_device(&tty_port[index],tty_driver,index, NULL); pr_info(DRIVER_DESC " create device %s minor=%d/n",ptr,index); return 0;}
开发者ID:h-hata,项目名称:htty,代码行数:30,
示例5: srmcons_initstatic int __initsrmcons_init(void){ setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, (unsigned long)&srmcons_singleton); if (srm_is_registered_console) { struct tty_driver *driver; int err; driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES); if (!driver) return -ENOMEM; tty_port_init(&srmcons_singleton.port); driver->driver_name = "srm"; driver->name = "srm"; driver->major = 0; /* dynamic */ driver->minor_start = 0; driver->type = TTY_DRIVER_TYPE_SYSTEM; driver->subtype = SYSTEM_TYPE_SYSCONS; driver->init_termios = tty_std_termios; tty_set_operations(driver, &srmcons_ops); tty_port_link_device(&srmcons_singleton.port, driver, 0); err = tty_register_driver(driver); if (err) { put_tty_driver(driver); tty_port_destroy(&srmcons_singleton.port); return err; } srmcons_driver = driver; } return -ENODEV;}
开发者ID:01org,项目名称:KVMGT-kernel,代码行数:35,
示例6: rs_initint __init rs_init(void){ tty_port_init(&serial_port); serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES); printk ("%s %s/n", serial_name, serial_version); /* Initialize the tty_driver structure */ serial_driver->driver_name = "iss_serial"; serial_driver->name = "ttyS"; serial_driver->major = TTY_MAJOR; serial_driver->minor_start = 64; serial_driver->type = TTY_DRIVER_TYPE_SERIAL; serial_driver->subtype = SERIAL_TYPE_NORMAL; serial_driver->init_termios = tty_std_termios; serial_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; serial_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(serial_driver, &serial_ops); tty_port_link_device(&serial_port, serial_driver, 0); if (tty_register_driver(serial_driver)) panic("Couldn't register serial driver/n"); return 0;}
开发者ID:01org,项目名称:thunderbolt-software-kernel-tree,代码行数:28,
示例7: simrs_initstatic int __init simrs_init(void){ struct serial_state *state; int retval; if (!ia64_platform_is("hpsim")) return -ENODEV; hp_simserial_driver = alloc_tty_driver(NR_PORTS); if (!hp_simserial_driver) return -ENOMEM; printk(KERN_INFO "SimSerial driver with no serial options enabled/n"); /* Initialize the tty_driver structure */ hp_simserial_driver->driver_name = "simserial"; hp_simserial_driver->name = "ttyS"; hp_simserial_driver->major = TTY_MAJOR; hp_simserial_driver->minor_start = 64; hp_simserial_driver->type = TTY_DRIVER_TYPE_SERIAL; hp_simserial_driver->subtype = SERIAL_TYPE_NORMAL; hp_simserial_driver->init_termios = tty_std_termios; hp_simserial_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; hp_simserial_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(hp_simserial_driver, &hp_ops); state = rs_table; tty_port_init(&state->port); state->port.ops = &hp_port_ops; state->port.close_delay = 0; /* XXX really 0? */ retval = hpsim_get_irq(KEYBOARD_INTR); if (retval < 0) { printk(KERN_ERR "%s: out of interrupt vectors!/n", __func__); goto err_free_tty; } state->irq = retval; /* the port is imaginary */ printk(KERN_INFO "ttyS0 at 0x03f8 (irq = %d) is a 16550/n", state->irq); tty_port_link_device(&state->port, hp_simserial_driver, 0); retval = tty_register_driver(hp_simserial_driver); if (retval) { printk(KERN_ERR "Couldn't register simserial driver/n"); goto err_free_tty; } return 0;err_free_tty: put_tty_driver(hp_simserial_driver); tty_port_destroy(&state->port); return retval;}
开发者ID:01org,项目名称:thunderbolt-software-kernel-tree,代码行数:58,
示例8: citty_initstatic int __init citty_init(void){ int retval; int i; F_ENTER(); /* allocate the tty driver */ citty_tty_driver = alloc_tty_driver(CITTY_TTY_MINORS); if (!citty_tty_driver) return -ENOMEM; /* initialize the tty driver */ citty_tty_driver->owner = THIS_MODULE; citty_tty_driver->driver_name = "citty_tty"; citty_tty_driver->name = "citty"; citty_tty_driver->major = CITTY_TTY_MAJOR; citty_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; citty_tty_driver->subtype = SERIAL_TYPE_NORMAL; citty_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; citty_tty_driver->init_termios = tty_std_termios; /* B115200 | CS8 | CREAD | HUPCL | CLOCAL; */ citty_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; citty_tty_driver->init_termios.c_iflag = IGNBRK | IGNCR | IGNPAR; citty_tty_driver->init_termios.c_oflag = 0; citty_tty_driver->init_termios.c_lflag = 0; tty_set_operations(citty_tty_driver, &serial_ops); /* register the tty driver */ retval = tty_register_driver(citty_tty_driver); if (retval) { printk(KERN_ERR "failed to register citty tty driver"); put_tty_driver(citty_tty_driver); citty_tty_driver = NULL; return retval; } /* register tty devices */ for (i = 0; i < CITTY_TTY_MINORS; ++i) { /* Init buffer */ cci_init_buffer(&txCittyBuf[i]); sema_init(&sem_lock_tty[i], 1); tty_port_init(&citty_port_table[i]); tty_port_register_device(&citty_port_table[i], citty_tty_driver, i, NULL); } printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "/n"); cctdev_init_module(); F_LEAVE(); return retval;}
开发者ID:GalaxyTab4,项目名称:maxicm_kernel_samsung_degaswifi,代码行数:56,
示例9: kzallocstatic struct tty_port *stty_port_init(){ struct tty_port *port = NULL; port = kzalloc(sizeof(struct tty_port),GFP_KERNEL); if (port == NULL) { printk(KERN_ERR "stty_port_init Failed to allocate device!/n"); return NULL; } tty_port_init(port); return port;}
开发者ID:ShinySide,项目名称:SM-G361H,代码行数:12,
示例10: pdc_console_tty_driver_initstatic int __init pdc_console_tty_driver_init(void){ int err; /* Check if the console driver is still registered. * It is unregistered if the pdc console was not selected as the * primary console. */ struct console *tmp; console_lock(); for_each_console(tmp) if (tmp == &pdc_cons) break; console_unlock(); if (!tmp) { printk(KERN_INFO "PDC console driver not registered anymore, not creating %s/n", pdc_cons.name); return -ENODEV; } printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag/n"); pdc_cons.flags &= ~CON_BOOT; tty_port_init(&tty_port); pdc_console_tty_driver = alloc_tty_driver(1); if (!pdc_console_tty_driver) return -ENOMEM; pdc_console_tty_driver->driver_name = "pdc_cons"; pdc_console_tty_driver->name = "ttyB"; pdc_console_tty_driver->major = MUX_MAJOR; pdc_console_tty_driver->minor_start = 0; pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; pdc_console_tty_driver->init_termios = tty_std_termios; pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops); tty_port_link_device(&tty_port, pdc_console_tty_driver, 0); err = tty_register_driver(pdc_console_tty_driver); if (err) { printk(KERN_ERR "Unable to register the PDC console TTY driver/n"); return err; } return 0;}
开发者ID:AllenDou,项目名称:linux,代码行数:50,
示例11: uart_register_driverint uart_register_driver(struct uart_driver *drv){ struct tty_driver *normal; int i, retval; BUG_ON(drv->state); drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); if (!drv->state) goto out; normal = alloc_tty_driver(drv->nr); if (!normal) goto out_kfree; drv->tty_driver = normal; normal->driver_name = drv->driver_name; normal->name = drv->dev_name; normal->major = drv->major; normal->minor_start = drv->minor; normal->type = TTY_DRIVER_TYPE_SERIAL; normal->subtype = SERIAL_TYPE_NORMAL; normal->init_termios = tty_std_termios; normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600; normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; normal->driver_state = drv; tty_set_operations(normal, &uart_ops); for (i = 0; i < drv->nr; i++) { struct uart_state *state = drv->state + i; struct tty_port *port = &state->port; tty_port_init(port); port->ops = &uart_port_ops; port->close_delay = HZ / 2; port->closing_wait = 30 * HZ; } retval = tty_register_driver(normal); if (retval >= 0) return retval; put_tty_driver(normal);out_kfree: kfree(drv->state);out: return -ENOMEM;}
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:50,
示例12: tty0tty_initstatic int __init tty0tty_init(void){ int retval; int i; #ifdef SCULL_DEBUG printk(KERN_DEBUG "%s - /n", __FUNCTION__);#endif /* allocate the tty driver */ tty0tty_tty_driver = alloc_tty_driver(TTY0TTY_MINORS); if (!tty0tty_tty_driver) return -ENOMEM; /* initialize the tty driver */ tty0tty_tty_driver->owner = THIS_MODULE; tty0tty_tty_driver->driver_name = "tty0tty"; tty0tty_tty_driver->name = "tnt"; /* no more devfs subsystem */ tty0tty_tty_driver->major = TTY0TTY_MAJOR; tty0tty_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; tty0tty_tty_driver->subtype = SERIAL_TYPE_NORMAL; tty0tty_tty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW ; /* no more devfs subsystem */ tty0tty_tty_driver->init_termios = tty_std_termios; tty0tty_tty_driver->init_termios.c_iflag = 0; tty0tty_tty_driver->init_termios.c_oflag = 0; tty0tty_tty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD; tty0tty_tty_driver->init_termios.c_lflag = 0; tty0tty_tty_driver->init_termios.c_ispeed = 38400; tty0tty_tty_driver->init_termios.c_ospeed = 38400; tty_set_operations(tty0tty_tty_driver, &serial_ops); for(i=0;i<TTY0TTY_MINORS;i++) { tty_port_init(&tport[i]); tty_port_link_device(&tport[i],tty0tty_tty_driver, i); } retval = tty_register_driver(tty0tty_tty_driver); if (retval) { printk(KERN_ERR "failed to register tty0tty tty driver"); put_tty_driver(tty0tty_tty_driver); return retval; } printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "/n"); return retval;}
开发者ID:abrayan,项目名称:tty0tty,代码行数:50,
示例13: my_uart_initstatic int __init my_uart_init(void){ /* TODO Auto-generated Function Stub */ int res; int i; my_uart_tty = alloc_tty_driver(MY_UART_N_MINORS); if (!my_uart_tty) { PERR("TTY Driver allocation failed/n"); return -ENOMEM; } my_uart_tty_initialization(); tty_set_operations(my_uart_tty, &my_uart_tops); res= tty_register_driver(my_uart_tty); if(res) { PERR("Failed to register the tty driver/n"); return res; } for (i = 0; i < MY_UART_N_MINORS; i++) { init_timer(&devices[i].my_uart_timer1); devices[i].my_uart_timer1.data = &devices[i]; //TODO devices[i].my_uart_timer1.function = my_timer; devices[i].my_uart_timer1.expires = jiffies + MY_UART_DELAY_MS * HZ / 1000; tty_port_init(&devices[i].port);#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) tty_register_device(my_uart_tty, i, NULL);#else tty_port_register_device(&devices[i].port, my_uart_tty, i, NULL);#endif } PINFO("INIT/n"); init_timer(&my_uart_timer); my_uart_timer.data = 100; //TODO my_uart_timer.function = my_timer; my_uart_timer.expires = jiffies + MY_UART_DELAY_MS * HZ / 1000; return 0;}
开发者ID:aseyfi,项目名称:linux_device_driver,代码行数:48,
示例14: ttyprintk_initstatic int __init ttyprintk_init(void){ int ret = -ENOMEM; void *rp; ttyprintk_driver = alloc_tty_driver(1); if (!ttyprintk_driver) return ret; ttyprintk_driver->owner = THIS_MODULE; ttyprintk_driver->driver_name = "ttyprintk"; ttyprintk_driver->name = "ttyprintk"; ttyprintk_driver->major = TTYAUX_MAJOR; ttyprintk_driver->minor_start = 3; ttyprintk_driver->num = 1; ttyprintk_driver->type = TTY_DRIVER_TYPE_CONSOLE; ttyprintk_driver->init_termios = tty_std_termios; ttyprintk_driver->init_termios.c_oflag = OPOST | OCRNL | ONOCR | ONLRET; ttyprintk_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; tty_set_operations(ttyprintk_driver, &ttyprintk_ops); ret = tty_register_driver(ttyprintk_driver); if (ret < 0) {; goto error; } /* create our unnumbered device */ rp = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL, ttyprintk_driver->name); if (IS_ERR(rp)) {; ret = PTR_ERR(rp); goto error; } tty_port_init(&tpk_port.port); tpk_port.port.ops = &null_ops; mutex_init(&tpk_port.port_write_mutex); return 0;error: put_tty_driver(ttyprintk_driver); ttyprintk_driver = NULL; return ret;}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:48,
示例15: register_lte_tty_deviceint register_lte_tty_device(struct tty_dev *tty_dev, struct device *device){ struct gdm *gdm; int i; int j; for (i = 0; i < TTY_MAX_COUNT; i++) { gdm = kmalloc(sizeof(struct gdm), GFP_KERNEL); if (!gdm) return -ENOMEM; mutex_lock(&gdm_table_lock); for (j = 0; j < GDM_TTY_MINOR; j++) { if (!gdm_table[i][j]) break; } if (j == GDM_TTY_MINOR) { kfree(gdm); mutex_unlock(&gdm_table_lock); return -EINVAL; } gdm_table[i][j] = gdm; mutex_unlock(&gdm_table_lock); tty_dev->gdm[i] = gdm; tty_port_init(&gdm->port); gdm->port.ops = &gdm_port_ops; gdm->index = i; gdm->minor = j; gdm->tty_dev = tty_dev; tty_port_register_device(&gdm->port, gdm_driver[i], gdm->minor, device); } for (i = 0; i < MAX_ISSUE_NUM; i++) gdm_tty_recv(gdm, gdm_tty_recv_complete); return 0;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:44,
示例16: scc_init_portstructsstatic void __init scc_init_portstructs(void){ struct scc_port *port; int i; for (i = 0; i < 2; i++) { port = scc_ports + i; tty_port_init(&port->gs.port); port->gs.port.ops = &scc_port_ops; port->gs.magic = SCC_MAGIC; port->gs.close_delay = HZ/2; port->gs.closing_wait = 30 * HZ; port->gs.rd = &scc_real_driver;#ifdef NEW_WRITE_LOCKING port->gs.port_write_mutex = MUTEX;#endif init_waitqueue_head(&port->gs.port.open_wait); init_waitqueue_head(&port->gs.port.close_wait); }}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:20,
示例17: kzallocstatic struct raw3215_info *raw3215_alloc_info(void){ struct raw3215_info *info; info = kzalloc(sizeof(struct raw3215_info), GFP_KERNEL | GFP_DMA); if (!info) return NULL; info->buffer = kzalloc(RAW3215_BUFFER_SIZE, GFP_KERNEL | GFP_DMA); info->inbuf = kzalloc(RAW3215_INBUF_SIZE, GFP_KERNEL | GFP_DMA); if (!info->buffer || !info->inbuf) { kfree(info); return NULL; } setup_timer(&info->timer, raw3215_timeout, (unsigned long)info); init_waitqueue_head(&info->empty_wait); tasklet_init(&info->tlet, raw3215_wakeup, (unsigned long)info); tty_port_init(&info->port); return info;}
开发者ID:spacex,项目名称:kernel-centos7,代码行数:22,
示例18: cidatatty_port_allocstatic int cidatatty_port_alloc(unsigned int index){ struct cidatatty_port *cidatatty; int ret = 0; mutex_lock(&cidatatty_table[index].lock); cidatatty = kzalloc(sizeof(struct cidatatty_port), GFP_KERNEL); if (cidatatty == NULL) { ret = -ENOMEM; goto out; } tty_port_init(&cidatatty->port); spin_lock_init(&cidatatty->port_lock); sema_init(&cidatatty->sem_lock_tty, 1); init_waitqueue_head(&cidatatty->wait); cidatatty_table[index].data_port = cidatatty;out: mutex_unlock(&cidatatty_table[index].lock); return ret;}
开发者ID:GalaxyTab4,项目名称:maxicm_kernel_samsung_degaswifi,代码行数:23,
示例19: void/* Diag char driver ready */struct usb_diag_ch *tty_diag_channel_open(const char *name, void *priv, void (*notify)(void *, unsigned, struct diag_request *)){ int i; unsigned long flags; if (legacy_ch.priv != NULL) return ERR_PTR(-EBUSY); spin_lock_init(&diag_tty_lock); spin_lock_irqsave(&diag_tty_lock, flags); legacy_ch.priv = priv; legacy_ch.notify = notify; spin_unlock_irqrestore(&diag_tty_lock, flags); for (i = 0; i < DIAG_TTY_MINOR_COUNT; i++) { tty_port_init(&diag_tty[i].port); tty_port_register_device(&diag_tty[i].port, diag_tty_driver, i, NULL); } return &legacy_ch;}
开发者ID:RoneyThomas,项目名称:linux-kernel-surnia,代码行数:24,
示例20: gs_port_allocstatic intgs_port_alloc(unsigned port_num, struct usb_cdc_line_coding *coding){ struct gs_port *port; int ret = 0; mutex_lock(&ports[port_num].lock); if (ports[port_num].port) { ret = -EBUSY; goto out; } port = kzalloc(sizeof(struct gs_port), GFP_KERNEL); if (port == NULL) { ret = -ENOMEM; goto out; } tty_port_init(&port->port); spin_lock_init(&port->port_lock); init_waitqueue_head(&port->drain_wait); init_waitqueue_head(&port->close_wait); tasklet_init(&port->push, gs_rx_push, (unsigned long) port); INIT_LIST_HEAD(&port->read_pool); INIT_LIST_HEAD(&port->read_queue); INIT_LIST_HEAD(&port->write_pool); port->port_num = port_num; port->port_line_coding = *coding; ports[port_num].port = port;out: mutex_unlock(&ports[port_num].lock); return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:37,
示例21: smbsim_serial_dev_initstatic int smbsim_serial_dev_init(SMBSIM_SERIAL_DEV * dev, int index){ DEV_NODE_PARAMS dev_params; int ret; /* Initialize device node parameters */ memset(&dev_params, 0, sizeof(dev_params)); dev_params.ioctl = smbsim_serial_ioctl; dev_params.ctx = dev; /* Create device node */ dev->dev_node = dev_node_create(smbsim_serial_class, &dev_params); if (dev->dev_node == NULL) { TRACE_MSG(TRACE_LEVEL_ERROR, TRACE_FLAG_DEFAULT, "dev_node_create failed/n"); return -ENOMEM; } /* Initialize virtual serial port */ ret = smbsim_serial_port_init(&dev->port, smbsim_serial_dev_read_handler); if (ret) { TRACE_ERR("smbsim_serial_port_init", ret); goto fail1; } /* Initialize TTY port */ tty_port_init(&dev->tty_port); dev->tty_port.ops = &smbsim_serial_port_ops; tty_port_link_device(&dev->tty_port, smbsim_serial_driver, index); return 0; fail1: dev_node_delete(dev->dev_node); return ret;}
开发者ID:hiro-sakamoto,项目名称:csf,代码行数:37,
示例22: nfcon_initstatic int __init nfcon_init(void){ int res; stderr_id = nf_get_id("NF_STDERR"); if (!stderr_id) return -ENODEV; nfcon_tty_driver = alloc_tty_driver(1); if (!nfcon_tty_driver) return -ENOMEM; tty_port_init(&nfcon_tty_port); nfcon_tty_driver->driver_name = "nfcon"; nfcon_tty_driver->name = "nfcon"; nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; nfcon_tty_driver->subtype = SYSTEM_TYPE_TTY; nfcon_tty_driver->init_termios = tty_std_termios; nfcon_tty_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(nfcon_tty_driver, &nfcon_tty_ops); tty_port_link_device(&nfcon_tty_port, nfcon_tty_driver, 0); res = tty_register_driver(nfcon_tty_driver); if (res) { pr_err("failed to register nfcon tty driver/n"); put_tty_driver(nfcon_tty_driver); tty_port_destroy(&nfcon_tty_port); return res; } if (!(nf_console.flags & CON_ENABLED)) register_console(&nf_console); return 0;}
开发者ID:nearffxx,项目名称:xpenology,代码行数:36,
示例23: shell_initint shell_init(void ) //clean warning{ printk("Enter ecall init/n"); shell_tty_drv = alloc_tty_driver(ES_TTY_MINORS); if (!shell_tty_drv) { printk("Cannot alloc shell tty driver/n"); return -1; } shell_tty_drv->owner = THIS_MODULE; shell_tty_drv->driver_name = "es_serial"; shell_tty_drv->name = "es_tty"; shell_tty_drv->major = ES_TTY_MAJOR; shell_tty_drv->minor_start = 0; shell_tty_drv->type = TTY_DRIVER_TYPE_SERIAL; shell_tty_drv->subtype = SERIAL_TYPE_NORMAL; shell_tty_drv->flags = TTY_DRIVER_REAL_RAW; shell_tty_drv->init_termios = tty_std_termios; shell_tty_drv->init_termios.c_cflag = B921600 | CS8 | CREAD | HUPCL | CLOCAL; tty_set_operations(shell_tty_drv, &shell_ops); tty_port_init(&shell_tty_port); shell_tty_port.ops = &shell_port_ops; tty_port_link_device(&shell_tty_port, shell_tty_drv, 0); if (tty_register_driver(shell_tty_drv)) { printk("Error registering shell tty driver/n"); put_tty_driver(shell_tty_drv); return -1; } printk("Finish ecall init/n"); return 0;}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:36,
示例24: pty_common_install/** * pty_common_install - set up the pty pair * @driver: the pty driver * @tty: the tty being instantiated * @bool: legacy, true if this is BSD style * * Perform the initial set up for the tty/pty pair. Called from the * tty layer when the port is first opened. * * Locking: the caller must hold the tty_mutex */static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, bool legacy){ struct tty_struct *o_tty; struct tty_port *ports[2]; int idx = tty->index; int retval = -ENOMEM; o_tty = alloc_tty_struct(); if (!o_tty) goto err; ports[0] = kmalloc(sizeof **ports, GFP_KERNEL); ports[1] = kmalloc(sizeof **ports, GFP_KERNEL); if (!ports[0] || !ports[1]) goto err_free_tty; if (!try_module_get(driver->other->owner)) { /* This cannot in fact currently happen */ goto err_free_tty; } initialize_tty_struct(o_tty, driver->other, idx); if (legacy) { /* We always use new tty termios data so we can do this the easy way .. */ retval = tty_init_termios(tty); if (retval) goto err_deinit_tty; retval = tty_init_termios(o_tty); if (retval) goto err_free_termios; driver->other->ttys[idx] = o_tty; driver->ttys[idx] = tty; } else { memset(&tty->termios_locked, 0, sizeof(tty->termios_locked)); tty->termios = driver->init_termios; memset(&o_tty->termios_locked, 0, sizeof(tty->termios_locked)); o_tty->termios = driver->other->init_termios; } /* * Everything allocated ... set up the o_tty structure. */ tty_driver_kref_get(driver->other); if (driver->subtype == PTY_TYPE_MASTER) o_tty->count++; /* Establish the links in both directions */ tty->link = o_tty; o_tty->link = tty; tty_port_init(ports[0]); tty_port_init(ports[1]); o_tty->port = ports[0]; tty->port = ports[1]; o_tty->port->itty = o_tty; tty_driver_kref_get(driver); tty->count++; return 0;err_free_termios: if (legacy) tty_free_termios(tty);err_deinit_tty: deinitialize_tty_struct(o_tty); module_put(o_tty->driver->owner);err_free_tty: kfree(ports[0]); kfree(ports[1]); free_tty_struct(o_tty);err: return retval;}
开发者ID:Jlsmily,项目名称:android_kernel_meilan2,代码行数:83,
示例25: tty0tty_initstatic int __init tty0tty_init(void){ int retval; int i; if (pairs > 128) pairs = 128; if (pairs < 1) pairs = 1; tport = kmalloc(2 * pairs * sizeof(struct tty_port), GFP_KERNEL); tty0tty_table = kmalloc(2 * pairs * sizeof(struct tty0tty_serial *), GFP_KERNEL); for (i = 0; i < 2 * pairs; i++) { tty0tty_table[i] = NULL; }#ifdef SCULL_DEBUG printk(KERN_DEBUG "%s - /n", __FUNCTION__);#endif /* allocate the tty driver */ tty0tty_tty_driver = alloc_tty_driver(2 * pairs); if (!tty0tty_tty_driver) return -ENOMEM; /* initialize the tty driver */ tty0tty_tty_driver->owner = THIS_MODULE; tty0tty_tty_driver->driver_name = "tty0tty"; tty0tty_tty_driver->name = "tnt"; /* no more devfs subsystem */ tty0tty_tty_driver->major = TTY0TTY_MAJOR; tty0tty_tty_driver->minor_start = TTY0TTY_MINOR; tty0tty_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; tty0tty_tty_driver->subtype = SERIAL_TYPE_NORMAL; tty0tty_tty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW; /* no more devfs subsystem */ tty0tty_tty_driver->init_termios = tty_std_termios; tty0tty_tty_driver->init_termios.c_iflag = 0; tty0tty_tty_driver->init_termios.c_oflag = 0; tty0tty_tty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD; tty0tty_tty_driver->init_termios.c_lflag = 0; tty0tty_tty_driver->init_termios.c_ispeed = 38400; tty0tty_tty_driver->init_termios.c_ospeed = 38400; tty_set_operations(tty0tty_tty_driver, &serial_ops); for (i = 0; i < 2 * pairs; i++) { tty_port_init(&tport[i]);#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) tty_port_link_device(&tport[i], tty0tty_tty_driver, i);#endif } retval = tty_register_driver(tty0tty_tty_driver); if (retval) { printk(KERN_ERR "failed to register tty0tty tty driver"); put_tty_driver(tty0tty_tty_driver); return retval; } printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "/n"); return retval;}
开发者ID:ReallyNiceGuy,项目名称:tty0tty,代码行数:62,
示例26: nozomi_card_init//.........这里部分代码省略......... ret = -ENODEV; goto err_rel_regs; } /* Find out what card type it is */ nozomi_get_card_type(dc); dc->base_addr = ioremap_nocache(start, dc->card_type); if (!dc->base_addr) { dev_err(&pdev->dev, "Unable to map card MMIO/n"); ret = -ENODEV; goto err_rel_regs; } dc->send_buf = kmalloc(SEND_BUF_MAX, GFP_KERNEL); if (!dc->send_buf) { dev_err(&pdev->dev, "Could not allocate send buffer?/n"); ret = -ENOMEM; goto err_free_sbuf; } for (i = PORT_MDM; i < MAX_PORT; i++) { if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_UL, GFP_KERNEL)) { dev_err(&pdev->dev, "Could not allocate kfifo buffer/n"); ret = -ENOMEM; goto err_free_kfifo; } } spin_lock_init(&dc->spin_mutex); nozomi_setup_private_data(dc); /* Disable all interrupts */ dc->last_ier = 0; writew(dc->last_ier, dc->reg_ier); ret = request_irq(pdev->irq, &interrupt_handler, IRQF_SHARED, NOZOMI_NAME, dc); if (unlikely(ret)) { dev_err(&pdev->dev, "can't request irq %d/n", pdev->irq); goto err_free_kfifo; } DBG1("base_addr: %p", dc->base_addr); make_sysfs_files(dc); dc->index_start = ndev_idx * MAX_PORT; ndevs[ndev_idx] = dc; pci_set_drvdata(pdev, dc); /* Enable RESET interrupt */ dc->last_ier = RESET; iowrite16(dc->last_ier, dc->reg_ier); dc->state = NOZOMI_STATE_ENABLED; for (i = 0; i < MAX_PORT; i++) { struct device *tty_dev; struct port *port = &dc->port[i]; port->dc = dc; tty_port_init(&port->port); port->port.ops = &noz_tty_port_ops; tty_dev = tty_port_register_device(&port->port, ntty_driver, dc->index_start + i, &pdev->dev); if (IS_ERR(tty_dev)) { ret = PTR_ERR(tty_dev); dev_err(&pdev->dev, "Could not allocate tty?/n"); tty_port_destroy(&port->port); goto err_free_tty; } } return 0;err_free_tty: for (i = 0; i < MAX_PORT; ++i) { tty_unregister_device(ntty_driver, dc->index_start + i); tty_port_destroy(&dc->port[i].port); }err_free_kfifo: for (i = 0; i < MAX_PORT; i++) kfifo_free(&dc->port[i].fifo_ul);err_free_sbuf: kfree(dc->send_buf); iounmap(dc->base_addr);err_rel_regs: pci_release_regions(pdev);err_disable_device: pci_disable_device(pdev);err_free: kfree(dc);err: return ret;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:101,
示例27: amiga_serial_probe/* * The serial driver boot-time initialization code! */static int __init amiga_serial_probe(struct platform_device *pdev){ unsigned long flags; struct serial_state * state; int error; serial_driver = alloc_tty_driver(NR_PORTS); if (!serial_driver) return -ENOMEM; show_serial_version(); /* Initialize the tty_driver structure */ serial_driver->driver_name = "amiserial"; serial_driver->name = "ttyS"; serial_driver->major = TTY_MAJOR; serial_driver->minor_start = 64; serial_driver->type = TTY_DRIVER_TYPE_SERIAL; serial_driver->subtype = SERIAL_TYPE_NORMAL; serial_driver->init_termios = tty_std_termios; serial_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; serial_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(serial_driver, &serial_ops); error = tty_register_driver(serial_driver); if (error) goto fail_put_tty_driver; state = rs_table; state->port = (int)&custom.serdatr; /* Just to give it a value */ state->custom_divisor = 0; state->icount.cts = state->icount.dsr = state->icount.rng = state->icount.dcd = 0; state->icount.rx = state->icount.tx = 0; state->icount.frame = state->icount.parity = 0; state->icount.overrun = state->icount.brk = 0; tty_port_init(&state->tport); state->tport.ops = &amiga_port_ops; printk(KERN_INFO "ttyS0 is the amiga builtin serial port/n"); /* Hardware set up */ state->baud_base = amiga_colorclock; state->xmit_fifo_size = 1; /* set ISRs, and then disable the rx interrupts */ error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); if (error) goto fail_unregister; error = request_irq(IRQ_AMIGA_RBF, ser_rx_int, 0, "serial RX", state); if (error) goto fail_free_irq; local_irq_save(flags); /* turn off Rx and Tx interrupts */ custom.intena = IF_RBF | IF_TBE; mb(); /* clear any pending interrupt */ custom.intreq = IF_RBF | IF_TBE; mb(); local_irq_restore(flags); /* * set the appropriate directions for the modem control flags, * and clear RTS and DTR */ ciab.ddra |= (SER_DTR | SER_RTS); /* outputs */ ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */ platform_set_drvdata(pdev, state); return 0;fail_free_irq: free_irq(IRQ_AMIGA_TBE, state);fail_unregister: tty_unregister_driver(serial_driver);fail_put_tty_driver: put_tty_driver(serial_driver); return error;}
开发者ID:kprog,项目名称:linux,代码行数:92,
示例28: ipoctal_inst_slot//.........这里部分代码省略......... struct ipoctal_channel *channel = &ipoctal->channel[i]; channel->regs = chan_regs + i; channel->block_regs = block_regs + (i >> 1); channel->board_id = ipoctal->board_id; if (i & 1) { channel->isr_tx_rdy_mask = ISR_TxRDY_B; channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_B; } else { channel->isr_tx_rdy_mask = ISR_TxRDY_A; channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A; } iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); channel->rx_enable = 0; iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY, &channel->regs->w.mr); /* mr1 */ iowrite8(0, &channel->regs->w.mr); /* mr2 */ iowrite8(TX_CLK_9600 | RX_CLK_9600, &channel->regs->w.csr); } for (i = 0; i < IP_OCTAL_NB_BLOCKS; i++) { iowrite8(ACR_BRG_SET2, &block_regs[i].w.acr); iowrite8(OPCR_MPP_OUTPUT | OPCR_MPOa_RTSN | OPCR_MPOb_RTSN, &block_regs[i].w.opcr); iowrite8(IMR_TxRDY_A | IMR_RxRDY_FFULL_A | IMR_DELTA_BREAK_A | IMR_TxRDY_B | IMR_RxRDY_FFULL_B | IMR_DELTA_BREAK_B, &block_regs[i].w.imr); } /* * IP-OCTAL has different addresses to copy its IRQ vector. * Depending of the carrier these addresses are accesible or not. * More info in the datasheet. */ ipoctal->dev->bus->ops->request_irq(ipoctal->dev, ipoctal_irq_handler, ipoctal); /* Dummy write */ iowrite8(1, ipoctal->mem8_space + 1); /* Register the TTY device */ /* Each IP-OCTAL channel is a TTY port */ tty = alloc_tty_driver(NR_CHANNELS); if (!tty) return -ENOMEM; /* Fill struct tty_driver with ipoctal data */ tty->owner = THIS_MODULE; tty->driver_name = KBUILD_MODNAME; sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot); tty->name = name; tty->major = 0; tty->minor_start = 0; tty->type = TTY_DRIVER_TYPE_SERIAL; tty->subtype = SERIAL_TYPE_NORMAL; tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; tty->init_termios = tty_std_termios; tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; tty->init_termios.c_ispeed = 9600; tty->init_termios.c_ospeed = 9600; tty_set_operations(tty, &ipoctal_fops); res = tty_register_driver(tty); if (res) { dev_err(&ipoctal->dev->dev, "Can't register tty driver./n"); put_tty_driver(tty); return res; } /* Save struct tty_driver for use it when uninstalling the device */ ipoctal->tty_drv = tty; for (i = 0; i < NR_CHANNELS; i++) { struct device *tty_dev; channel = &ipoctal->channel[i]; tty_port_init(&channel->tty_port); tty_port_alloc_xmit_buf(&channel->tty_port); channel->tty_port.ops = &ipoctal_tty_port_ops; ipoctal_reset_stats(&channel->stats); channel->nb_bytes = 0; spin_lock_init(&channel->lock); channel->pointer_read = 0; channel->pointer_write = 0; tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); if (IS_ERR(tty_dev)) { dev_err(&ipoctal->dev->dev, "Failed to register tty device./n"); tty_port_destroy(&channel->tty_port); continue; } dev_set_drvdata(tty_dev, channel); } return 0;}
开发者ID:03199618,项目名称:linux,代码行数:101,
注:本文中的tty_port_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tty_port_tty_get函数代码示例 C++ tty_name函数代码示例 |