Exemplo n.º 1
0
static int __init rin_init(void)
{
	int status;

	if (rin_maxdev < 4)
		rin_maxdev = 4; /* Sanity */

	rin_devs = kzalloc(sizeof(struct net_device *)*rin_maxdev,
								GFP_KERNEL);
	if (!rin_devs) {
		if(DEBUG) printk(KERN_ERR "RIN: Can't allocate slip devices array.\n");
		return -ENOMEM;
	}

	/* Fill in our line protocol discipline, and register it */
	status = tty_register_ldisc(N_RIN, &rin_ldisc);
	if (status != 0) {
		if(DEBUG) printk(KERN_ERR "RIN: can't register line discipline (err = %d)\n", status);
		kfree(rin_devs);
	}
	if (status == 0) {
		rin_tx_wq = create_singlethread_workqueue("rintx");
		if (!rin_tx_wq) {
			if(DEBUG) printk(KERN_ERR "RIN: failed to allocate workqueue");
			tty_unregister_ldisc(N_RIN);
			kfree(rin_devs);
			status = -ENOMEM;
		}
	}
	return status;
}
Exemplo n.º 2
0
static int __init pps_tty_init(void)
{
	int err;

	/* Inherit the N_TTY's ops */
	n_tty_inherit_ops(&pps_ldisc_ops);

	/* Save N_TTY's open()/close() methods */
	alias_n_tty_open = pps_ldisc_ops.open;
	alias_n_tty_close = pps_ldisc_ops.close;

	/* Init PPS_TTY data */
	pps_ldisc_ops.owner = THIS_MODULE;
	pps_ldisc_ops.magic = PPS_TTY_MAGIC;
	pps_ldisc_ops.name = "pps_tty";
	pps_ldisc_ops.dcd_change = pps_tty_dcd_change;
	pps_ldisc_ops.open = pps_tty_open;
	pps_ldisc_ops.close = pps_tty_close;

	err = tty_register_ldisc(N_PPS, &pps_ldisc_ops);
	if (err)
		pr_err("can't register PPS line discipline\n");
	else
		pr_info("PPS line discipline registered\n");

	return err;
}
Exemplo n.º 3
0
static int bcmbt_tty_init(void)
{
	int err;
	pr_debug("%s: BLUETOOTH:\n", __func__);

	/* Inherit the N_TTY's ops */
	n_tty_inherit_ops(&bcmbt_ldisc_ops);

	bcmbt_ldisc_ops.owner = THIS_MODULE;
	bcmbt_ldisc_ops.name = "bcmbt_tty";
	bcmbt_ldisc_ops.ioctl = bcmbt_tty_ioctl;
	bcmbt_ldisc_saved.open = bcmbt_ldisc_ops.open;
	bcmbt_ldisc_saved.close = bcmbt_ldisc_ops.close;
	bcmbt_ldisc_ops.open = bcmbt_tty_open;
	bcmbt_ldisc_ops.close = bcmbt_tty_close;

	err = tty_register_ldisc(N_BRCM_HCI, &bcmbt_ldisc_ops);
	if (err)
		pr_err("can't register N_BRCM_HCI line discipline\n");
	else
		pr_info("N_BRCM_HCI line discipline registered\n");

	pr_debug("%s BLUETOOTH:Exiting.\n", __func__);
	return err;
}
Exemplo n.º 4
0
int __init irtty_init(void)
{
	int status;
	
	irtty = hashbin_new( HB_LOCAL);
	if ( irtty == NULL) {
		printk( KERN_WARNING "IrDA: Can't allocate irtty hashbin!\n");
		return -ENOMEM;
	}

	/* Fill in our line protocol discipline, and register it */
	memset(&irda_ldisc, 0, sizeof( irda_ldisc));

	irda_ldisc.magic = TTY_LDISC_MAGIC;
 	irda_ldisc.name  = "irda";
	irda_ldisc.flags = 0;
	irda_ldisc.open  = irtty_open;
	irda_ldisc.close = irtty_close;
	irda_ldisc.read  = NULL;
	irda_ldisc.write = NULL;
	irda_ldisc.ioctl = (int (*)(struct tty_struct *, struct file *,
				    unsigned int, unsigned long)) irtty_ioctl;
 	irda_ldisc.poll  = NULL;
	irda_ldisc.receive_buf  = irtty_receive_buf;
	irda_ldisc.receive_room = irtty_receive_room;
	irda_ldisc.write_wakeup = irtty_write_wakeup;
	
	if ((status = tty_register_ldisc(N_IRDA, &irda_ldisc)) != 0) {
		ERROR("IrDA: can't register line discipline (err = %d)\n", 
		      status);
	}
	
	return status;
}
Exemplo n.º 5
0
static int __init slcan_init(void)
{
	int status;

	if (maxdev < 4)
		maxdev = 4; /* Sanity */

	printk(banner);
	printk(KERN_INFO "slcan: %d dynamic interface channels.\n", maxdev);

	slcan_devs = kmalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL);
	if (!slcan_devs) {
		printk(KERN_ERR "slcan: can't allocate slcan device array!\n");
		return -ENOMEM;
	}

	/* Clear the pointer array, we allocate devices when we need them */
	memset(slcan_devs, 0, sizeof(struct net_device *)*maxdev);

	/* Fill in our line protocol discipline, and register it */
	status = tty_register_ldisc(N_SLCAN, &slc_ldisc);
	if (status != 0)  {
		printk(KERN_ERR "slcan: can't register line discipline\n");
		kfree(slcan_devs);
	}
	return status;
}
Exemplo n.º 6
0
int __init n_hci_init(void)
{
	static struct tty_ldisc n_hci_ldisc;
	int err;

	INF("BlueZ HCI UART driver ver %s Copyright (C) 2000,2001 Qualcomm Inc", 
		VERSION);
	INF("Written 2000,2001 by Maxim Krasnyansky <*****@*****.**>");

	/* Register the tty discipline */

	memset(&n_hci_ldisc, 0, sizeof (n_hci_ldisc));
	n_hci_ldisc.magic       = TTY_LDISC_MAGIC;
	n_hci_ldisc.name        = "n_hci";
	n_hci_ldisc.open        = n_hci_tty_open;
	n_hci_ldisc.close       = n_hci_tty_close;
	n_hci_ldisc.read        = n_hci_tty_read;
	n_hci_ldisc.write       = n_hci_tty_write;
	n_hci_ldisc.ioctl       = n_hci_tty_ioctl;
	n_hci_ldisc.poll        = n_hci_tty_poll;
	n_hci_ldisc.receive_room= n_hci_tty_room;
	n_hci_ldisc.receive_buf = n_hci_tty_receive;
	n_hci_ldisc.write_wakeup= n_hci_tty_wakeup;

	if ((err = tty_register_ldisc(N_HCI, &n_hci_ldisc))) {
		ERR("Can't register HCI line discipline (%d)", err);
		return err;
	}

	return 0;
}
Exemplo n.º 7
0
void
cleanup_module(void)
{
	int i;

	if (x25_asy_ctrls != NULL)
	{
		for (i = 0; i < x25_asy_maxdev; i++)
		{
			if (x25_asy_ctrls[i])
			{
				/*
				 * VSV = if dev->start==0, then device
				 * unregistered while close proc.
				 */
				if (netif_running(&(x25_asy_ctrls[i]->dev)))
					unregister_netdev(&(x25_asy_ctrls[i]->dev));

				kfree(x25_asy_ctrls[i]);
				x25_asy_ctrls[i] = NULL;
			}
		}
		kfree(x25_asy_ctrls);
		x25_asy_ctrls = NULL;
	}
	if ((i = tty_register_ldisc(N_X25, NULL)))
	{
		printk("X.25 async: can't unregister line discipline (err = %d)\n", i);
	}
}
Exemplo n.º 8
0
static int __init r3964_init(void)
{
   int status;
   
   printk ("r3964: Philips r3964 Driver $Revision: 1.1.1.1 $\n");

   /*
    * Register the tty line discipline
    */
   
   status = tty_register_ldisc (N_R3964, &tty_ldisc_N_R3964);
   if (status == 0)
     {
       TRACE_L("line discipline %d registered", N_R3964);
       TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 
               tty_ldisc_N_R3964.num);
       TRACE_L("open=%x", (int)tty_ldisc_N_R3964.open);
       TRACE_L("tty_ldisc_N_R3964 = %x", (int)&tty_ldisc_N_R3964);
     }
   else
     {
       printk (KERN_ERR "r3964: error registering line discipline: %d\n", status);
     }
   return status;
}
Exemplo n.º 9
0
static void __exit exit_x25_asy(void)
{
	struct net_device *dev;
	int i;

	for (i = 0; i < x25_asy_maxdev; i++) {
		dev = x25_asy_devs[i];
		if (dev) {
			struct x25_asy *sl = dev->priv;

			spin_lock_bh(&sl->lock);
			if (sl->tty) 
				tty_hangup(sl->tty);

			spin_unlock_bh(&sl->lock);
			/*
			 * VSV = if dev->start==0, then device
			 * unregistered while close proc.
			 */
			unregister_netdev(dev);
			free_netdev(dev);
		}
	}

	kfree(x25_asy_devs);
	tty_register_ldisc(N_X25, NULL);
}
Exemplo n.º 10
0
/* module init/exit functions */
static int __init ttyhub_init(void)
{
        int status;

        if (max_subsys < 2)
                max_subsys = 2;

        if (probe_buf_size < 16)
                probe_buf_size = 16;

        printk(KERN_INFO "ttyhub: version %s, max. subsystems = %d, probe "
                "bufsize = %d"
#ifdef DEBUG
                " (debug build)"
#endif
                "\n", TTYHUB_VERSION, max_subsys, probe_buf_size);

        /* allocate space for pointers to subsystems and init lock */
        ttyhub_subsystems = kzalloc(
                sizeof(struct ttyhub_subsystem *) * max_subsys,
                GFP_KERNEL);
        if (ttyhub_subsystems == NULL)
                return -ENOMEM;
        spin_lock_init(&ttyhub_subsystems_lock);

        /* register line discipline */
        status = tty_register_ldisc(N_TTYHUB, &ttyhub_ldisc); // TODO dynamic LDISC nr
        if (status != 0) {
                kfree(ttyhub_subsystems);
                printk(KERN_ERR "ttyhub: can't register line discipline "
                        "(err = %d)\n", status);
        }
        return status;
}
Exemplo n.º 11
0
static int __init ld_phonet_init(void)
{
	int retval;
	retval = tty_register_ldisc(N_PHONET, &ld_phonet_ldisc);

	return  retval;
}
static int __init hci_uart_init(void)
{
	static struct tty_ldisc_ops hci_uart_ldisc;
	int err;

	BT_INFO("HCI UART driver ver %s", VERSION);

	/* Register the tty discipline */

	memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc));
	hci_uart_ldisc.magic		= TTY_LDISC_MAGIC;
	hci_uart_ldisc.name		= "n_hci";
	hci_uart_ldisc.open		= hci_uart_tty_open;
	hci_uart_ldisc.close		= hci_uart_tty_close;
	hci_uart_ldisc.read		= hci_uart_tty_read;
	hci_uart_ldisc.write		= hci_uart_tty_write;
	hci_uart_ldisc.ioctl		= hci_uart_tty_ioctl;
	hci_uart_ldisc.poll		= hci_uart_tty_poll;
	hci_uart_ldisc.receive_buf	= hci_uart_tty_receive;
	hci_uart_ldisc.write_wakeup	= hci_uart_tty_wakeup;
	hci_uart_ldisc.owner		= THIS_MODULE;

	if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
		BT_ERR("HCI line discipline registration failed. (%d)", err);
		return err;
	}

