当前位置: 首页>>代码示例>>C++>>正文


C++ put_tty_driver函数代码示例

本文整理汇总了C++中put_tty_driver函数的典型用法代码示例。如果您正苦于以下问题:C++ put_tty_driver函数的具体用法?C++ put_tty_driver怎么用?C++ put_tty_driver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了put_tty_driver函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ec_tty_cleanup_module

/** Module cleanup.
 *
 * Clears all master instances.
 */
void __exit ec_tty_cleanup_module(void)
{
    tty_unregister_driver(tty_driver);
    put_tty_driver(tty_driver);
    printk(KERN_INFO PFX "Module unloading.\n");
}
开发者ID:BlastTNG,项目名称:flight,代码行数:10,代码来源:module.c

示例2: lge_dm_tty_init

static int __init lge_dm_tty_init(void)
{
	int i, ret = 0;
	struct device *tty_dev;
	struct dm_tty *lge_dm_tty_drv;

	pr_info(DM_TTY_MODULE_NAME ": %s\n", __func__);

	lge_dm_tty_drv = kzalloc(sizeof(struct dm_tty), GFP_KERNEL);
	if (lge_dm_tty_drv == NULL) {
		pr_info(DM_TTY_MODULE_NAME "%s:"
		"failed to allocate lge_dm_tty", __func__);
		return 0;
	}

	lge_dm_tty = lge_dm_tty_drv;

	lge_dm_tty_drv->tty_drv = alloc_tty_driver(MAX_DM_TTY_DRV);

	if (!lge_dm_tty_drv->tty_drv) {
		pr_info(DM_TTY_MODULE_NAME ": %s - tty_drv is NULL", __func__);
		kfree(lge_dm_tty_drv);
		return 0;
	}

	lge_dm_tty_drv->tty_drv->name = "lge_dm_tty";
	lge_dm_tty_drv->tty_drv->owner = THIS_MODULE;
	lge_dm_tty_drv->tty_drv->driver_name = "lge_dm_tty";
	/* uses dynamically assigned dev_t values */
	lge_dm_tty_drv->tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
	lge_dm_tty_drv->tty_drv->subtype = SERIAL_TYPE_NORMAL;
	lge_dm_tty_drv->tty_drv->flags = TTY_DRIVER_REAL_RAW
		| TTY_DRIVER_DYNAMIC_DEV
		| TTY_DRIVER_RESET_TERMIOS;

	/* initializing the tty driver */
	lge_dm_tty_drv->tty_drv->init_termios = tty_std_termios;
	lge_dm_tty_drv->tty_drv->init_termios.c_iflag = IGNBRK | IGNPAR;
	lge_dm_tty_drv->tty_drv->init_termios.c_oflag = 0;
	lge_dm_tty_drv->tty_drv->init_termios.c_cflag =
		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	lge_dm_tty_drv->tty_drv->init_termios.c_lflag = 0;

	tty_set_operations(lge_dm_tty_drv->tty_drv, &lge_dm_tty_ops);

	ret = tty_register_driver(lge_dm_tty_drv->tty_drv);

	if (ret) {
		put_tty_driver(lge_dm_tty_drv->tty_drv);
		pr_info(DM_TTY_MODULE_NAME ": %s:"
		"tty_register_driver() ""failed\n",
			__func__);

		lge_dm_tty_drv->tty_drv = NULL;
		kfree(lge_dm_tty_drv);
		return 0;
	}

	tty_dev = tty_register_device(lge_dm_tty_drv->tty_drv, 0, NULL);

	if (IS_ERR(tty_dev)) {
		pr_info(DM_TTY_MODULE_NAME ": %s:"
		"tty_register_device() " "failed\n",
			__func__);
		tty_unregister_driver(lge_dm_tty_drv->tty_drv);
		put_tty_driver(lge_dm_tty_drv->tty_drv);
		kfree(lge_dm_tty_drv);
		return 0;
	}

	init_waitqueue_head(&lge_dm_tty_drv->waitq);

	lge_dm_tty_drv->tty_state = DM_TTY_REGISTERED;

	/* data initialization */
	dm_modem_response = kzalloc(DM_TTY_TX_MAX_PACKET_SIZE, GFP_KERNEL);
	if (dm_modem_response == NULL)
		pr_info(DM_TTY_MODULE_NAME ": %s: dm_modem_response ""failed\n",
			__func__);

	dm_modem_request = kzalloc(DM_TTY_RX_MAX_PACKET_SIZE, GFP_KERNEL);
	if (dm_modem_request == NULL)
		pr_info(DM_TTY_MODULE_NAME ": %s: dm_modem_request ""failed\n",
			__func__);

	dm_modem_response_header_length = sizeof(struct dm_router_header);
	dm_modem_response_header = kzalloc(dm_modem_response_header_length,
		GFP_KERNEL);
	if (dm_modem_response_header == NULL)
		pr_info(DM_TTY_MODULE_NAME ": %s: dm_modem_response_header "
			"failed\n", __func__);

	dm_modem_request_header_length = sizeof(struct dm_router_header);
	dm_modem_request_header = kzalloc(dm_modem_request_header_length,
		GFP_KERNEL);
	if (dm_modem_request_header == NULL)
		pr_info(DM_TTY_MODULE_NAME ": %s: dm_modem_request_header "
			"failed\n", __func__);

	dm_modem_response_body_length =
//.........这里部分代码省略.........
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:101,代码来源:lg_dm_tty.c

示例3: gserial_setup

/**
 * gserial_setup - initialize TTY driver for one or more ports
 * @g: gadget to associate with these ports
 * @count: how many ports to support
 * Context: may sleep
 *
 * The TTY stack needs to know in advance how many devices it should
 * plan to manage.  Use this call to set up the ports you will be
 * exporting through USB.  Later, connect them to functions based
 * on what configuration is activated by the USB host; and disconnect
 * them as appropriate.
 *
 * An example would be a two-configuration device in which both
 * configurations expose port 0, but through different functions.
 * One configuration could even expose port 1 while the other
 * one doesn't.
 *
 * Returns negative errno or zero.
 */
int gserial_setup(struct usb_gadget *g, unsigned count)
{
	unsigned			i;
	struct usb_cdc_line_coding	coding;
	int				status;

	if (count == 0 || count > N_PORTS)
		return -EINVAL;

	gs_tty_driver = alloc_tty_driver(count);
	if (!gs_tty_driver)
		return -ENOMEM;

	gs_tty_driver->driver_name = "g_serial";
	gs_tty_driver->name = PREFIX;
	/* uses dynamically assigned dev_t values */

	gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
	gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
	gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
	gs_tty_driver->init_termios = tty_std_termios;

	/* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on
	 * MS-Windows.  Otherwise, most of these flags shouldn't affect
	 * anything unless we were to actually hook up to a serial line.
	 */
	gs_tty_driver->init_termios.c_cflag =
			B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	gs_tty_driver->init_termios.c_ispeed = 9600;
	gs_tty_driver->init_termios.c_ospeed = 9600;

	coding.dwDTERate = cpu_to_le32(9600);
	coding.bCharFormat = 8;
	coding.bParityType = USB_CDC_NO_PARITY;
	coding.bDataBits = USB_CDC_1_STOP_BITS;

	tty_set_operations(gs_tty_driver, &gs_tty_ops);

	/* make devices be openable */
	for (i = 0; i < count; i++) {
		mutex_init(&ports[i].lock);
		status = gs_port_alloc(i, &coding);
		if (status) {
			count = i;
			goto fail;
		}
	}
	n_ports = count;

	/* export the driver ... */
	status = tty_register_driver(gs_tty_driver);
	if (status) {
		pr_err("%s: cannot register, err %d\n",
				__func__, status);
		goto fail;
	}

	/* ... and sysfs class devices, so mdev/udev make /dev/ttyGS* */
	for (i = 0; i < count; i++) {
		struct device	*tty_dev;

		tty_dev = tty_register_device(gs_tty_driver, i, &g->dev);
		if (IS_ERR(tty_dev))
			pr_warning("%s: no classdev for port %d, err %ld\n",
				__func__, i, PTR_ERR(tty_dev));
	}

	pr_debug("%s: registered %d ttyGS* device%s\n", __func__,
			count, (count == 1) ? "" : "s");

	return status;
fail:
	while (count--)
		kfree(ports[count].port);
	put_tty_driver(gs_tty_driver);
	gs_tty_driver = NULL;
	return status;
}
开发者ID:birey,项目名称:android_kernel_samsung_kyleproxx,代码行数:97,代码来源:u_serial.c

示例4: ehv_bc_exit

/**
 * ehv_bc_exit - ePAPR hypervisor byte channel driver termination
 *
 * This function is called when this driver is unloaded.
 */
static void __exit ehv_bc_exit(void)
{
	tty_unregister_driver(ehv_bc_driver);
	put_tty_driver(ehv_bc_driver);
	kfree(bcs);
}
开发者ID:realmz,项目名称:blackfin-linux,代码行数:11,代码来源:ehv_bytechan.c

示例5: smd_tty_init

static int __init smd_tty_init(void)
{
	int ret;
	int n;
	int idx;

	smd_tty_driver = alloc_tty_driver(MAX_SMD_TTYS);
	if (smd_tty_driver == 0)
		return -ENOMEM;

	smd_tty_driver->owner = THIS_MODULE;
	smd_tty_driver->driver_name = "smd_tty_driver";
	smd_tty_driver->name = "smd";
	smd_tty_driver->major = 0;
	smd_tty_driver->minor_start = 0;
	smd_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
	smd_tty_driver->subtype = SERIAL_TYPE_NORMAL;
	smd_tty_driver->init_termios = tty_std_termios;
	smd_tty_driver->init_termios.c_iflag = 0;
	smd_tty_driver->init_termios.c_oflag = 0;
	smd_tty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
	smd_tty_driver->init_termios.c_lflag = 0;
	smd_tty_driver->flags = TTY_DRIVER_RESET_TERMIOS |
		TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
	tty_set_operations(smd_tty_driver, &smd_tty_ops);

	ret = tty_register_driver(smd_tty_driver);
	if (ret) {
		put_tty_driver(smd_tty_driver);
		pr_err("%s: driver registration failed %d\n", __func__, ret);
		return ret;
	}

	for (n = 0; n < ARRAY_SIZE(smd_configs); ++n) {
		idx = smd_configs[n].tty_dev_index;

		if (smd_configs[n].dev_name == NULL)
			smd_configs[n].dev_name = smd_configs[n].port_name;

		if (idx == DS_IDX) {
			/*
			 * DS port uses the kernel API starting with
			 * 8660 Fusion.  Only register the userspace
			 * platform device for older targets.
			 */
			int legacy_ds = 0;

			legacy_ds |= cpu_is_msm7x01() || cpu_is_msm7x25();
			legacy_ds |= cpu_is_msm7x27() || cpu_is_msm7x30();
			legacy_ds |= cpu_is_qsd8x50() || cpu_is_msm8x55();
			/*
			 * use legacy mode for 8660 Standalone (subtype 0)
			 */
			legacy_ds |= cpu_is_msm8x60() &&
					(socinfo_get_platform_subtype() == 0x1);
			if (!legacy_ds)
				continue;
		}

		tty_register_device(smd_tty_driver, idx, 0);
		init_completion(&smd_tty[idx].ch_allocated);

		/* register platform device */
		smd_tty[idx].driver.probe = smd_tty_dummy_probe;
		smd_tty[idx].driver.driver.name = smd_configs[n].dev_name;
		smd_tty[idx].driver.driver.owner = THIS_MODULE;
		spin_lock_init(&smd_tty[idx].reset_lock);
		smd_tty[idx].is_open = 0;
		init_waitqueue_head(&smd_tty[idx].ch_opened_wait_queue);
		ret = platform_driver_register(&smd_tty[idx].driver);

		if (ret) {
			pr_err("%s: init failed %d (%d)\n", __func__, idx, ret);
			smd_tty[idx].driver.probe = NULL;
			goto out;
		}
		smd_tty[idx].smd = &smd_configs[n];
	}
	INIT_DELAYED_WORK(&loopback_work, loopback_probe_worker);
	return 0;

out:
	/* unregister platform devices */
	for (n = 0; n < ARRAY_SIZE(smd_configs); ++n) {
		idx = smd_configs[n].tty_dev_index;

		if (smd_tty[idx].driver.probe) {
			platform_driver_unregister(&smd_tty[idx].driver);
			tty_unregister_device(smd_tty_driver, idx);
		}
	}

	tty_unregister_driver(smd_tty_driver);
	put_tty_driver(smd_tty_driver);
	return ret;
}
开发者ID:antinarcoba,项目名称:mediapad-kernel,代码行数:96,代码来源:smd_tty.c

示例6: rs68328_init

/* rs_init inits the driver */
static int __init
rs68328_init(void)
{
    int flags, i;
    struct m68k_serial *info;

    serial_driver = alloc_tty_driver(NR_PORTS);
    if (!serial_driver)
        return -ENOMEM;

    show_serial_version();

    /* Initialize the tty_driver structure */
    /* SPARC: Not all of this is exactly right for us. */

    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 =
        m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
    serial_driver->flags = TTY_DRIVER_REAL_RAW;
    tty_set_operations(serial_driver, &rs_ops);

    local_irq_save(flags);

    for(i=0; i<NR_PORTS; i++) {

        info = &m68k_soft[i];
        info->magic = SERIAL_MAGIC;
        info->port = (int) &uart_addr[i];
        info->tty = NULL;
        info->irq = uart_irqs[i];
        info->custom_divisor = 16;
        info->close_delay = 50;
        info->closing_wait = 3000;
        info->x_char = 0;
        info->event = 0;
        info->count = 0;
        info->blocked_open = 0;
        init_waitqueue_head(&info->open_wait);
        init_waitqueue_head(&info->close_wait);
        info->line = i;
        info->is_cons = 1; /* Means shortcuts work */

        printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
               info->port, info->irq);
        printk(" is a builtin MC68328 UART\n");

#ifdef CONFIG_M68VZ328
        if (i > 0 )
            PJSEL &= 0xCF;  /* PSW enable second port output */
#endif

        if (request_irq(uart_irqs[i],
                        rs_interrupt,
                        0,
                        "M68328_UART", info))
            panic("Unable to attach 68328 serial interrupt\n");

        tty_port_link_device(&info->tport, serial_driver, i);
    }
    local_irq_restore(flags);

    if (tty_register_driver(serial_driver)) {
        put_tty_driver(serial_driver);
        printk(KERN_ERR "Couldn't register serial driver\n");
        return -ENOMEM;
    }

    return 0;
}
开发者ID:sombree,项目名称:Hulk-Kernel-V2,代码行数:75,代码来源:68328serial.c

示例7: smd_tty_init

static int __init smd_tty_init(void)
{
	int ret;
	int n;
	int idx;

	smd_tty_driver = alloc_tty_driver(MAX_SMD_TTYS);
	if (smd_tty_driver == 0)
		return -ENOMEM;

	smd_tty_driver->owner = THIS_MODULE;
	smd_tty_driver->driver_name = "smd_tty_driver";
	smd_tty_driver->name = "smd";
	smd_tty_driver->major = 0;
	smd_tty_driver->minor_start = 0;
	smd_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
	smd_tty_driver->subtype = SERIAL_TYPE_NORMAL;
	smd_tty_driver->init_termios = tty_std_termios;
	smd_tty_driver->init_termios.c_iflag = 0;
	smd_tty_driver->init_termios.c_oflag = 0;
	smd_tty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
	smd_tty_driver->init_termios.c_lflag = 0;
	smd_tty_driver->flags = TTY_DRIVER_RESET_TERMIOS |
		TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
	tty_set_operations(smd_tty_driver, &smd_tty_ops);

	ret = tty_register_driver(smd_tty_driver);
	if (ret) {
		put_tty_driver(smd_tty_driver);
		pr_err("%s: driver registration failed %d\n", __func__, ret);
		return ret;
	}

	for (n = 0; n < ARRAY_SIZE(smd_configs); ++n) {
		idx = smd_configs[n].tty_dev_index;

		if (smd_configs[n].dev_name == NULL)
			smd_configs[n].dev_name = smd_configs[n].port_name;

		if (idx == DS_IDX) {
			int legacy_ds = 0;

			legacy_ds |= cpu_is_msm7x01() || cpu_is_msm7x25();
			legacy_ds |= cpu_is_msm7x27() || cpu_is_msm7x30();
			legacy_ds |= cpu_is_qsd8x50() || cpu_is_msm8x55();
			legacy_ds |= (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm8930aa());
			legacy_ds |= cpu_is_msm8x60() &&
					(socinfo_get_platform_subtype() == 0x0);
			#ifdef CONFIG_MACH_DUMMY
			legacy_ds = 1;
			#endif

			if (!legacy_ds)
				continue;
		}

		tty_register_device(smd_tty_driver, idx, 0);
		init_completion(&smd_tty[idx].ch_allocated);

		
		smd_tty[idx].driver.probe = smd_tty_dummy_probe;
		smd_tty[idx].driver.driver.name = smd_configs[n].dev_name;
		smd_tty[idx].driver.driver.owner = THIS_MODULE;
		spin_lock_init(&smd_tty[idx].reset_lock);
		smd_tty[idx].is_open = 0;
		setup_timer(&smd_tty[idx].buf_req_timer, buf_req_retry,
				(unsigned long)&smd_tty[idx]);
		init_waitqueue_head(&smd_tty[idx].ch_opened_wait_queue);
		ret = platform_driver_register(&smd_tty[idx].driver);

		if (ret) {
			pr_err("%s: init failed %d (%d)\n", __func__, idx, ret);
			smd_tty[idx].driver.probe = NULL;
			goto out;
		}
		smd_tty[idx].smd = &smd_configs[n];
	}
	INIT_DELAYED_WORK(&loopback_work, loopback_probe_worker);
	return 0;

out:
	
	for (n = 0; n < ARRAY_SIZE(smd_configs); ++n) {
		idx = smd_configs[n].tty_dev_index;

		if (smd_tty[idx].driver.probe) {
			platform_driver_unregister(&smd_tty[idx].driver);
			tty_unregister_device(smd_tty_driver, idx);
		}
	}

	tty_unregister_driver(smd_tty_driver);
	put_tty_driver(smd_tty_driver);
	return ret;
}
开发者ID:Backspace-Dev,项目名称:x920d-jp,代码行数:95,代码来源:smd_tty.c

