Skip to contentSkip to conversation

Added driver for ISL29003 ambient light sensor

PATCH In review Daniel Mack 7 participants 40 messages Feb 25, 2009 – Mar 11, 2009 26 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/i2c/chips/Kconfig        |   10 +
 drivers/i2c/chips/Makefile       |    1 +
 drivers/i2c/chips/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/i2c/chips/isl29003.c
Documentation/i2c/chips/isl29003 new file +62 -0
new file mode 100644
index 0000000..f808141
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com&data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensors with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routing will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+value (read only):
+	returns the value from the last sensor reading
+
drivers/i2c/chips/Kconfig +10 -0
index c80312c..d10f515 100644
@@ -102,4 +102,14 @@ config SENSORS_TSL2550
 	  This driver can also be built as a module.  If so, the module
 	  will be called tsl2550.
 
+config SENSORS_ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on EXPERIMENTAL
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 endmenu
drivers/i2c/chips/Makefile +1 -0
index d142f23..c94c8a6 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_PCF8575)		+= pcf8575.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
+obj-$(CONFIG_SENSORS_ISL29003)	+= isl29003.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/isl29003.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
1.6.1.3

A message that is not in the archive (sent off-list or not yet received): 1235592618-10880-1-git-send-email-daniel-rDUAYElUppE@public.gmane.org

#2 lore raw

PATCH 1/1 Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Fixed some typos in the documentation.

 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/i2c/chips/Kconfig        |   10 +
 drivers/i2c/chips/Makefile       |    1 +
 drivers/i2c/chips/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/i2c/chips/isl29003.c
Documentation/i2c/chips/isl29003 new file +62 -0
new file mode 100644
index 0000000..f808141
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routing will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading in lux
+
drivers/i2c/chips/Kconfig +10 -0
index c80312c..d10f515 100644
@@ -102,4 +102,14 @@ config SENSORS_TSL2550
 	  This driver can also be built as a module.  If so, the module
 	  will be called tsl2550.
 
+config SENSORS_ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on EXPERIMENTAL
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 endmenu
drivers/i2c/chips/Makefile +1 -0
index d142f23..c94c8a6 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_PCF8575)		+= pcf8575.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
+obj-$(CONFIG_SENSORS_ISL29003)	+= isl29003.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/isl29003.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
1.6.1.3
#3 lore raw
In reply to a message not in the archive

Hi Daniel,

Quoted 9 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/i2c/chips/Kconfig        |   10 +
 drivers/i2c/chips/Makefile       |    1 +

Please read the header of these 2 files again.

Quoted 4 lines
 drivers/i2c/chips/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/i2c/chips/isl29003.c
Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Hi Jean,

Quoted 5 lines · Jean Delvare
Quoted 4 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

Quoted 7 lines
Quoted 5 lines
---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/i2c/chips/Kconfig        |   10 +
 drivers/i2c/chips/Makefile       |    1 +

Please read the header of these 2 files again.

Ok, I missed that. But drivers for I2C based devices will still be submitted via this list?

Daniel

A message that is not in the archive (sent off-list or not yet received): 20090225234004.GA19039-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#7 lore raw
Quoted 14 lines · Daniel Mack

Hi Jean,

Quoted 11 lines · Jean Delvare
Quoted 9 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/i2c/chips/Kconfig        |   10 +
 drivers/i2c/chips/Makefile       |    1 +
Quoted 4 lines
Quoted 1 line

Please read the header of these 2 files again.

Ok, I missed that. But drivers for I2C based devices will still be submitted via this list?

In last resort only. Ideally all drivers would fit in a subsystem and that subsystem's mailing list is the best place to post. Unless you have I2C-specific problems, of course, in which case you can ask here.

Signature · 1 line
Jean Delvare
#8 lore raw

PATCH 1/1 Added driver for ISL29003 ambient light sensor

In reply to a message not in the archive

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c
Documentation/hwmon/isl29003 new file +62 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/hwmon/Kconfig +10 -0
index b84bf06..ae9b93a 100644
@@ -414,6 +414,16 @@ config SENSORS_IBMPEX
 	  This driver can also be built as a module.  If so, the module
 	  will be called ibmpex.
 
+config SENSORS_ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 config SENSORS_IT87
 	tristate "ITE IT87xx and compatibles"
 	select HWMON_VID
drivers/hwmon/Makefile +1 -0
index 2e80f37..933874f 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
 obj-$(CONFIG_SENSORS_I5K_AMB)	+= i5k_amb.o
 obj-$(CONFIG_SENSORS_IBMAEM)	+= ibmaem.o
 obj-$(CONFIG_SENSORS_IBMPEX)	+= ibmpex.o
+obj-$(CONFIG_SENSORS_ISL29003)	+= isl29003.o
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_K8TEMP)	+= k8temp.o
 obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o
drivers/hwmon/isl29003.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
1.6.1.3

A message that is not in the archive (sent off-list or not yet received): 1235606248-13004-1-git-send-email-daniel-rDUAYElUppE@public.gmane.org

#10 lore raw
Quoted 8 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

Quoted 7 lines
 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

I think we need a new subsystem for light sensors. drivers/light maybe? Or maybe this fits into Jonathan Cameron's industrial I/O subsystem. Jonathan, what do you think? If not, maybe a more general subsystem for various sensor types (light, pressure, noise, whatever.)

Me, I don't really care where these drivers go as long as it's not in drivers/i2c/chips.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 17 lines · Jean Delvare
Quoted 8 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

Quoted 7 lines
 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c
Quoted 2 lines

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

I decided to put it there because of

config SENSORS_APPLESMC
tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"

Quoted 7 lines

I think we need a new subsystem for light sensors. drivers/light maybe? Or maybe this fits into Jonathan Cameron's industrial I/O subsystem. Jonathan, what do you think? If not, maybe a more general subsystem for various sensor types (light, pressure, noise, whatever.)

Me, I don't really care where these drivers go as long as it's not in drivers/i2c/chips.

I don't care eighter - who's deciding it then? Just let me know where you want it and I'll post a new patch.

Thanks,
Daniel

A message that is not in the archive (sent off-list or not yet received): 20090226090651.GA20531-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#14 lore raw
Quoted 18 lines · Daniel Mack
Quoted 17 lines · Jean Delvare
Quoted 15 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c
Quoted 8 lines
Quoted 2 lines

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

I decided to put it there because of

config SENSORS_APPLESMC
tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"

That driver is in hwmon for the motion sensor, and the temperature sensors, not the light sensor. That being said I was never happy to see these accelerometer drivers in hwmon, they don't have much in common with traditional hardware monitoring chips so they should have their own subsystem. Or they could go to drivers/mfd as these chips usually have many functions (as outlined by the above summary line.)

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw
Quoted 6 lines · Jean Delvare
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

Quoted 8 lines
Quoted 5 lines

I decided to put it there because of

config SENSORS_APPLESMC
tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"

That driver is in hwmon for the motion sensor, and the temperature sensors, not the light sensor.

Agreed. I was just looking for an appropriate place for it and the one above is what came closest.

What about adding drivers/sensors and start moving things there? I'd post a patch to move the tsl2550, the thing my driver derived from.

Does that sound suitable?

Daniel

A message that is not in the archive (sent off-list or not yet received): 20090226095718.GA24575-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#18 lore raw

PATCH 1/3 Added empty directories for hardware sensors

This adds empty directories and the neccessary entries to Makefiles and Kconfigs in order to provide a place for hardware sensors which are not meant to be based in drivers/hwmon.

---
How about this approach? Take it as RFC ...

 arch/arm/Kconfig         |    2 ++
 drivers/Kconfig          |    2 ++
 drivers/Makefile         |    1 +
 drivers/sensors/Kconfig  |   20 ++++++++++++++++++++
 drivers/sensors/Makefile |    4 ++++
 5 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 drivers/sensors/Kconfig
 create mode 100644 drivers/sensors/Makefile
arch/arm/Kconfig +2 -0
index dbfdf87..91a6c55 100644
@@ -1283,6 +1283,8 @@ source "drivers/power/Kconfig"
 
 source "drivers/hwmon/Kconfig"
 
+source "drivers/sensors/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/watchdog/Kconfig"
drivers/Kconfig +2 -0
index 00cf955..57a9578 100644
@@ -60,6 +60,8 @@ source "drivers/power/Kconfig"
 
 source "drivers/hwmon/Kconfig"
 
+source "drivers/sensors/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/watchdog/Kconfig"
drivers/Makefile +1 -0
index c1bf417..207a0d5 100644
@@ -74,6 +74,7 @@ obj-y				+= i2c/
 obj-$(CONFIG_W1)		+= w1/
 obj-$(CONFIG_POWER_SUPPLY)	+= power/
 obj-$(CONFIG_HWMON)		+= hwmon/
+obj-$(CONFIG_SENSORS)		+= sensors/
 obj-$(CONFIG_THERMAL)		+= thermal/
 obj-$(CONFIG_WATCHDOG)		+= watchdog/
 obj-$(CONFIG_PHONE)		+= telephony/
drivers/sensors/Kconfig new file +20 -0
new file mode 100644
index 0000000..bc85c90
@@ -0,0 +1,20 @@
+#
+# Sensor drivers
+#
+
+menuconfig SENSORS
+	tristate "Sensor drivers"
+	depends on HAS_IOMEM
+	default n
+	help
+	  Sensor drivers are for special purpose devices that can monitor
+	  ambient light, motion, temperature and the like.
+
+	  Check file:Documentation/sensors to see which devices are
+	  currently supported.
+
+
+if SENSORS
+
+endif # SENSORS
+
drivers/sensors/Makefile new file +4 -0
new file mode 100644
index 0000000..4c629c2
@@ -0,0 +1,4 @@
+#
+# Makefile for sensor chip drivers.
+#
+
Signature · 1 line
1.6.1.3

A message that is not in the archive (sent off-list or not yet received): 1235654648-3450-1-git-send-email-daniel-rDUAYElUppE@public.gmane.org

#20 lore raw

