From patchwork Thu Aug 1 03:44:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11070145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D58B913AC for ; Thu, 1 Aug 2019 03:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C07283C3 for ; Thu, 1 Aug 2019 03:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB59B283C8; Thu, 1 Aug 2019 03:45:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53821283C3 for ; Thu, 1 Aug 2019 03:45:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D10466E35B; Thu, 1 Aug 2019 03:45:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 293906E35D for ; Thu, 1 Aug 2019 03:45:22 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id l21so33268704pgm.3 for ; Wed, 31 Jul 2019 20:45:22 -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=rs9Szavz01lGhxB105GpAFsAJ0GA/GmuWwL2NPh/1Lc=; b=lAUBEr6LVHooOzwqEyW49GUOv/tQnTef5OZDwClnDSuFaIcR9qvTtJixF7ovoTz8mu ppau+p0RGOBgP+WULMAp/vc0c+5GxwLr2ujyzhi5o/4GL2j4IpVJHVlvg89kLkbkiR66 Ekd8pnmWHn4B5U6pk8ztgaFVZq9VnNhmLc5iblGIa4VAH0ae/goGFBGZVgJ2lSwQltW6 ezuNneESWztuN6MW2Uhaf2TGIUp1hd574h6QwcPKWy9dLmWIDLhYQ7jQSjXr7IP5eurB cf7wsB0QGHnxoF79f/KOCd9QpItVu8svMyXR9Ks7Xu7NEDFwkDOhwDS0xxvx+4uIRKe3 SX7Q== X-Gm-Message-State: APjAAAVWM0QMpjZZYA0Gnvjs6dGXFG3mu8fRA+psfA+4sUCMruNBRmC+ knSv60G8IRkmGBPznk6rqdRmvA== X-Google-Smtp-Source: APXvYqx6GQJiArHkNMY5CkBCvPwyOdt4fTOYA/3VTALL2+Rl1TPDFGIT8W/5hN361RUoQi54wouXQw== X-Received: by 2002:a17:90b:f0e:: with SMTP id br14mr6233618pjb.117.1564631121372; Wed, 31 Jul 2019 20:45:21 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id h70sm64775674pgc.36.2019.07.31.20.45.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 20:45:20 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v3 23/26] drm: kirin: Make driver_data variable non-global Date: Thu, 1 Aug 2019 03:44:36 +0000 Message-Id: <20190801034439.98227-24-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190801034439.98227-1-john.stultz@linaro.org> References: <20190801034439.98227-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=rs9Szavz01lGhxB105GpAFsAJ0GA/GmuWwL2NPh/1Lc=; b=RP6VNmIXUw1IL4IlU/gJX7/aS4NwEOhx/k3T7v40iplb7HaAg2bBR7EI8juAW1lE55 vw6RqUXZQn3tzgtDzP0XsTs3ja9B/7159KzfkX54QjTFKlyTP+7rUMdBpNEwM8f4H+Q1 RQAJii8IzqE0kjvaAjt8x0QfrS6CnWwcPgJkWJ4u29rnqq4ZQrWc6T7B90GtioTl7Mej 1zTbWRFa5mNN66sboTxlSVMNtib5QODg6O7jwD0QqAsNBUlDidIDNhI1tKeHcQHqb4pT /7z7Olx6LVMSexR8gg28q5lGFz3YVQXSjv55qaYe9xAdqIzMauUdjH45JsfirfZl4b/+ 84lA== 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 , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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: 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(-) 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; }