From patchwork Mon Oct 19 12:21:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 55222 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 43E4022EA2 for ; Mon, 19 Oct 2015 12:22:23 +0000 (UTC) Received: by wicfg8 with SMTP id fg8sf619084wic.0 for ; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:subject:date :message-id:in-reply-to:references:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=3XipHUrHWt+Kd7EIP5EndgjZG9vGpmF6tzv1Gijt9J8=; b=AHky2Im/eG9S8CvtxHmlJibl4aYmVVG/bYMPqngTUummG1lziziGh4yBmVQ4UxqKgK W7joqca0Tk/sk3MAXBzVFrX/UATKS3nLC6Ucu9PMImhSdXSkrcOdaP+tAJxi+AZ6d6lD D9sUmgSXk2aH9VB+RUFjqwMkRohOFOPcwAQSQWxXa94WjXMfCH2RqBD/45Nc8mvcn8bG n18AxITul+F4wXxIJoI78EVNXfBtxxdL3/zBahNxMRHg3SjWqFND2fleKU3iNJhsIBYX lx1Vt8Q+REBakgvYlPUzEUU0OJ6vaNnbhySmG+XkbnfkpcGX1uytDISJzVY4YPlQv+XD xcAQ== X-Gm-Message-State: ALoCoQlTjOE9so0m8DSysrhgS2i6jRt40iAq7ZMlNk026p57n3KlRzWsunIgZwEzrrjugR2WFVar X-Received: by 10.112.54.197 with SMTP id l5mr6584038lbp.21.1445257342518; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.205.7 with SMTP id d7ls611305lfg.82.gmail; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) X-Received: by 10.25.44.80 with SMTP id s77mr9369951lfs.37.1445257342380; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id 89si9457254lfr.2.2015.10.19.05.22.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 05:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lffz202 with SMTP id z202so28067122lff.3 for ; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) X-Received: by 10.25.38.9 with SMTP id m9mr9433699lfm.112.1445257342236; Mon, 19 Oct 2015 05:22:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1437758lbq; Mon, 19 Oct 2015 05:22:21 -0700 (PDT) X-Received: by 10.107.154.213 with SMTP id c204mr30656815ioe.80.1445257341104; Mon, 19 Oct 2015 05:22:21 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id q5si16380531ioi.175.2015.10.19.05.22.20; Mon, 19 Oct 2015 05:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF1896E8DE; Mon, 19 Oct 2015 05:22:19 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id C17AF6E8CA for ; Mon, 19 Oct 2015 05:22:18 -0700 (PDT) Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.2.131.158]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id t9JCLrEG003452; Mon, 19 Oct 2015 13:21:54 +0100 From: Liviu Dudau To: David Airlie , Daniel Vetter , Philipp Zabel , Mark Yao , Heiko Stuebner , Russell King Subject: [RFC PATCH v2 4/4] drm/armada: Convert the probe function to the generic drm_of_component_probe() Date: Mon, 19 Oct 2015 13:21:53 +0100 Message-Id: <1445257313-7147-5-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1445257313-7147-1-git-send-email-Liviu.Dudau@arm.com> References: <1445257313-7147-1-git-send-email-Liviu.Dudau@arm.com> Cc: linux-rockchip , LAKML , dri-devel , LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: liviu.dudau@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The armada DRM driver keeps some old platform data compatibility in the probe function that makes moving to the generic drm_of_component_probe() a bit more complicated that it should. Refactor the probe function to do the platform_data processing after the generic probe (and only if that fails). This way future cleanup can further remove support for it. Signed-off-by: Liviu Dudau Cc: Russell King --- drivers/gpu/drm/armada/armada_drv.c | 73 +++++++++++-------------------------- 1 file changed, 22 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 63d909e..25c42f3 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "armada_crtc.h" #include "armada_drm.h" #include "armada_gem.h" @@ -265,78 +266,48 @@ static void armada_add_endpoints(struct device *dev, } } -static int armada_drm_find_components(struct device *dev, - struct component_match **match) -{ - struct device_node *port; - int i; - - if (dev->of_node) { - struct device_node *np = dev->of_node; - - for (i = 0; ; i++) { - port = of_parse_phandle(np, "ports", i); - if (!port) - break; - - component_match_add(dev, match, compare_of, port); - of_node_put(port); - } +static const struct component_master_ops armada_master_ops = { + .bind = armada_drm_bind, + .unbind = armada_drm_unbind, +}; - if (i == 0) { - dev_err(dev, "missing 'ports' property\n"); - return -ENODEV; - } +static int armada_drm_probe(struct platform_device *pdev) +{ + struct component_match *match = NULL; + int ret; - for (i = 0; ; i++) { - port = of_parse_phandle(np, "ports", i); - if (!port) - break; + ret = drm_of_component_probe(&pdev->dev, compare_dev_name, + &armada_master_ops); + if (ret != -EINVAL) + return ret; - armada_add_endpoints(dev, match, port); - of_node_put(port); - } - } else if (dev->platform_data) { - char **devices = dev->platform_data; + if (pdev->dev.platform_data) { + char **devices = pdev->dev.platform_data; + struct device_node *port; struct device *d; + int i; for (i = 0; devices[i]; i++) - component_match_add(dev, match, compare_dev_name, + component_match_add(&pdev->dev, match, compare_dev_name, devices[i]); if (i == 0) { - dev_err(dev, "missing 'ports' property\n"); + dev_err(&pdev->dev, "missing 'ports' property\n"); return -ENODEV; } for (i = 0; devices[i]; i++) { d = bus_find_device_by_name(&platform_bus_type, NULL, - devices[i]); + devices[i]); if (d && d->of_node) { for_each_child_of_node(d->of_node, port) - armada_add_endpoints(dev, match, port); + armada_add_endpoints(&pdev->dev, match, + port); } put_device(d); } } - return 0; -} - -static const struct component_master_ops armada_master_ops = { - .bind = armada_drm_bind, - .unbind = armada_drm_unbind, -}; - -static int armada_drm_probe(struct platform_device *pdev) -{ - struct component_match *match = NULL; - int ret; - - ret = armada_drm_find_components(&pdev->dev, &match); - if (ret < 0) - return ret; - return component_master_add_with_match(&pdev->dev, &armada_master_ops, match); }