[v2,03/28] drm/bridge/analogix: Use drm_bridge_init()
diff mbox series

Message ID 20191204114732.28514-4-mihail.atanassov@arm.com
State New
Headers show
Series
  • drm/bridge: Consolidate initialization
Related show

Commit Message

Mihail Atanassov Dec. 4, 2019, 11:48 a.m. UTC
No functional change.

The setting of bridge->of_node by drm_bridge_init() in
analogix_dp_core.c is safe, since ->of_node isn't used directly and the
bridge isn't published with drm_bridge_add().

Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
---
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 5 ++---
 drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 8 ++------
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 ++---
 3 files changed, 6 insertions(+), 12 deletions(-)

Comments

Laurent Pinchart Dec. 5, 2019, 1:29 p.m. UTC | #1
On Wed, Dec 04, 2019 at 11:48:04AM +0000, Mihail Atanassov wrote:
> No functional change.
> 
> The setting of bridge->of_node by drm_bridge_init() in
> analogix_dp_core.c is safe, since ->of_node isn't used directly and the
> bridge isn't published with drm_bridge_add().

Still, it's not the right device, is it ? And if we later extend the
usage of dev in drm_bridge_init() it could cause issues. I think you
should use the right device pointer.

> 
> Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 5 ++---
>  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 8 ++------
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 ++---
>  3 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index b4f3a923a52a..130d5c3a07ef 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -696,8 +696,6 @@ static int anx6345_i2c_probe(struct i2c_client *client,
>  
>  	mutex_init(&anx6345->lock);
>  
> -	anx6345->bridge.of_node = client->dev.of_node;
> -
>  	anx6345->client = client;
>  	i2c_set_clientdata(client, anx6345);
>  
> @@ -760,7 +758,8 @@ static int anx6345_i2c_probe(struct i2c_client *client,
>  	/* Look for supported chip ID */
>  	anx6345_poweron(anx6345);
>  	if (anx6345_get_chip_id(anx6345)) {
> -		anx6345->bridge.funcs = &anx6345_bridge_funcs;
> +		drm_bridge_init(&anx6345->bridge, &client->dev,
> +				&anx6345_bridge_funcs, NULL, NULL);
>  		drm_bridge_add(&anx6345->bridge);
>  
>  		return 0;
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index 41867be03751..e37892cdc9cf 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -1214,10 +1214,6 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
>  
>  	mutex_init(&anx78xx->lock);
>  
> -#if IS_ENABLED(CONFIG_OF)
> -	anx78xx->bridge.of_node = client->dev.of_node;
> -#endif
> -
>  	anx78xx->client = client;
>  	i2c_set_clientdata(client, anx78xx);
>  
> @@ -1321,8 +1317,8 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
>  		goto err_poweroff;
>  	}
>  
> -	anx78xx->bridge.funcs = &anx78xx_bridge_funcs;
> -
> +	drm_bridge_init(&anx78xx->bridge, &client->dev, &anx78xx_bridge_funcs,
> +			NULL, NULL);
>  	drm_bridge_add(&anx78xx->bridge);
>  
>  	/* If cable is pulled out, just poweroff and wait for HPD event */
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index bb411fe52ae8..4042ba9a98d8 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1585,9 +1585,8 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
>  
>  	dp->bridge = bridge;
>  
> -	bridge->driver_private = dp;
> -	bridge->funcs = &analogix_dp_bridge_funcs;
> -
> +	drm_bridge_init(bridge, drm_dev->dev, &analogix_dp_bridge_funcs,
> +			NULL, dp);
>  	ret = drm_bridge_attach(dp->encoder, bridge, NULL);
>  	if (ret) {
>  		DRM_ERROR("failed to attach drm bridge\n");

Patch
diff mbox series

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index b4f3a923a52a..130d5c3a07ef 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -696,8 +696,6 @@  static int anx6345_i2c_probe(struct i2c_client *client,
 
 	mutex_init(&anx6345->lock);
 
-	anx6345->bridge.of_node = client->dev.of_node;
-
 	anx6345->client = client;
 	i2c_set_clientdata(client, anx6345);
 
@@ -760,7 +758,8 @@  static int anx6345_i2c_probe(struct i2c_client *client,
 	/* Look for supported chip ID */
 	anx6345_poweron(anx6345);
 	if (anx6345_get_chip_id(anx6345)) {
-		anx6345->bridge.funcs = &anx6345_bridge_funcs;
+		drm_bridge_init(&anx6345->bridge, &client->dev,
+				&anx6345_bridge_funcs, NULL, NULL);
 		drm_bridge_add(&anx6345->bridge);
 
 		return 0;
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
index 41867be03751..e37892cdc9cf 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
@@ -1214,10 +1214,6 @@  static int anx78xx_i2c_probe(struct i2c_client *client,
 
 	mutex_init(&anx78xx->lock);
 
-#if IS_ENABLED(CONFIG_OF)
-	anx78xx->bridge.of_node = client->dev.of_node;
-#endif
-
 	anx78xx->client = client;
 	i2c_set_clientdata(client, anx78xx);
 
@@ -1321,8 +1317,8 @@  static int anx78xx_i2c_probe(struct i2c_client *client,
 		goto err_poweroff;
 	}
 
-	anx78xx->bridge.funcs = &anx78xx_bridge_funcs;
-
+	drm_bridge_init(&anx78xx->bridge, &client->dev, &anx78xx_bridge_funcs,
+			NULL, NULL);
 	drm_bridge_add(&anx78xx->bridge);
 
 	/* If cable is pulled out, just poweroff and wait for HPD event */
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index bb411fe52ae8..4042ba9a98d8 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1585,9 +1585,8 @@  static int analogix_dp_create_bridge(struct drm_device *drm_dev,
 
 	dp->bridge = bridge;
 
-	bridge->driver_private = dp;
-	bridge->funcs = &analogix_dp_bridge_funcs;
-
+	drm_bridge_init(bridge, drm_dev->dev, &analogix_dp_bridge_funcs,
+			NULL, dp);
 	ret = drm_bridge_attach(dp->encoder, bridge, NULL);
 	if (ret) {
 		DRM_ERROR("failed to attach drm bridge\n");