From patchwork Tue Feb 18 22:59:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 13981049 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0337C28629C for ; Tue, 18 Feb 2025 23:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739919680; cv=none; b=KyTU/+S1l7RdMb9S4u0zSaowas3N1PlQmD7b3DoXOx6KnsadhFY38lChdUhEHj11+wl8GQ36kR05uA6CocjiuISEprWHO6/7bwXllzkZOMnKnBvMd4mvJUqpTnsi+F8RqPu6IPDAOUwYJCl+u7lyHhZPGMlp7CHG4HSOtWoy2m0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739919680; c=relaxed/simple; bh=RlgXTx99TLMTe9dpY8FdJqkEG3sILk446QrE192dGH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sgPKnw24CNBmVgtZCljbb7KNJ9KModdsUzhEof2PJ+mHe0fVcGwDTog5s9R0mbfSGk1sLuamy04sqt7ha+8yU/N/vSiT3N9dMXtkS5TOHL8GF4xZYMkVbPJx2dSpamJ76igldTGMjiGEESL5SmH5F01dkcYoBxkxpqvuoAscC6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE62EC4CEE2; Tue, 18 Feb 2025 23:01:19 +0000 (UTC) From: Dave Jiang To: linux-cxl@vger.kernel.org Cc: alison.schofield@intel.com Subject: [NDCTL PATCH v4 1/3] cxl: Add cxl_bus_get_by_provider() Date: Tue, 18 Feb 2025 15:59:54 -0700 Message-ID: <20250218230116.2689627-2-dave.jiang@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250218230116.2689627-1-dave.jiang@intel.com> References: <20250218230116.2689627-1-dave.jiang@intel.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add helper function cxl_bus_get_by_provider() in order to support unit test that will utilize the API call. Signed-off-by: Dave Jiang --- cxl/lib/libcxl.c | 11 +++++++++++ cxl/lib/libcxl.sym | 5 +++++ cxl/libcxl.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index 63aa4ef3acdc..bab7343e8a4a 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -3358,6 +3358,17 @@ CXL_EXPORT struct cxl_ctx *cxl_bus_get_ctx(struct cxl_bus *bus) return cxl_port_get_ctx(&bus->port); } +CXL_EXPORT struct cxl_bus *cxl_bus_get_by_provider(struct cxl_ctx *ctx, + const char *provider) +{ + struct cxl_bus *bus; + + cxl_bus_foreach(ctx, bus) + if (strcmp(provider, cxl_bus_get_provider(bus)) == 0) + return bus; + return NULL; +} + CXL_EXPORT void cxl_cmd_unref(struct cxl_cmd *cmd) { if (!cmd) diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym index 0c155a40ad47..1fc33cc6e1a4 100644 --- a/cxl/lib/libcxl.sym +++ b/cxl/lib/libcxl.sym @@ -288,3 +288,8 @@ global: cxl_memdev_trigger_poison_list; cxl_region_trigger_poison_list; } LIBCXL_7; + +LIBCXL_9 { +global: + cxl_bus_get_by_provider; +} LIBECXL_8; diff --git a/cxl/libcxl.h b/cxl/libcxl.h index 0a5fd0e13cc2..3b309968a808 100644 --- a/cxl/libcxl.h +++ b/cxl/libcxl.h @@ -122,6 +122,8 @@ int cxl_bus_get_id(struct cxl_bus *bus); struct cxl_port *cxl_bus_get_port(struct cxl_bus *bus); struct cxl_ctx *cxl_bus_get_ctx(struct cxl_bus *bus); int cxl_bus_disable_invalidate(struct cxl_bus *bus); +struct cxl_bus *cxl_bus_get_by_provider(struct cxl_ctx *ctx, + const char *provider); #define cxl_bus_foreach(ctx, bus) \ for (bus = cxl_bus_get_first(ctx); bus != NULL; \