Exemple #1
0
/*
 * Function irlmp_init (void)
 *
 *    Create (allocate) the main IrLMP structure
 *
 */
int __init irlmp_init(void)
{
	/* Initialize the irlmp structure. */
	irlmp = kmalloc( sizeof(struct irlmp_cb), GFP_KERNEL);
	if (irlmp == NULL)
		return -ENOMEM;
	memset(irlmp, 0, sizeof(struct irlmp_cb));
	
	irlmp->magic = LMP_MAGIC;
	spin_lock_init(&irlmp->lock);

	irlmp->clients = hashbin_new(HB_GLOBAL);
	irlmp->services = hashbin_new(HB_GLOBAL);
	irlmp->links = hashbin_new(HB_GLOBAL);
	irlmp->unconnected_lsaps = hashbin_new(HB_GLOBAL);
	irlmp->cachelog = hashbin_new(HB_GLOBAL);
	
	irlmp->free_lsap_sel = 0x10; /* Reserved 0x00-0x0f */
#ifdef CONFIG_IRDA_CACHE_LAST_LSAP
	irlmp->cache.valid = FALSE;
#endif
	strcpy(sysctl_devname, "Linux");
	
	/* Do discovery every 3 seconds */
	init_timer(&irlmp->discovery_timer);
   	irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout*HZ);

	return 0;
}
Exemple #2
0
/*
 * Function iriap_init (void)
 *
 *    Initializes the IrIAP layer, called by the module initialization code
 *    in irmod.c
 */
int __init iriap_init(void)
{
	struct ias_object *obj;
	struct iriap_cb *server;
	__u8 oct_seq[6];
	__u16 hints;

	/* Allocate master array */
	iriap = hashbin_new(HB_LOCK);
	if (!iriap)
		return -ENOMEM;

	/* Object repository - defined in irias_object.c */
	irias_objects = hashbin_new(HB_LOCK);
	if (!irias_objects) {
		IRDA_WARNING("%s: Can't allocate irias_objects hashbin!\n",
			     __func__);
		hashbin_delete(iriap, NULL);
		return -ENOMEM;
	}

	lockdep_set_class_and_name(&irias_objects->hb_spinlock, &irias_objects_key,
				   "irias_objects");

	/*
	 *  Register some default services for IrLMP
	 */
	hints  = irlmp_service_to_hint(S_COMPUTER);
	service_handle = irlmp_register_service(hints);

	/* Register the Device object with LM-IAS */
	obj = irias_new_object("Device", IAS_DEVICE_ID);
	irias_add_string_attrib(obj, "DeviceName", "Linux", IAS_KERNEL_ATTR);

	oct_seq[0] = 0x01;  /* Version 1 */
	oct_seq[1] = 0x00;  /* IAS support bits */
	oct_seq[2] = 0x00;  /* LM-MUX support bits */
#ifdef CONFIG_IRDA_ULTRA
	oct_seq[2] |= 0x04; /* Connectionless Data support */
#endif
	irias_add_octseq_attrib(obj, "IrLMPSupport", oct_seq, 3,
				IAS_KERNEL_ATTR);
	irias_insert_object(obj);

	/*
	 *  Register server support with IrLMP so we can accept incoming
	 *  connections
	 */
	server = iriap_open(LSAP_IAS, IAS_SERVER, NULL, NULL);
	if (!server) {
		IRDA_DEBUG(0, "%s(), unable to open server\n", __func__);
		return -1;
	}
	iriap_register_lsap(server, LSAP_IAS, IAS_SERVER);

	return 0;
}
Exemple #3
0
int __init irda_device_init( void)
{
	dongles = hashbin_new(HB_GLOBAL);
	if (dongles == NULL) {
		printk(KERN_WARNING 
		       "IrDA: Can't allocate dongles hashbin!\n");
		return -ENOMEM;
	}

	tasks = hashbin_new(HB_GLOBAL);
	if (tasks == NULL) {
		printk(KERN_WARNING 
		       "IrDA: Can't allocate tasks hashbin!\n");
		return -ENOMEM;
	}

	/* 
	 * Call the init function of the device drivers that has not been
	 * compiled as a module 
	 */
#ifdef CONFIG_IRTTY_SIR
	irtty_init();
#endif
#ifdef CONFIG_WINBOND_FIR
	w83977af_init();
#endif
#ifdef CONFIG_NSC_FIR
	nsc_ircc_init();
#endif
#ifdef CONFIG_TOSHIBA_FIR
	toshoboe_init();
#endif
#ifdef CONFIG_SMC_IRCC_FIR
	ircc_init();
#endif
#ifdef CONFIG_ESI_DONGLE
	esi_init();
#endif
#ifdef CONFIG_TEKRAM_DONGLE
	tekram_init();
#endif
#ifdef CONFIG_ACTISYS_DONGLE
	actisys_init();
#endif
#ifdef CONFIG_GIRBIL_DONGLE
	girbil_init();
#endif
#ifdef CONFIG_LITELINK_DONGLE
	litelink_init();
#endif
#ifdef CONFIG_OLD_BELKIN
 	old_belkin_init();
#endif
	return 0;
}
struct ias_object *irias_new_object( char *name, int id)
{
    struct ias_object *obj;

    IRDA_DEBUG( 4, "%s()\n", __func__);

    obj = kzalloc(sizeof(struct ias_object), GFP_ATOMIC);
    if (obj == NULL) {
        IRDA_WARNING("%s(), Unable to allocate object!\n",
                     __func__);
        return NULL;
    }

    obj->magic = IAS_OBJECT_MAGIC;
    obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
    if (!obj->name) {
        IRDA_WARNING("%s(), Unable to allocate name!\n",
                     __func__);
        kfree(obj);
        return NULL;
    }
    obj->id = id;

    obj->attribs = hashbin_new(HB_LOCK);

    if (obj->attribs == NULL) {
        IRDA_WARNING("%s(), Unable to allocate attribs!\n",
                     __func__);
        kfree(obj->name);
        kfree(obj);
        return NULL;
    }

    return obj;
}
Exemple #5
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;
}
/*
 * Function ias_new_object (name, id)
 *
 *    Create a new IAS object
 *
 */
struct ias_object *irias_new_object( char *name, int id)
{
        struct ias_object *obj;

	IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);

	obj = (struct ias_object *) kmalloc(sizeof(struct ias_object),
					    GFP_ATOMIC);
	if (obj == NULL) {
		WARNING("%s(), Unable to allocate object!\n",
			__FUNCTION__);
		return NULL;
	}
	memset(obj, 0, sizeof( struct ias_object));

	obj->magic = IAS_OBJECT_MAGIC;
	obj->name = strndup(name, IAS_MAX_CLASSNAME);
	obj->id = id;

	/* Locking notes : the attrib spinlock has lower precendence
	 * than the objects spinlock. Never grap the objects spinlock
	 * while holding any attrib spinlock (risk of deadlock). Jean II */
	obj->attribs = hashbin_new(HB_LOCK);

	if (obj->attribs == NULL) {
		WARNING("%s(), Unable to allocate attribs!\n", __FUNCTION__);
		kfree(obj);
		return NULL;
	}

	return obj;
}
Exemple #7
0
/*
 * Function ircomm_tty_init()
 *
 *    Init IrCOMM TTY layer/driver
 *
 */
static int __init ircomm_tty_init(void)
{
	driver = alloc_tty_driver(IRCOMM_TTY_PORTS);
	if (!driver)
		return -ENOMEM;
	ircomm_tty = hashbin_new(HB_LOCK); 
	if (ircomm_tty == NULL) {
		IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
		put_tty_driver(driver);
		return -ENOMEM;
	}

	driver->owner		= THIS_MODULE;
	driver->driver_name     = "ircomm";
	driver->name            = "ircomm";
	driver->major           = IRCOMM_TTY_MAJOR;
	driver->minor_start     = IRCOMM_TTY_MINOR;
	driver->type            = TTY_DRIVER_TYPE_SERIAL;
	driver->subtype         = SERIAL_TYPE_NORMAL;
	driver->init_termios    = tty_std_termios;
	driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	driver->flags           = TTY_DRIVER_REAL_RAW;
	tty_set_operations(driver, &ops);
	if (tty_register_driver(driver)) {
		IRDA_ERROR("%s(): Couldn't register serial driver\n",
			   __FUNCTION__);
		put_tty_driver(driver);
		return -1;
	}
	return 0;
}
Exemple #8
0
int __init irlap_init(void)
{
	/* Allocate master array */
	irlap = hashbin_new(HB_LOCAL);
	if (irlap == NULL) {
	        ERROR(__FUNCTION__ "(), can't allocate irlap hashbin!\n");
		return -ENOMEM;
	}

#ifdef CONFIG_IRDA_COMPRESSION
	irlap_compressors = hashbin_new(HB_LOCAL);
	if (irlap_compressors == NULL) {
		WARNING(__FUNCTION__ 
			"(), can't allocate compressors hashbin!\n");
		return -ENOMEM;
	}
#endif

	return 0;
}
Exemple #9
0
int __init irlap_init(void)
{
	/* Allocate master array */
	irlap = hashbin_new(HB_LOCAL);
	if (irlap == NULL) {
	        ERROR("%s(), can't allocate irlap hashbin!\n", __FUNCTION__);
		return -ENOMEM;
	}

	return 0;
}
Exemple #10
0
int __init irda_device_init( void)
{
	dongles = hashbin_new(HB_NOLOCK);
	if (dongles == NULL) {
		IRDA_WARNING("IrDA: Can't allocate dongles hashbin!\n");
		return -ENOMEM;
	}
	spin_lock_init(&dongles->hb_spinlock);

	tasks = hashbin_new(HB_LOCK);
	if (tasks == NULL) {
		IRDA_WARNING("IrDA: Can't allocate tasks hashbin!\n");
		hashbin_delete(dongles, NULL);
		return -ENOMEM;
	}

	/* We no longer initialise the driver ourselves here, we let
	 * the system do it for us... - Jean II */

	return 0;
}
Exemple #11
0
/*
 * Function ircomm_tty_init()
 *
 *    Init IrCOMM TTY layer/driver
 *
 */
