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); From patchwork Fri May 12 07:53:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 681253 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 32DCDC77B7C for ; Fri, 12 May 2023 07:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240372AbjELHyP (ORCPT ); Fri, 12 May 2023 03:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240374AbjELHx6 (ORCPT ); Fri, 12 May 2023 03:53:58 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E64106FD; Fri, 12 May 2023 00:53:31 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ac80da3443so105629231fa.0; Fri, 12 May 2023 00:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878010; x=1686470010; 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=r+fkvnw5qJK8Z9ZsEdDbVAibOHT/dgf1NL+n5A0kE4I=; b=P2el5kc09GmR4TELHXaLBONDRptaapBZXgUK3wEKkHoAPmtY9J2Qc1yr8KUR/4u5HP dnNBqWE0Pa2xaUIy4VJKr+uWa9bVH1jW7m4y/iSTDrl8wBvUhrRt5ePLB2XiEo61eS3l JKOtVi8/7GNe2+m7JMSU9goRVv+YB0MfD5rt9s7GRkkXloLQV1Hgj6paBsYn3Rk/d0nC ysMD5oN0iiYk111epYMERRDTCBq8z/fRrtOgCqssglyPDBHQmujNsmVViI18VbXN7AFl QAdKY8B16cLejoIMDgTb37tCb1/DZnJbcvBmOo0PCN7qZuJFUupLFsRrgddkzk4WFYnG a9lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878010; x=1686470010; 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=r+fkvnw5qJK8Z9ZsEdDbVAibOHT/dgf1NL+n5A0kE4I=; b=M30ogO3oM2xaPhYftT+PQ8K80B0odPDxBNWsriN0gGAOPGTUZwiuvr3C3mGROQJwFX vIXLaejj7XoqrlV/TWsJiuotXG7lcB82eXIn2Lpcvou7o+7TMdzA3HuR+n2wNKF9wUnd KnTQk7xXnvdCUR6yGzdt6vo9fwoH9gPsbJqPLE5VR4Ij1BHaGzC7U1px7Azm+lLLMaQF SUuucEnWx6JARCEdgiqr67J0fU5JEKA7CxH7TM+Jd1YrEiwRdM/Iv8QkzYNIjdSYTrWe aiK6qctAvu8Ou8j6HMXXPrZRW5Vv0QEwgMgLQ2X+zGHORFR68zEeb3fVphlKXYCcCGQ3 06kw== X-Gm-Message-State: AC+VfDwi2Akw+8Twd7qYw/lO3JlLbGy+H4H02WlcuVSPGMkx4S1bLSsC wFgrnFArQd+GMGIXfldxDvY= X-Google-Smtp-Source: ACHHUZ51mCBU4t5K+r6iUvLR0RIkn1IL1WxlHPQYiauSW0ImZb7mE0vLP5zf4X8InqXz4KoUNWkjhA== X-Received: by 2002:a2e:7004:0:b0:2ac:8e5a:1054 with SMTP id l4-20020a2e7004000000b002ac8e5a1054mr3988058ljc.0.1683878009870; Fri, 12 May 2023 00:53:29 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id l18-20020a05651c10d200b002aa4713b925sm2691194ljn.21.2023.05.12.00.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 00:53:29 -0700 (PDT) Date: Fri, 12 May 2023 10:53:25 +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 2/3] i2c: i2c-smbus: fwnode_irq_get_byname() return value fix Message-ID: 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() was changed to not return 0 upon failure so return value check can be adjusted to reflect the change. Reviewed-by: Sakari Ailus Reviewed-by: Andy Shevchenko Signed-off-by: Matti Vaittinen --- Depends on the mentioned return value change which is in patch 1/2. The return value change does also cause a functional change here. Eg. when IRQ mapping fails, the fwnode_irq_get_byname() no longer returns zero. This will cause also the probe here to return nonzero failure. I guess this is desired behaviour - but I would appreciate any confirmation. Please, see also previous discussion here: https://lore.kernel.org/all/fbd52f5f5253b382b8d7b3e8046134de29f965b8.1666710197.git.mazziesaccount@gmail.com/ Another suggestion has been to drop the check altogether. I am slightly reluctant on doing that unless it gets confirmed that is the "right thing to do". --- drivers/i2c/i2c-smbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index 138c3f5e0093..893fe7cd3e41 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -129,7 +129,7 @@ static int smbalert_probe(struct i2c_client *ara) } else { irq = fwnode_irq_get_byname(dev_fwnode(adapter->dev.parent), "smbus_alert"); - if (irq <= 0) + if (irq < 0) return irq; } From patchwork Fri May 12 07:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 681617 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 9B138C7EE25 for ; Fri, 12 May 2023 07:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239992AbjELHya (ORCPT ); Fri, 12 May 2023 03:54:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240351AbjELHyJ (ORCPT ); Fri, 12 May 2023 03:54:09 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03907100CE; Fri, 12 May 2023 00:53:51 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ac8091351eso101835801fa.2; Fri, 12 May 2023 00:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878025; x=1686470025; 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=UamIyRZFBw0Clb1Qm1i1FDtoVxcrvBBxLqTrmWJ4kUM=; b=D8Nfc850hE+XcwHJJnodIg9lQCxPABMpNE8TbL4p2gx6vCBNNWMD8mRzuXKu3uG2lT f4r2EKd8yuMjEtM6VavfoemsphC2bhF5K4RGoWXRQLyl+niVwqjfRlnGj6ZxvDLQuncQ qa5oK5QtZQ3gOOAEiDNccDJpahMSkHZa3c0BQ/UGwVl5sYXQnFpKp64dJoKuNwhdSy// 7yQIpoMWbISAjtGPlOR3pO/7Yv8cKtNV8jZP8rAxer3yrSlgXHbyDJYI5Png6/rPcBkn GYP3I0sgq5Als22F3lvCfZ0c5Iqgbzo2Fi5pe84Maoq2Oek4A9xuMWa5c1a9vttTHb/r Qf0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878025; x=1686470025; 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=UamIyRZFBw0Clb1Qm1i1FDtoVxcrvBBxLqTrmWJ4kUM=; b=HrgYkHBmww4Wmkxj06QpYj7knbbg9ZYiQUwxaop5usWRqoa+VJmjqyAVunvYct4K/I XxVivNqhQ55cPtZ857MS5LG6Cv5v6DaYNCQmAITsVebAyjfGfGGle9arHfZ8l0D3vAKr 7UqMOLl1TUZ4urDueCAF809eY0PkdhFpU4mEGewTHmJ329sYxFCXBzjoL0QcgB3Imyaq Qq7IHQf9KEAmAo4Ela1SPt61xsfC/HhgxTvC821LhawwN8FmrsMS4A3Pkurp8xjXl5wz M02VLvAvWWAY41va9RpXvaS+i2KBcj/OlRmx5uIjyXLk0pdP5H8hzaO9YWnGJXYjzLfQ OYXg== X-Gm-Message-State: AC+VfDxqBjiH+NirDAgTP93jOucNerRmUf+B9Radpshy3xeX+QLFm6LY Xr3SfdBfiBi3qn6yiGhfXgc= X-Google-Smtp-Source: ACHHUZ5tTAE/td2qUR/2Oxfo7q0tt4popK4haev3B//DkXySakT8sBeWAwj/t8s7JKOp5UNIAK2d7A== X-Received: by 2002:a2e:3211:0:b0:2a8:ba15:eb6f with SMTP id y17-20020a2e3211000000b002a8ba15eb6fmr3979864ljy.6.1683878024857; Fri, 12 May 2023 00:53:44 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id z12-20020a19f70c000000b004db3d57c3a8sm1383610lfe.96.2023.05.12.00.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 00:53:44 -0700 (PDT) Date: Fri, 12 May 2023 10:53:41 +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 3/3] iio: kx022a fix irq getting Message-ID: 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() was returning 0 at device-tree mapping error. If this occurred, the KX022A driver did abort the probe but errorneously directly returned the return value from fwnode_irq_get_byname() from probe. In case of a device-tree mapping error this indicated success. The fwnode_irq_get_byname() has since been fixed to not return zero on error so the check for fwnode_irq_get_byname() can be relaxed to only treat negative values as errors. This will also do decent fix even when backported to branches where fwnode_irq_get_byname() can still return zero on error because KX022A probe should later fail at IRQ requesting and a prober error handling should follow. Relax the return value check for fwnode_irq_get_byname() to only treat negative values as errors. Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202305110245.MFxC9bUj-lkp@intel.com/ Link: https://lore.kernel.org/r/202305110245.MFxC9bUj-lkp@intel.com/ Signed-off-by: Matti Vaittinen Fixes: 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer") --- drivers/iio/accel/kionix-kx022a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index f98393d74666..b8636fa8eaeb 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -1048,7 +1048,7 @@ int kx022a_probe_internal(struct device *dev) data->ien_reg = KX022A_REG_INC4; } else { irq = fwnode_irq_get_byname(fwnode, "INT2"); - if (irq <= 0) + if (irq < 0) return dev_err_probe(dev, irq, "No suitable IRQ\n"); data->inc_reg = KX022A_REG_INC5;