From patchwork Tue Apr 23 23:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 162759 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4354982jan; Tue, 23 Apr 2019 16:21:32 -0700 (PDT) X-Received: by 2002:aa7:8284:: with SMTP id s4mr29494625pfm.235.1556061692096; Tue, 23 Apr 2019 16:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556061692; cv=none; d=google.com; s=arc-20160816; b=rcqo/iZbOGYZTKFZrwrK3Xq/iNyGl2kr+V/lZRaYLTXOfuJLfpzYmIw5u4syQ14nSV xOvbXGhNhNeVdfpuAXJqYO1BBlPErejA/oAABgzKa/mEpVdyviaM0yjsALu6N4Q8C+kk Nacyip++1UbtzYb8ykTnneR4bpFGBU8G9Z1XqKgpv0gHq6czDqktvpIJRU9a0hfaeK6T baij3NpNwqwt6P7DdkEbJ4T4ebVgP7GKwUkDEyDQ6soTqmH/5mcBeJcEmyfeTs4w8FAX Z7A5LHurrewcmvXT44Lf8vKxSsfdryaSW8kzMllC4lMSPq4jwwphWkObdBhFqJDDvhIQ uzRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EYoqwtlhspVO6DfzyLClaQUxGfmShRm+XxIRhwBQn0I=; b=s5VGiFdn3s8xiPaCu7UvnDXMGwh2aeb42vMR3pljt0mHuf2/VjT8ER1RoM8sWEpEGQ ZblyC713zyQ/Vtwsa51TLoaQiAnYbHVRW90cn90MESMDynRy0EiNqlZlE58g25kDHpZM mxTg3A0I/FLlXN/K4pkZsv2WUEjwT4g3BRxKYYz9g07Tyjd1O6yWOMoQx+1bt3O8uBSw cq4lTIikCH6NS4JVmhuIGZXAo/HZuASacKdnZatQ+idP5msfnrsPvDLW+AB/n+R2cJlS LlanlakT/jlAKpXghxceDnrScIthHLchhmaoKliipenMCPrtCiC2WsgQ2qzDOGOO3iJO ip4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=untjjzDT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e2sor2510288pln.52.2019.04.23.16.21.32 for (Google Transport Security); Tue, 23 Apr 2019 16:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=untjjzDT; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=EYoqwtlhspVO6DfzyLClaQUxGfmShRm+XxIRhwBQn0I=; b=untjjzDTKcvx3+iaKnypN+M8KVcNEUpB4mwwFbgfwC7yJnVLUBuXEpWrZKIITqTcBN gVCMKZuU7x49a1EvydCQLYZ0v5weudYBbmFitR1K7Gh24cS8vTgajFK56tt7Hu+U48bE +w4OzV1FKl0FgVZHth0AEKFh/mDjlgqxlMNAyxjO9pXkUD2io8Y5+MQCESi7DzfOD8o+ DhYLCwlN38AEvwfx6tQsucj4HusnSH7zA6DI4x2BvZmeeAHqpDk+2wjNAaNfLS/6u640 AvHBbHkJcdxSBilkrUHaTcRf8S459B45aqIU5crH6Q4NTEN1NEQ86QgF0YXzfCgYlUsh 6Cvg== 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=EYoqwtlhspVO6DfzyLClaQUxGfmShRm+XxIRhwBQn0I=; b=bMaykWjH61lV1TbWAIkh9KY+FzJ2uo6IGArHMdkGMpXENPtAW3d2KGkAWTLVHteba8 R02Fn5MnsINcMfg0wXMTZndTKAx4U5KBN5ZPGA0uuH4taP9uOAfFvJ+8fNz6SCw8ChvK qG6q4sV8Y8i7U4x001wOrTVfQD6KGii4beS8d9huhvrZpfUFda4ljoEKFetE1bFI4Eog BMb55TvJtYeG3uTQeeucldt9UMW08JCxI7j5WkhIV9XpYvRjOZXwPk2HNG3LzudhHAZg xc282yzeQOqdcKsUq8vddM+Plp+jspaR/M91FHOkbhqBIdQk4COjDFhRm8IsDOBvgZf4 CXVA== X-Gm-Message-State: APjAAAUpn7d2RRfjcFmw71LN+03mSjO+d5mHf6guSLCSvQJyq5WV8JhD OJ9dfBXpd7Jnz996GHy6nW57TyM8ZQc8iQ== X-Google-Smtp-Source: APXvYqwSsIHNNCSlSYPmHMjgWsENBgc+jn8ULcVY1CgFWt3IEmlE6/E3F36W0TwLmUHJ8AIgZE/Zyg== X-Received: by 2002:a17:902:9898:: with SMTP id s24mr7893823plp.268.1556061691666; Tue, 23 Apr 2019 16:21:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id c28sm6984235pgm.42.2019.04.23.16.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 16:21:30 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen Feng , David Airlie , Daniel Vetter , dri-devel , John Stultz Subject: [PATCH 22/25] drm: kirin: Make driver_data variable non-global Date: Tue, 23 Apr 2019 16:20:53 -0700 Message-Id: <1556061656-1733-23-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556061656-1733-1-git-send-email-john.stultz@linaro.org> References: <1556061656-1733-1-git-send-email-john.stultz@linaro.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: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Signed-off-by: Xu YiPing [jstultz: Reworded commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 ++++++++++++++----------- 1 file changed, 24 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index a2938d4..634fd58 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -30,18 +30,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; @@ -97,6 +88,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; @@ -133,15 +139,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; @@ -191,12 +203,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; @@ -210,7 +216,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; }