[1/2] media: i2c: st_mipid02: cascade s_stream call to the source subdev

Message ID 20230711123211.794838-2-alain.volmat@foss.st.com
State New
Headers
Series media: stm32: correct s_stream calls in dcmi & st-mipid02 |

Commit Message

Alain Volmat July 11, 2023, 12:32 p.m. UTC
  Cascade the s_stream call to the source subdev whenever the bridge
streaming is enable / disabled.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/media/i2c/st-mipid02.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Hans Verkuil July 19, 2023, 10:26 a.m. UTC | #1
On 11/07/2023 14:32, Alain Volmat wrote:
> Cascade the s_stream call to the source subdev whenever the bridge
> streaming is enable / disabled.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/media/i2c/st-mipid02.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index 906553a28676..703d2f06f552 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge)
>  	struct i2c_client *client = bridge->i2c_client;
>  	int ret;
>  
> +	if (!bridge->s_subdev)
> +		goto error;

I'm getting this compiler warning:

media-git/drivers/media/i2c/st-mipid02.c: In function 'mipid02_stream_disable':
media-git/drivers/media/i2c/st-mipid02.c:568:12: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized]
  568 |         if (ret)
      |            ^
media-git/drivers/media/i2c/st-mipid02.c:548:13: note: 'ret' was declared here
  548 |         int ret;
      |             ^~~

I'm dropping this series, waiting for a v2.

Regards,

	Hans

> +
> +	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0);
> +	if (ret)
> +		goto error;
> +
>  	/* Disable all lanes */
>  	ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0);
>  	if (ret)
> @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge)
>  	if (ret)
>  		goto error;
>  
> +	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1);
> +	if (ret)
> +		goto error;
> +
>  	return 0;
>  
>  error:
  
Alain Volmat July 21, 2023, 12:18 p.m. UTC | #2
Hi Hans,

On Wed, Jul 19, 2023 at 12:26:37PM +0200, Hans Verkuil wrote:
> On 11/07/2023 14:32, Alain Volmat wrote:
> > Cascade the s_stream call to the source subdev whenever the bridge
> > streaming is enable / disabled.
> > 
> > Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> > ---
> >  drivers/media/i2c/st-mipid02.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> > index 906553a28676..703d2f06f552 100644
> > --- a/drivers/media/i2c/st-mipid02.c
> > +++ b/drivers/media/i2c/st-mipid02.c
> > @@ -547,6 +547,13 @@ static int mipid02_stream_disable(struct mipid02_dev *bridge)
> >  	struct i2c_client *client = bridge->i2c_client;
> >  	int ret;
> >  
> > +	if (!bridge->s_subdev)
> > +		goto error;
> 
> I'm getting this compiler warning:
> 
> media-git/drivers/media/i2c/st-mipid02.c: In function 'mipid02_stream_disable':
> media-git/drivers/media/i2c/st-mipid02.c:568:12: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized]
>   568 |         if (ret)
>       |            ^
> media-git/drivers/media/i2c/st-mipid02.c:548:13: note: 'ret' was declared here
>   548 |         int ret;
>       |             ^~~
> 
> I'm dropping this series, waiting for a v2.

Indeed, this was a real issue.  I added KCFLAGS=-Wmaybe-uninitialized
in my build command line to spot thoses issues from now on.

v2 posted with the fix.

> 
> Regards,
> 
> 	Hans

Regards,
Alain
> 
> > +
> > +	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0);
> > +	if (ret)
> > +		goto error;
> > +
> >  	/* Disable all lanes */
> >  	ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0);
> >  	if (ret)
> > @@ -633,6 +640,10 @@ static int mipid02_stream_enable(struct mipid02_dev *bridge)
> >  	if (ret)
> >  		goto error;
> >  
> > +	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1);
> > +	if (ret)
> > +		goto error;
> > +
> >  	return 0;
> >  
> >  error:
>
  

Patch

diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
index 906553a28676..703d2f06f552 100644
--- a/drivers/media/i2c/st-mipid02.c
+++ b/drivers/media/i2c/st-mipid02.c
@@ -547,6 +547,13 @@  static int mipid02_stream_disable(struct mipid02_dev *bridge)
 	struct i2c_client *client = bridge->i2c_client;
 	int ret;
 
+	if (!bridge->s_subdev)
+		goto error;
+
+	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0);
+	if (ret)
+		goto error;
+
 	/* Disable all lanes */
 	ret = mipid02_write_reg(bridge, MIPID02_CLK_LANE_REG1, 0);
 	if (ret)
@@ -633,6 +640,10 @@  static int mipid02_stream_enable(struct mipid02_dev *bridge)
 	if (ret)
 		goto error;
 
+	ret = v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1);
+	if (ret)
+		goto error;
+
 	return 0;
 
 error: