本文整理汇总了C++中pn544_disable_irq函数的典型用法代码示例。如果您正苦于以下问题:C++ pn544_disable_irq函数的具体用法?C++ pn544_disable_irq怎么用?C++ pn544_disable_irq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pn544_disable_irq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pn544_dev_read
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
char tmp[MAX_BUFFER_SIZE];
int ret, i;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
mutex_lock(&pn544_dev->read_mutex);
if (!gpio_get_value(pn544_dev->irq_gpio)) {
if (filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
goto fail;
}
pn544_dev->irq_enabled = true;
enable_irq(pn544_dev->client->irq);
ret = wait_event_interruptible(pn544_dev->read_wq,
gpio_get_value(pn544_dev->irq_gpio));
pn544_disable_irq(pn544_dev);
if (ret)
goto fail;
}
/* Read data */
ret = i2c_master_recv(pn544_dev->client, tmp, count);
mutex_unlock(&pn544_dev->read_mutex);
if (ret < 0) {
pr_err("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > count) {
pr_err("%s: received too many bytes from i2c (%d)\n",
__func__, ret);
return -EIO;
}
if (copy_to_user(buf, tmp, ret)) {
pr_warning("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}
for(i = 0; i < ret; i++){
printk(" %02X", tmp[i]);
}
return ret;
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
开发者ID:Nokius,项目名称:android_kernel_yotaphone2,代码行数:56,代码来源:pn544.c
示例2: pn544_i2c_read
static int pn544_i2c_read(int count)
{
char tmp[MAX_BUFFER_SIZE];
int ret, i;
if (!gpio_get_value(pn544_dev->irq_gpio)) {
enable_irq(pn544_dev->client->irq);
ret = wait_event_interruptible(pn544_dev->read_wq, gpio_get_value(pn544_dev->irq_gpio));
pn544_disable_irq(pn544_dev);
if (ret){
printk("[Nfc]wait_event_interruptible() fails");
goto fail;
}
}
/* Read data */
for(i=0; i<2; i++) {
ret = i2c_master_recv(pn544_dev->client, tmp, count);
/* pn544 seems to be slow in handling I2C read requests
* so add 1ms delay after recv operation */
udelay(1000);
if (ret < 0) {
printk("%s: i2c_master_recv returned %d\n", __func__, ret);
}
else if (ret > count) {
printk("%s: received too many bytes from i2c (%d)\n", __func__, ret);
}
else {
return I2C_TEST_PASS;
}
printk("[NFC] i2c_master_recv() retry....%d\n", i);
}
//printk("%s : reading %zu bytes.\n", __func__, count);
#if 0
printk("[Nfc]Received Data:\n");
for (i = 1; i < count; i++) {
printk("0x%02x, ", tmp[i] );
}
printk("\n");
#endif
/*if (copy_to_user(buf, tmp, ret)) {
pr_warning("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}*/
fail:
return I2C_TEST_NFC_FAIL;
}
开发者ID:blackjack4it,项目名称:android_kernel_asus_padfone_s,代码行数:54,代码来源:pn65n.c
示例3: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
pn544_disable_irq(pn544_dev);
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:itsmerajit,项目名称:kernel_otus,代码行数:11,代码来源:pn544-mot.c
示例4: __pn544_kread
static int __pn544_kread(void *dev, unsigned int length)
{
struct pn544_dev *pn544_dev = NULL;
char tmp[MAX_BUFFER_SIZE];
int ret = 0;
int irq_gpio_val = 0;
if(dev != NULL)
pn544_dev = (struct pn544_dev*)dev;
mutex_lock(&pn544_dev->read_mutex);
irq_gpio_val = gpio_get_value(pn544_dev->irq_gpio);
pr_debug(PN544_DRV_NAME ":IRQ GPIO = %d\n", irq_gpio_val);
if (irq_gpio_val == 0) {
pn544_dev->irq_enabled = true;
#ifdef READ_IRQ_MODIFY
do_reading=0;//DY_TEST
#endif
// enable_irq_wake(pn544_dev->client->irq);
// enable_irq(pn544_dev->client->irq);
enable_irq_wake(OMAP_GPIO_IRQ(pn544_dev->irq_gpio));
enable_irq(OMAP_GPIO_IRQ(pn544_dev->irq_gpio));
#ifdef READ_IRQ_MODIFY
ret = wait_event_interruptible(pn544_dev->read_wq, do_reading);
#else
ret = wait_event_interruptible(pn544_dev->read_wq, gpio_get_value(pn544_dev->irq_gpio));
#endif
pn544_disable_irq(pn544_dev);
if(ret)
goto fail;
}
memset(tmp, 0x00, MAX_BUFFER_SIZE);
ret = i2c_master_recv(pn544_dev->client, tmp, length);
while(tmp[0]==0x51&&tmp[1]==0xFF&&tmp[2]==0xFF){
ret = i2c_master_recv(pn544_dev->client, tmp, length);
printk("%s read retry!\n", __func__);
}
mutex_unlock(&pn544_dev->read_mutex);
printk("[seokmin] read data : 0x%X 0x%X 0x%X 0x%X\n", tmp[0], tmp[1], tmp[2], tmp[3]);
if (ret < 0) {
dprintk("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > length) {
dprintk("%s: received too many bytes from i2c (%d)\n", __func__);
return -EIO;
}
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
开发者ID:eklovya,项目名称:android_kernel_lge_p725,代码行数:53,代码来源:pn544_lge.c
示例5: pn544_irq_thread_fn
/* this function is used the irq handler*/
static irqreturn_t pn544_irq_thread_fn(int irq, void *dev_id)
{
PN544_DEBUG("%s:enter\n",__func__);
pn544_disable_irq(pn544_info);
pn544_info->read_irq = PN544_INT;
/* Wake up waiting readers */
wake_up(&pn544_info->read_wait);
return IRQ_HANDLED;
}
开发者ID:agrloki,项目名称:CeXstel-kernel-msm8x25,代码行数:14,代码来源:pn544.c
示例6: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
pr_info("[%s] in!\n", __func__);
pn544_disable_irq(pn544_dev);
#ifdef READ_IRQ_MODIFY
do_reading=1;//DY_TEST
#endif
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:eklovya,项目名称:android_kernel_lge_p725,代码行数:14,代码来源:pn544_lge.c
示例7: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
if (!gpio_get_value(pn544_dev->irq_gpio)) {
return IRQ_HANDLED;
}
pn544_disable_irq(pn544_dev);
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
printk("%s : IRQ trigger!\n", __func__);
return IRQ_HANDLED;
}
开发者ID:phenomx4,项目名称:android_kernel_n9510_n9520,代码行数:15,代码来源:pn544.c
示例8: pn544_remove
static int pn544_remove(struct i2c_client *client)
{
pn544_dev = i2c_get_clientdata(client);
pn544_disable_irq(pn544_dev);
free_irq(client->irq, pn544_dev);
misc_deregister(&pn544_dev->pn544_device);
mutex_destroy(&pn544_dev->read_mutex);
gpio_free(pn544_dev->irq_gpio);
gpio_free(pn544_dev->ven_gpio);
gpio_free(pn544_dev->firm_gpio);
kfree(pn544_dev);
pn544_dev = NULL;
return 0;
}
开发者ID:Nokius,项目名称:android_kernel_yotaphone2,代码行数:15,代码来源:pn544.c
示例9: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
dprintk(PN544_DRV_NAME ":pn544_dev_irq_handler : %d\n", irq);
pn544_disable_irq(pn544_dev);
#ifdef LGE_NFC_READ_IRQ_MODIFY
do_reading=1;//DY_TEST
#endif
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:Ntemis,项目名称:LG_X3_P880_v20a,代码行数:16,代码来源:pn544_lge.c
示例10: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
pn544_disable_irq(pn544_dev);
#ifdef FEATURE_PN544_KERNEL_LOG
pr_info("==> %s (ven, firm, irq)=(%d, %d, %d)\n", __func__, gpio_get_value(pn544_dev->ven_gpio), gpio_get_value(pn544_dev->firm_gpio), gpio_get_value(pn544_dev->irq_gpio));
#endif
#ifdef READ_IRQ_MODIFY
do_reading=1;
#endif
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:phuthinh100,项目名称:Kernel-JB--sky-A830L,代码行数:16,代码来源:pn544.c
示例11: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
pn544_disable_irq(pn544_dev);
#ifdef NXP_KR_PENDING_READ
irq_nfc = true;
#endif
#if 0 //def FEATURE_PN544_KERNEL_LOG
pr_info("==> %s (ven, firm, irq)=(%d, %d, %d) \n", __func__, VEN_GET_VALUE(pn544_dev->ven_gpio), FW_DL_GET_VALUE(pn544_dev->firm_gpio), gpio_get_value(pn544_dev->irq_gpio));
#endif
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:CM11MOD,项目名称:android_kernel_pantech_ef60s,代码行数:17,代码来源:pn544.c
示例12: pn544_dev_irq_handler
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id)
{
struct pn544_dev *pn544_dev = dev_id;
//FIH-SW2-PERIPHERAL-BJ-NFC_Porting-00+[
if (!gpio_get_value(pn544_dev->irq_gpio))
{
return IRQ_HANDLED;
}
//FIH-SW2-PERIPHERAL-BJ-NFC_Porting-00+]
pn544_disable_irq(pn544_dev);
/* Wake up waiting readers */
wake_up(&pn544_dev->read_wq);
return IRQ_HANDLED;
}
开发者ID:Zoldyck07,项目名称:SXDNickiSS,代码行数:18,代码来源:pn544.c
示例13: pn544_remove
static int pn544_remove(struct i2c_client *client)
{
printk("pn544_remove start\n");
pmu_disable();
pn544_dev = i2c_get_clientdata(client);
pn544_disable_irq(pn544_dev);
free_irq(client->irq, pn544_dev);
misc_deregister(&pn544_dev->pn544_device);
mutex_destroy(&pn544_dev->read_mutex);
// wake_lock_destroy(&pn544_dev->wl);//FIXED Screen off transcation proformance issue
gpio_free(pn544_dev->irq_gpio);
gpio_free(pn544_dev->ven_gpio);
gpio_free(pn544_dev->firm_gpio);
kfree(pn544_dev);
pn544_dev = NULL;
printk("pn544_remove end\n");
return 0;
}
开发者ID:moonlightly,项目名称:NX523J_kernel,代码行数:19,代码来源:pn547.c
示例14: pn544_dev_read
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
char *data;
int ret;
int tries = 0;
data = kzalloc(count, GFP_KERNEL);
if (!data) {
pr_err("%s: could not allocate buffer\n", __func__);
return -ENOMEM;
}
pr_debug("%s : reading %zu bytes.\n", __func__, count);
mutex_lock(&pn544_dev->read_mutex);
if (!gpio_get_value(pn544_dev->irq_gpio)) {
if (filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
mutex_unlock(&pn544_dev->read_mutex);
goto free_buf;
}
pn544_dev->irq_enabled = true;
irq_set_irq_wake(pn544_dev->client->irq, 1);
enable_irq(pn544_dev->client->irq);
ret = wait_event_interruptible(pn544_dev->read_wq,
gpio_get_value(pn544_dev->irq_gpio));
pn544_disable_irq(pn544_dev);
if (ret) {
mutex_unlock(&pn544_dev->read_mutex);
goto free_buf;
}
}
/* Read data */
do {
ret = i2c_master_recv(pn544_dev->client, data, count);
if (ret < 0)
msleep_interruptible(5);
} while ((ret < 0) && (++tries < 5));
mutex_unlock(&pn544_dev->read_mutex);
if (ret < 0) {
pr_err("%s: i2c_master_recv failed, returned %d\n",
__func__, ret);
goto free_buf;
}
if (copy_to_user(buf, data, count)) {
pr_err("%s : failed to copy to user space\n", __func__);
ret = -EFAULT;
}
free_buf:
kfree(data);
return ret;
}
开发者ID:itsmerajit,项目名称:kernel_otus,代码行数:64,代码来源:pn544-mot.c
示例15: pn544_probe
//.........这里部分代码省略.........
if (pn544_dev == NULL) {
dev_err(&client->dev,
"failed to allocate memory for module data\n");
ret = -ENOMEM;
goto err_exit;
}
ret = pn544_gpio_init(platform_data);
if (ret) {
dev_err(&client->dev, "gpio init failed\n");
goto err_gpio_init;
}
pn544_dev->irq_gpio = platform_data->irq_gpio;
pn544_dev->ven_gpio = platform_data->ven_gpio;
pn544_dev->firmware_gpio = platform_data->firmware_gpio;
pn544_dev->ven_polarity = platform_data->ven_polarity;
pn544_dev->discharge_delay = platform_data->discharge_delay;
pn544_dev->client = client;
pn544_dev->vdd = regulator_get(&client->dev, "vdd");
if (IS_ERR(pn544_dev->vdd)) {
dev_info(&client->dev, "vdd regulator control absent\n");
pn544_dev->vdd = NULL;
}
if (pn544_dev->vdd != NULL) {
regulator_set_voltage(pn544_dev->vdd, 2950000, 2950000);
ret = regulator_enable(pn544_dev->vdd);
if (ret < 0) {
dev_err(&client->dev, "Error enabling vddswp regulator\n");
goto err_en_regulator_swp;
}
}
/* init mutex and queues */
init_waitqueue_head(&pn544_dev->read_wq);
mutex_init(&pn544_dev->read_mutex);
spin_lock_init(&pn544_dev->irq_enabled_lock);
pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
pn544_dev->pn544_device.name = "pn544";
pn544_dev->pn544_device.fops = &pn544_dev_fops;
ret = misc_register(&pn544_dev->pn544_device);
if (ret) {
pr_err("%s : misc_register failed.\n", __FILE__);
goto err_misc_register;
}
pr_debug("%s : PN544 Misc Minor: %d\n",
__func__, pn544_dev->pn544_device.minor);
/* Get the device structure */
pn544_dev->pn544_control_device = pn544_dev->pn544_device.this_device;
/* Create sysfs device for PN544 control functionality */
ret = device_create_file(pn544_dev->pn544_control_device,
&dev_attr_pn544_control_dev);
if (ret) {
pr_err("%s : device_create_file failed\n", __FILE__);
goto err_device_create_file_failed;
}
/* request irq. the irq is set whenever the chip has data available
* for reading. it is cleared when all data has been read.
*/
pr_debug("%s : requesting IRQ %d\n", __func__, client->irq);
pn544_dev->irq_enabled = true;
ret = request_irq(client->irq, pn544_dev_irq_handler,
IRQF_TRIGGER_HIGH, client->name, pn544_dev);
if (ret) {
dev_err(&client->dev, "request_irq failed\n");
goto err_request_irq_failed;
}
if (unlikely(irq_set_irq_wake(client->irq, 1)))
pr_err("%s : unable to make irq %d wakeup\n", __func__,
client->irq);
pn544_disable_irq(pn544_dev);
i2c_set_clientdata(client, pn544_dev);
return 0;
err_request_irq_failed:
device_remove_file(pn544_dev->pn544_control_device,
&dev_attr_pn544_control_dev);
err_device_create_file_failed:
misc_deregister(&pn544_dev->pn544_device);
err_misc_register:
mutex_destroy(&pn544_dev->read_mutex);
pn544_gpio_free(pn544_dev);
if (pn544_dev->vdd != NULL)
regulator_disable(pn544_dev->vdd);
err_en_regulator_swp:
if (pn544_dev->vdd != NULL)
regulator_put(pn544_dev->vdd);
err_gpio_init:
kfree(pn544_dev);
err_exit:
return ret;
}
开发者ID:itsmerajit,项目名称:kernel_otus,代码行数:101,代码来源:pn544-mot.c
示例16: pn544_dev_read
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
char tmp[MAX_BUFFER_SIZE];
int ret;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
pr_debug("%s : reading %zu bytes.\n", __func__, count);
#ifdef FEATURE_PN544_KERNEL_LOG
pr_info("==> %s #1 (ven, firm, irq)=(%d, %d, %d)\n", __func__, gpio_get_value(pn544_dev->ven_gpio), gpio_get_value(pn544_dev->firm_gpio), gpio_get_value(pn544_dev->irq_gpio));
#endif
mutex_lock(&pn544_dev->read_mutex);
if (!gpio_get_value(pn544_dev->irq_gpio)) {
if (filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
goto fail;
}
pn544_dev->irq_enabled = true;
#ifdef READ_IRQ_MODIFY
do_reading=0;
#endif
enable_irq(pn544_dev->client->irq);
#ifdef READ_IRQ_MODIFY
ret = wait_event_interruptible(pn544_dev->read_wq, do_reading);
#else
ret = wait_event_interruptible(pn544_dev->read_wq,
gpio_get_value(pn544_dev->irq_gpio));
#endif
pn544_disable_irq(pn544_dev);
#ifdef READ_IRQ_MODIFY
if(cancle_read == true)
{
cancle_read = false;
ret = -1;
goto fail;
}
#endif
if (ret)
goto fail;
}
#ifdef FEATURE_PN544_KERNEL_LOG
pr_info("==> %s #2 (ven, firm, irq)=(%d, %d, %d)\n", __func__, gpio_get_value(pn544_dev->ven_gpio), gpio_get_value(pn544_dev->firm_gpio), gpio_get_value(pn544_dev->irq_gpio));
#endif
/* Read data */
ret = i2c_master_recv(pn544_dev->client, tmp, count);
mutex_unlock(&pn544_dev->read_mutex);
if (ret < 0) {
pr_err("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > count) {
pr_err("%s: received too many bytes from i2c (%d)\n",
__func__, ret);
return -EIO;
}
if (copy_to_user(buf, tmp, ret)) {
pr_warning("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}
return ret;
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
开发者ID:phuthinh100,项目名称:Kernel-JB--sky-A830L,代码行数:77,代码来源:pn544.c
示例17: pn544_dev_read
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
char tmp[MAX_BUFFER_SIZE];
int ret, i;
int calc = 0;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
NFC_DEBUG("%s : reading %zu bytes.\n", __func__, count);
mutex_lock(&pn544_dev->read_mutex);
wake_lock_timeout(&wlock_read, 1 * HZ);
NFC_DEBUG("%s : start to gpio_get_value with got value: %d\n",
__func__, gpio_get_value(pn544_dev->irq_gpio));
if (!gpio_get_value(pn544_dev->irq_gpio)) {
if (filp->f_flags & O_NONBLOCK) {
NFC_DEBUG("flip->f_flags=%u\n",filp->f_flags);
ret = -EAGAIN;
goto fail;
}
pn544_dev->irq_enabled = true;
NFC_DEBUG("%s : start to enable_irq.\n", __func__);
enable_irq(pn544_dev->client->irq);
NFC_DEBUG("%s : start to wait_event_interruptible.\n", __func__);
ret = wait_event_interruptible(pn544_dev->read_wq,
gpio_get_value(pn544_dev->irq_gpio));
NFC_DEBUG("%s : end to pn544_disable_irq, with ret: %d.\n", __func__, ret);
pn544_disable_irq(pn544_dev);
if (ret)
goto fail;
}
NFC_DEBUG("%s : start to i2c_master_recv.\n", __func__);
/* Read data */
while(calc <3)
{
calc ++;
ret = i2c_master_recv(pn544_dev->client, tmp, count);
if (ret < 0)
{
pr_info("%s : read data try =%d returned %d\n", __func__,calc,ret);
msleep(10);
continue;
}
else
break;
}
if (calc ==3) {
pr_err("%s : i2c_master_recv returned %d\n", __func__, ret);
ret = -EIO;
}
mutex_unlock(&pn544_dev->read_mutex);
NFC_DEBUG("%s : end to i2c_master_recv, with the ret: %d.\n", __func__, ret);
for(i=0; i<count; i++)
{
NFC_DEBUG("%s : read %x.\n", __func__, tmp[i]);
}
if (ret < 0) {
pr_err("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > count) {
pr_err("%s: received too many bytes from i2c (%d)\n",
__func__, ret);
return -EIO;
}
if (copy_to_user(buf, tmp, ret)) {
pr_err("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}
return ret;
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
开发者ID:serrvius,项目名称:huawei-p6,代码行数:92,代码来源:pn544.c
示例18: pn544_probe
static int pn544_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret;
struct pn544_i2c_platform_data *platform_data;
struct pn544_dev *pn544_dev;
platform_data = client->dev.platform_data;
if (platform_data == NULL) {
pr_err("%s : nfc probe fail\n", __func__);
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
pr_err("%s : need I2C_FUNC_I2C\n", __func__);
return -ENODEV;
}
ret = gpio_request(platform_data->irq_gpio, "nfc_int");
if (ret)
return -ENODEV;
ret = gpio_direction_input(platform_data->irq_gpio);
if (ret)
goto err_ven;
ret = gpio_request(platform_data->ven_gpio, "nfc_ven");
if (ret)
goto err_ven;
ret = gpio_direction_output(platform_data->ven_gpio, 0);
if (ret )
goto err_firm;
ret = gpio_request(platform_data->firm_gpio, "nfc_firm");
if (ret)
goto err_firm;
ret = gpio_direction_output(platform_data->firm_gpio, 0);
if (ret )
goto err_exit;
pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL);
if (pn544_dev == NULL) {
dev_err(&client->dev,
"failed to allocate memory for module data\n");
ret = -ENOMEM;
goto err_exit;
}
pn544_dev->irq_gpio = platform_data->irq_gpio;
pn544_dev->ven_gpio = platform_data->ven_gpio;
pn544_dev->firm_gpio = platform_data->firm_gpio;
pn544_dev->client = client;
/* init mutex and queues */
init_waitqueue_head(&pn544_dev->read_wq);
mutex_init(&pn544_dev->read_mutex);
spin_lock_init(&pn544_dev->irq_enabled_lock);
pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
pn544_dev->pn544_device.name = "pn544";
pn544_dev->pn544_device.fops = &pn544_dev_fops;
ret = misc_register(&pn544_dev->pn544_device);
if (ret) {
pr_err("%s : misc_register failed\n", __FILE__);
goto err_misc_register;
}
/* request irq. the irq is set whenever the chip has data available
* for reading. it is cleared when all data has been read.
*/
pr_info("%s : requesting IRQ %d\n", __func__, client->irq);
pn544_dev->irq_enabled = true;
ret = request_irq(client->irq, pn544_dev_irq_handler,
IRQF_TRIGGER_HIGH, client->name, pn544_dev);
if (ret) {
dev_err(&client->dev, "request_irq failed\n");
goto err_request_irq_failed;
}
pn544_disable_irq(pn544_dev);
i2c_set_clientdata(client, pn544_dev);
return 0;
err_request_irq_failed:
misc_deregister(&pn544_dev->pn544_device);
err_misc_register:
mutex_destroy(&pn544_dev->read_mutex);
kfree(pn544_dev);
err_exit:
gpio_free(platform_data->firm_gpio);
err_firm:
gpio_free(platform_data->ven_gpio);
err_ven:
gpio_free(platform_data->irq_gpio);
return ret;
}
开发者ID:phuthinh100,项目名称:Kernel-JB--sky-A830L,代码行数:100,代码来源:pn544.c
示例19: pn544_probe
static int pn544_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret;
struct pn544_i2c_platform_data *platform_data;
struct pn544_dev *pn544_dev = NULL;
dprintk(PN544_DRV_NAME ": pn544_probe() start\n");
pn544_client = client;
platform_data = client->dev.platform_data;
if (platform_data == NULL) {
pr_err("%s : nfc probe fail\n", __func__);
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
pr_err("%s : need I2C_FUNC_I2C\n", __func__);
return -ENODEV;
}
ret = gpio_request(platform_data->irq_gpio, "nfc_int");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_int request failed!\n");
return -ENODEV;
}
ret = gpio_request(platform_data->ven_gpio, "nfc_ven");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_ven request failed!\n");
goto err_ven;
}
ret = gpio_request(platform_data->firm_gpio, "nfc_firm");
if (ret) {
dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_firm request failed!\n");
goto err_firm;
}
pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL);
if (pn544_dev == NULL) {
dev_err(&client->dev,
"failed to allocate memory for module data\n");
ret = -ENOMEM;
goto err_exit;
}
pn544_dev->irq_gpio = platform_data->irq_gpio;
pn544_dev->ven_gpio = platform_data->ven_gpio;
pn544_dev->firm_gpio = platform_data->firm_gpio;
pn544_dev->client = client;
dprintk(PN544_DRV_NAME ":IRQ : %d\nVEN : %d\nFIRM : %d\n",
pn544_dev->irq_gpio, pn544_dev->ven_gpio, pn544_dev->firm_gpio);
pn544_gpio_enable(pn544_dev);
ret = gpio_direction_output(platform_data->ven_gpio,1);
ret = gpio_direction_output(platform_data->firm_gpio,0);
ret = gpio_direction_input(platform_data->irq_gpio);
/* init mutex and queues */
init_waitqueue_head(&pn544_dev->read_wq);
mutex_init(&pn544_dev->read_mutex);
spin_lock_init(&pn544_dev->irq_enabled_lock);
pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
pn544_dev->pn544_device.name = PN544_DRV_NAME;
pn544_dev->pn544_device.fops = &pn544_dev_fops;
ret = misc_register(&pn544_dev->pn544_device);
if (ret) {
pr_err("%s : misc_register failed\n", __FILE__);
goto err_misc_register;
}
/* request irq. the irq is set whenever the chip has data available
* for reading. it is cleared when all data has been read.
*/
pr_info("%s : requesting IRQ %d\n", __func__, client->irq);
pn544_dev->irq_enabled = true;
ret = request_irq(pn544_gpio_to_irq(pn544_dev), pn544_dev_irq_handler,
IRQF_TRIGGER_HIGH, client->name, pn544_dev);
if (ret) {
dev_err(&client->dev, "request_irq failed\n");
goto err_request_irq_failed;
}
#if !defined(LGE_NFC_HW_QCT_MSM8660)&&!defined(CONFIG_LGE_NFC_HW_QCT_MSM8255)
enable_irq_wake(pn544_get_irq_pin(pn544_dev));
#endif
pn544_disable_irq(pn544_dev);
i2c_set_clientdata(client, pn544_dev);
dprintk(PN544_DRV_NAME ": pn544_probe() end\n");
/*
*/
#ifdef CONFIG_LGE_NFC_MULTICORE_FASTBOOT
//.........这里部分代码省略.........
开发者ID:Ntemis,项目名称:LG_X3_P880_v20a,代码行数:101,代码来源:pn544_lge.c
示例20: pn544_dev_read
static ssize_t pn544_dev_read(struct file *filp, char __user *buf,
size_t count, loff_t *offset)
{
struct pn544_dev *pn544_dev = filp->private_data;
char tmp[MAX_BUFFER_SIZE];
int ret;
if (count > MAX_BUFFER_SIZE)
count = MAX_BUFFER_SIZE;
pr_debug("%s : reading %zu bytes.\n", __func__, count);
#if NFC_DEBUG
pr_info("pn544 : + r\n");
#endif
mutex_lock(&pn544_dev->read_mutex);
if(!gpio_get_value_cansleep(pn544_dev->irq_gpio)) {
if (filp->f_flags & O_NONBLOCK) {
pr_info("%s : O_NONBLOCK\n", __func__);
ret = -EAGAIN;
goto fail;
}
pn544_dev->irq_enabled = true;
do_reading=0;
enable_irq(pn544_dev->client->irq);
//ret =
wait_event(pn544_dev->read_wq,do_reading);
/* gpio_get_value(pn544_dev->irq_gpio)); */
/* pr_info("pn544 : h\n"); */
pn544_disable_irq(pn544_dev);
#if NFC_DEBUG
pr_info("pn544 : h\n");
#endif
#if 0
if (ret)
{
pr_info("pn544 : wait error[%d]\n", ret);
goto fail;
}
#endif
}
/* Read data */
ret = i2c_master_recv(pn544_dev->client, tmp, count);
mutex_unlock(&pn544_dev->read_mutex);
#if NFC_DEBUG
pr_info("pn544 : - r\n");
#endif
if (ret < 0) {
pr_err("%s: i2c_master_recv returned %d\n", __func__, ret);
return ret;
}
if (ret > count) {
pr_err("%s: received too many bytes from i2c (%d)\n",
__func__, ret);
return -EIO;
}
if (copy_to_user(buf, tmp, ret)) {
pr_warning("%s : failed to copy to user space\n", __func__);
return -EFAULT;
}
return ret;
fail:
mutex_unlock(&pn544_dev->read_mutex);
return ret;
}
开发者ID:CL0SeY,项目名称:i957kernel,代码行数:75,代码来源:pn544.c
注:本文中的pn544_disable_irq函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论