#ifdef CONFIG_BT_HCIUART_H4
	h4_init();
#endif
#ifdef CONFIG_BT_HCIUART_BCSP
	bcsp_init();
#endif
/* < DTS2012020604357 zhangyun 20120206 begin */
#if defined(CONFIG_BT_HCIUART_LL) && defined(HUAWEI_BT_BTLA_VER30)
	ll_init();
#endif

/*default without Huawei modification*/
#if defined(CONFIG_BT_HCIUART_LL) && (!defined(CONFIG_HUAWEI_KERNEL))
    ll_init();
#endif
/* DTS2012020604357 zhangyun 20120206 end > */
#ifdef CONFIG_BT_HCIUART_ATH3K
	ath_init();
#endif
/* < DTS2012020604357 zhangyun 20120206 begin */
#if defined(CONFIG_BT_HCIUART_IBS) && defined(HUAWEI_BT_BLUEZ_VER30)
	ibs_init();
#endif

/*default without Huawei modification*/
#if defined(CONFIG_BT_HCIUART_IBS) && (!defined(CONFIG_HUAWEI_KERNEL))
    ibs_init();
#endif
/* DTS2012020604357 zhangyun 20120206 end > */

	return 0;
}
Exemplo n.º 13
0
void n_hci_cleanup(void)
{
	int err;

	/* Release tty registration of line discipline */
	if ((err = tty_register_ldisc(N_HCI, NULL)))
		ERR("Can't unregister HCI line discipline (%d)", err);
}
Exemplo n.º 14
0
static int __init hci_uart_init(void)
{
	static struct tty_ldisc_ops hci_uart_ldisc;
	int err;

	BT_INFO("HCI UART driver ver %s", VERSION);

	/* Register the tty discipline */

	memset(&hci_uart_ldisc, 0, sizeof(hci_uart_ldisc));
	hci_uart_ldisc.magic		= TTY_LDISC_MAGIC;
	hci_uart_ldisc.name		= "n_hci";
	hci_uart_ldisc.open		= hci_uart_tty_open;
	hci_uart_ldisc.close		= hci_uart_tty_close;
	hci_uart_ldisc.read		= hci_uart_tty_read;
	hci_uart_ldisc.write		= hci_uart_tty_write;
	hci_uart_ldisc.ioctl		= hci_uart_tty_ioctl;
	hci_uart_ldisc.poll		= hci_uart_tty_poll;
	hci_uart_ldisc.receive_buf	= hci_uart_tty_receive;
	hci_uart_ldisc.write_wakeup	= hci_uart_tty_wakeup;
	hci_uart_ldisc.owner		= THIS_MODULE;

	err = tty_register_ldisc(N_HCI, &hci_uart_ldisc);
	if (err) {
		BT_ERR("HCI line discipline registration failed. (%d)", err);
		return err;
	}

#ifdef CONFIG_BT_HCIUART_H4
	h4_init();
#endif
#ifdef CONFIG_BT_HCIUART_BCSP
	bcsp_init();
#endif
#ifdef CONFIG_BT_HCIUART_LL
	ll_init();
#endif
#ifdef CONFIG_BT_HCIUART_ATH3K
	ath_init();
#endif
#ifdef CONFIG_BT_HCIUART_3WIRE
	h5_init();
#endif
#ifdef CONFIG_BT_HCIUART_INTEL
	intel_init();
#endif
#ifdef CONFIG_BT_HCIUART_BCM
	bcm_init();
#endif
#ifdef CONFIG_BT_HCIUART_QCA
	qca_init();
#endif
#ifdef CONFIG_BT_HCIUART_AG6XX
	ag6xx_init();
#endif

	return 0;
}
Exemplo n.º 15
0
static void __exit n_hdlc_exit(void)
{
	int status;
	/* Release tty registration of line discipline */
	if ((status = tty_register_ldisc(N_HDLC, NULL)))
		printk("N_HDLC: can't unregister line discipline (err = %d)\n", status);
	else
		printk("N_HDLC: line discipline unregistered\n");
}
Exemplo n.º 16
0
int __init serport_init(void)
{
        if (tty_register_ldisc(N_MOUSE, &serport_ldisc)) {
                printk(KERN_ERR "serport.c: Error registering line discipline.\n");
		return -ENODEV;
	}

	return  0;
}
Exemplo n.º 17
0
static int __init serport_init(void)
{
	int retval;
	retval = tty_register_ldisc(N_MOUSE, &serport_ldisc);
	if (retval)
		printk(KERN_ERR "serport.c: Error registering line discipline.\n");

	return  retval;
}
Exemplo n.º 18
0
static int __init hci_uart_init(void)
{
	static struct tty_ldisc_ops hci_uart_ldisc;
	int err;

	BT_INFO("HCI UART driver ver %s", VERSION);

	/* Register the tty discipline */

	memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc));
	hci_uart_ldisc.magic		= TTY_LDISC_MAGIC;
	hci_uart_ldisc.name		= "n_hci";
	hci_uart_ldisc.open		= hci_uart_tty_open;
	hci_uart_ldisc.close		= hci_uart_tty_close;
	hci_uart_ldisc.read		= hci_uart_tty_read;
	hci_uart_ldisc.write		= hci_uart_tty_write;
	hci_uart_ldisc.ioctl		= hci_uart_tty_ioctl;
	hci_uart_ldisc.poll		= hci_uart_tty_poll;
	hci_uart_ldisc.receive_buf	= hci_uart_tty_receive;
	hci_uart_ldisc.write_wakeup	= hci_uart_tty_wakeup;
	hci_uart_ldisc.owner		= THIS_MODULE;

	if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
		BT_ERR("HCI line discipline registration failed. (%d)", err);
		return err;
	}

