linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] iio: isl29028: move out of staging
@ 2017-02-09  1:54 Brian Masney
  2017-02-09  1:54 ` [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep() Brian Masney
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

This is my last series of staging cleanups for the ISL29028 driver.
Highlights of this patch series include some cleanups to the timing
code, a fix for runtime power management support, and documentation.

I mentioned in one of my earlier patch series that I was having issues
getting the proximity sensing portion of the sensor working. This
appears to be an issue with my sensor since I was able to get the
proximity sensor working intermittenly by tapping the chip. It is
likely an issue with the way that the chip was mounted on my breakout
board. I've also verified with a cell phone screen that the IR LED
turns on for two seconds when the proximity sensing feature is enabled.

Brian Masney (7):
  staging: iio: isl29028: change mdelay() to msleep()
  staging: iio: isl29028: fix incorrect sleep time when taking proximity
    reading
  staging: iio: isl29028: fix incorrect sampling frequency value
  staging: iio: isl29028: use the runtime power management for system
    sleep
  staging: iio: isl29028: add copyright
  iio: Documentation: add ABI documentation for
    in_proximity_sampling_frequency_available
  staging: iio: isl29028: move out of staging

 Documentation/ABI/testing/sysfs-bus-iio    |  1 +
 drivers/iio/light/Kconfig                  | 10 ++++++++
 drivers/iio/light/Makefile                 |  1 +
 drivers/{staging => }/iio/light/isl29028.c | 39 ++++++++++++++++++++----------
 drivers/staging/iio/light/Kconfig          | 10 --------
 drivers/staging/iio/light/Makefile         |  1 -
 6 files changed, 38 insertions(+), 24 deletions(-)
 rename drivers/{staging => }/iio/light/isl29028.c (95%)

-- 
2.9.3

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

* [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep()
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:41   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading Brian Masney
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

This driver in some cases can busy wait for upwards of 100 ms. Since the
kernel at this point is not running in atomic context, and is running in
process context, we can safely use msleep() instead. This patch changes
the two occurrences of mdelay() to msleep().

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29028.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index 6bb6d37..8dc24c94 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -121,7 +121,7 @@ static int isl29028_enable_proximity(struct isl29028_chip *chip)
 		return ret;
 
 	/* Wait for conversion to be complete for first sample */
-	mdelay(DIV_ROUND_UP(1000, chip->prox_sampling));
+	msleep(DIV_ROUND_UP(1000, chip->prox_sampling));
 
 	return 0;
 }
@@ -192,7 +192,7 @@ static int isl29028_set_als_ir_mode(struct isl29028_chip *chip,
 		return ret;
 
 	/* Need to wait for conversion time if ALS/IR mode enabled */
-	mdelay(ISL29028_CONV_TIME_MS);
+	msleep(ISL29028_CONV_TIME_MS);
 
 	chip->als_ir_mode = mode;
 
-- 
2.9.3

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

* [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
  2017-02-09  1:54 ` [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep() Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:40   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value Brian Masney
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

When proximity is enabled in isl29028_enable_proximity(), the function
msleep() is called with the sampling frequency, which is not correct.
This patch changes the code to sleep the specified amount of time listed
in the datasheet instead.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29028.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index 8dc24c94..177dced 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -63,6 +63,9 @@
 
 #define ISL29028_POWER_OFF_DELAY_MS		2000
 
+static const unsigned int isl29028_prox_sleep_time[] = {800, 400, 200, 100, 75,
+							50, 12, 0};
+
 enum isl29028_als_ir_mode {
 	ISL29028_MODE_NONE = 0,
 	ISL29028_MODE_ALS,
@@ -78,22 +81,29 @@ struct isl29028_chip {
 	enum isl29028_als_ir_mode	als_ir_mode;
 };
 
-static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
-					unsigned int sampling)
+static int isl29028_find_prox_sleep_time_index(int sampling)
 {
-	struct device *dev = regmap_get_device(chip->regmap);
-	static unsigned int prox_period[] = {800, 400, 200, 100, 75, 50, 12, 0};
 	unsigned int period = DIV_ROUND_UP(1000, sampling);
-	int sel, ret;
+	int i;
 
-	for (sel = 0; sel < ARRAY_SIZE(prox_period); ++sel) {
-		if (period >= prox_period[sel])
+	for (i = 0; i < ARRAY_SIZE(isl29028_prox_sleep_time); ++i) {
+		if (period >= isl29028_prox_sleep_time[i])
 			break;
 	}
 
+	return i;
+}
+
+static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
+					unsigned int sampling)
+{
+	struct device *dev = regmap_get_device(chip->regmap);
+	int sleep_index, ret;
+
+	sleep_index = isl29028_find_prox_sleep_time_index(sampling);
 	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
 				 ISL29028_CONF_PROX_SLP_MASK,
-				 sel << ISL29028_CONF_PROX_SLP_SH);
+				 sleep_index << ISL29028_CONF_PROX_SLP_SH);
 
 	if (ret < 0) {
 		dev_err(dev, "%s(): Error %d setting the proximity sampling\n",
@@ -108,7 +118,7 @@ static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
 
 static int isl29028_enable_proximity(struct isl29028_chip *chip)
 {
-	int ret;
+	int sleep_index, ret;
 
 	ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling);
 	if (ret < 0)
@@ -121,7 +131,8 @@ static int isl29028_enable_proximity(struct isl29028_chip *chip)
 		return ret;
 
 	/* Wait for conversion to be complete for first sample */
-	msleep(DIV_ROUND_UP(1000, chip->prox_sampling));
+	sleep_index = isl29028_find_prox_sleep_time_index(chip->prox_sampling);
+	msleep(isl29028_prox_sleep_time[sleep_index]);
 
 	return 0;
 }
-- 
2.9.3

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

* [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
  2017-02-09  1:54 ` [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep() Brian Masney
  2017-02-09  1:54 ` [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:44   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep Brian Masney
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

The sysfs attribute in_proximity_sampling_frequency_available currently
shows the values 1 3 5 10 13 20 83 100. These values are supposed to
correspond to the sleep values 800 400 200 100 75 50 12 0 (all in ms).
When passing in a sampling frequency of 3, it actually uses a sleep
time of 200ms instead of the expected 400ms value. This patch changes
the 3 supported sampling frequency to 2 so that the proximity sleep
time of 400ms can be used.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29028.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index 177dced..b63fdf70 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -471,7 +471,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,
 }
 
 static IIO_CONST_ATTR(in_proximity_sampling_frequency_available,
-				"1 3 5 10 13 20 83 100");
+				"1 2 5 10 13 20 83 100");
 static IIO_CONST_ATTR(in_illuminance_scale_available, "125 2000");
 
 #define ISL29028_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
-- 
2.9.3

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

* [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
                   ` (2 preceding siblings ...)
  2017-02-09  1:54 ` [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:47   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 5/7] staging: iio: isl29028: add copyright Brian Masney
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

With the introduction of runtime power management in commit 2db5054ac28d
("staging: iio: isl29028: add runtime power management support"), the
system could go to sleep and turn off the device without notifying the
runtime power management code. This patch changes the system suspend
and resume to go through the runtime power management.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29028.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index b63fdf70..ddd604d 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -656,7 +656,8 @@ static int __maybe_unused isl29028_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops isl29028_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(isl29028_suspend, isl29028_resume)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
 	SET_RUNTIME_PM_OPS(isl29028_suspend, isl29028_resume, NULL)
 };
 
-- 
2.9.3

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

* [PATCH 5/7] staging: iio: isl29028: add copyright
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
                   ` (3 preceding siblings ...)
  2017-02-09  1:54 ` [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:49   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available Brian Masney
  2017-02-09  1:54 ` [PATCH 7/7] staging: iio: isl29028: move out of staging Brian Masney
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

Add Brian Masney's copyright to the header for the several rounds of
staging cleanups that has been done to this driver.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29028.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index ddd604d..68b76b0 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -3,6 +3,7 @@
  * ISL29028 is Concurrent Ambient Light and Proximity Sensor
  *
  * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
-- 
2.9.3

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

* [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
                   ` (4 preceding siblings ...)
  2017-02-09  1:54 ` [PATCH 5/7] staging: iio: isl29028: add copyright Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:50   ` Jonathan Cameron
  2017-02-09  1:54 ` [PATCH 7/7] staging: iio: isl29028: move out of staging Brian Masney
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

Add entry for the in_proximity_sampling_frequency_available sysfs
entry to the existing sampling_frequency_available ABI documentation.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 Documentation/ABI/testing/sysfs-bus-iio | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 530809c..1ce4603 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -55,6 +55,7 @@ Description:
 		then it is to be found in the base device directory.
 
 What:		/sys/bus/iio/devices/iio:deviceX/sampling_frequency_available
+What:		/sys/bus/iio/devices/iio:deviceX/in_proximity_sampling_frequency_available
 What:		/sys/.../iio:deviceX/buffer/sampling_frequency_available
 What:		/sys/bus/iio/devices/triggerX/sampling_frequency_available
 KernelVersion:	2.6.35
-- 
2.9.3

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

* [PATCH 7/7] staging: iio: isl29028: move out of staging
  2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
                   ` (5 preceding siblings ...)
  2017-02-09  1:54 ` [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available Brian Masney
@ 2017-02-09  1:54 ` Brian Masney
  2017-02-11  9:54   ` Jonathan Cameron
  6 siblings, 1 reply; 15+ messages in thread
From: Brian Masney @ 2017-02-09  1:54 UTC (permalink / raw)
  To: jic23
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

Move ISL29028 ALS / Proximity Sensor out of staging and into mainline.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/iio/light/Kconfig                  | 10 ++++++++++
 drivers/iio/light/Makefile                 |  1 +
 drivers/{staging => }/iio/light/isl29028.c |  0
 drivers/staging/iio/light/Kconfig          | 10 ----------
 drivers/staging/iio/light/Makefile         |  1 -
 5 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/{staging => }/iio/light/isl29028.c (100%)

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 2afcbac..8b8c9e2 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -172,6 +172,16 @@ config SENSORS_ISL29018
 	 in lux, proximity infrared sensing and normal infrared sensing.
 	 Data from sensor is accessible via sysfs.
 
+config SENSORS_ISL29028
+	tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	 Provides driver for the Intersil's ISL29028 device.
+	 This driver supports the sysfs interface to get the ALS, IR intensity,
+	 Proximity value via iio. The ISL29028 provides the concurrent sensing
+	 of ambient light and proximity.
+
 config ISL29125
 	tristate "Intersil ISL29125 digital color light sensor"
 	depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index edfd69b..2e730af 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_GP2AP020A00F)	+= gp2ap020a00f.o
 obj-$(CONFIG_HID_SENSOR_ALS)	+= hid-sensor-als.o
 obj-$(CONFIG_HID_SENSOR_PROX)	+= hid-sensor-prox.o
 obj-$(CONFIG_SENSORS_ISL29018)	+= isl29018.o
+obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
 obj-$(CONFIG_ISL29125)		+= isl29125.o
 obj-$(CONFIG_JSA1212)		+= jsa1212.o
 obj-$(CONFIG_SENSORS_LM3533)	+= lm3533-als.o
diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/iio/light/isl29028.c
similarity index 100%
rename from drivers/staging/iio/light/isl29028.c
rename to drivers/iio/light/isl29028.c
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
index 4fbf629..aacb0ae 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -3,16 +3,6 @@
 #
 menu "Light sensors"
 
-config SENSORS_ISL29028
-	tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	 Provides driver for the Intersil's ISL29028 device.
-	 This driver supports the sysfs interface to get the ALS, IR intensity,
-	 Proximity value via iio. The ISL29028 provides the concurrent sensing
-	 of ambient light and proximity.
-
 config TSL2x7x
 	tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors"
 	depends on I2C
diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile
index f8693e9..10286c3 100644
--- a/drivers/staging/iio/light/Makefile
+++ b/drivers/staging/iio/light/Makefile
@@ -2,5 +2,4 @@
 # Makefile for industrial I/O Light sensors
 #
 
-obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
 obj-$(CONFIG_TSL2x7x)	+= tsl2x7x_core.o
-- 
2.9.3

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

* Re: [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading
  2017-02-09  1:54 ` [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading Brian Masney
@ 2017-02-11  9:40   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:40 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> When proximity is enabled in isl29028_enable_proximity(), the function
> msleep() is called with the sampling frequency, which is not correct.
> This patch changes the code to sleep the specified amount of time listed
> in the datasheet instead.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Seems sensible.  Applied to the togreg branch of iio.git and pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 31 +++++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index 8dc24c94..177dced 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -63,6 +63,9 @@
>  
>  #define ISL29028_POWER_OFF_DELAY_MS		2000
>  
> +static const unsigned int isl29028_prox_sleep_time[] = {800, 400, 200, 100, 75,
> +							50, 12, 0};
> +
>  enum isl29028_als_ir_mode {
>  	ISL29028_MODE_NONE = 0,
>  	ISL29028_MODE_ALS,
> @@ -78,22 +81,29 @@ struct isl29028_chip {
>  	enum isl29028_als_ir_mode	als_ir_mode;
>  };
>  
> -static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
> -					unsigned int sampling)
> +static int isl29028_find_prox_sleep_time_index(int sampling)
>  {
> -	struct device *dev = regmap_get_device(chip->regmap);
> -	static unsigned int prox_period[] = {800, 400, 200, 100, 75, 50, 12, 0};
>  	unsigned int period = DIV_ROUND_UP(1000, sampling);
> -	int sel, ret;
> +	int i;
>  
> -	for (sel = 0; sel < ARRAY_SIZE(prox_period); ++sel) {
> -		if (period >= prox_period[sel])
> +	for (i = 0; i < ARRAY_SIZE(isl29028_prox_sleep_time); ++i) {
> +		if (period >= isl29028_prox_sleep_time[i])
>  			break;
>  	}
>  
> +	return i;
> +}
> +
> +static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
> +					unsigned int sampling)
> +{
> +	struct device *dev = regmap_get_device(chip->regmap);
> +	int sleep_index, ret;
> +
> +	sleep_index = isl29028_find_prox_sleep_time_index(sampling);
>  	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
>  				 ISL29028_CONF_PROX_SLP_MASK,
> -				 sel << ISL29028_CONF_PROX_SLP_SH);
> +				 sleep_index << ISL29028_CONF_PROX_SLP_SH);
>  
>  	if (ret < 0) {
>  		dev_err(dev, "%s(): Error %d setting the proximity sampling\n",
> @@ -108,7 +118,7 @@ static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
>  
>  static int isl29028_enable_proximity(struct isl29028_chip *chip)
>  {
> -	int ret;
> +	int sleep_index, ret;
>  
>  	ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling);
>  	if (ret < 0)
> @@ -121,7 +131,8 @@ static int isl29028_enable_proximity(struct isl29028_chip *chip)
>  		return ret;
>  
>  	/* Wait for conversion to be complete for first sample */
> -	msleep(DIV_ROUND_UP(1000, chip->prox_sampling));
> +	sleep_index = isl29028_find_prox_sleep_time_index(chip->prox_sampling);
> +	msleep(isl29028_prox_sleep_time[sleep_index]);
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep()
  2017-02-09  1:54 ` [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep() Brian Masney
@ 2017-02-11  9:41   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:41 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> This driver in some cases can busy wait for upwards of 100 ms. Since the
> kernel at this point is not running in atomic context, and is running in
> process context, we can safely use msleep() instead. This patch changes
> the two occurrences of mdelay() to msleep().
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index 6bb6d37..8dc24c94 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -121,7 +121,7 @@ static int isl29028_enable_proximity(struct isl29028_chip *chip)
>  		return ret;
>  
>  	/* Wait for conversion to be complete for first sample */
> -	mdelay(DIV_ROUND_UP(1000, chip->prox_sampling));
> +	msleep(DIV_ROUND_UP(1000, chip->prox_sampling));
>  
>  	return 0;
>  }
> @@ -192,7 +192,7 @@ static int isl29028_set_als_ir_mode(struct isl29028_chip *chip,
>  		return ret;
>  
>  	/* Need to wait for conversion time if ALS/IR mode enabled */
> -	mdelay(ISL29028_CONV_TIME_MS);
> +	msleep(ISL29028_CONV_TIME_MS);
>  
>  	chip->als_ir_mode = mode;
>  
> 

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

* Re: [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value
  2017-02-09  1:54 ` [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value Brian Masney
@ 2017-02-11  9:44   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:44 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> The sysfs attribute in_proximity_sampling_frequency_available currently
> shows the values 1 3 5 10 13 20 83 100. These values are supposed to
> correspond to the sleep values 800 400 200 100 75 50 12 0 (all in ms).
> When passing in a sampling frequency of 3, it actually uses a sleep
> time of 200ms instead of the expected 400ms value. This patch changes
> the 3 supported sampling frequency to 2 so that the proximity sleep
> time of 400ms can be used.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Given there is no real difficulty in supporting fixed point numbers, could
we move this over to:
1, 2.5, 5 etc

Will clearly require more changes than you have with the fixup here, but
would represent what is going on more accurately for minimal cost.

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index 177dced..b63fdf70 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -471,7 +471,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,
>  }
>  
>  static IIO_CONST_ATTR(in_proximity_sampling_frequency_available,
> -				"1 3 5 10 13 20 83 100");
> +				"1 2 5 10 13 20 83 100");
>  static IIO_CONST_ATTR(in_illuminance_scale_available, "125 2000");
>  
>  #define ISL29028_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
> 

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

* Re: [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep
  2017-02-09  1:54 ` [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep Brian Masney
@ 2017-02-11  9:47   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:47 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> With the introduction of runtime power management in commit 2db5054ac28d
> ("staging: iio: isl29028: add runtime power management support"), the
> system could go to sleep and turn off the device without notifying the
> runtime power management code. This patch changes the system suspend
> and resume to go through the runtime power management.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index b63fdf70..ddd604d 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -656,7 +656,8 @@ static int __maybe_unused isl29028_resume(struct device *dev)
>  }
>  
>  static const struct dev_pm_ops isl29028_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(isl29028_suspend, isl29028_resume)
> +	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> +				pm_runtime_force_resume)
>  	SET_RUNTIME_PM_OPS(isl29028_suspend, isl29028_resume, NULL)
>  };
>  
> 

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

* Re: [PATCH 5/7] staging: iio: isl29028: add copyright
  2017-02-09  1:54 ` [PATCH 5/7] staging: iio: isl29028: add copyright Brian Masney
@ 2017-02-11  9:49   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:49 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> Add Brian Masney's copyright to the header for the several rounds of
> staging cleanups that has been done to this driver.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to play with it.

Not that they'll do much with this one ;)

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index ddd604d..68b76b0 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -3,6 +3,7 @@
>   * ISL29028 is Concurrent Ambient Light and Proximity Sensor
>   *
>   * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
> + * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org>
>   *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms and conditions of the GNU General Public License,
> 

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

* Re: [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available
  2017-02-09  1:54 ` [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available Brian Masney
@ 2017-02-11  9:50   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:50 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> Add entry for the in_proximity_sampling_frequency_available sysfs
> entry to the existing sampling_frequency_available ABI documentation.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 530809c..1ce4603 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -55,6 +55,7 @@ Description:
>  		then it is to be found in the base device directory.
>  
>  What:		/sys/bus/iio/devices/iio:deviceX/sampling_frequency_available
> +What:		/sys/bus/iio/devices/iio:deviceX/in_proximity_sampling_frequency_available
>  What:		/sys/.../iio:deviceX/buffer/sampling_frequency_available
>  What:		/sys/bus/iio/devices/triggerX/sampling_frequency_available
>  KernelVersion:	2.6.35
> 

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

* Re: [PATCH 7/7] staging: iio: isl29028: move out of staging
  2017-02-09  1:54 ` [PATCH 7/7] staging: iio: isl29028: move out of staging Brian Masney
@ 2017-02-11  9:54   ` Jonathan Cameron
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Cameron @ 2017-02-11  9:54 UTC (permalink / raw)
  To: Brian Masney
  Cc: gregkh, linux-iio, devel, knaack.h, lars, pmeerw, linux-kernel,
	ldewangan

On 09/02/17 01:54, Brian Masney wrote:
> Move ISL29028 ALS / Proximity Sensor out of staging and into mainline.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
I've taken another quick look at the driver and think this will be fine once
we have cleaned up that small question on the sampling frequencies.

Jonathan
> ---
>  drivers/iio/light/Kconfig                  | 10 ++++++++++
>  drivers/iio/light/Makefile                 |  1 +
>  drivers/{staging => }/iio/light/isl29028.c |  0
>  drivers/staging/iio/light/Kconfig          | 10 ----------
>  drivers/staging/iio/light/Makefile         |  1 -
>  5 files changed, 11 insertions(+), 11 deletions(-)
>  rename drivers/{staging => }/iio/light/isl29028.c (100%)
> 
> diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
> index 2afcbac..8b8c9e2 100644
> --- a/drivers/iio/light/Kconfig
> +++ b/drivers/iio/light/Kconfig
> @@ -172,6 +172,16 @@ config SENSORS_ISL29018
>  	 in lux, proximity infrared sensing and normal infrared sensing.
>  	 Data from sensor is accessible via sysfs.
>  
> +config SENSORS_ISL29028
> +	tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor"
> +	depends on I2C
> +	select REGMAP_I2C
> +	help
> +	 Provides driver for the Intersil's ISL29028 device.
> +	 This driver supports the sysfs interface to get the ALS, IR intensity,
> +	 Proximity value via iio. The ISL29028 provides the concurrent sensing
> +	 of ambient light and proximity.
> +
>  config ISL29125
>  	tristate "Intersil ISL29125 digital color light sensor"
>  	depends on I2C
> diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
> index edfd69b..2e730af 100644
> --- a/drivers/iio/light/Makefile
> +++ b/drivers/iio/light/Makefile
> @@ -20,6 +20,7 @@ obj-$(CONFIG_GP2AP020A00F)	+= gp2ap020a00f.o
>  obj-$(CONFIG_HID_SENSOR_ALS)	+= hid-sensor-als.o
>  obj-$(CONFIG_HID_SENSOR_PROX)	+= hid-sensor-prox.o
>  obj-$(CONFIG_SENSORS_ISL29018)	+= isl29018.o
> +obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
>  obj-$(CONFIG_ISL29125)		+= isl29125.o
>  obj-$(CONFIG_JSA1212)		+= jsa1212.o
>  obj-$(CONFIG_SENSORS_LM3533)	+= lm3533-als.o
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/iio/light/isl29028.c
> similarity index 100%
> rename from drivers/staging/iio/light/isl29028.c
> rename to drivers/iio/light/isl29028.c
> diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
> index 4fbf629..aacb0ae 100644
> --- a/drivers/staging/iio/light/Kconfig
> +++ b/drivers/staging/iio/light/Kconfig
> @@ -3,16 +3,6 @@
>  #
>  menu "Light sensors"
>  
> -config SENSORS_ISL29028
> -	tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor"
> -	depends on I2C
> -	select REGMAP_I2C
> -	help
> -	 Provides driver for the Intersil's ISL29028 device.
> -	 This driver supports the sysfs interface to get the ALS, IR intensity,
> -	 Proximity value via iio. The ISL29028 provides the concurrent sensing
> -	 of ambient light and proximity.
> -
>  config TSL2x7x
>  	tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors"
>  	depends on I2C
> diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile
> index f8693e9..10286c3 100644
> --- a/drivers/staging/iio/light/Makefile
> +++ b/drivers/staging/iio/light/Makefile
> @@ -2,5 +2,4 @@
>  # Makefile for industrial I/O Light sensors
>  #
>  
> -obj-$(CONFIG_SENSORS_ISL29028)	+= isl29028.o
>  obj-$(CONFIG_TSL2x7x)	+= tsl2x7x_core.o
> 

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

end of thread, other threads:[~2017-02-11  9:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09  1:54 [PATCH 0/7] iio: isl29028: move out of staging Brian Masney
2017-02-09  1:54 ` [PATCH 1/7] staging: iio: isl29028: change mdelay() to msleep() Brian Masney
2017-02-11  9:41   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 2/7] staging: iio: isl29028: fix incorrect sleep time when taking initial proximity reading Brian Masney
2017-02-11  9:40   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 3/7] staging: iio: isl29028: fix incorrect sampling frequency value Brian Masney
2017-02-11  9:44   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 4/7] staging: iio: isl29028: use the runtime power management for system sleep Brian Masney
2017-02-11  9:47   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 5/7] staging: iio: isl29028: add copyright Brian Masney
2017-02-11  9:49   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 6/7] iio: Documentation: add ABI documentation for in_proximity_sampling_frequency_available Brian Masney
2017-02-11  9:50   ` Jonathan Cameron
2017-02-09  1:54 ` [PATCH 7/7] staging: iio: isl29028: move out of staging Brian Masney
2017-02-11  9:54   ` 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).