Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1454507pxm; Thu, 3 Mar 2022 18:42:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAbYiznkabxS5ss4HzwSO+LKhAAAAlc4I4a4SnR9kujkrnhqsGIMa8N29wVCKV9NkWh6Ns X-Received: by 2002:a17:907:7ea3:b0:6d9:4406:6029 with SMTP id qb35-20020a1709077ea300b006d944066029mr9917711ejc.262.1646361753695; Thu, 03 Mar 2022 18:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646361753; cv=none; d=google.com; s=arc-20160816; b=nDXcOUEdQa5uKbRb3O4Bgyjv0ZNWjQmSvdCZFPWfsfk0gL9O/7Nzh0jM347rAoudtk 22Ik1w48AwwfAIpgGufZHXSox0rnDmhO+V//HBmZojIY7OH8XKjACO98gbilYxmA/KMM jF2Imd6l+s75O+rO+bkioFTa4PMVhubeIU8phHS7TJYUpkMji5PM3McOuMOjCFGEuiDB 7K12x+OHa4s+LbPVby2YlMXlbkk9ngV+52j522zO3mTuJ7dTSTKhC2FTCsfenOa7UX9n OWtFWUs0f8UhlWzosYTKA9HgTpAIRYN1yd9hfqmxWgdOLx3LPjoGe5eSZiGfQ60b6uSt sgOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X9JV+NV8hUdIRYanc1M81YurPWGieX1bhPcntTov4JQ=; b=PO+diGl0nXifPT7rGjYrknGi6NLLVhRWckjzCdCPSSgw0DeO88mdlxBgVIGkJcP0CX +DrHx7OZwMq7fp8pQ9h4IirTEdQzFB6+D6doWtBOxi0MBqMK5ct3J7DSCuCwg1XXOgys qgJNvLQD/X7a2OA8myXo8Ozxa5HvzehaZAYtCLApvS7Qhice1ffOcsE9rvqQfLkUuupf Cbcm15k89arR4ozIwg3lyPpUb9YeO7Oz1d+waUhNMLVrFVezF1xqj7N+X4GBGCA5cIp/ KPuiwO/7xGY8I94szV58z2c70c/X/qfW08/BwLQevfFyHg9joCSI8n2+MhhaiW5GUgPl JfVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c1kUcex8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a17090658c900b006d70d54e6a1si3175582ejs.78.2022.03.03.18.42.11; Thu, 03 Mar 2022 18:42:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c1kUcex8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236927AbiCCWcw (ORCPT + 99 others); Thu, 3 Mar 2022 17:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236929AbiCCWct (ORCPT ); Thu, 3 Mar 2022 17:32:49 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2755B15042D for ; Thu, 3 Mar 2022 14:32:03 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 12so6167395oix.12 for ; Thu, 03 Mar 2022 14:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X9JV+NV8hUdIRYanc1M81YurPWGieX1bhPcntTov4JQ=; b=c1kUcex8F+vJCxoKxNHDMtjxEQfmTnbQbbD1n1WPDnHEF5FnFi6Q6xhiU0gtNrvDiI GJyfnMZNzfhDVGA5cPVtOifgfe31tg08XGCP2javdtE8eVgWj60JNpHOJv2WdlF5zLUa 9IwTDPSFZFE+SGnsy9+6To5tSpMrL1H1WigpRs7PSlvcrzOKA6XElrjabd2r7ZYAtsFC pipuhGugBLIaVg5bronMYFQFdLQtv58iTT6FmZt6V6mdCuA+QgxUfkeFzJvpsglW9RFG fJ4jvodZfR69AcC8iCiAvH0zUVoBvCkWxxJ1IlVBCRqrjIcL72jxaZf7gTDk6O03Rx/S iVqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X9JV+NV8hUdIRYanc1M81YurPWGieX1bhPcntTov4JQ=; b=a4JqtE86lPpvfzABp1Y1kAc/7RBWAbX7Qogo/O1W4VL47pipxaGtJeLgmzXHWuC7wC q+awrbz6YoGYIOT0JCphHDWMWXTF91E6/yWjuGYSGuIv6YHHlzfPhOn/GoAweyEHfzZF 1JklQIu78fbCFoU4rc4/r2UvhRT0FQyMyHBZMfIHX1aBNAlvfZN1Q2FnAuhFGk9RhTCD 0ctLLeW3eYU8A6nRIT197pPv8ZvcPY8gBdZV0e3OLykfIsVMllfA36aBUTt50p0qa7HS lsbQEUictj0v2DqZueLh+umFmR5jLhqWAkorURaklP8bj8xzu3QNhnJgLLz6uBs4eKc2 N9ow== X-Gm-Message-State: AOAM532V7BACSLaafQBj9Jh1FVCP1+HWLWvXcP0XY+hsARN8KVh91TG3 5ccj1jG9H8el5O14Op6IKWLWjg== X-Received: by 2002:a05:6808:2022:b0:2d4:752b:dfb5 with SMTP id q34-20020a056808202200b002d4752bdfb5mr6712133oiw.174.1646346722312; Thu, 03 Mar 2022 14:32:02 -0800 (PST) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id fq14-20020a0568710b0e00b000d4492531a2sm1764777oab.17.2022.03.03.14.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 14:32:01 -0800 (PST) From: Bjorn Andersson To: Rob Herring , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Hans de Goede Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: [PATCH v3 2/6] device property: Use multi-connection matchers for single case Date: Thu, 3 Mar 2022 14:33:47 -0800 Message-Id: <20220303223351.141238-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220303223351.141238-1-bjorn.andersson@linaro.org> References: <20220303223351.141238-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The newly introduced helpers for searching for matches in the case of multiple connections can be resused by the single-connection case, so do this to save some duplication. Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - None drivers/base/property.c | 55 ++++------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 5cda205136f6..81156dc97ad7 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1193,31 +1193,6 @@ const void *device_get_match_data(struct device *dev) } EXPORT_SYMBOL_GPL(device_get_match_data); -static void * -fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, - void *data, devcon_match_fn_t match) -{ - struct fwnode_handle *node; - struct fwnode_handle *ep; - void *ret; - - fwnode_graph_for_each_endpoint(fwnode, ep) { - node = fwnode_graph_get_remote_port_parent(ep); - if (!fwnode_device_is_available(node)) { - fwnode_handle_put(node); - continue; - } - - ret = match(node, con_id, data); - fwnode_handle_put(node); - if (ret) { - fwnode_handle_put(ep); - return ret; - } - } - return NULL; -} - static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, @@ -1252,28 +1227,6 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, return count; } -static void * -fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, - void *data, devcon_match_fn_t match) -{ - struct fwnode_handle *node; - void *ret; - int i; - - for (i = 0; ; i++) { - node = fwnode_find_reference(fwnode, con_id, i); - if (IS_ERR(node)) - break; - - ret = match(node, NULL, data); - fwnode_handle_put(node); - if (ret) - return ret; - } - - return NULL; -} - static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match, @@ -1320,16 +1273,18 @@ void *fwnode_connection_find_match(struct fwnode_handle *fwnode, const char *con_id, void *data, devcon_match_fn_t match) { + unsigned int count; void *ret; if (!fwnode || !match) return NULL; - ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); - if (ret) + count = fwnode_graph_devcon_matches(fwnode, con_id, data, match, &ret, 1); + if (count) return ret; - return fwnode_devcon_match(fwnode, con_id, data, match); + count = fwnode_devcon_matches(fwnode, con_id, data, match, &ret, 1); + return count ? ret : NULL; } EXPORT_SYMBOL_GPL(fwnode_connection_find_match); -- 2.33.1