From patchwork Fri Nov 14 22:32:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5309991 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5ECC19F667 for ; Fri, 14 Nov 2014 22:32:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89B8C2017D for ; Fri, 14 Nov 2014 22:32:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCF9B20149 for ; Fri, 14 Nov 2014 22:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422787AbaKNWc2 (ORCPT ); Fri, 14 Nov 2014 17:32:28 -0500 Received: from mail-ig0-f170.google.com ([209.85.213.170]:57967 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422754AbaKNWc1 (ORCPT ); Fri, 14 Nov 2014 17:32:27 -0500 Received: by mail-ig0-f170.google.com with SMTP id a13so543973igq.3 for ; Fri, 14 Nov 2014 14:32:27 -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=QYeGdcgxmdxHpjqoOcu68XFRrzKBE8JS0CG8NL5giUA=; b=R99Yp8RsOgNJ4VwBDMIQQrvUJVnc7yrEj+53vVO882qf2Z+j3kMlTZkC1ryZr8m0mV riLsNxfA2M4uRbChorS5aYF3uSJTi/QpNaEEYnTGw5hofnFalINHe7Iyqie38+d/lhiM tn6GxNhGqm/gSggFm8Ki/k1whtUdFVxrZKqt7CWpa3b4Z/nexTvGmDepf4Z+/xGrLeNm +7XxaxMFTb7ewNzYRocZ0d4CRQhLkRaKpUZMB1UTyZdpMH2uXT33jN5sP2vs6aH0kJCm iJrw5wWSYHp6tWqHcb8z6UbqQ6JKesO07HD00c6c2sQZsK2tcxOf7NM22pny3ViNUhoK N7IQ== X-Gm-Message-State: ALoCoQn7Q2N7U2jvx/tqk4N51wVwC6HK9AHHHvbS+nXCFeAhlLLUvhYcDAWwvWRKtz+GZRB7Xa+b X-Received: by 10.43.75.138 with SMTP id za10mr13959353icb.23.1416004346925; Fri, 14 Nov 2014 14:32:26 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1301:8c0e:c406:dbcd:b83b]) by mx.google.com with ESMTPSA id o70sm30701ioe.20.2014.11.14.14.32.26 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Nov 2014 14:32:26 -0800 (PST) Date: Fri, 14 Nov 2014 14:32:24 -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: st21nfca: fix error handling of irq_of_parse_and_map Message-ID: <20141114223224.GA1448@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 --- drivers/nfc/st21nfca/i2c.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index 0ea756b..6d6d282 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c @@ -531,20 +531,19 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client) "clf_enable"); if (r) { nfc_err(&client->dev, "Failed to request enable pin\n"); - return -ENODEV; + return r; } phy->gpio_ena = 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; }