Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp182280ybb; Fri, 3 Apr 2020 00:14:06 -0700 (PDT) X-Google-Smtp-Source: APiQypIfulSyt+shfu+ouXe+euB7wRQgZob0IP1VzZeryRylkI4+0cAkrTYC3B4oABZy4qCa5KEg X-Received: by 2002:a9d:132:: with SMTP id 47mr5154526otu.142.1585898045803; Fri, 03 Apr 2020 00:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585898045; cv=none; d=google.com; s=arc-20160816; b=kYhXdn9QL9KJ4n4hDM8t+Dppa25KBQl/il1jfWg0hJjOyqnZbLK/BlJ+k/TYlW+R+B RmdMPBN36UJJKMQHJZTxBr6URCJgx9wvlRJoz8Kc1sU7leIQkmGdGBNlwsuMoJ0yvq0L lfH0aAYmZ+7kaaBXmnIuSn0SmwLkK38znrkXGNIWRI8jvd0sCWGVpReEGfx/PvpljPpA /MLntZs9iFc5Q7cgWl8pXt5+H4aIGuJ8U9SnFuXZsypCdrY2j3wJCRvouVe3NwBfY/he S9OFuY2+RqoFG4gs8xYQEDnyDRf5SK6xOQ0p4Y3slyFSqxN2NHtXQK9kB9eXdEHl34gF gVEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=iTvIwaUEXvfuOKYIWGjHdv4ZNok0r2ezSZPZ9Nr5hxM=; b=Agd7pdo8j0CHES7mYOdke9JnfeAkknc+JpJNv15LkLI/379lGsbuM8PAPK4hue1Qac oXbGh+JNpZo+lWrDF9pgWsnNIb4Uu1eJFQjYc9uLBEzw4kOR4yBGMi7CoGNo9zINMxwh hGMeU+IaMTapt79bI2/ha7eYNbTOo7EuwCso9xiETzxMbKZ1c13SBg1x10RvHdxrrmKa vQVa2orzlic/jQQq1qvyODkUE1gHmE1vbZKX88FJGSp9EBUynHIvCun4563PTGIvsc1H Nkp8g3ypBEAM61vvdrKAynGia8KEPcwrfqcRGbLJScpNd3n+RJz0YS4b1ibqJlCsZHJg qg1w== 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 p2si3707056otk.220.2020.04.03.00.13.51; Fri, 03 Apr 2020 00:14:05 -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 S2387677AbgDCHAa (ORCPT + 99 others); Fri, 3 Apr 2020 03:00:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:56654 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730759AbgDCHAa (ORCPT ); Fri, 3 Apr 2020 03:00:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D9D00ADC1; Fri, 3 Apr 2020 07:00:22 +0000 (UTC) Subject: Re: [PATCH 2/4] drm/hisilicon: Code cleanup for hibmc_drv_vdac To: Xinliang Liu , Tian Tao Cc: David Airlie , Chen Feng , lkml , dri-devel , linuxarm@huawei.com, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de References: <1583466184-7060-1-git-send-email-tiantao6@hisilicon.com> <1583466184-7060-5-git-send-email-tiantao6@hisilicon.com> From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= mQENBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURin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kgqTqwmaYzsl8UxZKvbaxq0zb ehDda8lvhFXodNFMAgTLJlLuDYOGLK2AwbrS3Sp0AEbkpdJBb44qVlGm5bApZouHeJ/+n+7r 12+lqdsAEQEAAYkBPAQYAQgAJhYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJbOdLgAhsMBQkD wmcAAAoJEGgNwR1TC3ojpfcIAInwP5OlcEKokTnHCiDTz4Ony4GnHRP2fXATQZCKxmu4AJY2 h9ifw9Nf2TjCZ6AMvC3thAN0rFDj55N9l4s1CpaDo4J+0fkrHuyNacnT206CeJV1E7NYntxU n+LSiRrOdywn6erjxRi9EYTVLCHcDhBEjKmFZfg4AM4GZMWX1lg0+eHbd5oL1as28WvvI/uI aMyV8RbyXot1r/8QLlWldU3NrTF5p7TMU2y3ZH2mf5suSKHAMtbE4jKJ8ZHFOo3GhLgjVrBW HE9JXO08xKkgD+w6v83+nomsEuf6C6LYrqY/tsZvyEX6zN8CtirPdPWu/VXNRYAl/lat7lSI 3H26qrE= Message-ID: <07040b3e-9137-10ef-9a18-381b0316fef9@suse.de> Date: Fri, 3 Apr 2020 09:00:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ZpAQgr4rgKRsm2Dtw09BFyu364lHgxHz7" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ZpAQgr4rgKRsm2Dtw09BFyu364lHgxHz7 Content-Type: multipart/mixed; boundary="KvchZNwh6Mib540wOsZ1oZ0hUXcq6lXYi"; protected-headers="v1" From: Thomas Zimmermann To: Xinliang Liu , Tian Tao Cc: David Airlie , Chen Feng , lkml , dri-devel , linuxarm@huawei.com, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de Message-ID: <07040b3e-9137-10ef-9a18-381b0316fef9@suse.de> Subject: Re: [PATCH 2/4] drm/hisilicon: Code cleanup for hibmc_drv_vdac References: <1583466184-7060-1-git-send-email-tiantao6@hisilicon.com> <1583466184-7060-5-git-send-email-tiantao6@hisilicon.com> In-Reply-To: --KvchZNwh6Mib540wOsZ1oZ0hUXcq6lXYi Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 03.04.20 um 04:26 schrieb Xinliang Liu: > Hi Tao, >=20 > On Fri, 6 Mar 2020 at 11:44, Tian Tao wrote: >> >> code cleanup for hibmc_drv_vdac.c, no actual function changes. >> >> Signed-off-by: Tian Tao >> Signed-off-by: Gong junjie >> --- >> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 49 ++++++++-------= --------- >> 1 file changed, 16 insertions(+), 33 deletions(-) >> >> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/driver= s/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c >> index 678ac2e..f0e6bb8 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_conne= ctor_funcs =3D { >> .atomic_destroy_state =3D drm_atomic_helper_connector_destroy_= state, >> }; >> >> -static struct drm_connector * >> -hibmc_connector_init(struct hibmc_drm_private *priv) >> -{ >> - struct drm_device *dev =3D priv->dev; >> - struct drm_connector *connector; >> - int ret; >> - >> - connector =3D devm_kzalloc(dev->dev, sizeof(*connector), GFP_K= ERNEL); >> - if (!connector) { >> - DRM_ERROR("failed to alloc memory when init connector\= n"); >> - return ERR_PTR(-ENOMEM); >> - } >> - >> - ret =3D 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 =3D hibmc_connector_init(priv); >> - if (IS_ERR(connector)) { >> - DRM_ERROR("failed to create connector: %ld\n", >> - PTR_ERR(connector)); >> - return PTR_ERR(connector); >> - } >> - >> encoder =3D devm_kzalloc(dev->dev, sizeof(*encoder), GFP_KERNE= L); >> if (!encoder) { >> DRM_ERROR("failed to alloc memory when init encoder\n"= ); >> @@ -131,6 +98,22 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv= ) >> } >> >> drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); >> + connector =3D devm_kzalloc(dev->dev, sizeof(*connector), GFP_K= ERNEL); >> + if (!connector) { >> + DRM_ERROR("failed to alloc memory when init connector\= n"); >> + return -ENOMEM; >> + } >> + >> + ret =3D 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_fu= ncs); >> + drm_connector_register(connector); >=20 > You don't need to register a non-hotplug connector as it will be > registered at drm_dev_register automatically. >=20 > See function definition: >=20 > 488 /** > 489 * drm_connector_register - register a connector > 490 * @connector: the connector to register > 491 * > 492 * Register userspace interfaces for a connector. Only call this > for connectors > 493 * which can be hotplugged after drm_dev_register() has been > called already, > 494 * e.g. DP MST connectors. All other connectors will be > registered automatically > 495 * when calling drm_dev_register(). > 496 * > 497 * Returns: > 498 * Zero on success, error code on failure. > 499 */ > 500 int drm_connector_register(struct drm_connector *connector) > 501 { >=20 >=20 > Besides, I don't think this patch cleans much things. True. Although the auto-kfree of devm_kzalloc() does not work correctly with DRM and should be replaced. I'd like to suggest to either allocate the connector as part of struct hibmc_drm_private, or implement drmm_connector_create() on top of DRM's new auto-cleanup functionality. Best regards Thomas >=20 > -Xinliang >=20 >> drm_connector_attach_encoder(connector, encoder); >> >> return 0; >> -- >> 2.7.4 >> > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany (HRB 36809, AG N=C3=BCrnberg) Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --KvchZNwh6Mib540wOsZ1oZ0hUXcq6lXYi-- --ZpAQgr4rgKRsm2Dtw09BFyu364lHgxHz7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl6G3wUACgkQaA3BHVML eiNy5wf+KuQNqGhClWLXXkwbsBxccUKZ2CknoocZyuQJoB2VzYt2xA5fG/arWnP4 rJSYX6gD7O+cPvRSrv4Lr8mmI5fe1iWhoRYYV4V5EBnUJA/QfD/dXc+U4RaKh6wx 4PKWLLBR8j8HonHcbHgHtOOlk+1nS6MS7Ly0kcvHXaShs09zbHsGKHflbISXYoPn j1HD/hk956fjbZBEFulrmJ4EXs4mLGA4frwV1l9HAgFvn4HiRS8sv2HnUUwslOGk MDawolF853coMHFiqtvrUPYeYWtuGfWehtmfzEYsHjnoUi9RnxvRbbKiT/k8ZF9j 8XqLslQdh4MA0tCXTQYRyu5MYN3YLg== =i+iM -----END PGP SIGNATURE----- --ZpAQgr4rgKRsm2Dtw09BFyu364lHgxHz7--