Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1157296imu; Wed, 16 Jan 2019 13:49:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN4YxgjVagACMOV5UWYEYeRsHRLeZVAnNkbL3MOPqnatdQMG5snMRJb0smG04tDjcyZCqfYZ X-Received: by 2002:a62:444b:: with SMTP id r72mr12215690pfa.184.1547675391051; Wed, 16 Jan 2019 13:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547675391; cv=none; d=google.com; s=arc-20160816; b=fL68/ogC+tBMXxUyLc87+lWa8zzNwATV0UwjoJdCe+rZgkiIOvdMbMFiyS16At4u6+ kNo2p0UJH0tc4DG3qBHIqhSQYfPGIWjhe0J1jQfCcxt5XDmkd9Qh1vEzM332KZid/LD7 ePk2i/LvM65vvvdjddEiwbYENGWCJHri7skzosmeJbidBSvdCibXzntPyG5fA1E9zBba 0ro1+OBF0tIT8e6m3/U9TX9hRhYAWymtqN9TJeUfmCqJx4MGUbM91Z0cuU1OiEsONB+5 qId3XbacN9m9MZHNrXtMwLqA/5ZxenNjSFGoK0Clbo3nwLo5VHdpdSsIH88KY/6KWdQg q/rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=6VvQAx+2FuRgBDmJPz2pSYJPMiWmuPQAP0p6EsjN5uQ=; b=e8Wi3fJE9WZEQP6u3ePc4JNttKihp5mhoZPh+Oqrc0EgZVVZmdzC/d3R+7bTQWikqv KrComJGm5o2z6cDJ6hLLAAdr7WK8W1mu8OacjbMjzdQTgmtaTtdvWBo34T0hQaIyrNpW WZraV6srJT44squyiwsEXw9hlWX/f3O53WjL0TdAXMq8eHsb7PkBmio/9CiLL87AKLXs YtZzMrl6+m+KVsyI2tTbbpzGv2lKWOYG8b6IKR10Hw/TmGaJY5YhPdiH29+UamdSFUrI AbwtZJxpzmNUIWjWq6QKDN2mF4z2QZAc1XihrLEDCP1ONIn26ImPGSDn6v9Pa3+J4jFu rsjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si4707452pfl.45.2019.01.16.13.49.35; Wed, 16 Jan 2019 13:49:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390292AbfAPNKa (ORCPT + 99 others); Wed, 16 Jan 2019 08:10:30 -0500 Received: from mga05.intel.com ([192.55.52.43]:44856 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390143AbfAPNKa (ORCPT ); Wed, 16 Jan 2019 08:10:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 05:10:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,486,1539673200"; d="scan'208";a="126489253" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2019 05:10:27 -0800 From: Ramalingam C To: intel-gfx-trybot@lists.freedesktop.org Cc: Ramalingam C , Greg Kroah-Hartman , Kate Stewart , Thomas Gleixner , Philippe Ombredanne , linux-kernel@vger.kernel.org Subject: [PATCH v10 03/40] component: alloc component_match without any comp to match Date: Wed, 16 Jan 2019 18:34:52 +0530 Message-Id: <1547643929-4679-3-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547643929-4679-1-git-send-email-ramalingam.c@intel.com> References: <1547643929-4679-1-git-send-email-ramalingam.c@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If all the components associated to a component master is not added to the component framework due to the HW capability or Kconfig selection, component_match will be NULL at component_master_add_with_match(). To avoid this, component_match_alloc() is added to the framework, to allcoate the struct component_match with zero associated components. Hence component master can be added with a component_match with zero associated components. This helps the component master bind call to get triggered, even if no component is registered for that particular master. This is meant for big PCI device drivers where small/optional features are external components, and based on usecases different combination of components are build as entire driver. In such PCI device driver Load, if we use the component master for waiting for few components(features) availability, only if they are supported by the underlying HW, then we need to allocate memory for component_match using the API introduced in this change before the call to component_master_add_with_match. Signed-off-by: Ramalingam C Suggested-by: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Kate Stewart Cc: Thomas Gleixner Cc: Philippe Ombredanne Cc: linux-kernel@vger.kernel.org Reviewed-by: Daniel Vetter Acked-by: Greg Kroah-Hartman --- drivers/base/component.c | 30 ++++++++++++++++++++++++++++++ include/linux/component.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/component.c b/drivers/base/component.c index ddcea8739c12..1b8bb07c0ec7 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -302,6 +302,36 @@ static int component_match_realloc(struct device *dev, } /* + * Allocate the match without any component_match_array elements. + * + * This function is useful when the component master might end up + * registering itself without any matching components. + */ +void component_match_alloc(struct device *master, + struct component_match **matchptr) +{ + struct component_match *match = *matchptr; + + if (IS_ERR(match)) + return; + + if (match) + return; + + match = devres_alloc(devm_component_match_release, + sizeof(*match), GFP_KERNEL); + if (!match) { + *matchptr = ERR_PTR(-ENOMEM); + return; + } + + devres_add(master, match); + + *matchptr = match; +} +EXPORT_SYMBOL(component_match_alloc); + +/* * Add a component to be matched, with a release function. * * The match array is first created or extended if necessary. diff --git a/include/linux/component.h b/include/linux/component.h index e71fbbbc74e2..3f6b420a58f8 100644 --- a/include/linux/component.h +++ b/include/linux/component.h @@ -37,6 +37,8 @@ void component_match_add_release(struct device *master, struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_alloc(struct device *master, + struct component_match **matchptr); static inline void component_match_add(struct device *master, struct component_match **matchptr, -- 2.7.4