hi gouhao:
 
这个补丁删除了hibmc_connector_init使用点,导致hibmc_connector_init函数申明但无使用点告警。

同时注意到本patch部分代码在主线通过 be8c8403f63cf ("drm/hisilicon: Code refactoring for hibmc_drv_vdac")

合入,因此希望能够直接将该patch作为本patch的前向补丁一起合入。
 
best regard

>>>>>>>>>>>>>>>>>>>>>>>>>> [WARNING] build_arm64_kabi <<<<<<<<<<<<<<<<<<<<<<<<<<

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig && make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c:125:1: warning: ‘hibmc_connector_init’ defined but not used [-Wunused-function]
 hibmc_connector_init(struct hibmc_drm_private *priv)
 ^~~~~~~~~~~~~~~~~~~~

==================================END==================================

On 2021/9/18 11:11, Gou Hao wrote:

From: Tian Tao <tiantao6(a)hisilicon.com&gt; mainline inclusion from mainline-v5.14.0-rc7 commit a0d078d06e516184e2f575f3803935697b5e3ac6 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I469VQ CVE: NA The modification of hibmc_vdac_init in the original patch cannot be incorporated. In this patch, the hibmc_vdac_init is backport from the mainline code. --------------------------------------- Use drm_get_edid to get the resolution, if that fails, set it to a fixed resolution. Rewrite the desrtoy callback function to release resources. Signed-off-by: Tian Tao <tiantao6(a)hisilicon.com&gt; Reviewed-by: Thomas Zimmermann <tzimmermann(a)suse.de&gt; Link: https://patchwork.freedesktop.org/patch/msgid/1600778670-60370-3-git-send... Signed-off-by: gouhao <gouhao(a)uniontech.com&gt; --- .../gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 55 ++++++++++++++----- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c index 90319a902..762e3404e 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -59,11 +59,23 @@ static int hibmc_valid_mode(int w, int h) static int hibmc_connector_get_modes(struct drm_connector *connector) { int count; + void *edid; + struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector); + + edid = drm_get_edid(connector, &hibmc_connector->adapter); + if (edid) { + drm_connector_update_edid_property(connector, edid); + count = drm_add_edid_modes(connector, edid); + if (count) + goto out; + } drm_connector_update_edid_property(connector, NULL); count = drm_add_modes_noedid(connector, 1920, 1200); drm_set_preferred_mode(connector, 1024, 768); +out: + kfree(edid); return count; } @@ -86,6 +98,14 @@ hibmc_connector_best_encoder(struct drm_connector *connector) return drm_encoder_find(connector->dev, NULL, connector->encoder_ids[0]); } +static void hibmc_connector_destroy(struct drm_connector *connector) +{ + struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector); + + i2c_del_adapter(&hibmc_connector->adapter); + drm_connector_cleanup(connector); +} + static const struct drm_connector_helper_funcs hibmc_connector_helper_funcs = { .get_modes = hibmc_connector_get_modes, @@ -95,7 +115,7 @@ static const struct drm_connector_helper_funcs static const struct drm_connector_funcs hibmc_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, + .destroy = hibmc_connector_destroy, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, @@ -155,21 +175,16 @@ static const struct drm_encoder_funcs hibmc_encoder_funcs = { int hibmc_vdac_init(struct hibmc_drm_private *priv) { struct drm_device *dev = priv->dev; - struct drm_encoder *encoder; - struct drm_connector *connector; + struct hibmc_connector *hibmc_connector = &priv->connector; + struct drm_encoder *encoder = &priv->encoder; + struct drm_connector *connector = &hibmc_connector->base; int ret; - connector = hibmc_connector_init(priv);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^
删除后 导致hibmc_connector_init函数申明但无使用点告警。

- 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"); - return -ENOMEM; + + ret = hibmc_ddc_create(dev, hibmc_connector); + if (ret) { + DRM_ERROR("failed to create ddc: %d\n", ret); + return ret; } encoder->possible_crtcs = 0x1; @@ -181,6 +196,18 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) } drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); + + ret = drm_connector_init_with_ddc(dev, connector, + &hibmc_connector_funcs, + DRM_MODE_CONNECTOR_VGA, + &hibmc_connector->adapter); + 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.20.1