diff mbox series

iio: hid: fix the retval in [accel|gyro]_3d_capture_sample

Message ID 80a61ea3eb5d00febdaf24ab27e3301fd8c70f74.camel@intel.com (mailing list archive)
State Changes Requested
Headers show
Series iio: hid: fix the retval in [accel|gyro]_3d_capture_sample | expand

Commit Message

Dmitry Perchanov Jan. 2, 2023, 6:51 p.m. UTC
From d12f607f83c0bdae6529d8cfbb0cf17f8920c380 Mon Sep 17 00:00:00 2001
From: Dmitry Perchanov <dmitry.perchanov@intel.com>
Date: Tue, 13 Dec 2022 17:44:01 +0200
Subject: [PATCH] iio: hid: fix the retval in [accel|gyro]_3d_capture_sample

Return value should be zero for success.
This was forgotten for timestamp feature.
Verified on RealSense cameras.

Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
---
 drivers/iio/accel/hid-sensor-accel-3d.c | 1 +
 drivers/iio/gyro/hid-sensor-gyro-3d.c   | 1 +
 2 files changed, 2 insertions(+)

Comments

Jonathan Cameron Jan. 8, 2023, 12:24 p.m. UTC | #1
On Mon, 02 Jan 2023 20:51:27 +0200
Dmitry Perchanov <dmitry.perchanov@intel.com> wrote:

> From d12f607f83c0bdae6529d8cfbb0cf17f8920c380 Mon Sep 17 00:00:00 2001
> From: Dmitry Perchanov <dmitry.perchanov@intel.com>
> Date: Tue, 13 Dec 2022 17:44:01 +0200
> Subject: [PATCH] iio: hid: fix the retval in [accel|gyro]_3d_capture_sample
> 
> Return value should be zero for success.
> This was forgotten for timestamp feature.
> Verified on RealSense cameras.
> 
> Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Hi Dmitry,

I've taken this as it stands (needed to do a bit of hand editing to get
git to accept your email).  However, if you fancy doing some cleanup
it would be better still if these functions just returned directly in each
arm of the switch statement.  Drop the final return and the compiler
will moan if any path is not covered...

Applied to the fixes-togreg branch of iio.git and marked for stable inclusion.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/hid-sensor-accel-3d.c | 1 +
>  drivers/iio/gyro/hid-sensor-gyro-3d.c   | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index a2def6f93..5eac7ea19 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -280,6 +280,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
>  			hid_sensor_convert_timestamp(
>  					&accel_state->common_attributes,
>  					*(int64_t *)raw_data);
> +		ret = 0;
>  	break;
>  	default:
>  		break;
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index 8f0ad022c..698c50da1 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -231,6 +231,7 @@ static int gyro_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
>  		gyro_state->timestamp =
>  			hid_sensor_convert_timestamp(&gyro_state->common_attributes,
>  						     *(s64 *)raw_data);
> +		ret = 0;
>  	break;
>  	default:
>  		break;
Jonathan Cameron Jan. 8, 2023, 12:32 p.m. UTC | #2
On Sun, 8 Jan 2023 12:24:34 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 02 Jan 2023 20:51:27 +0200
> Dmitry Perchanov <dmitry.perchanov@intel.com> wrote:
> 
> > From d12f607f83c0bdae6529d8cfbb0cf17f8920c380 Mon Sep 17 00:00:00 2001
> > From: Dmitry Perchanov <dmitry.perchanov@intel.com>
> > Date: Tue, 13 Dec 2022 17:44:01 +0200
> > Subject: [PATCH] iio: hid: fix the retval in [accel|gyro]_3d_capture_sample
This block shouldn't be here in the email.

> > 
> > Return value should be zero for success.
> > This was forgotten for timestamp feature.
> > Verified on RealSense cameras.
> > 
> > Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>  
> Hi Dmitry,
> 
> I've taken this as it stands (needed to do a bit of hand editing to get
> git to accept your email).  However, if you fancy doing some cleanup
> it would be better still if these functions just returned directly in each
> arm of the switch statement.  Drop the final return and the compiler
> will moan if any path is not covered...
> 
> Applied to the fixes-togreg branch of iio.git and marked for stable inclusion.
Actually, whilst applying I tried to add a fixes tag with the assumption these
were probably both added at a similar time.  Unfortunately not (one was 2021,
the other 2016).

As such I've dropped the patch.  Could you resend this as two separate patches, with
fixes tags as appropriate.
Fixes: 4648cbd8fb92 ("iio: hid-sensor-gyro-3d: Add timestamp channel")
Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")

This is a fix we definitely want backported, so making it easy to do is important.

Thanks,

Jonathan



