Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp928252pxb; Mon, 25 Oct 2021 22:43:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDuzG1Y0sYCutY5T5XaWclEv8vh+HVTNJvVO4iNbjNOx8HlgE6VPYCy46SbXXWrGzECvrM X-Received: by 2002:a63:7b42:: with SMTP id k2mr12133307pgn.268.1635226979762; Mon, 25 Oct 2021 22:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635226979; cv=none; d=google.com; s=arc-20160816; b=B1eIDUthdVKc8x5gThFu9baG9TLV4b71rOyDId+fpDmrfE4znOFXpQiTFJZaOXs1lT R3dNqRpkpKSE/iTCOjFzS0QAGxPaKtglsxt/A4JkoYlo3k/310yBVl8hv1OgAGsCp2OW OIrotYOJLcdOwUTjAtGMNlw/h2dFc2Q+jFzuka11pe0z1jXbLMYhFOSgCMywDGoJUY5/ Lm/8yZ9khVInxdiZano2iFinBUuZud3nkjLs2MUDLmjAZKvpOdFtu4yPv3c7rWsQOGDQ wILl3x2cx1/cqI2dwLQvhS8qzkQN3qtMzFP5xDmpW1ss8Zxm0um1zTDm8sYDEF/kxzW3 5Bvw== 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=nyCvsKt5+Vg32VhSvS6UqrlYOzSvHpna9uhIikJbGlY=; b=mwBG8IltaT0gWJz5+LEx83p0vi1h6Xgv/PgMtFbCCUQfv8hU6XGXOkN8eiUYEolUnD 9PoM4QZK7iirtJQY0sqT0lnlSyss5QfoS0M2TgSzHAbxyrm8UUu5Wzf/dz+J8G56sOCQ DMW5kZY/fl3Yt4CRguFgUKpbc4FmxDNtbQtkey+SgNlFi55kfBzgy5W4I0HQedyPboOU K7sd2HHI6X3xP+Bu/XHhAhOHsKR5LopUveRrYDByjWmFl8pNY7LjZlnJKPKG0x0jEfUI IZyyXLTa07H+7+HDJkFzGCewcJDhhL0G5moEWddgk6BAo8BqS3SVWNRbJgSp5N1wn/OU NVmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="ELI/xc9t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si23432093pfl.40.2021.10.25.22.42.47; Mon, 25 Oct 2021 22:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="ELI/xc9t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235793AbhJZADg (ORCPT + 99 others); Mon, 25 Oct 2021 20:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235536AbhJZADR (ORCPT ); Mon, 25 Oct 2021 20:03:17 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800C1C061228 for ; Mon, 25 Oct 2021 17:00:51 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id e65so12287871pgc.5 for ; Mon, 25 Oct 2021 17:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nyCvsKt5+Vg32VhSvS6UqrlYOzSvHpna9uhIikJbGlY=; b=ELI/xc9tsfUf5fr+ncUE1iTWXYgL9wN1B/iAw0x8RTP+cUC6wIoHOVfIaIFGEXaSZb +kL2JmE3M315dNsVvJDrzLpV5w5TJbA2xxHQpsgJFQxq+s3VEh6nJuh/RKu05HSOBjgm RFnkiS7RdhrqKvrmNed4oXt8kVMItRLUtv9WI= 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=nyCvsKt5+Vg32VhSvS6UqrlYOzSvHpna9uhIikJbGlY=; b=Kww2AIw+ihju++D3gZ8IsKLZsR3Mg5wwMSybv2N0QayyGvurBHs+ds1kU/2CPWJOch 780189w1gFLKMHWZNO+s5r0q9dC8tja6zILx/sIto58239u4FudeoUSIX7PQJdHdPysr SfVprUzJL008kUGo4+nLcRyYKEBjUfNOf39atoMeLoUh2qybZ0OnsmyPmUjJqzkP11Ff rM9k/rgOfUPyv0jO3xCr8SrGN3g4C6sVqoymQWsacz7lqMY5cCahiUyBXubO2S0tQNk+ txrJEgIjKRLe8eNS7CuXeiWnkBLgAsF1guNwcEgVugjI87c8eXHOAqDDzUY+FFVZKDMX ojQw== X-Gm-Message-State: AOAM533Dt1k1tmMd2P+c4HsRg5RP5yz7+XWDZYv8/RN90WtDbb8oOBxC vVXtcr/jxJopY9wDWWWV0wOS3Q== X-Received: by 2002:a63:6901:: with SMTP id e1mr16110874pgc.320.1635206451092; Mon, 25 Oct 2021 17:00:51 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:f5e3:5eb1:d5ee:6893]) by smtp.gmail.com with ESMTPSA id b7sm9900747pfm.28.2021.10.25.17.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 17:00:50 -0700 (PDT) From: Stephen Boyd To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Daniel Vetter , Daniel Vetter , Laurent Pinchart , "Rafael J. Wysocki" , Rob Clark , Russell King , Saravana Kannan Subject: [PATCH v3 05/34] component: Add {bind,unbind}_component() ops that take aggregate device Date: Mon, 25 Oct 2021 17:00:15 -0700 Message-Id: <20211026000044.885195-6-swboyd@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211026000044.885195-1-swboyd@chromium.org> References: <20211026000044.885195-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We'd like to get more device model features in the component framework so let's pass the struct aggregate_device pointer instead of the parent device pointer to the component binding functions. This will allow drivers to inspect and control things related to the aggregate device in case they need it, and they'll always be able to get back to the device they were using before by using the 'parent' member of the aggregate device struct. Suggested-by: Daniel Vetter Cc: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Laurent Pinchart Cc: "Rafael J. Wysocki" Cc: Rob Clark Cc: Russell King Cc: Saravana Kannan Signed-off-by: Stephen Boyd --- drivers/base/component.c | 14 +++++++++++--- include/linux/component.h | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/base/component.c b/drivers/base/component.c index 997b17053ecf..cbf2d4cc0794 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -699,8 +699,13 @@ static void component_unbind(struct component *component, { WARN_ON(!component->bound); - if (component->ops && component->ops->unbind) - component->ops->unbind(component->dev, adev->parent, data); + if (component->ops) { + if (component->ops->unbind) + component->ops->unbind(component->dev, adev->parent, data); + else if (component->ops->unbind_component) + component->ops->unbind_component(component->dev, adev, data); + } + component->bound = false; /* Release all resources claimed in the binding of this component */ @@ -765,7 +770,10 @@ static int component_bind(struct component *component, struct aggregate_device * dev_dbg(adev->parent, "binding %s (ops %ps)\n", dev_name(component->dev), component->ops); - ret = component->ops->bind(component->dev, adev->parent, data); + if (component->ops->bind_component) + ret = component->ops->bind_component(component->dev, adev, data); + else + ret = component->ops->bind(component->dev, adev->parent, data); if (!ret) { component->bound = true; diff --git a/include/linux/component.h b/include/linux/component.h index e99cf8e910f0..d8dcbf9733da 100644 --- a/include/linux/component.h +++ b/include/linux/component.h @@ -6,6 +6,7 @@ #include struct component_match; +struct aggregate_device; /** * struct component_ops - callbacks for component drivers @@ -19,18 +20,39 @@ struct component_ops { * * Called through component_bind_all() when the aggregate driver is * ready to bind the overall driver. + * + * Deprecated: Use bind_component() instead. */ int (*bind)(struct device *comp, struct device *master, void *master_data); + /** + * @bind_component: + * + * Called through component_bind_all() when the aggregate driver is + * ready to bind the overall driver. + */ + int (*bind_component)(struct device *comp, struct aggregate_device *adev, + void *aggregate_data); /** * @unbind: * * Called through component_unbind_all() when the aggregate driver is * ready to bind the overall driver, or when component_bind_all() fails * part-ways through and needs to unbind some already bound components. + * + * Deprecated: Use unbind_component() instead. */ void (*unbind)(struct device *comp, struct device *master, void *master_data); + /** + * @unbind_component: + * + * Called through component_unbind_all() when the aggregate driver is + * ready to unbind the overall driver, or when component_bind_all() fails + * part-ways through and needs to unbind some already bound components. + */ + int (*unbind_component)(struct device *comp, struct aggregate_device *adev, + void *aggregate_data); }; int component_add(struct device *, const struct component_ops *); -- https://chromeos.dev