From patchwork Thu Oct 15 16:11:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 55052 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f69.google.com (mail-lf0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 5795E22FFA for ; Thu, 15 Oct 2015 16:12:52 +0000 (UTC) Received: by lffv3 with SMTP id v3sf4883909lff.1 for ; Thu, 15 Oct 2015 09:12:51 -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=inr9QnEkdnRtVtWhJVrb5mAsa+dwAGXwZr1MZc7FJtA=; b=SbNKZTTP/T0EFQ4Fr3LI9G3UABVVfXo1xiVWi2+NAPicQ/KSsvxvxu5uKRJQNfijU8 Jhnhoim0Z1G2ejlxWxeTMIMlgmza5aUe5PDngczBARWO7NkZjx+IR6mVt3wzIcXGFSlF rMP4T7tIW4+d9BcjUmSvnUOvE9jj5UVMbqSzJ+sPKdgab4Jet0yl6LhOHCS+usgXXX2H B9un6Cq1pwHXDIviiYpvCEkEDw4dPUHgQTA0we3+StbRbkitY1zNVdnk6Olokj//Ne7m mnZQYVhohhw6re/55VB6S8+Akzsw8AZd6wG+/P8wlkjHcmyZy74M1sZY2G4fAJs5D9Bv LDSQ== X-Gm-Message-State: ALoCoQnwtAdGDIoerfvuov8s4ImpsiDeRIoR6M+qur2JY4xaSenvaYLOrtrcfkWNwUo/LEUWxZo5 X-Received: by 10.195.18.100 with SMTP id gl4mr2365434wjd.4.1444925571317; Thu, 15 Oct 2015 09:12:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.24.84 with SMTP id o81ls185310lfi.48.gmail; Thu, 15 Oct 2015 09:12:51 -0700 (PDT) X-Received: by 10.112.55.99 with SMTP id r3mr5088909lbp.64.1444925571133; Thu, 15 Oct 2015 09:12:51 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id 24si9621666lfu.23.2015.10.15.09.12.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 09:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbwb3 with SMTP id wb3so13063694lbb.1 for ; Thu, 15 Oct 2015 09:12:50 -0700 (PDT) X-Received: by 10.112.161.168 with SMTP id xt8mr4058623lbb.88.1444925570527; Thu, 15 Oct 2015 09:12:50 -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 w3csp725943lbq; Thu, 15 Oct 2015 09:12:49 -0700 (PDT) X-Received: by 10.50.43.198 with SMTP id y6mr34084585igl.55.1444925569315; Thu, 15 Oct 2015 09:12:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n31si12216765ioe.74.2015.10.15.09.12.47; Thu, 15 Oct 2015 09:12:49 -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 S1753551AbbJOQMK (ORCPT + 30 others); Thu, 15 Oct 2015 12:12:10 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:28866 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752290AbbJOQMI (ORCPT ); Thu, 15 Oct 2015 12:12:08 -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 t9FGBBSO020260; Thu, 15 Oct 2015 17:11:13 +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: [RFC PATCH 4/4] drm/armada: Convert the probe function to the generic drm_of_component_probe() Date: Thu, 15 Oct 2015 17:11:10 +0100 Message-Id: <1444925470-9963-5-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1444925470-9963-1-git-send-email-Liviu.Dudau@arm.com> References: <1444925470-9963-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.176 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 if that fails). This way future cleanup can further remove support for it. Signed-off-by: Liviu Dudau --- drivers/gpu/drm/armada/armada_drv.c | 83 +++++++++++++------------------------ 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 225034b..990080d 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" @@ -370,47 +371,36 @@ 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; +static const struct component_master_ops armada_master_ops = { + .bind = armada_drm_bind, + .unbind = armada_drm_unbind, +}; - component_match_add(dev, match, compare_of, port); - of_node_put(port); - } +static int armada_drm_probe(struct platform_device *pdev) +{ + int ret; - if (i == 0) { - dev_err(dev, "missing 'ports' property\n"); - return -ENODEV; - } + if (!is_componentized(&pdev->dev)) + return drm_platform_init(&armada_drm_driver, pdev); - 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) { + struct component_match *match = NULL; + 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; } @@ -419,35 +409,18 @@ static int armada_drm_find_components(struct device *dev, 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) -{ - if (is_componentized(&pdev->dev)) { - 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); - } else { - return drm_platform_init(&armada_drm_driver, pdev); + ret = component_master_add_with_match(&pdev->dev, + &armada_master_ops, + match); } + + return ret; } static int armada_drm_remove(struct platform_device *pdev)