示例8: atcmd_setup

int atcmd_setup(struct usb_gadget *g)
{
    struct device *tty_dev;
    int status;

    at_tty_driver = alloc_tty_driver(1);
    if (!at_tty_driver)
        return -ENOMEM;

    at_tty_driver->driver_name = "at_serial";
    at_tty_driver->name = AT_PREFIX;
    /* uses dynamically assigned dev_t values */

    at_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
    at_tty_driver->subtype = SERIAL_TYPE_NORMAL;
    at_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV
        | TTY_DRIVER_RESET_TERMIOS;
    at_tty_driver->init_termios = tty_std_termios;

    /* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on
     * MS-Windows.  Otherwise, most of these flags shouldn't affect
     * anything unless we were to actually hook up to a serial line.
     */
    at_tty_driver->init_termios.c_cflag =
        B9600 | CS8 | CREAD | HUPCL | CLOCAL;
    at_tty_driver->init_termios.c_ispeed = 9600;
    at_tty_driver->init_termios.c_ospeed = 9600;

    tty_set_operations(at_tty_driver, &at_tty_ops);

    /* make devices be openable */
    mutex_init(&gdata_ports[0].port->tty_lock);

    /* export the driver ... */
    status = tty_register_driver(at_tty_driver);
    if (status) {
        put_tty_driver(at_tty_driver);
        pr_err("%s: cannot register, err %d\n",
                __func__, status);
        goto fail;
    }

    /* ... and sysfs class devices, so mdev/udev make /dev/ttyGS* */
    tty_dev = tty_register_device(at_tty_driver, 0, &g->dev);
    if (IS_ERR(tty_dev))
        pr_warning("%s: no classdev, err %ld\n", __func__, PTR_ERR(tty_dev));

#ifdef ENABLE_DUMMY_HSIC_TTY
    status = hsic_setup(g);
    if (status)
        goto fail;
#endif

    pr_debug("%s: registered ttyGS0 device\n", __func__);

    return status;
fail:
    put_tty_driver(at_tty_driver);
    at_tty_driver = NULL;
    return status;
}
开发者ID:Loller79,项目名称:Solid_Kernel-STOCK-KK-CAF,代码行数:61,代码来源:u_atcmd.c

