aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-07-01 10:39:08 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-08-04 10:01:35 -0400
commit991763a91cbacf1e511ec9bea9ea8539e4d41f39 (patch)
tree42107271da372c899ee5f01834a5020b85b12b32 /drivers/hwmon
parent045c1391ec3b703ee00643fe9bda7cd65cd463e1 (diff)
hwmon: (ad7418) Avoid forward declaration
Move ad7418_driver to proper place to avoid forward declaration. Also move ad7418_init_client() close to ad7418_probe(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ad7418.c72
1 files changed, 34 insertions, 38 deletions
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
index 57d4a6295675..f7bf4299413d 100644
--- a/drivers/hwmon/ad7418.c
+++ b/drivers/hwmon/ad7418.c
@@ -55,44 +55,6 @@ struct ad7418_data {
55 u16 in[4]; 55 u16 in[4];
56}; 56};
57 57
58static int ad7418_probe(struct i2c_client *client,
59 const struct i2c_device_id *id);
60static int ad7418_remove(struct i2c_client *client);
61
62static const struct i2c_device_id ad7418_id[] = {
63 { "ad7416", ad7416 },
64 { "ad7417", ad7417 },
65 { "ad7418", ad7418 },
66 { }
67};
68MODULE_DEVICE_TABLE(i2c, ad7418_id);
69
70static struct i2c_driver ad7418_driver = {
71 .driver = {
72 .name = "ad7418",
73 },
74 .probe = ad7418_probe,
75 .remove = ad7418_remove,
76 .id_table = ad7418_id,
77};
78
79static void ad7418_init_client(struct i2c_client *client)
80{
81 struct ad7418_data *data = i2c_get_clientdata(client);
82
83 int reg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF);
84 if (reg < 0) {
85 dev_err(&client->dev, "cannot read configuration register\n");
86 } else {
87 dev_info(&client->dev, "configuring for mode 1\n");
88 i2c_smbus_write_byte_data(client, AD7418_REG_CONF, reg & 0xfe);
89
90 if (data->type == ad7417 || data->type == ad7418)
91 i2c_smbus_write_byte_data(client,
92 AD7418_REG_CONF2, 0x00);
93 }
94}
95
96static struct ad7418_data *ad7418_update_device(struct device *dev) 58static struct ad7418_data *ad7418_update_device(struct device *dev)
97{ 59{
98 struct i2c_client *client = to_i2c_client(dev); 60 struct i2c_client *client = to_i2c_client(dev);
@@ -219,6 +181,23 @@ static struct attribute *ad7418_attributes[] = {
219 NULL 181 NULL
220}; 182};
221 183
184static void ad7418_init_client(struct i2c_client *client)
185{
186 struct ad7418_data *data = i2c_get_clientdata(client);
187
188 int reg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF);
189 if (reg < 0) {
190 dev_err(&client->dev, "cannot read configuration register\n");
191 } else {
192 dev_info(&client->dev, "configuring for mode 1\n");
193 i2c_smbus_write_byte_data(client, AD7418_REG_CONF, reg & 0xfe);
194
195 if (data->type == ad7417 || data->type == ad7418)
196 i2c_smbus_write_byte_data(client,
197 AD7418_REG_CONF2, 0x00);
198 }
199}
200
222static int ad7418_probe(struct i2c_client *client, 201static int ad7418_probe(struct i2c_client *client,
223 const struct i2c_device_id *id) 202 const struct i2c_device_id *id)
224{ 203{
@@ -288,6 +267,23 @@ static int ad7418_remove(struct i2c_client *client)
288 return 0; 267 return 0;
289} 268}
290 269
270static const struct i2c_device_id ad7418_id[] = {
271 { "ad7416", ad7416 },
272 { "ad7417", ad7417 },
273 { "ad7418", ad7418 },
274 { }
275};
276MODULE_DEVICE_TABLE(i2c, ad7418_id);
277
278static struct i2c_driver ad7418_driver = {
279 .driver = {
280 .name = "ad7418",
281 },
282 .probe = ad7418_probe,
283 .remove = ad7418_remove,
284 .id_table = ad7418_id,
285};
286
291module_i2c_driver(ad7418_driver); 287module_i2c_driver(ad7418_driver);
292 288
293MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 289MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");