PATCH 2/3 Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
 Documentation/sensors/isl29003 |   62 +++++
 drivers/sensors/Kconfig        |   12 +
 drivers/sensors/Makefile       |    2 +
 drivers/sensors/isl29003.c     |  486 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 562 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/sensors/isl29003
 create mode 100644 drivers/sensors/isl29003.c
Documentation/sensors/isl29003 new file +62 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/sensors/Kconfig +12 -0
index bc85c90..8cf9409 100644
@@ -16,5 +16,17 @@ menuconfig SENSORS
 
 if SENSORS
 
+config SENSORS_ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	default n
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
+
 endif # SENSORS
 
drivers/sensors/Makefile +2 -0
index 4c629c2..1ebe5f2 100644
@@ -2,3 +2,5 @@
 # Makefile for sensor chip drivers.
 #
 
+obj-$(CONFIG_SENSORS_ISL29003)  += isl29003.o
+
drivers/sensors/isl29003.c new file +486 -0

486 lines not on this page · raw message

Signature · 1 line
1.6.1.3

A message that is not in the archive (sent off-list or not yet received): 1235654648-3450-2-git-send-email-daniel-rDUAYElUppE@public.gmane.org

#22 lore raw

PATCH 3/3 move tsl2550.c to drivers/sensors

As drivers/i2c(chips is deprecated, move tsl2550.c to the newly allocated place drivers/sensors.

---
 drivers/i2c/chips/Kconfig   |   10 -
 drivers/i2c/chips/Makefile  |    1 -
 drivers/i2c/chips/tsl2550.c |  489 -------------------------------------------
 drivers/sensors/Kconfig     |    9 +
 drivers/sensors/Makefile    |    3 +-
 drivers/sensors/tsl2550.c   |  489 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 500 insertions(+), 501 deletions(-)
 delete mode 100644 drivers/i2c/chips/tsl2550.c
 create mode 100644 drivers/sensors/tsl2550.c
drivers/i2c/chips/Kconfig +0 -10
index c80312c..5fdaa33 100644
@@ -92,14 +92,4 @@ config SENSORS_MAX6875
 	  This driver can also be built as a module.  If so, the module
 	  will be called max6875.
 
-config SENSORS_TSL2550
-	tristate "Taos TSL2550 ambient light sensor"
-	depends on EXPERIMENTAL
-	help
-	  If you say yes here you get support for the Taos TSL2550
-	  ambient light sensor.
-
-	  This driver can also be built as a module.  If so, the module
-	  will be called tsl2550.
-
 endmenu
drivers/i2c/chips/Makefile +0 -1
index d142f23..c4e55b9 100644
@@ -16,7 +16,6 @@ obj-$(CONFIG_SENSORS_PCA9539)	+= pca9539.o
 obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_PCF8575)		+= pcf8575.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
-obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/tsl2550.c deleted +0 -489

489 lines not on this page · raw message

drivers/sensors/Kconfig +9 -0
index 8cf9409..a5d1c2e 100644
@@ -27,6 +27,15 @@ config SENSORS_ISL29003
 	  This driver can also be built as a module.  If so, the module
 	  will be called isl29003.
 
+config SENSORS_TSL2550
+	tristate "Taos TSL2550 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Taos TSL2550
+	  ambient light sensor.
+          
+	  This driver can also be built as a module.  If so, the module
+	  will be called tsl2550.
 
 endif # SENSORS
 
drivers/sensors/Makefile +2 -1
index 1ebe5f2..874877d 100644
@@ -2,5 +2,6 @@
 # Makefile for sensor chip drivers.
 #
 
-obj-$(CONFIG_SENSORS_ISL29003)  += isl29003.o
+obj-$(CONFIG_SENSORS_ISL29003)	+= isl29003.o
+obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
drivers/sensors/tsl2550.c new file +489 -0

489 lines not on this page · raw message

Signature · 1 line
1.6.1.3
#23 lore raw

Re: [PATCH 1/3] Added empty directories for hardware sensors

In reply to a message not in the archive
Quoted 7 lines · Daniel Mack

This adds empty directories and the neccessary entries to Makefiles and Kconfigs in order to provide a place for hardware sensors which are not meant to be based in drivers/hwmon.

---
How about this approach? Take it as RFC ...

Any oppinion on this, anyone? I'm currently writing a driver for an accelerometer and will have the same uncertainty of where to put it in the end.

Daniel

Quoted 91 lines
 arch/arm/Kconfig         |    2 ++
 drivers/Kconfig          |    2 ++
 drivers/Makefile         |    1 +
 drivers/sensors/Kconfig  |   20 ++++++++++++++++++++
 drivers/sensors/Makefile |    4 ++++
 5 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 drivers/sensors/Kconfig
 create mode 100644 drivers/sensors/Makefile
arch/arm/Kconfig +2 -0
index dbfdf87..91a6c55 100644
@@ -1283,6 +1283,8 @@ source "drivers/power/Kconfig"
 
 source "drivers/hwmon/Kconfig"
 
+source "drivers/sensors/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/watchdog/Kconfig"
drivers/Kconfig +2 -0
index 00cf955..57a9578 100644
@@ -60,6 +60,8 @@ source "drivers/power/Kconfig"
 
 source "drivers/hwmon/Kconfig"
 
+source "drivers/sensors/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/watchdog/Kconfig"
drivers/Makefile +1 -0
index c1bf417..207a0d5 100644
@@ -74,6 +74,7 @@ obj-y				+= i2c/
 obj-$(CONFIG_W1)		+= w1/
 obj-$(CONFIG_POWER_SUPPLY)	+= power/
 obj-$(CONFIG_HWMON)		+= hwmon/
+obj-$(CONFIG_SENSORS)		+= sensors/
 obj-$(CONFIG_THERMAL)		+= thermal/
 obj-$(CONFIG_WATCHDOG)		+= watchdog/
 obj-$(CONFIG_PHONE)		+= telephony/
drivers/sensors/Kconfig new file +20 -0
new file mode 100644
index 0000000..bc85c90
@@ -0,0 +1,20 @@
+#
+# Sensor drivers
+#
+
+menuconfig SENSORS
+	tristate "Sensor drivers"
+	depends on HAS_IOMEM
+	default n
+	help
+	  Sensor drivers are for special purpose devices that can monitor
+	  ambient light, motion, temperature and the like.
+
+	  Check file:Documentation/sensors to see which devices are
+	  currently supported.
+
+
+if SENSORS
+
+endif # SENSORS
+
drivers/sensors/Makefile new file +4 -0
new file mode 100644
index 0000000..4c629c2
@@ -0,0 +1,4 @@
+#
+# Makefile for sensor chip drivers.
+#
+
Signature · 6 lines
1.6.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20090228124048.GB18336-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#25 lore raw

Re: [PATCH 1/3] Added empty directories for hardware sensors

Hi Daniel,

Quoted 5 lines · Daniel Mack
Quoted 4 lines · Daniel Mack

This adds empty directories and the neccessary entries to Makefiles and Kconfigs in order to provide a place for hardware sensors which are not meant to be based in drivers/hwmon.

Quoted 7 lines
Quoted 3 lines

---
 How about this approach? Take it as RFC ...

Any oppinion on this, anyone? I'm currently writing a driver for an accelerometer and will have the same uncertainty of where to put it in the end.

Better to submit this patch to LKML too, as it adds new directory. For accelerometer, few patches were submitted as "Industrial IO" framework from Jonathan Cameron. If you grep in LKML archive you will get the idea, also another place for accelerometer could be drivers/hwmon directory too if it fits in your driver requirements.

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

A message that is not in the archive (sent off-list or not yet received): 5d5443650903012122p795d51cdr18c1a79c606cd496-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#27 lore raw

Re: [PATCH 1/3] Added empty directories for hardware sensors

Hi Trilok,

Quoted 8 lines · Trilok Soni
Quoted 8 lines
Quoted 7 lines

This adds empty directories and the neccessary entries to Makefiles and Kconfigs in order to provide a place for hardware sensors which are not meant to be based in drivers/hwmon.

---
 How about this approach? Take it as RFC ...

Quoted 5 lines
Quoted 3 lines

Any oppinion on this, anyone? I'm currently writing a driver for an accelerometer and will have the same uncertainty of where to put it in the end.

Better to submit this patch to LKML too, as it adds new directory. For

Did that yesterday :)

Quoted 4 lines

accelerometer, few patches were submitted as "Industrial IO" framework from Jonathan Cameron. If you grep in LKML archive you will get the idea, also another place for accelerometer could be drivers/hwmon directory too if it fits in your driver requirements.

I realized that there is a driver for this accellerometer device already, it's just not usable with i2c/spi accessors. I'll discuss that now on the lkml, the question that started the thread is hence only left open for the ambient light sensors (my own one and the tps2550 in drivers/i2c/chips).

Daniel

#28 lore raw
In reply to a message not in the archive
Quoted 17 lines · Jean Delvare
Quoted 8 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

Quoted 7 lines
 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c
Quoted 2 lines

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

Sorry to annoy you again with that topic, but I'm a little stuck here. The 'industrial I/O' thread I was pointed to seems to be orphaned and I didn't get much response on the LKML about alternatives either.

As hwmon still appears the best existing place for such a driver to live in, could we just take it and move it somewhere else as soon somebody comes along with some better idea? I'd just like to avoid it being lost, and every other approach does not feel very productive currently.

Daniel

A message that is not in the archive (sent off-list or not yet received): 20090306160042.GA17800-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#30 lore raw

Hi Daniel,

Quoted 18 lines · Daniel Mack
Quoted 17 lines · Jean Delvare
Quoted 15 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c
Quoted 6 lines
Quoted 2 lines

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

Sorry to annoy you again with that topic, but I'm a little stuck here. The 'industrial I/O' thread I was pointed to seems to be orphaned and I didn't get much response on the LKML about alternatives either.

Sorry for the long silence, I have been pretty busy these last days, and was also hopping for a comment from Jonathan. The industrial I/O subsystem isn't orphaned, I am fairly certain it will be merged some day, but it could take some time.

