Commit e4878823 authored by Waldemar Rymarkiewicz's avatar Waldemar Rymarkiewicz Committed by Samuel Ortiz

NFC: pn533: Del frame logic from TgGet/SetData cmd

Remove frame logic from TgSetData and TgGetData commands
using the new iface for async send.
Signed-off-by: default avatarWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 1727cf93
...@@ -1450,65 +1450,46 @@ static int pn533_init_target_frame(struct pn533_frame *frame, ...@@ -1450,65 +1450,46 @@ static int pn533_init_target_frame(struct pn533_frame *frame,
#define PN533_CMD_DATAEXCH_HEAD_LEN 1 #define PN533_CMD_DATAEXCH_HEAD_LEN 1
#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262 #define PN533_CMD_DATAEXCH_DATA_MAXLEN 262
static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg, static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg,
u8 *params, int params_len) struct sk_buff *resp)
{ {
struct sk_buff *skb_resp = arg; u8 status;
struct pn533_frame *in_frame = (struct pn533_frame *) skb_resp->data;
nfc_dev_dbg(&dev->interface->dev, "%s", __func__); nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
if (params_len < 0) { if (IS_ERR(resp))
nfc_dev_err(&dev->interface->dev, return PTR_ERR(resp);
"Error %d when starting as a target",
params_len);
return params_len; status = resp->data[0];
} skb_pull(resp, sizeof(status));
if (params_len > 0 && params[0] != 0) { if (status != 0) {
nfc_tm_deactivated(dev->nfc_dev); nfc_tm_deactivated(dev->nfc_dev);
dev->tgt_mode = 0; dev->tgt_mode = 0;
dev_kfree_skb(resp);
kfree_skb(skb_resp);
return 0; return 0;
} }
skb_put(skb_resp, PN533_FRAME_SIZE(in_frame)); return nfc_tm_data_received(dev->nfc_dev, resp);
skb_pull(skb_resp,
PN533_FRAME_HEADER_LEN + PN533_CMD_DATAEXCH_HEAD_LEN);
skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_LEN);
return nfc_tm_data_received(dev->nfc_dev, skb_resp);
} }
static void pn533_wq_tg_get_data(struct work_struct *work) static void pn533_wq_tg_get_data(struct work_struct *work)
{ {
struct pn533 *dev = container_of(work, struct pn533, tg_work); struct pn533 *dev = container_of(work, struct pn533, tg_work);
struct pn533_frame *in_frame;
struct sk_buff *skb_resp;
size_t skb_resp_len;
nfc_dev_dbg(&dev->interface->dev, "%s", __func__); struct sk_buff *skb;
int rc;
skb_resp_len = PN533_FRAME_HEADER_LEN + nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
PN533_CMD_DATAEXCH_HEAD_LEN +
PN533_CMD_DATAEXCH_DATA_MAXLEN +
PN533_FRAME_TAIL_LEN;
skb_resp = nfc_alloc_recv_skb(skb_resp_len, GFP_KERNEL); skb = pn533_alloc_skb(0);
if (!skb_resp) if (!skb)
return; return;
in_frame = (struct pn533_frame *)skb_resp->data; rc = pn533_send_data_async(dev, PN533_CMD_TG_GET_DATA, skb,
pn533_tm_get_data_complete, NULL);
pn533_tx_frame_init(dev->out_frame, PN533_CMD_TG_GET_DATA);
pn533_tx_frame_finish(dev->out_frame);
pn533_send_cmd_frame_async(dev, dev->out_frame, in_frame, if (rc < 0)
skb_resp_len, dev_kfree_skb(skb);
pn533_tm_get_data_complete,
skb_resp);
return; return;
} }
...@@ -2280,23 +2261,20 @@ static int pn533_transceive(struct nfc_dev *nfc_dev, ...@@ -2280,23 +2261,20 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
} }
static int pn533_tm_send_complete(struct pn533 *dev, void *arg, static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
u8 *params, int params_len) struct sk_buff *resp)
{ {
struct sk_buff *skb_out = arg; u8 status;
nfc_dev_dbg(&dev->interface->dev, "%s", __func__); nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
dev_kfree_skb(skb_out); if (IS_ERR(resp))
return PTR_ERR(resp);
if (params_len < 0) { status = resp->data[0];
nfc_dev_err(&dev->interface->dev,
"Error %d when sending data",
params_len);
return params_len; dev_kfree_skb(resp);
}
if (params_len > 0 && params[0] != 0) { if (status != 0) {
nfc_tm_deactivated(dev->nfc_dev); nfc_tm_deactivated(dev->nfc_dev);
dev->tgt_mode = 0; dev->tgt_mode = 0;
...@@ -2312,30 +2290,21 @@ static int pn533_tm_send_complete(struct pn533 *dev, void *arg, ...@@ -2312,30 +2290,21 @@ static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
{ {
struct pn533 *dev = nfc_get_drvdata(nfc_dev); struct pn533 *dev = nfc_get_drvdata(nfc_dev);
struct pn533_frame *out_frame;
int rc; int rc;
nfc_dev_dbg(&dev->interface->dev, "%s", __func__); nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
rc = pn533_build_tx_frame(dev, skb, false); if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
if (rc)
goto error;
out_frame = (struct pn533_frame *) skb->data;
rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame,
PN533_NORMAL_FRAME_MAX_LEN,
pn533_tm_send_complete, skb);
if (rc) {
nfc_dev_err(&dev->interface->dev, nfc_dev_err(&dev->interface->dev,
"Error %d when trying to send data", rc); "Data length greater than the max allowed: %d",
goto error; PN533_CMD_DATAEXCH_DATA_MAXLEN);
return -ENOSYS;
} }
return 0; rc = pn533_send_data_async(dev, PN533_CMD_TG_SET_DATA, skb,
pn533_tm_send_complete, NULL);
error: if (rc < 0)
kfree_skb(skb); dev_kfree_skb(skb);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment