Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1183227ybb; Fri, 10 Apr 2020 19:53:11 -0700 (PDT) X-Google-Smtp-Source: APiQypLWPxhSoGLrQUepr5ku1ILWvuruHBqBJfzWedPql2hip3EdPi6MnTSQYqBaV6nC1FslYAAS X-Received: by 2002:ac8:6d01:: with SMTP id o1mr2056501qtt.246.1586573591508; Fri, 10 Apr 2020 19:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586573591; cv=none; d=google.com; s=arc-20160816; b=KctQ8wgKVGLwdjXEbFhLsxhZroRiwd1PrZHx4P/ybkTWkP6pnMU+FNSRCZT08mB/PI fJeSqe4YEsAznqlyDrB912l8o/ZcMZJFbw16gkP2q6PoHHexSTBKAhw3fqKipkHT5NEL DdokulX7gi2yZbYp6/QrKGRUrgFft7FZv1hOdO9MNmaUPhbbUO6nZPP2HdtFIkJ2ITCS n/cC0ka7U9NwR1mw1ga973cSIhTCY83MuPwJ8msYrvmAM7vUeZOaKWpepONAAy7HAvqm Cq8qiLFhgYV9h/MZfpHD3BTtJsxgZVinMQWtFx9vhOsVQ8Pcu/kN+GQPHZUcSib1tXza SvCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=ufndL4Lag1JNfT8qBn+40MyMPY+DYJeOrbhK4z3I7dE=; b=O9KRycjR7YHdMPxmCeSMElcF7YEboJaIV7twOQiVPPoFmbhfucV8fU6NDDBF5cUhCV ClbJsXHy80hyAHgUKVoRxl5lIDkDsOmvIKnWHRH0b6wTjXH2Ni1cDm96V8oMJpcQSven 7VrbE1xkoSxc9azOEa+5ZX+Y5DCImz4GrNg5aXFVFISxmyDZaf86Op4Gl4NeH03Q+qzP R7nDmkP8S29ZO+wqgepSN14nhL8ARIlSkzHzWn/n2hGkAsqnwynFofgtcTTGKR9JKXoj Y8aCIkSCzqfi1NwX2lCNJV32e4jXh8H/S3DoYJYfcsmwcWOI+N7yKyRFWydlw40vwYJJ DMyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si2058641qti.229.2020.04.10.19.52.57; Fri, 10 Apr 2020 19:53:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbgDKCuo (ORCPT + 99 others); Fri, 10 Apr 2020 22:50:44 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:12644 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726650AbgDKCuo (ORCPT ); Fri, 10 Apr 2020 22:50:44 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 51D0EEDB1F23B09CDA7E; Sat, 11 Apr 2020 10:50:43 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Sat, 11 Apr 2020 10:50:35 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH] drm/hisilicon: Code refactoring for hibmc_drv_vdac Date: Sat, 11 Apr 2020 10:49:47 +0800 Message-ID: <1586573387-42003-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org code refactoring for hibmc_drv_vdac.c, no actual function changes. Signed-off-by: Tian Tao --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 48 ++++++++---------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c index 678ac2e..d56c5d4 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -52,32 +52,6 @@ static const struct drm_connector_funcs hibmc_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static struct drm_connector * -hibmc_connector_init(struct hibmc_drm_private *priv) -{ - struct drm_device *dev = priv->dev; - struct drm_connector *connector; - int ret; - - connector = devm_kzalloc(dev->dev, sizeof(*connector), GFP_KERNEL); - if (!connector) { - DRM_ERROR("failed to alloc memory when init connector\n"); - return ERR_PTR(-ENOMEM); - } - - ret = drm_connector_init(dev, connector, - &hibmc_connector_funcs, - DRM_MODE_CONNECTOR_VGA); - if (ret) { - DRM_ERROR("failed to init connector: %d\n", ret); - return ERR_PTR(ret); - } - drm_connector_helper_add(connector, - &hibmc_connector_helper_funcs); - - return connector; -} - static void hibmc_encoder_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adj_mode) @@ -109,13 +83,6 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) struct drm_connector *connector; int ret; - connector = hibmc_connector_init(priv); - if (IS_ERR(connector)) { - DRM_ERROR("failed to create connector: %ld\n", - PTR_ERR(connector)); - return PTR_ERR(connector); - } - encoder = devm_kzalloc(dev->dev, sizeof(*encoder), GFP_KERNEL); if (!encoder) { DRM_ERROR("failed to alloc memory when init encoder\n"); @@ -131,6 +98,21 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) } drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); + + connector = devm_kzalloc(dev->dev, sizeof(*connector), GFP_KERNEL); + if (!connector) { + DRM_ERROR("failed to alloc memory when init connector\n"); + return -ENOMEM; + } + + ret = drm_connector_init(dev, connector, &hibmc_connector_funcs, + DRM_MODE_CONNECTOR_VGA); + if (ret) { + DRM_ERROR("failed to init connector: %d\n", ret); + return ret; + } + drm_connector_helper_add(connector, &hibmc_connector_helper_funcs); + drm_connector_attach_encoder(connector, encoder); return 0; -- 2.7.4