Quoted 4 lines

As hwmon still appears the best existing place for such a driver to live in, could we just take it and move it somewhere else as soon somebody comes along with some better idea? I'd just like to avoid it being lost, and every other approach does not feel very productive currently.

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw
Quoted 22 lines · Jean Delvare

Hi Daniel,

Quoted 19 lines · Daniel Mack
Quoted 18 lines · Jean Delvare
Quoted 8 lines · Daniel Mack

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

---
Moved the driver to drivers/hwmon

Quoted 7 lines
 Documentation/hwmon/isl29003 |   62 +++++
 drivers/hwmon/Kconfig        |   10 +
 drivers/hwmon/Makefile       |    1 +
 drivers/hwmon/isl29003.c     |  517 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 590 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/isl29003
 create mode 100644 drivers/hwmon/isl29003.c

Still no luck, sorry. Light sensors have nothing to do with hardware monitoring.

Quoted 8 lines
Quoted 3 lines

Sorry to annoy you again with that topic, but I'm a little stuck here. The 'industrial I/O' thread I was pointed to seems to be orphaned and I didn't get much response on the LKML about alternatives either.

Sorry for the long silence, I have been pretty busy these last days, and was also hopping for a comment from Jonathan. The industrial I/O subsystem isn't orphaned, I am fairly certain it will be merged some day, but it could take some time.

Sorry, I missed this thread entirely until just now.

Jean is indeed correct that things have gotten a little delayed. The principal problem has been lack of interested users / testers / driver developers.
Basically not enough people had relevant hardware. Things are improving so hopefully we can make some progress on this soon. In the meantime I've mostly just been fixing bugs my local users have been submitting rather than doing any major new development.

I have a similar light sensor driver which I'll admit I've not widely distributed at yet (it's in one of my git trees, imote2-linux, but under the soon to disappear i2c-chips oops) This one has been out of mainline for a while. It's for the tsl2561.

Quoted 6 lines
Quoted 5 lines

As hwmon still appears the best existing place for such a driver to live in, could we just take it and move it somewhere else as soon somebody comes along with some better idea? I'd just like to avoid it being lost, and every other approach does not feel very productive currently.

Quoted 6 lines

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Jean's suggestion of drivers/misc may make sense in the short term or I'm happy to do the minor bit of porting needed to merge this (and my tsl driver) into the industrial i/o tree (held on kernel.org) to ensure it doesn't disappear into the ether!

---
Jonathan Cameron

A message that is not in the archive (sent off-list or not yet received): 49B166E2.5060909-KWPb1pKIrIJaa/[email protected]

#34 lore raw
Quoted 14 lines · Jonathan Cameron
Quoted 4 lines

Sorry for the long silence, I have been pretty busy these last days, and was also hopping for a comment from Jonathan. The industrial I/O subsystem isn't orphaned, I am fairly certain it will be merged some day, but it could take some time.

Sorry, I missed this thread entirely until just now.

Jean is indeed correct that things have gotten a little delayed. The principal problem has been lack of interested users / testers / driver developers.
Basically not enough people had relevant hardware. Things are improving so hopefully we can make some progress on this soon. In the meantime I've mostly just been fixing bugs my local users have been submitting rather than doing any major new development.

Quoted 4 lines

I have a similar light sensor driver which I'll admit I've not widely distributed at yet (it's in one of my git trees, imote2-linux, but under the soon to disappear i2c-chips oops) This one has been out of mainline for a while. It's for the tsl2561.

And there is more in drivers/i2c/chips/ which should also be moved then (my last patch did so and put it into the proposed drivers/sensors).

Quoted 10 lines
Quoted 6 lines

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Jean's suggestion of drivers/misc may make sense in the short term or I'm happy to do the minor bit of porting needed to merge this (and my tsl driver) into the industrial i/o tree (held on kernel.org) to ensure it doesn't disappear into the ether!

Ok, perfect, do it so. And Cc: me when things get merged :)

Thanks,
Daniel

#35 lore raw
In reply to a message not in the archive
Quoted 8 lines · Jean Delvare
Quoted 3 lines

Sorry to annoy you again with that topic, but I'm a little stuck here. The 'industrial I/O' thread I was pointed to seems to be orphaned and I didn't get much response on the LKML about alternatives either.

Sorry for the long silence, I have been pretty busy these last days, and was also hopping for a comment from Jonathan. The industrial I/O subsystem isn't orphaned, I am fairly certain it will be merged some day, but it could take some time.

Haven't seen any follow-up on it, hence the doubt.

Quoted 11 lines
Quoted 4 lines

As hwmon still appears the best existing place for such a driver to live in, could we just take it and move it somewhere else as soon somebody comes along with some better idea? I'd just like to avoid it being lost, and every other approach does not feel very productive currently.

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Okay, drviers/misc sounds like a good intermediate solution. Do you want me to post another patch for that or will you move it yourself?

Thanks,
Daniel

A message that is not in the archive (sent off-list or not yet received): 20090306181409.GA20135-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#37 lore raw
Quoted 10 lines · Daniel Mack
Quoted 6 lines · Jean Delvare

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Okay, drviers/misc sounds like a good intermediate solution. Do you want me to post another patch for that or will you move it yourself?

Please post new patches, I'll review and apply them.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#39 lore raw

Hi Jean,

Quoted 8 lines · Jean Delvare
Quoted 8 lines · Jean Delvare
Quoted 6 lines

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Quoted 4 lines
Quoted 2 lines

Okay, drviers/misc sounds like a good intermediate solution. Do you want me to post another patch for that or will you move it yourself?

Please post new patches, I'll review and apply them.

Oh, I thought we agreed now to Jonathan Cameron's idea to merge this driver into the IIO framework and put it mainline sooner or later? No extra steps needed from my side - this driver certainly doesn't hurry :)

Thanks,
Daniel

A message that is not in the archive (sent off-list or not yet received): 20090307120631.GA25276-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#41 lore raw
Quoted 11 lines · Daniel Mack

Hi Jean,

Quoted 8 lines · Jean Delvare
Quoted 8 lines · Jean Delvare
Quoted 6 lines

I agree that it doesn't make sense to wait for the industrial I/O subsystem to be merged. But I also do not want to put in drivers/hwmon drivers which do not really belong there. So I'd either go the way you proposed already (drivers/sensors for non-hwmon sensor drivers) or simply put your driver in drivers/misc if this is only meant as a temporary home until the industrial I/O subsystem is merged.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Okay, drviers/misc sounds like a good intermediate solution. Do you want me to post another patch for that or will you move it yourself?

Please post new patches, I'll review and apply them.

Oh, I thought we agreed now to Jonathan Cameron's idea to merge this driver into the IIO framework and put it mainline sooner or later? No extra steps needed from my side - this driver certainly doesn't hurry :)

Both ways are equally fine with me.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#43 lore raw
Quoted 7 lines · Jean Delvare
Quoted 5 lines
Quoted 1 line

Please post new patches, I'll review and apply them.

Oh, I thought we agreed now to Jonathan Cameron's idea to merge this driver into the IIO framework and put it mainline sooner or later? No extra steps needed from my side - this driver certainly doesn't hurry :)

Both ways are equally fine with me.

Ok, nevermind, just to be sure :) As soon as IIO is merged, I'll send a patch to (re)move it again ...

Thanks,
Daniel

Quoted 1 line

From 48f05c0df089909928bf65a3cef29c5cff7ffb28 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Mon, 9 Mar 2009 22:02:23 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

Cc Jean Delvare <[email protected]>
Cc Jonathan Cameron <jic23-KWPb1pKIrIJaa/[email protected]>
---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/misc/Kconfig             |   10 +
 drivers/misc/Makefile            |    1 +
 drivers/misc/isl29003.c          |  486 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 559 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/misc/isl29003.c
Documentation/i2c/chips/isl29003 new file +62 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/misc/Kconfig +10 -0
index c64e679..b883b19 100644
@@ -223,6 +223,16 @@ config DELL_LAPTOP
 	This driver adds support for rfkill and backlight control to Dell
 	laptops.
 
+config ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 
drivers/misc/Makefile +1 -0
index bc11998..7871f05 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_ISL29003)		+= isl29003.o
 obj-$(CONFIG_C2PORT)		+= c2port/
 obj-y				+= eeprom/
drivers/misc/isl29003.c new file +486 -0

486 lines not on this page · raw message

Signature · 1 line
1.6.1.3

A message that is not in the archive (sent off-list or not yet received): 20090309210901.GC31367-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#45 lore raw
Quoted 25 lines · Daniel Mack
Quoted 7 lines · Jean Delvare
Quoted 5 lines
Quoted 1 line

Please post new patches, I'll review and apply them.

Oh, I thought we agreed now to Jonathan Cameron's idea to merge this driver into the IIO framework and put it mainline sooner or later? No extra steps needed from my side - this driver certainly doesn't hurry :)

Both ways are equally fine with me.

Ok, nevermind, just to be sure :) As soon as IIO is merged, I'll send a patch to (re)move it again ...

Thanks,
Daniel

From 48f05c0df089909928bf65a3cef29c5cff7ffb28 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Mon, 9 Mar 2009 22:02:23 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

Quoted 8 lines

It is put to drivers/misc for now until the industrial I/O framework gets merged.

Cc Jean Delvare <[email protected]>
Cc Jonathan Cameron <jic23-KWPb1pKIrIJaa/[email protected]>
---
 Documentation/i2c/chips/isl29003 |   62 +++++

Err, obviously not. If drivers/i2c/chips is going away, you can easily imagine that Documentation/i2c/chips is going away as well...

Quoted 6 lines
 drivers/misc/Kconfig             |   10 +
 drivers/misc/Makefile            |    1 +
 drivers/misc/isl29003.c          |  486 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 559 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/misc/isl29003.c
Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#47 lore raw
Quoted 4 lines · Jean Delvare
Quoted 1 line
 Documentation/i2c/chips/isl29003 |   62 +++++

Err, obviously not. If drivers/i2c/chips is going away, you can easily imagine that Documentation/i2c/chips is going away as well...

