linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/1] iio: common: cros_ec_sensors: Add protocol v3 support
@ 2019-07-02  8:49 Fabien Lahoudere
  2019-07-02  8:49 ` [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version Fabien Lahoudere
  0 siblings, 1 reply; 5+ messages in thread
From: Fabien Lahoudere @ 2019-07-02  8:49 UTC (permalink / raw)
  Cc: gwendal, egranata, kernel, Fabien Lahoudere, Jonathan Cameron,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Benson Leung, Enric Balletbo i Serra, Guenter Roeck,
	Nick Vaccaro, linux-iio, linux-kernel

This patch is part of a split of the following patch:
https://lkml.org/lkml/2019/6/18/268
To fix Enric comments from https://lkml.org/lkml/2019/6/25/949
I extract it from the other serie to speed up acceptance because
other patches need it to be upstreamed.

Changes since v3:
- Remove unneeded semicolon
- Add Enric Acked-by

Changes since v2:
- Use patch 1 from v1 after discussion on ML

Changes since v1:
- Drop second patch
- return ENODEV if version is 0

Fabien Lahoudere (1):
  iio: common: cros_ec_sensors: determine protocol version

 .../cros_ec_sensors/cros_ec_sensors_core.c    | 36 ++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

-- 
2.19.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version
  2019-07-02  8:49 [PATCH v4 0/1] iio: common: cros_ec_sensors: Add protocol v3 support Fabien Lahoudere
@ 2019-07-02  8:49 ` Fabien Lahoudere
  2019-07-14 16:19   ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Fabien Lahoudere @ 2019-07-02  8:49 UTC (permalink / raw)
  Cc: gwendal, egranata, kernel, Fabien Lahoudere, Nick Vaccaro,
	Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, linux-iio, linux-kernel

This patch adds a function to determine which version of the
protocol is used to communicate with EC.

Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
 .../cros_ec_sensors/cros_ec_sensors_core.c    | 36 ++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index 130362ca421b..81111af8a167 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -25,6 +25,31 @@ static char *cros_ec_loc[] = {
 	[MOTIONSENSE_LOC_MAX] = "unknown",
 };
 
+static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
+					     u16 cmd_offset, u16 cmd, u32 *mask)
+{
+	int ret;
+	struct {
+		struct cros_ec_command msg;
+		union {
+			struct ec_params_get_cmd_versions params;
+			struct ec_response_get_cmd_versions resp;
+		};
+	} __packed buf = {
+		.msg = {
+			.command = EC_CMD_GET_CMD_VERSIONS + cmd_offset,
+			.insize = sizeof(struct ec_response_get_cmd_versions),
+			.outsize = sizeof(struct ec_params_get_cmd_versions)
+			},
+		.params = {.cmd = cmd}
+	};
+
+	ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg);
+	if (ret >= 0)
+		*mask = buf.resp.version_mask;
+	return ret;
+}
+
 int cros_ec_sensors_core_init(struct platform_device *pdev,
 			      struct iio_dev *indio_dev,
 			      bool physical_device)
@@ -33,6 +58,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
 	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
 	struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
+	u32 ver_mask;
+	int ret;
 
 	platform_set_drvdata(pdev, indio_dev);
 
@@ -47,8 +74,15 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 
 	mutex_init(&state->cmd_lock);
 
+	ret = cros_ec_get_host_cmd_version_mask(state->ec,
+						ec->cmd_offset,
+						EC_CMD_MOTION_SENSE_CMD,
+						&ver_mask);
+	if (ret < 0)
+		return ret;
+
 	/* Set up the host command structure. */
