diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2009-12-12 17:32:59 +0000 |
---|---|---|
committer | Jonathan Cameron <jic23@cam.ac.uk> | 2010-02-18 12:06:51 +0000 |
commit | b7a9faba2d4f6d8cf95ac02ec5461c95241a0a01 (patch) | |
tree | 14e168426b074f984e7da706adb8c4d89bf9a0c9 | |
parent | b06a44d764d2ec6656f99184d16a7c4896ba991b (diff) |
isl29003: Move from misc to als now it is available with minimal changes
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Daniel Mack <daniel@caiaq.de>
-rw-r--r-- | drivers/als/Kconfig | 10 | ||||
-rw-r--r-- | drivers/als/Makefile | 2 | ||||
-rw-r--r-- | drivers/als/isl29003.c (renamed from drivers/misc/isl29003.c) | 46 | ||||
-rw-r--r-- | drivers/misc/Kconfig | 10 | ||||
-rw-r--r-- | drivers/misc/Makefile | 1 |
5 files changed, 43 insertions, 26 deletions
diff --git a/drivers/als/Kconfig b/drivers/als/Kconfig index 1564ffca5e75..9d99ac2b218e 100644 --- a/drivers/als/Kconfig +++ b/drivers/als/Kconfig @@ -11,6 +11,16 @@ menuconfig ALS if ALS +config ALS_ISL29003 + tristate "Intersil ISL29003 ambient light sensor" + depends on I2C && SYSFS + 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 ALS_TSL2550 tristate "Taos TSL2550 ambient light sensor" depends on EXPERIMENTAL && I2C diff --git a/drivers/als/Makefile b/drivers/als/Makefile index 314c645b79eb..4822b0f4b796 100644 --- a/drivers/als/Makefile +++ b/drivers/als/Makefile @@ -4,4 +4,6 @@ obj-$(CONFIG_ALS) += als_sys.o +obj-$(CONFIG_ALS_ISL29003) += isl29003.o obj-$(CONFIG_ALS_TSL2550) += tsl2550.o + diff --git a/drivers/misc/isl29003.c b/drivers/als/isl29003.c index a71e245801ee..1d7824a2873b 100644 --- a/drivers/misc/isl29003.c +++ b/drivers/als/isl29003.c @@ -31,9 +31,11 @@ #include <linux/i2c.h> #include <linux/mutex.h> #include <linux/delay.h> +#include <linux/als_sys.h> +#include <linux/err.h> #define ISL29003_DRV_NAME "isl29003" -#define DRIVER_VERSION "1.0" +#define DRIVER_VERSION "2.0" #define ISL29003_REG_COMMAND 0x00 #define ISL29003_ADC_ENABLED (1 << 7) @@ -61,6 +63,7 @@ #define ISL29003_NUM_CACHABLE_REGS 4 struct isl29003_data { + struct device *classdev; struct i2c_client *client; struct mutex lock; u8 reg_cache[ISL29003_NUM_CACHABLE_REGS]; @@ -196,7 +199,7 @@ static int isl29003_get_adc_value(struct i2c_client *client) static ssize_t isl29003_show_range(struct device *dev, struct device_attribute *attr, char *buf) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(dev->parent); return sprintf(buf, "%i\n", isl29003_get_range(client)); } @@ -204,7 +207,7 @@ 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); + struct i2c_client *client = to_i2c_client(dev->parent); unsigned long val; int ret; @@ -227,7 +230,7 @@ static ssize_t isl29003_show_resolution(struct device *dev, struct device_attribute *attr, char *buf) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(dev->parent); return sprintf(buf, "%d\n", isl29003_get_resolution(client)); } @@ -235,7 +238,7 @@ 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); + struct i2c_client *client = to_i2c_client(dev->parent); unsigned long val; int ret; @@ -256,14 +259,14 @@ static DEVICE_ATTR(resolution, S_IWUSR | S_IRUGO, static ssize_t isl29003_show_mode(struct device *dev, struct device_attribute *attr, char *buf) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(dev->parent); 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); + struct i2c_client *client = to_i2c_client(dev->parent); unsigned long val; int ret; @@ -286,7 +289,7 @@ static ssize_t isl29003_show_power_state(struct device *dev, struct device_attribute *attr, char *buf) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(dev->parent); return sprintf(buf, "%d\n", isl29003_get_power_state(client)); } @@ -294,7 +297,7 @@ 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); + struct i2c_client *client = to_i2c_client(dev->parent); unsigned long val; int ret; @@ -313,7 +316,7 @@ static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO, static ssize_t isl29003_show_lux(struct device *dev, struct device_attribute *attr, char *buf) { - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client = to_i2c_client(dev->parent); /* No LUX data if not operational */ if (!isl29003_get_power_state(client)) @@ -322,14 +325,14 @@ static ssize_t isl29003_show_lux(struct device *dev, return sprintf(buf, "%d\n", isl29003_get_adc_value(client)); } -static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL); +static DEVICE_ATTR(illuminance0, 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, + &dev_attr_illuminance0.attr, NULL }; @@ -388,14 +391,23 @@ static int __devinit isl29003_probe(struct i2c_client *client, if (err) goto exit_kfree; + data->classdev = als_device_register(&client->dev); + if (IS_ERR(data->classdev)) { + err = PTR_ERR(data->classdev); + goto exit_kfree; + } + /* register sysfs hooks */ - err = sysfs_create_group(&client->dev.kobj, &isl29003_attr_group); + err = sysfs_create_group(&data->classdev->kobj, &isl29003_attr_group); if (err) - goto exit_kfree; + goto exit_unreg; dev_info(&client->dev, "driver version %s enabled\n", DRIVER_VERSION); + return 0; +exit_unreg: + als_device_unregister(data->classdev); exit_kfree: kfree(data); return err; @@ -403,9 +415,13 @@ exit_kfree: static int __devexit isl29003_remove(struct i2c_client *client) { - sysfs_remove_group(&client->dev.kobj, &isl29003_attr_group); + struct isl29003_data *data = i2c_get_clientdata(client); + + sysfs_remove_group(&data->classdev->kobj, &isl29003_attr_group); + als_device_unregister(data->classdev); isl29003_set_power_state(client, 0); kfree(i2c_get_clientdata(client)); + return 0; } diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index e3551d20464f..3e9a7cd07704 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -249,16 +249,6 @@ config SGI_GRU_DEBUG This option enables addition debugging code for the SGI GRU driver. If you are unsure, say N. -config ISL29003 - tristate "Intersil ISL29003 ambient light sensor" - depends on I2C && SYSFS - 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 EP93XX_PWM tristate "EP93xx PWM support" depends on ARCH_EP93XX diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 049ff2482f30..aef32fa675f9 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -20,7 +20,6 @@ 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_ISL29003) += isl29003.o obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o obj-$(CONFIG_DS1682) += ds1682.o obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o |