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); 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); /* pn544 seems to be slow in handling I2C read requests * so add 1ms delay after recv operation */ udelay(1000); 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; }
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; }
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; }
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; }
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; }
static irqreturn_t pn544_dev_irq_handler(int irq, void *dev_id) { struct pn544_dev *pn544_dev = dev_id; /* OPPO 2012-08-13 liuhd Modify begin for nfc */ #ifndef PN544 if(gpio_get_value(pn544_dev->irq_gpio)){ pn544_disable_irq(pn544_dev); /* Wake up waiting readers */ wake_up(&pn544_dev->read_wq); } #else pn544_disable_irq(pn544_dev); /* Wake up waiting readers */ wake_up(&pn544_dev->read_wq); #endif /* OPPO 2012-08-13 liuhd Modify end */ return IRQ_HANDLED; }
/* 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; }
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; }
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; }
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; }
void pn544_dev_irq_handler(void) { struct pn544_dev *pn544_dev = p_pn544_dev; printk("pn544 irq handler is called\n"); if (!mt_get_gpio_in(IRQ_PIN)) { return; } pn544_disable_irq(pn544_dev); /* Wake up waiting readers */ wake_up(&pn544_dev->read_wq); }
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; }
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; }
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; }
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; }
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); do_reading=1; #if NFC_DEBUG pr_info("pn544 : call\n"); #endif return IRQ_HANDLED; }
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; }
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 READ_IRQ_MODIFY do_reading=1; #endif #ifdef FEATURE_PN544_KERNEL_LOG #if (BOARD_VER>WS10 && defined(CONFIG_MACH_MSM8960_EF44S)) 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)); #else pr_info("==> %s (ven, firm, irq)=(%d, %d, %d) sub_firm=%d\n", __func__, gpio_get_value(pn544_dev->ven_gpio), gpio_get_value(pn544_dev->firm_gpio), gpio_get_value(pn544_dev->irq_gpio),gpio_get_value(NFC_SUB_FW_DL_GPIO)); #endif #endif /* Wake up waiting readers */ wake_up(&pn544_dev->read_wq); return IRQ_HANDLED; }
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; }
static int pn544_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = -ENODEV; struct pn544_i2c_platform_data *platform_data; struct pn544_dev *pn544_dev; pr_debug("%s : Probing pn544 driver\n", __func__); if (client->dev.of_node) platform_data = pn544_of_init(client); else platform_data = client->dev.platform_data; if (!platform_data) { pr_err("%s : GPIO has value 0, nfc probe fail.\n", __func__); goto err_exit; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s : i2c_check_functionality I2C_FUNC_I2C failed.\n", __func__); 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; } 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; }
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; }
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; }
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; }
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 { struct task_struct *th; th = kthread_create(pn544_factory_standby_set_thread, NULL, "pn544_factory_standby"); if (IS_ERR(th)) { ret = PTR_ERR(th); goto err_request_irq_failed; } wake_up_process(th); } #else pn544_factory_standby_set(); #endif /* */ 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_firm: gpio_free(pn544_dev->firm_gpio); err_ven: gpio_free(pn544_dev->ven_gpio); // err_exit: pr_err(PN544_DRV_NAME ": pn544_dev is null\n"); pr_err(PN544_DRV_NAME ": pn544_probe() end with error!\n"); return ret; }
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; }
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; int ret,i; char tmp[MAX_BUFFER_SIZE]; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; printk("pn544 %s : reading %zu bytes.\n", __func__, count); mutex_lock(&pn544_dev->read_mutex); if (!mt_get_gpio_in(IRQ_PIN)) { printk("pn544 read no event\n"); if (filp->f_flags & O_NONBLOCK) { ret = -EAGAIN; goto fail; } printk("pn544 read wait event\n"); pn544_dev->irq_enabled = true; mt65xx_eint_unmask(EINT_NUM); ret = wait_event_interruptible(pn544_dev->read_wq, mt_get_gpio_in(IRQ_PIN)); pn544_disable_irq(pn544_dev); if (ret) { printk("pn544 read wait event error\n"); goto fail; } } /* Read data */ ret = i2c_master_recv(pn544_dev->client, tmp, count); mutex_unlock(&pn544_dev->read_mutex); if (ret < 0) { pr_err("pn544 %s: i2c_master_recv returned %d\n", __func__, ret); return ret; } if (ret > count) { pr_err("pn544 %s: received too many bytes from i2c (%d)\n", __func__, ret); return -EIO; } if (copy_to_user(buf, tmp, ret)) { pr_warning("pn544 %s : failed to copy to user space\n", __func__); return -EFAULT; } printk("pn544 IFD->PC:"); for(i = 0; i < ret; i++) { printk(" %02X", tmp[i]); } printk("\n"); return ret; fail: mutex_unlock(&pn544_dev->read_mutex); return ret; }
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; static char tmp[MAX_BUFFER_SIZE]; int ret; int irq_gpio_val = 0; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; pr_debug("%s : reading %zu bytes.\n", __func__, count); mutex_lock(&pn544_dev->read_mutex); if (!stReadIntFlag) { irq_gpio_val = gpio_get_value(pn544_dev->irq_gpio); dprintk(PN544_DRV_NAME ":IRQ GPIO = %d\n", irq_gpio_val); if (irq_gpio_val == 0) { if (filp->f_flags & O_NONBLOCK) { pr_err(PN544_DRV_NAME ":f_falg has O_NONBLOCK. EAGAIN!\n"); ret = -EAGAIN; goto fail; } pn544_dev->irq_enabled = true; #ifdef LGE_NFC_READ_IRQ_MODIFY do_reading=0;//DY_TEST #endif // #if !defined(LGE_NFC_HW_QCT_MSM8660) enable_irq_wake(pn544_get_irq_pin(pn544_dev)); #endif enable_irq(pn544_get_irq_pin(pn544_dev)); #ifdef LGE_NFC_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); //dprintk(PN544_DRV_NAME ":wait_event_interruptible : %d\n", ret); #ifdef LGE_NFC_READ_IRQ_MODIFY //DY_TEST if(cancle_read == true) { cancle_read = false; ret = -1; goto fail; } #endif if (ret) goto fail; } } /* Read data */ memset(tmp, 0x00, MAX_BUFFER_SIZE); 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; }
static int __devinit pn544_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret=0; /*del 10 lines*/ PN544_DEBUG("%s:entered\n",__func__); /* private data allocation */ pn544_info = kzalloc(sizeof(struct pn544_info), GFP_KERNEL); if (!pn544_info) { printk("%s:Cannot allocate memory for pn544_info.\n",__func__); ret = -ENOMEM; goto err_info_alloc; } pn544_info->buflen = max(PN544_MSG_MAX_SIZE, PN544_MAX_I2C_TRANSFER); pn544_info->buf = kzalloc(pn544_info->buflen, GFP_KERNEL); if (!pn544_info->buf) { printk("%s:Cannot allocate memory for pn544_info->buf.\n",__func__); ret = -ENOMEM; goto err_buf_alloc; } pn544_info->i2c_dev = client; pn544_info->state = PN544_ST_COLD; pn544_info->read_irq = PN544_NONE; mutex_init(&pn544_info->read_mutex); mutex_init(&pn544_info->mutex); mutex_init(&pn544_info->mutex_mmi); init_waitqueue_head(&pn544_info->read_wait); spin_lock_init(&pn544_info->irq_enabled_lock); i2c_set_clientdata(client, pn544_info); //On platform 7X30 we should identify whether GPIO04 is used #ifdef CONFIG_ARCH_MSM7X30 if (machine_is_msm8255_u8860_r()) { //GPIO04 is needed for firmware download ret = init_fw_download(); if(ret) { printk("%s:nfc init_fw_download failed\n",__func__); } } #else ret = init_fw_download(); if(ret) { printk("%s:nfc init_fw_download failed\n",__func__); } #endif pdata = client->dev.platform_data; if (!pdata) { printk("%s:No platform data\n",__func__); ret = -EINVAL; goto err_no_platform_data; } //The clock control of nfc is different between 7x27A and 7x30, we don't need to do following operation on 7X30 #ifdef CONFIG_ARCH_MSM7X30 /* nothing todo */ #else if (!pdata->pn544_clock_output_ctrl) { printk("%s:pn544_clock_output_ctrl missing\n",__func__); ret = -EINVAL; goto err_no_clock_ctrl; } else { ret = pdata->pn544_clock_output_ctrl(1); printk("pn544_clock_output_ctrl:%d \n",ret); if(ret) { goto err_no_clock_ctrl; } } //It is a fixed operation sequence, just follow it if (!pdata->pn544_fw_download_pull_down) { printk("%s:fw_download missing\n",__func__); ret = -EINVAL; goto err_no_fw_download; } else { ret = pdata->pn544_fw_download_pull_down(); if(ret) { goto err_no_fw_download; } } #endif if (!pdata->pn544_ven_reset) { printk("%s:ven reset missing\n",__func__); ret = -EINVAL; goto err_no_ven_reset; } else { ret = pdata->pn544_ven_reset(); if(ret) { goto err_no_ven_reset; } } /* we need to request read irq to support the pn544 *read function anyway , so we delete "if" here */ if (!pdata->pn544_interrupt_gpio_config) { printk("%s:request_resources() missing\n",__func__); ret = -EINVAL; goto err_gpio_config; } else { ret=pdata->pn544_interrupt_gpio_config(); if(ret) { goto err_gpio_config; } } /* irq request move down */ /* we need to request read irq to support the pn544 *read function anyway , so we delete "if" here */ //we use a func to deal the device probe if (pn544_i2c_device_probe(client) < 0) { printk("%s:unable to probe device.\n", __func__); ret = -ENODEV; goto err_cmd_resp; } /*kfree delete*/ memcpy(&pn544_client,client,sizeof(struct i2c_client)); if (0!=pn544_use_read_irq) { pn544_info->read_irq=PN544_NONE; enable_irq(pn544_client.irq); pn544_info->use_read_irq=1; } else { pn544_info->use_read_irq=0; } /* add irq request*/ pn544_info->irq_enabled = true; ret = request_irq(client->irq, pn544_irq_thread_fn, IRQF_TRIGGER_HIGH, PN544_DRIVER_NAME, pn544_info); if (ret < 0) { printk("%s:Unable to register IRQ handler\n", __func__); goto err_irq_req; } pn544_disable_irq(pn544_info); pn544_info->miscdev.minor = MISC_DYNAMIC_MINOR; pn544_info->miscdev.name = PN544_DRIVER_NAME; pn544_info->miscdev.fops = &pn544_fops; pn544_info->miscdev.parent = &client->dev; ret = misc_register(&pn544_info->miscdev); if (ret < 0) { printk("%s:Device registration failed\n",__func__); goto err_misc_dev; } /* remove code because the HAL and the up-level * code added to our project */ printk("%s success finished: info: %p, client %p\n", __func__, pn544_info, client); #ifdef CONFIG_HUAWEI_HW_DEV_DCT /* detect current device successful, set the flag as present */ set_hw_dev_flag(DEV_I2C_NFC); #endif ret = pn544_mmi_init(); if (ret) { goto err_mmi_error; } //following operation is for power save #ifdef CONFIG_ARCH_MSM7X30 /* nothing todo */ #else ret = pdata->pn544_clock_output_ctrl(0); printk("pn544_clock_output_ctrl:%d \n",ret); if(ret) { goto err_clock_mode_ctrl_err; } //It is another clock out put mode, we can see the difference with pn544_clock_output_ctrl() in board-msm7x27a.c if (!pdata->pn544_clock_output_mode_ctrl) { printk("%s:pn544_clock_output_mode_ctrl missing\n",__func__); ret = -EINVAL; goto err_clock_mode_ctrl_err; } else { // 1 - Set for clock PMU request mode , 0 - Close for clock PMU request mode ret = pdata->pn544_clock_output_mode_ctrl(1); printk("pn544_clock_output_mode_ctrl:%d \n",ret); if(ret) { goto err_clock_mode_ctrl_err; } } #endif /*del 4 lines*/ return 0; #ifdef CONFIG_ARCH_MSM7X30 /* nothing todo */ #else err_clock_mode_ctrl_err: #endif err_mmi_error: misc_deregister(&pn544_info->miscdev); err_misc_dev: free_irq(client->irq, pn544_info); err_irq_req: err_cmd_resp: /*del 14 lines*/ err_gpio_config: err_no_ven_reset: #ifdef CONFIG_ARCH_MSM7X30 /* nothing todo */ #else err_no_fw_download: pdata->pn544_clock_output_ctrl(0); printk("pn544_clock_output_ctrl close when error\n"); err_no_clock_ctrl: #endif err_no_platform_data: mutex_destroy(&pn544_info->read_mutex); mutex_destroy(&pn544_info->mutex); mutex_destroy(&pn544_info->mutex_mmi); kfree(pn544_info->buf); err_buf_alloc: kfree(pn544_info); err_info_alloc: return ret; }
static ssize_t pn544_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { /*use global var instead of container_of funcation*/ struct pn544_info *info = pn544_info; /*unused var variable 'len'*/ int ret = -1; int i = 0; char tmp[PN544_MAX_PACK_LEN]; PN544_DEBUG("%s:entered\n",__func__); if (count > PN544_MAX_PACK_LEN) count = PN544_MAX_PACK_LEN; PN544_DEBUG("%s : reading %zu bytes.\n", __func__, count); //mutex_lock(&info->mutex); /*if gpio value is high we should enable irq*/ PN544_DEBUG("%s:GPIO_NFC_INT value %d\n", __func__, gpio_get_value(GPIO_NFC_INT)); if(!gpio_get_value(GPIO_NFC_INT)) { PN544_DEBUG("%s:enable pn544irq !\n", __func__); pn544_info->irq_enabled = true; enable_irq(pn544_info->i2c_dev ->irq); ret = wait_event_interruptible(pn544_info->read_wait, gpio_get_value(GPIO_NFC_INT)); pn544_disable_irq(pn544_info); PN544_DEBUG("%s:enable pn544irq! ret=%d!\n", __func__, ret); if (ret) { goto out; } } if (update) { PN544_DEBUG("updateing****!\n"); } /* Read data */ ret = i2c_master_recv(info->i2c_dev, tmp, count); PN544_DEBUG("%s:read datasize: ret=%d count=%d\n", __func__, ret, count); //mutex_unlock(&info->mutex); if (ret < 0) { printk("%s: receive error! i2c_master_recv returned %d\n", __func__, ret); return ret; } if (ret > count) { printk("%s: received too many bytes from i2c (%d)\n", __func__, ret); return -EIO; } PN544_DEBUG("IFD->PC: "); for(i = 0; i < count; i++) { PN544_DEBUG("%02X", tmp[i]); } PN544_DEBUG("\n"); if (copy_to_user(buf, tmp, ret)) { printk("%s : failed to copy to user space\n", __func__); return -EFAULT; } PN544_DEBUG("%s:exit ret=%d\n",__func__,ret); return ret; out: //mutex_unlock(&info->mutex); return ret; }
static int pn544_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct pn544_dev *pn544_dev; printk("pn544 nfc probe step01 is ok\n"); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("pn544 %s : need I2C_FUNC_I2C\n", __func__); return -ENODEV; } printk("pn544 nfc probe step02 is ok\n"); pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL); if (pn544_dev == NULL) { dev_err(&client->dev, "pn544 failed to allocate memory for module data\n"); return -ENOMEM; } memset(pn544_dev, 0, sizeof(struct pn544_dev)); p_pn544_dev = pn544_dev; printk("pn544 nfc probe step03 is ok\n"); client->addr = (client->addr & I2C_MASK_FLAG); 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_DRVNAME; pn544_dev->pn544_device.fops = &pn544_dev_fops; ret = misc_register(&pn544_dev->pn544_device); if (ret) { pr_err("pn544 %s : misc_register failed\n", __FILE__); goto err_misc_register; } printk("pn544 nfc probe step04 is ok\n"); /* VEN */ mt_set_gpio_mode(VEN_PIN, GPIO_MODE_00); mt_set_gpio_dir(VEN_PIN, GPIO_DIR_OUT); /* GPIO4 */ mt_set_gpio_mode(GPIO4_PIN, GPIO_MODE_00); mt_set_gpio_dir(GPIO4_PIN, GPIO_DIR_OUT); /* IRQ */ mt_set_gpio_mode(IRQ_PIN, GPIO_MODE_01); mt_set_gpio_dir(IRQ_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(IRQ_PIN, true); mt_set_gpio_pull_select(IRQ_PIN, GPIO_PULL_DOWN); printk("pn544 nfc probe step05 is ok\n"); pn544_dev->irq_enabled = true; mt65xx_eint_set_sens(EINT_NUM, CUST_EINT_LEVEL_SENSITIVE); mt65xx_eint_set_hw_debounce(EINT_NUM, 0); mt65xx_eint_registration(EINT_NUM, CUST_EINT_DEBOUNCE_DISABLE, CUST_EINT_POLARITY_HIGH, pn544_dev_irq_handler, 0); pn544_disable_irq(pn544_dev); i2c_set_clientdata(client, pn544_dev); printk("pn544 nfc probe step06 is ok\n"); return 0; err_dma_alloc: misc_deregister(&pn544_dev->pn544_device); err_misc_register: mutex_destroy(&pn544_dev->read_mutex); kfree(pn544_dev); p_pn544_dev = NULL; return ret; }