[PATCH 1/4] drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device()
Robert Foss
robert.foss at linaro.org
Wed Jul 6 12:31:21 UTC 2022
Hey Hsin-Yi,
On Wed, 6 Jul 2022 at 04:29, Xin Ji <xji at analogixsemi.com> wrote:
>
> Hi Hsin-Yi, thanks for your patch, looks good to me.
>
> Reviewed-by: Xin Ji <xji at analogixsemi.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 at chromium.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
Can you fix the checkpatch --strict warnings and formatting issues in
this series?
More information about the dri-devel
mailing list