Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-12-03 Thread Jonathan Cameron
On 30/11/16 08:57, Enric Balletbo Serra wrote:
> Hi Jonathan,
> 
> Many thanks for the review, I'm preparing v2. One question below.
> 
> 2016-11-27 11:39 GMT+01:00 Jonathan Cameron :
>> On 25/11/16 12:03, Enric Balletbo i Serra wrote:
>>> From: Gwendal Grignou 
>>>
>>> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
>>> Creates an IIO device for each functions.
>>>
>>> Signed-off-by: Gwendal Grignou 
>>> Signed-off-by: Guenter Roeck 
>>> Signed-off-by: Enric Balletbo i Serra 
>> A few comments / questions inline.   We've missed the upcoming merge window
>> now anyway so plenty of time to tidy up loose ends.
>>
>> Thanks,
>>
>> Jonathan
>>> ---
>>>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>>>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>>>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
>>> +
>>>  3 files changed, 287 insertions(+)
>>>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>>
>>> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
>>> b/drivers/iio/common/cros_ec_sensors/Kconfig
>>> index 135f682..4fd0b87 100644
>>> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
>>> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
>>> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
>>> Accelerometers, Gyroscope and Magnetometer that are
>>> presented by the ChromeOS EC Sensor hub.
>>> Creates an IIO device for each functions.
>>> +
>>> +config IIO_CROS_EC_LIGHT_PROX
>>> + tristate "ChromeOS EC Light and Proximity Sensors"
>>> + select IIO_CROS_EC_SENSORS_CORE
>> As the build bot has pointed out this doesn't work...
>> I'd go with depends on myself as it's simpler than making sure to select
>> the whole tree of things needed.
>>
> 
> I'll fix this in v2.
> 
>>> + help
>>> +   Module to handle Light and Proximity sensors
>>> +   presented by the ChromeOS EC Sensor hub.
>>> +   Creates an IIO device for each functions.
>>> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
>>> b/drivers/iio/common/cros_ec_sensors/Makefile
>>> index ec716ff..7aaf2a2 100644
>>> --- a/drivers/iio/common/cros_ec_sensors/Makefile
>>> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
>>> @@ -4,3 +4,4 @@
>>>
>>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
>>> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
>>> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
>>> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>> new file mode 100644
>>> index 000..40a34de
>>> --- /dev/null
>>> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>> @@ -0,0 +1,278 @@
>>> +/*
>>> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
>>> + *
>>> + * Copyright (C) 2016 Google, Inc
>>> + *
>>> + * This software is licensed under the terms of the GNU General Public
>>> + * License version 2, as published by the Free Software Foundation, and
>>> + * may be copied, distributed, and modified under those terms.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include "cros_ec_sensors_core.h"
>>> +
>>> +/*
>>> + * We only represent one entry for light or proximity. EC is merging 
>>> different
>>> + * light sensors to return the what the eye would see. For proximity, we
>>> + * currently support only one light source.
>>> + */
>>> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
>>> +
>>> +/* State data for ec_sensors iio driver. */
>>> +struct cros_ec_sensors_state {
>>> + /* Shared by all sensors */
>>> + struct cros_ec_sensors_core_state core;
>>> +
>>> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
>>> +};
>>> +
>>> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
>>> +struct iio_chan_spec const *chan,
>>> +int *val, int *val2, long mask)
>>> +{
>>> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
>>> + u16 data = 0;
>>> + s64 val64;
>>> + int ret;
>>> + int idx = chan->scan_index;
>>> +
>>> + mutex_lock(>core.cmd_lock);
>>> +
>>> + switch (mask) {
>>> + case IIO_CHAN_INFO_RAW:
>>> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
>>> +

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-12-03 Thread Jonathan Cameron
On 30/11/16 08:57, Enric Balletbo Serra wrote:
> Hi Jonathan,
> 
> Many thanks for the review, I'm preparing v2. One question below.
> 
> 2016-11-27 11:39 GMT+01:00 Jonathan Cameron :
>> On 25/11/16 12:03, Enric Balletbo i Serra wrote:
>>> From: Gwendal Grignou 
>>>
>>> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
>>> Creates an IIO device for each functions.
>>>
>>> Signed-off-by: Gwendal Grignou 
>>> Signed-off-by: Guenter Roeck 
>>> Signed-off-by: Enric Balletbo i Serra 
>> A few comments / questions inline.   We've missed the upcoming merge window
>> now anyway so plenty of time to tidy up loose ends.
>>
>> Thanks,
>>
>> Jonathan
>>> ---
>>>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>>>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>>>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
>>> +
>>>  3 files changed, 287 insertions(+)
>>>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>>
>>> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
>>> b/drivers/iio/common/cros_ec_sensors/Kconfig
>>> index 135f682..4fd0b87 100644
>>> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
>>> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
>>> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
>>> Accelerometers, Gyroscope and Magnetometer that are
>>> presented by the ChromeOS EC Sensor hub.
>>> Creates an IIO device for each functions.
>>> +
>>> +config IIO_CROS_EC_LIGHT_PROX
>>> + tristate "ChromeOS EC Light and Proximity Sensors"
>>> + select IIO_CROS_EC_SENSORS_CORE
>> As the build bot has pointed out this doesn't work...
>> I'd go with depends on myself as it's simpler than making sure to select
>> the whole tree of things needed.
>>
> 
> I'll fix this in v2.
> 
>>> + help
>>> +   Module to handle Light and Proximity sensors
>>> +   presented by the ChromeOS EC Sensor hub.
>>> +   Creates an IIO device for each functions.
>>> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
>>> b/drivers/iio/common/cros_ec_sensors/Makefile
>>> index ec716ff..7aaf2a2 100644
>>> --- a/drivers/iio/common/cros_ec_sensors/Makefile
>>> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
>>> @@ -4,3 +4,4 @@
>>>
>>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
>>> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
>>> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
>>> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>> new file mode 100644
>>> index 000..40a34de
>>> --- /dev/null
>>> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>> @@ -0,0 +1,278 @@
>>> +/*
>>> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
>>> + *
>>> + * Copyright (C) 2016 Google, Inc
>>> + *
>>> + * This software is licensed under the terms of the GNU General Public
>>> + * License version 2, as published by the Free Software Foundation, and
>>> + * may be copied, distributed, and modified under those terms.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include "cros_ec_sensors_core.h"
>>> +
>>> +/*
>>> + * We only represent one entry for light or proximity. EC is merging 
>>> different
>>> + * light sensors to return the what the eye would see. For proximity, we
>>> + * currently support only one light source.
>>> + */
>>> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
>>> +
>>> +/* State data for ec_sensors iio driver. */
>>> +struct cros_ec_sensors_state {
>>> + /* Shared by all sensors */
>>> + struct cros_ec_sensors_core_state core;
>>> +
>>> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
>>> +};
>>> +
>>> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
>>> +struct iio_chan_spec const *chan,
>>> +int *val, int *val2, long mask)
>>> +{
>>> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
>>> + u16 data = 0;
>>> + s64 val64;
>>> + int ret;
>>> + int idx = chan->scan_index;
>>> +
>>> + mutex_lock(>core.cmd_lock);
>>> +
>>> + switch (mask) {
>>> + case IIO_CHAN_INFO_RAW:
>>> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
>>> +(s16 *));
>> As I read the code, this is already being output in lux or
>>> + if (ret < 0)
>>> + 

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-30 Thread Enric Balletbo Serra
Hi Jonathan,

Many thanks for the review, I'm preparing v2. One question below.

2016-11-27 11:39 GMT+01:00 Jonathan Cameron :
> On 25/11/16 12:03, Enric Balletbo i Serra wrote:
>> From: Gwendal Grignou 
>>
>> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
>> Creates an IIO device for each functions.
>>
>> Signed-off-by: Gwendal Grignou 
>> Signed-off-by: Guenter Roeck 
>> Signed-off-by: Enric Balletbo i Serra 
> A few comments / questions inline.   We've missed the upcoming merge window
> now anyway so plenty of time to tidy up loose ends.
>
> Thanks,
>
> Jonathan
>> ---
>>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
>> +
>>  3 files changed, 287 insertions(+)
>>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>
>> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
>> b/drivers/iio/common/cros_ec_sensors/Kconfig
>> index 135f682..4fd0b87 100644
>> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
>> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
>> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
>> Accelerometers, Gyroscope and Magnetometer that are
>> presented by the ChromeOS EC Sensor hub.
>> Creates an IIO device for each functions.
>> +
>> +config IIO_CROS_EC_LIGHT_PROX
>> + tristate "ChromeOS EC Light and Proximity Sensors"
>> + select IIO_CROS_EC_SENSORS_CORE
> As the build bot has pointed out this doesn't work...
> I'd go with depends on myself as it's simpler than making sure to select
> the whole tree of things needed.
>

I'll fix this in v2.

>> + help
>> +   Module to handle Light and Proximity sensors
>> +   presented by the ChromeOS EC Sensor hub.
>> +   Creates an IIO device for each functions.
>> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
>> b/drivers/iio/common/cros_ec_sensors/Makefile
>> index ec716ff..7aaf2a2 100644
>> --- a/drivers/iio/common/cros_ec_sensors/Makefile
>> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
>> @@ -4,3 +4,4 @@
>>
>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
>> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
>> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
>> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>> new file mode 100644
>> index 000..40a34de
>> --- /dev/null
>> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>> @@ -0,0 +1,278 @@
>> +/*
>> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
>> + *
>> + * Copyright (C) 2016 Google, Inc
>> + *
>> + * This software is licensed under the terms of the GNU General Public
>> + * License version 2, as published by the Free Software Foundation, and
>> + * may be copied, distributed, and modified under those terms.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "cros_ec_sensors_core.h"
>> +
>> +/*
>> + * We only represent one entry for light or proximity. EC is merging 
>> different
>> + * light sensors to return the what the eye would see. For proximity, we
>> + * currently support only one light source.
>> + */
>> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
>> +
>> +/* State data for ec_sensors iio driver. */
>> +struct cros_ec_sensors_state {
>> + /* Shared by all sensors */
>> + struct cros_ec_sensors_core_state core;
>> +
>> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
>> +};
>> +
>> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
>> +struct iio_chan_spec const *chan,
>> +int *val, int *val2, long mask)
>> +{
>> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
>> + u16 data = 0;
>> + s64 val64;
>> + int ret;
>> + int idx = chan->scan_index;
>> +
>> + mutex_lock(>core.cmd_lock);
>> +
>> + switch (mask) {
>> + case IIO_CHAN_INFO_RAW:
>> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
>> +(s16 *));
> As I read the code, this is already being output in lux or
>> + if (ret < 0)
>> + break;
>> + *val = data;
>> + break;
>> +  

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-30 Thread Enric Balletbo Serra
Hi Jonathan,

Many thanks for the review, I'm preparing v2. One question below.

2016-11-27 11:39 GMT+01:00 Jonathan Cameron :
> On 25/11/16 12:03, Enric Balletbo i Serra wrote:
>> From: Gwendal Grignou 
>>
>> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
>> Creates an IIO device for each functions.
>>
>> Signed-off-by: Gwendal Grignou 
>> Signed-off-by: Guenter Roeck 
>> Signed-off-by: Enric Balletbo i Serra 
> A few comments / questions inline.   We've missed the upcoming merge window
> now anyway so plenty of time to tidy up loose ends.
>
> Thanks,
>
> Jonathan
>> ---
>>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
>> +
>>  3 files changed, 287 insertions(+)
>>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>>
>> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
>> b/drivers/iio/common/cros_ec_sensors/Kconfig
>> index 135f682..4fd0b87 100644
>> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
>> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
>> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
>> Accelerometers, Gyroscope and Magnetometer that are
>> presented by the ChromeOS EC Sensor hub.
>> Creates an IIO device for each functions.
>> +
>> +config IIO_CROS_EC_LIGHT_PROX
>> + tristate "ChromeOS EC Light and Proximity Sensors"
>> + select IIO_CROS_EC_SENSORS_CORE
> As the build bot has pointed out this doesn't work...
> I'd go with depends on myself as it's simpler than making sure to select
> the whole tree of things needed.
>

I'll fix this in v2.

>> + help
>> +   Module to handle Light and Proximity sensors
>> +   presented by the ChromeOS EC Sensor hub.
>> +   Creates an IIO device for each functions.
>> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
>> b/drivers/iio/common/cros_ec_sensors/Makefile
>> index ec716ff..7aaf2a2 100644
>> --- a/drivers/iio/common/cros_ec_sensors/Makefile
>> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
>> @@ -4,3 +4,4 @@
>>
>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
>> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
>> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
>> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>> new file mode 100644
>> index 000..40a34de
>> --- /dev/null
>> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
>> @@ -0,0 +1,278 @@
>> +/*
>> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
>> + *
>> + * Copyright (C) 2016 Google, Inc
>> + *
>> + * This software is licensed under the terms of the GNU General Public
>> + * License version 2, as published by the Free Software Foundation, and
>> + * may be copied, distributed, and modified under those terms.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "cros_ec_sensors_core.h"
>> +
>> +/*
>> + * We only represent one entry for light or proximity. EC is merging 
>> different
>> + * light sensors to return the what the eye would see. For proximity, we
>> + * currently support only one light source.
>> + */
>> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
>> +
>> +/* State data for ec_sensors iio driver. */
>> +struct cros_ec_sensors_state {
>> + /* Shared by all sensors */
>> + struct cros_ec_sensors_core_state core;
>> +
>> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
>> +};
>> +
>> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
>> +struct iio_chan_spec const *chan,
>> +int *val, int *val2, long mask)
>> +{
>> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
>> + u16 data = 0;
>> + s64 val64;
>> + int ret;
>> + int idx = chan->scan_index;
>> +
>> + mutex_lock(>core.cmd_lock);
>> +
>> + switch (mask) {
>> + case IIO_CHAN_INFO_RAW:
>> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
>> +(s16 *));
> As I read the code, this is already being output in lux or
>> + if (ret < 0)
>> + break;
>> + *val = data;
>> + break;
>> + case IIO_CHAN_INFO_CALIBBIAS:
>> + st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET;
>> +   

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-27 Thread Jonathan Cameron
On 25/11/16 12:03, Enric Balletbo i Serra wrote:
> From: Gwendal Grignou 
> 
> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
> Creates an IIO device for each functions.
> 
> Signed-off-by: Gwendal Grignou 
> Signed-off-by: Guenter Roeck 
> Signed-off-by: Enric Balletbo i Serra 
A few comments / questions inline.   We've missed the upcoming merge window
now anyway so plenty of time to tidy up loose ends.

Thanks,

Jonathan
> ---
>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
> +
>  3 files changed, 287 insertions(+)
>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
> b/drivers/iio/common/cros_ec_sensors/Kconfig
> index 135f682..4fd0b87 100644
> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
> Accelerometers, Gyroscope and Magnetometer that are
> presented by the ChromeOS EC Sensor hub.
> Creates an IIO device for each functions.
> +
> +config IIO_CROS_EC_LIGHT_PROX
> + tristate "ChromeOS EC Light and Proximity Sensors"
> + select IIO_CROS_EC_SENSORS_CORE
As the build bot has pointed out this doesn't work...
I'd go with depends on myself as it's simpler than making sure to select
the whole tree of things needed.

> + help
> +   Module to handle Light and Proximity sensors
> +   presented by the ChromeOS EC Sensor hub.
> +   Creates an IIO device for each functions.
> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
> b/drivers/iio/common/cros_ec_sensors/Makefile
> index ec716ff..7aaf2a2 100644
> --- a/drivers/iio/common/cros_ec_sensors/Makefile
> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
> @@ -4,3 +4,4 @@
>  
>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> new file mode 100644
> index 000..40a34de
> --- /dev/null
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> @@ -0,0 +1,278 @@
> +/*
> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
> + *
> + * Copyright (C) 2016 Google, Inc
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "cros_ec_sensors_core.h"
> +
> +/*
> + * We only represent one entry for light or proximity. EC is merging 
> different
> + * light sensors to return the what the eye would see. For proximity, we
> + * currently support only one light source.
> + */
> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
> +
> +/* State data for ec_sensors iio driver. */
> +struct cros_ec_sensors_state {
> + /* Shared by all sensors */
> + struct cros_ec_sensors_core_state core;
> +
> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
> +};
> +
> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
> +struct iio_chan_spec const *chan,
> +int *val, int *val2, long mask)
> +{
> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
> + u16 data = 0;
> + s64 val64;
> + int ret;
> + int idx = chan->scan_index;
> +
> + mutex_lock(>core.cmd_lock);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
> +(s16 *));
As I read the code, this is already being output in lux or 
> + if (ret < 0)
> + break;
> + *val = data;
> + break;
> + case IIO_CHAN_INFO_CALIBBIAS:
> + st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET;
> + st->core.param.sensor_offset.flags = 0;
> +
> + ret = cros_ec_motion_send_host_cmd(>core, 0);
> + if (ret < 0)
> + break;
> +
> + 

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-27 Thread Jonathan Cameron
On 25/11/16 12:03, Enric Balletbo i Serra wrote:
> From: Gwendal Grignou 
> 
> Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
> Creates an IIO device for each functions.
> 
> Signed-off-by: Gwendal Grignou 
> Signed-off-by: Guenter Roeck 
> Signed-off-by: Enric Balletbo i Serra 
A few comments / questions inline.   We've missed the upcoming merge window
now anyway so plenty of time to tidy up loose ends.

Thanks,

Jonathan
> ---
>  drivers/iio/common/cros_ec_sensors/Kconfig |   8 +
>  drivers/iio/common/cros_ec_sensors/Makefile|   1 +
>  .../common/cros_ec_sensors/cros_ec_light_prox.c| 278 
> +
>  3 files changed, 287 insertions(+)
>  create mode 100644 drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/Kconfig 
> b/drivers/iio/common/cros_ec_sensors/Kconfig
> index 135f682..4fd0b87 100644
> --- a/drivers/iio/common/cros_ec_sensors/Kconfig
> +++ b/drivers/iio/common/cros_ec_sensors/Kconfig
> @@ -20,3 +20,11 @@ config IIO_CROS_EC_SENSORS
> Accelerometers, Gyroscope and Magnetometer that are
> presented by the ChromeOS EC Sensor hub.
> Creates an IIO device for each functions.
> +
> +config IIO_CROS_EC_LIGHT_PROX
> + tristate "ChromeOS EC Light and Proximity Sensors"
> + select IIO_CROS_EC_SENSORS_CORE
As the build bot has pointed out this doesn't work...
I'd go with depends on myself as it's simpler than making sure to select
the whole tree of things needed.

> + help
> +   Module to handle Light and Proximity sensors
> +   presented by the ChromeOS EC Sensor hub.
> +   Creates an IIO device for each functions.
> diff --git a/drivers/iio/common/cros_ec_sensors/Makefile 
> b/drivers/iio/common/cros_ec_sensors/Makefile
> index ec716ff..7aaf2a2 100644
> --- a/drivers/iio/common/cros_ec_sensors/Makefile
> +++ b/drivers/iio/common/cros_ec_sensors/Makefile
> @@ -4,3 +4,4 @@
>  
>  obj-$(CONFIG_IIO_CROS_EC_SENSORS_CORE) += cros_ec_sensors_core.o
>  obj-$(CONFIG_IIO_CROS_EC_SENSORS) += cros_ec_sensors.o
> +obj-$(CONFIG_IIO_CROS_EC_LIGHT_PROX) += cros_ec_light_prox.o
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c 
> b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> new file mode 100644
> index 000..40a34de
> --- /dev/null
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_light_prox.c
> @@ -0,0 +1,278 @@
> +/*
> + * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
> + *
> + * Copyright (C) 2016 Google, Inc
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "cros_ec_sensors_core.h"
> +
> +/*
> + * We only represent one entry for light or proximity. EC is merging 
> different
> + * light sensors to return the what the eye would see. For proximity, we
> + * currently support only one light source.
> + */
> +#define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
> +
> +/* State data for ec_sensors iio driver. */
> +struct cros_ec_sensors_state {
> + /* Shared by all sensors */
> + struct cros_ec_sensors_core_state core;
> +
> + struct iio_chan_spec channels[CROS_EC_LIGHT_PROX_MAX_CHANNELS];
> +};
> +
> +static int cros_ec_light_prox_read(struct iio_dev *indio_dev,
> +struct iio_chan_spec const *chan,
> +int *val, int *val2, long mask)
> +{
> + struct cros_ec_sensors_state *st = iio_priv(indio_dev);
> + u16 data = 0;
> + s64 val64;
> + int ret;
> + int idx = chan->scan_index;
> +
> + mutex_lock(>core.cmd_lock);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
> +(s16 *));
As I read the code, this is already being output in lux or 
> + if (ret < 0)
> + break;
> + *val = data;
> + break;
> + case IIO_CHAN_INFO_CALIBBIAS:
> + st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET;
> + st->core.param.sensor_offset.flags = 0;
> +
> + ret = cros_ec_motion_send_host_cmd(>core, 0);
> + if (ret < 0)
> + break;
> +
> + /* Save values */
> + st->core.calib[0] = st->core.resp->sensor_offset.offset[0];

Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-26 Thread kbuild test robot
Hi Gwendal,

[auto build test WARNING on iio/togreg]
[also build test WARNING on next-20161125]
[cannot apply to v4.9-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Enric-Balletbo-i-Serra/iio-cros_ec_light_prox-add-ChromeOS-EC-Light-and-Proximity-Sensors/20161125-232924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: um-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=um 

All warnings (new ones prefixed by >>):

warning: (IIO_CROS_EC_LIGHT_PROX) selects IIO_CROS_EC_SENSORS_CORE which has 
unmet direct dependencies (IIO && SYSFS && MFD_CROS_EC)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors

2016-11-26 Thread kbuild test robot
Hi Gwendal,

[auto build test WARNING on iio/togreg]
[also build test WARNING on next-20161125]
[cannot apply to v4.9-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Enric-Balletbo-i-Serra/iio-cros_ec_light_prox-add-ChromeOS-EC-Light-and-Proximity-Sensors/20161125-232924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: um-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=um 

All warnings (new ones prefixed by >>):

warning: (IIO_CROS_EC_LIGHT_PROX) selects IIO_CROS_EC_SENSORS_CORE which has 
unmet direct dependencies (IIO && SYSFS && MFD_CROS_EC)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip