示例#1
0
static ssize_t p61_dev_read(struct file *filp, char  *buf,
                size_t count, loff_t *offset)
{
	int ret = -1;
	struct p61_dev *p61_dev = filp->private_data;
    NFC_DBG_MSG(KERN_ALERT "p61_dev_read - Enter \n");
   	mutex_lock(&p61_dev->read_mutex);
	NFC_DBG_MSG(KERN_ALERT "p61_dev_read - aquried mutex - calling spi_read \n");
	NFC_DBG_MSG(KERN_ALERT "p61_dev_read - test1 count [0x%x] \n",count);
	/** Read data */
#ifdef IRQ_ENABLE
    NFC_DBG_MSG(KERN_ALERT "************ Test11 *****************\n");
    if (!gpio_get_value(p61_dev->irq_gpio))
    {
        while (1)
        {
		 NFC_DBG_MSG(KERN_ALERT "************ Test1 *****************\n");
        	NFC_DBG_MSG(" %s inside while(1) \n", __FUNCTION__);
            p61_dev->irq_enabled = true;
            enable_irq(p61_dev->spi->irq);
            ret = wait_event_interruptible(p61_dev->read_wq,!p61_dev->irq_enabled);
            p61_disable_irq(p61_dev);
            if (ret)
            {
            	NFC_DBG_MSG("p61_disable_irq() : Failed\n");
                goto fails;
            }
	    NFC_DBG_MSG(KERN_ALERT "************ Test2 *****************\n");
            if (gpio_get_value(p61_dev->irq_gpio))
                break;

            NFC_DBG_MSG("%s: spurious interrupt detected\n", __func__);
        }
    }

    NFC_DBG_MSG(KERN_ALERT "************  gpio already high read data Test11 *****************\n");
#endif
	NFC_DBG_MSG(KERN_ALERT "************ Test3 *****************\n");
	ret = spi_read (p61_dev -> spi,(void *) buf, count);
	if(0>ret)
	{
		NFC_ERR_MSG(KERN_ALERT "spi_read returns -1 \n");
		goto fails;
	}

	NFC_DBG_MSG(KERN_ALERT "Read ret %d \n",ret);

	mutex_unlock(&p61_dev->read_mutex);

	if (0 == ret)
	{
		ret = count;
	}

	return ret;

	fails:
	mutex_unlock(&p61_dev->read_mutex);
	return ret;
}
示例#2
0
static irqreturn_t p61_dev_irq_handler(int irq, void *dev_id)
{
    struct p61_dev *p61_dev = dev_id;

    P61_DBG_MSG("Entry : %s\n", __FUNCTION__);
    p61_disable_irq(p61_dev);

    /* Wake up waiting readers */
    wake_up(&p61_dev->read_wq);

    P61_DBG_MSG("Exit : %s\n", __FUNCTION__);
    return IRQ_HANDLED;
}
示例#3
0
static int p61_probe(struct spi_device *spi)
{
    int ret = -1;
    struct p61_spi_platform_data *platform_data = NULL;
    struct p61_spi_platform_data platform_data1;
    struct p61_dev *p61_dev = NULL;
#ifdef P61_IRQ_ENABLE
    unsigned int irq_flags;
#endif

    P61_DBG_MSG("%s chip select : %d , bus number = %d \n",
            __FUNCTION__, spi->chip_select, spi->master->bus_num);
#if !DRAGON_P61
    platform_data = spi->dev.platform_data;
    if (platform_data == NULL)
    {
        /* RC : rename the platformdata1 name */
        /* TBD: This is only for Panda as we are passing NULL for platform data */
        P61_ERR_MSG("%s : p61 probe fail\n", __func__);
        platform_data1.irq_gpio = P61_IRQ;
        platform_data1.rst_gpio = P61_RST;
        platform_data = &platform_data1;
        P61_ERR_MSG("%s : p61 probe fail1\n", __func__);
        //return  -ENODEV;
    }
#else
    ret = p61_parse_dt(&spi->dev, &platform_data1);
    if (ret) {
        pr_err("%s - Failed to parse DT\n", __func__);
        goto err_exit;
    }
    platform_data = &platform_data1;
#endif
    p61_dev = kzalloc(sizeof(*p61_dev), GFP_KERNEL);
    if (p61_dev == NULL)
    {
        P61_ERR_MSG("failed to allocate memory for module data\n");
        ret = -ENOMEM;
        goto err_exit;
    }
    ret = p61_hw_setup (platform_data, p61_dev, spi);
    if (ret < 0)
    {
        P61_ERR_MSG("Failed to p61_enable_P61_IRQ_ENABLE\n");
        goto err_exit0;
    }

    spi->bits_per_word = 8;
    spi->mode = SPI_MODE_0;
    spi->max_speed_hz = P61_SPI_CLOCK;
    //spi->chip_select = SPI_NO_CS;
    ret = spi_setup(spi);
    if (ret < 0)
    {
        P61_ERR_MSG("failed to do spi_setup()\n");
        goto err_exit0;
    }

    p61_dev -> spi = spi;
    p61_dev -> p61_device.minor = MISC_DYNAMIC_MINOR;
    p61_dev -> p61_device.name = "p73";
    p61_dev -> p61_device.fops = &p61_dev_fops;
    p61_dev -> p61_device.parent = &spi->dev;
    p61_dev->irq_gpio = platform_data->irq_gpio;
    p61_dev->rst_gpio  = platform_data->rst_gpio;


    dev_set_drvdata(&spi->dev, p61_dev);

    /* init mutex and queues */
    init_waitqueue_head(&p61_dev->read_wq);
    mutex_init(&p61_dev->read_mutex);
    mutex_init(&p61_dev->write_mutex);


#ifdef P61_IRQ_ENABLE
    spin_lock_init(&p61_dev->irq_enabled_lock);
#endif

    ret = misc_register(&p61_dev->p61_device);
    if (ret < 0)
    {
        P61_ERR_MSG("misc_register failed! %d\n", ret);
        goto err_exit0;
    }

#ifdef P61_IRQ_ENABLE
    p61_dev->spi->irq = gpio_to_irq(platform_data->irq_gpio);

    if ( p61_dev->spi->irq < 0)
    {
        P61_ERR_MSG("gpio_to_irq request failed gpio = 0x%x\n", platform_data->irq_gpio);
        goto err_exit1;
    }
    /* request irq.  the irq is set whenever the chip has data available
         * for reading.  it is cleared when all data has been read.
         */
    p61_dev->irq_enabled = true;
    p61_through_put_t.enable_through_put_measure = false;
    irq_flags = IRQF_TRIGGER_RISING | IRQF_ONESHOT;

    ret = request_irq(p61_dev->spi->irq, p61_dev_irq_handler,
                          irq_flags, p61_dev -> p61_device.name, p61_dev);
    if (ret)
    {
        P61_ERR_MSG("request_irq failed\n");
        goto err_exit1;
    }
    p61_disable_irq(p61_dev);

#endif

    p61_dev-> enable_poll_mode = 0; /* Default IRQ read mode */
    P61_DBG_MSG("Exit : %s\n", __FUNCTION__);
    return ret;
    err_exit1:
    misc_deregister(&p61_dev->p61_device);
    err_exit0:
    mutex_destroy(&p61_dev->read_mutex);
    mutex_destroy(&p61_dev->write_mutex);
    if(p61_dev != NULL)
        kfree(p61_dev);
    err_exit:
    P61_DBG_MSG("ERROR: Exit : %s ret %d\n", __FUNCTION__, ret);
    return ret;
}
示例#4
0
static ssize_t p61_dev_read(struct file *filp, char *buf, size_t count,
        loff_t *offset)
{
    int ret = -EIO;
    struct p61_dev *p61_dev = filp->private_data;
    unsigned char rx_buffer[MAX_BUFFER_SIZE];

    P61_DBG_MSG("p61_dev_read count %d - Enter \n", count);

    mutex_lock(&p61_dev->read_mutex);
    if (count > MAX_BUFFER_SIZE)
    {
        count = MAX_BUFFER_SIZE;
    }

    memset(&rx_buffer[0], 0x00, sizeof(rx_buffer));

    if (p61_dev->enable_poll_mode)
    {
        P61_DBG_MSG(" %s Poll Mode Enabled \n", __FUNCTION__);

        P61_DBG_MSG(KERN_INFO"SPI_READ returned 0x%x", count);
        ret = spi_read(p61_dev->spi, (void *)&rx_buffer[0], count);
        if (0 > ret)
        {
            P61_ERR_MSG(KERN_ALERT "spi_read failed [SOF] \n");
            goto fail;
        }
    }
    else
    {
#ifdef P61_IRQ_ENABLE
        P61_DBG_MSG(" %s Interrrupt Mode Enabled \n", __FUNCTION__);
        if (!gpio_get_value(p61_dev->irq_gpio))
        {
            if (filp->f_flags & O_NONBLOCK)
            {
                ret = -EAGAIN;
                goto fail;
            }
            while (1)
            {
                P61_DBG_MSG(" %s waiting for interrupt \n", __FUNCTION__);
                p61_dev->irq_enabled = true;
                enable_irq(p61_dev->spi->irq);
                ret = wait_event_interruptible(p61_dev->read_wq,!p61_dev->irq_enabled);
                p61_disable_irq(p61_dev);
                if (ret)
                {
                    P61_ERR_MSG("wait_event_interruptible() : Failed\n");
                    goto fail;
                }

                if (gpio_get_value(p61_dev->irq_gpio))
                    break;

                P61_ERR_MSG("%s: spurious interrupt detected\n", __func__);
            }
        }
#else
    P61_ERR_MSG(" %s P61_IRQ_ENABLE not Enabled \n", __FUNCTION__);
#endif
        ret = spi_read(p61_dev->spi, (void *)&rx_buffer[0], count);
        if (0 > ret)
        {
            P61_DBG_MSG(KERN_INFO"SPI_READ returned 0x%x", ret);
            ret = -EIO;
            goto fail;
        }
    }


    if(p61_through_put_t.enable_through_put_measure)
        p61_start_throughput_measurement(READ_THROUGH_PUT);

    if(p61_through_put_t.enable_through_put_measure)
        p61_stop_throughput_measurement (READ_THROUGH_PUT, count);
    P61_DBG_MSG(KERN_INFO"total_count = %d", count);

    if (copy_to_user(buf, &rx_buffer[0], count))
    {
        P61_ERR_MSG("%s : failed to copy to user space\n", __func__);
        ret = -EFAULT;
        goto fail;
    }
    P61_DBG_MSG("p61_dev_read ret %d Exit\n", ret);
    P61_DBG_MSG("p61_dev_read ret %d Exit\n", rx_buffer[0]);

    mutex_unlock(&p61_dev->read_mutex);

    return ret;

    fail:
    P61_ERR_MSG("Error p61_dev_read ret %d Exit\n", ret);
    mutex_unlock(&p61_dev->read_mutex);
    return ret;
}
示例#5
0
static ssize_t p61_dev_read(struct file *filp, char *buf, size_t count,
                            loff_t *offset)
{
    int ret = -EIO;
    struct p61_dev *p61_dev = filp->private_data;
    unsigned char sof = 0x00;
    int total_count = 0;
    unsigned char rx_buffer[MAX_BUFFER_SIZE];

    P61_DBG_MSG("p61_dev_read count %zu - Enter \n", count);

    if (count < MAX_BUFFER_SIZE)
    {
        P61_ERR_MSG(KERN_ALERT "Invalid length (min : 258) [%zu] \n", count);
        return -EINVAL;
    }
    mutex_lock(&p61_dev->read_mutex);
    if (count > MAX_BUFFER_SIZE)
    {
        count = MAX_BUFFER_SIZE;
    }

    memset(&rx_buffer[0], 0x00, sizeof(rx_buffer));

    if (p61_dev->enable_poll_mode)
    {
        P61_DBG_MSG(" %s Poll Mode Enabled \n", __FUNCTION__);
        do
        {
            sof = 0x00;
            P61_DBG_MSG(KERN_INFO"SPI_READ returned 0x%x", sof);
            ret = spi_read(p61_dev->spi, (void *)&sof, 1);
            if (0 > ret)
            {
                P61_ERR_MSG(KERN_ALERT "spi_read failed [SOF] \n");
                goto fail;
            }
            P61_DBG_MSG(KERN_INFO"SPI_READ returned 0x%x", sof);
            /* if SOF not received, give some time to P61 */
            /* RC put the conditional delay only if SOF not received */
            if (sof != SOF)
                usleep_range(5000, 5100);
        } while(sof != SOF);
    }
    else
    {
#ifdef P61_IRQ_ENABLE
        P61_DBG_MSG(" %s Interrrupt Mode Enabled \n", __FUNCTION__);
        if (!gpio_get_value(p61_dev->irq_gpio))
        {
            if (filp->f_flags & O_NONBLOCK)
            {
                ret = -EAGAIN;
                goto fail;
            }
            while (1)
            {
                P61_DBG_MSG(" %s waiting for interrupt \n", __FUNCTION__);
                p61_dev->irq_enabled = true;
                enable_irq(p61_dev->spi->irq);
                ret = wait_event_interruptible(p61_dev->read_wq,!p61_dev->irq_enabled);
                p61_disable_irq(p61_dev);
                if (ret)
                {
                    P61_ERR_MSG("wait_event_interruptible() : Failed\n");
                    goto fail;
                }

                if (gpio_get_value(p61_dev->irq_gpio))
                    break;

                P61_ERR_MSG("%s: spurious interrupt detected\n", __func__);
            }
        }
#else
        P61_ERR_MSG(" %s P61_IRQ_ENABLE not Enabled \n", __FUNCTION__);
#endif
        /* read the SOF */
        sof = 0x00;
        ret = spi_read(p61_dev->spi, (void *)&sof, 1);
        if ((0 > ret) || (sof != SOF))
        {
            P61_DBG_MSG(KERN_INFO"SPI_READ returned 0x%x", sof);
            P61_ERR_MSG(KERN_ALERT "spi_read failed [SOF] 0x%x\n", ret);
            ret = -EIO;
            goto fail;
        }
    }


    total_count = 1;
    rx_buffer[0] = sof;
    /* Read the HEADR of Two bytes*/
    ret = spi_read(p61_dev->spi, (void *)&rx_buffer[1], 2);
    if (ret < 0)
    {
        P61_ERR_MSG(KERN_ALERT "spi_read fails after [PCB] \n");
        ret = -EIO;
        goto fail;
    }

    total_count += 2;
    /* Get the data length */
    count = rx_buffer[2];
    P61_DBG_MSG(KERN_INFO"Data Lenth = %zu", count);
    /* Read the availabe data along with one byte LRC */
    ret = spi_read(p61_dev->spi, (void *)&rx_buffer[3], (count+1));
    if (ret < 0)
    {
        P61_ERR_MSG("spi_read failed \n");
        ret = -EIO;
        goto fail;
    }
    total_count = (total_count + (count+1));
    P61_DBG_MSG(KERN_INFO"total_count = %d", total_count);

    if (copy_to_user(buf, &rx_buffer[0], total_count))
    {
        P61_ERR_MSG("%s : failed to copy to user space\n", __func__);
        ret = -EFAULT;
        goto fail;
    }
    ret = total_count;
    P61_DBG_MSG("p61_dev_read ret %d Exit\n", ret);

    mutex_unlock(&p61_dev->read_mutex);

    return ret;

fail:
    P61_ERR_MSG("Error p61_dev_read ret %d Exit\n", ret);
    mutex_unlock(&p61_dev->read_mutex);
    return ret;
}
示例#6
0
static int p61_probe(struct spi_device *spi)
{
    int ret = -1;
    //struct p61_spi_platform_data *platform_data = NULL;
    //struct p61_spi_platform_data platform_data1;
    struct p61_dev *p61_dev = NULL;
#ifdef P61_IRQ_ENABLE
    unsigned int irq_flags;
#endif

    P61_DBG_MSG("%s chip select : %d , bus number = %d \n",
                __FUNCTION__, spi->chip_select, spi->master->bus_num);

    //platform_data = spi->dev.platform_data;
#if 0
    if (platform_data == NULL)
    {
        /* RC : rename the platformdata1 name */
        /* TBD: This is only for Panda as we are passing NULL for platform data */
        P61_ERR_MSG("%s : p61 probe fail\n", __func__);
        //platform_data1.irq_gpio = P61_IRQ;
        //platform_data1.rst_gpio = P61_RST;
        //platform_data = &platform_data1;
        P61_ERR_MSG("%s : p61 probe fail1\n", __func__);
        return  -ENODEV;
    }
#endif
    p61_dev = kzalloc(sizeof(*p61_dev), GFP_KERNEL);
    if (p61_dev == NULL)
    {
        P61_ERR_MSG("failed to allocate memory for module data\n");
        ret = -ENOMEM;
        goto err_exit;
    }

    ret = p61_parse_dt(&spi->dev, p61_dev);
    if (ret) {
        pr_err("%s - Failed to parse DT\n", __func__);
        goto p61_parse_dt_failed;
    }
    pr_info("%s: tz_mode=%d, isGpio_cfgDone:%d\n", __func__,
            p61_dev->tz_mode, p61_dev->isGpio_cfgDone);

#if 0
    ret = p61_hw_setup (platform_data, p61_dev, spi);
    if (ret < 0)
    {
        P61_ERR_MSG("Failed to p61_enable_P61_IRQ_ENABLE\n");
        goto err_exit0;
    }
#endif

    spi->bits_per_word = 8;
    spi->mode = SPI_MODE_0;
    spi->max_speed_hz = P61_SPI_CLOCK;
    //spi->chip_select = SPI_NO_CS;
    ret = spi_setup(spi);
    if (ret < 0)
    {
        P61_ERR_MSG("failed to do spi_setup()\n");
        goto p61_spi_setup_failed;
    }

    p61_dev -> spi = spi;
    p61_dev -> p61_device.minor = MISC_DYNAMIC_MINOR;
    p61_dev -> p61_device.name = "p61";
    p61_dev -> p61_device.fops = &p61_dev_fops;
    p61_dev -> p61_device.parent = &spi->dev;
    // p61_dev->irq_gpio = platform_data->irq_gpio;
    //p61_dev->rst_gpio  = platform_data->rst_gpio;


    dev_set_drvdata(&spi->dev, p61_dev);

    /* init mutex and queues */
    init_waitqueue_head(&p61_dev->read_wq);
    mutex_init(&p61_dev->read_mutex);
    mutex_init(&p61_dev->write_mutex);
    spin_lock_init(&p61_dev->ese_spi_lock);


#ifdef P61_IRQ_ENABLE
    spin_lock_init(&p61_dev->irq_enabled_lock);
#endif

    wake_lock_init(&p61_dev->ese_lock, WAKE_LOCK_SUSPEND, "ese_wake_lock");
    ret = misc_register(&p61_dev->p61_device);
    if (ret < 0)
    {
        P61_ERR_MSG("misc_register failed! %d\n", ret);
        goto err_exit0;
    }

#if 0 //test
    {
        struct device *dev;

        p61_device_class = class_create(THIS_MODULE, "ese");
        if (IS_ERR(p61_device_class)) {
            pr_err("%s class_create() is failed:%lu\n",
                   __func__,  PTR_ERR(p61_device_class));
            //status = PTR_ERR(p61_device_class);
            //goto vfsspi_probe_class_create_failed;
        }
        dev = device_create(p61_device_class, NULL,
                            0, p61_dev, "p61");
        pr_err("%s device_create() is failed:%lu\n",
               __func__,  PTR_ERR(dev));

        if ((device_create_file(dev, &dev_attr_test)) < 0)
            pr_err("%s device_create_file failed !!!\n", __func__);
        else
            pr_info("%s device_create_file success.\n", __func__);
        //ret = sysfs_create_group(&spi->dev.kobj,
        //		&p61_attribute_group);
        //if (ret < 0)
        //	pr_err("%s class_create() is failed - \n",
        //		__func__,  PTR_ERR(p61_device_class));
    }
#endif

#ifdef P61_IRQ_ENABLE
    p61_dev->spi->irq = gpio_to_irq(platform_data->irq_gpio);

    if ( p61_dev->spi->irq < 0)
    {
        P61_ERR_MSG("gpio_to_irq request failed gpio = 0x%x\n",
                    platform_data->irq_gpio);
        goto err_exit1;
    }
    /* request irq.  the irq is set whenever the chip has data available
    * for reading.  it is cleared when all data has been read.
    */
    p61_dev->irq_enabled = true;
    irq_flags = IRQF_TRIGGER_RISING | IRQF_ONESHOT;

    ret = request_irq(p61_dev->spi->irq, p61_dev_irq_handler,
                      irq_flags, p61_dev -> p61_device.name, p61_dev);
    if (ret)
    {
        P61_ERR_MSG("request_irq failed\n");
        goto err_exit1;
    }
    p61_disable_irq(p61_dev);
#endif

    p61_dev-> enable_poll_mode = 1; /* Default IRQ read mode */
    P61_DBG_MSG("%s finished...\n", __FUNCTION__);
    return ret;

    //err_exit1:
    misc_deregister(&p61_dev->p61_device);
err_exit0:
    mutex_destroy(&p61_dev->read_mutex);
    mutex_destroy(&p61_dev->write_mutex);
    wake_lock_destroy(&p61_dev->ese_lock);

p61_spi_setup_failed:
p61_parse_dt_failed:
    if(p61_dev != NULL)
        kfree(p61_dev);
err_exit:
    P61_DBG_MSG("ERROR: Exit : %s ret %d\n", __FUNCTION__, ret);
    return ret;
}
示例#7
0
static int __devinit p61_probe(struct spi_device *spi)
{
	int ret = 0;
	struct p61_dev *p61_dev=NULL;
	unsigned int irq_flags;
	printk("P61 with irq without log Entry : %s\n", __FUNCTION__);

	NFC_DBG_MSG("chip select : %d , bus number = %d \n", spi->chip_select, spi->master->bus_num);
	p61_dev = kzalloc(sizeof(*p61_dev), GFP_KERNEL);
	if (p61_dev == NULL)
	{
		NFC_ERR_MSG("failed to allocate memory for module data\n");
		ret = -ENOMEM;
		goto err_exit;
	}
	
	ret = gpio_request( P61_RST, "p61 reset");
	if (ret < 0)
	{
		NFC_ERR_MSG("p61 gpio reset request failed = 0x%x\n", P61_RST);
		goto fail_gpio;
	}

	NFC_ERR_MSG("gpio_request returned = 0x%x\n", ret);
	ret = gpio_direction_output(P61_RST,0);
	if (ret < 0)
	{
		NFC_ERR_MSG("p61 gpio rst request failed gpio = 0x%x\n", P61_RST);
		goto fail_gpio;
	}
	NFC_ERR_MSG("gpio_direction_output returned = 0x%x\n", ret);

	
#ifdef IRQ_ENABLE
    	ret = gpio_request( P61_IRQ, "p61 irq");
    	if (ret < 0)
    	{
    		NFC_ERR_MSG("p61 gpio request failed gpio = 0x%x\n", P61_IRQ);
    		goto err_exit0;
    	}

    	ret = gpio_direction_input(P61_IRQ);
    	if (ret < 0)
    	{
    		NFC_ERR_MSG("p61 gpio request failed gpio = 0x%x\n", P61_IRQ);
    		goto err_exit0;
    	}
#endif

	spi->bits_per_word = 8;
	spi->mode = SPI_MODE_0;
	spi->max_speed_hz = 7000000;//1000000;
	//spi->chip_select = SPI_NO_CS;
	ret = spi_setup(spi);
	if (ret < 0)
	{
		NFC_ERR_MSG("failed to do spi_setup()\n");
		goto err_exit0;
	}

	p61_dev -> spi = spi;
	p61_dev -> p61_device.minor = MISC_DYNAMIC_MINOR;
	p61_dev -> p61_device.name = "p61";
	p61_dev -> p61_device.fops = &p61_dev_fops;
	p61_dev -> p61_device.parent = &spi->dev;

	p61_dev -> ven_gpio = P61_RST;
	
	gpio_set_value(P61_RST, 1);
	msleep(20);
	printk("p61_dev->rst_gpio = %d\n ",P61_RST);
#ifdef IRQ_ENABLE
	p61_dev->irq_gpio = P61_IRQ;
#endif
	
	p61_set_data(spi, p61_dev);
	/* init mutex and queues */
	init_waitqueue_head(&p61_dev->read_wq);
	mutex_init(&p61_dev->read_mutex);
	//spin_lock_init(&p61_dev->irq_enabled_lock);
#ifdef IRQ_ENABLE
	spin_lock_init(&p61_dev->irq_enabled_lock);
#endif

	ret = misc_register(&p61_dev->p61_device);
	if (ret < 0)
	{
		NFC_ERR_MSG("misc_register failed! %d\n", ret);
		goto err_exit0;
	}
#ifdef IRQ_ENABLE
    p61_dev->spi->irq = gpio_to_irq(P61_IRQ);

    if ( p61_dev->spi->irq < 0)
    {
    	NFC_ERR_MSG("gpio_to_irq request failed gpio = 0x%x\n", P61_IRQ);
        goto err_exit0;
    }
    /* request irq.  the irq is set whenever the chip has data available
         * for reading.  it is cleared when all data has been read.
         */
    p61_dev->irq_enabled = true;
    irq_flags = IRQF_TRIGGER_RISING | IRQF_ONESHOT;

    ret = request_irq(p61_dev->spi->irq, p61_dev_irq_handler,
                          irq_flags, p61_dev -> p61_device.name, p61_dev);
    if (ret)
    {
        NFC_ERR_MSG("request_irq failed\n");
        goto err_exit0;
    }
    p61_disable_irq(p61_dev);

#endif

	NFC_DBG_MSG("Exit : %s\n", __FUNCTION__);

	return ret;

//	err_exit1:
//	misc_deregister(&p61_dev->p61_device);
	err_exit0:
	mutex_destroy(&p61_dev->read_mutex);
        if(p61_dev != NULL)
	kfree(p61_dev);
	fail_gpio:
	gpio_free(P61_RST);
	err_exit:
	return ret;
}