lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220706022926.GA2357796@anxtwsw-Precision-3640-Tower>
Date:   Wed, 6 Jul 2022 10:29:26 +0800
From:   Xin Ji <xji@...logixsemi.com>
To:     Hsin-Yi Wang <hsinyi@...omium.org>
Cc:     Robert Foss <robert.foss@...aro.org>,
        Andrzej Hajda <andrzej.hajda@...el.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Jonas Karlman <jonas@...boo.se>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        Sam Ravnborg <sam@...nborg.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Maxime Ripard <maxime@...no.tech>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] drm/bridge: anx7625: Convert to
 devm_i2c_new_dummy_device()

Hi Hsin-Yi, thanks for your patch, looks good to me.

Reviewed-by: Xin Ji <xji@...logixsemi.com>

On Thu, Jun 30, 2022 at 12:05:47AM +0800, Hsin-Yi Wang wrote:
> Simplify the resource management.
> 
> Signed-off-by: Hsin-Yi Wang <hsinyi@...omium.org>
> ---
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 96 +++++++----------------
>  1 file changed, 27 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 3710fa9ee0acd..f89e8151475f7 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -2436,82 +2436,44 @@ static const struct drm_bridge_funcs anx7625_bridge_funcs = {
>  static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx,
>  					      struct i2c_client *client)
>  {
> -	int err = 0;
> +	struct device *dev = &ctx->client->dev;
>  
> -	ctx->i2c.tx_p0_client = i2c_new_dummy_device(client->adapter,
> -						     TX_P0_ADDR >> 1);
> +	ctx->i2c.tx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						TX_P0_ADDR >> 1);
>  	if (IS_ERR(ctx->i2c.tx_p0_client))
>  		return PTR_ERR(ctx->i2c.tx_p0_client);
>  
> -	ctx->i2c.tx_p1_client = i2c_new_dummy_device(client->adapter,
> -						     TX_P1_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.tx_p1_client)) {
> -		err = PTR_ERR(ctx->i2c.tx_p1_client);
> -		goto free_tx_p0;
> -	}
> +	ctx->i2c.tx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						TX_P1_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.tx_p1_client))
> +		return PTR_ERR(ctx->i2c.tx_p1_client);
>  
> -	ctx->i2c.tx_p2_client = i2c_new_dummy_device(client->adapter,
> -						     TX_P2_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.tx_p2_client)) {
> -		err = PTR_ERR(ctx->i2c.tx_p2_client);
> -		goto free_tx_p1;
> -	}
> +	ctx->i2c.tx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						TX_P2_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.tx_p2_client))
> +		return PTR_ERR(ctx->i2c.tx_p2_client);
>  
> -	ctx->i2c.rx_p0_client = i2c_new_dummy_device(client->adapter,
> -						     RX_P0_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.rx_p0_client)) {
> -		err = PTR_ERR(ctx->i2c.rx_p0_client);
> -		goto free_tx_p2;
> -	}
> +	ctx->i2c.rx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						RX_P0_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.rx_p0_client))
> +		return PTR_ERR(ctx->i2c.rx_p0_client);
>  
> -	ctx->i2c.rx_p1_client = i2c_new_dummy_device(client->adapter,
> -						     RX_P1_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.rx_p1_client)) {
> -		err = PTR_ERR(ctx->i2c.rx_p1_client);
> -		goto free_rx_p0;
> -	}
> +	ctx->i2c.rx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						RX_P1_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.rx_p1_client))
> +		return PTR_ERR(ctx->i2c.rx_p1_client);
>  
> -	ctx->i2c.rx_p2_client = i2c_new_dummy_device(client->adapter,
> -						     RX_P2_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.rx_p2_client)) {
> -		err = PTR_ERR(ctx->i2c.rx_p2_client);
> -		goto free_rx_p1;
> -	}
> +	ctx->i2c.rx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						RX_P2_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.rx_p2_client))
> +		return PTR_ERR(ctx->i2c.rx_p2_client);
>  
> -	ctx->i2c.tcpc_client = i2c_new_dummy_device(client->adapter,
> -						    TCPC_INTERFACE_ADDR >> 1);
> -	if (IS_ERR(ctx->i2c.tcpc_client)) {
> -		err = PTR_ERR(ctx->i2c.tcpc_client);
> -		goto free_rx_p2;
> -	}
> +	ctx->i2c.tcpc_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +						TCPC_INTERFACE_ADDR >> 1);
> +	if (IS_ERR(ctx->i2c.tcpc_client))
> +		return PTR_ERR(ctx->i2c.tcpc_client);
>  
>  	return 0;
> -
> -free_rx_p2:
> -	i2c_unregister_device(ctx->i2c.rx_p2_client);
> -free_rx_p1:
> -	i2c_unregister_device(ctx->i2c.rx_p1_client);
> -free_rx_p0:
> -	i2c_unregister_device(ctx->i2c.rx_p0_client);
> -free_tx_p2:
> -	i2c_unregister_device(ctx->i2c.tx_p2_client);
> -free_tx_p1:
> -	i2c_unregister_device(ctx->i2c.tx_p1_client);
> -free_tx_p0:
> -	i2c_unregister_device(ctx->i2c.tx_p0_client);
> -
> -	return err;
> -}
> -
> -static void anx7625_unregister_i2c_dummy_clients(struct anx7625_data *ctx)
> -{
> -	i2c_unregister_device(ctx->i2c.tx_p0_client);
> -	i2c_unregister_device(ctx->i2c.tx_p1_client);
> -	i2c_unregister_device(ctx->i2c.tx_p2_client);
> -	i2c_unregister_device(ctx->i2c.rx_p0_client);
> -	i2c_unregister_device(ctx->i2c.rx_p1_client);
> -	i2c_unregister_device(ctx->i2c.rx_p2_client);
> -	i2c_unregister_device(ctx->i2c.tcpc_client);
>  }
>  
>  static int __maybe_unused anx7625_runtime_pm_suspend(struct device *dev)
> @@ -2723,8 +2685,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
>  	if (!platform->pdata.low_power_mode)
>  		pm_runtime_put_sync_suspend(&client->dev);
>  
> -	anx7625_unregister_i2c_dummy_clients(platform);
> -
>  free_wq:
>  	if (platform->workqueue)
>  		destroy_workqueue(platform->workqueue);
> @@ -2754,8 +2714,6 @@ static int anx7625_i2c_remove(struct i2c_client *client)
>  	if (!platform->pdata.low_power_mode)
>  		pm_runtime_put_sync_suspend(&client->dev);
>  
> -	anx7625_unregister_i2c_dummy_clients(platform);
> -
>  	if (platform->pdata.audio_en)
>  		anx7625_unregister_audio(platform);
>  
> -- 
> 2.37.0.rc0.161.g10f37bed90-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