Blame view
drivers/hwmon/adt7410.c
1.98 KB
983b97bed hwmon: Driver for... |
1 |
/* |
51c2a4871 hwmon: (adt7410) ... |
2 |
* ADT7410/ADT7420 digital temperature sensor driver |
983b97bed hwmon: Driver for... |
3 |
* |
51c2a4871 hwmon: (adt7410) ... |
4 5 |
* Copyright 2012-2013 Analog Devices Inc. * Author: Lars-Peter Clausen <lars@metafoo.de> |
983b97bed hwmon: Driver for... |
6 |
* |
51c2a4871 hwmon: (adt7410) ... |
7 |
* Licensed under the GPL-2 or later. |
983b97bed hwmon: Driver for... |
8 9 10 11 |
*/ #include <linux/module.h> #include <linux/init.h> |
983b97bed hwmon: Driver for... |
12 |
#include <linux/i2c.h> |
983b97bed hwmon: Driver for... |
13 |
|
51c2a4871 hwmon: (adt7410) ... |
14 |
#include "adt7x10.h" |
983b97bed hwmon: Driver for... |
15 |
|
51c2a4871 hwmon: (adt7410) ... |
16 |
static int adt7410_i2c_read_word(struct device *dev, u8 reg) |
983b97bed hwmon: Driver for... |
17 |
{ |
51c2a4871 hwmon: (adt7410) ... |
18 |
return i2c_smbus_read_word_swapped(to_i2c_client(dev), reg); |
983b97bed hwmon: Driver for... |
19 |
} |
51c2a4871 hwmon: (adt7410) ... |
20 |
static int adt7410_i2c_write_word(struct device *dev, u8 reg, u16 data) |
983b97bed hwmon: Driver for... |
21 |
{ |
51c2a4871 hwmon: (adt7410) ... |
22 |
return i2c_smbus_write_word_swapped(to_i2c_client(dev), reg, data); |
983b97bed hwmon: Driver for... |
23 |
} |
51c2a4871 hwmon: (adt7410) ... |
24 |
static int adt7410_i2c_read_byte(struct device *dev, u8 reg) |
983b97bed hwmon: Driver for... |
25 |
{ |
51c2a4871 hwmon: (adt7410) ... |
26 |
return i2c_smbus_read_byte_data(to_i2c_client(dev), reg); |
983b97bed hwmon: Driver for... |
27 |
} |
51c2a4871 hwmon: (adt7410) ... |
28 |
static int adt7410_i2c_write_byte(struct device *dev, u8 reg, u8 data) |
983b97bed hwmon: Driver for... |
29 |
{ |
51c2a4871 hwmon: (adt7410) ... |
30 |
return i2c_smbus_write_byte_data(to_i2c_client(dev), reg, data); |
983b97bed hwmon: Driver for... |
31 |
} |
51c2a4871 hwmon: (adt7410) ... |
32 33 34 35 36 |
static const struct adt7x10_ops adt7410_i2c_ops = { .read_word = adt7410_i2c_read_word, .write_word = adt7410_i2c_write_word, .read_byte = adt7410_i2c_read_byte, .write_byte = adt7410_i2c_write_byte, |
983b97bed hwmon: Driver for... |
37 |
}; |
51c2a4871 hwmon: (adt7410) ... |
38 39 |
static int adt7410_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) |
983b97bed hwmon: Driver for... |
40 |
{ |
983b97bed hwmon: Driver for... |
41 42 43 |
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; |
4b5e536b0 hwmon: (adt7x10) ... |
44 |
return adt7x10_probe(&client->dev, NULL, client->irq, &adt7410_i2c_ops); |
983b97bed hwmon: Driver for... |
45 |
} |
51c2a4871 hwmon: (adt7410) ... |
46 |
static int adt7410_i2c_remove(struct i2c_client *client) |
983b97bed hwmon: Driver for... |
47 |
{ |
4b5e536b0 hwmon: (adt7x10) ... |
48 |
return adt7x10_remove(&client->dev, client->irq); |
983b97bed hwmon: Driver for... |
49 50 51 |
} static const struct i2c_device_id adt7410_ids[] = { |
51c2a4871 hwmon: (adt7410) ... |
52 53 54 |
{ "adt7410", 0 }, { "adt7420", 0 }, {} |
983b97bed hwmon: Driver for... |
55 56 |
}; MODULE_DEVICE_TABLE(i2c, adt7410_ids); |
983b97bed hwmon: Driver for... |
57 58 59 60 |
static struct i2c_driver adt7410_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = "adt7410", |
51c2a4871 hwmon: (adt7410) ... |
61 |
.pm = ADT7X10_DEV_PM_OPS, |
983b97bed hwmon: Driver for... |
62 |
}, |
51c2a4871 hwmon: (adt7410) ... |
63 64 |
.probe = adt7410_i2c_probe, .remove = adt7410_i2c_remove, |
983b97bed hwmon: Driver for... |
65 |
.id_table = adt7410_ids, |
54be068d1 hwmon: (adt7410) ... |
66 |
.address_list = I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b), |
983b97bed hwmon: Driver for... |
67 |
}; |
983b97bed hwmon: Driver for... |
68 |
module_i2c_driver(adt7410_driver); |
51c2a4871 hwmon: (adt7410) ... |
69 70 |
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); MODULE_DESCRIPTION("ADT7410/AD7420 driver"); |
983b97bed hwmon: Driver for... |
71 |
MODULE_LICENSE("GPL"); |