From patchwork Thu Dec 2 22:27:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 519819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCEA4C433FE for ; Thu, 2 Dec 2021 22:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349396AbhLBWbF (ORCPT ); Thu, 2 Dec 2021 17:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349358AbhLBWbD (ORCPT ); Thu, 2 Dec 2021 17:31:03 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DF0C061758 for ; Thu, 2 Dec 2021 14:27:40 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id n26so967317pff.3 for ; Thu, 02 Dec 2021 14:27:40 -0800 (PST) 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=wHTGmIfG7F9SDIRewz7zNR4I/bW/soPNx1fVWL7SSqg=; b=TIhzbwW7xTHq27qJYHACDhp2KHurEns7No/8zr4oeHK5WpKcaX2tdKQG/2Sq6MTgMc u6JYB1BJuxA9+Ndi47NNPXQzi9rkXp8AibeeFayghSUdd/814AmzOwFPk79RSADLlHrG ZRj61JMjB9Ung1m1l2YWQAdc4oNREC4YGw5XQ= 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=wHTGmIfG7F9SDIRewz7zNR4I/bW/soPNx1fVWL7SSqg=; b=jeR7Ogznuy9pyyALOEZVRnJ4X1fcfWyCwpx+zNbkbjb1aX6cmgVoT0TehppbgzaXM1 os8QZLqyMgFQYtednhJBKjVhe/Q8qTflZGLChkt8KIbd4oWaQRtP0Z7JBBPdWKotgr5j 1OTBdOzg3kV8U0BsBAFRB8FNrQLwo8KcUR0PeAi+ACVG8xCuKDbHr4J0U07QOna2Xywe SifdCuw9iB4jCdI+BTRNUaEwYwCgsm7+p6ycjwYctokLPl8s1wWZTIps4BaFvE4xRPey QQc9Til1eE48F6KymneF1+ZNh9MK5bL4LqMI3WiEcp+wHJ8b0guFl1LRGrM+cAX2NBbc AY6A== X-Gm-Message-State: AOAM533cJd0YsxfiBYWGTdOzCDKkRgCP+6O+g1JV50crzvVd0XTptJf/ 3Pi5EJwvzUIufMVQSEDeoLiUHA== X-Google-Smtp-Source: ABdhPJzqNNOM+2d0wWt373IhGLQCkfpQ8uaLs4Awk+SD55er6894XsVy3NxTKfixb7gtqrTcou2m/A== X-Received: by 2002:a05:6a00:15c1:b0:49f:d21f:1d63 with SMTP id o1-20020a056a0015c100b0049fd21f1d63mr15298896pfu.18.1638484060421; Thu, 02 Dec 2021 14:27:40 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:f4f2:1b7e:5aea:bf3c]) by smtp.gmail.com with ESMTPSA id q9sm836934pfj.9.2021.12.02.14.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 14:27:40 -0800 (PST) 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 v4 05/34] component: Add {bind,unbind}_component() ops that take aggregate device Date: Thu, 2 Dec 2021 14:27:03 -0800 Message-Id: <20211202222732.2453851-6-swboyd@chromium.org> X-Mailer: git-send-email 2.34.0.384.gca35af8252-goog In-Reply-To: <20211202222732.2453851-1-swboyd@chromium.org> References: <20211202222732.2453851-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 dc38a8939ae6..e9e58b56cda4 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 *);