From patchwork Wed Apr 10 20:21:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787541 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83593181B9F; Wed, 10 Apr 2024 20:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712780573; cv=none; b=H4OjbGD3SONcZlxEZlbx2MgjtWTj+i3O0guVW8qyS0bwvEsNYnrq4r2xyfPPhY7EoB4XYrN0uLll1wTaO6w5MjWrlTE2LEhwPq6+nSKrlqpmiZoDmMyrneOoruMGZ1aQnSvMFE4CLeg+mGsL4OtEAnbk4sn4UqTeWpYt7d6DwMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712780573; c=relaxed/simple; bh=+2HZiSpbT1DVyz7ooUfdwbZ8UU3WoCwyFIEyBe958GA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XA3WMHycOdxeex85SyeH843xWulnCjve6DX+vG/P9Lx+xhjcjMJwYOcJOwM8d0XosQBI0u7RBKxnhVtD+nqNxn+dtu0TyXXMEUQoXlosJhKW9gfQlmN2j+mdBMXmNzGGEmvjRdB1hAJGeHTGzc2Fn/3fdF2oBjcYHQkmuTUP+NY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZCfujnxG; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZCfujnxG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712780572; x=1744316572; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+2HZiSpbT1DVyz7ooUfdwbZ8UU3WoCwyFIEyBe958GA=; b=ZCfujnxGzGWChA0Y5gn1wQyt5f2DFfsJSugi21PgmnPf+CGG9TR8hvAf mpBt2Lf/I5D616uSqmb+DCMRyBhVN7c8b8d/ivHaQrFo4mAiUp10UYJPx IbXC3ERvpJM0/FJ7s3sBGAoErakiPWe4zyOFu8kFcsqaZx0MO6zFLEkX6 40v6sZ+YVQ9mXIJhgO9OFiAegJeUcSUJQJG3GX4GF+MVE32H8dfPxggwr YMgkltadyjfd0MvFAg2Qcj1m+XhovhRu2hJaJeuQ5BLTxynNei981ZOxF srEXpmpYJDV3VhjxFvmFhGUxD6Kl2+fRXzHms7tn7D1/NYnBrRCCZlwAX w==; X-CSE-ConnectionGUID: WLf2weKlRP6MDlkwmbPmJg== X-CSE-MsgGUID: CkU6Te4tQdCYvDA/0+nn7w== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11960669" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="11960669" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 13:22:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937095429" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="937095429" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2024 13:22:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 14B151A6; Wed, 10 Apr 2024 23:22:45 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Subject: [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index() Date: Wed, 10 Apr 2024 23:21:46 +0300 Message-ID: <20240410202243.1658129-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240410202243.1658129-1-andriy.shevchenko@linux.intel.com> References: <20240410202243.1658129-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The acpi_get_gpiod_by_index() never is called with adev being NULL. Remove the redundant check. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 7f140df40f35..f596edf89451 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -873,9 +873,6 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, struct acpi_gpio_lookup lookup; int ret; - if (!adev) - return ERR_PTR(-ENODEV); - memset(&lookup, 0, sizeof(lookup)); lookup.index = index; From patchwork Wed Apr 10 20:21:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 788842 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CABF6181BAD; Wed, 10 Apr 2024 20:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712780573; cv=none; b=VZ0fw6eNdIESWpBwyuQQw41KQNykeV7obpXKuPj01p5xtFu3FARFI4ihY7Rk8Kir7G5SiI9wsfInDddnxR5yu3SARaUaGWP5troH3Qv+a8sYd668HI6fUtAES0xCvee5Jx7riglnkX0UKYgyGfgiY/CKT9FWnSUt5pUSQbBhQjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712780573; c=relaxed/simple; bh=5H0HF8xD//yLE+aRbR8R8jTk44h5XWBp8jiK/ynSaT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SbNORUwzfcRgdgCbniCAaWPKcOqKY/otkFnG0kyQ/pDZmUeEFla9qeLif+L7sLzyxif6eE4AOVDqNmYaq8ee/6WZ/GMkG4E6EMRjH1dfeo6QB6LGihH9ABQc1y2hB1NRdoS1ghwmsh1UVgzNJeb2FxRrEYCqArOgBMcthMJeZvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=h1AVp7hr; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="h1AVp7hr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712780572; x=1744316572; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5H0HF8xD//yLE+aRbR8R8jTk44h5XWBp8jiK/ynSaT8=; b=h1AVp7hrWpCO9ZrFfCoBRHj95rn3JuUYdHs3E5hYLtxMIyN9ikE8LxdU FjQpDz0ANoBHVfdnauaeDm7GyeayzA1ma6VnfOjPTDkm3csN/XTYxQcnV aWrsPySG56+oJncijRAEhOEKNhH3VbMyMXAUPwsxFKysBkkSUqtuZCca1 mDwvMVBmpCEw7mlRSp3Iw1nJyg06Pr1BxUo2wyog8sdgofoS2GK71mq4i Q8ken+pLSHEPU0Ck4k7mbm07VXzCKXElYjqvBwMHXyjlPVAKYixbyiusZ QfmZ2Pw6lzhbZ1VgTI6lqMrHZ5GISK40+PN/2EiCX6SQBp+s5O5pv9k1J w==; X-CSE-ConnectionGUID: Qb6f3wWpSrOQC+Zbw7Z0+Q== X-CSE-MsgGUID: 1AqBlvBIQdudGxJiXbDpAQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11960678" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="11960678" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 13:22:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937095430" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="937095430" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2024 13:22:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1DEA32E9; Wed, 10 Apr 2024 23:22:45 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Subject: [PATCH v1 2/2] gpiolib: acpi: Check for errors first in acpi_find_gpio() Date: Wed, 10 Apr 2024 23:21:47 +0300 Message-ID: <20240410202243.1658129-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240410202243.1658129-1-andriy.shevchenko@linux.intel.com> References: <20240410202243.1658129-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's better to parse the code when the usual pattern is being used, i.e. checking for error condition first. There is no functional or code generation change (tested in LLVM). Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index f596edf89451..c2a33beeec50 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -973,10 +973,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, else desc = acpi_get_gpiod_from_data(fwnode, propname, idx, &info); - if (!IS_ERR(desc)) - break; if (PTR_ERR(desc) == -EPROBE_DEFER) return ERR_CAST(desc); + + if (!IS_ERR(desc)) + break; } /* Then from plain _CRS GPIOs */