aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adt7462.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adt7462.c')
-rw-r--r--drivers/hwmon/adt7462.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
index 1852f27bac51..2af0c7b6b4e4 100644
--- a/drivers/hwmon/adt7462.c
+++ b/drivers/hwmon/adt7462.c
@@ -28,13 +28,11 @@
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/log2.h> 30#include <linux/log2.h>
31#include <linux/slab.h>
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END }; 34static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
34 35
35/* Insmod parameters */
36I2C_CLIENT_INSMOD_1(adt7462);
37
38/* ADT7462 registers */ 36/* ADT7462 registers */
39#define ADT7462_REG_DEVICE 0x3D 37#define ADT7462_REG_DEVICE 0x3D
40#define ADT7462_REG_VENDOR 0x3E 38#define ADT7462_REG_VENDOR 0x3E
@@ -97,7 +95,7 @@ I2C_CLIENT_INSMOD_1(adt7462);
97#define ADT7462_PIN24_SHIFT 6 95#define ADT7462_PIN24_SHIFT 6
98#define ADT7462_PIN26_VOLT_INPUT 0x08 96#define ADT7462_PIN26_VOLT_INPUT 0x08
99#define ADT7462_PIN25_VOLT_INPUT 0x20 97#define ADT7462_PIN25_VOLT_INPUT 0x20
100#define ADT7462_PIN28_SHIFT 6 /* cfg3 */ 98#define ADT7462_PIN28_SHIFT 4 /* cfg3 */
101#define ADT7462_PIN28_VOLT 0x5 99#define ADT7462_PIN28_VOLT 0x5
102 100
103#define ADT7462_REG_ALARM1 0xB8 101#define ADT7462_REG_ALARM1 0xB8
@@ -182,7 +180,7 @@ I2C_CLIENT_INSMOD_1(adt7462);
182 * 180 *
183 * Some, but not all, of these voltages have low/high limits. 181 * Some, but not all, of these voltages have low/high limits.
184 */ 182 */
185#define ADT7462_VOLT_COUNT 12 183#define ADT7462_VOLT_COUNT 13
186 184
187#define ADT7462_VENDOR 0x41 185#define ADT7462_VENDOR 0x41
188#define ADT7462_DEVICE 0x62 186#define ADT7462_DEVICE 0x62
@@ -237,12 +235,12 @@ struct adt7462_data {
237 235
238static int adt7462_probe(struct i2c_client *client, 236static int adt7462_probe(struct i2c_client *client,
239 const struct i2c_device_id *id); 237 const struct i2c_device_id *id);
240static int adt7462_detect(struct i2c_client *client, int kind, 238static int adt7462_detect(struct i2c_client *client,
241 struct i2c_board_info *info); 239 struct i2c_board_info *info);
242static int adt7462_remove(struct i2c_client *client); 240static int adt7462_remove(struct i2c_client *client);
243 241
244static const struct i2c_device_id adt7462_id[] = { 242static const struct i2c_device_id adt7462_id[] = {
245 { "adt7462", adt7462 }, 243 { "adt7462", 0 },
246 { } 244 { }
247}; 245};
248MODULE_DEVICE_TABLE(i2c, adt7462_id); 246MODULE_DEVICE_TABLE(i2c, adt7462_id);
@@ -256,7 +254,7 @@ static struct i2c_driver adt7462_driver = {
256 .remove = adt7462_remove, 254 .remove = adt7462_remove,
257 .id_table = adt7462_id, 255 .id_table = adt7462_id,
258 .detect = adt7462_detect, 256 .detect = adt7462_detect,
259 .address_data = &addr_data, 257 .address_list = normal_i2c,
260}; 258};
261 259
262/* 260/*
@@ -1902,31 +1900,26 @@ static struct attribute *adt7462_attr[] =
1902}; 1900};
1903 1901
1904/* Return 0 if detection is successful, -ENODEV otherwise */ 1902/* Return 0 if detection is successful, -ENODEV otherwise */
1905static int adt7462_detect(struct i2c_client *client, int kind, 1903static int adt7462_detect(struct i2c_client *client,
1906 struct i2c_board_info *info) 1904 struct i2c_board_info *info)
1907{ 1905{
1908 struct i2c_adapter *adapter = client->adapter; 1906 struct i2c_adapter *adapter = client->adapter;
1907 int vendor, device, revision;
1909 1908
1910 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1909 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1911 return -ENODEV; 1910 return -ENODEV;
1912 1911
1913 if (kind <= 0) { 1912 vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR);
1914 int vendor, device, revision; 1913 if (vendor != ADT7462_VENDOR)
1915 1914 return -ENODEV;
1916 vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR);
1917 if (vendor != ADT7462_VENDOR)
1918 return -ENODEV;
1919 1915
1920 device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE); 1916 device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE);
1921 if (device != ADT7462_DEVICE) 1917 if (device != ADT7462_DEVICE)
1922 return -ENODEV; 1918 return -ENODEV;
1923 1919
1924 revision = i2c_smbus_read_byte_data(client, 1920 revision = i2c_smbus_read_byte_data(client, ADT7462_REG_REVISION);
1925 ADT7462_REG_REVISION); 1921 if (revision != ADT7462_REVISION)
1926 if (revision != ADT7462_REVISION) 1922 return -ENODEV;
1927 return -ENODEV;
1928 } else
1929 dev_dbg(&adapter->dev, "detection forced\n");
1930 1923
1931 strlcpy(info->type, "adt7462", I2C_NAME_SIZE); 1924 strlcpy(info->type, "adt7462", I2C_NAME_SIZE);
1932 1925