public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: groeck@chromium.org, enric.balletbo@collabora.com,
	bleung@chromium.org, lars@metafoo.de, jic23@kernel.org,
	egranata@chromium.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: cros_ec: Add lid angle driver
Date: Mon, 11 Mar 2019 08:24:05 +0000	[thread overview]
Message-ID: <20190311082405.GB4731@dell> (raw)
In-Reply-To: <20190228015005.81232-1-gwendal@chromium.org>

On Wed, 27 Feb 2019, Gwendal Grignou wrote:

> Add a IIO driver that reports the angle between the lid and the base for
> ChromeOS convertible device.
> 
> Tested on eve with ToT EC firmware.
> Check driver is loaded and lid angle is correct.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---
>  drivers/iio/common/cros_ec_sensors/Kconfig    |   9 +
>  drivers/iio/common/cros_ec_sensors/Makefile   |   1 +
>  .../cros_ec_sensors/cros_ec_lid_angle.c       | 164 ++++++++++++++++++

>  drivers/mfd/cros_ec_dev.c                     |  15 +-

It doesn't look like there are build dependencies between the changes
in these different subsystems.  If my assumption is correct, please
pull the MFD changes out into a separate patch.

>  4 files changed, 186 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c

[...]

> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index d275deaecb12..11b5b2fd1f33 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -297,13 +297,17 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
>  
>  	resp = (struct ec_response_motion_sense *)msg->data;
>  	sensor_num = resp->dump.sensor_count;
> -	/* Allocate 1 extra sensors in FIFO are needed */
> -	sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell),
> +	/*
> +	 * Allocate extra sensors if lid angle sensor or FIFO are needed.
> +	 */
> +#define NUM_EXTRA_SENSORS 2

Please refrain from placing #defines in the middle of functions.

Move it to the top of the file.

> +	sensor_cells = kcalloc(sensor_num + NUM_EXTRA_SENSORS,

Actually, this isn't something that needs defining.

Just change the comment to:

  "Allocate 2 extra sensors if lid angle sensor or FIFO are needed."

... and drop the define.

> +			       sizeof(struct mfd_cell),
>  			       GFP_KERNEL);
>  	if (sensor_cells == NULL)
>  		goto error;
>  
> -	sensor_platforms = kcalloc(sensor_num + 1,
> +	sensor_platforms = kcalloc(sensor_num,
>  				   sizeof(struct cros_ec_sensor_platform),
>  				   GFP_KERNEL);
>  	if (sensor_platforms == NULL)
> @@ -363,6 +367,11 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
>  		sensor_cells[id].name = "cros-ec-ring";
>  		id++;
>  	}
> +	if (cros_ec_check_features(ec,
> +				EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) {
> +		sensor_cells[id].name = "cros-ec-lid-angle";
> +		id++;
> +	}
>  
>  	ret = mfd_add_devices(ec->dev, 0, sensor_cells, id,
>  			      NULL, 0, NULL);

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  parent reply	other threads:[~2019-03-11  8:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28  1:50 [PATCH] iio: cros_ec: Add lid angle driver Gwendal Grignou
2019-02-28 11:18 ` Enric Balletbo i Serra
2019-02-28 17:41   ` Gwendal Grignou
2019-02-28 17:41     ` [PATCH v2] " Gwendal Grignou
2019-03-03 12:43       ` Jonathan Cameron
2019-03-07  0:33         ` Gwendal Grignou
2019-03-07  0:35           ` [PATCH v3] " Gwendal Grignou
2019-03-07 12:32             ` Enric Balletbo i Serra
2019-03-09 17:43               ` Jonathan Cameron
2019-03-11  8:24 ` Lee Jones [this message]
2019-03-29  8:41   ` [PATCH v4 2/2] " Gwendal Grignou
2019-03-29 13:44     ` Guenter Roeck
2019-03-29 17:40       ` Gwendal Grignou
2019-03-29 20:08         ` [PATCH v5] " Gwendal Grignou
2019-03-29 20:17           ` Guenter Roeck
2019-03-29 22:37             ` Gwendal Grignou
2019-03-29 23:38               ` Guenter Roeck
2019-03-31 10:28           ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190311082405.GB4731@dell \
    --to=lee.jones@linaro.org \
    --cc=bleung@chromium.org \
    --cc=egranata@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox