aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>2013-04-03 02:02:08 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-11 10:29:04 -0400
commitddf19d206fe4ba4e7dc9629bc14025ba50915886 (patch)
treed363ae564f636fc10df8dfd475695ef5a9ad7b28 /drivers/nfc
parent140ef7f6b08ff8ebfe5da619036c21a6382d7df9 (diff)
NFC: pn533: Simplify __pn533_send_frame_async
In all cases (send_cmd_async, send_data_async and send_sync) pn533_send_async_complete() handles all responses internally, so there is no need to pass this as a callback. Cmd context is passed to __pn533_send_frame_async in all the cases as well. It's already kept in struct pn533 which is available all the time the device is attached. So we can make use of it instead. Therefore, cmd_complete and cmd_complete_arg are no needed any more. Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index ef8e44785b5e..72860569fb1a 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -330,8 +330,6 @@ struct pn533 {
330 int wq_in_error; 330 int wq_in_error;
331 int cancel_listen; 331 int cancel_listen;
332 332
333 pn533_cmd_complete_t cmd_complete;
334 void *cmd_complete_arg;
335 void *cmd_complete_mi_arg; 333 void *cmd_complete_mi_arg;
336 struct mutex cmd_lock; 334 struct mutex cmd_lock;
337 struct pn533_cmd *cmd; 335 struct pn533_cmd *cmd;
@@ -506,13 +504,14 @@ static bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame)
506 PN533_CMD_RESPONSE(dev->cmd->code)); 504 PN533_CMD_RESPONSE(dev->cmd->code));
507} 505}
508 506
507static int pn533_send_async_complete(struct pn533 *dev);
509 508
510static void pn533_wq_cmd_complete(struct work_struct *work) 509static void pn533_wq_cmd_complete(struct work_struct *work)
511{ 510{
512 struct pn533 *dev = container_of(work, struct pn533, cmd_complete_work); 511 struct pn533 *dev = container_of(work, struct pn533, cmd_complete_work);
513 int rc; 512 int rc;
514 513
515 rc = dev->cmd_complete(dev, dev->cmd_complete_arg, dev->wq_in_error); 514 rc = pn533_send_async_complete(dev);
516 if (rc != -EINPROGRESS) 515 if (rc != -EINPROGRESS)
517 queue_work(dev->wq, &dev->cmd_work); 516 queue_work(dev->wq, &dev->cmd_work);
518} 517}
@@ -643,15 +642,10 @@ static int pn533_send_ack(struct pn533 *dev, gfp_t flags)
643static int __pn533_send_frame_async(struct pn533 *dev, 642static int __pn533_send_frame_async(struct pn533 *dev,
644 struct sk_buff *out, 643 struct sk_buff *out,
645 struct sk_buff *in, 644 struct sk_buff *in,
646 int in_len, 645 int in_len)
647 pn533_cmd_complete_t cmd_complete,
648 void *arg)
649{ 646{
650 int rc; 647 int rc;
651 648
652 dev->cmd_complete = cmd_complete;
653 dev->cmd_complete_arg = arg;
654
655 dev->out_urb->transfer_buffer = out->data; 649 dev->out_urb->transfer_buffer = out->data;
656 dev->out_urb->transfer_buffer_length = out->len; 650 dev->out_urb->transfer_buffer_length = out->len;
657 651
@@ -692,9 +686,10 @@ static void pn533_build_cmd_frame(struct pn533 *dev, u8 cmd_code,
692 ops->tx_frame_finish(skb->data); 686 ops->tx_frame_finish(skb->data);
693} 687}
694 688
695static int pn533_send_async_complete(struct pn533 *dev, void *arg, int status) 689static int pn533_send_async_complete(struct pn533 *dev)
696{ 690{
697 struct pn533_cmd *cmd = arg; 691 struct pn533_cmd *cmd = dev->cmd;
692 int status = dev->wq_in_error;
698 693
699 struct sk_buff *req = cmd->req; 694 struct sk_buff *req = cmd->req;
700 struct sk_buff *resp = cmd->resp; 695 struct sk_buff *resp = cmd->resp;
@@ -749,8 +744,7 @@ static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,
749 mutex_lock(&dev->cmd_lock); 744 mutex_lock(&dev->cmd_lock);
750 745
751 if (!dev->cmd_pending) { 746 if (!dev->cmd_pending) {
752 rc = __pn533_send_frame_async(dev, req, resp, resp_len, 747 rc = __pn533_send_frame_async(dev, req, resp, resp_len);
753 pn533_send_async_complete, cmd);
754 if (rc) 748 if (rc)
755 goto error; 749 goto error;
756 750
@@ -859,8 +853,7 @@ static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,
859 853
860 pn533_build_cmd_frame(dev, cmd_code, req); 854 pn533_build_cmd_frame(dev, cmd_code, req);
861 855
862 rc = __pn533_send_frame_async(dev, req, resp, resp_len, 856 rc = __pn533_send_frame_async(dev, req, resp, resp_len);
863 pn533_send_async_complete, cmd);
864 if (rc < 0) { 857 if (rc < 0) {
865 dev_kfree_skb(resp); 858 dev_kfree_skb(resp);
866 kfree(cmd); 859 kfree(cmd);
@@ -891,8 +884,7 @@ static void pn533_wq_cmd(struct work_struct *work)
891 884
892 mutex_unlock(&dev->cmd_lock); 885 mutex_unlock(&dev->cmd_lock);
893 886
894 rc = __pn533_send_frame_async(dev, cmd->req, cmd->resp, cmd->resp_len, 887 rc = __pn533_send_frame_async(dev, cmd->req, cmd->resp, cmd->resp_len);
895 pn533_send_async_complete, cmd);
896 if (rc < 0) { 888 if (rc < 0) {
897 dev_kfree_skb(cmd->req); 889 dev_kfree_skb(cmd->req);
898 dev_kfree_skb(cmd->resp); 890 dev_kfree_skb(cmd->resp);