From patchwork Sat Nov 18 10:55:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 10064749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA3C160352 for ; Sat, 18 Nov 2017 10:56:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2AEB2A683 for ; Sat, 18 Nov 2017 10:56:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 974872A6C6; Sat, 18 Nov 2017 10:56:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 395FE2A683 for ; Sat, 18 Nov 2017 10:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RhrkDyUHs+9gB74Odx3mX9XaBjIYQj9cIli+Fyqj8oA=; b=jPBGBbIcZR4B3whz040XDOAALk AVqK6VSgcdotJy5ar7+nQNn17lEcQV1Lvi0c3NUZds2vQTQJazxTvLuf1uUlro6nnD2WMdklsMr8/ 3QpVBqm8LZfUYO10uL0KtLHfGNox8zkpZ0cSxCij/WZa+1wHT91R1kKWDqws7VytlqL+kgFlZoSic xdIOdvSLnIsZ+Hu5lUDW9WA4cI7V4Cp9rP5ivrwRj8t6ir09IXoAQbWzpf84SO5hsTVcgdQWcwMhO Rkd33OtAgBcg6P8LxoI8M5fghL40Tw7eDY79CJir7qPWMc6UsFBSRGFjAxjIo8998FliPVts0cJ+C lXM7n5Ng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eG0nY-00065U-QG; Sat, 18 Nov 2017 10:56:32 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eG0my-0005Vn-RD for linux-arm-kernel@lists.infradead.org; Sat, 18 Nov 2017 10:55:58 +0000 Received: by mail-pg0-x243.google.com with SMTP id l19so3850007pgo.2 for ; Sat, 18 Nov 2017 02:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Gy4Zi09ggh/9VtGtQOBn0kRT+VCRq6FfbUyrJ8uNEyU=; b=j5nc1JxaDb5ApcoFJ/YcQ8a2UqBQBelhGade3F1/PgwnudAUw9Q5ydhv9jMCz/oZ/K KVRMbHNe85BIjUwR28/owrRkThuOK7jdcYrp3yk86xa1arZGf94jmNv3zppqayAk1xnM h/Fami9koitxdPjnPG67QgQuN7MDtZWbvmn2Jup+aeyWyKpmCG5QuWFomay1+rsp9JUS Poy/gqQwo/QQGkgB3NoQwcnd2UB7RasfGaJf+jUEaoAemD+YtmXvIiZkIFS51X0MNw8P eXke3jz+yWsm5FRTpxs2MpC7n85d+omXIscnJSH/VKEDJBGB9ZVwDjGgCEcq5bqqo0IK BkNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Gy4Zi09ggh/9VtGtQOBn0kRT+VCRq6FfbUyrJ8uNEyU=; b=j1n2swMdz5lSpjm5M8zpVHsHhAi2WckNrFRd+Rxfod1B/PxHWWNwJ7myEEdRax1V+7 u+rZUDYirReoivDWV7d7h5vS0TkhlPXTfIuu+FeRj4yZ7e5hAzJigyl8X6KQ5yIXrEXp +QsKtYaXeRJ/mmMTo8PivrQo9S2r0gwXx/h+Wm6rtOmEquFckf7uJZNTCLsgusN7iyqv MIbZ39nqD0fdIEb1fxW05B38dv2z/j/UlUY9E9dEl4H8HBY262XNcWUCB4epNCLW7VKj QPiHKezV0CupDCVFUKb/Q3Hi3WPNOM1JsL8ureO4yVklNPAcf7D8+LpofqQP9+a/03IH Clyw== X-Gm-Message-State: AJaThX7G1v5nrybcUrrmxlWyfrxjRYC4MmrUAzwpRi7NUHQZUUly0Dow Ly67Sx4b7uhmAuihqSme+CA= X-Google-Smtp-Source: AGs4zMaJzsXjerrdjaioAf/wz7bZWoWcFax0z8UyS2cpC1n0jIZFokT28XreCVwFSlTVCuMeQigLtw== X-Received: by 10.159.208.67 with SMTP id w3mr7987822plz.175.1511002536314; Sat, 18 Nov 2017 02:55:36 -0800 (PST) Received: from localhost.localdomain ([103.16.68.147]) by smtp.gmail.com with ESMTPSA id g7sm12321513pfj.13.2017.11.18.02.55.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 18 Nov 2017 02:55:35 -0800 (PST) From: Arvind Yadav To: dmitry.torokhov@gmail.com, maxime.ripard@free-electrons.com, wens@csie.org, mcuos.com@gmail.com, linux@roeck-us.net, linux@armlinux.org.uk, lee.jones@linaro.org Subject: [PATCH 03/10 v3] Input: twl4030_keypad: Fix platform_get_irq's error checking Date: Sat, 18 Nov 2017 16:25:10 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171118_025557_017570_F4811C58 X-CRM114-Status: GOOD ( 11.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The platform_get_irq() function returns negative if an error occurs. zero or positive number on success. platform_get_irq() error checking for zero is not correct. Signed-off-by: Arvind Yadav --- changes in v2 : kp->irq is unsigned. use temporary int variable irq. changes in v3 : Add failure case '<= 0' instead of '< 0'. IRQ0 is not valid. drivers/input/keyboard/twl4030_keypad.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c index f9f98ef..d921238 100644 --- a/drivers/input/keyboard/twl4030_keypad.c +++ b/drivers/input/keyboard/twl4030_keypad.c @@ -341,6 +341,7 @@ static int twl4030_kp_probe(struct platform_device *pdev) struct input_dev *input; u8 reg; int error; + int irq; kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); if (!kp) @@ -388,11 +389,12 @@ static int twl4030_kp_probe(struct platform_device *pdev) return -EINVAL; } - kp->irq = platform_get_irq(pdev, 0); - if (!kp->irq) { + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { dev_err(&pdev->dev, "no keyboard irq assigned\n"); - return -EINVAL; + return irq; } + kp->irq = irq; error = matrix_keypad_build_keymap(keymap_data, NULL, TWL4030_MAX_ROWS,