diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/nfc/nfcwilink.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/nfc/nfcwilink.c')
-rw-r--r-- | drivers/nfc/nfcwilink.c | 97 |
1 files changed, 59 insertions, 38 deletions
diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index 7130864..59f95d8 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c @@ -146,11 +146,13 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name) unsigned long comp_ret; int rc; + nfc_dev_dbg(&drv->pdev->dev, "get_bts_file_name entry"); + skb = nfcwilink_skb_alloc(sizeof(struct nci_vs_nfcc_info_cmd), GFP_KERNEL); if (!skb) { - nfc_err(&drv->pdev->dev, - "no memory for nci_vs_nfcc_info_cmd\n"); + nfc_dev_err(&drv->pdev->dev, + "no memory for nci_vs_nfcc_info_cmd"); return -ENOMEM; } @@ -168,19 +170,21 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name) comp_ret = wait_for_completion_timeout(&drv->completed, msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT)); - dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld\n", - comp_ret); + nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld", + comp_ret); if (comp_ret == 0) { - nfc_err(&drv->pdev->dev, - "timeout on wait_for_completion_timeout\n"); + nfc_dev_err(&drv->pdev->dev, + "timeout on wait_for_completion_timeout"); return -ETIMEDOUT; } - dev_dbg(&drv->pdev->dev, "nci_vs_nfcc_info_rsp: plen %d, status %d\n", - drv->nfcc_info.plen, drv->nfcc_info.status); + nfc_dev_dbg(&drv->pdev->dev, "nci_vs_nfcc_info_rsp: plen %d, status %d", + drv->nfcc_info.plen, + drv->nfcc_info.status); if ((drv->nfcc_info.plen != 5) || (drv->nfcc_info.status != 0)) { - nfc_err(&drv->pdev->dev, "invalid nci_vs_nfcc_info_rsp\n"); + nfc_dev_err(&drv->pdev->dev, + "invalid nci_vs_nfcc_info_rsp"); return -EINVAL; } @@ -191,7 +195,7 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name) drv->nfcc_info.sw_ver_z, drv->nfcc_info.patch_id); - nfc_info(&drv->pdev->dev, "nfcwilink FW file name: %s\n", file_name); + nfc_dev_info(&drv->pdev->dev, "nfcwilink FW file name: %s", file_name); return 0; } @@ -203,13 +207,15 @@ static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len) unsigned long comp_ret; int rc; + nfc_dev_dbg(&drv->pdev->dev, "send_bts_cmd entry"); + /* verify valid cmd for the NFC channel */ if ((len <= sizeof(struct nfcwilink_hdr)) || (len > BTS_FILE_CMD_MAX_LEN) || (hdr->chnl != NFCWILINK_CHNL) || (hdr->opcode != NFCWILINK_OPCODE)) { - nfc_err(&drv->pdev->dev, - "ignoring invalid bts cmd, len %d, chnl %d, opcode %d\n", + nfc_dev_err(&drv->pdev->dev, + "ignoring invalid bts cmd, len %d, chnl %d, opcode %d", len, hdr->chnl, hdr->opcode); return 0; } @@ -220,7 +226,7 @@ static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len) skb = nfcwilink_skb_alloc(len, GFP_KERNEL); if (!skb) { - nfc_err(&drv->pdev->dev, "no memory for bts cmd\n"); + nfc_dev_err(&drv->pdev->dev, "no memory for bts cmd"); return -ENOMEM; } @@ -232,11 +238,11 @@ static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len) comp_ret = wait_for_completion_timeout(&drv->completed, msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT)); - dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld\n", - comp_ret); + nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld", + comp_ret); if (comp_ret == 0) { - nfc_err(&drv->pdev->dev, - "timeout on wait_for_completion_timeout\n"); + nfc_dev_err(&drv->pdev->dev, + "timeout on wait_for_completion_timeout"); return -ETIMEDOUT; } @@ -251,6 +257,8 @@ static int nfcwilink_download_fw(struct nfcwilink *drv) __u8 *ptr; int len, rc; + nfc_dev_dbg(&drv->pdev->dev, "download_fw entry"); + set_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags); rc = nfcwilink_get_bts_file_name(drv, file_name); @@ -259,7 +267,7 @@ static int nfcwilink_download_fw(struct nfcwilink *drv) rc = request_firmware(&fw, file_name, &drv->pdev->dev); if (rc) { - nfc_err(&drv->pdev->dev, "request_firmware failed %d\n", rc); + nfc_dev_err(&drv->pdev->dev, "request_firmware failed %d", rc); /* if the file is not found, don't exit with failure */ if (rc == -ENOENT) @@ -272,14 +280,14 @@ static int nfcwilink_download_fw(struct nfcwilink *drv) ptr = (__u8 *)fw->data; if ((len == 0) || (ptr == NULL)) { - dev_dbg(&drv->pdev->dev, - "request_firmware returned size %d\n", len); + nfc_dev_dbg(&drv->pdev->dev, + "request_firmware returned size %d", len); goto release_fw; } if (__le32_to_cpu(((struct bts_file_hdr *)ptr)->magic) != BTS_FILE_HDR_MAGIC) { - nfc_err(&drv->pdev->dev, "wrong bts magic number\n"); + nfc_dev_err(&drv->pdev->dev, "wrong bts magic number"); rc = -EINVAL; goto release_fw; } @@ -294,8 +302,8 @@ static int nfcwilink_download_fw(struct nfcwilink *drv) action_len = __le16_to_cpu(((struct bts_file_action *)ptr)->len); - dev_dbg(&drv->pdev->dev, "bts_file_action type %d, len %d\n", - action_type, action_len); + nfc_dev_dbg(&drv->pdev->dev, "bts_file_action type %d, len %d", + action_type, action_len); switch (action_type) { case BTS_FILE_ACTION_TYPE_SEND_CMD: @@ -325,6 +333,8 @@ static void nfcwilink_register_complete(void *priv_data, char data) { struct nfcwilink *drv = priv_data; + nfc_dev_dbg(&drv->pdev->dev, "register_complete entry"); + /* store ST registration status */ drv->st_register_cb_status = data; @@ -346,7 +356,7 @@ static long nfcwilink_receive(void *priv_data, struct sk_buff *skb) return -EFAULT; } - dev_dbg(&drv->pdev->dev, "receive entry, len %d\n", skb->len); + nfc_dev_dbg(&drv->pdev->dev, "receive entry, len %d", skb->len); /* strip the ST header (apart for the chnl byte, which is not received in the hdr) */ @@ -360,7 +370,7 @@ static long nfcwilink_receive(void *priv_data, struct sk_buff *skb) /* Forward skb to NCI core layer */ rc = nci_recv_frame(drv->ndev, skb); if (rc < 0) { - nfc_err(&drv->pdev->dev, "nci_recv_frame failed %d\n", rc); + nfc_dev_err(&drv->pdev->dev, "nci_recv_frame failed %d", rc); return rc; } @@ -386,6 +396,8 @@ static int nfcwilink_open(struct nci_dev *ndev) unsigned long comp_ret; int rc; + nfc_dev_dbg(&drv->pdev->dev, "open entry"); + if (test_and_set_bit(NFCWILINK_RUNNING, &drv->flags)) { rc = -EBUSY; goto exit; @@ -403,9 +415,9 @@ static int nfcwilink_open(struct nci_dev *ndev) &drv->completed, msecs_to_jiffies(NFCWILINK_REGISTER_TIMEOUT)); - dev_dbg(&drv->pdev->dev, - "wait_for_completion_timeout returned %ld\n", - comp_ret); + nfc_dev_dbg(&drv->pdev->dev, + "wait_for_completion_timeout returned %ld", + comp_ret); if (comp_ret == 0) { /* timeout */ @@ -413,12 +425,13 @@ static int nfcwilink_open(struct nci_dev *ndev) goto clear_exit; } else if (drv->st_register_cb_status != 0) { rc = drv->st_register_cb_status; - nfc_err(&drv->pdev->dev, - "st_register_cb failed %d\n", rc); + nfc_dev_err(&drv->pdev->dev, + "st_register_cb failed %d", rc); goto clear_exit; } } else { - nfc_err(&drv->pdev->dev, "st_register failed %d\n", rc); + nfc_dev_err(&drv->pdev->dev, + "st_register failed %d", rc); goto clear_exit; } } @@ -428,8 +441,8 @@ static int nfcwilink_open(struct nci_dev *ndev) drv->st_write = nfcwilink_proto.write; if (nfcwilink_download_fw(drv)) { - nfc_err(&drv->pdev->dev, "nfcwilink_download_fw failed %d\n", - rc); + nfc_dev_err(&drv->pdev->dev, "nfcwilink_download_fw failed %d", + rc); /* open should succeed, even if the FW download failed */ } @@ -447,12 +460,14 @@ static int nfcwilink_close(struct nci_dev *ndev) struct nfcwilink *drv = nci_get_drvdata(ndev); int rc; + nfc_dev_dbg(&drv->pdev->dev, "close entry"); + if (!test_and_clear_bit(NFCWILINK_RUNNING, &drv->flags)) return 0; rc = st_unregister(&nfcwilink_proto); if (rc) - nfc_err(&drv->pdev->dev, "st_unregister failed %d\n", rc); + nfc_dev_err(&drv->pdev->dev, "st_unregister failed %d", rc); drv->st_write = NULL; @@ -465,7 +480,7 @@ static int nfcwilink_send(struct nci_dev *ndev, struct sk_buff *skb) struct nfcwilink_hdr hdr = {NFCWILINK_CHNL, NFCWILINK_OPCODE, 0x0000}; long len; - dev_dbg(&drv->pdev->dev, "send entry, len %d\n", skb->len); + nfc_dev_dbg(&drv->pdev->dev, "send entry, len %d", skb->len); if (!test_bit(NFCWILINK_RUNNING, &drv->flags)) { kfree_skb(skb); @@ -483,7 +498,7 @@ static int nfcwilink_send(struct nci_dev *ndev, struct sk_buff *skb) len = drv->st_write(skb); if (len < 0) { kfree_skb(skb); - nfc_err(&drv->pdev->dev, "st_write failed %ld\n", len); + nfc_dev_err(&drv->pdev->dev, "st_write failed %ld", len); return -EFAULT; } @@ -502,6 +517,8 @@ static int nfcwilink_probe(struct platform_device *pdev) int rc; __u32 protocols; + nfc_dev_dbg(&pdev->dev, "probe entry"); + drv = devm_kzalloc(&pdev->dev, sizeof(struct nfcwilink), GFP_KERNEL); if (!drv) { rc = -ENOMEM; @@ -521,7 +538,7 @@ static int nfcwilink_probe(struct platform_device *pdev) NFCWILINK_HDR_LEN, 0); if (!drv->ndev) { - nfc_err(&pdev->dev, "nci_allocate_device failed\n"); + nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); rc = -ENOMEM; goto exit; } @@ -531,7 +548,7 @@ static int nfcwilink_probe(struct platform_device *pdev) rc = nci_register_device(drv->ndev); if (rc < 0) { - nfc_err(&pdev->dev, "nci_register_device failed %d\n", rc); + nfc_dev_err(&pdev->dev, "nci_register_device failed %d", rc); goto free_dev_exit; } @@ -551,6 +568,8 @@ static int nfcwilink_remove(struct platform_device *pdev) struct nfcwilink *drv = dev_get_drvdata(&pdev->dev); struct nci_dev *ndev; + nfc_dev_dbg(&pdev->dev, "remove entry"); + if (!drv) return -EFAULT; @@ -559,6 +578,8 @@ static int nfcwilink_remove(struct platform_device *pdev) nci_unregister_device(ndev); nci_free_device(ndev); + dev_set_drvdata(&pdev->dev, NULL); + return 0; } |