Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2248615pxm; Fri, 4 Mar 2022 12:17:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+GS9fK/N11uK7k1FuL/D5gI9psabohg4sxc1WAQ+maCXxqg0Yrd04+F6M9Lp+BqpN2jEu X-Received: by 2002:a17:902:6943:b0:149:7087:9904 with SMTP id k3-20020a170902694300b0014970879904mr77017plt.126.1646425044957; Fri, 04 Mar 2022 12:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646425044; cv=none; d=google.com; s=arc-20160816; b=hWUAsuJbm+94+ClUs/GAq6RFv+N5hw/PBYQZ7fh4GzT4QnW6GHvL3LOfXOIJuhhBPJ u597udRWDqsSyIqUoJIKG92bLN7eqdj1gJh8PIfdI73F2T2qDNrywCLQmMXB3N+l3I+S wev5wXSJoREehtCU1NHXWqGErM1MWyqRxhBApHnfZWrmNmbeqqdM+ICljJzfNO+R6Xk/ iAHzDLtOcF2+Z7GqjjLmCbuem2OZLE5gP6JhKXjx459SEE384CXdaWQTRpIo4DFyQ5rB gbekclr3gr2t5Re3orFfsPlKO2S4ymngkQJaSZqVprq89NXuNSXs6k2fNs0n5/GNxCOi J2kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=paPQdF4YyhAwTF7odO6fEdspUmW0vrJO09uFgKkqbBg=; b=aMpmU40gg6kjEkLyCus3N5oKS41e3H69EwmGw+1seRQOfmOpFgffqG+YvPBzkROAGU 3phjHOdgcweXOr8SUqPaC4tSE7LTrCw6ELojECh8j201CzIgmsyjMDJ1oz587CNIXzIW OPXZAk5TOXbEzMP+UKo3D4YOPA+83Jx3QFQG4N6ReCIqvJoqhiZ6KpzQ8d280bZJWfZk jlYGy55f80r9gxK54cfF3mDpV24OMoVhus7154sDc7jcodm7xp+f7KiS5eiGCQgIDudV eDeicauDSZAgfL/l5KNvjHK+NdCqHYngpnko/z1RnNzpqOXF7WN54kayyd8bHjcJv3+g 6xLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XGXabIPx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d12-20020a170903230c00b00151b8e02a29si3035947plh.22.2022.03.04.12.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:17:24 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XGXabIPx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7CB9D1F83C1; Fri, 4 Mar 2022 11:29:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234727AbiCDM42 (ORCPT + 99 others); Fri, 4 Mar 2022 07:56:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbiCDM40 (ORCPT ); Fri, 4 Mar 2022 07:56:26 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD9AE98D4; Fri, 4 Mar 2022 04:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646398539; x=1677934539; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=u8WLhOYgoR4+MkVoQ/8tm2u28hBvyv0voWHkunaJIQI=; b=XGXabIPxyMTmMaXy7AQfiY2a+/T5T341edp9TDMTs52e1VPGpqn51Zee ql/asXaSMBYGWAelxfdz+TZTaZ3ASrINCAhFALWm+mQosB6g7Szl8+LxR XfdQxEEVUCIFzJuBpxq00pt0Sak8EgrQ6segFFqx3LRw5zkXPA1ZNAach W+YE9k61Pucvif/W6vi8xyg8OMo8k7crUxyKnAKdUU1XIa7vFnVuMWg6h wtWxEQyHRqhqTaRakx5EFaJ4iFUrtoQAWpV0bAIDhBjbTH6KxL4BoFGt3 bmQTkuk/zoua31bU2f+WVqx2lQeYmdYqgq4/xXL+SceRI5H9oXGgyfbRG A==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="317197907" X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="317197907" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 04:55:39 -0800 X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="511842295" Received: from smile.fi.intel.com ([10.237.72.59]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 04:55:35 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nQ7SL-00BDxn-Ji; Fri, 04 Mar 2022 14:54:49 +0200 Date: Fri, 4 Mar 2022 14:54:49 +0200 From: Andy Shevchenko To: Bjorn Andersson Cc: Rob Herring , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Hans de Goede , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: Re: [PATCH v3 2/6] device property: Use multi-connection matchers for single case Message-ID: References: <20220303223351.141238-1-bjorn.andersson@linaro.org> <20220303223351.141238-2-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220303223351.141238-2-bjorn.andersson@linaro.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu, Mar 03, 2022 at 02:33:47PM -0800, Bjorn Andersson wrote: > 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. Reviewed-by: Andy Shevchenko > 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 > -- With Best Regards, Andy Shevchenko