Agreed. I didn't want to add Documentation/misc just for that single file, so where would you put it?

(Sorry for causing so much traffic for such a small, dumb driver)

Daniel

A message that is not in the archive (sent off-list or not yet received): 20090310090007.GB3263-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#49 lore raw
Quoted 8 lines · Daniel Mack
Quoted 4 lines · Jean Delvare
Quoted 1 line
 Documentation/i2c/chips/isl29003 |   62 +++++

Err, obviously not. If drivers/i2c/chips is going away, you can easily imagine that Documentation/i2c/chips is going away as well...

Agreed. I didn't want to add Documentation/misc just for that single file, so where would you put it?

Honestly, I'm not sure. But I wouldn't mind actually creating Documentation/misc or similar for it.

Quoted 1 line

(Sorry for causing so much traffic for such a small, dumb driver)

Not your fault, we're in the middle of restructuring this part of the driver tree...

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#51 lore raw
Quoted 4 lines · Jean Delvare
Quoted 3 lines · Daniel Mack
Quoted 2 lines · Jean Delvare
Quoted 1 line
 Documentation/i2c/chips/isl29003 |   62 +++++
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Err, obviously not. If drivers/i2c/chips is going away, you can easily imagine that Documentation/i2c/chips is going away as well...

Agreed. I didn't want to add Documentation/misc just for that single file, so where would you put it?

Honestly, I'm not sure. But I wouldn't mind actually creating Documentation/misc or similar for it.

Ok, will do. Anything else in the code you would like me to change?

Thanks,
Daniel

A message that is not in the archive (sent off-list or not yet received): 20090310102534.GC9564-ahpEBR4enfnCULTFXS99ULNAH6kLmebB@public.gmane.org

#53 lore raw
Quoted 9 lines · Daniel Mack
Quoted 6 lines · Jean Delvare
Quoted 2 lines · Daniel Mack

Agreed. I didn't want to add Documentation/misc just for that single file, so where would you put it?

Honestly, I'm not sure. But I wouldn't mind actually creating Documentation/misc or similar for it.

Ok, will do. Anything else in the code you would like me to change?

I did not have the time to review it and will not have the time in a near future, sorry.

There is a reason why I am trying to move these misc drivers outside of my maintenance area... Which basically means that you are totally free, and actually encouraged, to try to get your driver merged by another maintainer if I am too slow for you.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#55 lore raw

Hi Daniel,

Quoted 9 lines

I did not have the time to review it and will not have the time in a near future, sorry.

There is a reason why I am trying to move these misc drivers outside of my maintenance area... Which basically means that you are totally free, and actually encouraged, to try to get your driver merged by another maintainer if I am too slow for you.

My suggestion would be get this driver in mainline through -mm tree (cc akpm and linux-kernel) or Ben does the review and merge it from his tree. It is better not to wait for IIO to get merged.

Please re-submit your patch to linux-kenel with creating Documentation/misc directory.

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni

A message that is not in the archive (sent off-list or not yet received): 5d5443650903100401j35f13459kcc03adb7dc7e9297-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#57 lore raw
Quoted 11 lines · Trilok Soni

Hi Daniel,

Quoted 8 lines

I did not have the time to review it and will not have the time in a near future, sorry.

There is a reason why I am trying to move these misc drivers outside of my maintenance area... Which basically means that you are totally free, and actually encouraged, to try to get your driver merged by another maintainer if I am too slow for you.

Quoted 3 lines

My suggestion would be get this driver in mainline through -mm tree (cc akpm and linux-kernel) or Ben does the review and merge it from his tree. It is better not to wait for IIO to get merged.

Much as I'd like to argue IIO might go in soon, I suspect we'll still have a bit of an uphill struggle. As I've said I'll do the conversion to IIO, I'll be reading your code thoroughly anyway, so I'm happy to do a review of latest version you've posted.

Jonathan

Quoted 3 lines

Please re-submit your patch to linux-kenel with creating Documentation/misc directory.

#58 lore raw
In reply to a message not in the archive

Hi Daniel,

Some of the comments below are going to be more general than strictly relevant to this driver. More random musings than actual review ;)

I notice that this device is extremely similar to the ISL29004 where only differences being with i2c address selection (that one has some pins to allow more than one option). Worth rolling support for that device in here?

This device has some interesting interrupt / timing options which will fit nicely in the IIO framework. For now the driver sensibly ignores them entirely. (if you don't need them, why bother?)

Most of the comments below are matters of personal preference (so feel free to ignore me!) The two big ones I'd like answers to are:

* Why are you caching registers 4-7. The are read only and dependent on last reading so this is pointless.

* I'm confused by your resume code. I would expect you to want to write back to the device the values last seen in the control registers before the suspend whereas you are reading the values there upon resume back into your cache.

Otherwise the driver is fine with me.

Quoted 53 lines
Quoted 1 line

From 48f05c0df089909928bf65a3cef29c5cff7ffb28 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Mon, 9 Mar 2009 22:02:23 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

Cc Jean Delvare <[email protected]>
Cc Jonathan Cameron <jic23-KWPb1pKIrIJaa/[email protected]>
---
 Documentation/i2c/chips/isl29003 |   62 +++++
 drivers/misc/Kconfig             |   10 +
 drivers/misc/Makefile            |    1 +
 drivers/misc/isl29003.c          |  486 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 559 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/i2c/chips/isl29003
 create mode 100644 drivers/misc/isl29003.c
Documentation/i2c/chips/isl29003 new file +23 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux

Documentation/i2c/chips/isl29003 line 33

Quoted 10 lines
Documentation/i2c/chips/isl29003 new file +10 -0
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.

This is a little nasty given the chances of something else sitting on that address, but not much else you can do.

Documentation/i2c/chips/isl29003 line 43

Quoted 10 lines
Documentation/i2c/chips/isl29003 new file +10 -0
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux

This is going to be awkward to control in a generalized fashion, but the option here is fine for now.

Quoted 82 lines
Documentation/i2c/chips/isl29003 new file +18 -0
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/misc/Kconfig +10 -0
index c64e679..b883b19 100644
@@ -223,6 +223,16 @@ config DELL_LAPTOP
 	This driver adds support for rfkill and backlight control to Dell
 	laptops.
 
+config ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 
drivers/misc/Makefile +1 -0
index bc11998..7871f05 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_ISL29003)		+= isl29003.o
 obj-$(CONFIG_C2PORT)		+= c2port/
 obj-y				+= eeprom/
drivers/misc/isl29003.c new file +26 -0
new file mode 100644
index 0000000..a17e89b
@@ -0,0 +1,486 @@
+/*
+ *  isl29003.c - Linux kernel module for
+ * 	Intersil ISL29003 ambient light sensor
+ *
+ *  See file:Documentation/i2c/chips/isl29003
+ *
+ *  Copyright (c) 2009 Daniel Mack <[email protected]>
+ *
+ *  Based on code written by
+ *  	Rodolfo Giometti <[email protected]>
+ *  	Eurotech S.p.A. <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */

drivers/misc/isl29003.c line 36

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+
+#define ISL29003_DRV_NAME	"isl29003"
+#define DRIVER_VERSION		"1.0"

Some of the following are acting only as documentation. It's a matter of personal preference whether you specify them.

Quoted 48 lines
drivers/misc/isl29003.c new file +48 -0
+#define ISL29003_REG_COMMAND		0x00
+#define ISL29003_ADC_ENABLED		(1 << 7)
+#define ISL29003_ADC_PD			(1 << 6)
+#define ISL29003_TIMING_INT		(1 << 5)
+#define ISL29003_MODE_SHIFT		(2)
+#define ISL29003_MODE_MASK		(0x3 << ISL29003_MODE_SHIFT)
+#define ISL29003_RES_SHIFT		(0)
+#define ISL29003_RES_MASK		(0x3 << ISL29003_RES_SHIFT)
+
+#define ISL29003_REG_CONTROL		0x01
+#define ISL29003_INT_FLG		(1 << 5)
+#define ISL29003_RANGE_SHIFT		(2)
+#define ISL29003_RANGE_MASK		(0x3 << ISL29003_RANGE_SHIFT)
+#define ISL29003_INT_PERSISTS_SHIFT	(0)
+#define ISL29003_INT_PERSISTS_MASK	(0xf << ISL29003_INT_PERSISTS_SHIFT)
+
+#define ISL29003_REG_IRQ_THRESH_HI	0x02
+#define ISL29003_REG_IRQ_THRESH_LO	0x03
+#define ISL29003_REG_LSB_SENSOR		0x04
+#define ISL29003_REG_MSB_SENSOR		0x05
+#define ISL29003_REG_LSB_TIMER		0x06
+#define ISL29003_REG_MSB_TIMER		0x07
+
+struct isl29003_data {
+	struct i2c_client *client;
+	struct mutex lock;
+	u8 reg_cache[8];
+};
+
+static int gain_range[] = {
+	1000, 4000, 16000, 64000
+};
+
+/*
+ * register access helpers
+ */
+
+static int __isl29003_read_reg(struct i2c_client *client,
+			       u32 reg, u8 mask, u8 shift)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	return (data->reg_cache[reg] & mask) >> shift;
+}
+
+static int __isl29003_write_reg(struct i2c_client *client,
+				u32 reg, u8 mask, u8 shift, u8 val)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);

drivers/misc/isl29003.c line 95

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+	int ret = 0;
+	u8 tmp;
+
+	mutex_lock(&data->lock);
+
+	tmp = data->reg_cache[reg];
+	tmp &= ~mask;
+	tmp |= val << shift;
+
+	ret = i2c_smbus_write_byte_data(client, reg, tmp);

As i2c_smbus_write_byte_data is defined as returning zero on success this could simply be, if (!ret).

