Example #1
0
int init_module(void)
{
	int retval;
	
	retval=init_chrdev();
	if(retval < 0)
		return retval;
	retval = init_lirc_it87();
	if (retval) {
		drop_chrdev();
		return retval;
	}
	return 0;
}
/*!
 * This function initializes the driver in terms of memory of the soundcard
 * and some basic HW clock settings.
 *
 * @return              0 on success, -1 otherwise.
 */
static int __init usi_modem_ioctrl_probe(struct platform_device *pdev)
{
    int grc, irq = 0;
    
    dbg("%s, %s\n", __func__, "entry");
    
    #ifdef USI_MODEM_USBEN
    /* MODEM_USBEN */
    grc = gpio_request(USI_MODEM_USBEN, "modem-usben");
    if (grc)
        goto err_gpio_usben_req;

    grc = gpio_direction_output(USI_MODEM_USBEN, 1);
    if (grc)
        goto err_gpio_usben_dir;
    #endif

    #ifdef USI_MODEM_APReady
    /* MODEM_APReady */
    grc = gpio_request(USI_MODEM_APReady, "modem-apready");
    if (grc)
        goto err_gpio_apready_req;

    grc = gpio_direction_output(USI_MODEM_APReady, 1);
    if (grc)
        goto err_gpio_apready_dir;
    #endif

    #ifdef USI_MODEM_POWERKEY
    /* MODEM_POWERKEY */
    grc = gpio_request(USI_MODEM_POWERKEY, "modem-powerkey");
    if (grc)
        goto err_gpio_powerkey_req;

    grc = gpio_direction_output(USI_MODEM_POWERKEY, 0);
    if (grc)
        goto err_gpio_powerkey_dir;
    #endif

    #ifdef USI_MODEM_UARTEN
    /* MODEM_UARTEN */
    grc = gpio_request(USI_MODEM_UARTEN, "modem-uarten");
    if (grc)
        goto err_gpio_uarten_req;

    grc = gpio_direction_output(USI_MODEM_UARTEN, 1);
    if (grc)
        goto err_gpio_uarten_dir;
    #endif    
    
    #ifdef USI_MODEM_APWAKE
    /* MODEM_APWAKE */
    grc = gpio_request(USI_MODEM_APWAKE, "modem-apawake");
    if (grc) {
	goto err_gpio_apwake_req;
    }
    gpio_direction_input(USI_MODEM_APWAKE);
    irq	= gpio_to_irq(USI_MODEM_APWAKE);
    if(irq < 0)
    {
	gpio_free(USI_MODEM_APWAKE);
	printk("failed to request modem-apawake\n");
    }
    grc = request_irq(irq, detect_irq_handler, IRQ_BB_WAKEUP_AP_TRIGGER, "modem-apawake", NULL);
    if (grc < 0) {
	printk("%s: request_irq(%d) failed\n", __func__, irq);
	gpio_free(USI_MODEM_APWAKE);
	goto err_gpio_apwake_dir;
    }
    enable_irq_wake(irq);
    wake_lock_init(&modem_wakelock, WAKE_LOCK_SUSPEND, "modem-apawake");
    #endif

    /* Check Modem exist */
    modem_exist();

    /* Register character device */
    init_chrdev(&(pdev->dev));
    return 0;

#ifdef USI_MODEM_POWERKEY
err_gpio_powerkey_dir:
    printk(KERN_ERR "%s: USI_MODEM_POWERKEY gpio(%d) setting failed\n", __func__, USI_MODEM_POWERKEY);
    gpio_free(USI_MODEM_POWERKEY);

err_gpio_powerkey_req:
    printk(KERN_ERR "%s: USI_MODEM_POWERKEY gpio(%d) request failed\n", __func__, USI_MODEM_POWERKEY);
#endif

#ifdef USI_MODEM_UARTEN
err_gpio_uarten_dir:
    printk(KERN_ERR "%s: USI_MODEM_UARTEN gpio(%d) setting failed\n", __func__, USI_MODEM_UARTEN);
    gpio_free(USI_MODEM_UARTEN);

err_gpio_uarten_req:
    printk(KERN_ERR "%s: USI_MODEM_UARTEN gpio(%d) request failed\n", __func__, USI_MODEM_UARTEN);
#endif

#ifdef USI_MODEM_USBEN
err_gpio_usben_dir:
    printk(KERN_ERR "%s: USI_MODEM_USBEN gpio(%d) setting failed\n", __func__, USI_MODEM_USBEN);
    gpio_free(USI_MODEM_USBEN);

err_gpio_usben_req:
    printk(KERN_ERR "%s: USI_MODEM_USBEN gpio(%d) request failed\n", __func__, USI_MODEM_USBEN);
#endif

#ifdef USI_MODEM_APReady
err_gpio_apready_dir:
    printk(KERN_ERR "%s: USI_MODEM_APReady gpio(%d) setting failed\n", __func__, USI_MODEM_APReady);
    gpio_free(USI_MODEM_APReady);

err_gpio_apready_req:
    printk(KERN_ERR "%s: USI_MODEM_APReady gpio(%d) request failed\n", __func__, USI_MODEM_APReady);
#endif

#ifdef USI_MODEM_APWAKE
err_gpio_apwake_dir:
    printk(KERN_ERR "%s: USI_MODEM_APWAKE gpio(%d) setting failed\n", __func__, USI_MODEM_APWAKE);
    gpio_free(USI_MODEM_APWAKE);

err_gpio_apwake_req:
    printk(KERN_ERR "%s: USI_MODEM_APWAKE gpio(%d) request failed\n", __func__, USI_MODEM_APWAKE);
#endif
    return grc;
}