From patchwork Mon Feb 5 14:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 19943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp959134dyb; Mon, 5 Feb 2024 07:45:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvu43lvtFS2h4jbwgzVibgY/JUFnocCM2if9cMSG8XRBYFc5ciTZHd2h+FyoaicKZZKe48 X-Received: by 2002:a05:6102:55a7:b0:46d:2500:b3f5 with SMTP id dc39-20020a05610255a700b0046d2500b3f5mr203171vsb.35.1707147937291; Mon, 05 Feb 2024 07:45:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707147937; cv=pass; d=google.com; s=arc-20160816; b=HKxZGaTJ7GmC+NUlCz6i0jJKUr65VcIjfVHIBtibIqNsJeJ62dvS6neBamwhfWMWjC 50FbdYGUSkCRUVOXp7ugI5hLGcoJnd58WzQ9KCdvkeqTBrEDmVeOECblIH4Qi9wrJDR0 c+zTFGqXGEBXIRL9fHyu1hoQ5zCtklarTMJ3FO1KzNkb4AC062/Imf5PnR9v9WmFgUpk qxbFNaIdmIx8Lte8f/v255ErSfn6yweFRT9Rx/WKS16VjZQBTeM3JirCRCt2eIWJSgAo 9hPpAa5g0TNnFU3W+ul9kJdeRXNjRk7iRkrgcgahalv0f83t94iF+z2UJ7/E0iF12nMW viGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=AT8jlIR0dzd1xuN7czNO3iZmyyrZeJQ9hntlwaN7KhI=; fh=tyrrOPlkyQWsrY9ZdJiiZlVuWxY6o1oyjbfWN9xMJ3k=; b=zjZCL2GSlHLvC6IB+0YTFezwH4WDyUdR4YZyNiSr+mXGNbKQS00HgLU3IHuZ6zJUy3 GitvqLLGrWVUedSHzspaOJwhKlPBaiGmD+a4aFgsII4u6+uD39ZHNHUi6it4r1TsADxJ VS80139D0f6BfbaVUxglLbdH202Tr+GHMpPg9nQXVR286SBTNDJk2/82RkTRa0cZL22p DGeXD7ivdihSja74GNWC5g0TbjRN83ECgpP4gTKLXloVB5M4ilNAtJ6bwWPdWueNITRQ wD8Km5nwV+rQ55ydsUAx2qUfiPqh4aQa04CYUtqotit0TF4MOIXkvi0sTXmNjxU5pUmh UsrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=imGe3DNB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-52815-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52815-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUha3ulCZx1PjIzoTh7FH4FFprYIF7z2aLshAfwXs377vMNSjzH5vCuZTtDTbNpSEhb02HSeC6DrGpOwiIIVK/1SMGFAw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s16-20020ad44390000000b006819bba47f5si147270qvr.459.2024.02.05.07.45.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:45:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52815-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=imGe3DNB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-52815-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52815-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CE9651C24606 for ; Mon, 5 Feb 2024 14:26:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB88B2C6A4; Mon, 5 Feb 2024 14:26:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="imGe3DNB" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 466ED28E09; Mon, 5 Feb 2024 14:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707143186; cv=none; b=pXZOkVLPb9uexGCfNlsJsHQf+snUL2Cj31rLfq9ibKNPOi28Y6AqZN6YRZFPEgX7qOfH46wEK53sQluGOMTUaSVSDDc0mdDQ7mOLQBkrrrdQ+4XDOG2Vf83dmZI6oLBABW0Miyf1xyB7xpkebOyvNpoqzuJ2xSyPH0g87yWxO1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707143186; c=relaxed/simple; bh=m0QLdI83zB+FnoE7IBS4lFE86qJhrmdQ15xApBEaRSc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=d0QwT7ZB8RJQrnj3TZO2WtOmSqCWobnMTF4U5Zlpecw+HM0YcDwsz0f7WpyapN4BGOWat7zKrqqnEZ+WwzeUYQtlnkkE7Ls167T7hFdNNiqZWgANu7N90y+St9R8o5XMdRQgKTj5xIqf2fEtVIQDCZkXYUVQnOxcWYwAMgVBRB4= 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=imGe3DNB; arc=none smtp.client-ip=192.198.163.16 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707143184; x=1738679184; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=m0QLdI83zB+FnoE7IBS4lFE86qJhrmdQ15xApBEaRSc=; b=imGe3DNBhkyOsBBqMdvRm8j092do6b4gsJ1k6e/GUNltcR9HXtQ3sqwN tO+jaJ5m9NdahRo+ZKhSnx/vtjFZqETu/P1vZWT+pgpAT6QSHdAF6pk79 oPH9ayyLHB3u/YVmJKxRttKk20kfMHREIjtpJL1faax00uB26XEmH9hSd e9adxcdVCMpz94SzG/amQLvj2eT/4qJeJeM5G9JiGp5/Xasz8S6nCH79s rF7vmbSNTV0OsozYxgezad+wH95zLr3GjSwf2vHaIj/1nYX9ddMn5D0Ki 78Mjm2jE8HkeiHaqvIa9t+fjZ3TMcP3Cve+4ZbRmY5t+Lf6IzB6mTIGHl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10974"; a="787661" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="787661" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 06:26:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="5473000" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.intel.com) ([10.213.21.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 06:26:20 -0800 From: "Fabio M. De Francesco" To: Peter Zijlstra , Dan Williams , linux-kernel@vger.kernel.org Cc: linux-cxl@vger.kernel.org, Ingo Molnar , Jonathan Cameron , "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH 0/2 v2] Add cond_guard() to conditional guards Date: Mon, 5 Feb 2024 15:26:11 +0100 Message-ID: <20240205142613.23914-1-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790074355021095527 X-GMAIL-MSGID: 1790074355021095527 Add cond_guard() macro to conditional guards and use it to replace an open-coded up_read() in show_targetN() and remove a block marked by an 'out' label. Cc: Peter Zijlstra Cc: Jonathan Cameron Suggested-by: Dan Williams Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- Changes from RFC v4: Changed the interface of cond_guard() to take a variable to store a return code, the succes code and failure code, to enable a later check of the returned code in that variable. Changes from RFC v5: Changed the interface of cond_guard() to take one or more statements in its second argument to conform to Dan's final suggestion (thanks). Changes from v1: Fixed a grammar error in the commit message of 1/2; replaced the name of the second argument of cond_guard() with '_fail' according to Jonathan's comments (thanks). Fabio M. De Francesco (2): cleanup: Add cond_guard() to conditional guards cxl/region: Use cond_guard() in show_targetN() drivers/cxl/core/region.c | 16 ++++------------ include/linux/cleanup.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-)