Quoted 47 lines
drivers/misc/isl29003.c new file +47 -0
+	if (ret >= 0)
+		data->reg_cache[reg] = tmp;
+
+	mutex_unlock(&data->lock);
+	return ret;
+}
+
+/*
+ * internally used functions
+ */
+
+/* range */
+static int isl29003_get_range(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_CONTROL,
+		ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT);
+}
+
+static int isl29003_set_range(struct i2c_client *client, int range)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_CONTROL,
+		ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT, range);
+}
+
+/* resolution */
+static int isl29003_get_resolution(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT);
+}
+
+static int isl29003_set_resolution(struct i2c_client *client, int res)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT, res);
+}
+
+/* mode */
+static int isl29003_get_mode(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT);
+}
+
+static int isl29003_set_mode(struct i2c_client *client, int mode)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_COMMAND,

drivers/misc/isl29003.c line 152

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT, mode);
+}
+
+/* power_state */
+static int isl29003_set_power_state(struct i2c_client *client, int state)
+{
+	int ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_ENABLED, 0, state);

As this is either 0 or less than zero, again if (ret) will suffice.

drivers/misc/isl29003.c line 157

Quoted 5 lines
drivers/misc/isl29003.c new file +5 -0
+	if (ret < 0)
+		return ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_PD, 0, ~state);

Just return ret hence losing these 2 lines.

drivers/misc/isl29003.c line 169

Quoted 12 lines
drivers/misc/isl29003.c new file +12 -0
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int isl29003_get_power_state(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	u8 cmdreg = data->reg_cache[ISL29003_REG_COMMAND];
+	return (cmdreg & ISL29003_ADC_ENABLED) && (~cmdreg & ISL29003_ADC_PD);
+}

Unfortunately this chip has gain controlled by combination of the i2c accessed registers and an external resitor. I guess this falls into the category of things to be fixed in userspace. Perhaps some documentation to indicate this issue would help? (table 9 of data sheet)

Quoted 36 lines
drivers/misc/isl29003.c new file +36 -0
+static int isl29003_get_adc_value(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int lsb, msb, range, bitdepth;
+
+	mutex_lock(&data->lock);
+	lsb = i2c_smbus_read_byte_data(client, ISL29003_REG_LSB_SENSOR);
+
+	if (lsb < 0) {
+		mutex_unlock(&data->lock);
+		return lsb;
+	}
+
+	msb = i2c_smbus_read_byte_data(client, ISL29003_REG_MSB_SENSOR);
+	mutex_unlock(&data->lock);
+
+	if (msb < 0)
+		return msb;
+
+	range = isl29003_get_range(client);
+	bitdepth = (4 - isl29003_get_resolution(client)) * 4;
+	return (((msb << 8) | lsb) * gain_range[range]) >> bitdepth;
+}
+
+/*
+ * sysfs layer
+ */
+
+/* range */
+static ssize_t isl29003_show_range(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%i\n", isl29003_get_range(client));
+}
+

