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: 171880 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180559ily; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) X-Received: by 2002:a63:9d8a:: with SMTP id i132mr10886649pgd.410.1566342425759; Tue, 20 Aug 2019 16:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342425; cv=none; d=google.com; s=arc-20160816; b=0iJvhwfIagcTbqITSaLZlTHLGgwZzhC/ezyxbxJD+vLXy09AO/v14Iu4pJ3XRytG7/ 2gqrnyOUFYpXNw2z9j8RCPsS40P+15ZeRaRaqQxg5FauMCRzekr7vsULYRsyLgSvlizc ODFw7LnaNFMwkdPjjyInhuBHfWGlQpQDOLMmdBLVW4NnqxPfGsT5RiJY4gRp+mLYyYqB vEjpmYb6+UkdsjONXRlkp1niAzItVVIWlBAKHltFhH4LvuyfV4ytQrOSz7GsuPcJcmoz QkwLxBwwDvQO5kSbPJMbRj1BrmEMYgV45s+yEa0KsjC4ZuAHNlNEUZ9ZKKC+XzuJnT/a Z25w== 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=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=LHkGqvOCV0G86IiyYM1Q9zGOKruOtCUNlOHzGi6Gn3CAS872bR10JEdIjY0jL41vx9 l3iLz7DYa0Vc6jz5287+jdKk/vVA62/yIVyWZm/BYTt8elbtAIllWcamABpfDf1dhaee aQCaEOsxt31KaK+jE18WKvycurk8TjLHewJfdWFIYWy0VVoNCrqOj1K98PvCONj6L73B HEv0M8gQnBkwnfHExNnzsP2d6FiebUgKb+0x0r1hT1nlkV7ZGnPc9Fkw2Z06ovVZhjGJ Sn4PQxzxD3xxW9Iig6asVgFXPTOWnFIg1pRiViEZ867DcYJIUmt+WajfSzsIJW36lN9a V6GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jeM2fPkb; 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 c16sor5603479pfr.5.2019.08.20.16.07.05 for (Google Transport Security); Tue, 20 Aug 2019 16:07:05 -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=jeM2fPkb; 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=MVBS6s/BS2iml31wX2/Rhd0nBzLwsiOkYjbfOZWZ4tw=; b=jeM2fPkbWnWSTtEljReDIHFfsfeHVQ01JqHJ9u2ShkYBcp+/+8KYKxqhYw3vJRtfW7 QVPqk/3z38c4SPs8IzrPnm7uelkN5fbYcTCsyH17RHuZSVSNJXpYSnlPXTbgSEIDg3fz WI4Gu4RCVWN4uYRfzbWWXuHkT8DjXxSIKW/THCwmlSZIvU+aYIPe1yQ3f/BooYC1qeex Lgt5cV4PIgRLXnc7Xq4BkU2nuYMxZJ6yp0zDEMhyBn83wAsR6t5j9l8Cl+GBvNrG5kPV NPU0owlbQoPnSXK0TefSdAMsPcnLzi1X8CgwVKhtVh/K0uhgD62tZfDXhaW381uj/zNt upbA== 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=dOnNzNJ6aI1qrKaGj2OBD1w4JWcU4qvJ0DU/g3mCzkJOtXbZRi5jwUv43DzpjmkJ8D oOLtVAfSTkobqPJwXs/LZHgLjLYcgbMIDCEVoglrxDKETUMNKH0bxQSaDcilKEvWYr89 hswe+ufMFXOFkUScng+rrLO+uoEozjKkL4uztLTozw31jHnH6y0tGMqmbtpt1Ze8yZ2a CxyBa/4DEfSBdJH8tRtMivGJqBHxvSRbx8xNUphh6vNJzslkkDTDzRtxTQBQz4ZLXQIi I0u4+n5w8ipHZzZ27DugBXNwJBtgVpI0zIqr6dLFIm3FR/P2fwxxkUhDRQGpKLzea2V1 Q+lg== X-Gm-Message-State: APjAAAX9YjWXnJqjBYWpO2hJMkHo4Ldbj0dKmOgXY72DfFaVdFf7wlzC RLXVaf8SWcR1JTpHMsYlcpxCdT4F 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) Return-Path: 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 Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz 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> 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(-) -- 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 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; }