-	state->msg->version = 2;
+	state->msg->version = fls(ver_mask) - 1;
 	state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
 	state->msg->outsize = sizeof(struct ec_params_motion_sense);
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version
  2019-07-02  8:49 ` [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version Fabien Lahoudere
@ 2019-07-14 16:19   ` Jonathan Cameron
  2019-07-16  8:56     ` Fabien Lahoudere
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2019-07-14 16:19 UTC (permalink / raw)
  To: Fabien Lahoudere
  Cc: gwendal, egranata, kernel, Nick Vaccaro, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Benson Leung,
	Enric Balletbo i Serra, Guenter Roeck, linux-iio, linux-kernel

On Tue,  2 Jul 2019 10:49:38 +0200
Fabien Lahoudere <fabien.lahoudere@collabora.com> wrote:

> This patch adds a function to determine which version of the
> protocol is used to communicate with EC.
> 
> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
> Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
> Tested-by: Gwendal Grignou <gwendal@chromium.org>
> Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
There are so many different series flying around for this driver that
I have given up trying to figure out if I should be picking some of
them up.  I'll ack them on the assumption they'll all go together,
but feel free to ping me if you want me to pick some of them up
through IIO.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Thanks,

Jonathan

> ---
>  .../cros_ec_sensors/cros_ec_sensors_core.c    | 36 ++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index 130362ca421b..81111af8a167 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -25,6 +25,31 @@ static char *cros_ec_loc[] = {
>  	[MOTIONSENSE_LOC_MAX] = "unknown",
>  };
>  
> +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
> +					     u16 cmd_offset, u16 cmd, u32 *mask)
> +{
> +	int ret;
> +	struct {
> +		struct cros_ec_command msg;
> +		union {
> +			struct ec_params_get_cmd_versions params;
> +			struct ec_response_get_cmd_versions resp;
> +		};
> +	} __packed buf = {
> +		.msg = {
> +			.command = EC_CMD_GET_CMD_VERSIONS + cmd_offset,
> +			.insize = sizeof(struct ec_response_get_cmd_versions),
> +			.outsize = sizeof(struct ec_params_get_cmd_versions)
> +			},
> +		.params = {.cmd = cmd}
> +	};
> +
> +	ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg);
> +	if (ret >= 0)
> +		*mask = buf.resp.version_mask;
> +	return ret;
> +}
> +
>  int cros_ec_sensors_core_init(struct platform_device *pdev,
>  			      struct iio_dev *indio_dev,
>  			      bool physical_device)
> @@ -33,6 +58,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>  	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
>  	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
>  	struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
> +	u32 ver_mask;
> +	int ret;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> @@ -47,8 +74,15 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>  
>  	mutex_init(&state->cmd_lock);
>  
> +	ret = cros_ec_get_host_cmd_version_mask(state->ec,
> +						ec->cmd_offset,
> +						EC_CMD_MOTION_SENSE_CMD,
> +						&ver_mask);
> +	if (ret < 0)
> +		return ret;
> +
>  	/* Set up the host command structure. */
> -	state->msg->version = 2;
> +	state->msg->version = fls(ver_mask) - 1;
>  	state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
>  	state->msg->outsize = sizeof(struct ec_params_motion_sense);
>  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version
  2019-07-14 16:19   ` Jonathan Cameron
