[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220629160550.433980-2-hsinyi@chromium.org>
Date: Thu, 30 Jun 2022 00:05:47 +0800
From: Hsin-Yi Wang <hsinyi@...omium.org>
To: Robert Foss <robert.foss@...aro.org>, Xin Ji <xji@...logixsemi.com>
Cc: 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: [PATCH 1/4] drm/bridge: anx7625: Convert to devm_i2c_new_dummy_device()
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