From patchwork Fri Nov 14 22:35:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5310011 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88D12C11AC for ; Fri, 14 Nov 2014 22:35:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3D6F2017D for ; Fri, 14 Nov 2014 22:35:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0115C2015D for ; Fri, 14 Nov 2014 22:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754634AbaKNWfc (ORCPT ); Fri, 14 Nov 2014 17:35:32 -0500 Received: from mail-ie0-f174.google.com ([209.85.223.174]:40377 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754550AbaKNWfa (ORCPT ); Fri, 14 Nov 2014 17:35:30 -0500 Received: by mail-ie0-f174.google.com with SMTP id x19so18872149ier.33 for ; Fri, 14 Nov 2014 14:35:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=9XJRshN4eXS3Gwznjh/e9A5YcYKaVYSMlPhxgyQ/LVw=; b=DiXVruwKtjiNCmpsVpyXcoE+hay+mcW4/IBUBWWKCPvdxzkpE+uRpZg2ijRWjepJ3A qK2YLCY+CBYoLnI52VqK8QqGBMGtFMQbx6vc9LjFXPk1ruf1lWi/oAleimAnq5N/ViOl en54t8x6ya4Z7vi9XW0PbXS5lFgfRDKfcWzmvreQ+r4rSGJE94FS4CBV21pFYJUrX+QW ayGK1HP8Kich/5qMTKxDTyeXOSLdbmUL69QRjCNIsv4an2LVMp1nUCsgG1V6gI4yO5IK zvdXBqO23rycbHIQoowCmX7MCAu8c2DxTiZqUjzAmtTxoOfc4leDGUDbM+59+xBDvlGq allg== X-Gm-Message-State: ALoCoQkeaFdHsmrXH2Lu8TZ4Sj34qoEukn5Nh2XkENEPfDx/eoeqOWx5ZIcbfd4To1WKT5TRn+w4 X-Received: by 10.107.3.163 with SMTP id e35mr13543882ioi.45.1416004530102; Fri, 14 Nov 2014 14:35:30 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1301:8c0e:c406:dbcd:b83b]) by mx.google.com with ESMTPSA id ii3sm3115127igb.1.2014.11.14.14.35.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Nov 2014 14:35:29 -0800 (PST) Date: Fri, 14 Nov 2014 14:35:27 -0800 From: Dmitry Torokhov To: Lauro Ramos Venancio Cc: Aloisio Almeida Jr , Samuel Ortiz , Christophe Ricard , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] NFC: st21nfcb: fix error handling of irq_of_parse_and_map Message-ID: <20141114223527.GA2622@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Return value of irq_of_parse_and_map() is unsigned int, with 0 indicating failure, so testing for negative result never works. Also report error returned by devm_gpio_request_one instead of clobbering it with -ENODEV. Signed-off-by: Dmitry Torokhov --- Not tested, found by casual code inspection. drivers/nfc/st21nfcb/i2c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c index c5d2427..abe73ec 100644 --- a/drivers/nfc/st21nfcb/i2c.c +++ b/drivers/nfc/st21nfcb/i2c.c @@ -258,19 +258,18 @@ static int st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client) GPIOF_OUT_INIT_HIGH, "clf_reset"); if (r) { nfc_err(&client->dev, "Failed to request reset pin\n"); - return -ENODEV; + return r; } phy->gpio_reset = gpio; /* IRQ */ - r = irq_of_parse_and_map(pp, 0); - if (r < 0) { - nfc_err(&client->dev, "Unable to get irq, error: %d\n", r); - return r; + client->irq = irq_of_parse_and_map(pp, 0); + if (!client->irq) { + nfc_err(&client->dev, "Unable to get irq\n"); + return -EINVAL; } phy->irq_polarity = irq_get_trigger_type(r); - client->irq = r; return 0; }