@ 2019-07-16  8:56     ` Fabien Lahoudere
  2019-07-27 21:59       ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Fabien Lahoudere @ 2019-07-16  8:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: gwendal, egranata, kernel, Nick Vaccaro, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Benson Leung,
	Enric Balletbo i Serra, Guenter Roeck, linux-iio, linux-kernel

Le dimanche 14 juillet 2019 à 17:19 +0100, Jonathan Cameron a écrit :
> On Tue,  2 Jul 2019 10:49:38 +0200
> Fabien Lahoudere <fabien.lahoudere@collabora.com> wrote:
> 
> > This patch adds a function to determine which version of the
> > protocol is used to communicate with EC.
> > 
> > Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
> > Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
> > Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
> > Tested-by: Gwendal Grignou <gwendal@chromium.org>
> > Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> There are so many different series flying around for this driver that
> I have given up trying to figure out if I should be picking some of
> them up.  I'll ack them on the assumption they'll all go together,
> but feel free to ping me if you want me to pick some of them up
> through IIO.
> 

Yes sorry for all that confusing series.
Enric wanted this patch first and it is independant of others, so feel
free to pick it. Others patcheshave been sent separately.

Thanks

> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Thanks,
> 
> Jonathan
> 
> > ---
> >  .../cros_ec_sensors/cros_ec_sensors_core.c    | 36
> > ++++++++++++++++++-
> >  1 file changed, 35 insertions(+), 1 deletion(-)
> > 
> > diff --git
> > a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > index 130362ca421b..81111af8a167 100644
> > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > @@ -25,6 +25,31 @@ static char *cros_ec_loc[] = {
> >  	[MOTIONSENSE_LOC_MAX] = "unknown",
> >  };
> >  
> > +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device
> > *ec_dev,
> > +					     u16 cmd_offset, u16 cmd,
> > u32 *mask)
> > +{
> > +	int ret;
> > +	struct {
> > +		struct cros_ec_command msg;
> > +		union {
> > +			struct ec_params_get_cmd_versions params;
> > +			struct ec_response_get_cmd_versions resp;
> > +		};
> > +	} __packed buf = {
> > +		.msg = {
> > +			.command = EC_CMD_GET_CMD_VERSIONS +
> > cmd_offset,
> > +			.insize = sizeof(struct
> > ec_response_get_cmd_versions),
> > +			.outsize = sizeof(struct
> > ec_params_get_cmd_versions)
> > +			},
> > +		.params = {.cmd = cmd}
> > +	};
> > +
> > +	ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg);
> > +	if (ret >= 0)
> > +		*mask = buf.resp.version_mask;
> > +	return ret;
> > +}
> > +
> >  int cros_ec_sensors_core_init(struct platform_device *pdev,
> >  			      struct iio_dev *indio_dev,
> >  			      bool physical_device)
> > @@ -33,6 +58,8 @@ int cros_ec_sensors_core_init(struct
> > platform_device *pdev,
> >  	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> >  	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> >  	struct cros_ec_sensor_platform *sensor_platform =
> > dev_get_platdata(dev);
> > +	u32 ver_mask;
> > +	int ret;
> >  
> >  	platform_set_drvdata(pdev, indio_dev);
> >  
> > @@ -47,8 +74,15 @@ int cros_ec_sensors_core_init(struct
> > platform_device *pdev,
> >  
> >  	mutex_init(&state->cmd_lock);
> >  
> > +	ret = cros_ec_get_host_cmd_version_mask(state->ec,
> > +						ec->cmd_offset,
> > +						EC_CMD_MOTION_SENSE_CMD
> > ,
> > +						&ver_mask);
> > +	if (ret < 0)
> > +		return ret;
> > +
> >  	/* Set up the host command structure. */
> > -	state->msg->version = 2;
> > +	state->msg->version = fls(ver_mask) - 1;
> >  	state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> >  	state->msg->outsize = sizeof(struct ec_params_motion_sense);
> >  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version
  2019-07-16  8:56     ` Fabien Lahoudere
@ 2019-07-27 21:59       ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-07-27 21:59 UTC (permalink / raw)
  To: Fabien Lahoudere
  Cc: gwendal, egranata, kernel, Nick Vaccaro, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Benson Leung,
	Enric Balletbo i Serra, Guenter Roeck, linux-iio, linux-kernel

On Tue, 16 Jul 2019 10:56:38 +0200
Fabien Lahoudere <fabien.lahoudere@collabora.com> wrote:

> Le dimanche 14 juillet 2019 à 17:19 +0100, Jonathan Cameron a écrit :
> > On Tue,  2 Jul 2019 10:49:38 +0200
> > Fabien Lahoudere <fabien.lahoudere@collabora.com> wrote:
> >   
> > > This patch adds a function to determine which version of the
> > > protocol is used to communicate with EC.
> > > 
> > > Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
> > > Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
> > > Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
> > > Tested-by: Gwendal Grignou <gwendal@chromium.org>
> > > Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>  
> > There are so many different series flying around for this driver that
> > I have given up trying to figure out if I should be picking some of
> > them up.  I'll ack them on the assumption they'll all go together,
> > but feel free to ping me if you want me to pick some of them up
> > through IIO.
> >   
> 
> Yes sorry for all that confusing series.
> Enric wanted this patch first and it is independant of others, so feel
> free to pick it. Others patcheshave been sent separately.
Applied.

