Title: [9428] trunk/drivers/staging/iio/adc: staging: iio: Remove temperature sensor driver already supported in hwmon
Revision
9428
Author
hennerich
Date
2010-10-26 09:36:09 -0400 (Tue, 26 Oct 2010)

Log Message

staging: iio: Remove temperature sensor driver already supported in hwmon

Support for these sensors already exist in HWMON.
If functionality supported by these drivers is missing,
it should be added to HWMON, instead of duplicating drivers.

Modified Paths

Removed Paths

Diff

Modified: trunk/drivers/staging/iio/adc/Kconfig (9427 => 9428)


--- trunk/drivers/staging/iio/adc/Kconfig	2010-10-26 11:32:25 UTC (rev 9427)
+++ trunk/drivers/staging/iio/adc/Kconfig	2010-10-26 13:36:09 UTC (rev 9428)
@@ -62,13 +62,6 @@
 	  Say yes here to build support for Analog Devices AD7314
 	  temperature sensors.
 
-config AD7414
-	tristate "Analog Devices AD7414 and AD7415 temperature sensor driver"
-	depends on I2C
-	help
-	  Say yes here to build support for Analog Devices AD7414 and AD7415
-	  temperature sensors.
-
 config AD7416
 	tristate "Analog Devices AD7416/7/8 temperature sensor and ADC driver"
 	depends on I2C
@@ -121,13 +114,6 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad7745.
 
-config AD7816
-	tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver"
-	depends on SPI
-	help
-	  Say yes here to build support for Analog Devices AD7816/7/8
-	  temperature sensors and ADC.
-
 config ADT75
 	tristate "Analog Devices ADT75 temperature sensor driver"
 	depends on I2C
@@ -135,13 +121,6 @@
 	  Say yes here to build support for Analog Devices ADT75
 	  temperature sensors.
 
-config ADT7408
-	tristate "Analog Devices ADT7408 temperature sensor driver"
-	depends on I2C
-	help
-	  Say yes here to build support for Analog Devices ADT7408
-	  temperature sensors.
-
 config ADT7410
 	tristate "Analog Devices ADT7410 temperature sensor driver"
 	depends on I2C

Modified: trunk/drivers/staging/iio/adc/Makefile (9427 => 9428)


--- trunk/drivers/staging/iio/adc/Makefile	2010-10-26 11:32:25 UTC (rev 9427)
+++ trunk/drivers/staging/iio/adc/Makefile	2010-10-26 13:36:09 UTC (rev 9428)
@@ -20,12 +20,9 @@
 obj-$(CONFIG_AD7291) += ad7291.o
 obj-$(CONFIG_AD7298) += ad7298.o
 obj-$(CONFIG_AD7314) += ad7314.o
-obj-$(CONFIG_AD7414) += ad7414.o
-obj-$(CONFIG_AD7416) += ad7416.o
 obj-$(CONFIG_AD7476) += ad7476.o
 obj-$(CONFIG_AD7745) += ad7745.o
 obj-$(CONFIG_AD7816) += ad7816.o
 obj-$(CONFIG_ADT75) += adt75.o
 obj-$(CONFIG_ADT7310) += adt7310.o
-obj-$(CONFIG_ADT7408) += adt7408.o
 obj-$(CONFIG_ADT7410) += adt7410.o

Deleted: trunk/drivers/staging/iio/adc/ad7414.c (9427 => 9428)