> 
> Thanks,
> 
> Jonathan
> 
> > ---
> >  drivers/iio/accel/hid-sensor-accel-3d.c | 1 +
> >  drivers/iio/gyro/hid-sensor-gyro-3d.c   | 1 +
> >  2 files changed, 2 insertions(+)
> > 
> > diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> > index a2def6f93..5eac7ea19 100644
> > --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> > +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> > @@ -280,6 +280,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> >  			hid_sensor_convert_timestamp(
> >  					&accel_state->common_attributes,
> >  					*(int64_t *)raw_data);
> > +		ret = 0;
> >  	break;
> >  	default:
> >  		break;
> > diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > index 8f0ad022c..698c50da1 100644
> > --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > @@ -231,6 +231,7 @@ static int gyro_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> >  		gyro_state->timestamp =
> >  			hid_sensor_convert_timestamp(&gyro_state->common_attributes,
> >  						     *(s64 *)raw_data);
> > +		ret = 0;
> >  	break;
> >  	default:
> >  		break;  
>
Dmitry Perchanov Jan. 9, 2023, 7:46 a.m. UTC | #3
On Sun, 2023-01-08 at 12:32 +0000, Jonathan Cameron wrote:
> On Sun, 8 Jan 2023 12:24:34 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Mon, 02 Jan 2023 20:51:27 +0200
> > Dmitry Perchanov <dmitry.perchanov@intel.com> wrote:
> > 
> > > From d12f607f83c0bdae6529d8cfbb0cf17f8920c380 Mon Sep 17 00:00:00 2001
> > > From: Dmitry Perchanov <dmitry.perchanov@intel.com>
> > > Date: Tue, 13 Dec 2022 17:44:01 +0200
> > > Subject: [PATCH] iio: hid: fix the retval in [accel|gyro]_3d_capture_sample
> 
> This block shouldn't be here in the email.
> 
> > > 
> > > Return value should be zero for success.
> > > This was forgotten for timestamp feature.
> > > Verified on RealSense cameras.
> > > 
> > > Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>  
> > 
> > Hi Dmitry,
> > 
> > I've taken this as it stands (needed to do a bit of hand editing to get
> > git to accept your email).  However, if you fancy doing some cleanup
> > it would be better still if these functions just returned directly in each
> > arm of the switch statement.  Drop the final return and the compiler
> > will moan if any path is not covered...
> > 
> > Applied to the fixes-togreg branch of iio.git and marked for stable inclusion.
> 
> Actually, whilst applying I tried to add a fixes tag with the assumption these
> were probably both added at a similar time.  Unfortunately not (one was 2021,
> the other 2016).
> 
> As such I've dropped the patch.  Could you resend this as two separate patches, with
> fixes tags as appropriate.
> Fixes: 4648cbd8fb92 ("iio: hid-sensor-gyro-3d: Add timestamp channel")
> Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")
> 
I will resend two separate patches.

Thanks,

Dmitry

> This is a fix we definitely want backported, so making it easy to do is important.
> 
> Thanks,
> 
> Jonathan
> 
> 
> 
> > 
> > Thanks,
> > 
> > Jonathan
> > 
> > > ---
> > >  drivers/iio/accel/hid-sensor-accel-3d.c | 1 +
> > >  drivers/iio/gyro/hid-sensor-gyro-3d.c   | 1 +
> > >  2 files changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> > > index a2def6f93..5eac7ea19 100644
> > > --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> > > +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> > > @@ -280,6 +280,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> > >  			hid_sensor_convert_timestamp(
> > >  					&accel_state->common_attributes,
> > >  					*(int64_t *)raw_data);
> > > +		ret = 0;
> > >  	break;
> > >  	default:
> > >  		break;
> > > diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > > index 8f0ad022c..698c50da1 100644
> > > --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > > +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> > > @@ -231,6 +231,7 @@ static int gyro_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> > >  		gyro_state->timestamp =
> > >  			hid_sensor_convert_timestamp(&gyro_state->common_attributes,
> > >  						     *(s64 *)raw_data);
> > > +		ret = 0;
> > >  	break;
> > >  	default:
> > >  		break;  
> 
> 

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
diff mbox series

Patch

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index a2def6f93..5eac7ea19 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -280,6 +280,7 @@  static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
 			hid_sensor_convert_timestamp(
 					&accel_state->common_attributes,
 					*(int64_t *)raw_data);
+		ret = 0;
 	break;
 	default:
 		break;
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 8f0ad022c..698c50da1 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -231,6 +231,7 @@  static int gyro_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
 		gyro_state->timestamp =
 			hid_sensor_convert_timestamp(&gyro_state->common_attributes,
 						     *(s64 *)raw_data);
+		ret = 0;
 	break;
 	default:
 		break;