mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shreeya Patel <shreeya.patel@collabora.com>
To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org,
	Zhigang.Shi@liteon.com, krzk@kernel.org, krisman@collabora.com
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel@collabora.com,
	alvaro.soliverez@collabora.com
Subject: Re: [PATCH v3 3/3] iio: light: Add support for ltrf216a sensor
Date: Tue, 3 May 2022 22:37:49 +0530	[thread overview]
Message-ID: <8916313f-0974-0d2d-091b-17e5765c0304@collabora.com> (raw)
In-Reply-To: <20220503144354.75438-4-shreeya.patel@collabora.com>

Hi Jonathan,


Just one comment inline related to your previous review.

On 03/05/22 20:13, Shreeya Patel wrote:
> From: Zhigang Shi <Zhigang.Shi@liteon.com>
>
> Add initial support for ltrf216a ambient light sensor.
>
> Datasheet: gitlab.steamos.cloud/shreeya/iio/-/blob/main/LTRF216A.pdf
> Co-developed-by: Shreeya Patel <shreeya.patel@collabora.com>
> Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
> Signed-off-by: Zhigang Shi <Zhigang.Shi@liteon.com>
> ---
>
> Changes in v3
>    - Use u16 instead of u8 for int_time_fac
>    - Reorder headers in ltrf216a.c file
>    - Remove int_time_mapping table and use int_time_available
>
> Changes in v2
>    - Add support for 25ms and 50ms integration time.
>    - Rename some of the macros as per names given in datasheet
>    - Add a comment for the mutex lock
>    - Use read_avail callback instead of attributes and set the
>      appropriate _available bit.
>    - Use FIELD_PREP() at appropriate places.
>    - Add a constant lookup table for integration time and reg val
>    - Use BIT() macro for magic numbers.
>    - Improve error handling at few places.
>    - Use get_unaligned_le24() and div_u64()
>    - Use probe_new() callback and devm functions
>    - Return errors in probe using dev_err_probe()
>    - Use DEFINE_SIMPLE_DEV_PM_OPS()
>    - Correct the formula for lux to use 0.45 instead of 0.8
>
>
>   drivers/iio/light/Kconfig    |  10 +
>   drivers/iio/light/Makefile   |   1 +
>   drivers/iio/light/ltrf216a.c | 343 +++++++++++++++++++++++++++++++++++
>   3 files changed, 354 insertions(+)
>   create mode 100644 drivers/iio/light/ltrf216a.c
>
> diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
> index a62c7b4b8678..33d2b24ba1da 100644
> --- a/drivers/iio/light/Kconfig
> +++ b/drivers/iio/light/Kconfig
> @@ -318,6 +318,16 @@ config SENSORS_LM3533
>   	  changes. The ALS-control output values can be set per zone for the
>   	  three current output channels.
>   
> +config LTRF216A
> +	tristate "Liteon LTRF216A Light Sensor"
> +	depends on I2C
> +	help
> +	  If you say Y or M here, you get support for Liteon LTRF216A
> +	  Ambient Light Sensor.
> +
> +	  If built as a dynamically linked module, it will be called
> +	  ltrf216a.
> +
>   config LTR501
>   	tristate "LTR-501ALS-01 light sensor"
>   	depends on I2C
> diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
> index d10912faf964..8fa91b9fe5b6 100644
> --- a/drivers/iio/light/Makefile
> +++ b/drivers/iio/light/Makefile
> @@ -30,6 +30,7 @@ obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
>   obj-$(CONFIG_ISL29125)		+= isl29125.o
>   obj-$(CONFIG_JSA1212)		+= jsa1212.o
>   obj-$(CONFIG_SENSORS_LM3533)	+= lm3533-als.o
> +obj-$(CONFIG_LTRF216A)		+= ltrf216a.o
>   obj-$(CONFIG_LTR501)		+= ltr501.o
>   obj-$(CONFIG_LV0104CS)		+= lv0104cs.o
>   obj-$(CONFIG_MAX44000)		+= max44000.o
> diff --git a/drivers/iio/light/ltrf216a.c b/drivers/iio/light/ltrf216a.c
> new file mode 100644
> index 000000000000..1ad1eb4a4c6d
> --- /dev/null
> +++ b/drivers/iio/light/ltrf216a.c
> @@ -0,0 +1,343 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * LTRF216A Ambient Light Sensor
> + *
> + * Copyright (C) 2021 Lite-On Technology Corp (Singapore)
> + * Author: Shi Zhigang <Zhigang.Shi@liteon.com>
> + *
> + * IIO driver for LTRF216A (7-bit I2C slave address 0x53).
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/delay.h>
> +#include <linux/i2c.h>
> +#include <linux/init.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/pm.h>
> +#include <linux/iio/iio.h>
> +#include <asm/unaligned.h>
> +
> +#define LTRF216A_DRV_NAME "ltrf216a"
> +
> +#define LTRF216A_MAIN_CTRL		0x00
> +
> +#define LTRF216A_ALS_DATA_STATUS	BIT(3)
> +#define LTRF216A_ALS_ENABLE_MASK	BIT(1)
> +
> +#define LTRF216A_ALS_MEAS_RES		0x04
> +#define LTRF216A_MAIN_STATUS		0x07
> +#define LTRF216A_CLEAR_DATA_0		0x0A
> +
> +#define LTRF216A_ALS_DATA_0		0x0D
> +
> +static const int ltrf216a_int_time_available[5][2] = {
> +	{0, 400000},
> +	{0, 200000},
> +	{0, 100000},
> +	{0, 50000},
> +	{0, 25000},
> +};
> +
> +static const int ltrf216a_int_time_reg[5][2] = {
> +	{400, 0x03},
> +	{200, 0x13},
> +	{100, 0x22},
> +	{50, 0x31},
> +	{25, 0x40},
> +};
> +
> +struct ltrf216a_data {
> +	struct i2c_client *client;
> +	u32 int_time;
> +	u16 int_time_fac;
> +	u8 als_gain_fac;
> +	struct mutex mutex; /* Protect read and write operations */

I wasn't really sure about your comment related to the lock description 
here.
I see we are using these locks in read_raw and write_raw functions only and
hence I've added the above comment.



Thanks,
Shreeya Patel

  reply	other threads:[~2022-05-03 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 14:43 [PATCH v3 0/3] Add LTRF216A Driver Shreeya Patel
2022-05-03 14:43 ` [PATCH v3 1/3] dt-bindings: vendor-prefixes: Add 'ltr' as deprecated vendor prefix Shreeya Patel
2022-05-03 14:43 ` [PATCH v3 2/3] dt-bindings: Document ltrf216a light sensor bindings Shreeya Patel
2022-05-03 14:43 ` [PATCH v3 3/3] iio: light: Add support for ltrf216a sensor Shreeya Patel
2022-05-03 17:07   ` Shreeya Patel [this message]
2022-05-07 16:47     ` Jonathan Cameron
2022-05-07 16:59   ` 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=8916313f-0974-0d2d-091b-17e5765c0304@collabora.com \
    --to=shreeya.patel@collabora.com \
    --cc=Zhigang.Shi@liteon.com \
    --cc=alvaro.soliverez@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=krzk@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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

all inboxes | Powered by JetHome®