]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
nfc: pn533: pn533_phy_ops dev_[up, down] return int
authorLars Poeschel <poeschel@lemonage.de>
Wed, 13 Nov 2019 13:50:22 +0000 (14:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Nov 2019 20:15:03 +0000 (12:15 -0800)
Change dev_up and dev_down functions of struct pn533_phy_ops to return
int. This way the pn533 core can report errors in the phy layer to upper
layers.
The only user of this is currently uart.c and it is changed to report
the error of a possibly failing call to serdev_device_open.

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1487395 ("Error handling issues")
Fixes: c656aa4c27b1 ("nfc: pn533: add UART phy driver")
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/nfc/pn533/pn533.c
drivers/nfc/pn533/pn533.h
drivers/nfc/pn533/uart.c

index aa766e7ece7000f879e733c34e6054aa4634750f..346e084387f7d125a48df07ade33ef0689f69239 100644 (file)
@@ -2643,13 +2643,17 @@ static int pn532_sam_configuration(struct nfc_dev *nfc_dev)
 static int pn533_dev_up(struct nfc_dev *nfc_dev)
 {
        struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+       int rc;
 
-       if (dev->phy_ops->dev_up)
-               dev->phy_ops->dev_up(dev);
+       if (dev->phy_ops->dev_up) {
+               rc = dev->phy_ops->dev_up(dev);
+               if (rc)
+                       return rc;
+       }
 
        if ((dev->device_type == PN533_DEVICE_PN532) ||
                (dev->device_type == PN533_DEVICE_PN532_AUTOPOLL)) {
-               int rc = pn532_sam_configuration(nfc_dev);
+               rc = pn532_sam_configuration(nfc_dev);
 
                if (rc)
                        return rc;
@@ -2665,7 +2669,7 @@ static int pn533_dev_down(struct nfc_dev *nfc_dev)
 
        ret = pn533_rf_field(nfc_dev, 0);
        if (dev->phy_ops->dev_down && !ret)
-               dev->phy_ops->dev_down(dev);
+               ret = dev->phy_ops->dev_down(dev);
 
        return ret;
 }
index b66f02a5316741c3e08817f257851dba3e5ff3e6..5f94f38a2a08d2bc6162cd153d269b3c6708c4d1 100644 (file)
@@ -224,8 +224,8 @@ struct pn533_phy_ops {
         * bring up it's interface to the chip and have it suspended for power
         * saving reasons otherwise.
         */
-       void (*dev_up)(struct pn533 *priv);
-       void (*dev_down)(struct pn533 *priv);
+       int (*dev_up)(struct pn533 *priv);
+       int (*dev_down)(struct pn533 *priv);
 };
 
 
index 46e5ff16f69967b9a8fc6972a78ffb2b9562216d..a0665d8ea85bcad6bbfe912d35bc443f1a45156e 100644 (file)
@@ -100,20 +100,27 @@ static void pn532_uart_abort_cmd(struct pn533 *dev, gfp_t flags)
        pn533_recv_frame(dev, NULL, -ENOENT);
 }
 
-static void pn532_dev_up(struct pn533 *dev)
+static int pn532_dev_up(struct pn533 *dev)
 {
        struct pn532_uart_phy *pn532 = dev->phy;
+       int ret = 0;
+
+       ret = serdev_device_open(pn532->serdev);
+       if (ret)
+               return ret;
 
-       serdev_device_open(pn532->serdev);
        pn532->send_wakeup = PN532_SEND_LAST_WAKEUP;
+       return ret;
 }
 
-static void pn532_dev_down(struct pn533 *dev)
+static int pn532_dev_down(struct pn533 *dev)
 {
        struct pn532_uart_phy *pn532 = dev->phy;
 
        serdev_device_close(pn532->serdev);
        pn532->send_wakeup = PN532_SEND_WAKEUP;
+
+       return 0;
 }
 
 static struct pn533_phy_ops uart_phy_ops = {