--- trunk/drivers/staging/iio/adc/ad7414.c	2010-10-26 11:32:25 UTC (rev 9427)
+++ trunk/drivers/staging/iio/adc/ad7414.c	2010-10-26 13:36:09 UTC (rev 9428)
@@ -1,570 +0,0 @@
-/*
- * AD7414 digital temperature sensor driver supporting AD7414 and AD7415
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/i2c.h>
-#include <linux/rtc.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-
-/*
- * AD7414 registers definition
- */
-
-#define AD7414_TEMPERATURE		0
-#define AD7414_CONFIG			1
-#define AD7414_TEMPERATURE_HIGH		2
-#define AD7414_TEMPERATURE_LOW		3
-
-/*
- * AD7414 config bits
- */
-#define AD7414_TEST_MODE	0x3
-#define AD7414_ONE_SHOT		0x4
-#define AD7414_ALERT_RESET	0x8
-#define AD7414_ALERT_POLARITY	0x10
-#define AD7414_ALERT_EN		0x20
-#define AD7414_FLTR		0x40
-#define AD7414_PD		0x80
-
-/*
- * AD7414 masks
- */
-#define AD7414_TEMP_SIGN	0x200
-#define AD7414_TEMP_MASK	0xFFC0
-#define AD7414_TEMP_OFFSET	6
-#define AD7414_ALERT_FLAG	0x20
-#define AD7414_T_SIGN		0x80
-#define AD7414_T_HIGH_FLAG	0x10
-#define AD7414_T_LOW_FLAG	0x8
-
-
-/*
- * struct ad7414_chip_info - chip specifc information
- */
-
-struct ad7414_chip_info {
-	const char *name;
-	struct i2c_client *client;
-	struct iio_dev *indio_dev;
-	struct work_struct thresh_work;
-	s64 last_timestamp;
-	u8  mode;
-};
-
-/*
- * ad7414 register access by I2C
- */
-
-static int ad7414_i2c_read(struct ad7414_chip_info *chip, u8 reg, u8 *data)
-{
-	struct i2c_client *client = chip->client;
-	int ret = 0, len;
-
-	ret = i2c_smbus_write_byte(client, reg);
-	if (ret < 0) {
-		dev_err(&client->dev, "I2C read register address error\n");
-		return ret;
-	}
-
-	if (reg == AD7414_TEMPERATURE)
-		len = 2;
-	else
-		len = 1;
-
-	ret = i2c_master_recv(client, data, len);
-	if (ret < 0) {
-		dev_err(&client->dev, "I2C read error\n");
-		return ret;
-	}
-
-	return ret;
-}
-
-static int ad7414_i2c_write(struct ad7414_chip_info *chip, u8 reg, u8 data)
-{
-	struct i2c_client *client = chip->client;
-	int ret = 0;
-
-	ret = i2c_smbus_write_byte_data(client, reg, data);
-	if (ret < 0)
-		dev_err(&client->dev, "I2C write error\n");
-
-	return ret;
-}
-
-static ssize_t ad7414_show_mode(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-
-	if (chip->mode)
-		return sprintf(buf, "power-save\n");
-	else
-		return sprintf(buf, "full\n");
-}
-
-static ssize_t ad7414_store_mode(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	u8 config;
-	int ret;
-
-	ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-	if (ret)
-		return -EIO;
-
-	if (strcmp(buf, "full")) {
-		chip->mode = 0;
-		config &= ~AD7414_PD;
-	} else {
-		chip->mode = 1;
-		config |= AD7414_PD;
-	}
-
-	ret = ad7414_i2c_write(chip, AD7414_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	return ret;
-}
-
-static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
-		ad7414_show_mode,
-		ad7414_store_mode,
-		0);
-
-static ssize_t ad7414_show_available_modes(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return sprintf(buf, "full\npower-save\n");
-}
-
-static IIO_DEVICE_ATTR(available_modes, S_IRUGO, ad7414_show_available_modes, NULL, 0);
-
-static ssize_t ad7414_show_temperature(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	u8 config;
-	u16 data;
-	char sign = ' ';
-	int ret;
-
-	if (chip->mode) {
-		ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-		if (ret)
-			return -EIO;
-		ret = ad7414_i2c_write(chip, AD7414_CONFIG,
-				config | AD7414_ONE_SHOT);
-		if (ret)
-			return -EIO;
-	}
-
-	ret = ad7414_i2c_read(chip, AD7414_TEMPERATURE, (u8 *)&data);
-	if (ret)
-		return -EIO;
-
-	data = "" >> AD7414_TEMP_OFFSET;
-	if (data & AD7414_TEMP_SIGN) {
-		data = "" << 1) - data;
-		sign = '-';
-	}
-
-	return sprintf(buf, "%c%d.%.2d\n", sign, (data >> 2), (data & 3) * 25);
-}
-
-static IIO_DEVICE_ATTR(temperature, S_IRUGO, ad7414_show_temperature, NULL, 0);
-
-static ssize_t ad7414_show_name(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7414_show_name, NULL, 0);
-
-static struct attribute *ad7414_attributes[] = {
-	&iio_dev_attr_available_modes.dev_attr.attr,
-	&iio_dev_attr_mode.dev_attr.attr,
-	&iio_dev_attr_temperature.dev_attr.attr,
-	&iio_dev_attr_name.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ad7414_attribute_group = {
-	.attrs = ad7414_attributes,
-};
-
-/*
- * temperature bound events
- */
-
-#define IIO_EVENT_CODE_AD7414_T_HIGH    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_AD7414_T_LOW     IIO_BUFFER_EVENT_CODE(1)
-
-static void ad7414_interrupt_bh(struct work_struct *work_s)
-{
-	struct ad7414_chip_info *chip =
-		container_of(work_s, struct ad7414_chip_info, thresh_work);
-	u16 status;
-	u8 config;
-	int ret;
-
-	/* retrive ALART status */
-	ret = ad7414_i2c_read(chip, AD7414_TEMPERATURE, (u8 *)&status);
-	if (ret)
-		return;
-	status = swab16(status);
-
-	/* clear ALART pin in chip configuration register */
-	ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-	if (ret)
-		return;
-	ret = ad7414_i2c_write(chip, AD7414_CONFIG,
-			config | AD7414_ALERT_RESET);
-	if (ret)
-		return;
-
-	enable_irq(chip->client->irq);
-
-	if (status & AD7414_T_HIGH_FLAG)
-		iio_push_event(chip->indio_dev, 0,
-				IIO_EVENT_CODE_AD7414_T_HIGH,
-				chip->last_timestamp);
-	else if (status & AD7414_T_LOW_FLAG)
-		iio_push_event(chip->indio_dev, 0,
-				IIO_EVENT_CODE_AD7414_T_LOW,
-				chip->last_timestamp);
-}
-
-static int ad7414_interrupt(struct iio_dev *dev_info,
-		int index,
-		s64 timestamp,
-		int no_test)
-{
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-
-	chip->last_timestamp = timestamp;
-	schedule_work(&chip->thresh_work);
-
-	return 0;
-}
-
-IIO_EVENT_SH(ad7414, &ad7414_interrupt);
-
-static ssize_t ad7414_show_enabled(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	u8 config;
-	int ret;
-
-	/* retrive ALART status */
-	ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "%d\n", !!(config & AD7414_ALERT_EN));
-}
-
-static ssize_t ad7414_set_enabled(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	unsigned long data;
-	u8 config;
-	int ret;
-
-	ret = strict_strtoul(buf, 10, &data);
-	if (ret)
-		return -EINVAL;
-
-	/* retrive ALART status */
-	ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-	if (ret)
-		return -EIO;
-
-	if (data)
-		ret = ad7414_i2c_write(chip, AD7414_CONFIG,
-			config & ~AD7414_ALERT_EN);
-	else
-		ret = ad7414_i2c_write(chip, AD7414_CONFIG,
-			config | AD7414_ALERT_EN);
-	if (ret)
-		return -EIO;
-
-	return ret;
-}
-
-static inline ssize_t ad7414_show_temperature_bound(struct device *dev,
-		struct device_attribute *attr,
-		u8 bound_reg,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	s8 data;
-	int ret;
-
-	ret = ad7414_i2c_read(chip, bound_reg, &data);
-	if (ret)
-		return -EIO;
-
-	if (data & AD7414_T_SIGN)
-		data = "" - AD7414_T_SIGN;
-
-	return sprintf(buf, "%d\n", data);
-}
-
-static inline ssize_t ad7414_set_temperature_bound(struct device *dev,
-		struct device_attribute *attr,
-		u8 bound_reg,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct ad7414_chip_info *chip = dev_info->dev_data;
-	long data;
-	s8 value;
-	int ret;
-
-	ret = strict_strtol(buf, 10, &data);
-
-	if (ret || data > 127 || data < -128)
-		return -EINVAL;
-
-	value = (s8)data;
-	if (value < 0)
-		value = (AD7414_T_SIGN + value) | AD7414_T_SIGN;
-
-	ret = ad7414_i2c_write(chip, bound_reg, value);
-	if (ret)
-		return -EIO;
-
-	return ret;
-}
-
-static ssize_t ad7414_show_temperature_high(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return ad7414_show_temperature_bound(dev, attr,
-			AD7414_TEMPERATURE_HIGH, buf);
-}
-
-static inline ssize_t ad7414_set_temperature_high(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	return ad7414_set_temperature_bound(dev, attr,
-			AD7414_TEMPERATURE_HIGH, buf, len);
-}
-
-static ssize_t ad7414_show_temperature_low(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return ad7414_show_temperature_bound(dev, attr,
-			AD7414_TEMPERATURE_LOW, buf);
-}
-
-static inline ssize_t ad7414_set_temperature_low(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	return ad7414_set_temperature_bound(dev, attr,
-			AD7414_TEMPERATURE_LOW, buf, len);
-}
-
-IIO_EVENT_ATTR_SH(t_bound_enabled, iio_event_ad7414,
-		ad7414_show_enabled, ad7414_set_enabled, 0);
-IIO_EVENT_ATTR_SH(temperature_high, iio_event_ad7414,
-		ad7414_show_temperature_high, ad7414_set_temperature_high, 0);
-IIO_EVENT_ATTR_SH(temperature_low, iio_event_ad7414,
-		ad7414_show_temperature_low, ad7414_set_temperature_low, 0);
-
-static struct attribute *ad7414_event_attributes[] = {
-	&iio_event_attr_t_bound_enabled.dev_attr.attr,
-	&iio_event_attr_temperature_high.dev_attr.attr,
-	&iio_event_attr_temperature_low.dev_attr.attr,
-	NULL,
-};
-
-static struct attribute_group ad7414_event_attribute_group = {
-	.attrs = ad7414_event_attributes,
-};
-
-/*
- * device probe and remove
- */
-
-static int __devinit ad7414_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	struct ad7414_chip_info *chip;
-	int ret = 0;
-	u8 config;
-
-	chip = kzalloc(sizeof(struct ad7414_chip_info), GFP_KERNEL);
-
-	if (chip == NULL)
-		return -ENOMEM;
-
-	/* this is only used for device removal purposes */
-	i2c_set_clientdata(client, chip);
-
-	chip->client = client;
-	chip->name = id->name;
-
-	chip->indio_dev = iio_allocate_device();
-	if (chip->indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_free_chip;
-	}
-
-	chip->indio_dev->dev.parent = &client->dev;
-	chip->indio_dev->attrs = &ad7414_attribute_group;
-	if (strcmp(id->name, "ad7414") == 0)
-		chip->indio_dev->event_attrs = &ad7414_event_attribute_group;
-	else
-		client->irq = 0;
-	chip->indio_dev->dev_data = (void *)chip;
-	chip->indio_dev->driver_module = THIS_MODULE;
-	chip->indio_dev->num_interrupt_lines = 1;
-	chip->indio_dev->modes = INDIO_DIRECT_MODE;
-
-	ret = iio_device_register(chip->indio_dev);
-	if (ret)
-		goto error_free_dev;
-
-	if (client->irq) {
-		ret = iio_register_interrupt_line(client->irq,
-				chip->indio_dev,
-				0,
-				IRQF_TRIGGER_LOW,
-				chip->name);
-		if (ret)
-			goto error_unreg_dev;
-
-		/*
-		 * The event handler list element refer to iio_event_ad7414.
-		 * All event attributes bind to the same event handler.
-		 * So, only register event handler once.
-		 */
-		iio_add_event_to_list(&iio_event_ad7414,
-				&chip->indio_dev->interrupts[0]->ev_list);
-
-		INIT_WORK(&chip->thresh_work, ad7414_interrupt_bh);
-
-		ret = ad7414_i2c_read(chip, AD7414_CONFIG, &config);
-		if (ret) {
-			ret = -EIO;
-			goto error_unreg_irq;
-		}
-
-		/* set irq polarity low level */
-		ret = ad7414_i2c_write(chip, AD7414_CONFIG,
-			config & ~AD7414_ALERT_POLARITY);
-		if (ret) {
-			ret = -EIO;
-			goto error_unreg_irq;
-		}
-	}
-
-	dev_info(&client->dev, "%s temperature sensor registered.\n",
-			 id->name);
-
-	return 0;
-error_unreg_irq:
-	iio_unregister_interrupt_line(chip->indio_dev, 0);
-error_unreg_dev:
-	iio_device_unregister(chip->indio_dev);
-error_free_dev:
-	iio_free_device(chip->indio_dev);
-error_free_chip:
-	kfree(chip);
-
-	return ret;
-}
-
-static int __devexit ad7414_remove(struct i2c_client *client)
-{
-	struct ad7414_chip_info *chip = i2c_get_clientdata(client);
-	struct iio_dev *indio_dev = chip->indio_dev;
-
-	if (client->irq)
-		iio_unregister_interrupt_line(indio_dev, 0);
-	iio_device_unregister(indio_dev);
-	iio_free_device(chip->indio_dev);
-	kfree(chip);
-
-	return 0;
-}
-
-static const struct i2c_device_id ad7414_id[] = {
-	{ "ad7414", 0 },
-	{ "ad7415", 0 },
-	{}
-};
-
-MODULE_DEVICE_TABLE(i2c, ad7414_id);
-
-static struct i2c_driver ad7414_driver = {
-	.driver = {
-		.name = "ad7414",
-	},
-	.probe = ad7414_probe,
-	.remove = __devexit_p(ad7414_remove),
-	.id_table = ad7414_id,
-};
-
-static __init int ad7414_init(void)
-{
-	return i2c_add_driver(&ad7414_driver);
-}
-
-static __exit void ad7414_exit(void)
-{
-	i2c_del_driver(&ad7414_driver);
-}
-
-MODULE_AUTHOR("Sonic Zhang <[email protected]>");
-MODULE_DESCRIPTION("Analog Devices AD7414 and AD7415 digital"
-			" temperature sensor driver");
-MODULE_LICENSE("GPL v2");
-
-module_init(ad7414_init);
-module_exit(ad7414_exit);

