Ejemplo n.º 1
0
int __init lnb_init(void)
{
	int res, err;
	const char *name;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
	err = lnb_detect(NULL, -1, &name);
#else
	struct i2c_board_info info;
	err = lnb_detect(NULL, -1, &info);
	name = info.type;
#endif

	if (err) {
		printk("[LNB]: Error detecting lnb type!\n");
		return err;
	}

	dprintk("[LNB] lnb power control handling, type: %s\n", name);

	if(devType == LNB_PIO) {
		if ((res = lnb_pio_init())) {
			dprintk("[LNB] init lnb pio failed\n");
			return res;
		}
	} else {
		if ((res = i2c_add_driver(&lnb_i2c_driver))) {
			dprintk("[LNB] i2c add driver failed\n");
			return res;
		}

		if (!lnb_client) {
			printk(KERN_ERR "[LNB] no client found\n");
			i2c_del_driver(&lnb_i2c_driver);
			return -EIO;
		}
	}

	if (register_chrdev(LNB_MAJOR,"LNB",&lnb_fops)<0) {
		printk(KERN_ERR "[LNB] unable to register device\n");
		if(devType == LNB_PIO)
			lnb_pio_exit();
		else
			i2c_del_driver(&lnb_i2c_driver);
		return -EIO;
	}

	return 0;
}
Ejemplo n.º 2
0
int __init lnb_init(void)
{
	int res, err;
	const char *name;

	struct i2c_board_info info;
	err = lnb_detect(NULL, -1, &info);
	name = info.type;

	if (err)
	{
		dprintk(1, "Unknown LNB type\n");
		return err;
	}

	if (devType == LNB_PIO)
	{
		res = lnb_pio_init();
		if (res)
		{
			dprintk(1, "Init LNB PIO failed\n");
			return res;
		}
	}
	else
	{
		res = i2c_add_driver(&lnb_i2c_driver);
		if (res)
		{
			dprintk(1, "Adding i2c driver failed\n");
			return res;
		}
	}

	if (!lnb_client)
	{
		dprintk(1, "No client found\n");
		i2c_del_driver(&lnb_i2c_driver);
		return -EIO;
	}
	
	if (register_chrdev(LNB_MAJOR, "LNB", &lnb_fops) < 0)
	{
		dprintk(1, "Unable to register device\n");
		if (devType == LNB_PIO)
		{
			lnb_pio_exit();
		}
		else
		{
			i2c_del_driver(&lnb_i2c_driver);
		}
		return -EIO;
	}
	dprintk(1,"module lnb loaded, type: %s\n", name);
	return 0;
}