From patchwork Tue Oct 25 08:50:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 619039 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 B9E5CC04A95 for ; Tue, 25 Oct 2022 08:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbiJYIvS (ORCPT ); Tue, 25 Oct 2022 04:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbiJYIvJ (ORCPT ); Tue, 25 Oct 2022 04:51:09 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE83100BEF; Tue, 25 Oct 2022 01:51:06 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id bn35so7203826ljb.5; Tue, 25 Oct 2022 01:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=8R7Dzkg4GW8RstwwsY0aTGhaifKaL40i/WfeE85O4HQ=; b=M4gG5q52M/fQ9S4AOTPRH4k1dtWqpvOU0rll7wPOXPb3Bwet7P3t8f3mFv42GbrAy9 5EURqb4L7WnK/nC3JOiYfyGIGCDzWD4i6bHe0GX6e4/4fdYuaGk5orrzxKxmyHHnH1zN u24zaLTaynom7ACPi3VX8hiX03meCkywL+o6ONYMDc5scpG5EccOSBdrcVeSalgbzLRA v5V3PsOAfFOcJUWy+q/jA/g+oCqwET8SAAEiVCdOT9tLmshrPsEBrUewWDE0z99G/q6B 4rxDuEI7l8y/uV0E2Kinc6RPR7lKpJkMy3zF8fYozGaU+HIIUXEuq5+s56J/W0PPufAg Gp3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8R7Dzkg4GW8RstwwsY0aTGhaifKaL40i/WfeE85O4HQ=; b=WjJnxSb30D1Za/VjN+lzib1JeT0D1FITxn53zBKuM9pWP1rAuJuPzVcdZ1b2K8AUKf tP56pn/17WP3s7VM8We1wasPGpJvpu+R5sxFhwhMSNCXo5C9i4lYmVKoXBCmHMWH3FjX YWPCmcayDn/Cof7ZrBoo9i3fvZKecaWhZcHfBBoMpCdPW6Dlb1YcVzGcAJfkPh8RsA2w qPTauK9cNYCaP4w3nmVLxQokF/EljO9lRSKrJE4/EIN9muNORRu4cKHdI/DbrVmSNnZF Rz0X2qSuGTxUEO575l1dW5GlfDm6/ZM4Zrjtly60V5iw9Q9oppxUD5O6PEQzWuCcbNbI kIeQ== X-Gm-Message-State: ACrzQf06MhXtJNTKCnqaeQHB853PyXS8rulsC0dffQ/G/+WLrMAg23qZ YzZ8GygLwV1Y19MRf8X6ydRlLod0FC0= X-Google-Smtp-Source: AMsMyM7n1L9PPIffLH1ajY4W5iGiaOUMO2bRde9qkIiM0wgTpAlSYIFbHPglgLZnhCsLvU6I+4GokQ== X-Received: by 2002:a2e:9b17:0:b0:26e:367c:c904 with SMTP id u23-20020a2e9b17000000b0026e367cc904mr14717348lji.326.1666687864570; Tue, 25 Oct 2022 01:51:04 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id m4-20020a056512114400b0049b8c0571e5sm326150lfg.113.2022.10.25.01.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 01:51:03 -0700 (PDT) Date: Tue, 25 Oct 2022 11:50:59 +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 , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH 1/2] drivers: fwnode: fix fwnode_irq_get_byname() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 Signed-off-by: Matti Vaittinen --- I did a quick audit for the callers at v6.1-rc2: drivers/i2c/i2c-smbus.c drivers/iio/accel/adxl355_core.c drivers/iio/gyro/fxas21002c_core.c drivers/iio/imu/adis16480.c drivers/iio/imu/bmi160/bmi160_core.c drivers/iio/imu/bmi160/bmi160_core.c I did not spot any errors to be caused by this change. There will be a functional change in i2c-smbus.c as the probe will now return -EINVAL should the IRQ dt-mapping fail. It'd be nice if this was checked to be Ok by the peeps knowing the i2c-smbus :) --- 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 4d6278a84868..bfc6c7286db2 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -964,7 +964,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; @@ -973,7 +973,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); + + if (!ret) + return -EINVAL; + + return ret; } EXPORT_SYMBOL(fwnode_irq_get_byname); From patchwork Tue Oct 25 08:51:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 618454 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 8D998FA373E for ; Tue, 25 Oct 2022 08:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231836AbiJYIvq (ORCPT ); Tue, 25 Oct 2022 04:51:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbiJYIvg (ORCPT ); Tue, 25 Oct 2022 04:51:36 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D22104538; Tue, 25 Oct 2022 01:51:30 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id z24so5908094ljn.4; Tue, 25 Oct 2022 01:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=o3rqVRlWpSG6VhxIJc6elhskuf/gfvFUZOs7XfqtDQ4=; b=PhT/oTUlDmRpv0Bb4JK6SuAV7SfeTBOaUeARe12U3pXsQ7U6TVJ2j5K2k+atR1d8vk tM/06kMcF6NbAP8TlOctINFiaTlEF2XMyhRbCtE3My5IfILstolxutOF1+WRdmdj1OBr fG0P0VIZAdmF7Dz9JUDKWM1fv5k2I8t3IBkfuaITggVmkgB5oDpcI0AUVJfc2k/h4hiU VsWRL5Jdq2PK4sTYIC1eAssKvX0VZWKLUzA0ovT9Z9endNqdJtA6eH4DCtzU1wlIaVaV JkV+gpAEOe0PykcmX1dq819Vu+62ZyojEfUVJRg4VqR6fFB1oFL4hkTndCwfOUW354sb AW9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=o3rqVRlWpSG6VhxIJc6elhskuf/gfvFUZOs7XfqtDQ4=; b=Oq7ZGncmFMBoFjDydRf/8mfd8c27jpd3jIJvjmzi3AiVhIzVX9q1mzS7qf9g2hG6BA ku7rMn1IzbPu7V2IWUwzcdX+vx/48i+9Sa5KAtcII7T80uXOkdOyvZieCUEMJG23Jlcx ybstn2srDuOlm9p+KCfSZUWHw/B3DpCqX1O+UIdAeGJ0giDM6DBFfPPWxPhOVJUETXWI yccr7/XO19Ci+u90s8+iDPF0LKS+xPQ285kgA8z921xi98WSsqGbvf0E6B3CxGuL/lUd lBXw8XIBIfOvbr0fUMvM2w16+0Cojd8jyyjkGd5vsZtZN+EXfSutOdrMH4cx03MV5xyg DqRw== X-Gm-Message-State: ACrzQf3hDivAcd58MLKtvM8hG3GAqMYFWwZNSnwOiBy+0CeHdSVqltv1 /fToWH3PEaiXfR/wCnIjDHg= X-Google-Smtp-Source: AMsMyM74Jng8VYpXW1kaXxr8PkbuDusArrxPGpGFkyFF195SvESqix+NnNDVN3E1lw3x2QQmuF19ig== X-Received: by 2002:a2e:8541:0:b0:261:b44b:1a8b with SMTP id u1-20020a2e8541000000b00261b44b1a8bmr14594268ljj.46.1666687889255; Tue, 25 Oct 2022 01:51:29 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id p8-20020a2eba08000000b00277041268absm383931lja.78.2022.10.25.01.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 01:51:28 -0700 (PDT) Date: Tue, 25 Oct 2022 11:51:22 +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 , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH 2/2] 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-i2c@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. 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. --- 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 07c92c8495a3..d0cc4b7903ed 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -130,7 +130,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; }