drivers/misc/isl29003.c line 216

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+static ssize_t isl29003_store_range(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;

See as there are rather a lot of calls like this, why don't you consider moving this test into the register write command. If the device is powered up then it will get copied to the device. If not, just store it in the cache and it will be written on resume anyway (assuming my understanding of your suspend resume code is right!)

Quoted 91 lines
drivers/misc/isl29003.c new file +91 -0
+	if (!isl29003_get_power_state(client))
+		return -EBUSY;
+
+	ret = isl29003_set_range(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(range, S_IWUSR | S_IRUGO,
+		   isl29003_show_range, isl29003_store_range);
+
+
+/* resolution */
+static ssize_t isl29003_show_resolution(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_resolution(client));
+}
+
+static ssize_t isl29003_store_resolution(struct device *dev,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;
+
+	if (!isl29003_get_power_state(client))
+		return -EBUSY;
+
+	ret = isl29003_set_resolution(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(resolution, S_IWUSR | S_IRUGO,
+		   isl29003_show_resolution, isl29003_store_resolution);
+
+/* mode */
+static ssize_t isl29003_show_mode(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_mode(client));
+}
+
+static ssize_t isl29003_store_mode(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
+		return -EINVAL;
+
+	if (!isl29003_get_power_state(client))
+		return -EBUSY;
+
+	ret = isl29003_set_mode(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO,
+		   isl29003_show_mode, isl29003_store_mode);
+
+
+/* power state */
+static ssize_t isl29003_show_power_state(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_power_state(client));
+}
+
+static ssize_t isl29003_store_power_state(struct device *dev,
+					  struct device_attribute *attr,
+					  const char *buf, size_t count)

drivers/misc/isl29003.c line 319

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+		return -EINVAL;
+
+	ret = isl29003_set_power_state(client, val);
+	if (ret < 0)
+		return ret;

I'd go with more concise "return ret ? ret : count;" but thats down to personal preference.

Quoted 32 lines
drivers/misc/isl29003.c new file +32 -0
+	return count;
+}
+
+static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO,
+		   isl29003_show_power_state, isl29003_store_power_state);
+
+
+/* lux */
+static ssize_t isl29003_show_lux(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	/* No LUX data if not operational */
+	if (!isl29003_get_power_state(client))
+		return -EBUSY;
+
+	return sprintf(buf, "%d\n", isl29003_get_adc_value(client));
+}
+
+static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL);
+
+static struct attribute *isl29003_attributes[] = {
+	&dev_attr_range.attr,
+	&dev_attr_resolution.attr,
+	&dev_attr_mode.attr,
+	&dev_attr_power_state.attr,
+	&dev_attr_lux.attr,
+	NULL
+};
+
+static const struct attribute_group isl29003_attr_group = {

drivers/misc/isl29003.c line 362

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+	.attrs = isl29003_attributes,
+};
+
+static int isl29003_init_client(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int i;
+
+	/* read all the registers once to fill the cache.
+	 * if one of the reads fails, we consider the init failed */

Why are you caching registers 4-7? They are read only data registers and those you use are read on demand anyway. It's not a problem here, but worth noting that even the first 2 are not simply read / write control registers and hence any caching method has to be very careful
(there is a interrupt flag in control according to the data sheet.)

Quoted 66 lines
drivers/misc/isl29003.c new file +66 -0
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++) {
+		int v = i2c_smbus_read_byte_data(client, i);
+		if (v < 0)
+			return -ENODEV;
+
+		data->reg_cache[i] = v;
+	}
+
+	/* set defaults */
+	isl29003_set_range(client, 0);
+	isl29003_set_resolution(client, 0);
+	isl29003_set_mode(client, 0);
+	isl29003_set_power_state(client, 0);
+
+	return 0;
+}
+
+/*
+ * I2C layer
+ */
+
+static int __devinit isl29003_probe(struct i2c_client *client,
+				    const struct i2c_device_id *id)
+{
+	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
+	struct isl29003_data *data;
+	int err = 0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
+		return -EIO;
+
+	data = kzalloc(sizeof(struct isl29003_data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->client = client;
+	i2c_set_clientdata(client, data);
+	mutex_init(&data->lock);
+
+	/* initialize the ISL29003 chip */
+	err = isl29003_init_client(client);
+	if (err)
+		goto exit_kfree;
+
+	/* register sysfs hooks */
+	err = sysfs_create_group(&client->dev.kobj, &isl29003_attr_group);
+	if (err)
+		goto exit_kfree;
+
+	dev_info(&client->dev, "driver version %s enabled\n", DRIVER_VERSION);
+	return 0;
+
+exit_kfree:
+	kfree(data);
+	return err;
+}
+
+static int __devexit isl29003_remove(struct i2c_client *client)
+{
+	sysfs_remove_group(&client->dev.kobj, &isl29003_attr_group);
+	isl29003_set_power_state(client, 0);
+	kfree(i2c_get_clientdata(client));
+	return 0;
+}
+
+#ifdef CONFIG_PM

drivers/misc/isl29003.c line 438

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	return isl29003_set_power_state(client, 0);
+}
+
+static int isl29003_resume(struct i2c_client *client)
+{
+	int i;
+
+	/* restore registers from cache */

If we are restoring registers from cache, why are we reading them?

Quoted 48 lines
drivers/misc/isl29003.c new file +48 -0
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
+		if (i2c_smbus_read_byte_data(client, i, data->reg_cache[i]) < 0)
+			return -ENODEV;
+
+	return 0;
+}
+
+#else
+#define isl29003_suspend	NULL
+#define isl29003_resume		NULL
+#endif /* CONFIG_PM */
+
+static const struct i2c_device_id isl29003_id[] = {
+	{ "isl29003", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, isl29003_id);
+
+static struct i2c_driver isl29003_driver = {
+	.driver = {
+		.name	= ISL29003_DRV_NAME,
+		.owner	= THIS_MODULE,
+	},
+	.suspend = isl29003_suspend,
+	.resume	= isl29003_resume,
+	.probe	= isl29003_probe,
+	.remove	= __devexit_p(isl29003_remove),
+	.id_table = isl29003_id,
+};
+
+static int __init isl29003_init(void)
+{
+	return i2c_add_driver(&isl29003_driver);
+}
+
+static void __exit isl29003_exit(void)
+{
+	i2c_del_driver(&isl29003_driver);
+}
+
+MODULE_AUTHOR("Daniel Mack <[email protected]>");
+MODULE_DESCRIPTION("ISL29003 ambient light sensor driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(DRIVER_VERSION);
+
+module_init(isl29003_init);
+module_exit(isl29003_exit);
+
#59 lore raw

Hi Jonathan,

many thanks for your review!

Quoted 4 lines · Jonathan Cameron

I notice that this device is extremely similar to the ISL29004 where only differences being with i2c address selection (that one has some pins to allow more than one option). Worth rolling support for that device in here?

Well, the I2C address isn't coded in the driver but defined in the i2c_board_info array of the board support file, so there is no reason why it shouldn't work. Or are you talking about the names of files and functions that you would like to see reflecting this?

Quoted 3 lines

This device has some interesting interrupt / timing options which will fit nicely in the IIO framework. For now the driver sensibly ignores them entirely. (if you don't need them, why bother?)

Right, I don't need them personally, and things are not connected to the CPU, so I can't test that. I would expect anyone who needs this functions to add support to the code :)

Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.

This is a little nasty given the chances of something else sitting on that address, but not much else you can do.

True.

Quoted 2 lines

Some of the following are acting only as documentation. It's a matter of personal preference whether you specify them.

I defined them to make future feature additions easy ...

Quoted 8 lines
Quoted 8 lines
(quoted diff) +8 -0
+#define ISL29003_REG_COMMAND		0x00
+#define ISL29003_ADC_ENABLED		(1 << 7)
+#define ISL29003_ADC_PD			(1 << 6)
+#define ISL29003_TIMING_INT		(1 << 5)
+#define ISL29003_MODE_SHIFT		(2)
+#define ISL29003_MODE_MASK		(0x3 << ISL29003_MODE_SHIFT)
+#define ISL29003_RES_SHIFT		(0)
+#define ISL29003_RES_MASK		(0x3 << ISL29003_RES_SHIFT)

[...]

Quoted 8 lines
Quoted 8 lines
(quoted diff) +8 -0
+static int __isl29003_write_reg(struct i2c_client *client,
+				u32 reg, u8 mask, u8 shift, u8 val)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int ret = 0;
+	u8 tmp;
+
+	mutex_lock(&data->lock);
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+
+	tmp = data->reg_cache[reg];
+	tmp &= ~mask;
+	tmp |= val << shift;
+
+	ret = i2c_smbus_write_byte_data(client, reg, tmp);

As i2c_smbus_write_byte_data is defined as returning zero on success this could simply be, if (!ret).

Fixed.

Quoted 10 lines

Review

Quoted 9 lines
(quoted diff) +9 -0
+}
+
+/* power_state */
+static int isl29003_set_power_state(struct i2c_client *client, int state)
+{
+	int ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_ENABLED, 0, state);

As this is either 0 or less than zero, again if (ret) will suffice.

Fixed.

Quoted 6 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+	if (ret < 0)
+		return ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_PD, 0, ~state);

Just return ret hence losing these 2 lines.

Fixed.

Quoted 9 lines
Quoted 9 lines
(quoted diff) +9 -0
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int isl29003_get_power_state(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+	u8 cmdreg = data->reg_cache[ISL29003_REG_COMMAND];
+	return (cmdreg & ISL29003_ADC_ENABLED) && (~cmdreg & ISL29003_ADC_PD);
+}

Unfortunately this chip has gain controlled by combination of the i2c accessed registers and an external resitor. I guess this falls into the category of things to be fixed in userspace. Perhaps some documentation to indicate this issue would help? (table 9 of data sheet)

The resistor does not affect the value read from the register - it's about integration time only. Or did I get it wrong?

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;

See as there are rather a lot of calls like this, why don't you consider moving this test into the register write command. If the device is powered up then it will get copied to the device. If not, just store it in the cache and it will be written on resume anyway (assuming my understanding of your suspend resume code is right!)

It's not even necessary to do that - the driver can access all registers while the PD bit is set. So the only check is to not read sensor data when this condition is matched.

Quoted 7 lines
Quoted 7 lines
(quoted diff) +7 -0
+static ssize_t isl29003_store_power_state(struct device *dev,
+					  struct device_attribute *attr,
+					  const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+		return -EINVAL;
+
+	ret = isl29003_set_power_state(client, val);
+	if (ret < 0)
+		return ret;

I'd go with more concise "return ret ? ret : count;" but thats down to personal preference.

Fixed.

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	/* read all the registers once to fill the cache.
+	 * if one of the reads fails, we consider the init failed */

Why are you caching registers 4-7? They are read only data registers and those you use are read on demand anyway. It's not a problem here, but worth noting that even the first 2 are not simply read / write control registers and hence any caching method has to be very careful
(there is a interrupt flag in control according to the data sheet.)

You're right. I changed the cache to only store the first 4 registers for now. Interrupt handling will need some extra work anyway, so I'll leave that for now.

Quoted 5 lines

If we are restoring registers from cache, why are we reading them?

Review

Quoted 3 lines
(quoted diff) +3 -0
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
+		if (i2c_smbus_read_byte_data(client, i, data->reg_cache[i]) < 0)
+			return -ENODEV;

Typo - couldn't test the suspend/resume code yet. Fixed now.

Please see the patch below.

Thanks again,
Daniel

Quoted 1 line

From 8ee5021834900f312ff26cd2586c18e99af31a5d Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 10 Mar 2009 16:13:07 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

---
New version with Jonathan Cameron's review notes addressed.

 Documentation/misc-devices/isl29003 |   62 +++++
 drivers/misc/Kconfig                |   10 +
 drivers/misc/Makefile               |    1 +
 drivers/misc/isl29003.c             |  470 +++++++++++++++++++++++++++++++++++
 4 files changed, 543 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/misc-devices/isl29003
 create mode 100644 drivers/misc/isl29003.c
Documentation/misc-devices/isl29003 new file +62 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/misc/Kconfig +10 -0
index c64e679..b883b19 100644
@@ -223,6 +223,16 @@ config DELL_LAPTOP
 	This driver adds support for rfkill and backlight control to Dell
 	laptops.
 
+config ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 
drivers/misc/Makefile +1 -0
index bc11998..7871f05 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_ISL29003)		+= isl29003.o
 obj-$(CONFIG_C2PORT)		+= c2port/
 obj-y				+= eeprom/
drivers/misc/isl29003.c new file +470 -0

470 lines not on this page · raw message

Signature · 1 line
1.6.2
#60 lore raw
Quoted 3 lines · Daniel Mack

Hi Jonathan,

many thanks for your review!

You are welcome.

Quoted 11 lines · Jonathan Cameron
Quoted 4 lines

I notice that this device is extremely similar to the ISL29004 where only differences being with i2c address selection (that one has some pins to allow more than one option). Worth rolling support for that device in here?

Well, the I2C address isn't coded in the driver but defined in the i2c_board_info array of the board support file, so there is no reason why it shouldn't work. Or are you talking about the names of files and functions that you would like to see reflecting this?

function names and filenames are fine (typically you just pick a random device that the driver supports and name everything after that).
I think the only addition would be documentation of the patch and and id in the id table.

Quoted 93 lines
Quoted 4 lines

This device has some interesting interrupt / timing options which will fit nicely in the IIO framework. For now the driver sensibly ignores them entirely. (if you don't need them, why bother?)

Right, I don't need them personally, and things are not connected to the CPU, so I can't test that. I would expect anyone who needs this functions to add support to the code :)

Quoted 6 lines

Documentation/misc-devices/isl29003 line 33

Quoted 4 lines
Documentation/misc-devices/isl29003 new file +4 -0
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.

This is a little nasty given the chances of something else sitting on that address, but not much else you can do.

True.

Quoted 2 lines

Some of the following are acting only as documentation. It's a matter of personal preference whether you specify them.

I defined them to make future feature additions easy ...

Quoted 8 lines
Quoted 8 lines
drivers/misc/isl29003.c new file +8 -0
+#define ISL29003_REG_COMMAND		0x00
+#define ISL29003_ADC_ENABLED		(1 << 7)
+#define ISL29003_ADC_PD			(1 << 6)
+#define ISL29003_TIMING_INT		(1 << 5)
+#define ISL29003_MODE_SHIFT		(2)
+#define ISL29003_MODE_MASK		(0x3 << ISL29003_MODE_SHIFT)
+#define ISL29003_RES_SHIFT		(0)
+#define ISL29003_RES_MASK		(0x3 << ISL29003_RES_SHIFT)

[...]

Quoted 8 lines
Quoted 8 lines
drivers/misc/isl29003.c new file +8 -0
+static int __isl29003_write_reg(struct i2c_client *client,
+				u32 reg, u8 mask, u8 shift, u8 val)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int ret = 0;
+	u8 tmp;
+
+	mutex_lock(&data->lock);
Quoted 8 lines

drivers/misc/isl29003.c line 100

Quoted 6 lines
drivers/misc/isl29003.c new file +6 -0
+
+	tmp = data->reg_cache[reg];
+	tmp &= ~mask;
+	tmp |= val << shift;
+
+	ret = i2c_smbus_write_byte_data(client, reg, tmp);

As i2c_smbus_write_byte_data is defined as returning zero on success this could simply be, if (!ret).

Fixed.

Quoted 10 lines

drivers/misc/isl29003.c

Quoted 9 lines
drivers/misc/isl29003.c new file +9 -0
+}
+
+/* power_state */
+static int isl29003_set_power_state(struct i2c_client *client, int state)
+{
+	int ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_ENABLED, 0, state);

As this is either 0 or less than zero, again if (ret) will suffice.

Fixed.

Quoted 6 lines

drivers/misc/isl29003.c

Quoted 5 lines
drivers/misc/isl29003.c new file +5 -0
+	if (ret < 0)
+		return ret;
+
+	ret = __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_ADC_PD, 0, ~state);

Just return ret hence losing these 2 lines.

Fixed.

Quoted 9 lines
Quoted 9 lines
drivers/misc/isl29003.c new file +9 -0
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int isl29003_get_power_state(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
Quoted 8 lines

drivers/misc/isl29003.c line 164

Quoted 3 lines
drivers/misc/isl29003.c new file +3 -0
+	u8 cmdreg = data->reg_cache[ISL29003_REG_COMMAND];
+	return (cmdreg & ISL29003_ADC_ENABLED) && (~cmdreg & ISL29003_ADC_PD);
+}

Unfortunately this chip has gain controlled by combination of the i2c accessed registers and an external resitor. I guess this falls into the category of things to be fixed in userspace. Perhaps some documentation to indicate this issue would help? (table 9 of data sheet)

Quoted 2 lines

The resistor does not affect the value read from the register - it's about integration time only. Or did I get it wrong?

My reading of table 9 on the data sheet is that the full scale range is affected by the resistor. This is also described in the bit about calculating lux.

Quoted 648 lines
Quoted 9 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;

See as there are rather a lot of calls like this, why don't you consider moving this test into the register write command. If the device is powered up then it will get copied to the device. If not, just store it in the cache and it will be written on resume anyway (assuming my understanding of your suspend resume code is right!)

It's not even necessary to do that - the driver can access all registers while the PD bit is set. So the only check is to not read sensor data when this condition is matched.

Quoted 7 lines
Quoted 7 lines
drivers/misc/isl29003.c new file +7 -0
+static ssize_t isl29003_store_power_state(struct device *dev,
+					  struct device_attribute *attr,
+					  const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
Quoted 8 lines

drivers/misc/isl29003.c

Quoted 6 lines
drivers/misc/isl29003.c new file +6 -0
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+		return -EINVAL;
+
+	ret = isl29003_set_power_state(client, val);
+	if (ret < 0)
+		return ret;

I'd go with more concise "return ret ? ret : count;" but thats down to personal preference.

Fixed.

Quoted 7 lines

drivers/misc/isl29003.c line 345

Quoted 2 lines
drivers/misc/isl29003.c new file +2 -0
+	/* read all the registers once to fill the cache.
+	 * if one of the reads fails, we consider the init failed */

Why are you caching registers 4-7? They are read only data registers and those you use are read on demand anyway. It's not a problem here, but worth noting that even the first 2 are not simply read / write control registers and hence any caching method has to be very careful
(there is a interrupt flag in control according to the data sheet.)

You're right. I changed the cache to only store the first 4 registers for now. Interrupt handling will need some extra work anyway, so I'll leave that for now.

Quoted 5 lines

If we are restoring registers from cache, why are we reading them?

Review

Quoted 3 lines
(quoted diff) +3 -0
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
+		if (i2c_smbus_read_byte_data(client, i, data->reg_cache[i]) < 0)
+			return -ENODEV;

Typo - couldn't test the suspend/resume code yet. Fixed now.

Please see the patch below.

Thanks again,
Daniel

Quoted 1 line

From 8ee5021834900f312ff26cd2586c18e99af31a5d Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 10 Mar 2009 16:13:07 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

---
New version with Jonathan Cameron's review notes addressed.

 Documentation/misc-devices/isl29003 |   62 +++++
 drivers/misc/Kconfig                |   10 +
 drivers/misc/Makefile               |    1 +
 drivers/misc/isl29003.c             |  470 +++++++++++++++++++++++++++++++++++
 4 files changed, 543 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/misc-devices/isl29003
 create mode 100644 drivers/misc/isl29003.c
Documentation/misc-devices/isl29003 new file +62 -0
new file mode 100644
index 0000000..c4ff5f3
@@ -0,0 +1,62 @@
+Kernel driver isl29003
+=====================
+
+Supported chips:
+* Intersil ISL29003
+Prefix: 'isl29003'
+Addresses scanned: none
+Datasheet:
+http://www.intersil.com/data/fn/fn7464.pdf
+
+Author: Daniel Mack <[email protected]>
+
+
+Description
+-----------
+The ISL29003 is an integrated light sensor with a 16-bit integrating type
+ADC, I2C user programmable lux range select for optimized counts/lux, and
+I2C multi-function control and monitoring capabilities. The internal ADC
+provides 16-bit resolution while rejecting 50Hz and 60Hz flicker caused by
+artificial light sources.
+
+The driver allows to set the lux range, the bit resolution, the operational
+mode (see below) and the power state of device and can read the current lux
+value, of course.
+
+
+Detection
+---------
+
+The ISL29003 does not have an ID register which could be used to identify
+it, so the detection routine will just try to read from the configured I2C
+addess and consider the device to be present as soon as it ACKs the
+transfer.
+
+
+Sysfs entries
+-------------
+
+range:
+	0: 0 lux to 1000 lux (default)
+	1: 0 lux to 4000 lux
+	2: 0 lux to 16,000 lux
+	3: 0 lux to 64,000 lux
+
+resolution:
+	0: 2^16 cycles (default)
+	1: 2^12 cycles
+	2: 2^8 cycles
+	3: 2^4 cycles
+
+mode:
+	0: diode1's current (unsigned 16bit) (default)
+	1: diode1's current (unsigned 16bit)
+	2: difference between diodes (l1 - l2, signed 15bit)
+
+power_state:
+	0: device is disabled (default)
+	1: device is enabled
+
+lux (read only):
+	returns the value from the last sensor reading
+
drivers/misc/Kconfig +10 -0
index c64e679..b883b19 100644
@@ -223,6 +223,16 @@ config DELL_LAPTOP
 	This driver adds support for rfkill and backlight control to Dell
 	laptops.
 
+config ISL29003
+	tristate "Intersil ISL29003 ambient light sensor"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Intersil ISL29003
+	  ambient light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called isl29003.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 
drivers/misc/Makefile +1 -0
index bc11998..7871f05 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_ISL29003)		+= isl29003.o
 obj-$(CONFIG_C2PORT)		+= c2port/
 obj-y				+= eeprom/
