[libcamera-devel] libcamera: v4l2_device: Report device node on failure
diff mbox series

Message ID 20220903115042.954797-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: v4l2_device: Report device node on failure
Related show

Commit Message

Kieran Bingham Sept. 3, 2022, 11:50 a.m. UTC
When the V4L2Device fails to open, it is not clear what device
caused the failure. The Entity name is presented, but not the device
node.

Provide it.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/v4l2_device.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Pinchart Sept. 3, 2022, 1:37 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Sat, Sep 03, 2022 at 12:50:42PM +0100, Kieran Bingham via libcamera-devel wrote:
> When the V4L2Device fails to open, it is not clear what device
> caused the failure. The Entity name is presented, but not the device
> node.
> 
> Provide it.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/v4l2_device.cpp | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 1d899657bf7d..29a800a5cee3 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -90,6 +90,7 @@ int V4L2Device::open(unsigned int flags)
>  	if (!fd.isValid()) {
>  		int ret = -errno;
>  		LOG(V4L2, Error) << "Failed to open V4L2 device: "

You can drop the colon at the end of this line.

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

> +				 << deviceNode_ << ": "
>  				 << strerror(-ret);
>  		return ret;
>  	}
Laurent Pinchart Sept. 3, 2022, 1:47 p.m. UTC | #2
On Sat, Sep 03, 2022 at 04:37:55PM +0300, Laurent Pinchart via libcamera-devel wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Sat, Sep 03, 2022 at 12:50:42PM +0100, Kieran Bingham via libcamera-devel wrote:
> > When the V4L2Device fails to open, it is not clear what device
> > caused the failure. The Entity name is presented, but not the device
> > node.
> > 
> > Provide it.
> > 
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >  src/libcamera/v4l2_device.cpp | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> > index 1d899657bf7d..29a800a5cee3 100644
> > --- a/src/libcamera/v4l2_device.cpp
> > +++ b/src/libcamera/v4l2_device.cpp
> > @@ -90,6 +90,7 @@ int V4L2Device::open(unsigned int flags)
> >  	if (!fd.isValid()) {
> >  		int ret = -errno;
> >  		LOG(V4L2, Error) << "Failed to open V4L2 device: "
> 
> You can drop the colon at the end of this line.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Actually, as I suspect deviceNode_ to be an empty string in the case
you're trying to address, this would print

[0:23:47.240792321] [8216] ERROR V4L2 v4l2_device.cpp:92 'dw9719 2-000c': Failed to open V4L2 device : No such file or directory

which isn't great. Adding quotes would help

  		LOG(V4L2, Error) << "Failed to open V4L2 device `"
				 << deviceNode_ << "': "
				 << strerror(-ret);

as it would turn the message into

[0:23:47.240792321] [8216] ERROR V4L2 v4l2_device.cpp:92 'dw9719 2-000c': Failed to open V4L2 device `': No such file or directory

> > +				 << deviceNode_ << ": "
> >  				 << strerror(-ret);
> >  		return ret;
> >  	}
Umang Jain Sept. 5, 2022, 5:49 a.m. UTC | #3
Hi Kieran,

Thank you for the patches.

On 9/3/22 7:07 PM, Laurent Pinchart via libcamera-devel wrote:
> Hi Kieran,
>
> Thank you for the patch.
>
> On Sat, Sep 03, 2022 at 12:50:42PM +0100, Kieran Bingham via libcamera-devel wrote:
>> When the V4L2Device fails to open, it is not clear what device
>> caused the failure. The Entity name is presented, but not the device
>> node.
>>
>> Provide it.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>   src/libcamera/v4l2_device.cpp | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
>> index 1d899657bf7d..29a800a5cee3 100644
>> --- a/src/libcamera/v4l2_device.cpp
>> +++ b/src/libcamera/v4l2_device.cpp
>> @@ -90,6 +90,7 @@ int V4L2Device::open(unsigned int flags)
>>   	if (!fd.isValid()) {
>>   		int ret = -errno;
>>   		LOG(V4L2, Error) << "Failed to open V4L2 device: "
> You can drop the colon at the end of this line.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

With error-messages' pendantics applied,

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
>
>> +				 << deviceNode_ << ": "
>>   				 << strerror(-ret);
>>   		return ret;
>>   	}

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 1d899657bf7d..29a800a5cee3 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -90,6 +90,7 @@  int V4L2Device::open(unsigned int flags)
 	if (!fd.isValid()) {
 		int ret = -errno;
 		LOG(V4L2, Error) << "Failed to open V4L2 device: "
+				 << deviceNode_ << ": "
 				 << strerror(-ret);
 		return ret;
 	}