Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1660370imm; Wed, 26 Sep 2018 23:58:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV60SKuh/fZjEu2vQF4aMq/eLu3d7+3V4js4wHLue8hpQU4BTGhoKlNXPujmLxAhech5iuprc X-Received: by 2002:a63:1c61:: with SMTP id c33-v6mr8742454pgm.109.1538031521544; Wed, 26 Sep 2018 23:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538031521; cv=none; d=google.com; s=arc-20160816; b=t9FNezgOEuhpX7di+j54m4/aFOPaJPTqugQTOpRbKgYpciorkH/ISMwCUyGb+uBmP4 tVYfCCcEERKus0g9MAP8CK169swEzHpguSSSblTluR1LqwidX1NZ+RPwGwewB0ZvMwqf Wv5OtW49UZm4VS6yVH7b+zOBlQYreLF1PweO0TLwZ7tFIT5W3KeXfzuRfzXm2f9dtyse i6eargIor4FNsbE7S+f0w9Pqlpxc4zMOEJz9XUROMiwBzjOgq2t8nLX6fD1awgR9eyMf 7D74ROGSybjG7PLidq0a2r2nm9i5IdDp8ZCvrKgFWuXhhV6Bzh0EcvzkeKsPTxIbJiPH 5E5w== 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=BKawGYQ9kyO6sbQZbgncWDETBuEoI0hLizZOe3K6Gui1h7DDQ2jQY+FbBrPY7asjiq kX9oja/nNjdupiqWkXtAth4RBXVFk666OZP4nwHJmGU3C20MSNtudSwH8hGIGZ8y0+ud GrNPyzaq669TIbgYnU6YSFDEouLMVgmDWqVN1NR+GlTMjFV9vPez9Wp8Rr12K05J/aI0 mBi2a5d9VtYUc3Uz2/Vq3aDXIZYSDZcYGEMnED4Xw6Phv4byUCIM3qODDgvlYEt8to/Q z93SlJtjIvhUeHoWgWNQuQ021MV2TMNmejLmIkhkbUOFHQLDOQle54cbYLRIXQbH4/5S Q2Yw== 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 l14-v6si1210024pgi.34.2018.09.26.23.58.25; Wed, 26 Sep 2018 23:58:41 -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 S1727233AbeI0NOr (ORCPT + 99 others); Thu, 27 Sep 2018 09:14:47 -0400 Received: from mga02.intel.com ([134.134.136.20]:29284 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbeI0NOr (ORCPT ); Thu, 27 Sep 2018 09:14:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 23:58:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,309,1534834800"; d="scan'208";a="95204686" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2018 23:57:59 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, tomas.winkler@intel.com Cc: uma.shankar@intel.com, shashank.sharma@intel.com, jani.nikula@linux.intel.com, 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: Thu, 27 Sep 2018 12:24:57 +0530 Message-Id: <1538031330-21040-7-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538031330-21040-1-git-send-email-ramalingam.c@intel.com> References: <1538031330-21040-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