int __init ircomm_tty_init(void)
{	
	ircomm_tty = hashbin_new(HB_LOCAL); 
	if (ircomm_tty == NULL) {
		ERROR(__FUNCTION__ "(), can't allocate hashbin!\n");
		return -ENOMEM;
	}

	memset(&driver, 0, sizeof(struct tty_driver));
	driver.magic           = TTY_DRIVER_MAGIC;
	driver.driver_name     = "ircomm";
#ifdef CONFIG_DEVFS_FS
	driver.name            = "ircomm%d";
#else
	driver.name            = "ircomm";
#endif
	driver.major           = IRCOMM_TTY_MAJOR;
	driver.minor_start     = IRCOMM_TTY_MINOR;
	driver.num             = IRCOMM_TTY_PORTS;
	driver.type            = TTY_DRIVER_TYPE_SERIAL;
	driver.subtype         = SERIAL_TYPE_NORMAL;
	driver.init_termios    = tty_std_termios;
	driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	driver.flags           = TTY_DRIVER_REAL_RAW;
	driver.refcount        = &ircomm_tty_refcount;
	driver.table           = ircomm_tty_table;
	driver.termios         = ircomm_tty_termios;
	driver.termios_locked  = ircomm_tty_termios_locked;
	driver.open            = ircomm_tty_open;
	driver.close           = ircomm_tty_close;
	driver.write           = ircomm_tty_write;
	driver.write_room      = ircomm_tty_write_room;
	driver.chars_in_buffer = ircomm_tty_chars_in_buffer;
	driver.flush_buffer    = ircomm_tty_flush_buffer;
	driver.ioctl           = ircomm_tty_ioctl;
	driver.throttle        = ircomm_tty_throttle;
	driver.unthrottle      = ircomm_tty_unthrottle;
	driver.send_xchar      = ircomm_tty_send_xchar;
	driver.set_termios     = ircomm_tty_set_termios;
	driver.stop            = ircomm_tty_stop;
	driver.start           = ircomm_tty_start;
	driver.hangup          = ircomm_tty_hangup;
	driver.wait_until_sent = ircomm_tty_wait_until_sent;
#ifdef CONFIG_PROC_FS
	driver.read_proc       = ircomm_tty_read_proc;
#endif /* CONFIG_PROC_FS */
	if (tty_register_driver(&driver)) {
		ERROR(__FUNCTION__ "Couldn't register serial driver\n");
		return -1;
	}
	return 0;
}
Exemple #12
0
/*
 * Function ircomm_tty_init()
 *
 *    Init IrCOMM TTY layer/driver
 *
 */