示例9: ipoctal_install_all

static int ipoctal_install_all(void)
{
	int i, j, t;
	int res = 0;
	struct tty_driver *tty;
	char name[20] = "";

	ipoctal_installed = (struct ipoctal*) kzalloc(num_lun * sizeof(struct ipoctal), GFP_KERNEL);
	if (ipoctal_installed == NULL) {
		printk(KERN_ERR PFX "Unable to allocate memory for ipoctal's !\n");
		res = -ENOMEM;
		goto out_err;
	}

	for (i=0; i<num_lun;i++) {
		tty = alloc_tty_driver(NR_CHANNELS);

		if(!tty)
			return -ENOMEM;

		tty->owner = THIS_MODULE;
		tty->driver_name = "ipoctal";
		sprintf(name, "ipoctal.%d.", lun[i]);
		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->init_termios.c_iflag = tty_std_termios.c_iflag | IGNBRK;

		tty_set_operations(tty, &ipoctalFops);
		res = tty_register_driver(tty);
		if(res) {
			printk(KERN_ERR PFX "Can't register tty driver.\n");
			put_tty_driver(tty);
			goto out_uninst;
		}

		for(j = 0; j < NR_CHANNELS;j++) {
			tty_register_device(tty, j, NULL);
			ipoctal_installed[i].tty[j] = NULL;
			spin_lock_init(&ipoctal_installed[i].lock[j]);
			mutex_init(&ipoctal_installed[i].lock_write[j]);
			ipoctal_installed[i].pointer_read[j] = 0;
			ipoctal_installed[i].pointer_write[j] = 0;
			ipoctal_installed[i].nb_bytes[j] = 0;
		}
		ipoctal_installed[i].tty_drv = tty;
		ipoctal_installed[i].index = i;

		res = ipoctal_inst_slot(&ipoctal_installed[i],
				carrier_number[i],
				slot[i],
				irq[i],
				carrier[i]);
		if (res) {
			printk(KERN_ERR PFX "Error during IP octal install !\n");
			goto out_uninst;
		}	
	}

	return 0;

out_uninst :
	for (j=0; j < i;j++){
		for (t = 0; t < NR_CHANNELS; t++)
			tty_unregister_device(ipoctal_installed[j].tty_drv, t);
		tty_unregister_driver(ipoctal_installed[j].tty_drv);
		ipoctal_uninst_slot(&ipoctal_installed[j]);
	}
	kfree(ipoctal_installed);
	ipoctal_installed = NULL;
	printk(KERN_ERR PFX "Unregistered all IP octal devices\n");
out_err :
	return res;
}
开发者ID:dcobas,项目名称:coht,代码行数:82,代码来源:ipoctal_drvr.c

