From patchwork Wed Aug 14 18:46:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171354 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1203680ily; Wed, 14 Aug 2019 11:47:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwo22yMLlXOvUqDYqh0FlEUNkIY+f8W0yQ0GSjFwhKd7P+vdrSS7v24TT0rpPl1BBvrHZPF X-Received: by 2002:a17:902:169:: with SMTP id 96mr699391plb.297.1565808475011; Wed, 14 Aug 2019 11:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565808475; cv=none; d=google.com; s=arc-20160816; b=UlshqwBBNfFP5rLb6reQUyDobRg0qoVTN10f3CF24VbPiQVnru0tcuk7wi6pYpWu7B NdwhB90D00OugXpCwMbFT6cw8EPnVPGPJ657bIX3WgeY54ChqkxCGzZEGOKkQFTxflSi Ne8Qh4wmQ5l2+ntt8Fnfj6DYqGbVI2V995S6FggzU7vWHvpElFJM0u9s8yqFI+ELwTdO pLBPy1ZRbf1+k2i680qHOZkaQEKdajtpnwD0VTi2KzoREMLlvkYhQ6WIAy6bs1PEhaBv gonVzh2CKvk97Fg9BPvP/R9z/kNpAyxBtILSAPhwEjRvUoV9S0D4/A/XNp67Uo2L6GM1 ON7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OApmoIvKEwANRXPyc/6OWQeR4K/MRqLWVFQnZsIe75s=; b=P/2Px6w3Aq6AZzjhhisf/iLqNTEjhDxWBee/3USkuUiRye04I1u/KBNWK7uqt/X/ow 1qNLUO2ykV0aK0aGvBAYZgq/AD8/gUCQsHMGbtNsp3L04D0s/dkqYtZh4h9/qB8c4ifu tEThPEGnW72FOtUTH8uaI1yH8hcw8+kWsuJIg3jZHW/Yx+lKHP2VaiU/THANW+CTDfG0 BHi8DCykrI9ZiVfz+ns2y3R3jfeV+tjCjmB83ZSYdLkjSoPR2L9UZt0oqeH9vrxFwzfU atgwopVtq2LNO7tSaKtHqWre8IQGcGGhnlYLeGYuJJvRBTwRJpEVAWi4jxPHPu49xiQ8 Uh/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lOsITZch; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x126si316758pgx.356.2019.08.14.11.47.54; Wed, 14 Aug 2019 11:47:54 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lOsITZch; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729599AbfHNSrq (ORCPT + 28 others); Wed, 14 Aug 2019 14:47:46 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39031 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729486AbfHNSrn (ORCPT ); Wed, 14 Aug 2019 14:47:43 -0400 Received: by mail-pf1-f196.google.com with SMTP id f17so50104778pfn.6 for ; Wed, 14 Aug 2019 11:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OApmoIvKEwANRXPyc/6OWQeR4K/MRqLWVFQnZsIe75s=; b=lOsITZchiLFnULc5mm91WsaNs9MBzbyapHeMMb56+cdMOduZItbjK07Tu3gtHNJgwj 1mrPMeWj+3uA9BZum5sPSqe3wz4YHEcHXg0cAFV4S0JuHOb7Y36+EGsRZsl2q4Ebhugn RKMYnwMA23IRUelOo1yGFV7o/+Eso8NGPvNoQhNdO8FoZwxjC1cZC0NUYPGIeNmSXjgq flXmnQE9BmgM7AW1v2WbDZszd9ZxIoURO9WUoJf/XrHCfnx4BfoN+tSHUELB+rdPJxii zCLmsU+8GMqy6mPvkBUciI/vnNU7Kq34UXXWakMulrT4byK/uz3KcotFWFSfc4V3mrRp uFmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OApmoIvKEwANRXPyc/6OWQeR4K/MRqLWVFQnZsIe75s=; b=naUWT33QyEO0us0XEUyzw5FQUop/OF3hUirluONzsVE8qmKy3+nKMqN70LaxUfWxOD UAdEwmEgEheV/FtxpDUQnR4nFr2YNHY2L7CMbAYp2c73Fy0va1Knj7KkWOqM+X6epubX 62JCYaSNeNvAboPl0gSMNzPlRGBDh+owy3iwHShxQtkMnwuATuB2/Ahhf6sGST5NMQpV tPGorI9ZqP31Ttvj8vEJVfqfoAcwjGqZAAkmSY8LgqvrQajgJsj67Om7YtCN9yDqbvkC cr0SliBtM5c0qPBZ8nAaFSZPTQc0aUNphFlTYB0cW9DvIQhdIzhhaio1spHYOLXKunz9 t8eA== X-Gm-Message-State: APjAAAWQgg6E87ZSdj2nZ52vgShGZq+Ya/kmZg74S3kygYVRWVIhjOTz tRVE3ss86hihDiWdCXbCjtSdDSc0W3I= X-Received: by 2002:a17:90a:cd03:: with SMTP id d3mr1051669pju.117.1565808462290; Wed, 14 Aug 2019 11:47:42 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y16sm610855pfc.36.2019.08.14.11.47.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 11:47:41 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [RESEND][PATCH v3 23/26] drm: kirin: Make driver_data variable non-global Date: Wed, 14 Aug 2019 18:46:59 +0000 Message-Id: <20190814184702.54275-24-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814184702.54275-1-john.stultz@linaro.org> References: <20190814184702.54275-1-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the driver_data value to not be a global variable. Instead the driver_data value is accessed via the of_device_get_match_data() when needed. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index f1853b84ab58..cc79bd4ecec2 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -28,18 +28,9 @@ #include "kirin_drm_drv.h" -static struct kirin_drm_data *driver_data; -static int kirin_drm_kms_cleanup(struct drm_device *dev) -{ - drm_kms_helper_poll_fini(dev); - driver_data->cleanup(to_platform_device(dev->dev)); - drm_mode_config_cleanup(dev); - - return 0; -} - -static int kirin_drm_kms_init(struct drm_device *dev) +static int kirin_drm_kms_init(struct drm_device *dev, + const struct kirin_drm_data *driver_data) { int ret; @@ -95,6 +86,21 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; } +static int kirin_drm_kms_cleanup(struct drm_device *dev) +{ + const struct kirin_drm_data *driver_data; + + drm_kms_helper_poll_fini(dev); + + driver_data = of_device_get_match_data(dev->dev); + if (driver_data->cleanup) + driver_data->cleanup(to_platform_device(dev->dev)); + + drm_mode_config_cleanup(dev); + + return 0; +} + static int kirin_drm_connectors_register(struct drm_device *dev) { struct drm_connector *connector; @@ -131,15 +137,21 @@ static int kirin_drm_connectors_register(struct drm_device *dev) static int kirin_drm_bind(struct device *dev) { + struct kirin_drm_data *driver_data; struct drm_device *drm_dev; int ret; + driver_data = (struct kirin_drm_data *)of_device_get_match_data(dev); + if (driver_data == NULL) + return -EINVAL; + drm_dev = drm_dev_alloc(driver_data->driver, dev); if (IS_ERR(drm_dev)) return PTR_ERR(drm_dev); dev_set_drvdata(dev, drm_dev); - ret = kirin_drm_kms_init(drm_dev); + /* display controller init */ + ret = kirin_drm_kms_init(drm_dev, driver_data); if (ret) goto err_drm_dev_put; @@ -189,12 +201,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) struct component_match *match = NULL; struct device_node *remote; - driver_data = (struct kirin_drm_data *)of_device_get_match_data(dev); - if (!driver_data) { - DRM_ERROR("failed to get dt id data\n"); - return -EINVAL; - } - remote = of_graph_get_remote_node(np, 0, 0); if (!remote) return -ENODEV; @@ -208,7 +214,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev) static int kirin_drm_platform_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &kirin_drm_ops); - driver_data = NULL; return 0; }