Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1295869ybb; Fri, 10 Apr 2020 23:28:46 -0700 (PDT) X-Google-Smtp-Source: APiQypIER4xDH1KjaBcmDEhwo2AeVzWBrujmsCsh8kKvHsJhuKlwyjCBO14+artgi96LUmDM5aKw X-Received: by 2002:ac8:38f1:: with SMTP id g46mr2256547qtc.212.1586586526289; Fri, 10 Apr 2020 23:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586586526; cv=none; d=google.com; s=arc-20160816; b=gkqymn3jMWxoxMecAiHNnx5wV9oZHlckWegtgoGQJeskOaC56yDj17vQc+ufEs1YUv xpu9XDMxwCZBeMF/VrVPbGl/ZB7+dvbCoMO81emTqQsD2QFNgxksew/PW1YCAJnojnMU GkIc3Bw3jeGF0YZhbLBckJXUeZi+LRsYdOfgInmOx1YielK4qICXRX4YzUdOVDY9BdSI 7FaVMG4wyi0hQX1zaX4CSx3BEU0fCgs6zRxnF/fsD2/mlQTWfY14dbBNA8xhH5ebrOrP JxU4ZNOlvQ912/hz5pIApl4wd9vZRJUdbDdpUOSWvnRXkb16+M0qupfSeQ3UxiVXDAoN q9Ww== 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=2DBybOvg0j4/WGSIsneeg01OR+TLdEvjbFBL6xjrT9g=; b=PeUvAIxBjj2VuNCaW4q9pugn9WQWhTy+JnNhJZKoxxRLBP+8KbP0Bxii1RspXRk2+p mgauIM/qS96ZlmeEXMdlp/uIl+06RKCXQrd6KLlHOFjmP/XAmu2OUakYrZ3z/W9DKh+l 7xXZxIAZb1jo6GH4RhTzSPlmPV+ldzGmRakpCp3/Lgn1SJpTC4Dv2OIzfeIEcw9MNibd oA1P+2YZTNU2IyNZT+ZXizUisvmHpEGDTawM8Fi4ai9czPna3VpG6y/w8bzGDiODiXeA e73mE5B6OXVvvKJYpxaqejN9UN9LgHrKXPyMPSYB7rj/0YBExjcrDRKr4FF+Od2cr7eh 7/6A== 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 70si2614362qkk.278.2020.04.10.23.28.19; Fri, 10 Apr 2020 23:28:46 -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 S1725901AbgDKG0R (ORCPT + 99 others); Sat, 11 Apr 2020 02:26:17 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36264 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725855AbgDKG0R (ORCPT ); Sat, 11 Apr 2020 02:26:17 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A4E5B11C0BFD9F02F034; Sat, 11 Apr 2020 14:26:13 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Sat, 11 Apr 2020 14:26:04 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH v2] drm/hisilicon: Code refactoring for hibmc_drv_vdac Date: Sat, 11 Apr 2020 14:25:15 +0800 Message-ID: <1586586315-12764-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. v2: remove the debug message. Signed-off-by: Tian Tao Reviewed-by: Joe Perches --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 50 +++++++----------------- 1 file changed, 14 insertions(+), 36 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..077b7996 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,18 +83,9 @@ 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"); + if (!encoder) return -ENOMEM; - } encoder->possible_crtcs = 0x1; ret = drm_encoder_init(dev, encoder, &hibmc_encoder_funcs, @@ -131,6 +96,19 @@ 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) + 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