linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Poeschel <poeschel@lemonage.de>
To: Lars Poeschel <poeschel@lemonage.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Jilayne Lovejoy <opensource@jilayne.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Steve Winslow <swinslow@gmail.com>,
	netdev@vger.kernel.org (open list:NFC SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list)
Cc: coverity-bot <keescook+coverity-bot@chromium.org>
Subject: [PATCH net-next] nfc: pn533: pn533_phy_ops dev_[up,down] return int
Date: Wed, 13 Nov 2019 14:50:22 +0100	[thread overview]
Message-ID: <20191113135039.32086-1-poeschel@lemonage.de> (raw)

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>
---
 drivers/nfc/pn533/pn533.c | 12 ++++++++----
 drivers/nfc/pn533/pn533.h |  4 ++--
 drivers/nfc/pn533/uart.c  | 13 ++++++++++---
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index aa766e7ece70..346e084387f7 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -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;
 }
diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h
index b66f02a53167..5f94f38a2a08 100644
--- a/drivers/nfc/pn533/pn533.h
+++ b/drivers/nfc/pn533/pn533.h
@@ -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);
 };
 
 
diff --git a/drivers/nfc/pn533/uart.c b/drivers/nfc/pn533/uart.c
index 46e5ff16f699..a0665d8ea85b 100644
--- a/drivers/nfc/pn533/uart.c
+++ b/drivers/nfc/pn533/uart.c
@@ -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 = {
-- 
2.24.0


             reply	other threads:[~2019-11-13 13:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 13:50 Lars Poeschel [this message]
2019-11-13 20:15 ` [PATCH net-next] nfc: pn533: pn533_phy_ops dev_[up,down] return int David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113135039.32086-1-poeschel@lemonage.de \
    --to=poeschel@lemonage.de \
    --cc=davem@davemloft.net \
    --cc=gustavo@embeddedor.com \
    --cc=keescook+coverity-bot@chromium.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=opensource@jilayne.com \
    --cc=swinslow@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).