Skip to contentSkip to conversation

Add ALS drivers for the apds9802als

PATCH In review Alan Cox 2 participants 2 messages Sep 28, 2010

Subsystems (2)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 Add ALS drivers for the apds9802als

From: anantha <[email protected]>

This adds support for the ADPS9802ALS sensor.

Cleanup by Alan Cox
- move mutexes to cover more things
- report I/O errors back to user space
- report range and values in LUX

[The 4K and 64K in the hw spec acutally means 4095 (12bit) and 65535 (16bit).]

---

 drivers/misc/Kconfig       |   10 +
 drivers/misc/Makefile      |    1 
 drivers/misc/apds9802als.c |  308 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 319 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/apds9802als.c
drivers/misc/Kconfig +10 -0
index 53b21ff..d6ec9ce 100644
@@ -293,6 +293,16 @@ config SGI_GRU_DEBUG
 	This option enables addition debugging code for the SGI GRU driver. If
 	you are unsure, say N.
 
+config APDS9802ALS
+	tristate "Medfield Avago APDS9802 ALS Sensor module"
+	depends on I2C
+	help
+	  If you say yes here you get support for the ALS APDS9802 ambient
+	  light sensor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called apds9802als.
+
 config ISL29003
 	tristate "Intersil ISL29003 ambient light sensor"
 	depends on I2C && SYSFS
drivers/misc/Makefile +1 -0
index 4c771a2..0e5f2a5 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_SGI_XP)		+= sgi-xp/
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_CS5535_MFGPT)	+= cs5535-mfgpt.o
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
+obj-$(CONFIG_APDS9802ALS)	+= apds9802als.o
 obj-$(CONFIG_ISL29003)		+= isl29003.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 obj-$(CONFIG_EP93XX_PWM)	+= ep93xx_pwm.o
drivers/misc/apds9802als.c new file +308 -0

308 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Alan Cox
 drivers/misc/apds9802als.c |  308 ++++++++++++++++++++++++++++++++++++++++++++

[]

drivers/misc/apds9802als.c line 231

Quoted 9 lines
drivers/misc/apds9802als.c new file +9 -0
+static int  apds9802als_probe(struct i2c_client *client,
+					const struct i2c_device_id *id)
+{
+	int res;
+	struct als_data *data;
+
+	data = kzalloc(sizeof(struct als_data), GFP_KERNEL);
+	if (data == NULL) {
+		dev_err(&client->dev, "Memory allocation failed");

missing newline.