1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/module.h>
21#include <linux/i2c.h>
22#include <linux/err.h>
23#include "bmp085.h"
24
25#define BMP085_I2C_ADDRESS 0x77
26
27static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS,
28 I2C_CLIENT_END };
29
30static int bmp085_i2c_detect(struct i2c_client *client,
31 struct i2c_board_info *info)
32{
33 if (client->addr != BMP085_I2C_ADDRESS)
34 return -ENODEV;
35
36 return bmp085_detect(&client->dev);
37}
38
39static int bmp085_i2c_probe(struct i2c_client *client,
40 const struct i2c_device_id *id)
41{
42 int err;
43 struct regmap *regmap = devm_regmap_init_i2c(client,
44 &bmp085_regmap_config);
45
46 if (IS_ERR(regmap)) {
47 err = PTR_ERR(regmap);
48 dev_err(&client->dev, "Failed to init regmap: %d\n", err);
49 return err;
50 }
51
52 return bmp085_probe(&client->dev, regmap, client->irq);
53}
54
55static int bmp085_i2c_remove(struct i2c_client *client)
56{
57 return bmp085_remove(&client->dev);
58}
59
60static const struct i2c_device_id bmp085_id[] = {
61 { BMP085_NAME, 0 },
62 { "bmp180", 0 },
63 { }
64};
65MODULE_DEVICE_TABLE(i2c, bmp085_id);
66
67static struct i2c_driver bmp085_i2c_driver = {
68 .driver = {
69 .name = BMP085_NAME,
70 },
71 .id_table = bmp085_id,
72 .probe = bmp085_i2c_probe,
73 .remove = bmp085_i2c_remove,
74
75 .detect = bmp085_i2c_detect,
76 .address_list = normal_i2c
77};
78
79module_i2c_driver(bmp085_i2c_driver);
80
81MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>");
82MODULE_DESCRIPTION("BMP085 I2C bus driver");
83MODULE_LICENSE("GPL");
84