From patchwork Fri May 12 07:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13238812 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 BB033C77B7C for ; Fri, 12 May 2023 07:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240340AbjELHxO (ORCPT ); Fri, 12 May 2023 03:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240310AbjELHxG (ORCPT ); Fri, 12 May 2023 03:53:06 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 246A8E738; Fri, 12 May 2023 00:52:49 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f14468ef54so10960535e87.0; Fri, 12 May 2023 00:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683877967; x=1686469967; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=SfrfdrSrNKE90eE0l8Rc2KZKqXQ3Sz7SANrwHCEDoDk=; b=LLWpebN/XjBOI9ynbOxwWnrY5MbIAfDg8r4idfu1bpYIou99BvDMPBsqv0048lv0m3 dSzG/f9J4FEIZUkNvWjGNilQO0iNdjaBvb9MASr99Wi90drA4oHzrYTM6IV2e8hdChhY qlj0XHTKrl/meTCzfRpNF0/8ADjDPgVZ92wyECkvkVvIabbshHmjucUB+k8uVFU96AZl us2f31b29ug/Bkcc3Xpml2SG8aNUNOpbUOeP96EoOiG9UND30VW+CFz7Uaqi5GmUpbSQ uhfuVRJt+oSbDMlD+z1LIamYDeIyTdu7z83eWEojxDo6nLP4CxgJ27GaFxElNOHRuBfQ Mczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683877967; x=1686469967; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SfrfdrSrNKE90eE0l8Rc2KZKqXQ3Sz7SANrwHCEDoDk=; b=S0JKQKPCRHW+gwgJpxFbN1YGsBwc5lIK2XT54Ej+g1oFhyk+REyiRn3FHKlbGHYT6k 84G7GWTFMSnUD6c/ghSRGBRAEGZqoqAFxZ0Gk2brOoHnR9zQLM9asvdkucWWipFd/Plt Red4WE3krtHb/3y0CF/G3Uvj3B7mFtrMAvsHDf4yg+gonGfJaDP8hkyG74IwUoPN9FXr 4s01DIBO2p2JtO1YAU9sygHWjG1SSd6k5EO9zB8Ij8ChlkEDITrWfwV6cCli+dpT1LM+ 5/a0VNuE0v9VQxXWu01p3WQaWcmO6Ay47G72UUl2M8TVzoSOKbIk2zOe3xRaxxHXdBAK g0+Q== X-Gm-Message-State: AC+VfDy7W0ROoMs3lDqdClof1vqhARYO02eM1Ups4+y2CnlTDTXY3bt9 ujVOG062BA+7DoqMgJN4aQo= X-Google-Smtp-Source: ACHHUZ4SQ1I2y3NrGxAklPxOegaQJ1TbG1EqTdvzK9IxvpJVYxGfm+D0mXFnSpAEvl1zqKXZ4Ub/TA== X-Received: by 2002:ac2:50d3:0:b0:4f1:4a1a:ded7 with SMTP id h19-20020ac250d3000000b004f14a1aded7mr3778979lfm.37.1683877966823; Fri, 12 May 2023 00:52:46 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id e24-20020ac25478000000b004f25df23cddsm1104988lfn.170.2023.05.12.00.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 00:52:46 -0700 (PDT) Date: Fri, 12 May 2023 10:52:38 +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 0/3] fix fwnode_irq_get_byname() returnvalue Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The fix fwnode_irq_get_byname() may have returned zero if mapping the IRQ fails. This contradicts the documentation. Furthermore, returning zero or errno on error is unepected and can easily lead to problems like: int probe(foo) { ... ret = fwnode_irq_get_byname(...); if (ret < 0) return ret; ... } or int probe(foo) { ... ret = fwnode_irq_get_byname(...); if (ret <= 0) return ret; ... } which are both likely to be wrong. First treats zero as successful call and misses the IRQ mapping failure. Second returns zero from probe even though it detects the IRQ mapping failure correvtly. Here we change the fwnode_irq_get_byname() to always return a negative errno upon failure. I have also audited following callers (v6.4-rc1): drivers/i2c/i2c-smbus.c drivers/iio/accel/adxl355_core.c drivers/iio/accel/kionix-kx022a.c drivers/iio/adc/ad4130.c drivers/iio/adc/max11410.c drivers/iio/addac/ad74115.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 and it seems to me these calls will be Ok after the change. The i2c-smbus.c and kionix-kx022a.c will gain a functional change (bugfix?) as after this patch the probe will return -EINVAL should the IRQ mapping fail. The series will also adjust the return value check for zero to be omitted. --- Matti Vaittinen (3): drivers: fwnode: fix fwnode_irq_get_byname() i2c: i2c-smbus: fwnode_irq_get_byname() return value fix iio: kx022a fix irq getting drivers/base/property.c | 9 +++++++-- drivers/i2c/i2c-smbus.c | 2 +- drivers/iio/accel/kionix-kx022a.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) base-commit: ac9a78681b921877518763ba0e89202254349d1b