NFC: pn533: Move wq_in_error to cmd context
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Wed, 3 Apr 2013 06:02:11 +0000 (08:02 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 11 Apr 2013 14:29:06 +0000 (16:29 +0200)
Rename 'wq_in_error' field to more relevant 'status'
and move it to cmd context struct.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn533.c

index 326cefb..edee0d5 100644 (file)
@@ -331,7 +331,6 @@ struct pn533 {
        struct list_head cmd_queue;
        struct pn533_cmd *cmd;
        u8 cmd_pending;
-       int wq_in_error;
        struct mutex cmd_lock;  /* protects cmd queue */
 
        void *cmd_complete_mi_arg;
@@ -357,6 +356,7 @@ struct pn533 {
 struct pn533_cmd {
        struct list_head queue;
        u8 code;
+       int status;
        struct sk_buff *req;
        struct sk_buff *resp;
        int resp_len;
@@ -506,8 +506,11 @@ static bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame)
 static void pn533_recv_response(struct urb *urb)
 {
        struct pn533 *dev = urb->context;
+       struct pn533_cmd *cmd = dev->cmd;
        u8 *in_frame;
 
+       cmd->status = urb->status;
+
        switch (urb->status) {
        case 0:
                break; /* success */
@@ -516,13 +519,11 @@ static void pn533_recv_response(struct urb *urb)
                nfc_dev_dbg(&dev->interface->dev,
                            "The urb has been canceled (status %d)",
                            urb->status);
-               dev->wq_in_error = urb->status;
                goto sched_wq;
        case -ESHUTDOWN:
        default:
                nfc_dev_err(&dev->interface->dev,
                            "Urb failure (status %d)", urb->status);
-               dev->wq_in_error = urb->status;
                goto sched_wq;
        }
 
@@ -534,19 +535,17 @@ static void pn533_recv_response(struct urb *urb)
 
        if (!dev->ops->rx_is_frame_valid(in_frame)) {
                nfc_dev_err(&dev->interface->dev, "Received an invalid frame");
-               dev->wq_in_error = -EIO;
+               cmd->status = -EIO;
                goto sched_wq;
        }
 
        if (!pn533_rx_frame_is_cmd_response(dev, in_frame)) {
                nfc_dev_err(&dev->interface->dev,
                            "It it not the response to the last command");
-               dev->wq_in_error = -EIO;
+               cmd->status = -EIO;
                goto sched_wq;
        }
 
-       dev->wq_in_error = 0;
-
 sched_wq:
        queue_work(dev->wq, &dev->cmd_complete_work);
 }
@@ -561,9 +560,12 @@ static int pn533_submit_urb_for_response(struct pn533 *dev, gfp_t flags)
 static void pn533_recv_ack(struct urb *urb)
 {
        struct pn533 *dev = urb->context;
+       struct pn533_cmd *cmd = dev->cmd;
        struct pn533_std_frame *in_frame;
        int rc;
 
+       cmd->status = urb->status;
+
        switch (urb->status) {
        case 0:
                break; /* success */
@@ -572,13 +574,11 @@ static void pn533_recv_ack(struct urb *urb)
                nfc_dev_dbg(&dev->interface->dev,
                            "The urb has been stopped (status %d)",
                            urb->status);
-               dev->wq_in_error = urb->status;
                goto sched_wq;
        case -ESHUTDOWN:
        default:
                nfc_dev_err(&dev->interface->dev,
                            "Urb failure (status %d)", urb->status);
-               dev->wq_in_error = urb->status;
                goto sched_wq;
        }
 
@@ -586,7 +586,7 @@ static void pn533_recv_ack(struct urb *urb)
 
        if (!pn533_std_rx_frame_is_ack(in_frame)) {
                nfc_dev_err(&dev->interface->dev, "Received an invalid ack");
-               dev->wq_in_error = -EIO;
+               cmd->status = -EIO;
                goto sched_wq;
        }
 
@@ -594,7 +594,7 @@ static void pn533_recv_ack(struct urb *urb)
        if (rc) {
                nfc_dev_err(&dev->interface->dev,
                            "usb_submit_urb failed with result %d", rc);
-               dev->wq_in_error = rc;
+               cmd->status = rc;
                goto sched_wq;
        }
 
@@ -676,7 +676,7 @@ static void pn533_build_cmd_frame(struct pn533 *dev, u8 cmd_code,
 static int pn533_send_async_complete(struct pn533 *dev)
 {
        struct pn533_cmd *cmd = dev->cmd;
-       int status = dev->wq_in_error;
+       int status = cmd->status;
 
        struct sk_buff *req = cmd->req;
        struct sk_buff *resp = cmd->resp;