Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1884764ybc; Wed, 13 Nov 2019 05:55:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzIQXBCYa+XzGSnrYbfFVEo1DysKlco28MQpyGi/SIKoI+0ul+V7iaJ9ebxKqRaGxhTMZs1 X-Received: by 2002:a50:c191:: with SMTP id m17mr3608872edf.259.1573653336588; Wed, 13 Nov 2019 05:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573653336; cv=none; d=google.com; s=arc-20160816; b=Xo8kzisfX5WRWpk4Umy/GTVH09zxuKHIrIBjnAJOE/WiSYZtauGgRAO06LNg/h1c7g 28DtkTsoRXdkT+JFVI1v2JH3oiV/jpHrzNPsV7cbS4t4noB3x1YH0H0I1E8ivWZf4N22 Dp/mFPds0ZZwh1cLu0XQ06VcMcDqb2PI/yjIwfg6yAVIWu146350Qw3HtnK1HG/tGt1V CLHcsqswCXR2Ua8n1YtHNeU+39K5JBDs60tDUHEv62fdWeRlu8xdG01ffBDECtxUYR3x OEytI5/dI3tBp1EnR5FnIuJL8qRFcdOOgL/l3DbuVlJ7kOwqO6iuQKCcEZN3VHibz/Sr /8vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wd/z2neAFrbREjY1HE7jzMb1D6OiY7IccH6WeKurLxE=; b=GHqoUEfsrVR6QPxyzH2tAMZKsdSBLPuoCrZzhPgMPZNDKs3v3x+RnYIldKjFVPAqbQ EEi7xPZLkza7CQrItmKHWoFJeS6xh/Tq3HODi4hPhXrexyplmyjV4GdM0yFG4Cotp57z fBorga3ItFe+Bv6wdO1aE30atexA3qcIRMYM0Z9J12deID5ox6ZSPpg1yFJscoklpXyF TYWwcw7QjpyAHPctfHnyxrSfJK4IATeXGiQmyqc5SIWqrhVAIk2xRFjZON9ZDdyiovNQ cNAlPC9VQ0vD+AHBEhQHSLrEQrGUkpkMewkxdSAHRb+8pSqB4UPHk88J47CdRjE8jmlQ CyuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy25si1107774ejb.291.2019.11.13.05.55.10; Wed, 13 Nov 2019 05:55:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727593AbfKMNvx (ORCPT + 99 others); Wed, 13 Nov 2019 08:51:53 -0500 Received: from smtp2.goneo.de ([85.220.129.33]:46438 "EHLO smtp2.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfKMNvx (ORCPT ); Wed, 13 Nov 2019 08:51:53 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 3941123FC29; Wed, 13 Nov 2019 14:51:49 +0100 (CET) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -3.07 X-Spam-Level: X-Spam-Status: No, score=-3.07 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.170, BAYES_00=-1.9] autolearn=ham Received: from smtp2.goneo.de ([127.0.0.1]) by localhost (smtp2.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VWH12606cqcp; Wed, 13 Nov 2019 14:51:48 +0100 (CET) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 2BF0B23F40C; Wed, 13 Nov 2019 14:51:47 +0100 (CET) From: Lars Poeschel To: Lars Poeschel , "David S. Miller" , "Gustavo A. R. Silva" , Kate Stewart , Jilayne Lovejoy , Thomas Gleixner , Steve Winslow , netdev@vger.kernel.org (open list:NFC SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Cc: coverity-bot Subject: [PATCH net-next] nfc: pn533: pn533_phy_ops dev_[up,down] return int Date: Wed, 13 Nov 2019 14:50:22 +0100 Message-Id: <20191113135039.32086-1-poeschel@lemonage.de> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Addresses-Coverity-ID: 1487395 ("Error handling issues") Fixes: c656aa4c27b1 ("nfc: pn533: add UART phy driver") Signed-off-by: Lars Poeschel --- 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