From patchwork Tue Oct 20 09:23:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 55298 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 2D1A223024 for ; Tue, 20 Oct 2015 09:24:43 +0000 (UTC) Received: by wikv3 with SMTP id v3sf6994963wik.1 for ; Tue, 20 Oct 2015 02:24:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=kRhKZBS+t902fU5c1fFcYaTgvTbLxVqe3LQ22PDbMSQ=; b=hT2T5GeqZnldShLYZoXe2k+ow/3TTZVGa8DzRzSkJfZuLi06UufjIz910hw8Z6jMWZ TSqgDyM82hdPxnc86EwyvfMVnFNh81f7ffepcqHePeuoD9hnQxAZdA48y4M+l5kQMaBv XpPcy6HaXkeOJA4lMJy09DULitGf5y+2taJfRNKMPf+7gebx0MVtU8PwDtGNgcAYd7cg P7ptdQO2Fkdl8SLnV724ZINwG98Klfh+Cace+DVoyLnhmu2Zetvd6PsRLc1wx2cXi6Ws P7uHQxf33PdAv5hGikapYqDjcLhkwPTwHrm1C5Gagq+UKCtv27kaAouKY5hW7Zu5HsQz xbMw== X-Gm-Message-State: ALoCoQmKNBrsr4EVja99rSXZJ/4HHrH109iy/CUmgfvSvmciuKidV0aEsXZZRsEX4dfPtWzydU/Z X-Received: by 10.194.192.71 with SMTP id he7mr420522wjc.2.1445333082510; Tue, 20 Oct 2015 02:24:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.29.148 with SMTP id d142ls42617lfd.27.gmail; Tue, 20 Oct 2015 02:24:42 -0700 (PDT) X-Received: by 10.112.218.42 with SMTP id pd10mr1173060lbc.114.1445333082323; Tue, 20 Oct 2015 02:24:42 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id t1si1552241lbk.72.2015.10.20.02.24.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 02:24:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbec13 with SMTP id ec13so8125538lbb.0 for ; Tue, 20 Oct 2015 02:24:42 -0700 (PDT) X-Received: by 10.112.64.41 with SMTP id l9mr168431lbs.32.1445333082212; Tue, 20 Oct 2015 02:24:42 -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 w3csp1961756lbq; Tue, 20 Oct 2015 02:24:41 -0700 (PDT) X-Received: by 10.50.142.67 with SMTP id ru3mr23350643igb.38.1445333081224; Tue, 20 Oct 2015 02:24:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si17501871igx.75.2015.10.20.02.24.39; Tue, 20 Oct 2015 02:24: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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753573AbbJTJY2 (ORCPT + 28 others); Tue, 20 Oct 2015 05:24:28 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:25760 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752221AbbJTJYT (ORCPT ); Tue, 20 Oct 2015 05:24:19 -0400 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 t9K9NFXR008059; Tue, 20 Oct 2015 10:23:18 +0100 From: Liviu Dudau To: David Airlie , Daniel Vetter , Philipp Zabel , Mark Yao , Heiko Stuebner , Russell King Cc: dri-devel , linux-rockchip , LAKML , LKML Subject: [PATCH v4 4/4] drm/armada: Convert the probe function to the generic drm_of_component_probe() Date: Tue, 20 Oct 2015 10:23:15 +0100 Message-Id: <1445332995-11212-5-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1445332995-11212-1-git-send-email-Liviu.Dudau@arm.com> References: <1445332995-11212-1-git-send-email-Liviu.Dudau@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.170 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Acked-by: Russell King --- drivers/gpu/drm/armada/armada_drv.c | 68 +++++++++++-------------------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 63d909e..3a7ba69 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,43 +266,29 @@ 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; + struct device *dev = &pdev->dev; + int ret; - for (i = 0; ; i++) { - port = of_parse_phandle(np, "ports", i); - if (!port) - break; + ret = drm_of_component_probe(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) { + if (dev->platform_data) { char **devices = 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(dev, &match, compare_dev_name, devices[i]); if (i == 0) { @@ -311,32 +298,15 @@ static int armada_drm_find_components(struct device *dev, 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(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); }