summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2010-01-28 18:19:17 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2010-01-28 18:19:17 +1100
commitc136720c0bc1842978225b5d312002b27b0d35a8 (patch)
treeb0f29dde8bdcecacf8cbb27e1500149382af544e
parent9c8ec0bea7f4fa59b33caef310a111afc3837706 (diff)
Revert "tsl2550: Move form i2c/chips to als and update interfaces"
This reverts commit b75349f118718a435f2bb7b6e675572ecd591627.
-rw-r--r--Documentation/ABI/testing/sysfs-class-als9
-rw-r--r--drivers/als/Kconfig14
-rw-r--r--drivers/als/Makefile2
-rw-r--r--drivers/i2c/chips/Kconfig10
-rw-r--r--drivers/i2c/chips/Makefile2
-rw-r--r--drivers/i2c/chips/tsl2550.c (renamed from drivers/als/tsl2550.c)91
6 files changed, 45 insertions, 83 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-als b/Documentation/ABI/testing/sysfs-class-als
index 732f449ef22f..d3b33f3be579 100644
--- a/Documentation/ABI/testing/sysfs-class-als
+++ b/Documentation/ABI/testing/sysfs-class-als
@@ -7,12 +7,3 @@ Description: Current Ambient Light Illuminance reported by
Unit: lux (lumens per square meter)
RO
-What: /sys/class/als/.../exposure_time[n]
-Date: Dec. 2009
-KernelVersion: 2.6.32
-Contact: Jonathan Cameron <jic23@cam.ac.uk>
-Description: Sensor exposure time. In some devices this
- corresponds to the combined time needed to
- to internally read several different sensors.
- Unit: microseconds
- RW
diff --git a/drivers/als/Kconfig b/drivers/als/Kconfig
index 1564ffca5e75..200c52ba5eff 100644
--- a/drivers/als/Kconfig
+++ b/drivers/als/Kconfig
@@ -8,17 +8,3 @@ 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
diff --git a/drivers/als/Makefile b/drivers/als/Makefile
index 314c645b79eb..a5271978134a 100644
--- a/drivers/als/Makefile
+++ b/drivers/als/Makefile
@@ -3,5 +3,3 @@
#
obj-$(CONFIG_ALS) += als_sys.o
-
-obj-$(CONFIG_ALS_TSL2550) += tsl2550.o
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index c11f8d61cf43..ae4539d99bef 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -6,4 +6,14 @@
menu "Miscellaneous I2C Chip support"
+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
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index ffde18d53531..fe0af0f81f2d 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -10,6 +10,8 @@
# * I/O expander drivers go to drivers/gpio
#
+obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
+
ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
EXTRA_CFLAGS += -DDEBUG
endif
diff --git a/drivers/als/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 27745a579dc3..b153ba6b182e 100644
--- a/drivers/als/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -3,7 +3,6 @@
*
* Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it>
* Copyright (C) 2007 Eurotech S.p.A. <info@eurotech.it>
- * Copyright (C) 2009 Jonathan Cameron <jic23@cam.ac.uk>
*
* 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
@@ -25,11 +24,9 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
-#include <linux/err.h>
-#include <linux/als_sys.h>
#define TSL2550_DRV_NAME "tsl2550"
-#define DRIVER_VERSION "2.0"
+#define DRIVER_VERSION "1.2"
/*
* Defines
@@ -47,7 +44,6 @@
*/
struct tsl2550_data {
- struct device *classdev;
struct i2c_client *client;
struct mutex update_lock;
@@ -106,14 +102,11 @@ static int tsl2550_get_adc_value(struct i2c_client *client, u8 cmd)
return ret;
if (!(ret & 0x80))
return -EAGAIN;
- if (ret == 0x7f)
- return -ERANGE;
return ret & 0x7f; /* remove the "valid" bit */
}
/*
- * LUX calculation - note the range is dependent on combination
- * of infrared level and visible light levels.
+ * LUX calculation
*/
static const u8 ratio_lut[] = {
@@ -195,8 +188,7 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
static ssize_t tsl2550_show_power_state(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct i2c_client *client = to_i2c_client(dev->parent);
- struct tsl2550_data *data = i2c_get_clientdata(client);
+ struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev));
return sprintf(buf, "%u\n", data->power_state);
}
@@ -204,13 +196,12 @@ static ssize_t tsl2550_show_power_state(struct device *dev,
static ssize_t tsl2550_store_power_state(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct i2c_client *client = to_i2c_client(dev->parent);
+ struct i2c_client *client = to_i2c_client(dev);
struct tsl2550_data *data = i2c_get_clientdata(client);
- unsigned long val;
+ unsigned long val = simple_strtoul(buf, NULL, 10);
int ret;
- ret = strict_strtoul(buf, 10, &val);
- if (ret || val < 0 || val > 1)
+ if (val < 0 || val > 1)
return -EINVAL;
mutex_lock(&data->update_lock);
@@ -226,45 +217,40 @@ static ssize_t tsl2550_store_power_state(struct device *dev,
static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO,
tsl2550_show_power_state, tsl2550_store_power_state);
-static ssize_t tsl2550_show_exposure(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t tsl2550_show_operating_mode(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
- struct i2c_client *client = to_i2c_client(dev->parent);
- struct tsl2550_data *data = i2c_get_clientdata(client);
- if (data->operating_mode)
- return sprintf(buf, "160000\n");
- else
- return sprintf(buf, "800000\n");
+ struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev));
+
+ return sprintf(buf, "%u\n", data->operating_mode);
}
-static ssize_t tsl2550_store_exposure(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t count)
+static ssize_t tsl2550_store_operating_mode(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
{
- struct i2c_client *client = to_i2c_client(dev->parent);
+ struct i2c_client *client = to_i2c_client(dev);
struct tsl2550_data *data = i2c_get_clientdata(client);
- unsigned long val;
-
- int ret = strict_strtoul(buf, 10, &val);
+ unsigned long val = simple_strtoul(buf, NULL, 10);
+ int ret;
- if (ret)
+ if (val < 0 || val > 1)
return -EINVAL;
+
+ if (data->power_state == 0)
+ return -EBUSY;
+
mutex_lock(&data->update_lock);
- if (val >= 800000)
- ret = tsl2550_set_operating_mode(client, 0);
- else
- ret = tsl2550_set_operating_mode(client, 1);
+ ret = tsl2550_set_operating_mode(client, val);
mutex_unlock(&data->update_lock);
+
if (ret < 0)
return ret;
return count;
}
-static DEVICE_ATTR(exposure_time0, S_IWUSR | S_IRUGO,
- tsl2550_show_exposure, tsl2550_store_exposure);
+static DEVICE_ATTR(operating_mode, S_IWUSR | S_IRUGO,
+ tsl2550_show_operating_mode, tsl2550_store_operating_mode);
static ssize_t __tsl2550_show_lux(struct i2c_client *client, char *buf)
{
@@ -295,7 +281,7 @@ static ssize_t __tsl2550_show_lux(struct i2c_client *client, char *buf)
static ssize_t tsl2550_show_lux1_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct i2c_client *client = to_i2c_client(dev->parent);
+ struct i2c_client *client = to_i2c_client(dev);
struct tsl2550_data *data = i2c_get_clientdata(client);
int ret;
@@ -310,13 +296,13 @@ static ssize_t tsl2550_show_lux1_input(struct device *dev,
return ret;
}
-static DEVICE_ATTR(illuminance0, S_IRUGO,
+static DEVICE_ATTR(lux1_input, S_IRUGO,
tsl2550_show_lux1_input, NULL);
static struct attribute *tsl2550_attributes[] = {
&dev_attr_power_state.attr,
- &dev_attr_exposure_time0.attr,
- &dev_attr_illuminance0.attr,
+ &dev_attr_operating_mode.attr,
+ &dev_attr_lux1_input.attr,
NULL
};
@@ -402,22 +388,14 @@ static int __devinit tsl2550_probe(struct i2c_client *client,
goto exit_kfree;
/* Register sysfs hooks */
- data->classdev = als_device_register(&client->dev);
- if (IS_ERR(data->classdev)) {
- err = PTR_ERR(data->classdev);
- goto exit_kfree;
- }
-
- err = sysfs_create_group(&data->classdev->kobj, &tsl2550_attr_group);
+ err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group);
if (err)
- goto exit_unreg;
+ goto exit_kfree;
dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION);
return 0;
-exit_unreg:
- als_device_unregister(data->classdev);
exit_kfree:
kfree(data);
exit:
@@ -426,15 +404,12 @@ exit:
static int __devexit tsl2550_remove(struct i2c_client *client)
{
- struct tsl2550_data *data = i2c_get_clientdata(client);
-
- sysfs_remove_group(&data->classdev->kobj, &tsl2550_attr_group);
- als_device_unregister(data->classdev);
+ sysfs_remove_group(&client->dev.kobj, &tsl2550_attr_group);
/* Power down the device */
tsl2550_set_power_state(client, 0);
- kfree(data);
+ kfree(i2c_get_clientdata(client));
return 0;
}