[PATCH] drm: encoder_slave: Remove unused encoder functions

linux@treblig.org posted 1 patch 1 month ago
drivers/gpu/drm/drm_encoder_slave.c | 26 --------------------------
include/drm/drm_encoder_slave.h     | 11 ++---------
2 files changed, 2 insertions(+), 35 deletions(-)
[PATCH] drm: encoder_slave: Remove unused encoder functions
Posted by linux@treblig.org 1 month ago
From: "Dr. David Alan Gilbert" <linux@treblig.org>

drm_i2c_encoder_commit(), drm_i2c_encoder_mode_set() and
drm_i2c_encoder_prepare() have been unused since 2016's
commit 7bc61cc5df80 ("drm/arcpgu: Accommodate adv7511 switch to DRM
bridge").

Remove them.
That change makes drm_i2c_encoder_dpms() unused.
Remove it.

Remove the comments about those functions wrapping a couple of
pointers in drm_encoder_slave_funcs.  I can see sil164, ch7006, and nv17
set those fields, and I can see some nouveau code that calls them
directly; so i don't think we can remove the fields.
(Although it's not clear to me if the sil164 or ch7006 code
can ever get called).

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 drivers/gpu/drm/drm_encoder_slave.c | 26 --------------------------
 include/drm/drm_encoder_slave.h     | 11 ++---------
 2 files changed, 2 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
index e464429d32df..0c994a4ef9ae 100644
--- a/drivers/gpu/drm/drm_encoder_slave.c
+++ b/drivers/gpu/drm/drm_encoder_slave.c
@@ -125,12 +125,6 @@ get_slave_funcs(struct drm_encoder *enc)
 	return to_encoder_slave(enc)->slave_funcs;
 }
 
-void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-	get_slave_funcs(encoder)->dpms(encoder, mode);
-}
-EXPORT_SYMBOL(drm_i2c_encoder_dpms);
-
 bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
 		const struct drm_display_mode *mode,
 		struct drm_display_mode *adjusted_mode)
@@ -142,26 +136,6 @@ bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
 }
 EXPORT_SYMBOL(drm_i2c_encoder_mode_fixup);
 
-void drm_i2c_encoder_prepare(struct drm_encoder *encoder)
-{
-	drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
-}
-EXPORT_SYMBOL(drm_i2c_encoder_prepare);
-
-void drm_i2c_encoder_commit(struct drm_encoder *encoder)
-{
-	drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
-}
-EXPORT_SYMBOL(drm_i2c_encoder_commit);
-
-void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
-		struct drm_display_mode *mode,
-		struct drm_display_mode *adjusted_mode)
-{
-	get_slave_funcs(encoder)->mode_set(encoder, mode, adjusted_mode);
-}
-EXPORT_SYMBOL(drm_i2c_encoder_mode_set);
-
 enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
 	    struct drm_connector *connector)
 {
diff --git a/include/drm/drm_encoder_slave.h b/include/drm/drm_encoder_slave.h
index 49172166a164..3089db10b6fd 100644
--- a/include/drm/drm_encoder_slave.h
+++ b/include/drm/drm_encoder_slave.h
@@ -58,8 +58,7 @@ struct drm_encoder_slave_funcs {
 	void (*destroy)(struct drm_encoder *encoder);
 
 	/**
-	 * @dpms: Analogous to &drm_encoder_helper_funcs @dpms callback. Wrapped
-	 * by drm_i2c_encoder_dpms().
+	 * @dpms: Analogous to &drm_encoder_helper_funcs @dpms callback.
 	 */
 	void (*dpms)(struct drm_encoder *encoder, int mode);
 
@@ -88,7 +87,7 @@ struct drm_encoder_slave_funcs {
 			  struct drm_display_mode *mode);
 	/**
 	 * @mode_set: Analogous to &drm_encoder_helper_funcs @mode_set
-	 * callback. Wrapped by drm_i2c_encoder_mode_set().
+	 * callback.
 	 */
 	void (*mode_set)(struct drm_encoder *encoder,
 			 struct drm_display_mode *mode,
@@ -223,15 +222,9 @@ void drm_i2c_encoder_destroy(struct drm_encoder *encoder);
  * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
  */
 
-void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode);
 bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
 		const struct drm_display_mode *mode,
 		struct drm_display_mode *adjusted_mode);
-void drm_i2c_encoder_prepare(struct drm_encoder *encoder);
-void drm_i2c_encoder_commit(struct drm_encoder *encoder);
-void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
-		struct drm_display_mode *mode,
-		struct drm_display_mode *adjusted_mode);
 enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
 	    struct drm_connector *connector);
 void drm_i2c_encoder_save(struct drm_encoder *encoder);