drivers/misc/isl29003.c new file +460 -0
new file mode 100644
index 0000000..2e2a592
@@ -0,0 +1,470 @@
+/*
+ *  isl29003.c - Linux kernel module for
+ * 	Intersil ISL29003 ambient light sensor
+ *
+ *  See file:Documentation/misc-devices/isl29003
+ *
+ *  Copyright (c) 2009 Daniel Mack <[email protected]>
+ *
+ *  Based on code written by
+ *  	Rodolfo Giometti <[email protected]>
+ *  	Eurotech S.p.A. <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+
+#define ISL29003_DRV_NAME	"isl29003"
+#define DRIVER_VERSION		"1.0"
+
+#define ISL29003_REG_COMMAND		0x00
+#define ISL29003_ADC_ENABLED		(1 << 7)
+#define ISL29003_ADC_PD			(1 << 6)
+#define ISL29003_TIMING_INT		(1 << 5)
+#define ISL29003_MODE_SHIFT		(2)
+#define ISL29003_MODE_MASK		(0x3 << ISL29003_MODE_SHIFT)
+#define ISL29003_RES_SHIFT		(0)
+#define ISL29003_RES_MASK		(0x3 << ISL29003_RES_SHIFT)
+
+#define ISL29003_REG_CONTROL		0x01
+#define ISL29003_INT_FLG		(1 << 5)
+#define ISL29003_RANGE_SHIFT		(2)
+#define ISL29003_RANGE_MASK		(0x3 << ISL29003_RANGE_SHIFT)
+#define ISL29003_INT_PERSISTS_SHIFT	(0)
+#define ISL29003_INT_PERSISTS_MASK	(0xf << ISL29003_INT_PERSISTS_SHIFT)
+
+#define ISL29003_REG_IRQ_THRESH_HI	0x02
+#define ISL29003_REG_IRQ_THRESH_LO	0x03
+#define ISL29003_REG_LSB_SENSOR		0x04
+#define ISL29003_REG_MSB_SENSOR		0x05
+#define ISL29003_REG_LSB_TIMER		0x06
+#define ISL29003_REG_MSB_TIMER		0x07
+
+#define ISL29003_NUM_CACHABLE_REGS	4
+
+struct isl29003_data {
+	struct i2c_client *client;
+	struct mutex lock;
+	u8 reg_cache[ISL29003_NUM_CACHABLE_REGS];
+};
+
+static int gain_range[] = {
+	1000, 4000, 16000, 64000
+};
+
+/*
+ * register access helpers
+ */
+
+static int __isl29003_read_reg(struct i2c_client *client,
+			       u32 reg, u8 mask, u8 shift)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	return (data->reg_cache[reg] & mask) >> shift;
+}
+
+static int __isl29003_write_reg(struct i2c_client *client,
+				u32 reg, u8 mask, u8 shift, u8 val)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int ret = 0;
+	u8 tmp;
+
+	if (reg >= ISL29003_NUM_CACHABLE_REGS)
+		return -EINVAL;
+
+	mutex_lock(&data->lock);
+
+	tmp = data->reg_cache[reg];
+	tmp &= ~mask;
+	tmp |= val << shift;
+
+	ret = i2c_smbus_write_byte_data(client, reg, tmp);
+	if (!ret)
+		data->reg_cache[reg] = tmp;
+
+	mutex_unlock(&data->lock);
+	return ret;
+}
+
+/*
+ * internally used functions
+ */
+
+/* range */
+static int isl29003_get_range(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_CONTROL,
+		ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT);
+}
+
+static int isl29003_set_range(struct i2c_client *client, int range)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_CONTROL,
+		ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT, range);
+}
+
+/* resolution */
+static int isl29003_get_resolution(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT);
+}
+
+static int isl29003_set_resolution(struct i2c_client *client, int res)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT, res);
+}
+
+/* mode */
+static int isl29003_get_mode(struct i2c_client *client)
+{
+	return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT);
+}
+
+static int isl29003_set_mode(struct i2c_client *client, int mode)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+		ISL29003_RES_MASK, ISL29003_RES_SHIFT, mode);
+}
+
+/* power_state */
+static int isl29003_set_power_state(struct i2c_client *client, int state)
+{
+	return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
+				ISL29003_ADC_ENABLED | ISL29003_ADC_PD, 0,
+				state ? ISL29003_ADC_ENABLED : ISL29003_ADC_PD);
+}
+
+static int isl29003_get_power_state(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	u8 cmdreg = data->reg_cache[ISL29003_REG_COMMAND];
+	return ~cmdreg & ISL29003_ADC_PD;
+}
+
+static int isl29003_get_adc_value(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int lsb, msb, range, bitdepth;
+
+	mutex_lock(&data->lock);
+	lsb = i2c_smbus_read_byte_data(client, ISL29003_REG_LSB_SENSOR);
+
+	if (lsb < 0) {
+		mutex_unlock(&data->lock);
+		return lsb;
+	}
+
+	msb = i2c_smbus_read_byte_data(client, ISL29003_REG_MSB_SENSOR);
+	mutex_unlock(&data->lock);
+
+	if (msb < 0)
+		return msb;
+
+	range = isl29003_get_range(client);
+	bitdepth = (4 - isl29003_get_resolution(client)) * 4;
+	return (((msb << 8) | lsb) * gain_range[range]) >> bitdepth;
+}
+
+/*
+ * sysfs layer
+ */
+
+/* range */
+static ssize_t isl29003_show_range(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%i\n", isl29003_get_range(client));
+}
+
+static ssize_t isl29003_store_range(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;
+
+	ret = isl29003_set_range(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(range, S_IWUSR | S_IRUGO,
+		   isl29003_show_range, isl29003_store_range);
+
+
+/* resolution */
+static ssize_t isl29003_show_resolution(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_resolution(client));
+}
+
+static ssize_t isl29003_store_resolution(struct device *dev,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+		return -EINVAL;
+
+	ret = isl29003_set_resolution(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(resolution, S_IWUSR | S_IRUGO,
+		   isl29003_show_resolution, isl29003_store_resolution);
+
+/* mode */
+static ssize_t isl29003_show_mode(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_mode(client));
+}
+
+static ssize_t isl29003_store_mode(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
+		return -EINVAL;
+
+	ret = isl29003_set_mode(client, val);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO,
+		   isl29003_show_mode, isl29003_store_mode);
+
+
+/* power state */
+static ssize_t isl29003_show_power_state(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	return sprintf(buf, "%d\n", isl29003_get_power_state(client));
+}
+
+static ssize_t isl29003_store_power_state(struct device *dev,
+					  struct device_attribute *attr,
+					  const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	unsigned long val;
+	int ret;
+
+	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+		return -EINVAL;
+
+	ret = isl29003_set_power_state(client, val);
+	return ret ? ret : count;
+}
+
+static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO,
+		   isl29003_show_power_state, isl29003_store_power_state);
+
+
+/* lux */
+static ssize_t isl29003_show_lux(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	/* No LUX data if not operational */
+	if (!isl29003_get_power_state(client))
+		return -EBUSY;
+
+	return sprintf(buf, "%d\n", isl29003_get_adc_value(client));
+}
+
+static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL);
+
+static struct attribute *isl29003_attributes[] = {
+	&dev_attr_range.attr,
+	&dev_attr_resolution.attr,
+	&dev_attr_mode.attr,
+	&dev_attr_power_state.attr,
+	&dev_attr_lux.attr,
+	NULL
+};
+
+static const struct attribute_group isl29003_attr_group = {
+	.attrs = isl29003_attributes,
+};
+
+static int isl29003_init_client(struct i2c_client *client)
+{
+	struct isl29003_data *data = i2c_get_clientdata(client);
+	int i;
+
+	/* read all the registers once to fill the cache.
+	 * if one of the reads fails, we consider the init failed */
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++) {
+		int v = i2c_smbus_read_byte_data(client, i);
+		if (v < 0)
+			return -ENODEV;
+
+		data->reg_cache[i] = v;
+	}
+
+	/* set defaults */
+	isl29003_set_range(client, 0);
+	isl29003_set_resolution(client, 0);
+	isl29003_set_mode(client, 0);
+	isl29003_set_power_state(client, 0);
+
+	return 0;
+}
+
+/*
+ * I2C layer
+ */
+
+static int __devinit isl29003_probe(struct i2c_client *client,
+				    const struct i2c_device_id *id)
+{
+	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
+	struct isl29003_data *data;
+	int err = 0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
+		return -EIO;
+
+	data = kzalloc(sizeof(struct isl29003_data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->client = client;
+	i2c_set_clientdata(client, data);
+	mutex_init(&data->lock);
+
+	/* initialize the ISL29003 chip */
+	err = isl29003_init_client(client);
+	if (err)
+		goto exit_kfree;
+
+	/* register sysfs hooks */
+	err = sysfs_create_group(&client->dev.kobj, &isl29003_attr_group);
+	if (err)
+		goto exit_kfree;
+
+	dev_info(&client->dev, "driver version %s enabled\n", DRIVER_VERSION);
+	return 0;
+
+exit_kfree:
+	kfree(data);
+	return err;
+}
+
+static int __devexit isl29003_remove(struct i2c_client *client)
+{
+	sysfs_remove_group(&client->dev.kobj, &isl29003_attr_group);
+	isl29003_set_power_state(client, 0);
+	kfree(i2c_get_clientdata(client));
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+	return isl29003_set_power_state(client, 0);
+}
+
+static int isl29003_resume(struct i2c_client *client)
+{
+	int i;
+	struct isl29003_data *data = i2c_get_clientdata(client);
+
+	/* restore registers from cache */
+	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
+		if (!i2c_smbus_write_byte_data(client, i, data->reg_cache[i]))
+			return -EIO;
+
+	return 0;
+}
+
+#else
+#define isl29003_suspend	NULL
+#define isl29003_resume		NULL
+#endif /* CONFIG_PM */
+
+static const struct i2c_device_id isl29003_id[] = {
+	{ "isl29003", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, isl29003_id);
+
+static struct i2c_driver isl29003_driver = {
+	.driver = {
+		.name	= ISL29003_DRV_NAME,
+		.owner	= THIS_MODULE,
+	},
+	.suspend = isl29003_suspend,
+	.resume	= isl29003_resume,
+	.probe	= isl29003_probe,
+	.remove	= __devexit_p(isl29003_remove),
+	.id_table = isl29003_id,
+};
+
+static int __init isl29003_init(void)
+{
+	return i2c_add_driver(&isl29003_driver);
+}
+
+static void __exit isl29003_exit(void)
+{
+	i2c_del_driver(&isl29003_driver);

drivers/misc/isl29003.c line 470

Quoted 10 lines
drivers/misc/isl29003.c new file +10 -0
+}
+
+MODULE_AUTHOR("Daniel Mack <[email protected]>");
+MODULE_DESCRIPTION("ISL29003 ambient light sensor driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(DRIVER_VERSION);
+
+module_init(isl29003_init);
+module_exit(isl29003_exit);
+

All looks fine to me.

Cheers,

Jonathan

#61 lore raw
Quoted 13 lines · Jonathan Cameron
Quoted 13 lines
Quoted 1 line

From 8ee5021834900f312ff26cd2586c18e99af31a5d Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 10 Mar 2009 16:13:07 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

[...]

Quoted 3 lines

All looks fine to me.

Ok, wonderful :)

What's the merge path for that, who'll queue it?

Thanks,
Daniel

#62 lore raw
Quoted 13 lines · On Wed, 11 Mar 2009 01:31:55 +0100 Daniel Mack…
Quoted 12 lines · Jonathan Cameron
Quoted 12 lines
Quoted 1 line

From 8ee5021834900f312ff26cd2586c18e99af31a5d Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 10 Mar 2009 16:13:07 +0100
Subject: [PATCH] Added driver for ISL29003 ambient light sensor

This patch adds a driver for Intersil's ISL29003 ambient light sensor device plus some documentation. Inspired by tsl2550.c, a driver for a similar device.

It is put to drivers/misc for now until the industrial I/O framework gets merged.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

[...]

Quoted 3 lines

All looks fine to me.

I cannot find this review which Jonathan performed. Fumbled reply-to-all, or did vger break?

Quoted 3 lines

Ok, wonderful :)

What's the merge path for that, who'll queue it?

I can take care of it.

Was any thought given to the CONFIG_SYSFS=n situation?

#63 lore raw
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Wed, 11 Mar 2009 01:31:55 +0100 Daniel Mack…
Quoted 3 lines

All looks fine to me.

I cannot find this review which Jonathan performed. Fumbled reply-to-all, or did vger break?

Jonathan replied to the posting on linux-i2c and linux-kernel wasn't in the loop, sorry. Find his posting here:

	http://marc.info/?l=linux-i2c&m=123669064909549&w=2
Quoted 3 lines

I can take care of it.

Was any thought given to the CONFIG_SYSFS=n situation?

You're right, it should depend on that. You want me so send a patch on top of the other or one that replaces it?

Thanks,
Daniel

#64 lore raw
Quoted 6 lines · On Wed, 11 Mar 2009 09:32:52 +0100 Daniel Mack…
Quoted 5 lines · Andrew Morton
Quoted 3 lines · On Wed, 11 Mar 2009 01:31:55 +0100 Daniel Mack…
Quoted 3 lines

All looks fine to me.

Quoted 7 lines
Quoted 2 lines

I cannot find this review which Jonathan performed. Fumbled reply-to-all, or did vger break?

Jonathan replied to the posting on linux-i2c and linux-kernel wasn't in the loop, sorry. Find his posting here:

	http://marc.info/?l=linux-i2c&m=123669064909549&w=2

OK. Please always use reply-to-all, guys.

Quoted 6 lines
Quoted 3 lines

I can take care of it.

Was any thought given to the CONFIG_SYSFS=n situation?

You're right, it should depend on that. You want me so send a patch on top of the other or one that replaces it?

Either way is OK by me at this time.

#65 lore raw
Quoted 6 lines · Andrew Morton
Quoted 4 lines

Jonathan replied to the posting on linux-i2c and linux-kernel wasn't in the loop, sorry. Find his posting here:

	http://marc.info/?l=linux-i2c&m=123669064909549&w=2

OK. Please always use reply-to-all, guys.

The thread moved from linux-i2c to linux-kernel, hence the trouble.

Quoted 4 lines
Quoted 2 lines

You're right, it should depend on that. You want me so send a patch on top of the other or one that replaces it?

Either way is OK by me at this time.

Ok, I chose the shorter variant :) See the patch below.

Thanks,
Daniel

Quoted 1 line

From 9143c849682280ca3b0544e580bc90241c385927 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Wed, 11 Mar 2009 17:39:13 +0100
Subject: [PATCH] make isl29003 depend on sysfs

---
 drivers/misc/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/misc/Kconfig +1 -1
index b883b19..16e1815 100644
@@ -225,7 +225,7 @@ config DELL_LAPTOP
 
 config ISL29003
 	tristate "Intersil ISL29003 ambient light sensor"
-	depends on I2C
+	depends on I2C && SYSFS
 	help
 	  If you say yes here you get support for the Intersil ISL29003
 	  ambient light sensor.
Signature · 1 line
1.6.2