NFC: pn533: Keep cmd context in pn533 struct
Keep cmd context in pn533 struct instead of only cmd code.
The context already includes cmd_code.
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 2f39209..147ad05 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -334,7 +334,7 @@
void *cmd_complete_arg;
void *cmd_complete_mi_arg;
struct mutex cmd_lock;
- u8 cmd;
+ struct pn533_cmd *cmd;
struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1];
u8 poll_mod_count;
@@ -502,7 +502,8 @@
static bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame)
{
- return (dev->ops->get_cmd_code(frame) == PN533_CMD_RESPONSE(dev->cmd));
+ return (dev->ops->get_cmd_code(frame) ==
+ PN533_CMD_RESPONSE(dev->cmd->cmd_code));
}
@@ -648,7 +649,6 @@
{
int rc;
- dev->cmd = dev->ops->get_cmd_code(out->data);
dev->cmd_complete = cmd_complete;
dev->cmd_complete_arg = arg;
@@ -707,8 +707,7 @@
rc = cmd->complete_cb(dev, cmd->complete_cb_context,
ERR_PTR(status));
dev_kfree_skb(resp);
- kfree(cmd);
- return rc;
+ goto done;
}
skb_put(resp, dev->ops->rx_frame_size(resp->data));
@@ -717,7 +716,9 @@
rc = cmd->complete_cb(dev, cmd->complete_cb_context, resp);
+done:
kfree(cmd);
+ dev->cmd = NULL;
return rc;
}
@@ -754,6 +755,7 @@
goto error;
dev->cmd_pending = 1;
+ dev->cmd = cmd;
goto unlock;
}
@@ -862,6 +864,8 @@
if (rc < 0) {
dev_kfree_skb(resp);
kfree(cmd);
+ } else {
+ dev->cmd = cmd;
}
return rc;
@@ -893,7 +897,10 @@
dev_kfree_skb(cmd->req);
dev_kfree_skb(cmd->resp);
kfree(cmd);
+ return;
}
+
+ dev->cmd = cmd;
}
struct pn533_sync_cmd_response {