示例10: spi_tty_init

static int __init spi_tty_init(void)
{
	int retval;
	struct spi_tty_s *spi_tty;

	SPI_IPC_INFO("%s\n", __func__);

	tx_size = 0L;
	tx_time = 0L;
	tx_count = 0L;
	write_count = 0L;

	spi_tty_gbl = kmalloc(sizeof(*spi_tty), GFP_KERNEL);
	if (spi_tty_gbl == NULL) {
		pr_err("%s: Cannot malloc mem!\n", __func__);
		return -ENOMEM;
	}

	memset(spi_tty_gbl, 0x0, sizeof(*spi_tty));
	spi_tty = spi_tty_gbl;
	SPI_IPC_INFO("spi_tty=%p\n", spi_tty);

	spi_tty->write_buf = spi_tty_buf_alloc();
	if (!spi_tty->write_buf) {
		kfree(spi_tty_gbl);
		pr_err("failed to malloc spi_tty write buf!\n");
		return -ENOMEM;
	}

	spi_tty->throttle = 0;
	spi_tty->open_count = 0;
	spi_tty->tx_null = 0;
	spin_lock_init(&spi_tty->port_lock);
	mutex_init(&spi_tty->work_lock);
	INIT_WORK(&spi_tty->write_work, spi_tty_write_worker);
	wake_lock_init(&spi_tty->wakelock, WAKE_LOCK_SUSPEND, "spi_tty_wakelock");

	init_waitqueue_head(&spi_tty->write_wait);
	spi_tty->write_buf_full = 0;

	spi_tty->work_queue = create_singlethread_workqueue("spi_tty_wq");
	if (spi_tty->work_queue  == NULL) {
		kfree(spi_tty);
		kfree(spi_big_trans.tx_buf);
		pr_err("Failed to create work queue\n");
		return -ESRCH;
	}

	spi_slave_message_init(&spi_big_msg);

	spi_big_trans.tx_buf = kmalloc(SPI_TRANSACTION_LEN*2, GFP_KERNEL);
	if (!spi_big_trans.tx_buf) {
		kfree(spi_tty);
		pr_err("%s: Cannot malloc mem!\n", __func__);
		return -ENOMEM;
	}

	spi_big_trans.rx_buf = spi_big_trans.tx_buf + SPI_TRANSACTION_LEN;
	spi_slave_message_add_tail(&spi_big_trans, &spi_big_msg);

	spi_tty_driver = alloc_tty_driver(SPI_TTY_MINORS);
	if (!spi_tty_driver)
		return -ENOMEM;

	spi_tty_driver->owner = THIS_MODULE;
	spi_tty_driver->driver_name = "spi_modem";
	spi_tty_driver->name = "ttySPI";
	spi_tty_driver->major = SPI_TTY_MAJOR;
	spi_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
	spi_tty_driver->subtype = SERIAL_TYPE_NORMAL;
	spi_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
	spi_tty_driver->init_termios = tty_std_termios;
	spi_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	tty_set_operations(spi_tty_driver, &serial_ops);

	retval = tty_register_driver(spi_tty_driver);
	if (retval) {
		pr_err("failed to register spi_tty tty driver");
		put_tty_driver(spi_tty_driver);
		return retval;
	}

	tty_register_device(spi_tty_driver, 0, NULL);

	// Depends on module_init() call sequence, mdm6600_dev_probe may
	mdm6600_spi_dev.cb_context = spi_tty;
	//mdm6600_spi_dev.callback = spi_tty_handle_data;
	mdm6600_spi_dev.callback = NULL;
	mdm6600_spi_dev.handle_master_mrdy = spi_tty_handle_mrdy;
	spi_tty->spi_slave_dev = &mdm6600_spi_dev;

	return retval;
}
开发者ID:Atrix-Dev-Team,项目名称:kernel-MB860,代码行数:93,代码来源:spi_tty.c

示例11: lge_bypass_init

static int __init lge_bypass_init(void)
{
    int ret = 0;

    struct device *tty_dev = NULL;
    struct bypass_driver *bypass_drv = NULL;

    pr_info("%s\n", __func__);

    bypass_drv = kzalloc(sizeof(struct bypass_driver), GFP_KERNEL);
    if (!bypass_drv) {
        pr_err( "%s: memory alloc fail\n", __func__);
        return 0;
    }

    bypass_drv->tty_drv = alloc_tty_driver(BYPASS_MAX_DRV);
    if(!bypass_drv->tty_drv) {
        pr_err( "%s: tty alloc driver fail\n", __func__);
        kfree(bypass_drv);
        return 0;
    }

    bypass_drv->port = kzalloc(sizeof(struct tty_port), GFP_KERNEL);
    if(!bypass_drv->port) {
        pr_err( "%s: memory alloc port fail\n", __func__);
        kfree(bypass_drv->tty_drv);
        kfree(bypass_drv);
        return 0;
    }
    tty_port_init(bypass_drv->port);

    lge_bypass_drv = bypass_drv;

    bypass_drv->tty_drv->name = "lge_diag_bypass";
    bypass_drv->tty_drv->owner = THIS_MODULE;
    bypass_drv->tty_drv->driver_name = "lge_diag_bypass";

    bypass_drv->tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
    bypass_drv->tty_drv->subtype = SERIAL_TYPE_NORMAL;
    bypass_drv->tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_RESET_TERMIOS;

    bypass_drv->tty_drv->init_termios = tty_std_termios;
    bypass_drv->tty_drv->init_termios.c_iflag = IGNBRK | IGNPAR;
    bypass_drv->tty_drv->init_termios.c_oflag = 0;
    bypass_drv->tty_drv->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
    bypass_drv->tty_drv->init_termios.c_lflag = 0;

    tty_set_operations(bypass_drv->tty_drv, &lge_bypass_ops);
#if defined(CONFIG_ARCH_MSM8916) || defined(CONFIG_ARCH_APQ8084) || defined(CONFIG_ARCH_ODIN)
    tty_port_link_device(bypass_drv->port, bypass_drv->tty_drv, 0);
#endif
    ret = tty_register_driver(bypass_drv->tty_drv);

    if (ret) {
        pr_err("%s: fail to tty_register_driver\n", __func__);
        put_tty_driver(bypass_drv->tty_drv);
#if defined(CONFIG_ARCH_MSM8916) || defined(CONFIG_ARCH_APQ8084) || defined(CONFIG_ARCH_ODIN)
        tty_port_destroy(bypass_drv->port);
#endif
        bypass_drv->tty_drv = NULL;
        kfree(bypass_drv->port);
        kfree(bypass_drv);
        return 0;
    }

    tty_dev = tty_register_device(bypass_drv->tty_drv, 0, NULL);

    if (IS_ERR(tty_dev)) {
        pr_err("%s: fail to tty_register_device\n", __func__);
        tty_unregister_driver(bypass_drv->tty_drv);
        put_tty_driver(bypass_drv->tty_drv);
#if defined(CONFIG_ARCH_MSM8916) || defined(CONFIG_ARCH_APQ8084) || defined(CONFIG_ARCH_ODIN)
        tty_port_destroy(bypass_drv->port);
#endif
        kfree(bypass_drv->port);
        kfree(bypass_drv);
        return 0;
    }

    bypass_drv->enable = 0;

    pr_info( "%s: success\n", __func__);

    return 0;
}
开发者ID:MH2033,项目名称:VIPER_KERNEL_LP_D802,代码行数:85,代码来源:lg_diag_bypass.c

示例12: qcnmea_exit

}

