Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4392467pxu; Tue, 1 Dec 2020 04:00:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxn27jTzn2qkWlQWnxVjQw07GtEzRl2ekvcbZwQBsirGLRN/EAiVhau+VHpPqfvzIqen46F X-Received: by 2002:a50:e803:: with SMTP id e3mr2626711edn.249.1606824004172; Tue, 01 Dec 2020 04:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606824004; cv=none; d=google.com; s=arc-20160816; b=UR3rGBHsRYMHdOfMsT6ttuL00A39bk1qq0YjDkw1OefjVFPQJbpnfZG+sVamsU8nEW p6uXpSpR4iozrR6yMA9w59ydSHQHGW8dvvXGdJIBAHmB+0227thsn0MGa9p0bQ9tK/z8 gQxIAAWF480OwnDUYbYs1ZjuK3PlW9/khgCSgtFNfMKcrkmtt+3gvjFKlFBeR2xlbckd YndlEr73wQz0Ye+5xfDiWvna6AtrirhYpimTPvhYU7Rxvo/Sc75H8lQxIq842u3IfEBt VHB8i71eV+P84DiWA7uyhpOUG44EWpVqIlsVicryEqV0sX421vJSfKy8iwLka5BIG3H7 YCYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kByRk0ZGU4fsmlAaCypjo2uIe4cGO/03N+M2xh183+s=; b=RwmbXZpnv3pDuD6tiFqQ3NqEA8yhslAkT0EMtljcSVJG8WmrRo6KRemVctS7WwwFNa KcBPYMAkrXEoEa1qLehN4yaERI3T3bhN8wD7WxD5L4Go13pCgCLPTD4ocjjiUAZtzhtA XXipMP4LeCN7oPc2OaRmDfDR4f6HzWmvtt+T4LQ+ra3T55elXzgE3qqa2tDu4LNAIkyL rLnd1CFwDeL4Va3/bI7SmcPKYf8Ztn3PIuKcFKwQQuUR/bMA2S1ljowAx4Oi+VsTkXa3 x7uO0Lbp5h4JzTD6sa0y5X5jSDwHCgj12HQ7VW+syTbP7a5/VL3fKTy39UlctXQcuKgP TD6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf17si764694ejb.338.2020.12.01.03.59.41; Tue, 01 Dec 2020 04:00:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbgLAL40 (ORCPT + 99 others); Tue, 1 Dec 2020 06:56:26 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8172 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgLAL40 (ORCPT ); Tue, 1 Dec 2020 06:56:26 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4ClgX43lcNz15VbT; Tue, 1 Dec 2020 19:55:16 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Dec 2020 19:55:37 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH drm/hisilicon v2 2/4] drm/hisilicon: Code refactoring for hibmc_drm_drv Date: Tue, 1 Dec 2020 19:55:52 +0800 Message-ID: <1606823754-52451-3-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606823754-52451-1-git-send-email-tiantao6@hisilicon.com> References: <1606823754-52451-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the devm_drm_dev_alloc provided by the drm framework to alloc a struct hibmc_drm_private. Signed-off-by: Tian Tao --- 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