From patchwork Tue Feb 6 12:12:59 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: 20008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1545532dyb; Tue, 6 Feb 2024 05:45:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+FYrWK1tyDpq4wj8r6MK+yPcBm1hUx1L5mNPnmuqjJFEUYQW71kKkO/S5x3+v8ATe16r+ X-Received: by 2002:a05:620a:1a25:b0:785:8f91:d441 with SMTP id bk37-20020a05620a1a2500b007858f91d441mr1491610qkb.60.1707227108367; Tue, 06 Feb 2024 05:45:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707227108; cv=pass; d=google.com; s=arc-20160816; b=ps3pBzaw6qrSCdNpxZJ9opEvjVZrhQkvdXhiDaAhAaYlkQW7W17c2rIZX53aYS/u3m GbMIYX26ioE/m0jCjs5/F72YI+f30AtQ9vFqHn21ydSjg+iZBt6fquEcO/uRsfCzkNBU JVHHoXnAtkJsBbsRmRjEVxXZii4lWIwGAEImh53stIP39ieWmzEz6pV+st70s2d01H03 jIt0VX5/r+30ljbC1oGpHPAX6lgxvGToZRzjjlFA57Wciw7GXfhlXNl366/+s3bGnZp9 s5DST2AoA60GgH4P7IMx+SERpqgJJB78p2FBacqP6RHDxsu/yC/TGz9Vs8WNb2nc5/oD V0eA== 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=nGZf/CV7MFDfSp45gBISmBXmS+7WMH2mB4ayReectKk=; fh=18ZPGJtjg3820EMYGCAmZtycDXUjX1nbFVGASns+By8=; b=w3JEWcVWEt1aciuGxIy5k7WxKfJJip+qQzI94rkJlTA4e4PIZNX5jLf7XzSCcMa0vY kUYxyNbERTW65LNP1tUTKvlAjNl0ICzgRSUFHRrWejO2GGR6dbD8P/6gFIA4XsEhBRpr o7OEgfc8pxRk7Yvm5afwWc191wCg72BbVBTio1CzsNxyfYaJsabYP16/PcPQ4S+S0eWD g6ZCRXYh6oKZr57TDlDTk/nHUFjbLpPQyXZevnEy47BqOkv9tiit34iS36qW7kjkIAKE tAIe7K4K8GMetFQjowDkgoJpsl7O6Px2a6jOSh7aHQcClNzEkfwJlyJeyg0lJZceedzi opqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UWwnsyTA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-54934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54934-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVK8sf0csZUOkiLZsTc6UzdzhHTFG6ElsCYFL8ISVqZWy+ifaxNGH8yZYuwXtnTNEU8U2NGgn/0v535w73z6SYX4ffoVQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x22-20020ae9f816000000b0078564385ca1si2239782qkh.727.2024.02.06.05.45.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UWwnsyTA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-54934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54934-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 845221C24583 for ; Tue, 6 Feb 2024 12:29:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FFA812F5B7; Tue, 6 Feb 2024 12:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UWwnsyTA" 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 39F1E12EBE6; Tue, 6 Feb 2024 12:13:10 +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=1707221593; cv=none; b=sBqABxEq5H+Z5FhZd7PmkYrBF9jBo0IeHaBnjF9KfC1LLJOgn9E+BBC+f/8YZ5SCYE19OvSXpIkyJFZ8SS1kycDo3XkO8tK6oYrzmLlskAnAR7eRraUcGKvBihh0ZQhBUt4T5VVM1ILB1iC/HNikXGfIvyrzJB+4u9EXwTZyMlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707221593; c=relaxed/simple; bh=HNOUf291pv9yr5OMqopIb665gLes2bjCx3QC88n6zX0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iQ84sbdclqGeBnB/0YSAeetAfDAmgnrcCvgl36Ui+BG6GSY3A9cMv2akHnsgnTImuYp/qVW60ZSCFuIV2LHjmbtiEOBSA0G4rAztX/foRpQo8Hpmxy3wNbpH6lctEcjJ/5q5Xf0v4kXJ84WN/D0t9/Y5dS9gRJaicflqtnpgxEI= 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=UWwnsyTA; 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=1707221592; x=1738757592; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HNOUf291pv9yr5OMqopIb665gLes2bjCx3QC88n6zX0=; b=UWwnsyTA4H3s0cGTt7zg5QiGi1RVwQEijX8lPEC++dJpUtXDd2UEpWDx 9BgdS4RyRwSvsqmOPteOd1JDBF/koeYQKR0KjdS9z/WX2Lj8N2Y8Z3K5r 3kYgNl7VjiD3gD+pwdjk0D7rSKj7ADZhMHt58S6uDwSu7HnNJqOF7B7O3 KMtdR6f6KIIOdZNaLBpMldhcDZ2OY7lTNgjRQyyIQEP3JLIng3S7qI1uh iy8jRPbIwwH/NSvP27At0/QrOQzVGjGuuOb2jQomjjq/TPCutoOx3pHSU KK8fGJvF/VgxrdfO6lfCe5i2TQef9SQoB+HM1LlKwDWfkmY4PXp4fRHEZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="998413" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="998413" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 04:13:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="24247456" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.2.175]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 04:13:06 -0800 From: "Fabio M. De Francesco" To: Peter Zijlstra , Dan Williams , linux-kernel@vger.kernel.org Cc: linux-cxl@vger.kernel.org, Dave Jiang , Jonathan Cameron , Ingo Molnar , "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH 0/2 v3] Add cond_guard() to conditional guards Date: Tue, 6 Feb 2024 13:12:59 +0100 Message-ID: <20240206121301.7225-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: 1790157372372657936 X-GMAIL-MSGID: 1790157372372657936 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: Dave Jiang Cc: Jonathan Cameron Cc: Peter Zijlstra 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 a statement or statement-expression as its second argument to conform to Dan's 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). Changes from v2: Changed macro's implementation to add an 'else' to protect against it being used incorrectly within another if() block. Suggested by Dan (thanks). The Reviewed-by tags on 1/2 are not forwarded because the implementation of cond_guard() has changed. Removed a redundant 'else' from show_targetN() in 2/2. 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 | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-)