[libcamera-devel,13/20] libcamera: ipu3: cio2: Mark sensor() as const

Message ID 20200714104212.48683-14-jacopo@jmondi.org
State Superseded, archived
Delegated to: Jacopo Mondi
Headers show
Series
  • libcamera: ipu3: Rework pipe configuration
Related show

Commit Message

Jacopo Mondi July 14, 2020, 10:42 a.m. UTC
Mark the CIO2Device::sensor() method as const, and allow to call it
on const instances of the class.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/ipu3/cio2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart July 14, 2020, 9:33 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Jul 14, 2020 at 12:42:05PM +0200, Jacopo Mondi wrote:
> Mark the CIO2Device::sensor() method as const, and allow to call it
> on const instances of the class.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/cio2.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
> index f905d97fa79d..0f75b0bc4572 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.h
> +++ b/src/libcamera/pipeline/ipu3/cio2.h
> @@ -49,7 +49,7 @@ public:
>  	int start();
>  	int stop();
>  
> -	CameraSensor *sensor() { return sensor_; }
> +	CameraSensor *sensor() const { return sensor_; }

This would calling non-const methods of the CameraSensor class from a
caller that only has access to a const CIO2Device. Wouldn't it be better
to have two methods, a const and a non-const one ?

	CameraSensor *sensor() { return sensor_; }
	const CameraSensor *sensor() const { return sensor_; }

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

>  
>  	int queueBuffer(Request *request, FrameBuffer *rawBuffer);
>  	void tryReturnBuffer(FrameBuffer *buffer);

Patch

diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
index f905d97fa79d..0f75b0bc4572 100644
--- a/src/libcamera/pipeline/ipu3/cio2.h
+++ b/src/libcamera/pipeline/ipu3/cio2.h
@@ -49,7 +49,7 @@  public:
 	int start();
 	int stop();
 
-	CameraSensor *sensor() { return sensor_; }
+	CameraSensor *sensor() const { return sensor_; }
 
 	int queueBuffer(Request *request, FrameBuffer *rawBuffer);
 	void tryReturnBuffer(FrameBuffer *buffer);