]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
NFC: xmit from hci ops must return 0 or negative
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Thu, 20 Sep 2012 06:59:10 +0000 (08:59 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 24 Sep 2012 22:17:27 +0000 (00:17 +0200)
xmit callback provided by a driver encapsulates upper layers
data and sends it to the hardware. So, HCI does not know the
exact amount of data being sent and thus can't handle partially
sent frames properly.

Therefore, the driver must return 0 for completely sent frame or
negative for failure.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Acked-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn544_hci.c
include/net/nfc/hci.h

index 7b0c2176e89bc8031ff32fcc76557d81a7020352..c9c8570273ab5a58c782e9fe953339e091042d2a 100644 (file)
@@ -235,8 +235,12 @@ static int pn544_hci_i2c_write(struct i2c_client *client, u8 *buf, int len)
                r = i2c_master_send(client, buf, len);
        }
 
-       if (r >= 0 && r != len)
-               r = -EREMOTEIO;
+       if (r >= 0) {
+               if (r != len)
+                       return -EREMOTEIO;
+               else
+                       return 0;
+       }
 
        return r;
 }
index 9b5ed2d94d6055e258c230a20a0629b2f90aa4d1..e900072950cb8cf5635e4a106389e34bd5df21f1 100644 (file)
@@ -30,6 +30,11 @@ struct nfc_hci_ops {
        int (*open) (struct nfc_hci_dev *hdev);
        void (*close) (struct nfc_hci_dev *hdev);
        int (*hci_ready) (struct nfc_hci_dev *hdev);
+       /*
+        * xmit must always send the complete buffer before
+        * returning. Returned result must be 0 for success
+        * or negative for failure.
+        */
        int (*xmit) (struct nfc_hci_dev *hdev, struct sk_buff *skb);
        int (*start_poll) (struct nfc_hci_dev *hdev,
                           u32 im_protocols, u32 tm_protocols);