From patchwork Fri May 12 07:53:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 681618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFF21C7EE25 for ; Fri, 12 May 2023 07:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240356AbjELHxY (ORCPT ); Fri, 12 May 2023 03:53:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240337AbjELHxN (ORCPT ); Fri, 12 May 2023 03:53:13 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFD8100F9; Fri, 12 May 2023 00:53:07 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f14468ef54so10960816e87.0; Fri, 12 May 2023 00:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683877985; x=1686469985; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zGWZeSOJvbJTBrhI3yrJesYXVyhARM/YB/qVyBmPJnA=; b=p1T36/U67c4bI93KQPUoVzB8t570wxx699H81X4eDMaCi1TAsntFPzeBwOCJgxrjoc dZys5yPZkXmOaAESU27Qed0Qk+cg57AP6gr6qnsHxv1B5yVCV7WGyJ2AoU1i3UctCA9U AbJJLygmkOrf6MMahX7lqFAWUy0l+9r0Gpt5rfy2ohV17+owS+U8TTaZjLttWAx3j7iJ tBU3PyQQGfhLLoWEj+5bHlo2Ob63gl+DCx7g5FTXC9nhMQAOdMAaSL0ZXX86SGULftIN lIigeLOi9swBGwGk5mjSORvx7UZPVxf3MwSyX2Ls0LdUEa1BntPO2h6H1mAcBaKvQhYY f25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683877985; x=1686469985; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zGWZeSOJvbJTBrhI3yrJesYXVyhARM/YB/qVyBmPJnA=; b=kKWkE9SG+SYCB3SWx5nTEuzTyIWDKvrt31UAoOCXXB6wdwwTEju00SCV5ahZ9x00AY lJTKiLbUhwNU3zPQqAW+1rK9kEfLiC0v2o9qHrGXMovpFPCq+uF8bUAJDetlBQdbo/20 qheNdAfj9d4GMwkcMlzdeeNQpznoe3Hw2U1KWHTmSrxic3p4ZZvpMvYk+G2gx5CGe9fX 6QIy1aQ3Gyen/pNbldQntg1hou0TM3YnPjV60u7FvB44Y/RwcluyGeok9kk9iQ0hhR5B frsq7PAwM5kUt0RDTufgniJyPWVRNrY5HZlTBisbl7S+noV85rZVlFH9iZIRzx5VdNXH RbTQ== X-Gm-Message-State: AC+VfDwBCmQsrrBYVAOHxVk01NC7383Ga/DZamWdb0fhi7N8JENNjz6M qaA7QSewo12pjhuCVzeUgj0= X-Google-Smtp-Source: ACHHUZ7qYGp3wgx6QTPLyhqD5sl+XwY/8F9KO4E6giVnrinsLVSUiUhbsySoHpjo7zLnUXaDf3LcyQ== X-Received: by 2002:a19:f813:0:b0:4ec:a48a:28c0 with SMTP id a19-20020a19f813000000b004eca48a28c0mr3574652lff.25.1683877985032; Fri, 12 May 2023 00:53:05 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id x17-20020ac25dd1000000b004f155743899sm1386872lfq.92.2023.05.12.00.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 00:53:04 -0700 (PDT) Date: Fri, 12 May 2023 10:53:00 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Wolfram Sang , Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v3 1/3] drivers: fwnode: fix fwnode_irq_get_byname() Message-ID: <9dd75817886fbb2a0cc58e2248dbba52d8a6d908.1683875389.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The fwnode_irq_get_byname() does return 0 upon device-tree IRQ mapping failure. This is contradicting the function documentation and can potentially be a source of errors like: int probe(...) { ... irq = fwnode_irq_get_byname(); if (irq <= 0) return irq; ... } Here we do correctly check the return value from fwnode_irq_get_byname() but the driver probe will now return success. (There was already one such user in-tree). Change the fwnode_irq_get_byname() to work as documented and according to the common convention and abd always return a negative errno upon failure. Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") Suggested-by: Sakari Ailus Reviewed-by: Sakari Ailus Reviewed-by: Andy Shevchenko Signed-off-by: Matti Vaittinen --- drivers/base/property.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f6117ec9805c..a3b95d2d781f 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1011,7 +1011,7 @@ EXPORT_SYMBOL(fwnode_irq_get); */ int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) { - int index; + int index, ret; if (!name) return -EINVAL; @@ -1020,7 +1020,12 @@ int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) if (index < 0) return index; - return fwnode_irq_get(fwnode, index); + ret = fwnode_irq_get(fwnode, index); + /* We treat mapping errors as invalid case */ + if (ret == 0) + return -EINVAL; + + return ret; } EXPORT_SYMBOL(fwnode_irq_get_byname);