-- 
2.47.0
Re: [PATCH] drm: encoder_slave: Remove unused encoder functions
Posted by Dmitry Baryshkov 3 weeks, 6 days ago
On Fri, Oct 25, 2024 at 09:39:20PM +0100, linux@treblig.org wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
> 
> drm_i2c_encoder_commit(), drm_i2c_encoder_mode_set() and
> drm_i2c_encoder_prepare() have been unused since 2016's
> commit 7bc61cc5df80 ("drm/arcpgu: Accommodate adv7511 switch to DRM
> bridge").
> 
> Remove them.
> That change makes drm_i2c_encoder_dpms() unused.
> Remove it.
> 
> Remove the comments about those functions wrapping a couple of
> pointers in drm_encoder_slave_funcs.  I can see sil164, ch7006, and nv17
> set those fields, and I can see some nouveau code that calls them
> directly; so i don't think we can remove the fields.
> (Although it's not clear to me if the sil164 or ch7006 code
> can ever get called).
> 
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> ---
>  drivers/gpu/drm/drm_encoder_slave.c | 26 --------------------------
>  include/drm/drm_encoder_slave.h     | 11 ++---------
>  2 files changed, 2 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
> index e464429d32df..0c994a4ef9ae 100644
> --- a/drivers/gpu/drm/drm_encoder_slave.c
> +++ b/drivers/gpu/drm/drm_encoder_slave.c
> @@ -125,12 +125,6 @@ get_slave_funcs(struct drm_encoder *enc)
>  	return to_encoder_slave(enc)->slave_funcs;
>  }
>  
> -void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode)
> -{
> -	get_slave_funcs(encoder)->dpms(encoder, mode);
> -}
> -EXPORT_SYMBOL(drm_i2c_encoder_dpms);

I think it might be better to convert nouveau to use these functions
instead of open-coding them. Another option might be to make nouveau use
normal drm_bridge interface to talk to i2c encoders and drop the custom
interface.

Ben, WDYT?

> -
>  bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
>  		const struct drm_display_mode *mode,
>  		struct drm_display_mode *adjusted_mode)
> @@ -142,26 +136,6 @@ bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
>  }
>  EXPORT_SYMBOL(drm_i2c_encoder_mode_fixup);
>  
> -void drm_i2c_encoder_prepare(struct drm_encoder *encoder)
> -{
> -	drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
> -}
> -EXPORT_SYMBOL(drm_i2c_encoder_prepare);
> -
> -void drm_i2c_encoder_commit(struct drm_encoder *encoder)
> -{
> -	drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
> -}
> -EXPORT_SYMBOL(drm_i2c_encoder_commit);
> -
> -void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
> -		struct drm_display_mode *mode,
> -		struct drm_display_mode *adjusted_mode)
> -{
> -	get_slave_funcs(encoder)->mode_set(encoder, mode, adjusted_mode);
> -}
> -EXPORT_SYMBOL(drm_i2c_encoder_mode_set);
> -
>  enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
>  	    struct drm_connector *connector)
>  {
> diff --git a/include/drm/drm_encoder_slave.h b/include/drm/drm_encoder_slave.h
> index 49172166a164..3089db10b6fd 100644
> --- a/include/drm/drm_encoder_slave.h
> +++ b/include/drm/drm_encoder_slave.h
> @@ -58,8 +58,7 @@ struct drm_encoder_slave_funcs {
>  	void (*destroy)(struct drm_encoder *encoder);
>  
>  	/**
> -	 * @dpms: Analogous to &drm_encoder_helper_funcs @dpms callback. Wrapped
> -	 * by drm_i2c_encoder_dpms().
> +	 * @dpms: Analogous to &drm_encoder_helper_funcs @dpms callback.
>  	 */
>  	void (*dpms)(struct drm_encoder *encoder, int mode);
>  
> @@ -88,7 +87,7 @@ struct drm_encoder_slave_funcs {
>  			  struct drm_display_mode *mode);
>  	/**
>  	 * @mode_set: Analogous to &drm_encoder_helper_funcs @mode_set
> -	 * callback. Wrapped by drm_i2c_encoder_mode_set().
> +	 * callback.
>  	 */
>  	void (*mode_set)(struct drm_encoder *encoder,
>  			 struct drm_display_mode *mode,
> @@ -223,15 +222,9 @@ void drm_i2c_encoder_destroy(struct drm_encoder *encoder);
>   * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
>   */
>  
> -void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode);
>  bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
>  		const struct drm_display_mode *mode,
>  		struct drm_display_mode *adjusted_mode);
> -void drm_i2c_encoder_prepare(struct drm_encoder *encoder);
> -void drm_i2c_encoder_commit(struct drm_encoder *encoder);
> -void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
> -		struct drm_display_mode *mode,
> -		struct drm_display_mode *adjusted_mode);
>  enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
>  	    struct drm_connector *connector);
>  void drm_i2c_encoder_save(struct drm_encoder *encoder);
> -- 
> 2.47.0
> 

-- 
With best wishes
Dmitry