ALS: TSL2550 driver move from i2c/chips
PATCH v2 1/1 ALS: TSL2550 driver move from i2c/chips
---
This is not a finished patch. We still need to resolve the debate on naming conventions with ALS. Basically is there are a pressing reason for not having /sys/class/als/als0/ etc and moving management into the core? Otherwise we end up with every driver having to implement their own management systems and a lot of code replication.
This will however work with current ALS patch set.
Additions since previous V1:
Removed set operating mode sysfs and replaced with an illuminance0_range_max. If requested max is in low range it will go with that, otherwise maximum range is selected.
For now I've left the device id code etc alone, as moving this into the ALS core is still under debate.
Couple of trivial style fixes thrown up by checkpatch in the original driver that we might was well fix during this move.
V1:
Minimal changes made. Untested due to lack of hardware.
Full patch this time rather than move one.
Documentation/ABI/testing/sysfs-class-als | 9 + drivers/als/Kconfig | 14 + drivers/als/Makefile | 2 + drivers/als/tsl2550.c | 535 +++++++++++++++++++++++++++++ drivers/i2c/chips/Kconfig | 10 - drivers/i2c/chips/Makefile | 1 - drivers/i2c/chips/tsl2550.c | 470 ------------------------- 7 files changed, 560 insertions(+), 481 deletions(-)
Documentation/ABI/testing/sysfs-class-als +9 -0
@@ -7,3 +7,12 @@ Description: Current Ambient Light Illuminance reported by Unit: lux (lumens per square meter) RO +What: /sys/class/als/.../illuminance[n]_range_max +Date: Oct. 2009 +KernelVersion: 2.6.32 +Contact: Jonathan Cameron <[email protected]> +Description: Maximum value of Ambient Light Illuminance as + reported by ALS driver. Used when a device + has a multiple operating ranges. + Unit: lux (lumens per square meter) + RW
drivers/als/Kconfig +14 -0
@@ -8,3 +8,17 @@ menuconfig ALS This framework provides a generic sysfs I/F for Ambient Light Sensor devices. If you want this support, you should say Y or M here. + +if ALS + +config ALS_TSL2550 + tristate "Taos TSL2550 ambient light sensor" + depends on EXPERIMENTAL && 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 #ALS
drivers/als/Makefile +2 -0
@@ -3,3 +3,5 @@ # obj-$(CONFIG_ALS) += als_sys.o + +obj-$(CONFIG_ALS_TSL2550) += tsl2550.o
drivers/als/tsl2550.c new file +535 -0
535 lines not on this page · raw message
drivers/i2c/chips/Kconfig +0 -10
@@ -16,14 +16,4 @@ config DS1682 This driver can also be built as a module. If so, the module will be called ds1682. -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
@@ -11,7 +11,6 @@ # obj-$(CONFIG_DS1682) += ds1682.o -obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/tsl2550.c deleted +0 -470
470 lines not on this page · raw message
Signature · 1 line
1.6.3.3
drivers/als/tsl2550.c line 88
Quoted 11 lines · Jonathan Cameron
drivers/als/tsl2550.c new file +11
-0+static int tsl2550_get_id (void ) +{ +int ret, val; + +idr_again: +if (unlikely (idr_pre_get (&tsl2550_idr,GFP_KERNEL ) ==0 )) +return -ENOMEM ; +spin_lock (&tsl2550_idr_lock); + ret =idr_get_new (&tsl2550_idr,NULL , &val); +if (unlikely (ret == -EAGAIN )) + goto idr_again;
That looks like a fair chance to produce a deadlock by reacquiring the above spinlock.
Also I never see the above lock released later from this function or its caller.
---
Since V2:
Fix of silly idr allocation code mistake. Illustrated Jean's point that someone would muck this up rather too well. (thanks Frederick!)
Additions since previous V1:
Removed set operating mode sysfs and replaced with an illuminance0_range_max. If requested max is in low range it will go with that, otherwise maximum range is selected.
For now I've left the device id code etc alone, as moving this into the ALS core is still under debate.
Couple of trivial style fixes.
V1:
Minimal changes made. Untested due to lack of hardware.
--- Documentation/ABI/testing/sysfs-class-als | 9 + drivers/als/Kconfig | 14 + drivers/als/Makefile | 2 + drivers/als/tsl2550.c | 536 +++++++++++++++++++++++++++++ drivers/i2c/chips/Kconfig | 10 - drivers/i2c/chips/Makefile | 1 - drivers/i2c/chips/tsl2550.c | 470 ------------------------- 7 files changed, 561 insertions(+), 481 deletions(-)
(quoted diff) +0 -0
b/Documentation/ABI/testing/sysfs-class-als
index d3b33f3..9db1936 100644
Documentation/ABI/testing/sysfs-class-als +0 -0
@@ -7,3 +7,12 @@ Description: Current Ambient Light Illuminance
reported by
Unit: lux (lumens per square meter)
RO
+What: /sys/class/als/.../illuminance[n]_range_max
+Date: Oct. 2009
+KernelVersion: 2.6.32
+Contact: Jonathan Cameron <[email protected]>
+Description: Maximum value of Ambient Light Illuminance as
+ reported by ALS driver. Used when a device + has a multiple operating ranges. + Unit: lux (lumens per square meter) + RW
drivers/als/Kconfig +14 -0
@@ -8,3 +8,17 @@ menuconfig ALS This framework provides a generic sysfs I/F for Ambient Light Sensor devices. If you want this support, you should say Y or M here. + +if ALS + +config ALS_TSL2550 + tristate "Taos TSL2550 ambient light sensor" + depends on EXPERIMENTAL && 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 #ALS
drivers/als/Makefile +2 -0
@@ -3,3 +3,5 @@ # obj-$(CONFIG_ALS) += als_sys.o + +obj-$(CONFIG_ALS_TSL2550) += tsl2550.o
drivers/als/tsl2550.c new file +536 -0
536 lines not on this page · raw message
drivers/i2c/chips/Kconfig +0 -10
@@ -16,14 +16,4 @@ config DS1682 This driver can also be built as a module. If so, the module will be called ds1682. -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
@@ -11,7 +11,6 @@ # obj-$(CONFIG_DS1682) += ds1682.o -obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/tsl2550.c deleted +0 -470
470 lines not on this page · raw message
Signature · 1 line
1.6.3.3