#ifdef CONFIG_BT_HCIUART_H4
	h4_init();
#endif
/*
#ifdef CONFIG_BT_HCIUART_BCSP
	bcsp_init();
#endif
#ifdef CONFIG_BT_HCIUART_LL
	ll_init();
#endif
#ifdef CONFIG_BT_HCIUART_ATH3K
	ath_init();
#endif
*/

//Realtek_add_start	
//add realtek h5 support	
//#ifdef CONFIG_BT_HCIUART_RTKH5
	h5_init();
//#endif
//Realtek_add_end

#ifdef BTCOEX
	rtk_uart_coex_init();
#endif

	return 0;
}
Exemplo n.º 19
0
static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_dai *codec_dai = rtd->codec_dai;
	struct snd_soc_card *card = rtd->card;
	struct snd_soc_dapm_context *dapm = &card->dapm;
	int ret;
	/* Codec is ready, now add/activate board specific controls */

	/* Store a pointer to the codec structure for tty ldisc use */
	cx20442_codec = rtd->codec;

	/* Set up digital mute if not provided by the codec */
	if (!codec_dai->driver->ops) {
		codec_dai->driver->ops = &ams_delta_dai_ops;
	} else {
		ams_delta_ops.startup = ams_delta_startup;
		ams_delta_ops.shutdown = ams_delta_shutdown;
	}

	/* Add hook switch - can be used to control the codec from userspace
	 * even if line discipline fails */
	ret = snd_soc_jack_new(rtd->codec, "hook_switch",
				SND_JACK_HEADSET, &ams_delta_hook_switch);
	if (ret)
		dev_warn(card->dev,
				"Failed to allocate resources for hook switch, "
				"will continue without one.\n");
	else {
		ret = snd_soc_jack_add_gpios(&ams_delta_hook_switch,
					ARRAY_SIZE(ams_delta_hook_switch_gpios),
					ams_delta_hook_switch_gpios);
		if (ret)
			dev_warn(card->dev,
				"Failed to set up hook switch GPIO line, "
				"will continue with hook switch inactive.\n");
	}

	/* Register optional line discipline for over the modem control */
	ret = tty_register_ldisc(N_V253, &cx81801_ops);
	if (ret) {
		dev_warn(card->dev,
				"Failed to register line discipline, "
				"will continue without any controls.\n");
		return 0;
	}

	/* Set up initial pin constellation */
	snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
	snd_soc_dapm_disable_pin(dapm, "Speaker");
	snd_soc_dapm_disable_pin(dapm, "AGCIN");
	snd_soc_dapm_disable_pin(dapm, "AGCOUT");

	return 0;
}
Exemplo n.º 20
0
int lunix_ldisc_init(void)
{
    int ret;

    //debug("initializing lunix ldisc\n");
    atomic_set(&lunix_disc_available, 1);
    ret = tty_register_ldisc(N_LUNIX_LDISC, &lunix_ldisc_ops);
    if (ret)
        printk(KERN_ERR "%s: Error registering line discipline, ret = %d.\n", __FILE__, ret);

    //debug("leaving with ret = %d\n", ret);
    return ret;
}
Exemplo n.º 21
0
static int __init port_relay_init(void)
{
	int retval;
	retval = tty_register_ldisc(N_MOUSE, &port_ldisc);
	if (retval)
		printk(KERN_ERR "port_relay.c: Error registering line discipline.\n");

#ifdef CONFIG_PROC_FS
    proc_create("tty/ttyUSB", 0, NULL, &tty_usb_proc_fops);
#endif
    gs_tty_driver = NULL;
	return  retval;
}
Exemplo n.º 22
0
int st_core_init(struct st_data_s **core_data)
{
	struct st_data_s *st_gdata;
	long err;

	err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
	if (err) {
		pr_err("error registering %d line discipline %ld",
			   N_TI_WL, err);
		return err;
	}
	pr_debug("registered n_shared line discipline");

	st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
	if (!st_gdata) {
		pr_err("memory allocation failed");
		err = tty_unregister_ldisc(N_TI_WL);
		if (err)
			pr_err("unable to un-register ldisc %ld", err);
		err = -ENOMEM;
		return err;
	}

	/* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
	 * will be pushed in this queue for actual transmission.
	 */
	skb_queue_head_init(&st_gdata->txq);
	skb_queue_head_init(&st_gdata->tx_waitq);

	/* Locking used in st_int_enqueue() to avoid multiple execution */
	spin_lock_init(&st_gdata->lock);
	spin_lock_init(&st_gdata->pm_lock);

	/* Power Management protection mechanism w.r.t. RX queue activity */
	wake_lock_init(&st_gdata->wake_lock, WAKE_LOCK_SUSPEND,
			ST_PM_PROTECT_WAKE_LOCK_NAME);

	err = st_ll_init(st_gdata);
	if (err) {
		pr_err("error during st_ll initialization(%ld)", err);
		wake_lock_destroy(&st_gdata->wake_lock);
		kfree(st_gdata);
		err = tty_unregister_ldisc(N_TI_WL);
		if (err)
			pr_err("unable to un-register ldisc");
		return err;
	}
	*core_data = st_gdata;
	return 0;
}
Exemplo n.º 23
0
static int __init brickpi_init(void)
{
	int err;

	err = tty_register_ldisc(N_BRICKPI, &brickpi_ldisc);
	if (err) {
		pr_err("Could not register BrickPi line discipline. (%d)\n",
			err);
		return err;
	}

	pr_info("Registered BrickPi line discipline. (%d)\n", N_BRICKPI);

	return 0;
}
Exemplo n.º 24
0
void hci_uart_cleanup(void)
{
	int err;

#ifdef CONFIG_BLUEZ_HCIUART_H4
	h4_deinit();
#endif
#ifdef CONFIG_BLUEZ_HCIUART_BCSP
	bcsp_deinit();
#endif

	/* Release tty registration of line discipline */
	if ((err = tty_register_ldisc(N_HCI, NULL)))
		BT_ERR("Can't unregister HCI line discipline (%d)", err);
}
Exemplo n.º 25
0
static int __init init_x25_asy(void)
{
	if (x25_asy_maxdev < 4)
		x25_asy_maxdev = 4; /* Sanity */

	pr_info("X.25 async: version 0.00 ALPHA (dynamic channels, max=%d)\n",
		x25_asy_maxdev);

	x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *),
				GFP_KERNEL);
	if (!x25_asy_devs)
		return -ENOMEM;

	return tty_register_ldisc(N_X25, &x25_ldisc);
}
Exemplo n.º 26
0
static int __init ev3_uart_init(void)
{
	int err;

	err = tty_register_ldisc(N_LEGOEV3, &ev3_uart_ldisc);
	if (err) {
		pr_err("Could not register EV3 UART sensor line discipline. (%d)\n",
			err);
		return err;
	}

	pr_info("Registered EV3 UART sensor line discipline. (%d)\n", N_LEGOEV3);

	return 0;
}
Exemplo n.º 27
0
int st_core_init(struct st_data_s **core_data)
{
	struct st_data_s *st_gdata;
	long err;

	err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
	if (err) {
		pr_err("error registering %d line discipline %ld",
			   N_TI_WL, err);
		return err;
	}
	pr_debug("registered n_shared line discipline");

	st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
	if (!st_gdata) {
		pr_err("memory allocation failed");
		err = tty_unregister_ldisc(N_TI_WL);
		if (err)
			pr_err("unable to un-register ldisc %ld", err);
		err = -ENOMEM;
		return err;
	}

	/* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
	 * will be pushed in this queue for actual transmission.
	 */
	skb_queue_head_init(&st_gdata->txq);
	skb_queue_head_init(&st_gdata->tx_waitq);

	/* Locking used in st_int_enqueue() to avoid multiple execution */
	spin_lock_init(&st_gdata->lock);

	err = st_ll_init(st_gdata);
	if (err) {
		pr_err("error during st_ll initialization(%ld)", err);
		kfree(st_gdata);
		err = tty_unregister_ldisc(N_TI_WL);
		if (err)
			pr_err("unable to un-register ldisc");
		return err;
	}

	INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup);

	*core_data = st_gdata;
	return 0;
}
Exemplo n.º 28
0
static int __init init_x25_asy(void)
{
	if (x25_asy_maxdev < 4)
		x25_asy_maxdev = 4; /* Sanity */

	pr_info("X.25 async: version 0.00 ALPHA (dynamic channels, max=%d)\n",
		x25_asy_maxdev);

	x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *),
				GFP_KERNEL);
	if (!x25_asy_devs) {
		pr_warn("Can't allocate x25_asy_ctrls[] array! Uaargh! (-> No X.25 available)\n");
		return -ENOMEM;
	}

	return tty_register_ldisc(N_X25, &x25_ldisc);
}
Exemplo n.º 29
0
static void irtty_cleanup(void) 
{
	int ret;
	
	/* Unregister tty line-discipline */
	if ((ret = tty_register_ldisc(N_IRDA, NULL))) {
		ERROR("%s(), can't unregister line discipline (err = %d)\n",
			__FUNCTION__, ret);
	}

	/*
	 *  The TTY should care of deallocating the instances by using the
	 *  callback to irtty_close(), therefore we do give any deallocation
	 *  function to hashbin_destroy().
	 */
	hashbin_delete(irtty, NULL);
}
Exemplo n.º 30
0
/**
 * n_tracerouter_init -	module initialisation
 *
 * Registers this module as a line discipline driver.
 *
 * Return:
 *	0 for success, any other value error.
 */
static int __init n_tracerouter_init(void)
{
	int retval;

	tr_data = kzalloc(sizeof(struct tracerouter_data), GFP_KERNEL);
	if (tr_data == NULL)
		return -ENOMEM;


	/* Note N_TRACEROUTER is defined in linux/tty.h */
	retval = tty_register_ldisc(N_TRACEROUTER, &tty_ptirouter_ldisc);
	if (retval < 0) {
		pr_err("%s: Registration failed: %d\n", __func__, retval);
		kfree(tr_data);
	}
	return retval;
}