Thanks,

Jonathan
> 
> Thanks
> 
> > Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Thanks,
> > 
> > Jonathan
> >   
> > > ---
> > >  .../cros_ec_sensors/cros_ec_sensors_core.c    | 36
> > > ++++++++++++++++++-
> > >  1 file changed, 35 insertions(+), 1 deletion(-)
> > > 
> > > diff --git
> > > a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > > b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > > index 130362ca421b..81111af8a167 100644
> > > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > > @@ -25,6 +25,31 @@ static char *cros_ec_loc[] = {
> > >  	[MOTIONSENSE_LOC_MAX] = "unknown",
> > >  };
> > >  
> > > +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device
> > > *ec_dev,
> > > +					     u16 cmd_offset, u16 cmd,
> > > u32 *mask)
> > > +{
> > > +	int ret;
> > > +	struct {
> > > +		struct cros_ec_command msg;
> > > +		union {
> > > +			struct ec_params_get_cmd_versions params;
> > > +			struct ec_response_get_cmd_versions resp;
> > > +		};
> > > +	} __packed buf = {
> > > +		.msg = {
> > > +			.command = EC_CMD_GET_CMD_VERSIONS +
> > > cmd_offset,
> > > +			.insize = sizeof(struct
> > > ec_response_get_cmd_versions),
> > > +			.outsize = sizeof(struct
> > > ec_params_get_cmd_versions)
> > > +			},
> > > +		.params = {.cmd = cmd}
> > > +	};
> > > +
> > > +	ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg);
> > > +	if (ret >= 0)
> > > +		*mask = buf.resp.version_mask;
> > > +	return ret;
> > > +}
> > > +
> > >  int cros_ec_sensors_core_init(struct platform_device *pdev,
> > >  			      struct iio_dev *indio_dev,
> > >  			      bool physical_device)
> > > @@ -33,6 +58,8 @@ int cros_ec_sensors_core_init(struct
> > > platform_device *pdev,
> > >  	struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> > >  	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> > >  	struct cros_ec_sensor_platform *sensor_platform =
> > > dev_get_platdata(dev);
> > > +	u32 ver_mask;
> > > +	int ret;
> > >  
> > >  	platform_set_drvdata(pdev, indio_dev);
> > >  
> > > @@ -47,8 +74,15 @@ int cros_ec_sensors_core_init(struct
> > > platform_device *pdev,
> > >  
> > >  	mutex_init(&state->cmd_lock);
> > >  
> > > +	ret = cros_ec_get_host_cmd_version_mask(state->ec,
> > > +						ec->cmd_offset,
> > > +						EC_CMD_MOTION_SENSE_CMD
> > > ,
> > > +						&ver_mask);
> > > +	if (ret < 0)
> > > +		return ret;
> > > +
> > >  	/* Set up the host command structure. */
> > > -	state->msg->version = 2;
> > > +	state->msg->version = fls(ver_mask) - 1;
> > >  	state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> > >  	state->msg->outsize = sizeof(struct ec_params_motion_sense);
> > >    
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-27 21:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02  8:49 [PATCH v4 0/1] iio: common: cros_ec_sensors: Add protocol v3 support Fabien Lahoudere
2019-07-02  8:49 ` [PATCH v4 1/1] iio: common: cros_ec_sensors: determine protocol version Fabien Lahoudere
2019-07-14 16:19   ` Jonathan Cameron
2019-07-16  8:56     ` Fabien Lahoudere
2019-07-27 21:59       ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).