static int __init ircomm_tty_init(void)
{
	driver = alloc_tty_driver(IRCOMM_TTY_PORTS);
	if (!driver)
		return -ENOMEM;
	ircomm_tty = hashbin_new(HB_LOCK);
	if (ircomm_tty == NULL) {
		IRDA_ERROR("%s(), can't allocate hashbin!\n", __func__);
		put_tty_driver(driver);
		return -ENOMEM;
	}

<<<<<<< HEAD
Exemple #13
0
/*
 * Function irlmp_init (void)
 *
 *    Create (allocate) the main IrLMP structure
 *
 */
int __init irlmp_init(void)
{
	IRDA_DEBUG(1, "%s()\n", __func__);
	/* Initialize the irlmp structure. */
	irlmp = kzalloc( sizeof(struct irlmp_cb), GFP_KERNEL);
	if (irlmp == NULL)
		return -ENOMEM;

	irlmp->magic = LMP_MAGIC;

	irlmp->clients = hashbin_new(HB_LOCK);
	irlmp->services = hashbin_new(HB_LOCK);
	irlmp->links = hashbin_new(HB_LOCK);
	irlmp->unconnected_lsaps = hashbin_new(HB_LOCK);
	irlmp->cachelog = hashbin_new(HB_NOLOCK);

	if ((irlmp->clients == NULL) ||
	    (irlmp->services == NULL) ||
	    (irlmp->links == NULL) ||
	    (irlmp->unconnected_lsaps == NULL) ||
	    (irlmp->cachelog == NULL)) {
		return -ENOMEM;
	}

	spin_lock_init(&irlmp->cachelog->hb_spinlock);

	irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */
	strcpy(sysctl_devname, "Linux");

	init_timer(&irlmp->discovery_timer);

	/* Do discovery every 3 seconds, conditionally */
	if (sysctl_discovery)
		irlmp_start_discovery_timer(irlmp,
					    sysctl_discovery_timeout*HZ);

	return 0;
}
Exemple #14
0
int __init ircomm_init(void)
{
	ircomm = hashbin_new(HB_LOCAL); 
	if (ircomm == NULL) {
		ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
		return -ENOMEM;
	}
	
#ifdef CONFIG_PROC_FS
	create_proc_info_entry("ircomm", 0, proc_irda, ircomm_proc_read);
#endif /* CONFIG_PROC_FS */
	
	MESSAGE("IrCOMM protocol (Dag Brattli)\n");
		
	return 0;
}
int __init irttp_init(void)
{
	irttp = kzalloc(sizeof(struct irttp_cb), GFP_KERNEL);
	if (irttp == NULL)
		return -ENOMEM;

	irttp->magic = TTP_MAGIC;

	irttp->tsaps = hashbin_new(HB_LOCK);
	if (!irttp->tsaps) {
		IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
			   __func__);
		kfree(irttp);
		return -ENOMEM;
	}

	return 0;
}
Exemple #16
0
static int __init ircomm_init(void)
{
	ircomm = hashbin_new(HB_LOCK);
	if (ircomm == NULL) {
		IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
		return -ENOMEM;
	}

#ifdef CONFIG_PROC_FS
	{ struct proc_dir_entry *ent;
	ent = create_proc_entry("ircomm", 0, proc_irda);
	if (ent)
		ent->proc_fops = &ircomm_proc_fops;
	}
#endif /* CONFIG_PROC_FS */

	IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n");

	return 0;
}
Exemple #17
0
/*
 * Function ias_new_object (name, id)
 *
 *    Create a new IAS object
 *
 */
struct ias_object *irias_new_object( char *name, int id)
{
        struct ias_object *obj;
	
	IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);

	obj = (struct ias_object *) kmalloc(sizeof(struct ias_object), 
					    GFP_ATOMIC);
	if (obj == NULL) {
		IRDA_DEBUG(0, "%s(), Unable to allocate object!\n", __FUNCTION__);
		return NULL;
	}
	memset(obj, 0, sizeof( struct ias_object));

	obj->magic = IAS_OBJECT_MAGIC;
	obj->name = strndup(name, IAS_MAX_CLASSNAME);
	obj->id = id;

	obj->attribs = hashbin_new(HB_LOCAL);
	
	return obj;
}
static int __init ircomm_init(void)
{
    ircomm = hashbin_new(HB_LOCK);
    if (ircomm == NULL) {
        IRDA_ERROR("%s(), can't allocate hashbin!\n", __func__);
        return -ENOMEM;
    }

#ifdef CONFIG_PROC_FS
    {   struct proc_dir_entry *ent;
        ent = proc_create("ircomm", 0, proc_irda, &ircomm_proc_fops);
        if (!ent) {
            printk(KERN_ERR "ircomm_init: can't create /proc entry!\n");
            return -ENODEV;
        }
    }
#endif

    IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n");

    return 0;
}
Exemple #19
0
/*
 * Function ias_new_object (name, id)
 *
 *    Create a new IAS object
 *
 */
