diff mbox series

[11/16] media: i2c: max9286: Cache channel amplitude

Message ID 20210216174146.106639-12-jacopo+renesas@jmondi.org (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series media: i2c: GMSL reliability improvements | expand

Commit Message

Jacopo Mondi Feb. 16, 2021, 5:41 p.m. UTC
Cache the current channel amplitude in a driver variable
to skip updating it if the new requested value is the same
as the currently configured one.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/max9286.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Feb. 17, 2021, 8:08 a.m. UTC | #1
On Tue, Feb 16, 2021 at 6:41 PM Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
> Cache the current channel amplitude in a driver variable
> to skip updating it if the new requested value is the same

newly

> as the currently configured one.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Gr{oetje,eeting}s,

                        Geert
Kieran Bingham Feb. 18, 2021, 3:39 p.m. UTC | #2
On 16/02/2021 17:41, Jacopo Mondi wrote:
> Cache the current channel amplitude in a driver variable
> to skip updating it if the new requested value is the same
> as the currently configured one.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

I like this model better than deciding outside of the call :-)

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>


> ---
>  drivers/media/i2c/max9286.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index 1f14cd817fbf..4afb5ca06448 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -164,6 +164,7 @@ struct max9286_priv {
>  	bool mux_open;
>  
>  	u32 init_rev_chan_mv;
> +	u32 rev_chan_mv;
>  
>  	struct v4l2_ctrl_handler ctrls;
>  	struct v4l2_ctrl *pixelrate;
> @@ -340,8 +341,15 @@ static void max9286_configure_i2c(struct max9286_priv *priv, bool localack)
>  static void max9286_reverse_channel_setup(struct max9286_priv *priv,
>  					  unsigned int chan_amplitude)
>  {
> +	u8 chan_config;
> +
> +	if (priv->rev_chan_mv == chan_amplitude)
> +		return;
> +
> +	priv->rev_chan_mv = chan_amplitude;
> +
>  	/* Reverse channel transmission time: default to 1. */
> -	u8 chan_config = MAX9286_REV_TRF(1);
> +	chan_config = MAX9286_REV_TRF(1);
>  
>  	/*
>  	 * Reverse channel setup.
> @@ -563,8 +571,7 @@ static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
>  	 * - Disable auto-ack as communication on the control channel are now
>  	 *   stable.
>  	 */
> -	if (priv->init_rev_chan_mv < 170)
> -		max9286_reverse_channel_setup(priv, 170);
> +	max9286_reverse_channel_setup(priv, 170);
>  	max9286_check_config_link(priv, priv->source_mask);
>  
>  	/*
>
Laurent Pinchart Feb. 22, 2021, 1:33 a.m. UTC | #3
Hi Jacopo,

Thank you for the patch.

On Tue, Feb 16, 2021 at 06:41:41PM +0100, Jacopo Mondi wrote:
> Cache the current channel amplitude in a driver variable
> to skip updating it if the new requested value is the same
> as the currently configured one.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/i2c/max9286.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index 1f14cd817fbf..4afb5ca06448 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -164,6 +164,7 @@ struct max9286_priv {
>  	bool mux_open;
>  
>  	u32 init_rev_chan_mv;
> +	u32 rev_chan_mv;
>  
>  	struct v4l2_ctrl_handler ctrls;
>  	struct v4l2_ctrl *pixelrate;
> @@ -340,8 +341,15 @@ static void max9286_configure_i2c(struct max9286_priv *priv, bool localack)
>  static void max9286_reverse_channel_setup(struct max9286_priv *priv,
>  					  unsigned int chan_amplitude)
>  {
> +	u8 chan_config;
> +
> +	if (priv->rev_chan_mv == chan_amplitude)
> +		return;
> +
> +	priv->rev_chan_mv = chan_amplitude;
> +
>  	/* Reverse channel transmission time: default to 1. */
> -	u8 chan_config = MAX9286_REV_TRF(1);
> +	chan_config = MAX9286_REV_TRF(1);
>  
>  	/*
>  	 * Reverse channel setup.
> @@ -563,8 +571,7 @@ static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
>  	 * - Disable auto-ack as communication on the control channel are now
>  	 *   stable.
>  	 */
> -	if (priv->init_rev_chan_mv < 170)
> -		max9286_reverse_channel_setup(priv, 170);
> +	max9286_reverse_channel_setup(priv, 170);
>  	max9286_check_config_link(priv, priv->source_mask);
>  
>  	/*
diff mbox series

Patch

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 1f14cd817fbf..4afb5ca06448 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -164,6 +164,7 @@  struct max9286_priv {
 	bool mux_open;
 
 	u32 init_rev_chan_mv;
+	u32 rev_chan_mv;
 
 	struct v4l2_ctrl_handler ctrls;
 	struct v4l2_ctrl *pixelrate;
@@ -340,8 +341,15 @@  static void max9286_configure_i2c(struct max9286_priv *priv, bool localack)
 static void max9286_reverse_channel_setup(struct max9286_priv *priv,
 					  unsigned int chan_amplitude)
 {
+	u8 chan_config;
+
+	if (priv->rev_chan_mv == chan_amplitude)
+		return;
+
+	priv->rev_chan_mv = chan_amplitude;
+
 	/* Reverse channel transmission time: default to 1. */
-	u8 chan_config = MAX9286_REV_TRF(1);
+	chan_config = MAX9286_REV_TRF(1);
 
 	/*
 	 * Reverse channel setup.
@@ -563,8 +571,7 @@  static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
 	 * - Disable auto-ack as communication on the control channel are now
 	 *   stable.
 	 */
-	if (priv->init_rev_chan_mv < 170)
-		max9286_reverse_channel_setup(priv, 170);
+	max9286_reverse_channel_setup(priv, 170);
 	max9286_check_config_link(priv, priv->source_mask);
 
 	/*