static void __exit qcnmea_exit()
{
    tty_unregister_driver(qcnmea_tty_driver);
    put_tty_driver(qcnmea_tty_driver);
开发者ID:vickylinuxer,项目名称:at91sam9263-kernel,代码行数:6,代码来源:qct-nmea.c

示例13: mts_tty_init

static int __init mts_tty_init(void)
{
	int ret = 0;
	struct device *tty_dev =  NULL;
	struct mts_tty *mts_tty_drv = NULL;

	mts_tty_drv = kzalloc(sizeof(struct mts_tty), GFP_KERNEL);

	if (mts_tty_drv == NULL) {
		printk( "mts_tty_init: memory alloc fail %d - %d\n", 0, 0);
		return 0;
	}

	mts_tty_drv->mts_tty_port = kzalloc(sizeof(struct tty_port), GFP_KERNEL);

	if (mts_tty_drv->mts_tty_port == NULL) {
		printk( "mts_tty_init: memory alloc fail %d - %d\n", 0, 0);
		kfree(mts_tty_drv);
		return 0;
	}

	tty_port_init(mts_tty_drv->mts_tty_port);

	mts_tty = mts_tty_drv;
	mts_tty_drv->tty_drv = alloc_tty_driver(MAX_DIAG_MTS_DRV);

	if (!mts_tty_drv->tty_drv) {
		printk( "mts_tty_init: tty alloc driver fail %d - %d\n", 1, 0);
		kfree(mts_tty_drv->mts_tty_port);
		kfree(mts_tty_drv);
		return 0;
	}

	mts_tty_drv->tty_drv->name = "mts_tty";
	mts_tty_drv->tty_drv->owner = THIS_MODULE;
	mts_tty_drv->tty_drv->driver_name = "mts_tty";

	/* uses dynamically assigned dev_t values */
	mts_tty_drv->tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
	mts_tty_drv->tty_drv->subtype = SERIAL_TYPE_NORMAL;
	mts_tty_drv->tty_drv->flags = TTY_DRIVER_REAL_RAW |
				       TTY_DRIVER_DYNAMIC_DEV |
				       TTY_DRIVER_RESET_TERMIOS;

	/* initializing the mts driver */
	mts_tty_drv->tty_drv->init_termios = tty_std_termios;
	mts_tty_drv->tty_drv->init_termios.c_iflag = IGNBRK | IGNPAR;
	mts_tty_drv->tty_drv->init_termios.c_oflag = 0;
	mts_tty_drv->tty_drv->init_termios.c_cflag =
		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	mts_tty_drv->tty_drv->init_termios.c_lflag = 0;

	tty_set_operations(mts_tty_drv->tty_drv, &mts_tty_ops);
	tty_port_link_device(mts_tty_drv->mts_tty_port, mts_tty_drv->tty_drv, 0);
	ret = tty_register_driver(mts_tty_drv->tty_drv);

	if (ret) {
		printk("fail to mts tty_register_driver\n");
		put_tty_driver(mts_tty_drv->tty_drv);
		tty_port_destroy(mts_tty_drv->mts_tty_port);
		mts_tty_drv->tty_drv = NULL;
		kfree(mts_tty_drv->mts_tty_port);
		kfree(mts_tty_drv);
		return 0;
	}

	tty_dev = tty_register_device(mts_tty_drv->tty_drv, 0, NULL);

	if (IS_ERR(tty_dev)) {
		printk("fail to mts tty_register_device\n");
		tty_unregister_driver(mts_tty_drv->tty_drv);
		put_tty_driver(mts_tty_drv->tty_drv);
		tty_port_destroy(mts_tty_drv->mts_tty_port);
		kfree(mts_tty_drv->mts_tty_port);
		kfree(mts_tty_drv);
		return 0;
	}
/*
	mts_tty->pm_notify.notifier_call = mts_pm_notify;
	register_pm_notifier(&mts_tty->pm_notify);
	init_waitqueue_head(&mts_tty->waitq);
*/
	mts_tty->run = 0;
//	mts_tty->pm_notify_info = 0;

	printk( "mts_tty_init success\n");
	return 0;
}
开发者ID:T-Macgnolia,项目名称:android_kernel_lge_g4stylus-stock,代码行数:88,代码来源:mts_tty.c

示例14: mcu_platform_probe

static int mcu_platform_probe(struct platform_device *pdev)
{
	int ret, i;
	struct mcu_data *data;
	struct mcu *mcu;
	u8 *base;

	mcu = platform_get_drvdata(pdev);
	intel_mcu_tty_driver = alloc_tty_driver(INTEL_MCU_TTY_MINORS);
	if (!intel_mcu_tty_driver) {
		dev_err(&pdev->dev, "fail to alloc tty driver\n");
		return -ENODEV;
	}

	intel_mcu_tty_driver->name = "ttymcu";
	intel_mcu_tty_driver->major = INTEL_MCU_TTY_MAJOR;
	intel_mcu_tty_driver->minor_start = 0;
	intel_mcu_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
	intel_mcu_tty_driver->subtype = SERIAL_TYPE_NORMAL;
	intel_mcu_tty_driver->flags = TTY_DRIVER_REAL_RAW
		| TTY_DRIVER_DYNAMIC_DEV;
	intel_mcu_tty_driver->init_termios = tty_std_termios;
	intel_mcu_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
		HUPCL | CLOCAL;
	intel_mcu_tty_driver->init_termios.c_ispeed = 38400;
	intel_mcu_tty_driver->init_termios.c_ospeed = 38400;
	intel_mcu_tty_driver->init_termios.c_iflag = 0;
	intel_mcu_tty_driver->init_termios.c_oflag = 0;
	intel_mcu_tty_driver->init_termios.c_lflag = 0;
	tty_set_operations(intel_mcu_tty_driver, &intel_mcu_ops);

	ret = tty_register_driver(intel_mcu_tty_driver);
	if (ret) {
		dev_err(&pdev->dev, "fail to register tty driver\n");
		goto tty_reg_fail;
	}

	base = (u8 *)mcu->ddr[1];
	for (i = INTEL_MCU_TTY_MINORS - 1; i >= 0; i--) {
		data = kzalloc(sizeof(struct mcu_data), GFP_KERNEL);
		if (data == NULL) {
			dev_err(&pdev->dev, "fail to alloc mcu data\n");
			goto data_alloc_fail;
		}

		data->index = i;
		tty_port_init(&data->port);
		data->dev = tty_port_register_device(&data->port,
				intel_mcu_tty_driver, i, &pdev->dev);
		mcu_table[i] = data;
		data->mcu = mcu;
		init_completion(&data->cmp);
		data->lbuf.addr = base;
		data->lbuf.length = BUF_IA_DDR_SIZE;
		lbuf_read_reset(&data->lbuf);
		base += BUF_IA_DDR_SIZE;
	}
	ret = sysfs_create_group(&pdev->dev.kobj,
			&intel_mcu_tty_attribute_group);
	if (ret) {
		pr_err("failed to create the mdbg sysfs attributes\n");
		sysfs_remove_group(&pdev->dev.kobj,
				&intel_mcu_tty_attribute_group);
		goto data_alloc_fail;
	}

	intel_psh_ipc_bind(PSH_RECV_CH0, raw_data_handler, mcu_table[0]);
	intel_psh_ipc_bind(PSH_RECV_CH1, raw_data_handler, mcu_table[1]);
	intel_psh_ipc_bind(PSH_RECV_CH2, cmd_handler, mcu_table[2]);

	pr_info("MCU detected and ready to used!\n");

	return 0;

data_alloc_fail:
	for (i = 0; i < INTEL_MCU_TTY_MINORS; i++)
		kfree(mcu_table[i]);
tty_reg_fail:
	put_tty_driver(intel_mcu_tty_driver);
	return ret;
}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:81,代码来源:intel_mcu_common.c

示例15: hsic_tty_init

static int __init hsic_tty_init(void)
{
    int ret;
    int n;
    unsigned port_num;

    pr_debug("%s\n", __func__);

    hsic_tty_driver = alloc_tty_driver(MAX_HSIC_TTYS);
    if (hsic_tty_driver == 0)
        return -ENOMEM;

    hsic_tty_driver->owner = THIS_MODULE;
    hsic_tty_driver->driver_name = "hsic_tty_driver";
    hsic_tty_driver->name = "hsic";
    hsic_tty_driver->major = 0;
    hsic_tty_driver->minor_start = 0;
    hsic_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
    hsic_tty_driver->subtype = SERIAL_TYPE_NORMAL;
    hsic_tty_driver->init_termios = tty_std_termios;
    hsic_tty_driver->init_termios.c_iflag = 0;
    hsic_tty_driver->init_termios.c_oflag = 0;
    hsic_tty_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
    hsic_tty_driver->init_termios.c_lflag = 0;
    hsic_tty_driver->flags = TTY_DRIVER_RESET_TERMIOS |
        TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
    tty_set_operations(hsic_tty_driver, &hsic_tty_ops);

    ret = tty_register_driver(hsic_tty_driver);
    if (ret) {
        put_tty_driver(hsic_tty_driver);
        pr_err("%s: driver registration failed %d\n", __func__, ret);
        return ret;
    }

    port_num = hsic_tty_data_setup(1, HSIC_TTY_SERIAL);
    if (port_num < 0)
    {
        pr_err("%s: hsic_tty_data_setup failed\n", __func__);
        goto out;
    }

    ret = hsic_tty_ctrl_setup(1, HSIC_TTY_SERIAL);
    if (ret < 0)
    {
        pr_err("%s: hsic_tty_ctrl_setup failed\n", __func__);
        goto out;
    }

    hsic_tty.client_port_num = port_num;
#ifdef CONFIG_MODEM_SUPPORT
    spin_lock_init(&hsic_tty.lock);
    spin_lock_init(&hsic_tty.reset_lock);
    hsic_tty.connect = hsic_tty_connect;
    hsic_tty.get_dtr = hsic_tty_get_dtr;
    hsic_tty.get_rts = hsic_tty_get_rts;
    hsic_tty.send_carrier_detect = hsic_tty_send_carrier_detect;
    hsic_tty.send_ring_indicator = hsic_tty_send_ring_indicator;
    hsic_tty.send_modem_ctrl_bits = hsic_tty_send_modem_ctrl_bits;
    hsic_tty.disconnect = hsic_tty_disconnect;
    hsic_tty.send_break = hsic_tty_send_break;;
#endif
    hsic_tty.tty = NULL;

    ret = hsic_tty_ctrl_connect(&hsic_tty, port_num);
    if (ret) {
        pr_err("%s: hsic_tty_ctrl_connect failed: err:%d\n",
                __func__, ret);
        goto out;
    }

    ret = hsic_tty_data_connect(&hsic_tty, port_num);
    if (ret) {
        pr_err("%s: hsic_tty_data_connect failed: err:%d\n",
                __func__, ret);
        hsic_tty_ctrl_disconnect(&hsic_tty, port_num);
        goto out;
    }

    for (n = 0; n < MAX_HSIC_TTYS; ++n)
    {
        pr_info("%s: %d\n", __func__, n);
        tty_register_device(hsic_tty_driver, n, 0);
    }
    return 0;

out:
    tty_unregister_driver(hsic_tty_driver);
    put_tty_driver(hsic_tty_driver);
    return ret;
}
开发者ID:Canuck-OG,项目名称:LGF180-Optimus-G-_Android_KK_v30a_Kernel,代码行数:91,代码来源:hsic_tty.c


注:本文中的put_tty_driver函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。