Commit e660916b authored by Hsin-Yi Wang's avatar Hsin-Yi Wang Committed by Robert Foss

drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device()

Simplify the resource management.
Signed-off-by: default avatarHsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: default avatarXin Ji <xji@analogixsemi.com>
Signed-off-by: default avatarRobert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220706125254.2474095-2-hsinyi@chromium.org
parent a204f974
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment