linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tian Tao <tiantao6@hisilicon.com>
To: <airlied@linux.ie>, <daniel@ffwll.ch>, <tzimmermann@suse.de>,
	<kraxel@redhat.com>, <alexander.deucher@amd.com>,
	<tglx@linutronix.de>, <dri-devel@lists.freedesktop.org>,
	<xinliang.liu@linaro.org>, <maarten.lankhorst@linux.intel.com>,
	<mripard@kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH drm/hisilicon v2 2/4] drm/hisilicon: Code refactoring for hibmc_drm_drv
Date: Tue, 1 Dec 2020 19:55:52 +0800	[thread overview]
Message-ID: <1606823754-52451-3-git-send-email-tiantao6@hisilicon.com> (raw)
In-Reply-To: <1606823754-52451-1-git-send-email-tiantao6@hisilicon.com>

Use the devm_drm_dev_alloc provided by the drm framework to alloc
a struct hibmc_drm_private.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 16 ++++++----------
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h |  2 +-
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index dd9fadc..c5b0b57 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -262,13 +262,6 @@ static int hibmc_load(struct drm_device *dev)
 	struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
 	int ret;
 
-	priv = drmm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		drm_err(dev, "no memory to allocate for hibmc_drm_private\n");
-		return -ENOMEM;
-	}
-	dev->dev_private = priv;
-
 	ret = hibmc_hw_init(priv);
 	if (ret)
 		goto err;
@@ -311,6 +304,7 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
 			   const struct pci_device_id *ent)
 {
 	struct drm_device *dev;
+	struct hibmc_drm_private *priv;
 	int ret;
 
 	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev,
@@ -318,12 +312,14 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
-	dev = drm_dev_alloc(&hibmc_driver, &pdev->dev);
-	if (IS_ERR(dev)) {
+	priv = devm_drm_dev_alloc(&pdev->dev, &hibmc_driver,
+				  struct hibmc_drm_private, dev);
+	if (IS_ERR(priv)) {
 		DRM_ERROR("failed to allocate drm_device\n");
-		return PTR_ERR(dev);
+		return PTR_ERR(priv);
 	}
 
+	dev = &priv->dev;
 	dev->pdev = pdev;
 	pci_set_drvdata(pdev, dev);
 
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index e35353a..7e0c756 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -52,7 +52,7 @@ static inline struct hibmc_connector *to_hibmc_connector(struct drm_connector *c
 
 static inline struct hibmc_drm_private *to_hibmc_drm_private(struct drm_device *dev)
 {
-	return dev->dev_private;
+	return container_of(dev, struct hibmc_drm_private, dev);
 }
 
 void hibmc_set_power_mode(struct hibmc_drm_private *priv,
-- 
2.7.4


  parent reply	other threads:[~2020-12-01 11:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 11:55 [PATCH drm/hisilicon v2 0/4] Add the new api to install irq Tian Tao
2020-12-01 11:55 ` [PATCH drm/hisilicon v2 1/4] drm/hisilicon: Assgin local variable to drm_device Tian Tao
2020-12-01 12:17   ` Thomas Zimmermann
2020-12-01 12:26     ` tiantao (H)
2020-12-01 12:36       ` Thomas Zimmermann
2020-12-01 13:05         ` tiantao (H)
2020-12-01 13:44           ` Thomas Zimmermann
2020-12-02  2:06             ` tiantao (H)
2020-12-02  2:54               ` tiantao (H)
2020-12-02  7:49                 ` Thomas Zimmermann
2020-12-01 11:55 ` Tian Tao [this message]
2020-12-01 11:55 ` [PATCH drm/hisilicon v2 3/4] drm/irq: Add the new api to install irq Tian Tao
2020-12-01 11:55 ` [PATCH drm/hisilicon v2 4/4] drm/hisilicon: Use the new api devm_drm_irq_install Tian Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1606823754-52451-3-git-send-email-tiantao6@hisilicon.com \
    --to=tiantao6@hisilicon.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tzimmermann@suse.de \
    --cc=xinliang.liu@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).