From patchwork Tue Aug 20 23:06:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11104851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2989E1398 for ; Tue, 20 Aug 2019 23:07:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 116602341C for ; Tue, 20 Aug 2019 23:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 116602341C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11D986E8BC; Tue, 20 Aug 2019 23:07:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE9206E8CE for ; Tue, 20 Aug 2019 23:07:06 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id f17so90658pfn.6 for ; Tue, 20 Aug 2019 16:07:06 -0700 (PDT) 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=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=CIFbiVdHAZYEF8RWxBVQwrqukA8V3py9Zcx1jRypf7PRPuVkxpKOPgkf7t+xQ8VVR2 6HHOwWXLBbHNVso3mH0T6yHtcP5qzac7owVmd2IxiE4AHB+xrvkEI/trE5Alrho9X6A5 /6C3SV8r8H5odzkiHxKAhBUKtr/SglDNK2rNCNa/tbawXwCiU86Zzbnabyss+VzcR0eW un35K9R5dJxuTqF0Lr/HB6TRV8lirl6cD+ebedgc9q2stNbyv1kxioMhKoDaV014/UER 7rdGOF8Q9ygSZvL+yFfAuGxAVRp4nETVSB7DWMfoZHVnrAFbUq7QPrJUF8QO8w1VlzVt UteA== X-Gm-Message-State: APjAAAV5pOyTYULJm+kV3p+AAMR/52zsOcVprfUfVkdPLwQloveJqqRe z9pWR1Kg36QLkoEXQcCBLo4tFw== X-Google-Smtp-Source: APXvYqwG9+bnLD4/Mpplbe8yIuvH+GlW31O8nnLcR91y1DkSlFoAAJKR0LUsiNpcJoVraKcZf5ZvIg== X-Received: by 2002:a62:76d5:: with SMTP id r204mr32005336pfc.252.1566342425396; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:07:04 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v5 22/25] drm: kirin: Make driver_data variable non-global Date: Tue, 20 Aug 2019 23:06:23 +0000 Message-Id: <20190820230626.23253-23-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-1-john.stultz@linaro.org> X-Mailman-Original-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=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=jeM2fPkbWnWSTtEljReDIHFfsfeHVQ01JqHJ9u2ShkYBcp+/+8KYKxqhYw3vJRtfW7 QVPqk/3z38c4SPs8IzrPnm7uelkN5fbYcTCsyH17RHuZSVSNJXpYSnlPXTbgSEIDg3fz WI4Gu4RCVWN4uYRfzbWWXuHkT8DjXxSIKW/THCwmlSZIvU+aYIPe1yQ3f/BooYC1qeex Lgt5cV4PIgRLXnc7Xq4BkU2nuYMxZJ6yp0zDEMhyBn83wAsR6t5j9l8Cl+GBvNrG5kPV NPU0owlbQoPnSXK0TefSdAMsPcnLzi1X8CgwVKhtVh/K0uhgD62tZfDXhaW381uj/zNt upbA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xu YiPing , David Airlie , dri-devel , Xinliang Liu , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Acked-by: Xinliang Liu Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- v5: checkpatch --strict whitespace fixups noticed by Sam --- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 7f8d4539b1a9..f5df88378591 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -29,18 +29,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; @@ -96,6 +87,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; @@ -132,15 +138,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) + 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; @@ -190,12 +202,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; @@ -209,7 +215,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; }