Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1114280oof; Tue, 25 Sep 2018 08:26:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV63k/irfxCGUe90xc3xga3zrGyh3yFZmIVeNiyFWvtOIC5A76Oejh45JYB0xAJ9AYV1lz696 X-Received: by 2002:a17:902:7142:: with SMTP id u2-v6mr1805045plm.154.1537889171353; Tue, 25 Sep 2018 08:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889171; cv=none; d=google.com; s=arc-20160816; b=K+IcaxVeSXQKdcR8m0jsGFAPRB13dBVBaindwGQ8D/7xJD+4NX1Fl10q5QB4nyQJrW 5rv79sAev6pz/Mtv4cjTRp66NPGPQaD/Oz3tADDLVbntkY7SPYlF8NNpLcikDAVYJf+9 VTfwmgqh64lPH21zMvK2SuQCmtLRMAlz13kcnmpJRuMk3A5SaHt3BjxKQqCsU2csIdy9 JqT4OYmVPi22eUdB+6ZtL81Mkxxd0zmxRtHc4c9CudvEvTe/d/U4mSevHtOGwokomlzi coRUsUooekDUHrTR2Fm144gpH22dht/GOgeaFBfCmSLglknJp8mOZdKfiugcDqtDIZUZ SHzQ== 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=i1o+gE3ebWBEg4VZVr1VGIT0zKZ69c+aberJS02GGLA=; b=Y/UButQANqNlWxbZaZ2bzrAheKF6lupbtk/r//FJGp5jx+lT7i1v7t5QT3spNnQx85 aMxJ8IT5+mzCgKLCGpOzLb74SsS+a7FsT+ilSl+k3vNHtCNSiSn8Z+vIjQ8Mo46ulile PbAjonAchhLXrQd+EZFneoaUOvNhWUIbQXb4Avb08by6A1fWvwVjCifX2/ebanlKPmiN aE4vCOKW+dGCFFT9B7qAv+hfzVWwwOW2/BdtPpgY3WAmdhA8J+T31TjmnZ3QMxfHwooA rYuYV7VCkIDpCzRDdRQclGxhu3k0WhySnyAcXbDBO9lvV8WlGb5tdLZ0YrD7ECiD22QD Zndw== 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 i31-v6si2583256pgb.29.2018.09.25.08.25.55; Tue, 25 Sep 2018 08:26:11 -0700 (PDT) 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 S1729979AbeIYVb2 (ORCPT + 99 others); Tue, 25 Sep 2018 17:31:28 -0400 Received: from mga04.intel.com ([192.55.52.120]:46410 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729465AbeIYVb2 (ORCPT ); Tue, 25 Sep 2018 17:31:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2018 08:23:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,302,1534834800"; d="scan'208";a="260120271" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga005.jf.intel.com with ESMTP; 25 Sep 2018 08:23:21 -0700 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 v7 06/39] component: alloc component_match without any comp to match Date: Tue, 25 Sep 2018 20:50:29 +0530 Message-Id: <1537888862-31081-7-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537888862-31081-1-git-send-email-ramalingam.c@intel.com> References: <1537888862-31081-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. v2: No Change. 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 --- 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 8946dfee4768..007fb738263a 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -312,6 +312,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