struct ias_object *irias_new_object( char *name, int id)
{
	struct ias_object *obj;

	obj = kzalloc(sizeof(struct ias_object), GFP_ATOMIC);
	if (obj == NULL) {
		net_warn_ratelimited("%s(), Unable to allocate object!\n",
				     __func__);
		return NULL;
	}

	obj->magic = IAS_OBJECT_MAGIC;
	obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
	if (!obj->name) {
		net_warn_ratelimited("%s(), Unable to allocate name!\n",
				     __func__);
		kfree(obj);
		return NULL;
	}
	obj->id = id;

	/* Locking notes : the attrib spinlock has lower precendence
	 * than the objects spinlock. Never grap the objects spinlock
	 * while holding any attrib spinlock (risk of deadlock). Jean II */
	obj->attribs = hashbin_new(HB_LOCK);

	if (obj->attribs == NULL) {
		net_warn_ratelimited("%s(), Unable to allocate attribs!\n",
				     __func__);
		kfree(obj->name);
		kfree(obj);
		return NULL;
	}

	return obj;
}
Exemple #20
0
__initfunc(int irda_device_init( void))
{
	DEBUG( 4, __FUNCTION__ "()\n");

	/* Allocate master array */
	irda_device = hashbin_new( HB_LOCAL);
	if ( irda_device == NULL) {
		printk( KERN_WARNING "IrDA: Can't allocate irda_device hashbin!\n");
		return -ENOMEM;
	}

	/* 
	 * Call the init function of the device drivers that has not been
	 * compiled as a module 
	 */
#ifdef CONFIG_IRTTY_SIR
	irtty_init();
#endif
#ifdef CONFIG_WINBOND_FIR
	w83977af_init();
#endif
#ifdef CONFIG_NSC_FIR
	pc87108_init();
#endif
#ifdef CONFIG_ESI_DONGLE
	esi_init();
#endif
#ifdef CONFIG_TEKRAM_DONGLE
	tekram_init();
#endif
#ifdef CONFIG_ACTISYS_DONGLE
	actisys_init();
#endif

	return 0;
}
int __init irda_device_init( void)
{
	dongles = hashbin_new(HB_GLOBAL);
	if (dongles == NULL) {
		printk(KERN_WARNING 
		       "IrDA: Can't allocate dongles hashbin!\n");
		return -ENOMEM;
	}

	tasks = hashbin_new(HB_GLOBAL);
	if (tasks == NULL) {
		printk(KERN_WARNING 
		       "IrDA: Can't allocate tasks hashbin!\n");
		return -ENOMEM;
	}

	/* 
	 * Call the init function of the device drivers that has not been
	 * compiled as a module 
	 * Note : non-modular IrDA is not supported in 2.4.X, so don't
	 * waste too much time fixing this code. If you require it, please
	 * upgrade to the IrDA stack in 2.5.X. Jean II
	 */
#ifdef CONFIG_IRTTY_SIR
	irtty_init();
#endif
#ifdef CONFIG_WINBOND_FIR
	w83977af_init();
#endif
#ifdef CONFIG_SA1100_FIR
	sa1100_irda_init();
#endif
#ifdef CONFIG_NSC_FIR
	nsc_ircc_init();
#endif
#ifdef CONFIG_TOSHIBA_OLD
	toshoboe_init();
#endif
#ifdef CONFIG_SMC_IRCC_FIR
	ircc_init();
#endif
#ifdef CONFIG_ESI_DONGLE
	esi_init();
#endif
#ifdef CONFIG_TEKRAM_DONGLE
	tekram_init();
#endif
#ifdef CONFIG_ACTISYS_DONGLE
	actisys_init();
#endif
#ifdef CONFIG_GIRBIL_DONGLE
	girbil_init();
#endif
#ifdef CONFIG_LITELINK_DONGLE
	litelink_init();
#endif
#ifdef CONFIG_OLD_BELKIN
 	old_belkin_init();
#endif
#ifdef CONFIG_EP7211_IR
 	ep7211_ir_init();
#endif
#ifdef CONFIG_EP93XX_SIR
	ep93xx_sir_init();
#endif
#ifdef CONFIG_EP93XX_IRDA
	ep93xx_irda_init();
#endif
#ifdef CONFIG_MCP2120_DONGLE
	mcp2120_init();
#endif
	return 0;
}