diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
| commit | 6c9468e9eb1252eaefd94ce7f06e1be9b0b641b1 (patch) | |
| tree | 797676a336b050bfa1ef879377c07e541b9075d6 /drivers/misc | |
| parent | 4cb3ca7cd7e2cae8d1daf5345ec99a1e8502cf3f (diff) | |
| parent | c81eddb0e3728661d1585fbc564449c94165cc36 (diff) | |
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/misc')
35 files changed, 521 insertions, 5 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index d16af6a423fb..2191c8d896a0 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
| @@ -268,6 +268,16 @@ config ISL29003 | |||
| 268 | This driver can also be built as a module. If so, the module | 268 | This driver can also be built as a module. If so, the module |
| 269 | will be called isl29003. | 269 | will be called isl29003. |
| 270 | 270 | ||
| 271 | config SENSORS_TSL2550 | ||
| 272 | tristate "Taos TSL2550 ambient light sensor" | ||
| 273 | depends on I2C && SYSFS | ||
| 274 | help | ||
| 275 | If you say yes here you get support for the Taos TSL2550 | ||
| 276 | ambient light sensor. | ||
| 277 | |||
| 278 | This driver can also be built as a module. If so, the module | ||
| 279 | will be called tsl2550. | ||
| 280 | |||
| 271 | config EP93XX_PWM | 281 | config EP93XX_PWM |
| 272 | tristate "EP93xx PWM support" | 282 | tristate "EP93xx PWM support" |
| 273 | depends on ARCH_EP93XX | 283 | depends on ARCH_EP93XX |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 049ff2482f30..27c484355414 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
| @@ -21,6 +21,7 @@ obj-$(CONFIG_SGI_GRU) += sgi-gru/ | |||
| 21 | obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o | 21 | obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o |
| 22 | obj-$(CONFIG_HP_ILO) += hpilo.o | 22 | obj-$(CONFIG_HP_ILO) += hpilo.o |
| 23 | obj-$(CONFIG_ISL29003) += isl29003.o | 23 | obj-$(CONFIG_ISL29003) += isl29003.o |
| 24 | obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o | ||
| 24 | obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o | 25 | obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o |
| 25 | obj-$(CONFIG_DS1682) += ds1682.o | 26 | obj-$(CONFIG_DS1682) += ds1682.o |
| 26 | obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o | 27 | obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o |
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 558bf3f2c276..4afffe610f99 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
| 16 | #include <linux/spinlock.h> | 16 | #include <linux/spinlock.h> |
| 17 | #include <linux/atmel-ssc.h> | 17 | #include <linux/atmel-ssc.h> |
| 18 | #include <linux/slab.h> | ||
| 18 | 19 | ||
| 19 | /* Serialize access to ssc_list and user count */ | 20 | /* Serialize access to ssc_list and user count */ |
| 20 | static DEFINE_SPINLOCK(user_lock); | 21 | static DEFINE_SPINLOCK(user_lock); |
diff --git a/drivers/misc/atmel_pwm.c b/drivers/misc/atmel_pwm.c index 6aa5294dfec4..0f3fb4f03bdf 100644 --- a/drivers/misc/atmel_pwm.c +++ b/drivers/misc/atmel_pwm.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
| 2 | #include <linux/clk.h> | 2 | #include <linux/clk.h> |
| 3 | #include <linux/err.h> | 3 | #include <linux/err.h> |
| 4 | #include <linux/slab.h> | ||
| 4 | #include <linux/io.h> | 5 | #include <linux/io.h> |
| 5 | #include <linux/interrupt.h> | 6 | #include <linux/interrupt.h> |
| 6 | #include <linux/platform_device.h> | 7 | #include <linux/platform_device.h> |
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c index 05dc8a31f280..3891124001f2 100644 --- a/drivers/misc/atmel_tclib.c +++ b/drivers/misc/atmel_tclib.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <linux/ioport.h> | 6 | #include <linux/ioport.h> |
| 7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
| 8 | #include <linux/platform_device.h> | 8 | #include <linux/platform_device.h> |
| 9 | #include <linux/slab.h> | ||
| 9 | 10 | ||
| 10 | /* Number of bytes to reserve for the iomem resource */ | 11 | /* Number of bytes to reserve for the iomem resource */ |
| 11 | #define ATMEL_TC_IOMEM_SIZE 256 | 12 | #define ATMEL_TC_IOMEM_SIZE 256 |
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index b5346b4db91a..ed090e77c9cd 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
| 21 | #include <linux/idr.h> | 21 | #include <linux/idr.h> |
| 22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
| 23 | #include <linux/slab.h> | ||
| 23 | 24 | ||
| 24 | #include <linux/c2port.h> | 25 | #include <linux/c2port.h> |
| 25 | 26 | ||
| @@ -912,8 +913,8 @@ struct c2port_device *c2port_device_register(char *name, | |||
| 912 | 913 | ||
| 913 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, | 914 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, |
| 914 | "c2port%d", id); | 915 | "c2port%d", id); |
| 915 | if (unlikely(!c2dev->dev)) { | 916 | if (unlikely(IS_ERR(c2dev->dev))) { |
| 916 | ret = -ENOMEM; | 917 | ret = PTR_ERR(c2dev->dev); |
| 917 | goto error_device_create; | 918 | goto error_device_create; |
| 918 | } | 919 | } |
| 919 | dev_set_drvdata(c2dev->dev, c2dev); | 920 | dev_set_drvdata(c2dev->dev, c2dev); |
diff --git a/drivers/misc/cb710/core.c b/drivers/misc/cb710/core.c index b14eab0f2ba5..efec4139c3f6 100644 --- a/drivers/misc/cb710/core.c +++ b/drivers/misc/cb710/core.c | |||
| @@ -9,11 +9,11 @@ | |||
| 9 | */ | 9 | */ |
| 10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/slab.h> | ||
| 13 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
| 14 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
| 15 | #include <linux/idr.h> | 14 | #include <linux/idr.h> |
| 16 | #include <linux/cb710.h> | 15 | #include <linux/cb710.h> |
| 16 | #include <linux/gfp.h> | ||
| 17 | 17 | ||
| 18 | static DEFINE_IDA(cb710_ida); | 18 | static DEFINE_IDA(cb710_ida); |
| 19 | static DEFINE_SPINLOCK(cb710_ida_lock); | 19 | static DEFINE_SPINLOCK(cb710_ida_lock); |
diff --git a/drivers/misc/cb710/debug.c b/drivers/misc/cb710/debug.c index 02358d086e03..fcb3b8e30c52 100644 --- a/drivers/misc/cb710/debug.c +++ b/drivers/misc/cb710/debug.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <linux/cb710.h> | 10 | #include <linux/cb710.h> |
| 11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/slab.h> | ||
| 14 | 13 | ||
| 15 | #define CB710_REG_COUNT 0x80 | 14 | #define CB710_REG_COUNT 0x80 |
| 16 | 15 | ||
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c index 8110460558ff..9bec24db4d41 100644 --- a/drivers/misc/cs5535-mfgpt.c +++ b/drivers/misc/cs5535-mfgpt.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
| 20 | #include <linux/cs5535.h> | 20 | #include <linux/cs5535.h> |
| 21 | #include <linux/slab.h> | ||
| 21 | 22 | ||
| 22 | #define DRV_NAME "cs5535-mfgpt" | 23 | #define DRV_NAME "cs5535-mfgpt" |
| 23 | #define MFGPT_BAR 2 | 24 | #define MFGPT_BAR 2 |
diff --git a/drivers/misc/ds1682.c b/drivers/misc/ds1682.c index f3ee4a1abb77..9197cfc55015 100644 --- a/drivers/misc/ds1682.c +++ b/drivers/misc/ds1682.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | 33 | ||
| 34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
| 35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 36 | #include <linux/slab.h> | ||
| 37 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
| 38 | #include <linux/string.h> | 37 | #include <linux/string.h> |
| 39 | #include <linux/list.h> | 38 | #include <linux/list.h> |
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 2cb2736d65aa..db7d0f21b65d 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c | |||
| @@ -505,6 +505,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
| 505 | * Export the EEPROM bytes through sysfs, since that's convenient. | 505 | * Export the EEPROM bytes through sysfs, since that's convenient. |
| 506 | * By default, only root should see the data (maybe passwords etc) | 506 | * By default, only root should see the data (maybe passwords etc) |
| 507 | */ | 507 | */ |
| 508 | sysfs_bin_attr_init(&at24->bin); | ||
| 508 | at24->bin.attr.name = "eeprom"; | 509 | at24->bin.attr.name = "eeprom"; |
| 509 | at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR; | 510 | at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR; |
| 510 | at24->bin.read = at24_bin_read; | 511 | at24->bin.read = at24_bin_read; |
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index d902d81dde39..d194212a41f6 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c | |||
| @@ -347,6 +347,7 @@ static int at25_probe(struct spi_device *spi) | |||
| 347 | * that's sensitive for read and/or write, like ethernet addresses, | 347 | * that's sensitive for read and/or write, like ethernet addresses, |
| 348 | * security codes, board-specific manufacturing calibrations, etc. | 348 | * security codes, board-specific manufacturing calibrations, etc. |
| 349 | */ | 349 | */ |
| 350 | sysfs_bin_attr_init(&at25->bin); | ||
| 350 | at25->bin.attr.name = "eeprom"; | 351 | at25->bin.attr.name = "eeprom"; |
| 351 | at25->bin.attr.mode = S_IRUSR; | 352 | at25->bin.attr.mode = S_IRUSR; |
| 352 | at25->bin.read = at25_bin_read; | 353 | at25->bin.read = at25_bin_read; |
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 1eac626e710a..48c84a58163e 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
| 29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
| 30 | #include <linux/slab.h> | ||
| 30 | 31 | ||
| 31 | static LIST_HEAD(container_list); | 32 | static LIST_HEAD(container_list); |
| 32 | static DEFINE_MUTEX(container_list_lock); | 33 | static DEFINE_MUTEX(container_list_lock); |
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c index ba4694169d79..46b3439673e9 100644 --- a/drivers/misc/ep93xx_pwm.c +++ b/drivers/misc/ep93xx_pwm.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/slab.h> | ||
| 22 | #include <linux/clk.h> | 23 | #include <linux/clk.h> |
| 23 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 24 | #include <linux/io.h> | 25 | #include <linux/io.h> |
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c index a92a3a742b43..98ad0120aa9b 100644 --- a/drivers/misc/hpilo.c +++ b/drivers/misc/hpilo.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
| 26 | #include <linux/wait.h> | 26 | #include <linux/wait.h> |
| 27 | #include <linux/poll.h> | 27 | #include <linux/poll.h> |
| 28 | #include <linux/slab.h> | ||
| 28 | #include "hpilo.h" | 29 | #include "hpilo.h" |
| 29 | 30 | ||
| 30 | static struct class *ilo_class; | 31 | static struct class *ilo_class; |
diff --git a/drivers/misc/ibmasm/command.c b/drivers/misc/ibmasm/command.c index e2031739aa29..5c766b4fb238 100644 --- a/drivers/misc/ibmasm/command.c +++ b/drivers/misc/ibmasm/command.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 26 | #include <linux/slab.h> | ||
| 26 | #include "ibmasm.h" | 27 | #include "ibmasm.h" |
| 27 | #include "lowlevel.h" | 28 | #include "lowlevel.h" |
| 28 | 29 | ||
diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c index 572d41ffc186..76bfda1ffaa9 100644 --- a/drivers/misc/ibmasm/event.c +++ b/drivers/misc/ibmasm/event.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 26 | #include <linux/slab.h> | ||
| 26 | #include "ibmasm.h" | 27 | #include "ibmasm.h" |
| 27 | #include "lowlevel.h" | 28 | #include "lowlevel.h" |
| 28 | 29 | ||
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index aecf40ecb3a4..8844a3f45381 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c | |||
| @@ -75,6 +75,7 @@ | |||
| 75 | 75 | ||
| 76 | #include <linux/fs.h> | 76 | #include <linux/fs.h> |
| 77 | #include <linux/pagemap.h> | 77 | #include <linux/pagemap.h> |
| 78 | #include <linux/slab.h> | ||
| 78 | #include <asm/uaccess.h> | 79 | #include <asm/uaccess.h> |
| 79 | #include <asm/io.h> | 80 | #include <asm/io.h> |
| 80 | #include "ibmasm.h" | 81 | #include "ibmasm.h" |
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c index dc14b0b9cbfa..a234d965243b 100644 --- a/drivers/misc/ibmasm/module.c +++ b/drivers/misc/ibmasm/module.c | |||
| @@ -52,6 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | #include <linux/pci.h> | 53 | #include <linux/pci.h> |
| 54 | #include <linux/init.h> | 54 | #include <linux/init.h> |
| 55 | #include <linux/slab.h> | ||
| 55 | #include "ibmasm.h" | 56 | #include "ibmasm.h" |
| 56 | #include "lowlevel.h" | 57 | #include "lowlevel.h" |
| 57 | #include "remote.h" | 58 | #include "remote.h" |
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c index 395a4ea64e9c..152e9d93eecb 100644 --- a/drivers/misc/ics932s401.c +++ b/drivers/misc/ics932s401.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
| 27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
| 28 | #include <linux/log2.h> | 28 | #include <linux/log2.h> |
| 29 | #include <linux/slab.h> | ||
| 29 | 30 | ||
| 30 | /* Addresses to scan */ | 31 | /* Addresses to scan */ |
| 31 | static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END }; | 32 | static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END }; |
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c index 09dcb699e667..193206602d88 100644 --- a/drivers/misc/ioc4.c +++ b/drivers/misc/ioc4.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
| 31 | #include <linux/ioc4.h> | 31 | #include <linux/ioc4.h> |
| 32 | #include <linux/ktime.h> | 32 | #include <linux/ktime.h> |
| 33 | #include <linux/slab.h> | ||
| 33 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
| 34 | #include <linux/time.h> | 35 | #include <linux/time.h> |
| 35 | #include <asm/io.h> | 36 | #include <asm/io.h> |
diff --git a/drivers/misc/iwmc3200top/debugfs.c b/drivers/misc/iwmc3200top/debugfs.c index 0c8ea0a1c8a3..e9eda471f6e0 100644 --- a/drivers/misc/iwmc3200top/debugfs.c +++ b/drivers/misc/iwmc3200top/debugfs.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/slab.h> | ||
| 28 | #include <linux/string.h> | 29 | #include <linux/string.h> |
| 29 | #include <linux/ctype.h> | 30 | #include <linux/ctype.h> |
| 30 | #include <linux/mmc/sdio_func.h> | 31 | #include <linux/mmc/sdio_func.h> |
diff --git a/drivers/misc/iwmc3200top/fw-download.c b/drivers/misc/iwmc3200top/fw-download.c index 9dbaeb574e63..e27afde6e99f 100644 --- a/drivers/misc/iwmc3200top/fw-download.c +++ b/drivers/misc/iwmc3200top/fw-download.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #include <linux/firmware.h> | 27 | #include <linux/firmware.h> |
| 28 | #include <linux/mmc/sdio_func.h> | 28 | #include <linux/mmc/sdio_func.h> |
| 29 | #include <linux/slab.h> | ||
| 29 | #include <asm/unaligned.h> | 30 | #include <asm/unaligned.h> |
| 30 | 31 | ||
| 31 | #include "iwmc3200top.h" | 32 | #include "iwmc3200top.h" |
diff --git a/drivers/misc/iwmc3200top/log.c b/drivers/misc/iwmc3200top/log.c index d569279698f6..a36a55a49cac 100644 --- a/drivers/misc/iwmc3200top/log.c +++ b/drivers/misc/iwmc3200top/log.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/mmc/sdio_func.h> | 28 | #include <linux/mmc/sdio_func.h> |
| 29 | #include <linux/slab.h> | ||
| 29 | #include <linux/ctype.h> | 30 | #include <linux/ctype.h> |
| 30 | #include "fw-msg.h" | 31 | #include "fw-msg.h" |
| 31 | #include "iwmc3200top.h" | 32 | #include "iwmc3200top.h" |
diff --git a/drivers/misc/iwmc3200top/main.c b/drivers/misc/iwmc3200top/main.c index 3b7292a5cea9..c73cef2c3c5e 100644 --- a/drivers/misc/iwmc3200top/main.c +++ b/drivers/misc/iwmc3200top/main.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/slab.h> | ||
| 28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
| 29 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
| 30 | #include <linux/debugfs.h> | 31 | #include <linux/debugfs.h> |
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index fcb6ec1af173..72450237a0f4 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c | |||
| @@ -295,6 +295,10 @@ static int check_and_rewind_pc(char *put_str, char *arg) | |||
| 295 | /* On x86 a breakpoint stop requires it to be decremented */ | 295 | /* On x86 a breakpoint stop requires it to be decremented */ |
| 296 | if (addr + 1 == kgdbts_regs.ip) | 296 | if (addr + 1 == kgdbts_regs.ip) |
| 297 | offset = -1; | 297 | offset = -1; |
| 298 | #elif defined(CONFIG_SUPERH) | ||
| 299 | /* On SUPERH a breakpoint stop requires it to be decremented */ | ||
| 300 | if (addr + 2 == kgdbts_regs.pc) | ||
| 301 | offset = -2; | ||
| 298 | #endif | 302 | #endif |
| 299 | if (strcmp(arg, "silent") && | 303 | if (strcmp(arg, "silent") && |
| 300 | instruction_pointer(&kgdbts_regs) + offset != addr) { | 304 | instruction_pointer(&kgdbts_regs) + offset != addr) { |
| @@ -305,6 +309,8 @@ static int check_and_rewind_pc(char *put_str, char *arg) | |||
| 305 | #ifdef CONFIG_X86 | 309 | #ifdef CONFIG_X86 |
| 306 | /* On x86 adjust the instruction pointer if needed */ | 310 | /* On x86 adjust the instruction pointer if needed */ |
| 307 | kgdbts_regs.ip += offset; | 311 | kgdbts_regs.ip += offset; |
| 312 | #elif defined(CONFIG_SUPERH) | ||
| 313 | kgdbts_regs.pc += offset; | ||
| 308 | #endif | 314 | #endif |
| 309 | return 0; | 315 | return 0; |
| 310 | } | 316 | } |
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 4a0648301fdf..31a991161f0a 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
| 41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
| 42 | #include <linux/hrtimer.h> | 42 | #include <linux/hrtimer.h> |
| 43 | #include <linux/slab.h> | ||
| 43 | #include <scsi/scsi_cmnd.h> | 44 | #include <scsi/scsi_cmnd.h> |
| 44 | #include <linux/debugfs.h> | 45 | #include <linux/debugfs.h> |
| 45 | 46 | ||
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 779aa8ebe4cf..75ee0d3f6f45 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
| 22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/cdev.h> | 23 | #include <linux/cdev.h> |
| 24 | #include <linux/slab.h> | ||
| 24 | #include <linux/phantom.h> | 25 | #include <linux/phantom.h> |
| 25 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
| 26 | #include <linux/smp_lock.h> | 27 | #include <linux/smp_lock.h> |
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 832ed4c88cf7..8d082b46426b 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | */ | 44 | */ |
| 45 | 45 | ||
| 46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
| 47 | #include <linux/slab.h> | ||
| 47 | #include <linux/sysctl.h> | 48 | #include <linux/sysctl.h> |
| 48 | #include <linux/device.h> | 49 | #include <linux/device.h> |
| 49 | #include <linux/delay.h> | 50 | #include <linux/delay.h> |
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c index 9a6268c89fdd..d551f09ccb79 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include <linux/device.h> | 18 | #include <linux/device.h> |
| 19 | #include <linux/hardirq.h> | 19 | #include <linux/hardirq.h> |
| 20 | #include <linux/slab.h> | ||
| 20 | #include "xpc.h" | 21 | #include "xpc.h" |
| 21 | #include <asm/uv/uv_hub.h> | 22 | #include <asm/uv/uv_hub.h> |
| 22 | 23 | ||
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c index 8b70e03f939f..7d71c04fc938 100644 --- a/drivers/misc/sgi-xp/xpc_sn2.c +++ b/drivers/misc/sgi-xp/xpc_sn2.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
| 17 | #include <linux/slab.h> | ||
| 17 | #include <asm/uncached.h> | 18 | #include <asm/uncached.h> |
| 18 | #include <asm/sn/mspec.h> | 19 | #include <asm/sn/mspec.h> |
| 19 | #include <asm/sn/sn_sal.h> | 20 | #include <asm/sn/sn_sal.h> |
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c index 8725d5e8ab0c..1f59ee2226ca 100644 --- a/drivers/misc/sgi-xp/xpc_uv.c +++ b/drivers/misc/sgi-xp/xpc_uv.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
| 20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
| 21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
| 22 | #include <linux/slab.h> | ||
| 22 | #include <asm/uv/uv_hub.h> | 23 | #include <asm/uv/uv_hub.h> |
| 23 | #if defined CONFIG_X86_64 | 24 | #if defined CONFIG_X86_64 |
| 24 | #include <asm/uv/bios.h> | 25 | #include <asm/uv/bios.h> |
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index 57b152f8d1b9..ee5109a3cd98 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <linux/slab.h> | ||
| 23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 24 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
| 25 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c index 98bcba521da2..5f6852dff40b 100644 --- a/drivers/misc/tifm_core.c +++ b/drivers/misc/tifm_core.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/tifm.h> | 12 | #include <linux/tifm.h> |
| 13 | #include <linux/slab.h> | ||
| 13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 14 | #include <linux/idr.h> | 15 | #include <linux/idr.h> |
| 15 | 16 | ||
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c new file mode 100644 index 000000000000..483ae5f7f68e --- /dev/null +++ b/drivers/misc/tsl2550.c | |||
| @@ -0,0 +1,473 @@ | |||
| 1 | /* | ||
| 2 | * tsl2550.c - Linux kernel modules for ambient light sensor | ||
| 3 | * | ||
| 4 | * Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it> | ||
| 5 | * Copyright (C) 2007 Eurotech S.p.A. <info@eurotech.it> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/i2c.h> | ||
| 26 | #include <linux/mutex.h> | ||
| 27 | |||
| 28 | #define TSL2550_DRV_NAME "tsl2550" | ||
| 29 | #define DRIVER_VERSION "1.2" | ||
| 30 | |||
| 31 | /* | ||
| 32 | * Defines | ||
| 33 | */ | ||
| 34 | |||
| 35 | #define TSL2550_POWER_DOWN 0x00 | ||
| 36 | #define TSL2550_POWER_UP 0x03 | ||
| 37 | #define TSL2550_STANDARD_RANGE 0x18 | ||
| 38 | #define TSL2550_EXTENDED_RANGE 0x1d | ||
| 39 | #define TSL2550_READ_ADC0 0x43 | ||
| 40 | #define TSL2550_READ_ADC1 0x83 | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Structs | ||
| 44 | */ | ||
| 45 | |||
| 46 | struct tsl2550_data { | ||
| 47 | struct i2c_client *client; | ||
| 48 | struct mutex update_lock; | ||
| 49 | |||
| 50 | unsigned int power_state:1; | ||
| 51 | unsigned int operating_mode:1; | ||
| 52 | }; | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Global data | ||
| 56 | */ | ||
| 57 | |||
| 58 | static const u8 TSL2550_MODE_RANGE[2] = { | ||
| 59 | TSL2550_STANDARD_RANGE, TSL2550_EXTENDED_RANGE, | ||
| 60 | }; | ||
| 61 | |||
| 62 | /* | ||
| 63 | * Management functions | ||
| 64 | */ | ||
| 65 | |||
| 66 | static int tsl2550_set_operating_mode(struct i2c_client *client, int mode) | ||
| 67 | { | ||
| 68 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 69 | |||
| 70 | int ret = i2c_smbus_write_byte(client, TSL2550_MODE_RANGE[mode]); | ||
| 71 | |||
| 72 | data->operating_mode = mode; | ||
| 73 | |||
| 74 | return ret; | ||
| 75 | } | ||
| 76 | |||
| 77 | static int tsl2550_set_power_state(struct i2c_client *client, int state) | ||
| 78 | { | ||
| 79 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 80 | int ret; | ||
| 81 | |||
| 82 | if (state == 0) | ||
| 83 | ret = i2c_smbus_write_byte(client, TSL2550_POWER_DOWN); | ||
| 84 | else { | ||
| 85 | ret = i2c_smbus_write_byte(client, TSL2550_POWER_UP); | ||
| 86 | |||
| 87 | /* On power up we should reset operating mode also... */ | ||
| 88 | tsl2550_set_operating_mode(client, data->operating_mode); | ||
| 89 | } | ||
| 90 | |||
| 91 | data->power_state = state; | ||
| 92 | |||
| 93 | return ret; | ||
| 94 | } | ||
| 95 | |||
| 96 | static int tsl2550_get_adc_value(struct i2c_client *client, u8 cmd) | ||
| 97 | { | ||
| 98 | int ret; | ||
| 99 | |||
| 100 | ret = i2c_smbus_read_byte_data(client, cmd); | ||
| 101 | if (ret < 0) | ||
| 102 | return ret; | ||
| 103 | if (!(ret & 0x80)) | ||
| 104 | return -EAGAIN; | ||
| 105 | return ret & 0x7f; /* remove the "valid" bit */ | ||
| 106 | } | ||
| 107 | |||
| 108 | /* | ||
| 109 | * LUX calculation | ||
| 110 | */ | ||
| 111 | |||
| 112 | #define TSL2550_MAX_LUX 1846 | ||
| 113 | |||
| 114 | static const u8 ratio_lut[] = { | ||
| 115 | 100, 100, 100, 100, 100, 100, 100, 100, | ||
| 116 | 100, 100, 100, 100, 100, 100, 99, 99, | ||
| 117 | 99, 99, 99, 99, 99, 99, 99, 99, | ||
| 118 | 99, 99, 99, 98, 98, 98, 98, 98, | ||
| 119 | 98, 98, 97, 97, 97, 97, 97, 96, | ||
| 120 | 96, 96, 96, 95, 95, 95, 94, 94, | ||
| 121 | 93, 93, 93, 92, 92, 91, 91, 90, | ||
| 122 | 89, 89, 88, 87, 87, 86, 85, 84, | ||
| 123 | 83, 82, 81, 80, 79, 78, 77, 75, | ||
| 124 | 74, 73, 71, 69, 68, 66, 64, 62, | ||
| 125 | 60, 58, 56, 54, 52, 49, 47, 44, | ||
| 126 | 42, 41, 40, 40, 39, 39, 38, 38, | ||
| 127 | 37, 37, 37, 36, 36, 36, 35, 35, | ||
| 128 | 35, 35, 34, 34, 34, 34, 33, 33, | ||
| 129 | 33, 33, 32, 32, 32, 32, 32, 31, | ||
| 130 | 31, 31, 31, 31, 30, 30, 30, 30, | ||
| 131 | 30, | ||
| 132 | }; | ||
| 133 | |||
| 134 | static const u16 count_lut[] = { | ||
| 135 | 0, 1, 2, 3, 4, 5, 6, 7, | ||
| 136 | 8, 9, 10, 11, 12, 13, 14, 15, | ||
| 137 | 16, 18, 20, 22, 24, 26, 28, 30, | ||
| 138 | 32, 34, 36, 38, 40, 42, 44, 46, | ||
| 139 | 49, 53, 57, 61, 65, 69, 73, 77, | ||
| 140 | 81, 85, 89, 93, 97, 101, 105, 109, | ||
| 141 | 115, 123, 131, 139, 147, 155, 163, 171, | ||
| 142 | 179, 187, 195, 203, 211, 219, 227, 235, | ||
| 143 | 247, 263, 279, 295, 311, 327, 343, 359, | ||
| 144 | 375, 391, 407, 423, 439, 455, 471, 487, | ||
| 145 | 511, 543, 575, 607, 639, 671, 703, 735, | ||
| 146 | 767, 799, 831, 863, 895, 927, 959, 991, | ||
| 147 | 1039, 1103, 1167, 1231, 1295, 1359, 1423, 1487, | ||
| 148 | 1551, 1615, 1679, 1743, 1807, 1871, 1935, 1999, | ||
| 149 | 2095, 2223, 2351, 2479, 2607, 2735, 2863, 2991, | ||
| 150 | 3119, 3247, 3375, 3503, 3631, 3759, 3887, 4015, | ||
| 151 | }; | ||
| 152 | |||
| 153 | /* | ||
| 154 | * This function is described into Taos TSL2550 Designer's Notebook | ||
| 155 | * pages 2, 3. | ||
| 156 | */ | ||
| 157 | static int tsl2550_calculate_lux(u8 ch0, u8 ch1) | ||
| 158 | { | ||
| 159 | unsigned int lux; | ||
| 160 | |||
| 161 | /* Look up count from channel values */ | ||
| 162 | u16 c0 = count_lut[ch0]; | ||
| 163 | u16 c1 = count_lut[ch1]; | ||
| 164 | |||
| 165 | /* | ||
| 166 | * Calculate ratio. | ||
| 167 | * Note: the "128" is a scaling factor | ||
| 168 | */ | ||
| 169 | u8 r = 128; | ||
| 170 | |||
| 171 | /* Avoid division by 0 and count 1 cannot be greater than count 0 */ | ||
| 172 | if (c1 <= c0) | ||
| 173 | if (c0) { | ||
| 174 | r = c1 * 128 / c0; | ||
| 175 | |||
| 176 | /* Calculate LUX */ | ||
| 177 | lux = ((c0 - c1) * ratio_lut[r]) / 256; | ||
| 178 | } else | ||
| 179 | lux = 0; | ||
| 180 | else | ||
| 181 | return -EAGAIN; | ||
| 182 | |||
| 183 | /* LUX range check */ | ||
| 184 | return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux; | ||
| 185 | } | ||
| 186 | |||
| 187 | /* | ||
| 188 | * SysFS support | ||
| 189 | */ | ||
| 190 | |||
| 191 | static ssize_t tsl2550_show_power_state(struct device *dev, | ||
| 192 | struct device_attribute *attr, char *buf) | ||
| 193 | { | ||
| 194 | struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
| 195 | |||
| 196 | return sprintf(buf, "%u\n", data->power_state); | ||
| 197 | } | ||
| 198 | |||
| 199 | static ssize_t tsl2550_store_power_state(struct device *dev, | ||
| 200 | struct device_attribute *attr, const char *buf, size_t count) | ||
| 201 | { | ||
| 202 | struct i2c_client *client = to_i2c_client(dev); | ||
| 203 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 204 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
| 205 | int ret; | ||
| 206 | |||
| 207 | if (val < 0 || val > 1) | ||
| 208 | return -EINVAL; | ||
| 209 | |||
| 210 | mutex_lock(&data->update_lock); | ||
| 211 | ret = tsl2550_set_power_state(client, val); | ||
| 212 | mutex_unlock(&data->update_lock); | ||
| 213 | |||
| 214 | if (ret < 0) | ||
| 215 | return ret; | ||
| 216 | |||
| 217 | return count; | ||
| 218 | } | ||
| 219 | |||
| 220 | static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO, | ||
| 221 | tsl2550_show_power_state, tsl2550_store_power_state); | ||
| 222 | |||
| 223 | static ssize_t tsl2550_show_operating_mode(struct device *dev, | ||
| 224 | struct device_attribute *attr, char *buf) | ||
| 225 | { | ||
| 226 | struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
| 227 | |||
| 228 | return sprintf(buf, "%u\n", data->operating_mode); | ||
| 229 | } | ||
| 230 | |||
| 231 | static ssize_t tsl2550_store_operating_mode(struct device *dev, | ||
| 232 | struct device_attribute *attr, const char *buf, size_t count) | ||
| 233 | { | ||
| 234 | struct i2c_client *client = to_i2c_client(dev); | ||
| 235 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 236 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
| 237 | int ret; | ||
| 238 | |||
| 239 | if (val < 0 || val > 1) | ||
| 240 | return -EINVAL; | ||
| 241 | |||
| 242 | if (data->power_state == 0) | ||
| 243 | return -EBUSY; | ||
| 244 | |||
| 245 | mutex_lock(&data->update_lock); | ||
| 246 | ret = tsl2550_set_operating_mode(client, val); | ||
| 247 | mutex_unlock(&data->update_lock); | ||
| 248 | |||
| 249 | if (ret < 0) | ||
| 250 | return ret; | ||
| 251 | |||
| 252 | return count; | ||
| 253 | } | ||
| 254 | |||
| 255 | static DEVICE_ATTR(operating_mode, S_IWUSR | S_IRUGO, | ||
| 256 | tsl2550_show_operating_mode, tsl2550_store_operating_mode); | ||
| 257 | |||
| 258 | static ssize_t __tsl2550_show_lux(struct i2c_client *client, char *buf) | ||
| 259 | { | ||
| 260 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 261 | u8 ch0, ch1; | ||
| 262 | int ret; | ||
| 263 | |||
| 264 | ret = tsl2550_get_adc_value(client, TSL2550_READ_ADC0); | ||
| 265 | if (ret < 0) | ||
| 266 | return ret; | ||
| 267 | ch0 = ret; | ||
| 268 | |||
| 269 | ret = tsl2550_get_adc_value(client, TSL2550_READ_ADC1); | ||
| 270 | if (ret < 0) | ||
| 271 | return ret; | ||
| 272 | ch1 = ret; | ||
| 273 | |||
| 274 | /* Do the job */ | ||
| 275 | ret = tsl2550_calculate_lux(ch0, ch1); | ||
| 276 | if (ret < 0) | ||
| 277 | return ret; | ||
| 278 | if (data->operating_mode == 1) | ||
| 279 | ret *= 5; | ||
| 280 | |||
| 281 | return sprintf(buf, "%d\n", ret); | ||
| 282 | } | ||
| 283 | |||
| 284 | static ssize_t tsl2550_show_lux1_input(struct device *dev, | ||
| 285 | struct device_attribute *attr, char *buf) | ||
| 286 | { | ||
| 287 | struct i2c_client *client = to_i2c_client(dev); | ||
| 288 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 289 | int ret; | ||
| 290 | |||
| 291 | /* No LUX data if not operational */ | ||
| 292 | if (!data->power_state) | ||
| 293 | return -EBUSY; | ||
| 294 | |||
| 295 | mutex_lock(&data->update_lock); | ||
| 296 | ret = __tsl2550_show_lux(client, buf); | ||
| 297 | mutex_unlock(&data->update_lock); | ||
| 298 | |||
| 299 | return ret; | ||
| 300 | } | ||
| 301 | |||
| 302 | static DEVICE_ATTR(lux1_input, S_IRUGO, | ||
| 303 | tsl2550_show_lux1_input, NULL); | ||
| 304 | |||
| 305 | static struct attribute *tsl2550_attributes[] = { | ||
| 306 | &dev_attr_power_state.attr, | ||
| 307 | &dev_attr_operating_mode.attr, | ||
| 308 | &dev_attr_lux1_input.attr, | ||
| 309 | NULL | ||
| 310 | }; | ||
| 311 | |||
| 312 | static const struct attribute_group tsl2550_attr_group = { | ||
| 313 | .attrs = tsl2550_attributes, | ||
| 314 | }; | ||
| 315 | |||
| 316 | /* | ||
| 317 | * Initialization function | ||
| 318 | */ | ||
| 319 | |||
| 320 | static int tsl2550_init_client(struct i2c_client *client) | ||
| 321 | { | ||
| 322 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
| 323 | int err; | ||
| 324 | |||
| 325 | /* | ||
| 326 | * Probe the chip. To do so we try to power up the device and then to | ||
| 327 | * read back the 0x03 code | ||
| 328 | */ | ||
| 329 | err = i2c_smbus_read_byte_data(client, TSL2550_POWER_UP); | ||
| 330 | if (err < 0) | ||
| 331 | return err; | ||
| 332 | if (err != TSL2550_POWER_UP) | ||
| 333 | return -ENODEV; | ||
| 334 | data->power_state = 1; | ||
| 335 | |||
| 336 | /* Set the default operating mode */ | ||
| 337 | err = i2c_smbus_write_byte(client, | ||
| 338 | TSL2550_MODE_RANGE[data->operating_mode]); | ||
| 339 | if (err < 0) | ||
| 340 | return err; | ||
| 341 | |||
| 342 | return 0; | ||
| 343 | } | ||
| 344 | |||
| 345 | /* | ||
| 346 | * I2C init/probing/exit functions | ||
| 347 | */ | ||
| 348 | |||
| 349 | static struct i2c_driver tsl2550_driver; | ||
| 350 | static int __devinit tsl2550_probe(struct i2c_client *client, | ||
| 351 | const struct i2c_device_id *id) | ||
| 352 | { | ||
| 353 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
| 354 | struct tsl2550_data *data; | ||
| 355 | int *opmode, err = 0; | ||
| 356 | |||
| 357 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE | ||
| 358 | | I2C_FUNC_SMBUS_READ_BYTE_DATA)) { | ||
| 359 | err = -EIO; | ||
| 360 | goto exit; | ||
| 361 | } | ||
| 362 | |||
| 363 | data = kzalloc(sizeof(struct tsl2550_data), GFP_KERNEL); | ||
| 364 | if (!data) { | ||
| 365 | err = -ENOMEM; | ||
| 366 | goto exit; | ||
| 367 | } | ||
| 368 | data->client = client; | ||
| 369 | i2c_set_clientdata(client, data); | ||
| 370 | |||
| 371 | /* Check platform data */ | ||
| 372 | opmode = client->dev.platform_data; | ||
| 373 | if (opmode) { | ||
| 374 | if (*opmode < 0 || *opmode > 1) { | ||
| 375 | dev_err(&client->dev, "invalid operating_mode (%d)\n", | ||
| 376 | *opmode); | ||
| 377 | err = -EINVAL; | ||
| 378 | goto exit_kfree; | ||
| 379 | } | ||
| 380 | data->operating_mode = *opmode; | ||
| 381 | } else | ||
| 382 | data->operating_mode = 0; /* default mode is standard */ | ||
| 383 | dev_info(&client->dev, "%s operating mode\n", | ||
| 384 | data->operating_mode ? "extended" : "standard"); | ||
| 385 | |||
| 386 | mutex_init(&data->update_lock); | ||
| 387 | |||
| 388 | /* Initialize the TSL2550 chip */ | ||
| 389 | err = tsl2550_init_client(client); | ||
| 390 | if (err) | ||
| 391 | goto exit_kfree; | ||
| 392 | |||
| 393 | /* Register sysfs hooks */ | ||
| 394 | err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group); | ||
| 395 | if (err) | ||
| 396 | goto exit_kfree; | ||
| 397 | |||
| 398 | dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION); | ||
| 399 | |||
| 400 | return 0; | ||
| 401 | |||
| 402 | exit_kfree: | ||
| 403 | kfree(data); | ||
| 404 | exit: | ||
| 405 | return err; | ||
| 406 | } | ||
| 407 | |||
| 408 | static int __devexit tsl2550_remove(struct i2c_client *client) | ||
| 409 | { | ||
| 410 | sysfs_remove_group(&client->dev.kobj, &tsl2550_attr_group); | ||
| 411 | |||
| 412 | /* Power down the device */ | ||
| 413 | tsl2550_set_power_state(client, 0); | ||
| 414 | |||
| 415 | kfree(i2c_get_clientdata(client)); | ||
| 416 | |||
| 417 | return 0; | ||
| 418 | } | ||
| 419 | |||
| 420 | #ifdef CONFIG_PM | ||
| 421 | |||
| 422 | static int tsl2550_suspend(struct i2c_client *client, pm_message_t mesg) | ||
| 423 | { | ||
| 424 | return tsl2550_set_power_state(client, 0); | ||
| 425 | } | ||
| 426 | |||
| 427 | static int tsl2550_resume(struct i2c_client *client) | ||
| 428 | { | ||
| 429 | return tsl2550_set_power_state(client, 1); | ||
| 430 | } | ||
| 431 | |||
| 432 | #else | ||
| 433 | |||
| 434 | #define tsl2550_suspend NULL | ||
| 435 | #define tsl2550_resume NULL | ||
| 436 | |||
| 437 | #endif /* CONFIG_PM */ | ||
| 438 | |||
| 439 | static const struct i2c_device_id tsl2550_id[] = { | ||
| 440 | { "tsl2550", 0 }, | ||
| 441 | { } | ||
| 442 | }; | ||
| 443 | MODULE_DEVICE_TABLE(i2c, tsl2550_id); | ||
| 444 | |||
| 445 | static struct i2c_driver tsl2550_driver = { | ||
| 446 | .driver = { | ||
| 447 | .name = TSL2550_DRV_NAME, | ||
| 448 | .owner = THIS_MODULE, | ||
| 449 | }, | ||
| 450 | .suspend = tsl2550_suspend, | ||
| 451 | .resume = tsl2550_resume, | ||
| 452 | .probe = tsl2550_probe, | ||
| 453 | .remove = __devexit_p(tsl2550_remove), | ||
| 454 | .id_table = tsl2550_id, | ||
| 455 | }; | ||
| 456 | |||
| 457 | static int __init tsl2550_init(void) | ||
| 458 | { | ||
| 459 | return i2c_add_driver(&tsl2550_driver); | ||
| 460 | } | ||
| 461 | |||
| 462 | static void __exit tsl2550_exit(void) | ||
| 463 | { | ||
| 464 | i2c_del_driver(&tsl2550_driver); | ||
| 465 | } | ||
| 466 | |||
| 467 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
| 468 | MODULE_DESCRIPTION("TSL2550 ambient light sensor driver"); | ||
| 469 | MODULE_LICENSE("GPL"); | ||
| 470 | MODULE_VERSION(DRIVER_VERSION); | ||
| 471 | |||
| 472 | module_init(tsl2550_init); | ||
| 473 | module_exit(tsl2550_exit); | ||
