[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YpjHLN2U8DOh9NLH@pendragon.ideasonboard.com>
Date: Thu, 2 Jun 2022 17:20:28 +0300
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc: andrzej.hajda@...el.com, narmstrong@...libre.com,
robert.foss@...aro.org, jonas@...boo.se, jernej.skrabec@...il.com,
airlied@...ux.ie, daniel@...ll.ch, maxime@...no.tech,
sam@...nborg.org, alsi@...g-olufsen.dk, jagan@...rulasolutions.com,
biju.das.jz@...renesas.com, l.stach@...gutronix.de,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] drm: bridge: adv7511: Add check for
mipi_dsi_driver_register
Hi Jiasheng,
Thank you for the patch.
On Thu, Jun 02, 2022 at 06:34:01PM +0800, Jiasheng Jiang wrote:
> As mipi_dsi_driver_register could return error if fails,
> it should be better to check the return value and return error
> if fails.
> Moreover, if i2c_add_driver fails, mipi_dsi_driver_register
> should be reverted.
>
> Fixes: 1e4d58cd7f88 ("drm/bridge: adv7533: Create a MIPI DSI device")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
> ---
> Changelog:
>
> v1 -> v2
>
> *Change 1. Add the mipi_dsi_driver_unregister if i2c_add_driver fails.
> ---
> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index 5bb9300040dd..2275d15d4a8b 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -1392,10 +1392,21 @@ static struct i2c_driver adv7511_driver = {
>
> static int __init adv7511_init(void)
> {
> - if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
> - mipi_dsi_driver_register(&adv7533_dsi_driver);
> + int ret;
> +
> + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
> + ret = mipi_dsi_driver_register(&adv7533_dsi_driver);
> + if (ret)
> + return ret;
> + }
>
> - return i2c_add_driver(&adv7511_driver);
> + ret = i2c_add_driver(&adv7511_driver);
> + if (ret) {
> + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
> + mipi_dsi_driver_unregister(&adv7533_dsi_driver);
> + }
> +
> + return ret;
> }
> module_init(adv7511_init);
>
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists