From patchwork Mon Oct 19 15:07:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 55233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id EB97E22F11 for ; Mon, 19 Oct 2015 15:08:12 +0000 (UTC) Received: by wibhd5 with SMTP id hd5sf854753wib.0 for ; Mon, 19 Oct 2015 08:08:12 -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=EVKzlckiNiHQ/MqyuNP+aWcPYgdHx+G9ECwkxWPMYuPzwMtG6j0Ra3/vUbycg5WWI5 IkiwhIa7bzR1GKyhn/eYRBDr8W8jgKDYRJzjg85fnohNFrZqUBinqiA8iJJ2929HItOG gDXa4FfQjR9qr+jLR/TrjFB3X8bo32oIk9r/IXGIW2fEXhJ/TYldz1B4JcaYsdo0qk4Q QKN2crXY5oQE99LgjHW17Avxri/YJ+gZt+mjwS/VvqhKgW9ClT8cuylM7gVRgdmlYD8W HQkLf8tKSiaSmb8V2dJzzr2wzWZnbA3j/dEMNnxa9gVuoGfK64jJ2nCSUfE2qYc46U2j PPXw== X-Gm-Message-State: ALoCoQk7aHMtMAb5fyn+bZq6DBJ0jDIGEPeQIEsFRZq95RTHcMpi2mIdi7MEOwZYJggMD3Lq0z3v X-Received: by 10.194.248.131 with SMTP id ym3mr1141772wjc.7.1445267292161; Mon, 19 Oct 2015 08:08:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.211.137 with SMTP id k131ls497210lfg.53.gmail; Mon, 19 Oct 2015 08:08:12 -0700 (PDT) X-Received: by 10.112.16.67 with SMTP id e3mr14951534lbd.5.1445267291958; Mon, 19 Oct 2015 08:08:11 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id p192si23185182lfd.147.2015.10.19.08.08.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 08:08:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbcao8 with SMTP id ao8so145889758lbc.3 for ; Mon, 19 Oct 2015 08:08:11 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr15164671lbb.35.1445267291400; Mon, 19 Oct 2015 08:08:11 -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 w3csp1527859lbq; Mon, 19 Oct 2015 08:08:10 -0700 (PDT) X-Received: by 10.68.68.134 with SMTP id w6mr35520084pbt.61.1445267289923; Mon, 19 Oct 2015 08:08:09 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id ad8si6687393pad.214.2015.10.19.08.08.09; Mon, 19 Oct 2015 08:08:09 -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 DCC4C6E942; Mon, 19 Oct 2015 08:08:08 -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 99AEB6E942 for ; Mon, 19 Oct 2015 08:08:07 -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 t9JF7o2l025900; Mon, 19 Oct 2015 16:07:51 +0100 From: Liviu Dudau To: David Airlie , Daniel Vetter , Philipp Zabel , Mark Yao , Heiko Stuebner , Russell King Subject: [RFC PATCH v3 4/4] drm/armada: Convert the probe function to the generic drm_of_component_probe() Date: Mon, 19 Oct 2015 16:07:50 +0100 Message-Id: <1445267270-23126-5-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1445267270-23126-1-git-send-email-Liviu.Dudau@arm.com> References: <1445267270-23126-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.217.175 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); }