Deleted: trunk/drivers/staging/iio/adc/adt7408.c (9427 => 9428)


--- trunk/drivers/staging/iio/adc/adt7408.c	2010-10-26 11:32:25 UTC (rev 9427)
+++ trunk/drivers/staging/iio/adc/adt7408.c	2010-10-26 13:36:09 UTC (rev 9428)
@@ -1,1004 +0,0 @@
-/*
- * ADT7408 digital temperature sensor driver supporting ADT7408
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/i2c.h>
-#include <linux/rtc.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-
-/*
- * ADT7408 registers definition
- */
-
-#define ADT7408_CAPABILITY		0
-#define ADT7408_CONFIG			1
-#define ADT7408_T_ALARM_HIGH		2
-#define ADT7408_T_ALARM_LOW		3
-#define ADT7408_T_CRIT			4
-#define ADT7408_TEMPERATURE		5
-#define ADT7408_MANUFACTURER_ID		6
-#define ADT7408_DEVICE_ID		7
-
-/*
- * ADT7408 capability
- */
-#define ADT7408_CAP_ALARM_CRIT_TRIPS	0x1
-#define ADT7408_CAP_HIGH_PRECISION	0x2
-#define ADT7408_CAP_WIDER_RANGE		0x4
-#define ADT7408_CAP_T_RESOLUTION_MASK	0x18
-#define ADT7408_CAP_T_RESOLUTION_HIGH	0x18
-#define ADT7408_CAP_T_RESOLUTION_LOW	0x8
-
-/*
- * ADT7408 config
- */
-#define ADT7408_EVENT_MODE		0x1
-#define ADT7408_EVENT_POLARITY		0x2
-#define ADT7408_EVENT_CRIT_ONLY		0x4
-#define ADT7408_EVENT_ENABLE		0x8
-#define ADT7408_EVENT_STATUS		0x10
-#define ADT7408_EVENT_CLEAR		0x20
-#define ADT7408_EVENT_ALARM_LOCK	0x40
-#define ADT7408_EVENT_CRIT_LOCK		0x80
-#define ADT7408_PD			0x100
-#define ADT7408_HISTERESIS_MASK		0x600
-#define ADT7408_HISTERESIS_1_5		0x200
-#define ADT7408_HISTERESIS_3		0x400
-#define ADT7408_HISTERESIS_6		0x600
-
-/*
- * ADT7408 masks
- */
-#define ADT7408_BOUND_VALUE_SIGN		0x400
-#define ADT7408_BOUND_VALUE_OFFSET		2
-#define ADT7408_BOUND_VALUE_FLOAT_OFFSET	2
-#define ADT7408_BOUND_VALUE_FLOAT_MASK		0x3
-#define ADT7408_T_VALUE_SIGN			0x1000
-#define ADT7408_T_VALUE_FLOAT_OFFSET		4
-#define ADT7408_T_VALUE_FLOAT_MASK		0xF
-
-/*
- * ADT7408 event source
- */
-#define ADT7408_T_BELLOW_ALARM			0x2000
-#define ADT7408_T_ABOVE_ALARM			0x4000
-#define ADT7408_T_ABOVE_CRIT			0x8000
-
-
-/*
- * struct adt7408_chip_info - chip specifc information
- */
-
-struct adt7408_chip_info {
-	const char *name;
-	struct i2c_client *client;
-	struct iio_dev *indio_dev;
-	struct work_struct thresh_work;
-	s64 last_timestamp;
-	u16 config;
-};
-
-/*
- * adt7408 register access by I2C
- */
-
-static int adt7408_i2c_read(struct adt7408_chip_info *chip, u8 reg, u16 *data)
-{
-	struct i2c_client *client = chip->client;
-	int ret = 0;
-
-	ret = i2c_smbus_read_word_data(client, reg);
-	if (ret < 0) {
-		dev_err(&client->dev, "I2C read error\n");
-		return ret;
-	}
-
-	*data = ""
-
-	return 0;
-}
-
-static int adt7408_i2c_write(struct adt7408_chip_info *chip, u8 reg, u16 data)
-{
-	struct i2c_client *client = chip->client;
-	int ret = 0;
-
-	ret = i2c_smbus_write_word_data(client, reg, swab16(data));
-	if (ret < 0)
-		dev_err(&client->dev, "I2C write error\n");
-
-	return ret;
-}
-
-static int adt7408_is_event_locked(struct adt7408_chip_info *chip)
-{
-	return chip->config & (ADT7408_EVENT_ALARM_LOCK | ADT7408_EVENT_ALARM_LOCK);
-}
-
-static ssize_t adt7408_show_mode(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-
-	if (chip->config & ADT7408_PD)
-		return sprintf(buf, "power-save\n");
-	else
-		return sprintf(buf, "full\n");
-}
-
-static ssize_t adt7408_store_mode(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 config;
-	int ret;
-
-	if (adt7408_is_event_locked(chip)) {
-		dev_err(dev, "Warning: Events are locked.\n");
-		return -EIO;
-	}
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config & (~ADT7408_PD);
-	if (!strcmp(buf, "full"))
-		config |= ADT7408_PD;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
-		adt7408_show_mode,
-		adt7408_store_mode,
-		0);
-
-static ssize_t adt7408_show_available_modes(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return sprintf(buf, "full\npower-down\n");
-}
-
-static IIO_DEVICE_ATTR(available_modes, S_IRUGO, adt7408_show_available_modes, NULL, 0);
-
-static ssize_t adt7408_show_capability(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 capability;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CAPABILITY, &capability);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "0x%x\n", capability);
-}
-
-static IIO_DEVICE_ATTR(capability, S_IRUGO | S_IWUSR,
-		adt7408_show_capability,
-		NULL,
-		0);
-
-static ssize_t adt7408_show_manufactory_id(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 id;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_MANUFACTURER_ID, &id);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "0x%x\n", id);
-}
-
-static IIO_DEVICE_ATTR(manufactory_id, S_IRUGO | S_IWUSR,
-		adt7408_show_manufactory_id,
-		NULL,
-		0);
-
-static ssize_t adt7408_show_device_id(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 id;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_MANUFACTURER_ID, &id);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "0x%x\n", id);
-}
-
-static IIO_DEVICE_ATTR(device_id, S_IRUGO | S_IWUSR,
-		adt7408_show_device_id,
-		NULL,
-		0);
-
-static ssize_t adt7408_show_value(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 data;
-	char sign = ' ';
-	int ret;
-
-	if (chip->config & ADT7408_PD) {
-		dev_err(dev, "Can't read value in power-down mode.\n");
-		return -EIO;
-	}
-
-	ret = adt7408_i2c_read(chip, ADT7408_TEMPERATURE, &data);
-	if (ret)
-		return -EIO;
-
-	if (data & ADT7408_T_VALUE_SIGN) {
-		/* convert supplement to positive value */
-		data = "" << 1) - data;
-		sign = '-';
-	}
-
-	return sprintf(buf, "%c%d.%.4d\n", sign,
-		(data >> ADT7408_T_VALUE_FLOAT_OFFSET),
-		(data & ADT7408_T_VALUE_FLOAT_MASK) * 625);
-}
-
-static IIO_DEVICE_ATTR(value, S_IRUGO, adt7408_show_value, NULL, 0);
-
-static ssize_t adt7408_show_name(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, adt7408_show_name, NULL, 0);
-
-static struct attribute *adt7408_attributes[] = {
-	&iio_dev_attr_available_modes.dev_attr.attr,
-	&iio_dev_attr_mode.dev_attr.attr,
-	&iio_dev_attr_capability.dev_attr.attr,
-	&iio_dev_attr_device_id.dev_attr.attr,
-	&iio_dev_attr_manufactory_id.dev_attr.attr,
-	&iio_dev_attr_value.dev_attr.attr,
-	&iio_dev_attr_name.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group adt7408_attribute_group = {
-	.attrs = adt7408_attributes,
-};
-
-/*
- * temperature bound events
- */
-
-#define IIO_EVENT_CODE_ADT7408_ABOVE_ALARM    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_ADT7408_BELLOW_ALARM   IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_ADT7408_ABOVE_CRIT     IIO_BUFFER_EVENT_CODE(2)
-
-static void adt7408_interrupt_bh(struct work_struct *work_s)
-{
-	struct adt7408_chip_info *chip =
-		container_of(work_s, struct adt7408_chip_info, thresh_work);
-	u16 config;
-	u16 data;
-
-	if (adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config))
-		return;
-
-	if (!(chip->config & ADT7408_EVENT_STATUS))
-		return;
-
-	config = chip->config & ~ADT7408_EVENT_CLEAR;
-	if (data)
-		config |= ADT7408_EVENT_CLEAR;
-
-	adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-
-	if (adt7408_i2c_read(chip, ADT7408_TEMPERATURE, &data))
-		goto exit;
-
-	if (data & ADT7408_T_ABOVE_ALARM)
-		iio_push_event(chip->indio_dev, 0,
-			IIO_EVENT_CODE_ADT7408_ABOVE_ALARM,
-			chip->last_timestamp);
-	if (data & ADT7408_T_BELLOW_ALARM)
-		iio_push_event(chip->indio_dev, 0,
-			IIO_EVENT_CODE_ADT7408_BELLOW_ALARM,
-			chip->last_timestamp);
-	if (data & ADT7408_T_ABOVE_CRIT)
-		iio_push_event(chip->indio_dev, 0,
-			IIO_EVENT_CODE_ADT7408_ABOVE_CRIT,
-			chip->last_timestamp);
-exit:
-	enable_irq(chip->client->irq);
-}
-
-static int adt7408_interrupt(struct iio_dev *dev_info,
-		int index,
-		s64 timestamp,
-		int no_test)
-{
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-
-	chip->last_timestamp = timestamp;
-	schedule_work(&chip->thresh_work);
-
-	return 0;
-}
-
-IIO_EVENT_SH(adt7408, &adt7408_interrupt);
-
-static ssize_t adt7408_show_event_mode(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	if (chip->config & ADT7408_EVENT_MODE)
-		return sprintf(buf, "interrupt\n");
-	else
-		return sprintf(buf, "comparator\n");
-}
-
-static ssize_t adt7408_set_event_mode(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 config;
-	int ret;
-
-	if (adt7408_is_event_locked(chip)) {
-		dev_err(dev, "Warning: Events are locked.\n");
-		return -EIO;
-	}
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config &= ~ADT7408_EVENT_MODE;
-	if (strcmp(buf, "comparator") != 0)
-		config |= ADT7408_EVENT_MODE;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-static ssize_t adt7408_show_available_event_modes(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return sprintf(buf, "comparator\ninterrupt\n");
-}
-
-static ssize_t adt7408_show_event_crit_only(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "%d\n", !!(chip->config & ADT7408_EVENT_CRIT_ONLY));
-}
-
-static ssize_t adt7408_set_event_crit_only(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	unsigned long data = ""
-	u16 config;
-	int ret;
-
-	if (adt7408_is_event_locked(chip)) {
-		dev_err(dev, "Warning: Events are locked.\n");
-		return -EIO;
-	}
-
-	ret = strict_strtoul(buf, 10, &data);
-	if (ret)
-		return -EINVAL;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config &= ~ADT7408_EVENT_CRIT_ONLY;
-	if (data)
-		config |= ADT7408_EVENT_CRIT_ONLY;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-static ssize_t adt7408_show_event_enable(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "%d\n", !!(chip->config & ADT7408_EVENT_ENABLE));
-}
-
-static ssize_t adt7408_set_event_enable(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	unsigned long data;
-	u16 config;
-	int ret;
-
-	if (adt7408_is_event_locked(chip)) {
-		dev_err(dev, "Warning: Events are locked.\n");
-		return -EIO;
-	}
-
-	ret = strict_strtoul(buf, 10, &data);
-	if (ret)
-		return -EINVAL;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config & ~ADT7408_EVENT_ENABLE;
-	if (data)
-		config |= ADT7408_EVENT_ENABLE;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-static ssize_t adt7408_show_alarm_lock(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "%d\n", !!(chip->config & ADT7408_EVENT_ALARM_LOCK));
-}
-
-static ssize_t adt7408_set_alarm_lock(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	unsigned long data;
-	u16 config;
-	int ret;
-
-	ret = strict_strtoul(buf, 10, &data);
-	if (ret)
-		return -EINVAL;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config & ~ADT7408_EVENT_ALARM_LOCK;
-	if (data)
-		config |= ADT7408_EVENT_ALARM_LOCK;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-static ssize_t adt7408_show_crit_lock(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	return sprintf(buf, "%d\n", !!(chip->config & ADT7408_EVENT_CRIT_LOCK));
-}
-
-static ssize_t adt7408_set_crit_lock(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	unsigned long data;
-	u16 config;
-	int ret;
-
-	ret = strict_strtoul(buf, 10, &data);
-	if (ret)
-		return -EINVAL;
-
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config = chip->config & ~ADT7408_EVENT_CRIT_LOCK;
-	if (data)
-		config |= ADT7408_EVENT_CRIT_LOCK;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-
-	return ret;
-}
-
-
-static inline ssize_t adt7408_show_t_bound(struct device *dev,
-		struct device_attribute *attr,
-		u8 bound_reg,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	u16 data;
-	char sign = ' ';
-	int ret;
-
-	ret = adt7408_i2c_read(chip, bound_reg, &data);
-	if (ret)
-		return -EIO;
-
-	data >>= ADT7408_BOUND_VALUE_OFFSET;
-	if (data & ADT7408_BOUND_VALUE_SIGN) {
-		/* convert supplement to positive value */
-		data = "" << 1) - data;
-		sign = '-';
-	}
-
-	return sprintf(buf, "%c%d.%.2d\n", sign,
-			data >> ADT7408_BOUND_VALUE_FLOAT_OFFSET,
-			(data & ADT7408_BOUND_VALUE_FLOAT_MASK) * 25);
-}
-
-static inline ssize_t adt7408_set_t_bound(struct device *dev,
-		struct device_attribute *attr,
-		u8 bound_reg,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	long tmp1, tmp2;
-	u16 data;
-	char *pos;
-	int ret;
-
-	pos = strchr(buf, '.');
-
-	ret = strict_strtol(buf, 10, &tmp1);
-
-	if (ret || tmp1 > 127 || tmp1 < -128)
-		return -EINVAL;
-
-	if (pos) {
-		len = strlen(pos);
-		if (len > ADT7408_BOUND_VALUE_FLOAT_OFFSET)
-			len = ADT7408_BOUND_VALUE_FLOAT_OFFSET;
-		pos[len] = 0;
-		ret = strict_strtol(pos, 10, &tmp2);
-
-		if (!ret)
-			tmp2 = (tmp2 / 25) * 25;
-	}
-
-	if (tmp1 < 0)
-		data = ""
-	else
-		data = ""
-	data = "" << ADT7408_BOUND_VALUE_FLOAT_OFFSET) |
-		(tmp2 & ADT7408_BOUND_VALUE_FLOAT_MASK);
-	if (tmp1 < 0)
-		/* convert positive value to supplyment */
-		data = "" << 1) - data;
-	data <<= ADT7408_BOUND_VALUE_OFFSET;
-
-	ret = adt7408_i2c_write(chip, bound_reg, data);
-	if (ret)
-		return -EIO;
-
-	return ret;
-}
-
-static ssize_t adt7408_show_t_alarm_high(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return adt7408_show_t_bound(dev, attr,
-			ADT7408_T_ALARM_HIGH, buf);
-}
-
-static inline ssize_t adt7408_set_t_alarm_high(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	return adt7408_set_t_bound(dev, attr,
-			ADT7408_T_ALARM_HIGH, buf, len);
-}
-
-static ssize_t adt7408_show_t_alarm_low(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return adt7408_show_t_bound(dev, attr,
-			ADT7408_T_ALARM_LOW, buf);
-}
-
-static inline ssize_t adt7408_set_t_alarm_low(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	return adt7408_set_t_bound(dev, attr,
-			ADT7408_T_ALARM_LOW, buf, len);
-}
-
-static ssize_t adt7408_show_t_crit(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return adt7408_show_t_bound(dev, attr,
-			ADT7408_T_CRIT, buf);
-}
-
-static inline ssize_t adt7408_set_t_crit(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	return adt7408_set_t_bound(dev, attr,
-			ADT7408_T_CRIT, buf, len);
-}
-
-static ssize_t adt7408_show_t_hyst(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-
-	/* retrive ALART status */
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	switch (chip->config & ADT7408_HISTERESIS_MASK) {
-	case ADT7408_HISTERESIS_1_5:
-		return sprintf(buf, "1.5\n");
-	case ADT7408_HISTERESIS_3:
-		return sprintf(buf, "3\n");
-	case ADT7408_HISTERESIS_6:
-		return sprintf(buf, "6\n");
-	default:
-		return sprintf(buf, "Disabled\n");
-	}
-}
-
-static inline ssize_t adt7408_set_t_hyst(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf,
-		size_t len)
-{
-	struct iio_dev *dev_info = dev_get_drvdata(dev);
-	struct adt7408_chip_info *chip = dev_info->dev_data;
-	int ret;
-	u16 config = 0;
-
-	if (strcmp(buf, "disble"))
-		config = ADT7408_HISTERESIS_MASK;
-	else if (strcmp(buf, "1.5"))
-		config = ADT7408_HISTERESIS_1_5;
-	else if (len > 1 && buf[0] == '3')
-		config = ADT7408_HISTERESIS_6;
-	else if (len > 1 && buf[0] == '6')
-		config = ADT7408_HISTERESIS_6;
-
-	if (!config)
-		return -EINVAL;
-
-	/* retrive ALART status */
-	ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-	if (ret)
-		return -EIO;
-
-	config |= chip->config & ~ADT7408_HISTERESIS_MASK;
-
-	ret = adt7408_i2c_write(chip, ADT7408_CONFIG, config);
-	if (ret)
-		return -EIO;
-
-	chip->config = config;
-	return ret;
-}
-
-static ssize_t adt7408_show_available_t_hyst(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	return sprintf(buf, "1.5\n3\n6\ndisable\n");
-}
-
-IIO_EVENT_ATTR_SH(event_mode, iio_event_adt7408,
-		adt7408_show_event_mode, adt7408_set_event_mode, 0);
-IIO_EVENT_ATTR_SH(available_event_modes, iio_event_adt7408,
-		adt7408_show_available_event_modes, NULL, 0);
-IIO_EVENT_ATTR_SH(event_crit_only, iio_event_adt7408,
-		adt7408_show_event_crit_only, adt7408_set_event_crit_only, 0);
-IIO_EVENT_ATTR_SH(event_enable, iio_event_adt7408,
-		adt7408_show_event_enable, adt7408_set_event_enable, 0);
-IIO_EVENT_ATTR_SH(alarm_lock, iio_event_adt7408,
-		adt7408_show_alarm_lock, adt7408_set_alarm_lock, 0);
-IIO_EVENT_ATTR_SH(crit_lock, iio_event_adt7408,
-		adt7408_show_crit_lock, adt7408_set_crit_lock, 0);
-IIO_EVENT_ATTR_SH(t_alarm_high, iio_event_adt7408,
-		adt7408_show_t_alarm_high, adt7408_set_t_alarm_high, 0);
-IIO_EVENT_ATTR_SH(t_alarm_low, iio_event_adt7408,
-		adt7408_show_t_alarm_low, adt7408_set_t_alarm_low, 0);
-IIO_EVENT_ATTR_SH(t_crit, iio_event_adt7408,
-		adt7408_show_t_crit, adt7408_set_t_crit, 0);
-IIO_EVENT_ATTR_SH(t_hyst, iio_event_adt7408,
-		adt7408_show_t_hyst, adt7408_set_t_hyst, 0);
-IIO_EVENT_ATTR_SH(available_t_hyst, iio_event_adt7408,
-		adt7408_show_available_t_hyst, NULL, 0);
-
-static struct attribute *adt7408_event_attributes[] = {
-	&iio_event_attr_event_mode.dev_attr.attr,
-	&iio_event_attr_available_event_modes.dev_attr.attr,
-	&iio_event_attr_event_crit_only.dev_attr.attr,
-	&iio_event_attr_event_enable.dev_attr.attr,
-	&iio_event_attr_alarm_lock.dev_attr.attr,
-	&iio_event_attr_crit_lock.dev_attr.attr,
-	&iio_event_attr_t_alarm_high.dev_attr.attr,
-	&iio_event_attr_t_alarm_low.dev_attr.attr,
-	&iio_event_attr_t_crit.dev_attr.attr,
-	&iio_event_attr_t_hyst.dev_attr.attr,
-	&iio_event_attr_available_t_hyst.dev_attr.attr,
-	NULL,
-};
-
-static struct attribute_group adt7408_event_attribute_group = {
-	.attrs = adt7408_event_attributes,
-};
-
-/*
- * device probe and remove
- */
-
-static int __devinit adt7408_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	struct adt7408_chip_info *chip;
-	int ret = 0;
-
-	chip = kzalloc(sizeof(struct adt7408_chip_info), GFP_KERNEL);
-
-	if (chip == NULL)
-		return -ENOMEM;
-
-	/* this is only used for device removal purposes */
-	i2c_set_clientdata(client, chip);
-
-	chip->client = client;
-	chip->name = id->name;
-
-	chip->indio_dev = iio_allocate_device();
-	if (chip->indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_free_chip;
-	}
-
-	chip->indio_dev->dev.parent = &client->dev;
-	chip->indio_dev->attrs = &adt7408_attribute_group;
-	chip->indio_dev->event_attrs = &adt7408_event_attribute_group;
-	chip->indio_dev->dev_data = (void *)chip;
-	chip->indio_dev->driver_module = THIS_MODULE;
-	chip->indio_dev->num_interrupt_lines = 1;
-	chip->indio_dev->modes = INDIO_DIRECT_MODE;
-
-	ret = iio_device_register(chip->indio_dev);
-	if (ret)
-		goto error_free_dev;
-
-	if (client->irq) {
-		ret = iio_register_interrupt_line(client->irq,
-				chip->indio_dev,
-				0,
-				IRQF_TRIGGER_LOW,
-				chip->name);
-		if (ret)
-			goto error_unreg_dev;
-
-		/*
-		 * The event handler list element refer to iio_event_adt7408.
-		 * All event attributes bind to the same event handler.
-		 * So, only register event handler once.
-		 */
-		iio_add_event_to_list(&iio_event_adt7408,
-				&chip->indio_dev->interrupts[0]->ev_list);
-
-		INIT_WORK(&chip->thresh_work, adt7408_interrupt_bh);
-
-		ret = adt7408_i2c_read(chip, ADT7408_CONFIG, &chip->config);
-		if (ret) {
-			ret = -EIO;
-			goto error_unreg_irq;
-		}
-
-		/* set irq polarity low level */
-		chip->config &= ~ADT7408_EVENT_POLARITY;
-
-		ret = adt7408_i2c_write(chip, ADT7408_CONFIG, chip->config);
-		if (ret) {
-			ret = -EIO;
-			goto error_unreg_irq;
-		}
-	}
-
-	dev_info(&client->dev, "%s temperature sensor registered.\n",
-			 id->name);
-
-	return 0;
-
-error_unreg_irq:
-	iio_unregister_interrupt_line(chip->indio_dev, 0);
-error_unreg_dev:
-	iio_device_unregister(chip->indio_dev);
-error_free_dev:
-	iio_free_device(chip->indio_dev);
-error_free_chip:
-	kfree(chip);
-
-	return ret;
-}
-
-static int __devexit adt7408_remove(struct i2c_client *client)
-{
-	struct adt7408_chip_info *chip = i2c_get_clientdata(client);
-	struct iio_dev *indio_dev = chip->indio_dev;
-
-	if (client->irq)
-		iio_unregister_interrupt_line(indio_dev, 0);
-	iio_device_unregister(indio_dev);
-	iio_free_device(chip->indio_dev);
-	kfree(chip);
-
-	return 0;
-}
-
-static const struct i2c_device_id adt7408_id[] = {
-	{ "adt7408", 0 },
-	{}
-};
-
-MODULE_DEVICE_TABLE(i2c, adt7408_id);
-
-static struct i2c_driver adt7408_driver = {
-	.driver = {
-		.name = "adt7408",
-	},
-	.probe = adt7408_probe,
-	.remove = __devexit_p(adt7408_remove),
-	.id_table = adt7408_id,
-};
-
-static __init int adt7408_init(void)
-{
-	return i2c_add_driver(&adt7408_driver);
-}
-
-static __exit void adt7408_exit(void)
-{
-	i2c_del_driver(&adt7408_driver);
-}
-
-MODULE_AUTHOR("Sonic Zhang <[email protected]>");
-MODULE_DESCRIPTION("Analog Devices ADT7408 digital"
-			" temperature sensor driver");
-MODULE_LICENSE("GPL v2");
-
-module_init(adt7408_init);
-module_exit(adt7408_exit);
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to