diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-28 17:14:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-28 17:14:57 -0400 |
commit | 20731945ae743034353a88c307920d1f16cf8ac8 (patch) | |
tree | 132c796fe3a167dece8cec7a40b1d5dd83a68bc8 /drivers | |
parent | 406119f49d4a6cf8b6eee639128e0575a95065e3 (diff) | |
parent | a9d1b24d91f91b77db3da8aeacb414764f789b9c (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
Diffstat (limited to 'drivers')
85 files changed, 1615 insertions, 972 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index e928cdb041cb..8102876c7c3f 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -121,7 +121,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, | |||
121 | static struct adm1021_data *adm1021_update_device(struct device *dev); | 121 | static struct adm1021_data *adm1021_update_device(struct device *dev); |
122 | 122 | ||
123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ | 123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ |
124 | static int read_only = 0; | 124 | static int read_only; |
125 | 125 | ||
126 | 126 | ||
127 | /* This is the driver that will be inserted */ | 127 | /* This is the driver that will be inserted */ |
@@ -204,11 +204,10 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
204 | client structure, even though we cannot fill it completely yet. | 204 | client structure, even though we cannot fill it completely yet. |
205 | But it allows us to access adm1021_{read,write}_value. */ | 205 | But it allows us to access adm1021_{read,write}_value. */ |
206 | 206 | ||
207 | if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { | 207 | if (!(data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { |
208 | err = -ENOMEM; | 208 | err = -ENOMEM; |
209 | goto error0; | 209 | goto error0; |
210 | } | 210 | } |
211 | memset(data, 0, sizeof(struct adm1021_data)); | ||
212 | 211 | ||
213 | new_client = &data->client; | 212 | new_client = &data->client; |
214 | i2c_set_clientdata(new_client, data); | 213 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 526b7ff179eb..3ec12421694f 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -331,11 +331,10 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
332 | goto exit; | 332 | goto exit; |
333 | 333 | ||
334 | if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { | 334 | if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { |
335 | err = -ENOMEM; | 335 | err = -ENOMEM; |
336 | goto exit; | 336 | goto exit; |
337 | } | 337 | } |
338 | memset(data, 0, sizeof(struct adm1025_data)); | ||
339 | 338 | ||
340 | /* The common I2C client data is placed right before the | 339 | /* The common I2C client data is placed right before the |
341 | ADM1025-specific data. */ | 340 | ADM1025-specific data. */ |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 625158110fd4..e0f56549d1d8 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -315,7 +315,7 @@ static struct i2c_driver adm1026_driver = { | |||
315 | .detach_client = adm1026_detach_client, | 315 | .detach_client = adm1026_detach_client, |
316 | }; | 316 | }; |
317 | 317 | ||
318 | int adm1026_attach_adapter(struct i2c_adapter *adapter) | 318 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) |
319 | { | 319 | { |
320 | if (!(adapter->class & I2C_CLASS_HWMON)) { | 320 | if (!(adapter->class & I2C_CLASS_HWMON)) { |
321 | return 0; | 321 | return 0; |
@@ -323,7 +323,7 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) | |||
323 | return i2c_probe(adapter, &addr_data, adm1026_detect); | 323 | return i2c_probe(adapter, &addr_data, adm1026_detect); |
324 | } | 324 | } |
325 | 325 | ||
326 | int adm1026_detach_client(struct i2c_client *client) | 326 | static int adm1026_detach_client(struct i2c_client *client) |
327 | { | 327 | { |
328 | struct adm1026_data *data = i2c_get_clientdata(client); | 328 | struct adm1026_data *data = i2c_get_clientdata(client); |
329 | hwmon_device_unregister(data->class_dev); | 329 | hwmon_device_unregister(data->class_dev); |
@@ -332,7 +332,7 @@ int adm1026_detach_client(struct i2c_client *client) | |||
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | int adm1026_read_value(struct i2c_client *client, u8 reg) | 335 | static int adm1026_read_value(struct i2c_client *client, u8 reg) |
336 | { | 336 | { |
337 | int res; | 337 | int res; |
338 | 338 | ||
@@ -346,7 +346,7 @@ int adm1026_read_value(struct i2c_client *client, u8 reg) | |||
346 | return res; | 346 | return res; |
347 | } | 347 | } |
348 | 348 | ||
349 | int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | 349 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value) |
350 | { | 350 | { |
351 | int res; | 351 | int res; |
352 | 352 | ||
@@ -360,7 +360,7 @@ int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | |||
360 | return res; | 360 | return res; |
361 | } | 361 | } |
362 | 362 | ||
363 | void adm1026_init_client(struct i2c_client *client) | 363 | static void adm1026_init_client(struct i2c_client *client) |
364 | { | 364 | { |
365 | int value, i; | 365 | int value, i; |
366 | struct adm1026_data *data = i2c_get_clientdata(client); | 366 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -460,7 +460,7 @@ void adm1026_init_client(struct i2c_client *client) | |||
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | void adm1026_print_gpio(struct i2c_client *client) | 463 | static void adm1026_print_gpio(struct i2c_client *client) |
464 | { | 464 | { |
465 | struct adm1026_data *data = i2c_get_clientdata(client); | 465 | struct adm1026_data *data = i2c_get_clientdata(client); |
466 | int i; | 466 | int i; |
@@ -492,7 +492,7 @@ void adm1026_print_gpio(struct i2c_client *client) | |||
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void adm1026_fixup_gpio(struct i2c_client *client) | 495 | static void adm1026_fixup_gpio(struct i2c_client *client) |
496 | { | 496 | { |
497 | struct adm1026_data *data = i2c_get_clientdata(client); | 497 | struct adm1026_data *data = i2c_get_clientdata(client); |
498 | int i; | 498 | int i; |
@@ -1452,8 +1452,8 @@ static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | |||
1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1454 | 1454 | ||
1455 | int adm1026_detect(struct i2c_adapter *adapter, int address, | 1455 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
1456 | int kind) | 1456 | int kind) |
1457 | { | 1457 | { |
1458 | int company, verstep; | 1458 | int company, verstep; |
1459 | struct i2c_client *new_client; | 1459 | struct i2c_client *new_client; |
@@ -1470,13 +1470,11 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1470 | client structure, even though we cannot fill it completely yet. | 1470 | client structure, even though we cannot fill it completely yet. |
1471 | But it allows us to access adm1026_{read,write}_value. */ | 1471 | But it allows us to access adm1026_{read,write}_value. */ |
1472 | 1472 | ||
1473 | if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { | 1473 | if (!(data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { |
1474 | err = -ENOMEM; | 1474 | err = -ENOMEM; |
1475 | goto exit; | 1475 | goto exit; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | memset(data, 0, sizeof(struct adm1026_data)); | ||
1479 | |||
1480 | new_client = &data->client; | 1478 | new_client = &data->client; |
1481 | i2c_set_clientdata(new_client, data); | 1479 | i2c_set_clientdata(new_client, data); |
1482 | new_client->addr = address; | 1480 | new_client->addr = address; |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 58338ed7c8a1..7c545d5eee45 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -740,11 +740,10 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
741 | goto exit; | 741 | goto exit; |
742 | 742 | ||
743 | if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { | 743 | if (!(data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { |
744 | err = -ENOMEM; | 744 | err = -ENOMEM; |
745 | goto exit; | 745 | goto exit; |
746 | } | 746 | } |
747 | memset(data, 0, sizeof(struct adm1031_data)); | ||
748 | 747 | ||
749 | new_client = &data->client; | 748 | new_client = &data->client; |
750 | i2c_set_clientdata(new_client, data); | 749 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index bc7faef162f7..11dc95f8a17e 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
49 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
50 | #include <linux/err.h> | 51 | #include <linux/err.h> |
@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); | |||
69 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | 70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) |
70 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | 71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) |
71 | #define ADM9240_REG_TEMP 0x27 | 72 | #define ADM9240_REG_TEMP 0x27 |
72 | #define ADM9240_REG_TEMP_HIGH 0x39 | 73 | #define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */ |
73 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
74 | #define ADM9240_REG_ANALOG_OUT 0x19 | 74 | #define ADM9240_REG_ANALOG_OUT 0x19 |
75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | 75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 |
76 | #define ADM9240_REG_VID_FAN_DIV 0x47 | 76 | #define ADM9240_REG_VID_FAN_DIV 0x47 |
@@ -162,177 +162,155 @@ struct adm9240_data { | |||
162 | u8 fan_min[2]; /* rw fan1_min */ | 162 | u8 fan_min[2]; /* rw fan1_min */ |
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | 163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ |
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | 164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ |
165 | s8 temp_high; /* rw temp1_max */ | 165 | s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */ |
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | 166 | u16 alarms; /* ro alarms */ |
168 | u8 aout; /* rw aout_output */ | 167 | u8 aout; /* rw aout_output */ |
169 | u8 vid; /* ro vid */ | 168 | u8 vid; /* ro vid */ |
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | 169 | u8 vrm; /* -- vrm set on startup, no accessor */ |
171 | }; | 170 | }; |
172 | 171 | ||
173 | /* i2c byte read/write interface */ | 172 | /*** sysfs accessors ***/ |
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | 173 | |
174 | /* temperature */ | ||
175 | static ssize_t show_temp(struct device *dev, struct device_attribute *dummy, | ||
176 | char *buf) | ||
175 | { | 177 | { |
176 | return i2c_smbus_read_byte_data(client, reg); | 178 | struct adm9240_data *data = adm9240_update_device(dev); |
179 | return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ | ||
177 | } | 180 | } |
178 | 181 | ||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | 182 | static ssize_t show_max(struct device *dev, struct device_attribute *devattr, |
183 | char *buf) | ||
180 | { | 184 | { |
181 | return i2c_smbus_write_byte_data(client, reg, value); | 185 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
186 | struct adm9240_data *data = adm9240_update_device(dev); | ||
187 | return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000); | ||
182 | } | 188 | } |
183 | 189 | ||
184 | /*** sysfs accessors ***/ | 190 | static ssize_t set_max(struct device *dev, struct device_attribute *devattr, |
191 | const char *buf, size_t count) | ||
192 | { | ||
193 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
194 | struct i2c_client *client = to_i2c_client(dev); | ||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
196 | long val = simple_strtol(buf, NULL, 10); | ||
197 | |||
198 | down(&data->update_lock); | ||
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | ||
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | ||
201 | data->temp_max[attr->index]); | ||
202 | up(&data->update_lock); | ||
203 | return count; | ||
204 | } | ||
185 | 205 | ||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | 206 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); |
207 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
208 | show_max, set_max, 0); | ||
209 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
210 | show_max, set_max, 1); | ||
223 | 211 | ||
224 | /* voltage */ | 212 | /* voltage */ |
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 213 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
214 | char *buf) | ||
226 | { | 215 | { |
216 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | 217 | struct adm9240_data *data = adm9240_update_device(dev); |
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | 218 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index], |
219 | attr->index)); | ||
229 | } | 220 | } |
230 | 221 | ||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 222 | static ssize_t show_in_min(struct device *dev, |
223 | struct device_attribute *devattr, char *buf) | ||
232 | { | 224 | { |
225 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | 226 | struct adm9240_data *data = adm9240_update_device(dev); |
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | 227 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index], |
228 | attr->index)); | ||
235 | } | 229 | } |
236 | 230 | ||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 231 | static ssize_t show_in_max(struct device *dev, |
232 | struct device_attribute *devattr, char *buf) | ||
238 | { | 233 | { |
234 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | 235 | struct adm9240_data *data = adm9240_update_device(dev); |
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | 236 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index], |
237 | attr->index)); | ||
241 | } | 238 | } |
242 | 239 | ||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | 240 | static ssize_t set_in_min(struct device *dev, |
244 | size_t count, int nr) | 241 | struct device_attribute *devattr, |
242 | const char *buf, size_t count) | ||
245 | { | 243 | { |
244 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
246 | struct i2c_client *client = to_i2c_client(dev); | 245 | struct i2c_client *client = to_i2c_client(dev); |
247 | struct adm9240_data *data = i2c_get_clientdata(client); | 246 | struct adm9240_data *data = i2c_get_clientdata(client); |
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
249 | 248 | ||
250 | down(&data->update_lock); | 249 | down(&data->update_lock); |
251 | data->in_min[nr] = IN_TO_REG(val, nr); | 250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | 251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | ||
253 | up(&data->update_lock); | 253 | up(&data->update_lock); |
254 | return count; | 254 | return count; |
255 | } | 255 | } |
256 | 256 | ||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | 257 | static ssize_t set_in_max(struct device *dev, |
258 | size_t count, int nr) | 258 | struct device_attribute *devattr, |
259 | const char *buf, size_t count) | ||
259 | { | 260 | { |
261 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
260 | struct i2c_client *client = to_i2c_client(dev); | 262 | struct i2c_client *client = to_i2c_client(dev); |
261 | struct adm9240_data *data = i2c_get_clientdata(client); | 263 | struct adm9240_data *data = i2c_get_clientdata(client); |
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | 264 | unsigned long val = simple_strtoul(buf, NULL, 10); |
263 | 265 | ||
264 | down(&data->update_lock); | 266 | down(&data->update_lock); |
265 | data->in_max[nr] = IN_TO_REG(val, nr); | 267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | 268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | ||
267 | up(&data->update_lock); | 270 | up(&data->update_lock); |
268 | return count; | 271 | return count; |
269 | } | 272 | } |
270 | 273 | ||
271 | #define show_in_offset(offset) \ | 274 | #define vin(nr) \ |
272 | static ssize_t show_in##offset(struct device *dev, \ | 275 | static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ |
273 | struct device_attribute *attr, \ | 276 | show_in, NULL, nr); \ |
274 | char *buf) \ | 277 | static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ |
275 | { \ | 278 | show_in_min, set_in_min, nr); \ |
276 | return show_in(dev, buf, offset); \ | 279 | static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ |
277 | } \ | 280 | show_in_max, set_in_max, nr); |
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | 281 | |
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | 282 | vin(0); |
280 | struct device_attribute *attr, \ | 283 | vin(1); |
281 | char *buf) \ | 284 | vin(2); |
282 | { \ | 285 | vin(3); |
283 | return show_in_min(dev, buf, offset); \ | 286 | vin(4); |
284 | } \ | 287 | vin(5); |
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | 288 | ||
317 | /* fans */ | 289 | /* fans */ |
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 290 | static ssize_t show_fan(struct device *dev, |
291 | struct device_attribute *devattr, char *buf) | ||
319 | { | 292 | { |
293 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | 294 | struct adm9240_data *data = adm9240_update_device(dev); |
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | 295 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
322 | 1 << data->fan_div[nr])); | 296 | 1 << data->fan_div[attr->index])); |
323 | } | 297 | } |
324 | 298 | ||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 299 | static ssize_t show_fan_min(struct device *dev, |
300 | struct device_attribute *devattr, char *buf) | ||
326 | { | 301 | { |
302 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | 303 | struct adm9240_data *data = adm9240_update_device(dev); |
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 304 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index], |
329 | 1 << data->fan_div[nr])); | 305 | 1 << data->fan_div[attr->index])); |
330 | } | 306 | } |
331 | 307 | ||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 308 | static ssize_t show_fan_div(struct device *dev, |
309 | struct device_attribute *devattr, char *buf) | ||
333 | { | 310 | { |
311 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | 312 | struct adm9240_data *data = adm9240_update_device(dev); |
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | 313 | return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]); |
336 | } | 314 | } |
337 | 315 | ||
338 | /* write new fan div, callers must hold data->update_lock */ | 316 | /* write new fan div, callers must hold data->update_lock */ |
@@ -341,16 +319,16 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
341 | { | 319 | { |
342 | u8 reg, old, shift = (nr + 2) * 2; | 320 | u8 reg, old, shift = (nr + 2) * 2; |
343 | 321 | ||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 322 | reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
345 | old = (reg >> shift) & 3; | 323 | old = (reg >> shift) & 3; |
346 | reg &= ~(3 << shift); | 324 | reg &= ~(3 << shift); |
347 | reg |= (fan_div << shift); | 325 | reg |= (fan_div << shift); |
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | 326 | i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg); |
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | 327 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " |
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | 328 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); |
351 | } | 329 | } |
352 | 330 | ||
353 | /* | 331 | /* |
354 | * set fan speed low limit: | 332 | * set fan speed low limit: |
355 | * | 333 | * |
356 | * - value is zero: disable fan speed low limit alarm | 334 | * - value is zero: disable fan speed low limit alarm |
@@ -361,12 +339,15 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | 339 | * - otherwise: select fan clock divider to suit fan speed low limit, |
362 | * measurement code may adjust registers to ensure fan speed reading | 340 | * measurement code may adjust registers to ensure fan speed reading |
363 | */ | 341 | */ |
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 342 | static ssize_t set_fan_min(struct device *dev, |
365 | size_t count, int nr) | 343 | struct device_attribute *devattr, |
344 | const char *buf, size_t count) | ||
366 | { | 345 | { |
346 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
367 | struct i2c_client *client = to_i2c_client(dev); | 347 | struct i2c_client *client = to_i2c_client(dev); |
368 | struct adm9240_data *data = i2c_get_clientdata(client); | 348 | struct adm9240_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 349 | unsigned long val = simple_strtoul(buf, NULL, 10); |
350 | int nr = attr->index; | ||
370 | u8 new_div; | 351 | u8 new_div; |
371 | 352 | ||
372 | down(&data->update_lock); | 353 | down(&data->update_lock); |
@@ -406,50 +387,27 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
406 | data->fan_div[nr] = new_div; | 387 | data->fan_div[nr] = new_div; |
407 | adm9240_write_fan_div(client, nr, new_div); | 388 | adm9240_write_fan_div(client, nr, new_div); |
408 | } | 389 | } |
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | 390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
410 | data->fan_min[nr]); | 391 | data->fan_min[nr]); |
411 | 392 | ||
412 | up(&data->update_lock); | 393 | up(&data->update_lock); |
413 | return count; | 394 | return count; |
414 | } | 395 | } |
415 | 396 | ||
416 | #define show_fan_offset(offset) \ | 397 | #define fan(nr) \ |
417 | static ssize_t show_fan_##offset (struct device *dev, \ | 398 | static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ |
418 | struct device_attribute *attr, \ | 399 | show_fan, NULL, nr - 1); \ |
419 | char *buf) \ | 400 | static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ |
420 | { \ | 401 | show_fan_div, NULL, nr - 1); \ |
421 | return show_fan(dev, buf, offset - 1); \ | 402 | static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ |
422 | } \ | 403 | show_fan_min, set_fan_min, nr - 1); |
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | 404 | |
424 | struct device_attribute *attr, \ | 405 | fan(1); |
425 | char *buf) \ | 406 | fan(2); |
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | 407 | ||
451 | /* alarms */ | 408 | /* alarms */ |
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 409 | static ssize_t show_alarms(struct device *dev, |
410 | struct device_attribute *attr, char *buf) | ||
453 | { | 411 | { |
454 | struct adm9240_data *data = adm9240_update_device(dev); | 412 | struct adm9240_data *data = adm9240_update_device(dev); |
455 | return sprintf(buf, "%u\n", data->alarms); | 413 | return sprintf(buf, "%u\n", data->alarms); |
@@ -457,7 +415,8 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 415 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
458 | 416 | ||
459 | /* vid */ | 417 | /* vid */ |
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 418 | static ssize_t show_vid(struct device *dev, |
419 | struct device_attribute *attr, char *buf) | ||
461 | { | 420 | { |
462 | struct adm9240_data *data = adm9240_update_device(dev); | 421 | struct adm9240_data *data = adm9240_update_device(dev); |
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 422 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
@@ -465,13 +424,16 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 424 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
466 | 425 | ||
467 | /* analog output */ | 426 | /* analog output */ |
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | 427 | static ssize_t show_aout(struct device *dev, |
428 | struct device_attribute *attr, char *buf) | ||
469 | { | 429 | { |
470 | struct adm9240_data *data = adm9240_update_device(dev); | 430 | struct adm9240_data *data = adm9240_update_device(dev); |
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | 431 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); |
472 | } | 432 | } |
473 | 433 | ||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 434 | static ssize_t set_aout(struct device *dev, |
435 | struct device_attribute *attr, | ||
436 | const char *buf, size_t count) | ||
475 | { | 437 | { |
476 | struct i2c_client *client = to_i2c_client(dev); | 438 | struct i2c_client *client = to_i2c_client(dev); |
477 | struct adm9240_data *data = i2c_get_clientdata(client); | 439 | struct adm9240_data *data = i2c_get_clientdata(client); |
@@ -479,20 +441,23 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
479 | 441 | ||
480 | down(&data->update_lock); | 442 | down(&data->update_lock); |
481 | data->aout = AOUT_TO_REG(val); | 443 | data->aout = AOUT_TO_REG(val); |
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | 444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
483 | up(&data->update_lock); | 445 | up(&data->update_lock); |
484 | return count; | 446 | return count; |
485 | } | 447 | } |
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
487 | 449 | ||
488 | /* chassis_clear */ | 450 | /* chassis_clear */ |
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 451 | static ssize_t chassis_clear(struct device *dev, |
452 | struct device_attribute *attr, | ||
453 | const char *buf, size_t count) | ||
490 | { | 454 | { |
491 | struct i2c_client *client = to_i2c_client(dev); | 455 | struct i2c_client *client = to_i2c_client(dev); |
492 | unsigned long val = simple_strtol(buf, NULL, 10); | 456 | unsigned long val = simple_strtol(buf, NULL, 10); |
493 | 457 | ||
494 | if (val == 1) { | 458 | if (val == 1) { |
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | 459 | i2c_smbus_write_byte_data(client, |
460 | ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | 461 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); |
497 | } | 462 | } |
498 | return count; | 463 | return count; |
@@ -513,11 +478,10 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 478 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
514 | goto exit; | 479 | goto exit; |
515 | 480 | ||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | 481 | if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { |
517 | err = -ENOMEM; | 482 | err = -ENOMEM; |
518 | goto exit; | 483 | goto exit; |
519 | } | 484 | } |
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | 485 | ||
522 | new_client = &data->client; | 486 | new_client = &data->client; |
523 | i2c_set_clientdata(new_client, data); | 487 | i2c_set_clientdata(new_client, data); |
@@ -533,7 +497,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
533 | if (kind < 0) { | 497 | if (kind < 0) { |
534 | 498 | ||
535 | /* verify chip: reg address should match i2c address */ | 499 | /* verify chip: reg address should match i2c address */ |
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | 500 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
537 | != address) { | 501 | != address) { |
538 | dev_err(&adapter->dev, "detect fail: address match, " | 502 | dev_err(&adapter->dev, "detect fail: address match, " |
539 | "0x%02x\n", address); | 503 | "0x%02x\n", address); |
@@ -541,8 +505,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
541 | } | 505 | } |
542 | 506 | ||
543 | /* check known chip manufacturer */ | 507 | /* check known chip manufacturer */ |
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | 508 | man_id = i2c_smbus_read_byte_data(new_client, |
545 | 509 | ADM9240_REG_MAN_ID); | |
546 | if (man_id == 0x23) { | 510 | if (man_id == 0x23) { |
547 | kind = adm9240; | 511 | kind = adm9240; |
548 | } else if (man_id == 0xda) { | 512 | } else if (man_id == 0xda) { |
@@ -556,7 +520,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
556 | } | 520 | } |
557 | 521 | ||
558 | /* successful detect, print chip info */ | 522 | /* successful detect, print chip info */ |
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | 523 | die_rev = i2c_smbus_read_byte_data(new_client, |
524 | ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | 525 | dev_info(&adapter->dev, "found %s revision %u\n", |
561 | man_id == 0x23 ? "ADM9240" : | 526 | man_id == 0x23 ? "ADM9240" : |
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | 527 | man_id == 0xda ? "DS1780" : "LM81", die_rev); |
@@ -588,33 +553,59 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
588 | goto exit_detach; | 553 | goto exit_detach; |
589 | } | 554 | } |
590 | 555 | ||
591 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 556 | device_create_file(&new_client->dev, |
592 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 557 | &sensor_dev_attr_in0_input.dev_attr); |
593 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 558 | device_create_file(&new_client->dev, |
594 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 559 | &sensor_dev_attr_in0_min.dev_attr); |
595 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 560 | device_create_file(&new_client->dev, |
596 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 561 | &sensor_dev_attr_in0_max.dev_attr); |
597 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 562 | device_create_file(&new_client->dev, |
598 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 563 | &sensor_dev_attr_in1_input.dev_attr); |
599 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 564 | device_create_file(&new_client->dev, |
600 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 565 | &sensor_dev_attr_in1_min.dev_attr); |
601 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 566 | device_create_file(&new_client->dev, |
602 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 567 | &sensor_dev_attr_in1_max.dev_attr); |
603 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 568 | device_create_file(&new_client->dev, |
604 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 569 | &sensor_dev_attr_in2_input.dev_attr); |
605 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 570 | device_create_file(&new_client->dev, |
606 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 571 | &sensor_dev_attr_in2_min.dev_attr); |
607 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 572 | device_create_file(&new_client->dev, |
608 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 573 | &sensor_dev_attr_in2_max.dev_attr); |
609 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 574 | device_create_file(&new_client->dev, |
610 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 575 | &sensor_dev_attr_in3_input.dev_attr); |
576 | device_create_file(&new_client->dev, | ||
577 | &sensor_dev_attr_in3_min.dev_attr); | ||
578 | device_create_file(&new_client->dev, | ||
579 | &sensor_dev_attr_in3_max.dev_attr); | ||
580 | device_create_file(&new_client->dev, | ||
581 | &sensor_dev_attr_in4_input.dev_attr); | ||
582 | device_create_file(&new_client->dev, | ||
583 | &sensor_dev_attr_in4_min.dev_attr); | ||
584 | device_create_file(&new_client->dev, | ||
585 | &sensor_dev_attr_in4_max.dev_attr); | ||
586 | device_create_file(&new_client->dev, | ||
587 | &sensor_dev_attr_in5_input.dev_attr); | ||
588 | device_create_file(&new_client->dev, | ||
589 | &sensor_dev_attr_in5_min.dev_attr); | ||
590 | device_create_file(&new_client->dev, | ||
591 | &sensor_dev_attr_in5_max.dev_attr); | ||
611 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 592 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
612 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 593 | device_create_file(&new_client->dev, |
613 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 594 | &sensor_dev_attr_temp1_max.dev_attr); |
614 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 595 | device_create_file(&new_client->dev, |
615 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 596 | &sensor_dev_attr_temp1_max_hyst.dev_attr); |
616 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 597 | device_create_file(&new_client->dev, |
617 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 598 | &sensor_dev_attr_fan1_input.dev_attr); |
599 | device_create_file(&new_client->dev, | ||
600 | &sensor_dev_attr_fan1_div.dev_attr); | ||
601 | device_create_file(&new_client->dev, | ||
602 | &sensor_dev_attr_fan1_min.dev_attr); | ||
603 | device_create_file(&new_client->dev, | ||
604 | &sensor_dev_attr_fan2_input.dev_attr); | ||
605 | device_create_file(&new_client->dev, | ||
606 | &sensor_dev_attr_fan2_div.dev_attr); | ||
607 | device_create_file(&new_client->dev, | ||
608 | &sensor_dev_attr_fan2_min.dev_attr); | ||
618 | device_create_file(&new_client->dev, &dev_attr_alarms); | 609 | device_create_file(&new_client->dev, &dev_attr_alarms); |
619 | device_create_file(&new_client->dev, &dev_attr_aout_output); | 610 | device_create_file(&new_client->dev, &dev_attr_aout_output); |
620 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | 611 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); |
@@ -654,8 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client) | |||
654 | static void adm9240_init_client(struct i2c_client *client) | 645 | static void adm9240_init_client(struct i2c_client *client) |
655 | { | 646 | { |
656 | struct adm9240_data *data = i2c_get_clientdata(client); | 647 | struct adm9240_data *data = i2c_get_clientdata(client); |
657 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | 648 | u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG); |
658 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | 649 | u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3; |
659 | 650 | ||
660 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ | 651 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ |
661 | 652 | ||
@@ -672,18 +663,22 @@ static void adm9240_init_client(struct i2c_client *client) | |||
672 | 663 | ||
673 | for (i = 0; i < 6; i++) | 664 | for (i = 0; i < 6; i++) |
674 | { | 665 | { |
675 | adm9240_write_value(client, | 666 | i2c_smbus_write_byte_data(client, |
676 | ADM9240_REG_IN_MIN(i), 0); | 667 | ADM9240_REG_IN_MIN(i), 0); |
677 | adm9240_write_value(client, | 668 | i2c_smbus_write_byte_data(client, |
678 | ADM9240_REG_IN_MAX(i), 255); | 669 | ADM9240_REG_IN_MAX(i), 255); |
679 | } | 670 | } |
680 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | 671 | i2c_smbus_write_byte_data(client, |
681 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | 672 | ADM9240_REG_FAN_MIN(0), 255); |
682 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | 673 | i2c_smbus_write_byte_data(client, |
683 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | 674 | ADM9240_REG_FAN_MIN(1), 255); |
675 | i2c_smbus_write_byte_data(client, | ||
676 | ADM9240_REG_TEMP_MAX(0), 127); | ||
677 | i2c_smbus_write_byte_data(client, | ||
678 | ADM9240_REG_TEMP_MAX(1), 127); | ||
684 | 679 | ||
685 | /* start measurement cycle */ | 680 | /* start measurement cycle */ |
686 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | 681 | i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); |
687 | 682 | ||
688 | dev_info(&client->dev, "cold start: config was 0x%02x " | 683 | dev_info(&client->dev, "cold start: config was 0x%02x " |
689 | "mode %u\n", conf, mode); | 684 | "mode %u\n", conf, mode); |
@@ -704,25 +699,25 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
704 | 699 | ||
705 | for (i = 0; i < 6; i++) /* read voltages */ | 700 | for (i = 0; i < 6; i++) /* read voltages */ |
706 | { | 701 | { |
707 | data->in[i] = adm9240_read_value(client, | 702 | data->in[i] = i2c_smbus_read_byte_data(client, |
708 | ADM9240_REG_IN(i)); | 703 | ADM9240_REG_IN(i)); |
709 | } | 704 | } |
710 | data->alarms = adm9240_read_value(client, | 705 | data->alarms = i2c_smbus_read_byte_data(client, |
711 | ADM9240_REG_INT(0)) | | 706 | ADM9240_REG_INT(0)) | |
712 | adm9240_read_value(client, | 707 | i2c_smbus_read_byte_data(client, |
713 | ADM9240_REG_INT(1)) << 8; | 708 | ADM9240_REG_INT(1)) << 8; |
714 | 709 | ||
715 | /* read temperature: assume temperature changes less than | 710 | /* read temperature: assume temperature changes less than |
716 | * 0.5'C per two measurement cycles thus ignore possible | 711 | * 0.5'C per two measurement cycles thus ignore possible |
717 | * but unlikely aliasing error on lsb reading. --Grant */ | 712 | * but unlikely aliasing error on lsb reading. --Grant */ |
718 | data->temp = ((adm9240_read_value(client, | 713 | data->temp = ((i2c_smbus_read_byte_data(client, |
719 | ADM9240_REG_TEMP) << 8) | | 714 | ADM9240_REG_TEMP) << 8) | |
720 | adm9240_read_value(client, | 715 | i2c_smbus_read_byte_data(client, |
721 | ADM9240_REG_TEMP_CONF)) / 128; | 716 | ADM9240_REG_TEMP_CONF)) / 128; |
722 | 717 | ||
723 | for (i = 0; i < 2; i++) /* read fans */ | 718 | for (i = 0; i < 2; i++) /* read fans */ |
724 | { | 719 | { |
725 | data->fan[i] = adm9240_read_value(client, | 720 | data->fan[i] = i2c_smbus_read_byte_data(client, |
726 | ADM9240_REG_FAN(i)); | 721 | ADM9240_REG_FAN(i)); |
727 | 722 | ||
728 | /* adjust fan clock divider on overflow */ | 723 | /* adjust fan clock divider on overflow */ |
@@ -747,30 +742,30 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
747 | 742 | ||
748 | for (i = 0; i < 6; i++) | 743 | for (i = 0; i < 6; i++) |
749 | { | 744 | { |
750 | data->in_min[i] = adm9240_read_value(client, | 745 | data->in_min[i] = i2c_smbus_read_byte_data(client, |
751 | ADM9240_REG_IN_MIN(i)); | 746 | ADM9240_REG_IN_MIN(i)); |
752 | data->in_max[i] = adm9240_read_value(client, | 747 | data->in_max[i] = i2c_smbus_read_byte_data(client, |
753 | ADM9240_REG_IN_MAX(i)); | 748 | ADM9240_REG_IN_MAX(i)); |
754 | } | 749 | } |
755 | for (i = 0; i < 2; i++) | 750 | for (i = 0; i < 2; i++) |
756 | { | 751 | { |
757 | data->fan_min[i] = adm9240_read_value(client, | 752 | data->fan_min[i] = i2c_smbus_read_byte_data(client, |
758 | ADM9240_REG_FAN_MIN(i)); | 753 | ADM9240_REG_FAN_MIN(i)); |
759 | } | 754 | } |
760 | data->temp_high = adm9240_read_value(client, | 755 | data->temp_max[0] = i2c_smbus_read_byte_data(client, |
761 | ADM9240_REG_TEMP_HIGH); | 756 | ADM9240_REG_TEMP_MAX(0)); |
762 | data->temp_hyst = adm9240_read_value(client, | 757 | data->temp_max[1] = i2c_smbus_read_byte_data(client, |
763 | ADM9240_REG_TEMP_HYST); | 758 | ADM9240_REG_TEMP_MAX(1)); |
764 | 759 | ||
765 | /* read fan divs and 5-bit VID */ | 760 | /* read fan divs and 5-bit VID */ |
766 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 761 | i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
767 | data->fan_div[0] = (i >> 4) & 3; | 762 | data->fan_div[0] = (i >> 4) & 3; |
768 | data->fan_div[1] = (i >> 6) & 3; | 763 | data->fan_div[1] = (i >> 6) & 3; |
769 | data->vid = i & 0x0f; | 764 | data->vid = i & 0x0f; |
770 | data->vid |= (adm9240_read_value(client, | 765 | data->vid |= (i2c_smbus_read_byte_data(client, |
771 | ADM9240_REG_VID4) & 1) << 4; | 766 | ADM9240_REG_VID4) & 1) << 4; |
772 | /* read analog out */ | 767 | /* read analog out */ |
773 | data->aout = adm9240_read_value(client, | 768 | data->aout = i2c_smbus_read_byte_data(client, |
774 | ADM9240_REG_ANALOG_OUT); | 769 | ADM9240_REG_ANALOG_OUT); |
775 | 770 | ||
776 | data->last_updated_config = jiffies; | 771 | data->last_updated_config = jiffies; |
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 8e34855a6274..52c469722a65 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -629,19 +629,17 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | |||
629 | int i, id, err; | 629 | int i, id, err; |
630 | struct asb100_data *data = i2c_get_clientdata(new_client); | 630 | struct asb100_data *data = i2c_get_clientdata(new_client); |
631 | 631 | ||
632 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 632 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
633 | if (!(data->lm75[0])) { | 633 | if (!(data->lm75[0])) { |
634 | err = -ENOMEM; | 634 | err = -ENOMEM; |
635 | goto ERROR_SC_0; | 635 | goto ERROR_SC_0; |
636 | } | 636 | } |
637 | memset(data->lm75[0], 0x00, sizeof(struct i2c_client)); | ||
638 | 637 | ||
639 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 638 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
640 | if (!(data->lm75[1])) { | 639 | if (!(data->lm75[1])) { |
641 | err = -ENOMEM; | 640 | err = -ENOMEM; |
642 | goto ERROR_SC_1; | 641 | goto ERROR_SC_1; |
643 | } | 642 | } |
644 | memset(data->lm75[1], 0x00, sizeof(struct i2c_client)); | ||
645 | 643 | ||
646 | id = i2c_adapter_id(adapter); | 644 | id = i2c_adapter_id(adapter); |
647 | 645 | ||
@@ -724,12 +722,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
724 | client structure, even though we cannot fill it completely yet. | 722 | client structure, even though we cannot fill it completely yet. |
725 | But it allows us to access asb100_{read,write}_value. */ | 723 | But it allows us to access asb100_{read,write}_value. */ |
726 | 724 | ||
727 | if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { | 725 | if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) { |
728 | pr_debug("asb100.o: detect failed, kmalloc failed!\n"); | 726 | pr_debug("asb100.o: detect failed, kzalloc failed!\n"); |
729 | err = -ENOMEM; | 727 | err = -ENOMEM; |
730 | goto ERROR0; | 728 | goto ERROR0; |
731 | } | 729 | } |
732 | memset(data, 0, sizeof(struct asb100_data)); | ||
733 | 730 | ||
734 | new_client = &data->client; | 731 | new_client = &data->client; |
735 | init_MUTEX(&data->lock); | 732 | init_MUTEX(&data->lock); |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index deb4d34c9539..53324f56404e 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -253,6 +253,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | |||
253 | 253 | ||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | 254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) |
255 | { | 255 | { |
256 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
257 | return 0; | ||
256 | return i2c_probe(adapter, &addr_data, &atxp1_detect); | 258 | return i2c_probe(adapter, &addr_data, &atxp1_detect); |
257 | }; | 259 | }; |
258 | 260 | ||
@@ -266,12 +268,11 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 268 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
267 | goto exit; | 269 | goto exit; |
268 | 270 | ||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | 271 | if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { |
270 | err = -ENOMEM; | 272 | err = -ENOMEM; |
271 | goto exit; | 273 | goto exit; |
272 | } | 274 | } |
273 | 275 | ||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | 276 | new_client = &data->client; |
276 | i2c_set_clientdata(new_client, data); | 277 | i2c_set_clientdata(new_client, data); |
277 | 278 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index b0199e063d0e..34f71b7c7f37 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -180,12 +180,14 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); | |||
180 | 180 | ||
181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) | 181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) |
182 | { | 182 | { |
183 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
184 | return 0; | ||
183 | return i2c_probe(adapter, &addr_data, ds1621_detect); | 185 | return i2c_probe(adapter, &addr_data, ds1621_detect); |
184 | } | 186 | } |
185 | 187 | ||
186 | /* This function is called by i2c_probe */ | 188 | /* This function is called by i2c_probe */ |
187 | int ds1621_detect(struct i2c_adapter *adapter, int address, | 189 | static int ds1621_detect(struct i2c_adapter *adapter, int address, |
188 | int kind) | 190 | int kind) |
189 | { | 191 | { |
190 | int conf, temp; | 192 | int conf, temp; |
191 | struct i2c_client *new_client; | 193 | struct i2c_client *new_client; |
@@ -200,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
200 | /* OK. For now, we presume we have a valid client. We now create the | 202 | /* OK. For now, we presume we have a valid client. We now create the |
201 | client structure, even though we cannot fill it completely yet. | 203 | client structure, even though we cannot fill it completely yet. |
202 | But it allows us to access ds1621_{read,write}_value. */ | 204 | But it allows us to access ds1621_{read,write}_value. */ |
203 | if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { | 205 | if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { |
204 | err = -ENOMEM; | 206 | err = -ENOMEM; |
205 | goto exit; | 207 | goto exit; |
206 | } | 208 | } |
207 | memset(data, 0, sizeof(struct ds1621_data)); | ||
208 | 209 | ||
209 | new_client = &data->client; | 210 | new_client = &data->client; |
210 | i2c_set_clientdata(new_client, data); | 211 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index eef6061d786b..a02e1c34c757 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -303,11 +303,10 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
303 | /* OK. For now, we presume we have a valid client. We now create the | 303 | /* OK. For now, we presume we have a valid client. We now create the |
304 | * client structure, even though we cannot fill it completely yet. | 304 | * client structure, even though we cannot fill it completely yet. |
305 | * But it allows us to access i2c_smbus_read_byte_data. */ | 305 | * But it allows us to access i2c_smbus_read_byte_data. */ |
306 | if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { | 306 | if (!(data = kzalloc(sizeof(struct fscher_data), GFP_KERNEL))) { |
307 | err = -ENOMEM; | 307 | err = -ENOMEM; |
308 | goto exit; | 308 | goto exit; |
309 | } | 309 | } |
310 | memset(data, 0, sizeof(struct fscher_data)); | ||
311 | 310 | ||
312 | /* The common I2C client data is placed right before the | 311 | /* The common I2C client data is placed right before the |
313 | * Hermes-specific data. */ | 312 | * Hermes-specific data. */ |
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 5fc77a5fed07..64e4edc64f8d 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -438,7 +438,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) | |||
438 | return i2c_probe(adapter, &addr_data, fscpos_detect); | 438 | return i2c_probe(adapter, &addr_data, fscpos_detect); |
439 | } | 439 | } |
440 | 440 | ||
441 | int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | 441 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) |
442 | { | 442 | { |
443 | struct i2c_client *new_client; | 443 | struct i2c_client *new_client; |
444 | struct fscpos_data *data; | 444 | struct fscpos_data *data; |
@@ -453,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
453 | * But it allows us to access fscpos_{read,write}_value. | 453 | * But it allows us to access fscpos_{read,write}_value. |
454 | */ | 454 | */ |
455 | 455 | ||
456 | if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { | 456 | if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { |
457 | err = -ENOMEM; | 457 | err = -ENOMEM; |
458 | goto exit; | 458 | goto exit; |
459 | } | 459 | } |
460 | memset(data, 0, sizeof(struct fscpos_data)); | ||
461 | 460 | ||
462 | new_client = &data->client; | 461 | new_client = &data->client; |
463 | i2c_set_clientdata(new_client, data); | 462 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 256b9323c84b..2f178dbe3d87 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -365,11 +365,10 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
365 | client structure, even though we cannot fill it completely yet. | 365 | client structure, even though we cannot fill it completely yet. |
366 | But it allows us to access gl518_{read,write}_value. */ | 366 | But it allows us to access gl518_{read,write}_value. */ |
367 | 367 | ||
368 | if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { | 368 | if (!(data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL))) { |
369 | err = -ENOMEM; | 369 | err = -ENOMEM; |
370 | goto exit; | 370 | goto exit; |
371 | } | 371 | } |
372 | memset(data, 0, sizeof(struct gl518_data)); | ||
373 | 372 | ||
374 | new_client = &data->client; | 373 | new_client = &data->client; |
375 | i2c_set_clientdata(new_client, data); | 374 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 12fd757066fc..c39ba1239426 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -536,11 +536,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
536 | client structure, even though we cannot fill it completely yet. | 536 | client structure, even though we cannot fill it completely yet. |
537 | But it allows us to access gl520_{read,write}_value. */ | 537 | But it allows us to access gl520_{read,write}_value. */ |
538 | 538 | ||
539 | if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { | 539 | if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) { |
540 | err = -ENOMEM; | 540 | err = -ENOMEM; |
541 | goto exit; | 541 | goto exit; |
542 | } | 542 | } |
543 | memset(data, 0, sizeof(struct gl520_data)); | ||
544 | 543 | ||
545 | new_client = &data->client; | 544 | new_client = &data->client; |
546 | i2c_set_clientdata(new_client, data); | 545 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 53cc2b6d6385..6c41e25e670b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -2,7 +2,7 @@ | |||
2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring. | 3 | monitoring. |
4 | 4 | ||
5 | Supports: IT8705F Super I/O chip w/LPC interface & SMBus | 5 | Supports: IT8705F Super I/O chip w/LPC interface |
6 | IT8712F Super I/O chip w/LPC interface & SMBus | 6 | IT8712F Super I/O chip w/LPC interface & SMBus |
7 | Sis950 A clone of the IT8705F | 7 | Sis950 A clone of the IT8705F |
8 | 8 | ||
@@ -47,7 +47,7 @@ | |||
47 | /* Addresses to scan */ | 47 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | 48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
49 | 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | 0x2e, 0x2f, I2C_CLIENT_END }; |
50 | static unsigned short isa_address = 0x290; | 50 | static unsigned short isa_address; |
51 | 51 | ||
52 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
53 | I2C_CLIENT_INSMOD_2(it87, it8712); | 53 | I2C_CLIENT_INSMOD_2(it87, it8712); |
@@ -706,7 +706,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter) | |||
706 | } | 706 | } |
707 | 707 | ||
708 | /* SuperIO detection - will change isa_address if a chip is found */ | 708 | /* SuperIO detection - will change isa_address if a chip is found */ |
709 | static int __init it87_find(int *address) | 709 | static int __init it87_find(unsigned short *address) |
710 | { | 710 | { |
711 | int err = -ENODEV; | 711 | int err = -ENODEV; |
712 | 712 | ||
@@ -738,7 +738,7 @@ exit: | |||
738 | } | 738 | } |
739 | 739 | ||
740 | /* This function is called by i2c_probe */ | 740 | /* This function is called by i2c_probe */ |
741 | int it87_detect(struct i2c_adapter *adapter, int address, int kind) | 741 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind) |
742 | { | 742 | { |
743 | int i; | 743 | int i; |
744 | struct i2c_client *new_client; | 744 | struct i2c_client *new_client; |
@@ -757,42 +757,14 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) | 757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) |
758 | goto ERROR0; | 758 | goto ERROR0; |
759 | 759 | ||
760 | /* Probe whether there is anything available on this address. Already | 760 | /* For now, we presume we have a valid client. We create the |
761 | done for SMBus and Super-I/O clients */ | ||
762 | if (kind < 0) { | ||
763 | if (is_isa && !chip_type) { | ||
764 | #define REALLY_SLOW_IO | ||
765 | /* We need the timeouts for at least some IT87-like chips. But only | ||
766 | if we read 'undefined' registers. */ | ||
767 | i = inb_p(address + 1); | ||
768 | if (inb_p(address + 2) != i | ||
769 | || inb_p(address + 3) != i | ||
770 | || inb_p(address + 7) != i) { | ||
771 | err = -ENODEV; | ||
772 | goto ERROR1; | ||
773 | } | ||
774 | #undef REALLY_SLOW_IO | ||
775 | |||
776 | /* Let's just hope nothing breaks here */ | ||
777 | i = inb_p(address + 5) & 0x7f; | ||
778 | outb_p(~i & 0x7f, address + 5); | ||
779 | if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { | ||
780 | outb_p(i, address + 5); | ||
781 | err = -ENODEV; | ||
782 | goto ERROR1; | ||
783 | } | ||
784 | } | ||
785 | } | ||
786 | |||
787 | /* OK. For now, we presume we have a valid client. We now create the | ||
788 | client structure, even though we cannot fill it completely yet. | 761 | client structure, even though we cannot fill it completely yet. |
789 | But it allows us to access it87_{read,write}_value. */ | 762 | But it allows us to access it87_{read,write}_value. */ |
790 | 763 | ||
791 | if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { | 764 | if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { |
792 | err = -ENOMEM; | 765 | err = -ENOMEM; |
793 | goto ERROR1; | 766 | goto ERROR1; |
794 | } | 767 | } |
795 | memset(data, 0, sizeof(struct it87_data)); | ||
796 | 768 | ||
797 | new_client = &data->client; | 769 | new_client = &data->client; |
798 | if (is_isa) | 770 | if (is_isa) |
@@ -1182,20 +1154,18 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1182 | 1154 | ||
1183 | static int __init sm_it87_init(void) | 1155 | static int __init sm_it87_init(void) |
1184 | { | 1156 | { |
1185 | int addr, res; | 1157 | int res; |
1186 | |||
1187 | if (!it87_find(&addr)) { | ||
1188 | isa_address = addr; | ||
1189 | } | ||
1190 | 1158 | ||
1191 | res = i2c_add_driver(&it87_driver); | 1159 | res = i2c_add_driver(&it87_driver); |
1192 | if (res) | 1160 | if (res) |
1193 | return res; | 1161 | return res; |
1194 | 1162 | ||
1195 | res = i2c_isa_add_driver(&it87_isa_driver); | 1163 | if (!it87_find(&isa_address)) { |
1196 | if (res) { | 1164 | res = i2c_isa_add_driver(&it87_isa_driver); |
1197 | i2c_del_driver(&it87_driver); | 1165 | if (res) { |
1198 | return res; | 1166 | i2c_del_driver(&it87_driver); |
1167 | return res; | ||
1168 | } | ||
1199 | } | 1169 | } |
1200 | 1170 | ||
1201 | return 0; | 1171 | return 0; |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index be5c7095ecbb..954ec2497249 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -375,11 +375,10 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
376 | goto exit; | 376 | goto exit; |
377 | 377 | ||
378 | if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { | 378 | if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) { |
379 | err = -ENOMEM; | 379 | err = -ENOMEM; |
380 | goto exit; | 380 | goto exit; |
381 | } | 381 | } |
382 | memset(data, 0, sizeof(struct lm63_data)); | ||
383 | 382 | ||
384 | /* The common I2C client data is placed right before the | 383 | /* The common I2C client data is placed right before the |
385 | LM63-specific data. */ | 384 | LM63-specific data. */ |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 9a3ebdf583f4..d70f4c8fc1e6 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -127,11 +127,10 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
127 | /* OK. For now, we presume we have a valid client. We now create the | 127 | /* OK. For now, we presume we have a valid client. We now create the |
128 | client structure, even though we cannot fill it completely yet. | 128 | client structure, even though we cannot fill it completely yet. |
129 | But it allows us to access lm75_{read,write}_value. */ | 129 | But it allows us to access lm75_{read,write}_value. */ |
130 | if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { | 130 | if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { |
131 | err = -ENOMEM; | 131 | err = -ENOMEM; |
132 | goto exit; | 132 | goto exit; |
133 | } | 133 | } |
134 | memset(data, 0, sizeof(struct lm75_data)); | ||
135 | 134 | ||
136 | new_client = &data->client; | 135 | new_client = &data->client; |
137 | i2c_set_clientdata(new_client, data); | 136 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 866eab96a6f6..9380fda7dcd1 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -226,11 +226,10 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
226 | /* OK. For now, we presume we have a valid client. We now create the | 226 | /* OK. For now, we presume we have a valid client. We now create the |
227 | client structure, even though we cannot fill it completely yet. | 227 | client structure, even though we cannot fill it completely yet. |
228 | But it allows us to access lm77_{read,write}_value. */ | 228 | But it allows us to access lm77_{read,write}_value. */ |
229 | if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { | 229 | if (!(data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL))) { |
230 | err = -ENOMEM; | 230 | err = -ENOMEM; |
231 | goto exit; | 231 | goto exit; |
232 | } | 232 | } |
233 | memset(data, 0, sizeof(struct lm77_data)); | ||
234 | 233 | ||
235 | new_client = &data->client; | 234 | new_client = &data->client; |
236 | i2c_set_clientdata(new_client, data); | 235 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f6730dc3573b..bde0cda9477e 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -480,7 +480,7 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | /* This function is called by i2c_probe */ | 482 | /* This function is called by i2c_probe */ |
483 | int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | 483 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) |
484 | { | 484 | { |
485 | int i, err; | 485 | int i, err; |
486 | struct i2c_client *new_client; | 486 | struct i2c_client *new_client; |
@@ -540,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
540 | client structure, even though we cannot fill it completely yet. | 540 | client structure, even though we cannot fill it completely yet. |
541 | But it allows us to access lm78_{read,write}_value. */ | 541 | But it allows us to access lm78_{read,write}_value. */ |
542 | 542 | ||
543 | if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { | 543 | if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) { |
544 | err = -ENOMEM; | 544 | err = -ENOMEM; |
545 | goto ERROR1; | 545 | goto ERROR1; |
546 | } | 546 | } |
547 | memset(data, 0, sizeof(struct lm78_data)); | ||
548 | 547 | ||
549 | new_client = &data->client; | 548 | new_client = &data->client; |
550 | if (is_isa) | 549 | if (is_isa) |
@@ -726,7 +725,6 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
726 | return i2c_smbus_write_byte_data(client, reg, value); | 725 | return i2c_smbus_write_byte_data(client, reg, value); |
727 | } | 726 | } |
728 | 727 | ||
729 | /* Called when we have found a new LM78. It should set limits, etc. */ | ||
730 | static void lm78_init_client(struct i2c_client *client) | 728 | static void lm78_init_client(struct i2c_client *client) |
731 | { | 729 | { |
732 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); | 730 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 83af8b3a0cac..c359fdea211e 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -393,7 +393,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) | |||
393 | return i2c_probe(adapter, &addr_data, lm80_detect); | 393 | return i2c_probe(adapter, &addr_data, lm80_detect); |
394 | } | 394 | } |
395 | 395 | ||
396 | int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | 396 | static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) |
397 | { | 397 | { |
398 | int i, cur; | 398 | int i, cur; |
399 | struct i2c_client *new_client; | 399 | struct i2c_client *new_client; |
@@ -407,11 +407,10 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | /* OK. For now, we presume we have a valid client. We now create the | 407 | /* OK. For now, we presume we have a valid client. We now create the |
408 | client structure, even though we cannot fill it completely yet. | 408 | client structure, even though we cannot fill it completely yet. |
409 | But it allows us to access lm80_{read,write}_value. */ | 409 | But it allows us to access lm80_{read,write}_value. */ |
410 | if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { | 410 | if (!(data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL))) { |
411 | err = -ENOMEM; | 411 | err = -ENOMEM; |
412 | goto exit; | 412 | goto exit; |
413 | } | 413 | } |
414 | memset(data, 0, sizeof(struct lm80_data)); | ||
415 | 414 | ||
416 | new_client = &data->client; | 415 | new_client = &data->client; |
417 | i2c_set_clientdata(new_client, data); | 416 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index d74b2c20c719..9a70611a9f69 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -230,11 +230,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
231 | goto exit; | 231 | goto exit; |
232 | 232 | ||
233 | if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { | 233 | if (!(data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL))) { |
234 | err = -ENOMEM; | 234 | err = -ENOMEM; |
235 | goto exit; | 235 | goto exit; |
236 | } | 236 | } |
237 | memset(data, 0, sizeof(struct lm83_data)); | ||
238 | 237 | ||
239 | /* The common I2C client data is placed right after the | 238 | /* The common I2C client data is placed right after the |
240 | * LM83-specific data. */ | 239 | * LM83-specific data. */ |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index ab214df9624b..d1070ed2bee6 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1007,14 +1007,14 @@ temp_auto(1); | |||
1007 | temp_auto(2); | 1007 | temp_auto(2); |
1008 | temp_auto(3); | 1008 | temp_auto(3); |
1009 | 1009 | ||
1010 | int lm85_attach_adapter(struct i2c_adapter *adapter) | 1010 | static int lm85_attach_adapter(struct i2c_adapter *adapter) |
1011 | { | 1011 | { |
1012 | if (!(adapter->class & I2C_CLASS_HWMON)) | 1012 | if (!(adapter->class & I2C_CLASS_HWMON)) |
1013 | return 0; | 1013 | return 0; |
1014 | return i2c_probe(adapter, &addr_data, lm85_detect); | 1014 | return i2c_probe(adapter, &addr_data, lm85_detect); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | int lm85_detect(struct i2c_adapter *adapter, int address, | 1017 | static int lm85_detect(struct i2c_adapter *adapter, int address, |
1018 | int kind) | 1018 | int kind) |
1019 | { | 1019 | { |
1020 | int company, verstep ; | 1020 | int company, verstep ; |
@@ -1033,11 +1033,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1033 | client structure, even though we cannot fill it completely yet. | 1033 | client structure, even though we cannot fill it completely yet. |
1034 | But it allows us to access lm85_{read,write}_value. */ | 1034 | But it allows us to access lm85_{read,write}_value. */ |
1035 | 1035 | ||
1036 | if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { | 1036 | if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) { |
1037 | err = -ENOMEM; | 1037 | err = -ENOMEM; |
1038 | goto ERROR0; | 1038 | goto ERROR0; |
1039 | } | 1039 | } |
1040 | memset(data, 0, sizeof(struct lm85_data)); | ||
1041 | 1040 | ||
1042 | new_client = &data->client; | 1041 | new_client = &data->client; |
1043 | i2c_set_clientdata(new_client, data); | 1042 | i2c_set_clientdata(new_client, data); |
@@ -1236,7 +1235,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1236 | return err; | 1235 | return err; |
1237 | } | 1236 | } |
1238 | 1237 | ||
1239 | int lm85_detach_client(struct i2c_client *client) | 1238 | static int lm85_detach_client(struct i2c_client *client) |
1240 | { | 1239 | { |
1241 | struct lm85_data *data = i2c_get_clientdata(client); | 1240 | struct lm85_data *data = i2c_get_clientdata(client); |
1242 | hwmon_device_unregister(data->class_dev); | 1241 | hwmon_device_unregister(data->class_dev); |
@@ -1246,7 +1245,7 @@ int lm85_detach_client(struct i2c_client *client) | |||
1246 | } | 1245 | } |
1247 | 1246 | ||
1248 | 1247 | ||
1249 | int lm85_read_value(struct i2c_client *client, u8 reg) | 1248 | static int lm85_read_value(struct i2c_client *client, u8 reg) |
1250 | { | 1249 | { |
1251 | int res; | 1250 | int res; |
1252 | 1251 | ||
@@ -1276,7 +1275,7 @@ int lm85_read_value(struct i2c_client *client, u8 reg) | |||
1276 | return res ; | 1275 | return res ; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | int lm85_write_value(struct i2c_client *client, u8 reg, int value) | 1278 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value) |
1280 | { | 1279 | { |
1281 | int res ; | 1280 | int res ; |
1282 | 1281 | ||
@@ -1305,7 +1304,7 @@ int lm85_write_value(struct i2c_client *client, u8 reg, int value) | |||
1305 | return res ; | 1304 | return res ; |
1306 | } | 1305 | } |
1307 | 1306 | ||
1308 | void lm85_init_client(struct i2c_client *client) | 1307 | static void lm85_init_client(struct i2c_client *client) |
1309 | { | 1308 | { |
1310 | int value; | 1309 | int value; |
1311 | struct lm85_data *data = i2c_get_clientdata(client); | 1310 | struct lm85_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index dca996de4c33..eeec18177861 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -554,11 +554,10 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
555 | goto exit; | 555 | goto exit; |
556 | 556 | ||
557 | if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { | 557 | if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) { |
558 | err = -ENOMEM; | 558 | err = -ENOMEM; |
559 | goto exit; | 559 | goto exit; |
560 | } | 560 | } |
561 | memset(data, 0, sizeof(struct lm87_data)); | ||
562 | 561 | ||
563 | /* The common I2C client data is placed right before the | 562 | /* The common I2C client data is placed right before the |
564 | LM87-specific data. */ | 563 | LM87-specific data. */ |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 14de05fcd431..83cf2e1b09f5 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * Devices. That chip is similar to the LM90, with a few differences | 31 | * Devices. That chip is similar to the LM90, with a few differences |
32 | * that are not handled by this driver. Complete datasheet can be | 32 | * that are not handled by this driver. Complete datasheet can be |
33 | * obtained from Analog's website at: | 33 | * obtained from Analog's website at: |
34 | * http://products.analog.com/products/info.asp?product=ADM1032 | 34 | * http://www.analog.com/en/prod/0,2877,ADM1032,00.html |
35 | * Among others, it has a higher accuracy than the LM90, much like the | 35 | * Among others, it has a higher accuracy than the LM90, much like the |
36 | * LM86 does. | 36 | * LM86 does. |
37 | * | 37 | * |
@@ -49,7 +49,7 @@ | |||
49 | * register values are decoded differently) it is ignored by this | 49 | * register values are decoded differently) it is ignored by this |
50 | * driver. Complete datasheet can be obtained from Analog's website | 50 | * driver. Complete datasheet can be obtained from Analog's website |
51 | * at: | 51 | * at: |
52 | * http://products.analog.com/products/info.asp?product=ADT7461 | 52 | * http://www.analog.com/en/prod/0,2877,ADT7461,00.html |
53 | * | 53 | * |
54 | * Since the LM90 was the first chipset supported by this driver, most | 54 | * Since the LM90 was the first chipset supported by this driver, most |
55 | * comments will refer to this chipset, but are actually general and | 55 | * comments will refer to this chipset, but are actually general and |
@@ -83,10 +83,10 @@ | |||
83 | * Addresses to scan | 83 | * Addresses to scan |
84 | * Address is fully defined internally and cannot be changed except for | 84 | * Address is fully defined internally and cannot be changed except for |
85 | * MAX6659. | 85 | * MAX6659. |
86 | * LM86, LM89, LM90, LM99, ADM1032, MAX6657 and MAX6658 have address 0x4c. | 86 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 |
87 | * LM89-1, and LM99-1 have address 0x4d. | 87 | * have address 0x4c. |
88 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. | ||
88 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). | 89 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). |
89 | * ADT7461 always has address 0x4c. | ||
90 | */ | 90 | */ |
91 | 91 | ||
92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; | 92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; |
@@ -345,10 +345,74 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, | |||
345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); | 345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
347 | 347 | ||
348 | /* pec used for ADM1032 only */ | ||
349 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, | ||
350 | char *buf) | ||
351 | { | ||
352 | struct i2c_client *client = to_i2c_client(dev); | ||
353 | return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC)); | ||
354 | } | ||
355 | |||
356 | static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, | ||
357 | const char *buf, size_t count) | ||
358 | { | ||
359 | struct i2c_client *client = to_i2c_client(dev); | ||
360 | long val = simple_strtol(buf, NULL, 10); | ||
361 | |||
362 | switch (val) { | ||
363 | case 0: | ||
364 | client->flags &= ~I2C_CLIENT_PEC; | ||
365 | break; | ||
366 | case 1: | ||
367 | client->flags |= I2C_CLIENT_PEC; | ||
368 | break; | ||
369 | default: | ||
370 | return -EINVAL; | ||
371 | } | ||
372 | |||
373 | return count; | ||
374 | } | ||
375 | |||
376 | static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); | ||
377 | |||
348 | /* | 378 | /* |
349 | * Real code | 379 | * Real code |
350 | */ | 380 | */ |
351 | 381 | ||
382 | /* The ADM1032 supports PEC but not on write byte transactions, so we need | ||
383 | to explicitely ask for a transaction without PEC. */ | ||
384 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) | ||
385 | { | ||
386 | return i2c_smbus_xfer(client->adapter, client->addr, | ||
387 | client->flags & ~I2C_CLIENT_PEC, | ||
388 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); | ||
389 | } | ||
390 | |||
391 | /* It is assumed that client->update_lock is held (unless we are in | ||
392 | detection or initialization steps). This matters when PEC is enabled, | ||
393 | because we don't want the address pointer to change between the write | ||
394 | byte and the read byte transactions. */ | ||
395 | static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) | ||
396 | { | ||
397 | int err; | ||
398 | |||
399 | if (client->flags & I2C_CLIENT_PEC) { | ||
400 | err = adm1032_write_byte(client, reg); | ||
401 | if (err >= 0) | ||
402 | err = i2c_smbus_read_byte(client); | ||
403 | } else | ||
404 | err = i2c_smbus_read_byte_data(client, reg); | ||
405 | |||
406 | if (err < 0) { | ||
407 | dev_warn(&client->dev, "Register %#02x read failed (%d)\n", | ||
408 | reg, err); | ||
409 | return err; | ||
410 | } | ||
411 | *value = err; | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
352 | static int lm90_attach_adapter(struct i2c_adapter *adapter) | 416 | static int lm90_attach_adapter(struct i2c_adapter *adapter) |
353 | { | 417 | { |
354 | if (!(adapter->class & I2C_CLASS_HWMON)) | 418 | if (!(adapter->class & I2C_CLASS_HWMON)) |
@@ -370,11 +434,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
370 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 434 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
371 | goto exit; | 435 | goto exit; |
372 | 436 | ||
373 | if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { | 437 | if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) { |
374 | err = -ENOMEM; | 438 | err = -ENOMEM; |
375 | goto exit; | 439 | goto exit; |
376 | } | 440 | } |
377 | memset(data, 0, sizeof(struct lm90_data)); | ||
378 | 441 | ||
379 | /* The common I2C client data is placed right before the | 442 | /* The common I2C client data is placed right before the |
380 | LM90-specific data. */ | 443 | LM90-specific data. */ |
@@ -403,20 +466,22 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
403 | if (kind < 0) { /* detection and identification */ | 466 | if (kind < 0) { /* detection and identification */ |
404 | u8 man_id, chip_id, reg_config1, reg_convrate; | 467 | u8 man_id, chip_id, reg_config1, reg_convrate; |
405 | 468 | ||
406 | man_id = i2c_smbus_read_byte_data(new_client, | 469 | if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID, |
407 | LM90_REG_R_MAN_ID); | 470 | &man_id) < 0 |
408 | chip_id = i2c_smbus_read_byte_data(new_client, | 471 | || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID, |
409 | LM90_REG_R_CHIP_ID); | 472 | &chip_id) < 0 |
410 | reg_config1 = i2c_smbus_read_byte_data(new_client, | 473 | || lm90_read_reg(new_client, LM90_REG_R_CONFIG1, |
411 | LM90_REG_R_CONFIG1); | 474 | ®_config1) < 0 |
412 | reg_convrate = i2c_smbus_read_byte_data(new_client, | 475 | || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, |
413 | LM90_REG_R_CONVRATE); | 476 | ®_convrate) < 0) |
477 | goto exit_free; | ||
414 | 478 | ||
415 | if (man_id == 0x01) { /* National Semiconductor */ | 479 | if (man_id == 0x01) { /* National Semiconductor */ |
416 | u8 reg_config2; | 480 | u8 reg_config2; |
417 | 481 | ||
418 | reg_config2 = i2c_smbus_read_byte_data(new_client, | 482 | if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, |
419 | LM90_REG_R_CONFIG2); | 483 | ®_config2) < 0) |
484 | goto exit_free; | ||
420 | 485 | ||
421 | if ((reg_config1 & 0x2A) == 0x00 | 486 | if ((reg_config1 & 0x2A) == 0x00 |
422 | && (reg_config2 & 0xF8) == 0x00 | 487 | && (reg_config2 & 0xF8) == 0x00 |
@@ -435,14 +500,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
435 | } | 500 | } |
436 | } else | 501 | } else |
437 | if (man_id == 0x41) { /* Analog Devices */ | 502 | if (man_id == 0x41) { /* Analog Devices */ |
438 | if (address == 0x4C | 503 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
439 | && (chip_id & 0xF0) == 0x40 /* ADM1032 */ | ||
440 | && (reg_config1 & 0x3F) == 0x00 | 504 | && (reg_config1 & 0x3F) == 0x00 |
441 | && reg_convrate <= 0x0A) { | 505 | && reg_convrate <= 0x0A) { |
442 | kind = adm1032; | 506 | kind = adm1032; |
443 | } else | 507 | } else |
444 | if (address == 0x4c | 508 | if (chip_id == 0x51 /* ADT7461 */ |
445 | && chip_id == 0x51 /* ADT7461 */ | ||
446 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ | 509 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ |
447 | && reg_convrate <= 0x0A) { | 510 | && reg_convrate <= 0x0A) { |
448 | kind = adt7461; | 511 | kind = adt7461; |
@@ -477,6 +540,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
477 | name = "lm90"; | 540 | name = "lm90"; |
478 | } else if (kind == adm1032) { | 541 | } else if (kind == adm1032) { |
479 | name = "adm1032"; | 542 | name = "adm1032"; |
543 | /* The ADM1032 supports PEC, but only if combined | ||
544 | transactions are not used. */ | ||
545 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
546 | new_client->flags |= I2C_CLIENT_PEC; | ||
480 | } else if (kind == lm99) { | 547 | } else if (kind == lm99) { |
481 | name = "lm99"; | 548 | name = "lm99"; |
482 | } else if (kind == lm86) { | 549 | } else if (kind == lm86) { |
@@ -529,6 +596,9 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
529 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | 596 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); |
530 | device_create_file(&new_client->dev, &dev_attr_alarms); | 597 | device_create_file(&new_client->dev, &dev_attr_alarms); |
531 | 598 | ||
599 | if (new_client->flags & I2C_CLIENT_PEC) | ||
600 | device_create_file(&new_client->dev, &dev_attr_pec); | ||
601 | |||
532 | return 0; | 602 | return 0; |
533 | 603 | ||
534 | exit_detach: | 604 | exit_detach: |
@@ -548,7 +618,10 @@ static void lm90_init_client(struct i2c_client *client) | |||
548 | */ | 618 | */ |
549 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, | 619 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, |
550 | 5); /* 2 Hz */ | 620 | 5); /* 2 Hz */ |
551 | config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1); | 621 | if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { |
622 | dev_warn(&client->dev, "Initialization failed!\n"); | ||
623 | return; | ||
624 | } | ||
552 | if (config & 0x40) | 625 | if (config & 0x40) |
553 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, | 626 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, |
554 | config & 0xBF); /* run */ | 627 | config & 0xBF); /* run */ |
@@ -576,21 +649,15 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
576 | down(&data->update_lock); | 649 | down(&data->update_lock); |
577 | 650 | ||
578 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
579 | u8 oldh, newh; | 652 | u8 oldh, newh, l; |
580 | 653 | ||
581 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 654 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
582 | data->temp8[0] = i2c_smbus_read_byte_data(client, | 655 | lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, &data->temp8[0]); |
583 | LM90_REG_R_LOCAL_TEMP); | 656 | lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[1]); |
584 | data->temp8[1] = i2c_smbus_read_byte_data(client, | 657 | lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[2]); |
585 | LM90_REG_R_LOCAL_LOW); | 658 | lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[3]); |
586 | data->temp8[2] = i2c_smbus_read_byte_data(client, | 659 | lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[4]); |
587 | LM90_REG_R_LOCAL_HIGH); | 660 | lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); |
588 | data->temp8[3] = i2c_smbus_read_byte_data(client, | ||
589 | LM90_REG_R_LOCAL_CRIT); | ||
590 | data->temp8[4] = i2c_smbus_read_byte_data(client, | ||
591 | LM90_REG_R_REMOTE_CRIT); | ||
592 | data->temp_hyst = i2c_smbus_read_byte_data(client, | ||
593 | LM90_REG_R_TCRIT_HYST); | ||
594 | 661 | ||
595 | /* | 662 | /* |
596 | * There is a trick here. We have to read two registers to | 663 | * There is a trick here. We have to read two registers to |
@@ -606,36 +673,20 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
606 | * then we have a valid reading. Else we have to read the low | 673 | * then we have a valid reading. Else we have to read the low |
607 | * byte again, and now we believe we have a correct reading. | 674 | * byte again, and now we believe we have a correct reading. |
608 | */ | 675 | */ |
609 | oldh = i2c_smbus_read_byte_data(client, | 676 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &oldh) == 0 |
610 | LM90_REG_R_REMOTE_TEMPH); | 677 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0 |
611 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 678 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &newh) == 0 |
612 | LM90_REG_R_REMOTE_TEMPL); | 679 | && (newh == oldh |
613 | newh = i2c_smbus_read_byte_data(client, | 680 | || lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0)) |
614 | LM90_REG_R_REMOTE_TEMPH); | 681 | data->temp11[0] = (newh << 8) | l; |
615 | if (newh != oldh) { | 682 | |
616 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 683 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &newh) == 0 |
617 | LM90_REG_R_REMOTE_TEMPL); | 684 | && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0) |
618 | #ifdef DEBUG | 685 | data->temp11[1] = (newh << 8) | l; |
619 | oldh = i2c_smbus_read_byte_data(client, | 686 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0 |
620 | LM90_REG_R_REMOTE_TEMPH); | 687 | && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) |
621 | /* oldh is actually newer */ | 688 | data->temp11[2] = (newh << 8) | l; |
622 | if (newh != oldh) | 689 | lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); |
623 | dev_warn(&client->dev, "Remote temperature may be " | ||
624 | "wrong.\n"); | ||
625 | #endif | ||
626 | } | ||
627 | data->temp11[0] |= (newh << 8); | ||
628 | |||
629 | data->temp11[1] = (i2c_smbus_read_byte_data(client, | ||
630 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
631 | i2c_smbus_read_byte_data(client, | ||
632 | LM90_REG_R_REMOTE_LOWL); | ||
633 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
634 | LM90_REG_R_REMOTE_HIGHH) << 8) + | ||
635 | i2c_smbus_read_byte_data(client, | ||
636 | LM90_REG_R_REMOTE_HIGHL); | ||
637 | data->alarms = i2c_smbus_read_byte_data(client, | ||
638 | LM90_REG_R_STATUS); | ||
639 | 690 | ||
640 | data->last_updated = jiffies; | 691 | data->last_updated = jiffies; |
641 | data->valid = 1; | 692 | data->valid = 1; |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 647b7c7cd575..7a4b3701ed1a 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -300,11 +300,10 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | | I2C_FUNC_SMBUS_WORD_DATA)) | 300 | | I2C_FUNC_SMBUS_WORD_DATA)) |
301 | goto exit; | 301 | goto exit; |
302 | 302 | ||
303 | if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { | 303 | if (!(data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL))) { |
304 | err = -ENOMEM; | 304 | err = -ENOMEM; |
305 | goto exit; | 305 | goto exit; |
306 | } | 306 | } |
307 | memset(data, 0, sizeof(struct lm92_data)); | ||
308 | 307 | ||
309 | /* Fill in enough client fields so that we can read from the chip, | 308 | /* Fill in enough client fields so that we can read from the chip, |
310 | which is required for identication */ | 309 | which is required for identication */ |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 16bf71f3a04d..6a82ffae1bfd 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -197,11 +197,10 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
198 | goto exit; | 198 | goto exit; |
199 | 199 | ||
200 | if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { | 200 | if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) { |
201 | err = -ENOMEM; | 201 | err = -ENOMEM; |
202 | goto exit; | 202 | goto exit; |
203 | } | 203 | } |
204 | memset(data, 0, sizeof(struct max1619_data)); | ||
205 | 204 | ||
206 | /* The common I2C client data is placed right before the | 205 | /* The common I2C client data is placed right before the |
207 | MAX1619-specific data. */ | 206 | MAX1619-specific data. */ |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index cf2a35799c7c..17f745a23d04 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -754,9 +754,8 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
754 | const char *name = "pc87360"; | 754 | const char *name = "pc87360"; |
755 | int use_thermistors = 0; | 755 | int use_thermistors = 0; |
756 | 756 | ||
757 | if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 757 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
758 | return -ENOMEM; | 758 | return -ENOMEM; |
759 | memset(data, 0x00, sizeof(struct pc87360_data)); | ||
760 | 759 | ||
761 | new_client = &data->client; | 760 | new_client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 761 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 21aa9a41f62c..9c6cadec1087 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -518,11 +518,10 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
518 | goto exit_release; | 518 | goto exit_release; |
519 | } | 519 | } |
520 | 520 | ||
521 | if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { | 521 | if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { |
522 | err = -ENOMEM; | 522 | err = -ENOMEM; |
523 | goto exit_release; | 523 | goto exit_release; |
524 | } | 524 | } |
525 | memset(data, 0, sizeof(struct sis5595_data)); | ||
526 | 525 | ||
527 | new_client = &data->client; | 526 | new_client = &data->client; |
528 | new_client->addr = address; | 527 | new_client->addr = address; |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 7fe71576dea4..2a3e21b5b6b4 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -244,11 +244,10 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
244 | return -EBUSY; | 244 | return -EBUSY; |
245 | } | 245 | } |
246 | 246 | ||
247 | if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { | 247 | if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { |
248 | err = -ENOMEM; | 248 | err = -ENOMEM; |
249 | goto error_release; | 249 | goto error_release; |
250 | } | 250 | } |
251 | memset(data, 0x00, sizeof(struct smsc47b397_data)); | ||
252 | 251 | ||
253 | new_client = &data->client; | 252 | new_client = &data->client; |
254 | i2c_set_clientdata(new_client, data); | 253 | i2c_set_clientdata(new_client, data); |
@@ -299,7 +298,7 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
299 | superio_enter(); | 298 | superio_enter(); |
300 | id = superio_inb(SUPERIO_REG_DEVID); | 299 | id = superio_inb(SUPERIO_REG_DEVID); |
301 | 300 | ||
302 | if (id != 0x6f) { | 301 | if ((id != 0x6f) && (id != 0x81)) { |
303 | superio_exit(); | 302 | superio_exit(); |
304 | return -ENODEV; | 303 | return -ENODEV; |
305 | } | 304 | } |
@@ -310,8 +309,9 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
310 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) | 309 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) |
311 | | superio_inb(SUPERIO_REG_BASE_LSB); | 310 | | superio_inb(SUPERIO_REG_BASE_LSB); |
312 | 311 | ||
313 | printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " | 312 | printk(KERN_INFO "smsc47b397: found SMSC %s " |
314 | "(base address 0x%04x, revision %u)\n", *addr, rev); | 313 | "(base address 0x%04x, revision %u)\n", |
314 | id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev); | ||
315 | 315 | ||
316 | superio_exit(); | 316 | superio_exit(); |
317 | return 0; | 317 | return 0; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index c9cc683eba4a..5905c1af88f2 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -3,7 +3,7 @@ | |||
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, | 5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, |
6 | LPC47M15x and LPC47M192 Super-I/O chips. | 6 | LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. |
7 | 7 | ||
8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> |
@@ -356,6 +356,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
358 | * can do much more besides (device id 0x60). | 358 | * can do much more besides (device id 0x60). |
359 | * The LPC47M997 is undocumented, but seems to be compatible with | ||
360 | * the LPC47M192, and has the same device id. | ||
359 | */ | 361 | */ |
360 | if (val == 0x51) | 362 | if (val == 0x51) |
361 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); | 363 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
@@ -364,7 +366,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
364 | else if (val == 0x5F) | 366 | else if (val == 0x5F) |
365 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); | 367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
366 | else if (val == 0x60) | 368 | else if (val == 0x60) |
367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | 369 | printk(KERN_INFO "smsc47m1: Found SMSC " |
370 | "LPC47M15x/LPC47M192/LPC47M997\n"); | ||
368 | else { | 371 | else { |
369 | superio_exit(); | 372 | superio_exit(); |
370 | return -ENODEV; | 373 | return -ENODEV; |
@@ -396,11 +399,10 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
396 | return -EBUSY; | 399 | return -EBUSY; |
397 | } | 400 | } |
398 | 401 | ||
399 | if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { | 402 | if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { |
400 | err = -ENOMEM; | 403 | err = -ENOMEM; |
401 | goto error_release; | 404 | goto error_release; |
402 | } | 405 | } |
403 | memset(data, 0x00, sizeof(struct smsc47m1_data)); | ||
404 | 406 | ||
405 | new_client = &data->client; | 407 | new_client = &data->client; |
406 | i2c_set_clientdata(new_client, data); | 408 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 05ddc88e7dd2..6f696f897176 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | /* If force_addr is set to anything different from 0, we forcibly enable | 45 | /* If force_addr is set to anything different from 0, we forcibly enable |
46 | the device at the given address. */ | 46 | the device at the given address. */ |
47 | static unsigned short force_addr = 0; | 47 | static unsigned short force_addr; |
48 | module_param(force_addr, ushort, 0); | 48 | module_param(force_addr, ushort, 0); |
49 | MODULE_PARM_DESC(force_addr, | 49 | MODULE_PARM_DESC(force_addr, |
50 | "Initialize the base address of the sensors"); | 50 | "Initialize the base address of the sensors"); |
@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
198 | but the function is very linear in the useful range (0-80 deg C), so | 198 | but the function is very linear in the useful range (0-80 deg C), so |
199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
200 | is the temp at via register values 0-255: */ | 200 | is the temp at via register values 0-255: */ |
201 | static const long tempLUT[] = | 201 | static const s16 tempLUT[] = |
202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /* for 8-bit temperature hyst and over registers */ | 272 | /* for 8-bit temperature hyst and over registers */ |
273 | #define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) | 273 | #define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100) |
274 | 274 | ||
275 | /* for 10-bit temperature readings */ | 275 | /* for 10-bit temperature readings */ |
276 | static inline long TEMP_FROM_REG10(u16 val) | 276 | static inline long TEMP_FROM_REG10(u16 val) |
@@ -589,10 +589,8 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
589 | u16 val; | 589 | u16 val; |
590 | 590 | ||
591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
592 | if (force_addr) | ||
593 | address = force_addr & 0xFF00; | ||
594 | |||
595 | if (force_addr) { | 592 | if (force_addr) { |
593 | address = force_addr & 0xFF00; | ||
596 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", | 594 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
597 | address); | 595 | address); |
598 | if (PCIBIOS_SUCCESSFUL != | 596 | if (PCIBIOS_SUCCESSFUL != |
@@ -603,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
603 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 601 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
604 | return -ENODEV; | 602 | return -ENODEV; |
605 | if (!(val & 0x0001)) { | 603 | if (!(val & 0x0001)) { |
606 | dev_warn(&adapter->dev, "enabling sensors\n"); | 604 | if (force_addr) { |
607 | if (PCIBIOS_SUCCESSFUL != | 605 | dev_info(&adapter->dev, "enabling sensors\n"); |
608 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 606 | if (PCIBIOS_SUCCESSFUL != |
609 | val | 0x0001)) | 607 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
608 | val | 0x0001)) | ||
609 | return -ENODEV; | ||
610 | } else { | ||
611 | dev_warn(&adapter->dev, "sensors disabled - enable " | ||
612 | "with force_addr=0x%x\n", address); | ||
610 | return -ENODEV; | 613 | return -ENODEV; |
614 | } | ||
611 | } | 615 | } |
612 | 616 | ||
613 | /* Reserve the ISA region */ | 617 | /* Reserve the ISA region */ |
@@ -617,11 +621,10 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
617 | return -ENODEV; | 621 | return -ENODEV; |
618 | } | 622 | } |
619 | 623 | ||
620 | if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { | 624 | if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) { |
621 | err = -ENOMEM; | 625 | err = -ENOMEM; |
622 | goto exit_release; | 626 | goto exit_release; |
623 | } | 627 | } |
624 | memset(data, 0, sizeof(struct via686a_data)); | ||
625 | 628 | ||
626 | new_client = &data->client; | 629 | new_client = &data->client; |
627 | i2c_set_clientdata(new_client, data); | 630 | i2c_set_clientdata(new_client, data); |
@@ -708,7 +711,6 @@ static int via686a_detach_client(struct i2c_client *client) | |||
708 | return 0; | 711 | return 0; |
709 | } | 712 | } |
710 | 713 | ||
711 | /* Called when we have found a new VIA686A. Set limits, etc. */ | ||
712 | static void via686a_init_client(struct i2c_client *client) | 714 | static void via686a_init_client(struct i2c_client *client) |
713 | { | 715 | { |
714 | u8 reg; | 716 | u8 reg; |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index b60efe8f8b26..eee22a57e929 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -105,7 +105,9 @@ superio_exit(void) | |||
105 | * ISA constants | 105 | * ISA constants |
106 | */ | 106 | */ |
107 | 107 | ||
108 | #define REGION_LENGTH 8 | 108 | #define REGION_ALIGNMENT ~7 |
109 | #define REGION_OFFSET 5 | ||
110 | #define REGION_LENGTH 2 | ||
109 | #define ADDR_REG_OFFSET 5 | 111 | #define ADDR_REG_OFFSET 5 |
110 | #define DATA_REG_OFFSET 6 | 112 | #define DATA_REG_OFFSET 6 |
111 | 113 | ||
@@ -673,16 +675,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | struct w83627ehf_data *data; | 675 | struct w83627ehf_data *data; |
674 | int i, err = 0; | 676 | int i, err = 0; |
675 | 677 | ||
676 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | 678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
679 | w83627ehf_driver.name)) { | ||
677 | err = -EBUSY; | 680 | err = -EBUSY; |
678 | goto exit; | 681 | goto exit; |
679 | } | 682 | } |
680 | 683 | ||
681 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | 684 | if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { |
682 | err = -ENOMEM; | 685 | err = -ENOMEM; |
683 | goto exit_release; | 686 | goto exit_release; |
684 | } | 687 | } |
685 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
686 | 688 | ||
687 | client = &data->client; | 689 | client = &data->client; |
688 | i2c_set_clientdata(client, data); | 690 | i2c_set_clientdata(client, data); |
@@ -762,7 +764,7 @@ exit_detach: | |||
762 | exit_free: | 764 | exit_free: |
763 | kfree(data); | 765 | kfree(data); |
764 | exit_release: | 766 | exit_release: |
765 | release_region(address, REGION_LENGTH); | 767 | release_region(address + REGION_OFFSET, REGION_LENGTH); |
766 | exit: | 768 | exit: |
767 | return err; | 769 | return err; |
768 | } | 770 | } |
@@ -776,7 +778,7 @@ static int w83627ehf_detach_client(struct i2c_client *client) | |||
776 | 778 | ||
777 | if ((err = i2c_detach_client(client))) | 779 | if ((err = i2c_detach_client(client))) |
778 | return err; | 780 | return err; |
779 | release_region(client->addr, REGION_LENGTH); | 781 | release_region(client->addr + REGION_OFFSET, REGION_LENGTH); |
780 | kfree(data); | 782 | kfree(data); |
781 | 783 | ||
782 | return 0; | 784 | return 0; |
@@ -807,7 +809,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr) | |||
807 | superio_select(W83627EHF_LD_HWM); | 809 | superio_select(W83627EHF_LD_HWM); |
808 | val = (superio_inb(SIO_REG_ADDR) << 8) | 810 | val = (superio_inb(SIO_REG_ADDR) << 8) |
809 | | superio_inb(SIO_REG_ADDR + 1); | 811 | | superio_inb(SIO_REG_ADDR + 1); |
810 | *addr = val & ~(REGION_LENGTH - 1); | 812 | *addr = val & REGION_ALIGNMENT; |
811 | if (*addr == 0) { | 813 | if (*addr == 0) { |
812 | superio_exit(); | 814 | superio_exit(); |
813 | return -ENODEV; | 815 | return -ENODEV; |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 3479dc5208e2..70ef926c3bd8 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -142,10 +142,14 @@ superio_exit(void) | |||
142 | #define WINB_BASE_REG 0x60 | 142 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 143 | /* Constants specified below */ |
144 | 144 | ||
145 | /* Length of ISA address segment */ | 145 | /* Alignment of the base address */ |
146 | #define WINB_EXTENT 8 | 146 | #define WINB_ALIGNMENT ~7 |
147 | 147 | ||
148 | /* Where are the ISA address/data registers relative to the base address */ | 148 | /* Offset & size of I/O region we are interested in */ |
149 | #define WINB_REGION_OFFSET 5 | ||
150 | #define WINB_REGION_SIZE 2 | ||
151 | |||
152 | /* Where are the sensors address/data registers relative to the base address */ | ||
149 | #define W83781D_ADDR_REG_OFFSET 5 | 153 | #define W83781D_ADDR_REG_OFFSET 5 |
150 | #define W83781D_DATA_REG_OFFSET 6 | 154 | #define W83781D_DATA_REG_OFFSET 6 |
151 | 155 | ||
@@ -197,7 +201,6 @@ superio_exit(void) | |||
197 | 201 | ||
198 | #define W83627HF_REG_PWM1 0x5A | 202 | #define W83627HF_REG_PWM1 0x5A |
199 | #define W83627HF_REG_PWM2 0x5B | 203 | #define W83627HF_REG_PWM2 0x5B |
200 | #define W83627HF_REG_PWMCLK12 0x5C | ||
201 | 204 | ||
202 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 205 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ |
203 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 206 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ |
@@ -981,7 +984,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
981 | superio_select(W83627HF_LD_HWM); | 984 | superio_select(W83627HF_LD_HWM); |
982 | val = (superio_inb(WINB_BASE_REG) << 8) | | 985 | val = (superio_inb(WINB_BASE_REG) << 8) | |
983 | superio_inb(WINB_BASE_REG + 1); | 986 | superio_inb(WINB_BASE_REG + 1); |
984 | *addr = val & ~(WINB_EXTENT - 1); | 987 | *addr = val & WINB_ALIGNMENT; |
985 | if (*addr == 0 && force_addr == 0) { | 988 | if (*addr == 0 && force_addr == 0) { |
986 | superio_exit(); | 989 | superio_exit(); |
987 | return -ENODEV; | 990 | return -ENODEV; |
@@ -1000,9 +1003,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1000 | const char *client_name = ""; | 1003 | const char *client_name = ""; |
1001 | 1004 | ||
1002 | if(force_addr) | 1005 | if(force_addr) |
1003 | address = force_addr & ~(WINB_EXTENT - 1); | 1006 | address = force_addr & WINB_ALIGNMENT; |
1004 | 1007 | ||
1005 | if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { | 1008 | if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, |
1009 | w83627hf_driver.name)) { | ||
1006 | err = -EBUSY; | 1010 | err = -EBUSY; |
1007 | goto ERROR0; | 1011 | goto ERROR0; |
1008 | } | 1012 | } |
@@ -1041,11 +1045,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1041 | client structure, even though we cannot fill it completely yet. | 1045 | client structure, even though we cannot fill it completely yet. |
1042 | But it allows us to access w83627hf_{read,write}_value. */ | 1046 | But it allows us to access w83627hf_{read,write}_value. */ |
1043 | 1047 | ||
1044 | if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { | 1048 | if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { |
1045 | err = -ENOMEM; | 1049 | err = -ENOMEM; |
1046 | goto ERROR1; | 1050 | goto ERROR1; |
1047 | } | 1051 | } |
1048 | memset(data, 0, sizeof(struct w83627hf_data)); | ||
1049 | 1052 | ||
1050 | new_client = &data->client; | 1053 | new_client = &data->client; |
1051 | i2c_set_clientdata(new_client, data); | 1054 | i2c_set_clientdata(new_client, data); |
@@ -1148,7 +1151,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1148 | ERROR2: | 1151 | ERROR2: |
1149 | kfree(data); | 1152 | kfree(data); |
1150 | ERROR1: | 1153 | ERROR1: |
1151 | release_region(address, WINB_EXTENT); | 1154 | release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1152 | ERROR0: | 1155 | ERROR0: |
1153 | return err; | 1156 | return err; |
1154 | } | 1157 | } |
@@ -1163,7 +1166,7 @@ static int w83627hf_detach_client(struct i2c_client *client) | |||
1163 | if ((err = i2c_detach_client(client))) | 1166 | if ((err = i2c_detach_client(client))) |
1164 | return err; | 1167 | return err; |
1165 | 1168 | ||
1166 | release_region(client->addr, WINB_EXTENT); | 1169 | release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1167 | kfree(data); | 1170 | kfree(data); |
1168 | 1171 | ||
1169 | return 0; | 1172 | return 0; |
@@ -1275,7 +1278,6 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1275 | return 0; | 1278 | return 0; |
1276 | } | 1279 | } |
1277 | 1280 | ||
1278 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1279 | static void w83627hf_init_client(struct i2c_client *client) | 1281 | static void w83627hf_init_client(struct i2c_client *client) |
1280 | { | 1282 | { |
1281 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1283 | struct w83627hf_data *data = i2c_get_clientdata(client); |
@@ -1369,12 +1371,6 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1369 | } | 1371 | } |
1370 | } | 1372 | } |
1371 | 1373 | ||
1372 | if (type == w83627hf) { | ||
1373 | /* enable PWM2 control (can't hurt since PWM reg | ||
1374 | should have been reset to 0xff) */ | ||
1375 | w83627hf_write_value(client, W83627HF_REG_PWMCLK12, | ||
1376 | 0x19); | ||
1377 | } | ||
1378 | /* enable comparator mode for temp2 and temp3 so | 1374 | /* enable comparator mode for temp2 and temp3 so |
1379 | alarm indication will work correctly */ | 1375 | alarm indication will work correctly */ |
1380 | i = w83627hf_read_value(client, W83781D_REG_IRQ); | 1376 | i = w83627hf_read_value(client, W83781D_REG_IRQ); |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 4c43337ca780..9265f32122fa 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -889,12 +889,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
889 | const char *client_name = ""; | 889 | const char *client_name = ""; |
890 | struct w83781d_data *data = i2c_get_clientdata(new_client); | 890 | struct w83781d_data *data = i2c_get_clientdata(new_client); |
891 | 891 | ||
892 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 892 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
893 | if (!(data->lm75[0])) { | 893 | if (!(data->lm75[0])) { |
894 | err = -ENOMEM; | 894 | err = -ENOMEM; |
895 | goto ERROR_SC_0; | 895 | goto ERROR_SC_0; |
896 | } | 896 | } |
897 | memset(data->lm75[0], 0x00, sizeof (struct i2c_client)); | ||
898 | 897 | ||
899 | id = i2c_adapter_id(adapter); | 898 | id = i2c_adapter_id(adapter); |
900 | 899 | ||
@@ -919,13 +918,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
919 | } | 918 | } |
920 | 919 | ||
921 | if (kind != w83783s) { | 920 | if (kind != w83783s) { |
922 | 921 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | |
923 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
924 | if (!(data->lm75[1])) { | 922 | if (!(data->lm75[1])) { |
925 | err = -ENOMEM; | 923 | err = -ENOMEM; |
926 | goto ERROR_SC_1; | 924 | goto ERROR_SC_1; |
927 | } | 925 | } |
928 | memset(data->lm75[1], 0x0, sizeof(struct i2c_client)); | ||
929 | 926 | ||
930 | if (force_subclients[0] == id && | 927 | if (force_subclients[0] == id && |
931 | force_subclients[1] == address) { | 928 | force_subclients[1] == address) { |
@@ -1064,11 +1061,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1064 | client structure, even though we cannot fill it completely yet. | 1061 | client structure, even though we cannot fill it completely yet. |
1065 | But it allows us to access w83781d_{read,write}_value. */ | 1062 | But it allows us to access w83781d_{read,write}_value. */ |
1066 | 1063 | ||
1067 | if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { | 1064 | if (!(data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { |
1068 | err = -ENOMEM; | 1065 | err = -ENOMEM; |
1069 | goto ERROR1; | 1066 | goto ERROR1; |
1070 | } | 1067 | } |
1071 | memset(data, 0, sizeof(struct w83781d_data)); | ||
1072 | 1068 | ||
1073 | new_client = &data->client; | 1069 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
@@ -1451,7 +1447,6 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1451 | return 0; | 1447 | return 0; |
1452 | } | 1448 | } |
1453 | 1449 | ||
1454 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1455 | static void | 1450 | static void |
1456 | w83781d_init_client(struct i2c_client *client) | 1451 | w83781d_init_client(struct i2c_client *client) |
1457 | { | 1452 | { |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ba0c28015f6a..4be59dbb78c4 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1086,11 +1086,10 @@ w83792d_create_subclient(struct i2c_adapter *adapter, | |||
1086 | int err; | 1086 | int err; |
1087 | struct i2c_client *sub_client; | 1087 | struct i2c_client *sub_client; |
1088 | 1088 | ||
1089 | (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 1089 | (*sub_cli) = sub_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
1090 | if (!(sub_client)) { | 1090 | if (!(sub_client)) { |
1091 | return -ENOMEM; | 1091 | return -ENOMEM; |
1092 | } | 1092 | } |
1093 | memset(sub_client, 0x00, sizeof(struct i2c_client)); | ||
1094 | sub_client->addr = 0x48 + addr; | 1093 | sub_client->addr = 0x48 + addr; |
1095 | i2c_set_clientdata(sub_client, NULL); | 1094 | i2c_set_clientdata(sub_client, NULL); |
1096 | sub_client->adapter = adapter; | 1095 | sub_client->adapter = adapter; |
@@ -1184,11 +1183,10 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | client structure, even though we cannot fill it completely yet. | 1183 | client structure, even though we cannot fill it completely yet. |
1185 | But it allows us to access w83792d_{read,write}_value. */ | 1184 | But it allows us to access w83792d_{read,write}_value. */ |
1186 | 1185 | ||
1187 | if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { | 1186 | if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { |
1188 | err = -ENOMEM; | 1187 | err = -ENOMEM; |
1189 | goto ERROR0; | 1188 | goto ERROR0; |
1190 | } | 1189 | } |
1191 | memset(data, 0, sizeof(struct w83792d_data)); | ||
1192 | 1190 | ||
1193 | new_client = &data->client; | 1191 | new_client = &data->client; |
1194 | i2c_set_clientdata(new_client, data); | 1192 | i2c_set_clientdata(new_client, data); |
@@ -1429,7 +1427,6 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
1429 | return 0; | 1427 | return 0; |
1430 | } | 1428 | } |
1431 | 1429 | ||
1432 | /* Called when we have found a new W83792D. It should set limits, etc. */ | ||
1433 | static void | 1430 | static void |
1434 | w83792d_init_client(struct i2c_client *client) | 1431 | w83792d_init_client(struct i2c_client *client) |
1435 | { | 1432 | { |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 133e34ab1d0a..f495b6378668 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/jiffies.h> | 37 | #include <linux/jiffies.h> |
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | ||
40 | #include <linux/err.h> | 41 | #include <linux/err.h> |
41 | 42 | ||
42 | /* How many retries on register read error */ | 43 | /* How many retries on register read error */ |
@@ -73,7 +74,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts); | |||
73 | * The W83L785TS-S uses signed 8-bit values. | 74 | * The W83L785TS-S uses signed 8-bit values. |
74 | */ | 75 | */ |
75 | 76 | ||
76 | #define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) | 77 | #define TEMP_FROM_REG(val) ((val) * 1000) |
77 | 78 | ||
78 | /* | 79 | /* |
79 | * Functions declaration | 80 | * Functions declaration |
@@ -111,27 +112,24 @@ struct w83l785ts_data { | |||
111 | unsigned long last_updated; /* in jiffies */ | 112 | unsigned long last_updated; /* in jiffies */ |
112 | 113 | ||
113 | /* registers values */ | 114 | /* registers values */ |
114 | u8 temp, temp_over; | 115 | s8 temp[2]; /* 0: input |
116 | 1: critical limit */ | ||
115 | }; | 117 | }; |
116 | 118 | ||
117 | /* | 119 | /* |
118 | * Sysfs stuff | 120 | * Sysfs stuff |
119 | */ | 121 | */ |
120 | 122 | ||
121 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) | 123 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
124 | char *buf) | ||
122 | { | 125 | { |
126 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
123 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | 127 | struct w83l785ts_data *data = w83l785ts_update_device(dev); |
124 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 128 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); |
125 | } | 129 | } |
126 | 130 | ||
127 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) | 131 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
128 | { | 132 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1); |
129 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | ||
130 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | ||
131 | } | ||
132 | |||
133 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
134 | static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL); | ||
135 | 133 | ||
136 | /* | 134 | /* |
137 | * Real code | 135 | * Real code |
@@ -158,12 +156,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
158 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 156 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
159 | goto exit; | 157 | goto exit; |
160 | 158 | ||
161 | if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { | 159 | if (!(data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { |
162 | err = -ENOMEM; | 160 | err = -ENOMEM; |
163 | goto exit; | 161 | goto exit; |
164 | } | 162 | } |
165 | memset(data, 0, sizeof(struct w83l785ts_data)); | ||
166 | |||
167 | 163 | ||
168 | /* The common I2C client data is placed right before the | 164 | /* The common I2C client data is placed right before the |
169 | * W83L785TS-specific data. */ | 165 | * W83L785TS-specific data. */ |
@@ -228,7 +224,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
228 | init_MUTEX(&data->update_lock); | 224 | init_MUTEX(&data->update_lock); |
229 | 225 | ||
230 | /* Default values in case the first read fails (unlikely). */ | 226 | /* Default values in case the first read fails (unlikely). */ |
231 | data->temp_over = data->temp = 0; | 227 | data->temp[1] = data->temp[0] = 0; |
232 | 228 | ||
233 | /* Tell the I2C layer a new client has arrived. */ | 229 | /* Tell the I2C layer a new client has arrived. */ |
234 | if ((err = i2c_attach_client(new_client))) | 230 | if ((err = i2c_attach_client(new_client))) |
@@ -246,8 +242,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
246 | goto exit_detach; | 242 | goto exit_detach; |
247 | } | 243 | } |
248 | 244 | ||
249 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 245 | device_create_file(&new_client->dev, |
250 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 246 | &sensor_dev_attr_temp1_input.dev_attr); |
247 | device_create_file(&new_client->dev, | ||
248 | &sensor_dev_attr_temp1_max.dev_attr); | ||
251 | 249 | ||
252 | return 0; | 250 | return 0; |
253 | 251 | ||
@@ -305,10 +303,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
305 | 303 | ||
306 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
307 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
308 | data->temp = w83l785ts_read_value(client, | 306 | data->temp[0] = w83l785ts_read_value(client, |
309 | W83L785TS_REG_TEMP, data->temp); | 307 | W83L785TS_REG_TEMP, data->temp[0]); |
310 | data->temp_over = w83l785ts_read_value(client, | 308 | data->temp[1] = w83l785ts_read_value(client, |
311 | W83L785TS_REG_TEMP_OVER, data->temp_over); | 309 | W83L785TS_REG_TEMP_OVER, data->temp[1]); |
312 | 310 | ||
313 | data->last_updated = jiffies; | 311 | data->last_updated = jiffies; |
314 | data->valid = 1; | 312 | data->valid = 1; |
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index beb10edfe9c1..82946acab4c7 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) | 34 | #define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) |
35 | #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) | 35 | #define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) |
36 | 36 | ||
37 | static int i2c_debug=0; | 37 | static int i2c_debug; |
38 | 38 | ||
39 | #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) | 39 | #define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) |
40 | #define pca_inw(adap, reg) adap->read_byte(adap, reg) | 40 | #define pca_inw(adap, reg) adap->read_byte(adap, reg) |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 8ed5ad12552f..938848ae162d 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | /* module parameters: | 43 | /* module parameters: |
44 | */ | 44 | */ |
45 | static int bit_scan=0; /* have a look at what's hanging 'round */ | 45 | static int bit_scan; /* have a look at what's hanging 'round */ |
46 | 46 | ||
47 | 47 | ||
48 | static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, | 48 | static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 3badfec75b1c..4010fe92e72b 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -135,11 +135,12 @@ config I2C_I810 | |||
135 | help | 135 | help |
136 | If you say yes to this option, support will be included for the Intel | 136 | If you say yes to this option, support will be included for the Intel |
137 | 810/815 family of mainboard I2C interfaces. Specifically, the | 137 | 810/815 family of mainboard I2C interfaces. Specifically, the |
138 | following versions of the chipset is supported: | 138 | following versions of the chipset are supported: |
139 | i810AA | 139 | i810AA |
140 | i810AB | 140 | i810AB |
141 | i810E | 141 | i810E |
142 | i815 | 142 | i815 |
143 | i845G | ||
143 | 144 | ||
144 | This driver can also be built as a module. If so, the module | 145 | This driver can also be built as a module. If so, the module |
145 | will be called i2c-i810. | 146 | will be called i2c-i810. |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index f021acd2674e..ba90f5140af6 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -134,7 +134,7 @@ | |||
134 | /* -> Read = 1 */ | 134 | /* -> Read = 1 */ |
135 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ | 135 | #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ |
136 | 136 | ||
137 | 137 | static struct pci_driver ali1535_driver; | |
138 | static unsigned short ali1535_smba; | 138 | static unsigned short ali1535_smba; |
139 | static DECLARE_MUTEX(i2c_ali1535_sem); | 139 | static DECLARE_MUTEX(i2c_ali1535_sem); |
140 | 140 | ||
@@ -162,7 +162,8 @@ static int ali1535_setup(struct pci_dev *dev) | |||
162 | goto exit; | 162 | goto exit; |
163 | } | 163 | } |
164 | 164 | ||
165 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, "ali1535-smb")) { | 165 | if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, |
166 | ali1535_driver.name)) { | ||
166 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", | 167 | dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", |
167 | ali1535_smba); | 168 | ali1535_smba); |
168 | goto exit; | 169 | goto exit; |
@@ -480,7 +481,6 @@ static struct i2c_adapter ali1535_adapter = { | |||
480 | .owner = THIS_MODULE, | 481 | .owner = THIS_MODULE, |
481 | .class = I2C_CLASS_HWMON, | 482 | .class = I2C_CLASS_HWMON, |
482 | .algo = &smbus_algorithm, | 483 | .algo = &smbus_algorithm, |
483 | .name = "unset", | ||
484 | }; | 484 | }; |
485 | 485 | ||
486 | static struct pci_device_id ali1535_ids[] = { | 486 | static struct pci_device_id ali1535_ids[] = { |
@@ -513,6 +513,7 @@ static void __devexit ali1535_remove(struct pci_dev *dev) | |||
513 | } | 513 | } |
514 | 514 | ||
515 | static struct pci_driver ali1535_driver = { | 515 | static struct pci_driver ali1535_driver = { |
516 | .owner = THIS_MODULE, | ||
516 | .name = "ali1535_smbus", | 517 | .name = "ali1535_smbus", |
517 | .id_table = ali1535_ids, | 518 | .id_table = ali1535_ids, |
518 | .probe = ali1535_probe, | 519 | .probe = ali1535_probe, |
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 86947504aea1..f1a62d892425 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | #define HST_CNTL2_SIZEMASK 0x38 | 61 | #define HST_CNTL2_SIZEMASK 0x38 |
62 | 62 | ||
63 | static struct pci_driver ali1563_pci_driver; | ||
63 | static unsigned short ali1563_smba; | 64 | static unsigned short ali1563_smba; |
64 | 65 | ||
65 | static int ali1563_transaction(struct i2c_adapter * a, int size) | 66 | static int ali1563_transaction(struct i2c_adapter * a, int size) |
@@ -350,7 +351,8 @@ static int __devinit ali1563_setup(struct pci_dev * dev) | |||
350 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); | 351 | dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); |
351 | goto Err; | 352 | goto Err; |
352 | } | 353 | } |
353 | if (!request_region(ali1563_smba,ALI1563_SMB_IOSIZE,"i2c-ali1563")) { | 354 | if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, |
355 | ali1563_pci_driver.name)) { | ||
354 | dev_warn(&dev->dev,"Could not allocate I/O space"); | 356 | dev_warn(&dev->dev,"Could not allocate I/O space"); |
355 | goto Err; | 357 | goto Err; |
356 | } | 358 | } |
@@ -406,7 +408,8 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = { | |||
406 | MODULE_DEVICE_TABLE (pci, ali1563_id_table); | 408 | MODULE_DEVICE_TABLE (pci, ali1563_id_table); |
407 | 409 | ||
408 | static struct pci_driver ali1563_pci_driver = { | 410 | static struct pci_driver ali1563_pci_driver = { |
409 | .name = "ali1563_i2c", | 411 | .owner = THIS_MODULE, |
412 | .name = "ali1563_smbus", | ||
410 | .id_table = ali1563_id_table, | 413 | .id_table = ali1563_id_table, |
411 | .probe = ali1563_probe, | 414 | .probe = ali1563_probe, |
412 | .remove = __devexit_p(ali1563_remove), | 415 | .remove = __devexit_p(ali1563_remove), |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index b3f50bff39a0..400b08ed4299 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -125,12 +125,13 @@ | |||
125 | 125 | ||
126 | /* If force_addr is set to anything different from 0, we forcibly enable | 126 | /* If force_addr is set to anything different from 0, we forcibly enable |
127 | the device at the given address. */ | 127 | the device at the given address. */ |
128 | static u16 force_addr = 0; | 128 | static u16 force_addr; |
129 | module_param(force_addr, ushort, 0); | 129 | module_param(force_addr, ushort, 0); |
130 | MODULE_PARM_DESC(force_addr, | 130 | MODULE_PARM_DESC(force_addr, |
131 | "Initialize the base address of the i2c controller"); | 131 | "Initialize the base address of the i2c controller"); |
132 | 132 | ||
133 | static unsigned short ali15x3_smba = 0; | 133 | static struct pci_driver ali15x3_driver; |
134 | static unsigned short ali15x3_smba; | ||
134 | 135 | ||
135 | static int ali15x3_setup(struct pci_dev *ALI15X3_dev) | 136 | static int ali15x3_setup(struct pci_dev *ALI15X3_dev) |
136 | { | 137 | { |
@@ -166,7 +167,8 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev) | |||
166 | if(force_addr) | 167 | if(force_addr) |
167 | ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); | 168 | ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); |
168 | 169 | ||
169 | if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { | 170 | if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, |
171 | ali15x3_driver.name)) { | ||
170 | dev_err(&ALI15X3_dev->dev, | 172 | dev_err(&ALI15X3_dev->dev, |
171 | "ALI15X3_smb region 0x%x already in use!\n", | 173 | "ALI15X3_smb region 0x%x already in use!\n", |
172 | ali15x3_smba); | 174 | ali15x3_smba); |
@@ -470,7 +472,6 @@ static struct i2c_adapter ali15x3_adapter = { | |||
470 | .owner = THIS_MODULE, | 472 | .owner = THIS_MODULE, |
471 | .class = I2C_CLASS_HWMON, | 473 | .class = I2C_CLASS_HWMON, |
472 | .algo = &smbus_algorithm, | 474 | .algo = &smbus_algorithm, |
473 | .name = "unset", | ||
474 | }; | 475 | }; |
475 | 476 | ||
476 | static struct pci_device_id ali15x3_ids[] = { | 477 | static struct pci_device_id ali15x3_ids[] = { |
@@ -503,6 +504,7 @@ static void __devexit ali15x3_remove(struct pci_dev *dev) | |||
503 | } | 504 | } |
504 | 505 | ||
505 | static struct pci_driver ali15x3_driver = { | 506 | static struct pci_driver ali15x3_driver = { |
507 | .owner = THIS_MODULE, | ||
506 | .name = "ali15x3_smbus", | 508 | .name = "ali15x3_smbus", |
507 | .id_table = ali15x3_ids, | 509 | .id_table = ali15x3_ids, |
508 | .probe = ali15x3_probe, | 510 | .probe = ali15x3_probe, |
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 4e553e8c5cba..f51ab652300a 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void) | |||
169 | init_MUTEX(&amd756_lock); | 169 | init_MUTEX(&amd756_lock); |
170 | 170 | ||
171 | /* Define the 5 virtual adapters and algorithms structures */ | 171 | /* Define the 5 virtual adapters and algorithms structures */ |
172 | if (!(s4882_adapter = kmalloc(5 * sizeof(struct i2c_adapter), | 172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), |
173 | GFP_KERNEL))) { | 173 | GFP_KERNEL))) { |
174 | error = -ENOMEM; | 174 | error = -ENOMEM; |
175 | goto ERROR1; | 175 | goto ERROR1; |
176 | } | 176 | } |
177 | if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm), | 177 | if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm), |
178 | GFP_KERNEL))) { | 178 | GFP_KERNEL))) { |
179 | error = -ENOMEM; | 179 | error = -ENOMEM; |
180 | goto ERROR2; | 180 | goto ERROR2; |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 6ad0603384b8..de035d137c3f 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -85,8 +85,8 @@ | |||
85 | #define AMD756_PROCESS_CALL 0x04 | 85 | #define AMD756_PROCESS_CALL 0x04 |
86 | #define AMD756_BLOCK_DATA 0x05 | 86 | #define AMD756_BLOCK_DATA 0x05 |
87 | 87 | ||
88 | 88 | static struct pci_driver amd756_driver; | |
89 | static unsigned short amd756_ioport = 0; | 89 | static unsigned short amd756_ioport; |
90 | 90 | ||
91 | /* | 91 | /* |
92 | SMBUS event = I/O 28-29 bit 11 | 92 | SMBUS event = I/O 28-29 bit 11 |
@@ -303,7 +303,6 @@ struct i2c_adapter amd756_smbus = { | |||
303 | .owner = THIS_MODULE, | 303 | .owner = THIS_MODULE, |
304 | .class = I2C_CLASS_HWMON, | 304 | .class = I2C_CLASS_HWMON, |
305 | .algo = &smbus_algorithm, | 305 | .algo = &smbus_algorithm, |
306 | .name = "unset", | ||
307 | }; | 306 | }; |
308 | 307 | ||
309 | enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; | 308 | enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; |
@@ -365,7 +364,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, | |||
365 | amd756_ioport += SMB_ADDR_OFFSET; | 364 | amd756_ioport += SMB_ADDR_OFFSET; |
366 | } | 365 | } |
367 | 366 | ||
368 | if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { | 367 | if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) { |
369 | dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", | 368 | dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", |
370 | amd756_ioport); | 369 | amd756_ioport); |
371 | return -ENODEV; | 370 | return -ENODEV; |
@@ -402,6 +401,7 @@ static void __devexit amd756_remove(struct pci_dev *dev) | |||
402 | } | 401 | } |
403 | 402 | ||
404 | static struct pci_driver amd756_driver = { | 403 | static struct pci_driver amd756_driver = { |
404 | .owner = THIS_MODULE, | ||
405 | .name = "amd756_smbus", | 405 | .name = "amd756_smbus", |
406 | .id_table = amd756_ids, | 406 | .id_table = amd756_ids, |
407 | .probe = amd756_probe, | 407 | .probe = amd756_probe, |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 45ea24ba14d5..f3b79a68dbec 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -30,6 +30,8 @@ struct amd_smbus { | |||
30 | int size; | 30 | int size; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static struct pci_driver amd8111_driver; | ||
34 | |||
33 | /* | 35 | /* |
34 | * AMD PCI control registers definitions. | 36 | * AMD PCI control registers definitions. |
35 | */ | 37 | */ |
@@ -242,7 +244,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
242 | break; | 244 | break; |
243 | 245 | ||
244 | case I2C_SMBUS_BLOCK_PROC_CALL: | 246 | case I2C_SMBUS_BLOCK_PROC_CALL: |
245 | protocol |= pec; | ||
246 | len = min_t(u8, data->block[0], 31); | 247 | len = min_t(u8, data->block[0], 31); |
247 | amd_ec_write(smbus, AMD_SMB_CMD, command); | 248 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
248 | amd_ec_write(smbus, AMD_SMB_BCNT, len); | 249 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
@@ -252,13 +253,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl | |||
252 | read_write = I2C_SMBUS_READ; | 253 | read_write = I2C_SMBUS_READ; |
253 | break; | 254 | break; |
254 | 255 | ||
255 | case I2C_SMBUS_WORD_DATA_PEC: | ||
256 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
257 | case I2C_SMBUS_PROC_CALL_PEC: | ||
258 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
259 | dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size); | ||
260 | return -1; | ||
261 | |||
262 | default: | 256 | default: |
263 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); | 257 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); |
264 | return -1; | 258 | return -1; |
@@ -343,16 +337,15 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ | |||
343 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) | 337 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) |
344 | return -ENODEV; | 338 | return -ENODEV; |
345 | 339 | ||
346 | smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL); | 340 | smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); |
347 | if (!smbus) | 341 | if (!smbus) |
348 | return -ENOMEM; | 342 | return -ENOMEM; |
349 | memset(smbus, 0, sizeof(struct amd_smbus)); | ||
350 | 343 | ||
351 | smbus->dev = dev; | 344 | smbus->dev = dev; |
352 | smbus->base = pci_resource_start(dev, 0); | 345 | smbus->base = pci_resource_start(dev, 0); |
353 | smbus->size = pci_resource_len(dev, 0); | 346 | smbus->size = pci_resource_len(dev, 0); |
354 | 347 | ||
355 | if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) | 348 | if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) |
356 | goto out_kfree; | 349 | goto out_kfree; |
357 | 350 | ||
358 | smbus->adapter.owner = THIS_MODULE; | 351 | smbus->adapter.owner = THIS_MODULE; |
@@ -391,6 +384,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev) | |||
391 | } | 384 | } |
392 | 385 | ||
393 | static struct pci_driver amd8111_driver = { | 386 | static struct pci_driver amd8111_driver = { |
387 | .owner = THIS_MODULE, | ||
394 | .name = "amd8111_smbus2", | 388 | .name = "amd8111_smbus2", |
395 | .id_table = amd8111_ids, | 389 | .id_table = amd8111_ids, |
396 | .probe = amd8111_probe, | 390 | .probe = amd8111_probe, |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 6930b660e508..59f8308c2356 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
23 | Frodo Looijaard <frodol@dds.nl> */ | 23 | Frodo Looijaard <frodol@dds.nl> */ |
24 | 24 | ||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -46,12 +46,14 @@ | |||
46 | #define DEFAULT_BASE 0x330 | 46 | #define DEFAULT_BASE 0x330 |
47 | 47 | ||
48 | static int base; | 48 | static int base; |
49 | static u8 __iomem *base_iomem; | ||
50 | |||
49 | static int irq; | 51 | static int irq; |
50 | static int clock = 0x1c; | 52 | static int clock = 0x1c; |
51 | static int own = 0x55; | 53 | static int own = 0x55; |
52 | static int mmapped; | 54 | static int mmapped; |
53 | 55 | ||
54 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - | 56 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - |
55 | this module in real supports only one device, due to missing arguments | 57 | this module in real supports only one device, due to missing arguments |
56 | in some functions, called from the algo-pcf module. Sometimes it's | 58 | in some functions, called from the algo-pcf module. Sometimes it's |
57 | need to be rewriten - but for now just remove this for simpler reading */ | 59 | need to be rewriten - but for now just remove this for simpler reading */ |
@@ -60,40 +62,33 @@ static wait_queue_head_t pcf_wait; | |||
60 | static int pcf_pending; | 62 | static int pcf_pending; |
61 | static spinlock_t lock; | 63 | static spinlock_t lock; |
62 | 64 | ||
65 | static struct i2c_adapter pcf_isa_ops; | ||
66 | |||
63 | /* ----- local functions ---------------------------------------------- */ | 67 | /* ----- local functions ---------------------------------------------- */ |
64 | 68 | ||
65 | static void pcf_isa_setbyte(void *data, int ctl, int val) | 69 | static void pcf_isa_setbyte(void *data, int ctl, int val) |
66 | { | 70 | { |
67 | int address = ctl ? (base + 1) : base; | 71 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; |
68 | 72 | ||
69 | /* enable irq if any specified for serial operation */ | 73 | /* enable irq if any specified for serial operation */ |
70 | if (ctl && irq && (val & I2C_PCF_ESO)) { | 74 | if (ctl && irq && (val & I2C_PCF_ESO)) { |
71 | val |= I2C_PCF_ENI; | 75 | val |= I2C_PCF_ENI; |
72 | } | 76 | } |
73 | 77 | ||
74 | pr_debug("i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255); | 78 | pr_debug("%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val); |
75 | 79 | iowrite8(val, address); | |
76 | switch (mmapped) { | 80 | #ifdef __alpha__ |
77 | case 0: /* regular I/O */ | 81 | /* API UP2000 needs some hardware fudging to make the write stick */ |
78 | outb(val, address); | 82 | iowrite8(val, address); |
79 | break; | 83 | #endif |
80 | case 2: /* double mapped I/O needed for UP2000 board, | ||
81 | I don't know why this... */ | ||
82 | writeb(val, (void *)address); | ||
83 | /* fall */ | ||
84 | case 1: /* memory mapped I/O */ | ||
85 | writeb(val, (void *)address); | ||
86 | break; | ||
87 | } | ||
88 | } | 84 | } |
89 | 85 | ||
90 | static int pcf_isa_getbyte(void *data, int ctl) | 86 | static int pcf_isa_getbyte(void *data, int ctl) |
91 | { | 87 | { |
92 | int address = ctl ? (base + 1) : base; | 88 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; |
93 | int val = mmapped ? readb((void *)address) : inb(address); | 89 | int val = ioread8(address); |
94 | |||
95 | pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val); | ||
96 | 90 | ||
91 | pr_debug("%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val); | ||
97 | return (val); | 92 | return (val); |
98 | } | 93 | } |
99 | 94 | ||
@@ -149,16 +144,40 @@ static int pcf_isa_init(void) | |||
149 | { | 144 | { |
150 | spin_lock_init(&lock); | 145 | spin_lock_init(&lock); |
151 | if (!mmapped) { | 146 | if (!mmapped) { |
152 | if (!request_region(base, 2, "i2c (isa bus adapter)")) { | 147 | if (!request_region(base, 2, pcf_isa_ops.name)) { |
153 | printk(KERN_ERR | 148 | printk(KERN_ERR "%s: requested I/O region (%#x:2) is " |
154 | "i2c-elektor: requested I/O region (0x%X:2) " | 149 | "in use\n", pcf_isa_ops.name, base); |
155 | "is in use.\n", base); | 150 | return -ENODEV; |
151 | } | ||
152 | base_iomem = ioport_map(base, 2); | ||
153 | if (!base_iomem) { | ||
154 | printk(KERN_ERR "%s: remap of I/O region %#x failed\n", | ||
155 | pcf_isa_ops.name, base); | ||
156 | release_region(base, 2); | ||
157 | return -ENODEV; | ||
158 | } | ||
159 | } else { | ||
160 | if (!request_mem_region(base, 2, pcf_isa_ops.name)) { | ||
161 | printk(KERN_ERR "%s: requested memory region (%#x:2) " | ||
162 | "is in use\n", pcf_isa_ops.name, base); | ||
163 | return -ENODEV; | ||
164 | } | ||
165 | base_iomem = ioremap(base, 2); | ||
166 | if (base_iomem == NULL) { | ||
167 | printk(KERN_ERR "%s: remap of memory region %#x " | ||
168 | "failed\n", pcf_isa_ops.name, base); | ||
169 | release_mem_region(base, 2); | ||
156 | return -ENODEV; | 170 | return -ENODEV; |
157 | } | 171 | } |
158 | } | 172 | } |
173 | pr_debug("%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base, | ||
174 | base_iomem); | ||
175 | |||
159 | if (irq > 0) { | 176 | if (irq > 0) { |
160 | if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", NULL) < 0) { | 177 | if (request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name, |
161 | printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq); | 178 | NULL) < 0) { |
179 | printk(KERN_ERR "%s: Request irq%d failed\n", | ||
180 | pcf_isa_ops.name, irq); | ||
162 | irq = 0; | 181 | irq = 0; |
163 | } else | 182 | } else |
164 | enable_irq(irq); | 183 | enable_irq(irq); |
@@ -186,47 +205,49 @@ static struct i2c_adapter pcf_isa_ops = { | |||
186 | .class = I2C_CLASS_HWMON, | 205 | .class = I2C_CLASS_HWMON, |
187 | .id = I2C_HW_P_ELEK, | 206 | .id = I2C_HW_P_ELEK, |
188 | .algo_data = &pcf_isa_data, | 207 | .algo_data = &pcf_isa_data, |
189 | .name = "PCF8584 ISA adapter", | 208 | .name = "i2c-elektor", |
190 | }; | 209 | }; |
191 | 210 | ||
192 | static int __init i2c_pcfisa_init(void) | 211 | static int __init i2c_pcfisa_init(void) |
193 | { | 212 | { |
194 | #ifdef __alpha__ | 213 | #ifdef __alpha__ |
195 | /* check to see we have memory mapped PCF8584 connected to the | 214 | /* check to see we have memory mapped PCF8584 connected to the |
196 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ | 215 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ |
197 | if (base == 0) { | 216 | if (base == 0) { |
198 | struct pci_dev *cy693_dev; | 217 | struct pci_dev *cy693_dev; |
199 | 218 | ||
200 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, | 219 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, |
201 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); | 220 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); |
202 | if (cy693_dev) { | 221 | if (cy693_dev) { |
203 | char config; | 222 | unsigned char config; |
204 | /* yeap, we've found cypress, let's check config */ | 223 | /* yeap, we've found cypress, let's check config */ |
205 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { | 224 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { |
206 | 225 | ||
207 | pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config); | 226 | pr_debug("%s: found cy82c693, config " |
227 | "register 0x47 = 0x%02x\n", | ||
228 | pcf_isa_ops.name, config); | ||
208 | 229 | ||
209 | /* UP2000 board has this register set to 0xe1, | 230 | /* UP2000 board has this register set to 0xe1, |
210 | but the most significant bit as seems can be | 231 | but the most significant bit as seems can be |
211 | reset during the proper initialisation | 232 | reset during the proper initialisation |
212 | sequence if guys from API decides to do that | 233 | sequence if guys from API decides to do that |
213 | (so, we can even enable Tsunami Pchip | 234 | (so, we can even enable Tsunami Pchip |
214 | window for the upper 1 Gb) */ | 235 | window for the upper 1 Gb) */ |
215 | 236 | ||
216 | /* so just check for ROMCS at 0xe0000, | 237 | /* so just check for ROMCS at 0xe0000, |
217 | ROMCS enabled for writes | 238 | ROMCS enabled for writes |
218 | and external XD Bus buffer in use. */ | 239 | and external XD Bus buffer in use. */ |
219 | if ((config & 0x7f) == 0x61) { | 240 | if ((config & 0x7f) == 0x61) { |
220 | /* seems to be UP2000 like board */ | 241 | /* seems to be UP2000 like board */ |
221 | base = 0xe0000; | 242 | base = 0xe0000; |
222 | /* I don't know why we need to | 243 | mmapped = 1; |
223 | write twice */ | 244 | /* UP2000 drives ISA with |
224 | mmapped = 2; | ||
225 | /* UP2000 drives ISA with | ||
226 | 8.25 MHz (PCI/4) clock | 245 | 8.25 MHz (PCI/4) clock |
227 | (this can be read from cypress) */ | 246 | (this can be read from cypress) */ |
228 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; | 247 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; |
229 | printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n"); | 248 | pr_info("%s: found API UP2000 like " |
249 | "board, will probe PCF8584 " | ||
250 | "later\n", pcf_isa_ops.name); | ||
230 | } | 251 | } |
231 | } | 252 | } |
232 | pci_dev_put(cy693_dev); | 253 | pci_dev_put(cy693_dev); |
@@ -236,12 +257,11 @@ static int __init i2c_pcfisa_init(void) | |||
236 | 257 | ||
237 | /* sanity checks for mmapped I/O */ | 258 | /* sanity checks for mmapped I/O */ |
238 | if (mmapped && base < 0xc8000) { | 259 | if (mmapped && base < 0xc8000) { |
239 | printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); | 260 | printk(KERN_ERR "%s: incorrect base address (%#x) specified " |
261 | "for mmapped I/O\n", pcf_isa_ops.name, base); | ||
240 | return -ENODEV; | 262 | return -ENODEV; |
241 | } | 263 | } |
242 | 264 | ||
243 | printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n"); | ||
244 | |||
245 | if (base == 0) { | 265 | if (base == 0) { |
246 | base = DEFAULT_BASE; | 266 | base = DEFAULT_BASE; |
247 | } | 267 | } |
@@ -251,8 +271,8 @@ static int __init i2c_pcfisa_init(void) | |||
251 | return -ENODEV; | 271 | return -ENODEV; |
252 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) | 272 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) |
253 | goto fail; | 273 | goto fail; |
254 | 274 | ||
255 | printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base); | 275 | dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); |
256 | 276 | ||
257 | return 0; | 277 | return 0; |
258 | 278 | ||
@@ -262,8 +282,13 @@ static int __init i2c_pcfisa_init(void) | |||
262 | free_irq(irq, NULL); | 282 | free_irq(irq, NULL); |
263 | } | 283 | } |
264 | 284 | ||
265 | if (!mmapped) | 285 | if (!mmapped) { |
266 | release_region(base , 2); | 286 | ioport_unmap(base_iomem); |
287 | release_region(base, 2); | ||
288 | } else { | ||
289 | iounmap(base_iomem); | ||
290 | release_mem_region(base, 2); | ||
291 | } | ||
267 | return -ENODEV; | 292 | return -ENODEV; |
268 | } | 293 | } |
269 | 294 | ||
@@ -276,8 +301,13 @@ static void i2c_pcfisa_exit(void) | |||
276 | free_irq(irq, NULL); | 301 | free_irq(irq, NULL); |
277 | } | 302 | } |
278 | 303 | ||
279 | if (!mmapped) | 304 | if (!mmapped) { |
280 | release_region(base , 2); | 305 | ioport_unmap(base_iomem); |
306 | release_region(base, 2); | ||
307 | } else { | ||
308 | iounmap(base_iomem); | ||
309 | release_mem_region(base, 2); | ||
310 | } | ||
281 | } | 311 | } |
282 | 312 | ||
283 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); | 313 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); |
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index e0cb3b0f92fa..1b5354e24bf5 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -155,6 +155,7 @@ static void __devexit hydra_remove(struct pci_dev *dev) | |||
155 | 155 | ||
156 | 156 | ||
157 | static struct pci_driver hydra_driver = { | 157 | static struct pci_driver hydra_driver = { |
158 | .owner = THIS_MODULE, | ||
158 | .name = "hydra_smbus", | 159 | .name = "hydra_smbus", |
159 | .id_table = hydra_ids, | 160 | .id_table = hydra_ids, |
160 | .probe = hydra_probe, | 161 | .probe = hydra_probe, |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 709beab76609..4f63195069da 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -52,10 +52,6 @@ | |||
52 | #include <linux/i2c.h> | 52 | #include <linux/i2c.h> |
53 | #include <asm/io.h> | 53 | #include <asm/io.h> |
54 | 54 | ||
55 | #ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC | ||
56 | #define HAVE_PEC | ||
57 | #endif | ||
58 | |||
59 | /* I801 SMBus address offsets */ | 55 | /* I801 SMBus address offsets */ |
60 | #define SMBHSTSTS (0 + i801_smba) | 56 | #define SMBHSTSTS (0 + i801_smba) |
61 | #define SMBHSTCNT (2 + i801_smba) | 57 | #define SMBHSTCNT (2 + i801_smba) |
@@ -106,10 +102,11 @@ MODULE_PARM_DESC(force_addr, | |||
106 | "EXTREMELY DANGEROUS!"); | 102 | "EXTREMELY DANGEROUS!"); |
107 | 103 | ||
108 | static int i801_transaction(void); | 104 | static int i801_transaction(void); |
109 | static int i801_block_transaction(union i2c_smbus_data *data, | 105 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, |
110 | char read_write, int command); | 106 | int command, int hwpec); |
111 | 107 | ||
112 | static unsigned short i801_smba; | 108 | static unsigned short i801_smba; |
109 | static struct pci_driver i801_driver; | ||
113 | static struct pci_dev *I801_dev; | 110 | static struct pci_dev *I801_dev; |
114 | static int isich4; | 111 | static int isich4; |
115 | 112 | ||
@@ -143,7 +140,7 @@ static int i801_setup(struct pci_dev *dev) | |||
143 | } | 140 | } |
144 | } | 141 | } |
145 | 142 | ||
146 | if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { | 143 | if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { |
147 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", | 144 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", |
148 | i801_smba); | 145 | i801_smba); |
149 | error_return = -EBUSY; | 146 | error_return = -EBUSY; |
@@ -252,7 +249,7 @@ static int i801_transaction(void) | |||
252 | 249 | ||
253 | /* All-inclusive block transaction function */ | 250 | /* All-inclusive block transaction function */ |
254 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | 251 | static int i801_block_transaction(union i2c_smbus_data *data, char read_write, |
255 | int command) | 252 | int command, int hwpec) |
256 | { | 253 | { |
257 | int i, len; | 254 | int i, len; |
258 | int smbcmd; | 255 | int smbcmd; |
@@ -391,8 +388,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
391 | goto END; | 388 | goto END; |
392 | } | 389 | } |
393 | 390 | ||
394 | #ifdef HAVE_PEC | 391 | if (hwpec) { |
395 | if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) { | ||
396 | /* wait for INTR bit as advised by Intel */ | 392 | /* wait for INTR bit as advised by Intel */ |
397 | timeout = 0; | 393 | timeout = 0; |
398 | do { | 394 | do { |
@@ -406,7 +402,6 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
406 | } | 402 | } |
407 | outb_p(temp, SMBHSTSTS); | 403 | outb_p(temp, SMBHSTSTS); |
408 | } | 404 | } |
409 | #endif | ||
410 | result = 0; | 405 | result = 0; |
411 | END: | 406 | END: |
412 | if (command == I2C_SMBUS_I2C_BLOCK_DATA) { | 407 | if (command == I2C_SMBUS_I2C_BLOCK_DATA) { |
@@ -421,14 +416,13 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
421 | unsigned short flags, char read_write, u8 command, | 416 | unsigned short flags, char read_write, u8 command, |
422 | int size, union i2c_smbus_data * data) | 417 | int size, union i2c_smbus_data * data) |
423 | { | 418 | { |
424 | int hwpec = 0; | 419 | int hwpec; |
425 | int block = 0; | 420 | int block = 0; |
426 | int ret, xact = 0; | 421 | int ret, xact = 0; |
427 | 422 | ||
428 | #ifdef HAVE_PEC | 423 | hwpec = isich4 && (flags & I2C_CLIENT_PEC) |
429 | if(isich4) | 424 | && size != I2C_SMBUS_QUICK |
430 | hwpec = (flags & I2C_CLIENT_PEC) != 0; | 425 | && size != I2C_SMBUS_I2C_BLOCK_DATA; |
431 | #endif | ||
432 | 426 | ||
433 | switch (size) { | 427 | switch (size) { |
434 | case I2C_SMBUS_QUICK: | 428 | case I2C_SMBUS_QUICK: |
@@ -463,11 +457,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
463 | break; | 457 | break; |
464 | case I2C_SMBUS_BLOCK_DATA: | 458 | case I2C_SMBUS_BLOCK_DATA: |
465 | case I2C_SMBUS_I2C_BLOCK_DATA: | 459 | case I2C_SMBUS_I2C_BLOCK_DATA: |
466 | #ifdef HAVE_PEC | ||
467 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
468 | if(hwpec && size == I2C_SMBUS_BLOCK_DATA) | ||
469 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
470 | #endif | ||
471 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | 460 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), |
472 | SMBHSTADD); | 461 | SMBHSTADD); |
473 | outb_p(command, SMBHSTCMD); | 462 | outb_p(command, SMBHSTCMD); |
@@ -479,27 +468,18 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
479 | return -1; | 468 | return -1; |
480 | } | 469 | } |
481 | 470 | ||
482 | #ifdef HAVE_PEC | 471 | if (hwpec) |
483 | if(isich4 && hwpec) { | 472 | outb_p(1, SMBAUXCTL); /* enable hardware PEC */ |
484 | if(size != I2C_SMBUS_QUICK && | 473 | |
485 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
486 | outb_p(1, SMBAUXCTL); /* enable HW PEC */ | ||
487 | } | ||
488 | #endif | ||
489 | if(block) | 474 | if(block) |
490 | ret = i801_block_transaction(data, read_write, size); | 475 | ret = i801_block_transaction(data, read_write, size, hwpec); |
491 | else { | 476 | else { |
492 | outb_p(xact | ENABLE_INT9, SMBHSTCNT); | 477 | outb_p(xact | ENABLE_INT9, SMBHSTCNT); |
493 | ret = i801_transaction(); | 478 | ret = i801_transaction(); |
494 | } | 479 | } |
495 | 480 | ||
496 | #ifdef HAVE_PEC | 481 | if (hwpec) |
497 | if(isich4 && hwpec) { | 482 | outb_p(0, SMBAUXCTL); /* disable hardware PEC */ |
498 | if(size != I2C_SMBUS_QUICK && | ||
499 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
500 | outb_p(0, SMBAUXCTL); | ||
501 | } | ||
502 | #endif | ||
503 | 483 | ||
504 | if(block) | 484 | if(block) |
505 | return ret; | 485 | return ret; |
@@ -526,12 +506,7 @@ static u32 i801_func(struct i2c_adapter *adapter) | |||
526 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 506 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
527 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 507 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
528 | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | 508 | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
529 | #ifdef HAVE_PEC | 509 | | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0); |
530 | | (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC | | ||
531 | I2C_FUNC_SMBUS_HWPEC_CALC | ||
532 | : 0) | ||
533 | #endif | ||
534 | ; | ||
535 | } | 510 | } |
536 | 511 | ||
537 | static struct i2c_algorithm smbus_algorithm = { | 512 | static struct i2c_algorithm smbus_algorithm = { |
@@ -543,7 +518,6 @@ static struct i2c_adapter i801_adapter = { | |||
543 | .owner = THIS_MODULE, | 518 | .owner = THIS_MODULE, |
544 | .class = I2C_CLASS_HWMON, | 519 | .class = I2C_CLASS_HWMON, |
545 | .algo = &smbus_algorithm, | 520 | .algo = &smbus_algorithm, |
546 | .name = "unset", | ||
547 | }; | 521 | }; |
548 | 522 | ||
549 | static struct pci_device_id i801_ids[] = { | 523 | static struct pci_device_id i801_ids[] = { |
@@ -586,6 +560,7 @@ static void __devexit i801_remove(struct pci_dev *dev) | |||
586 | } | 560 | } |
587 | 561 | ||
588 | static struct pci_driver i801_driver = { | 562 | static struct pci_driver i801_driver = { |
563 | .owner = THIS_MODULE, | ||
589 | .name = "i801_smbus", | 564 | .name = "i801_smbus", |
590 | .id_table = i801_ids, | 565 | .id_table = i801_ids, |
591 | .probe = i801_probe, | 566 | .probe = i801_probe, |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index 0ff7016e0629..52bc30593bd7 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -32,6 +32,7 @@ | |||
32 | i810AB 7123 | 32 | i810AB 7123 |
33 | i810E 7125 | 33 | i810E 7125 |
34 | i815 1132 | 34 | i815 1132 |
35 | i845G 2562 | ||
35 | */ | 36 | */ |
36 | 37 | ||
37 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
@@ -232,6 +233,7 @@ static void __devexit i810_remove(struct pci_dev *dev) | |||
232 | } | 233 | } |
233 | 234 | ||
234 | static struct pci_driver i810_driver = { | 235 | static struct pci_driver i810_driver = { |
236 | .owner = THIS_MODULE, | ||
235 | .name = "i810_smbus", | 237 | .name = "i810_smbus", |
236 | .id_table = i810_ids, | 238 | .id_table = i810_ids, |
237 | .probe = i810_probe, | 239 | .probe = i810_probe, |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index a3ed9590f028..1a587253d716 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -672,13 +672,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
672 | printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", | 672 | printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", |
673 | ocp->def->index); | 673 | ocp->def->index); |
674 | 674 | ||
675 | if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ | 675 | if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) { |
676 | printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", | 676 | printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", |
677 | ocp->def->index); | 677 | ocp->def->index); |
678 | return -ENOMEM; | 678 | return -ENOMEM; |
679 | } | 679 | } |
680 | 680 | ||
681 | memset(dev, 0, sizeof(*dev)); | ||
682 | dev->idx = ocp->def->index; | 681 | dev->idx = ocp->def->index; |
683 | ocp_set_drvdata(ocp, dev); | 682 | ocp_set_drvdata(ocp, dev); |
684 | 683 | ||
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 7bd9102db701..9888fae1f37a 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "i2c-iop3xx.h" | 43 | #include "i2c-iop3xx.h" |
44 | 44 | ||
45 | /* global unit counter */ | 45 | /* global unit counter */ |
46 | static int i2c_id = 0; | 46 | static int i2c_id; |
47 | 47 | ||
48 | static inline unsigned char | 48 | static inline unsigned char |
49 | iic_cook_addr(struct i2c_msg *msg) | 49 | iic_cook_addr(struct i2c_msg *msg) |
@@ -440,19 +440,17 @@ iop3xx_i2c_probe(struct device *dev) | |||
440 | struct i2c_adapter *new_adapter; | 440 | struct i2c_adapter *new_adapter; |
441 | struct i2c_algo_iop3xx_data *adapter_data; | 441 | struct i2c_algo_iop3xx_data *adapter_data; |
442 | 442 | ||
443 | new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | 443 | new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); |
444 | if (!new_adapter) { | 444 | if (!new_adapter) { |
445 | ret = -ENOMEM; | 445 | ret = -ENOMEM; |
446 | goto out; | 446 | goto out; |
447 | } | 447 | } |
448 | memset((void*)new_adapter, 0, sizeof(*new_adapter)); | ||
449 | 448 | ||
450 | adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); | 449 | adapter_data = kzalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); |
451 | if (!adapter_data) { | 450 | if (!adapter_data) { |
452 | ret = -ENOMEM; | 451 | ret = -ENOMEM; |
453 | goto free_adapter; | 452 | goto free_adapter; |
454 | } | 453 | } |
455 | memset((void*)adapter_data, 0, sizeof(*adapter_data)); | ||
456 | 454 | ||
457 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 455 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
458 | if (!res) { | 456 | if (!res) { |
@@ -525,6 +523,7 @@ out: | |||
525 | 523 | ||
526 | 524 | ||
527 | static struct device_driver iop3xx_i2c_driver = { | 525 | static struct device_driver iop3xx_i2c_driver = { |
526 | .owner = THIS_MODULE, | ||
528 | .name = "IOP3xx-I2C", | 527 | .name = "IOP3xx-I2C", |
529 | .bus = &platform_bus_type, | 528 | .bus = &platform_bus_type, |
530 | .probe = iop3xx_i2c_probe, | 529 | .probe = iop3xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index bdc6806dafae..4fdc02411609 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -92,6 +92,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver) | |||
92 | 92 | ||
93 | /* Add the driver to the list of i2c drivers in the driver core */ | 93 | /* Add the driver to the list of i2c drivers in the driver core */ |
94 | driver->driver.name = driver->name; | 94 | driver->driver.name = driver->name; |
95 | driver->driver.owner = driver->owner; | ||
95 | driver->driver.bus = &i2c_bus_type; | 96 | driver->driver.bus = &i2c_bus_type; |
96 | driver->driver.probe = i2c_isa_device_probe; | 97 | driver->driver.probe = i2c_isa_device_probe; |
97 | driver->driver.remove = i2c_isa_device_remove; | 98 | driver->driver.remove = i2c_isa_device_remove; |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 1956af382cd8..42016ee6ef13 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ | 36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ |
37 | #include <asm/arch/gpio.h> | 37 | #include <asm/arch/gpio.h> |
38 | 38 | ||
39 | static struct device_driver ixp2000_i2c_driver; | ||
40 | |||
39 | static inline int ixp2000_scl_pin(void *data) | 41 | static inline int ixp2000_scl_pin(void *data) |
40 | { | 42 | { |
41 | return ((struct ixp2000_i2c_pins*)data)->scl_pin; | 43 | return ((struct ixp2000_i2c_pins*)data)->scl_pin; |
@@ -104,11 +106,10 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
104 | struct platform_device *plat_dev = to_platform_device(dev); | 106 | struct platform_device *plat_dev = to_platform_device(dev); |
105 | struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; | 107 | struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; |
106 | struct ixp2000_i2c_data *drv_data = | 108 | struct ixp2000_i2c_data *drv_data = |
107 | kmalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); | 109 | kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); |
108 | 110 | ||
109 | if (!drv_data) | 111 | if (!drv_data) |
110 | return -ENOMEM; | 112 | return -ENOMEM; |
111 | memzero(drv_data, sizeof(*drv_data)); | ||
112 | drv_data->gpio_pins = gpio; | 113 | drv_data->gpio_pins = gpio; |
113 | 114 | ||
114 | drv_data->algo_data.data = gpio; | 115 | drv_data->algo_data.data = gpio; |
@@ -121,6 +122,8 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
121 | drv_data->algo_data.timeout = 100; | 122 | drv_data->algo_data.timeout = 100; |
122 | 123 | ||
123 | drv_data->adapter.id = I2C_HW_B_IXP2000, | 124 | drv_data->adapter.id = I2C_HW_B_IXP2000, |
125 | strlcpy(drv_data->adapter.name, ixp2000_i2c_driver.name, | ||
126 | I2C_NAME_SIZE); | ||
124 | drv_data->adapter.algo_data = &drv_data->algo_data, | 127 | drv_data->adapter.algo_data = &drv_data->algo_data, |
125 | 128 | ||
126 | drv_data->adapter.dev.parent = &plat_dev->dev; | 129 | drv_data->adapter.dev.parent = &plat_dev->dev; |
@@ -142,6 +145,7 @@ static int ixp2000_i2c_probe(struct device *dev) | |||
142 | } | 145 | } |
143 | 146 | ||
144 | static struct device_driver ixp2000_i2c_driver = { | 147 | static struct device_driver ixp2000_i2c_driver = { |
148 | .owner = THIS_MODULE, | ||
145 | .name = "IXP2000-I2C", | 149 | .name = "IXP2000-I2C", |
146 | .bus = &platform_bus_type, | 150 | .bus = &platform_bus_type, |
147 | .probe = ixp2000_i2c_probe, | 151 | .probe = ixp2000_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index f6f5ca31fdba..69303ab65e04 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | #include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ | 36 | #include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ |
37 | 37 | ||
38 | static struct device_driver ixp4xx_i2c_driver; | ||
39 | |||
38 | static inline int ixp4xx_scl_pin(void *data) | 40 | static inline int ixp4xx_scl_pin(void *data) |
39 | { | 41 | { |
40 | return ((struct ixp4xx_i2c_pins*)data)->scl_pin; | 42 | return ((struct ixp4xx_i2c_pins*)data)->scl_pin; |
@@ -105,12 +107,11 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
105 | struct platform_device *plat_dev = to_platform_device(dev); | 107 | struct platform_device *plat_dev = to_platform_device(dev); |
106 | struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; | 108 | struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; |
107 | struct ixp4xx_i2c_data *drv_data = | 109 | struct ixp4xx_i2c_data *drv_data = |
108 | kmalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); | 110 | kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); |
109 | 111 | ||
110 | if(!drv_data) | 112 | if(!drv_data) |
111 | return -ENOMEM; | 113 | return -ENOMEM; |
112 | 114 | ||
113 | memzero(drv_data, sizeof(struct ixp4xx_i2c_data)); | ||
114 | drv_data->gpio_pins = gpio; | 115 | drv_data->gpio_pins = gpio; |
115 | 116 | ||
116 | /* | 117 | /* |
@@ -129,6 +130,8 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
129 | drv_data->algo_data.timeout = 100; | 130 | drv_data->algo_data.timeout = 100; |
130 | 131 | ||
131 | drv_data->adapter.id = I2C_HW_B_IXP4XX; | 132 | drv_data->adapter.id = I2C_HW_B_IXP4XX; |
133 | strlcpy(drv_data->adapter.name, ixp4xx_i2c_driver.name, | ||
134 | I2C_NAME_SIZE); | ||
132 | drv_data->adapter.algo_data = &drv_data->algo_data; | 135 | drv_data->adapter.algo_data = &drv_data->algo_data; |
133 | 136 | ||
134 | drv_data->adapter.dev.parent = &plat_dev->dev; | 137 | drv_data->adapter.dev.parent = &plat_dev->dev; |
@@ -151,6 +154,7 @@ static int ixp4xx_i2c_probe(struct device *dev) | |||
151 | } | 154 | } |
152 | 155 | ||
153 | static struct device_driver ixp4xx_i2c_driver = { | 156 | static struct device_driver ixp4xx_i2c_driver = { |
157 | .owner = THIS_MODULE, | ||
154 | .name = "IXP4XX-I2C", | 158 | .name = "IXP4XX-I2C", |
155 | .bus = &platform_bus_type, | 159 | .bus = &platform_bus_type, |
156 | .probe = ixp4xx_i2c_probe, | 160 | .probe = ixp4xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index eff5896ce865..d61f748278fc 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
@@ -535,13 +535,12 @@ create_iface(struct device_node *np, struct device *dev) | |||
535 | 535 | ||
536 | tsize = sizeof(struct keywest_iface) + | 536 | tsize = sizeof(struct keywest_iface) + |
537 | (sizeof(struct keywest_chan) + 4) * nchan; | 537 | (sizeof(struct keywest_chan) + 4) * nchan; |
538 | iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); | 538 | iface = kzalloc(tsize, GFP_KERNEL); |
539 | if (iface == NULL) { | 539 | if (iface == NULL) { |
540 | printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); | 540 | printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); |
541 | pmac_low_i2c_unlock(np); | 541 | pmac_low_i2c_unlock(np); |
542 | return -ENOMEM; | 542 | return -ENOMEM; |
543 | } | 543 | } |
544 | memset(iface, 0, tsize); | ||
545 | spin_lock_init(&iface->lock); | 544 | spin_lock_init(&iface->lock); |
546 | init_completion(&iface->complete); | 545 | init_completion(&iface->complete); |
547 | iface->node = of_node_get(np); | 546 | iface->node = of_node_get(np); |
@@ -716,6 +715,7 @@ static struct of_device_id i2c_keywest_match[] = | |||
716 | 715 | ||
717 | static struct macio_driver i2c_keywest_macio_driver = | 716 | static struct macio_driver i2c_keywest_macio_driver = |
718 | { | 717 | { |
718 | .owner = THIS_MODULE, | ||
719 | .name = "i2c-keywest", | 719 | .name = "i2c-keywest", |
720 | .match_table = i2c_keywest_match, | 720 | .match_table = i2c_keywest_match, |
721 | .probe = create_iface_macio, | 721 | .probe = create_iface_macio, |
@@ -724,6 +724,7 @@ static struct macio_driver i2c_keywest_macio_driver = | |||
724 | 724 | ||
725 | static struct of_platform_driver i2c_keywest_of_platform_driver = | 725 | static struct of_platform_driver i2c_keywest_of_platform_driver = |
726 | { | 726 | { |
727 | .owner = THIS_MODULE, | ||
727 | .name = "i2c-keywest", | 728 | .name = "i2c-keywest", |
728 | .match_table = i2c_keywest_match, | 729 | .match_table = i2c_keywest_match, |
729 | .probe = create_iface_of_platform, | 730 | .probe = create_iface_of_platform, |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index f065583ddcf1..8491633005b8 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -296,10 +296,9 @@ static int fsl_i2c_probe(struct device *device) | |||
296 | 296 | ||
297 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | 297 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; |
298 | 298 | ||
299 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | 299 | if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) { |
300 | return -ENOMEM; | 300 | return -ENOMEM; |
301 | } | 301 | } |
302 | memset(i2c, 0, sizeof(*i2c)); | ||
303 | 302 | ||
304 | i2c->irq = platform_get_irq(pdev, 0); | 303 | i2c->irq = platform_get_irq(pdev, 0); |
305 | i2c->flags = pdata->device_flags; | 304 | i2c->flags = pdata->device_flags; |
@@ -361,6 +360,7 @@ static int fsl_i2c_remove(struct device *device) | |||
361 | 360 | ||
362 | /* Structure for a device driver */ | 361 | /* Structure for a device driver */ |
363 | static struct device_driver fsl_i2c_driver = { | 362 | static struct device_driver fsl_i2c_driver = { |
363 | .owner = THIS_MODULE, | ||
364 | .name = "fsl-i2c", | 364 | .name = "fsl-i2c", |
365 | .bus = &platform_bus_type, | 365 | .bus = &platform_bus_type, |
366 | .probe = fsl_i2c_probe, | 366 | .probe = fsl_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 99abca45fece..d0d2a6f1386e 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -500,13 +500,10 @@ mv64xxx_i2c_probe(struct device *dev) | |||
500 | if ((pd->id != 0) || !pdata) | 500 | if ((pd->id != 0) || !pdata) |
501 | return -ENODEV; | 501 | return -ENODEV; |
502 | 502 | ||
503 | drv_data = kmalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); | 503 | drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); |
504 | |||
505 | if (!drv_data) | 504 | if (!drv_data) |
506 | return -ENOMEM; | 505 | return -ENOMEM; |
507 | 506 | ||
508 | memset(drv_data, 0, sizeof(struct mv64xxx_i2c_data)); | ||
509 | |||
510 | if (mv64xxx_i2c_map_regs(pd, drv_data)) { | 507 | if (mv64xxx_i2c_map_regs(pd, drv_data)) { |
511 | rc = -ENODEV; | 508 | rc = -ENODEV; |
512 | goto exit_kfree; | 509 | goto exit_kfree; |
@@ -570,6 +567,7 @@ mv64xxx_i2c_remove(struct device *dev) | |||
570 | } | 567 | } |
571 | 568 | ||
572 | static struct device_driver mv64xxx_i2c_driver = { | 569 | static struct device_driver mv64xxx_i2c_driver = { |
570 | .owner = THIS_MODULE, | ||
573 | .name = MV64XXX_I2C_CTLR_NAME, | 571 | .name = MV64XXX_I2C_CTLR_NAME, |
574 | .bus = &platform_bus_type, | 572 | .bus = &platform_bus_type, |
575 | .probe = mv64xxx_i2c_probe, | 573 | .probe = mv64xxx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index fe9c0f42a2b7..fd26036e68a3 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -97,6 +97,7 @@ struct nforce2_smbus { | |||
97 | #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a | 97 | #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a |
98 | #define NVIDIA_SMB_PRTCL_PEC 0x80 | 98 | #define NVIDIA_SMB_PRTCL_PEC 0x80 |
99 | 99 | ||
100 | static struct pci_driver nforce2_driver; | ||
100 | 101 | ||
101 | static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, | 102 | static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, |
102 | unsigned short flags, char read_write, | 103 | unsigned short flags, char read_write, |
@@ -113,7 +114,6 @@ static struct i2c_adapter nforce2_adapter = { | |||
113 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
114 | .class = I2C_CLASS_HWMON, | 115 | .class = I2C_CLASS_HWMON, |
115 | .algo = &smbus_algorithm, | 116 | .algo = &smbus_algorithm, |
116 | .name = "unset", | ||
117 | }; | 117 | }; |
118 | 118 | ||
119 | /* Return -1 on error. See smbus.h for more information */ | 119 | /* Return -1 on error. See smbus.h for more information */ |
@@ -188,13 +188,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
188 | dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); | 188 | dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); |
189 | return -1; | 189 | return -1; |
190 | 190 | ||
191 | case I2C_SMBUS_WORD_DATA_PEC: | ||
192 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
193 | case I2C_SMBUS_PROC_CALL_PEC: | ||
194 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
195 | dev_err(&adap->dev, "Unexpected software PEC transaction %d\n.", size); | ||
196 | return -1; | ||
197 | |||
198 | default: | 191 | default: |
199 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); | 192 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); |
200 | return -1; | 193 | return -1; |
@@ -285,7 +278,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg, | |||
285 | smbus->base = iobase & 0xfffc; | 278 | smbus->base = iobase & 0xfffc; |
286 | smbus->size = 8; | 279 | smbus->size = 8; |
287 | 280 | ||
288 | if (!request_region(smbus->base, smbus->size, "nForce2 SMBus")) { | 281 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { |
289 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", | 282 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", |
290 | smbus->base, smbus->base+smbus->size-1, name); | 283 | smbus->base, smbus->base+smbus->size-1, name); |
291 | return -1; | 284 | return -1; |
@@ -313,10 +306,8 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ | |||
313 | int res1, res2; | 306 | int res1, res2; |
314 | 307 | ||
315 | /* we support 2 SMBus adapters */ | 308 | /* we support 2 SMBus adapters */ |
316 | if (!(smbuses = (void *)kmalloc(2*sizeof(struct nforce2_smbus), | 309 | if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL))) |
317 | GFP_KERNEL))) | ||
318 | return -ENOMEM; | 310 | return -ENOMEM; |
319 | memset (smbuses, 0, 2*sizeof(struct nforce2_smbus)); | ||
320 | pci_set_drvdata(dev, smbuses); | 311 | pci_set_drvdata(dev, smbuses); |
321 | 312 | ||
322 | /* SMBus adapter 1 */ | 313 | /* SMBus adapter 1 */ |
@@ -356,6 +347,7 @@ static void __devexit nforce2_remove(struct pci_dev *dev) | |||
356 | } | 347 | } |
357 | 348 | ||
358 | static struct pci_driver nforce2_driver = { | 349 | static struct pci_driver nforce2_driver = { |
350 | .owner = THIS_MODULE, | ||
359 | .name = "nForce2_smbus", | 351 | .name = "nForce2_smbus", |
360 | .id_table = nforce2_ids, | 352 | .id_table = nforce2_ids, |
361 | .probe = nforce2_probe, | 353 | .probe = nforce2_probe, |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 71a2502fe069..2854d858fc9b 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -155,12 +155,11 @@ static void i2c_parport_attach (struct parport *port) | |||
155 | { | 155 | { |
156 | struct i2c_par *adapter; | 156 | struct i2c_par *adapter; |
157 | 157 | ||
158 | adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); | 158 | adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); |
159 | if (adapter == NULL) { | 159 | if (adapter == NULL) { |
160 | printk(KERN_ERR "i2c-parport: Failed to kmalloc\n"); | 160 | printk(KERN_ERR "i2c-parport: Failed to kzalloc\n"); |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | memset(adapter, 0x00, sizeof(struct i2c_par)); | ||
164 | 163 | ||
165 | pr_debug("i2c-parport: attaching to %s\n", port->name); | 164 | pr_debug("i2c-parport: attaching to %s\n", port->name); |
166 | adapter->pdev = parport_register_device(port, "i2c-parport", | 165 | adapter->pdev = parport_register_device(port, "i2c-parport", |
@@ -232,7 +231,7 @@ static void i2c_parport_detach (struct parport *port) | |||
232 | } | 231 | } |
233 | } | 232 | } |
234 | 233 | ||
235 | static struct parport_driver i2c_driver = { | 234 | static struct parport_driver i2c_parport_driver = { |
236 | .name = "i2c-parport", | 235 | .name = "i2c-parport", |
237 | .attach = i2c_parport_attach, | 236 | .attach = i2c_parport_attach, |
238 | .detach = i2c_parport_detach, | 237 | .detach = i2c_parport_detach, |
@@ -250,12 +249,12 @@ static int __init i2c_parport_init(void) | |||
250 | type = 0; | 249 | type = 0; |
251 | } | 250 | } |
252 | 251 | ||
253 | return parport_register_driver(&i2c_driver); | 252 | return parport_register_driver(&i2c_parport_driver); |
254 | } | 253 | } |
255 | 254 | ||
256 | static void __exit i2c_parport_exit(void) | 255 | static void __exit i2c_parport_exit(void) |
257 | { | 256 | { |
258 | parport_unregister_driver(&i2c_driver); | 257 | parport_unregister_driver(&i2c_parport_driver); |
259 | } | 258 | } |
260 | 259 | ||
261 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 260 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 6d48a4da7bed..7d63eec423fe 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -90,13 +90,13 @@ struct sd { | |||
90 | 90 | ||
91 | /* If force is set to anything different from 0, we forcibly enable the | 91 | /* If force is set to anything different from 0, we forcibly enable the |
92 | PIIX4. DANGEROUS! */ | 92 | PIIX4. DANGEROUS! */ |
93 | static int force = 0; | 93 | static int force; |
94 | module_param (force, int, 0); | 94 | module_param (force, int, 0); |
95 | MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); | 95 | MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); |
96 | 96 | ||
97 | /* If force_addr is set to anything different from 0, we forcibly enable | 97 | /* If force_addr is set to anything different from 0, we forcibly enable |
98 | the PIIX4 at the given address. VERY DANGEROUS! */ | 98 | the PIIX4 at the given address. VERY DANGEROUS! */ |
99 | static int force_addr = 0; | 99 | static int force_addr; |
100 | module_param (force_addr, int, 0); | 100 | module_param (force_addr, int, 0); |
101 | MODULE_PARM_DESC(force_addr, | 101 | MODULE_PARM_DESC(force_addr, |
102 | "Forcibly enable the PIIX4 at the given address. " | 102 | "Forcibly enable the PIIX4 at the given address. " |
@@ -104,14 +104,15 @@ MODULE_PARM_DESC(force_addr, | |||
104 | 104 | ||
105 | /* If fix_hstcfg is set to anything different from 0, we reset one of the | 105 | /* If fix_hstcfg is set to anything different from 0, we reset one of the |
106 | registers to be a valid value. */ | 106 | registers to be a valid value. */ |
107 | static int fix_hstcfg = 0; | 107 | static int fix_hstcfg; |
108 | module_param (fix_hstcfg, int, 0); | 108 | module_param (fix_hstcfg, int, 0); |
109 | MODULE_PARM_DESC(fix_hstcfg, | 109 | MODULE_PARM_DESC(fix_hstcfg, |
110 | "Fix config register. Needed on some boards (Force CPCI735)."); | 110 | "Fix config register. Needed on some boards (Force CPCI735)."); |
111 | 111 | ||
112 | static int piix4_transaction(void); | 112 | static int piix4_transaction(void); |
113 | 113 | ||
114 | static unsigned short piix4_smba = 0; | 114 | static unsigned short piix4_smba; |
115 | static struct pci_driver piix4_driver; | ||
115 | static struct i2c_adapter piix4_adapter; | 116 | static struct i2c_adapter piix4_adapter; |
116 | 117 | ||
117 | static struct dmi_system_id __devinitdata piix4_dmi_table[] = { | 118 | static struct dmi_system_id __devinitdata piix4_dmi_table[] = { |
@@ -157,7 +158,7 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, | |||
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | if (!request_region(piix4_smba, SMBIOSIZE, "piix4-smbus")) { | 161 | if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { |
161 | dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", | 162 | dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", |
162 | piix4_smba); | 163 | piix4_smba); |
163 | return -ENODEV; | 164 | return -ENODEV; |
@@ -407,7 +408,6 @@ static struct i2c_adapter piix4_adapter = { | |||
407 | .owner = THIS_MODULE, | 408 | .owner = THIS_MODULE, |
408 | .class = I2C_CLASS_HWMON, | 409 | .class = I2C_CLASS_HWMON, |
409 | .algo = &smbus_algorithm, | 410 | .algo = &smbus_algorithm, |
410 | .name = "unset", | ||
411 | }; | 411 | }; |
412 | 412 | ||
413 | static struct pci_device_id piix4_ids[] = { | 413 | static struct pci_device_id piix4_ids[] = { |
@@ -462,6 +462,7 @@ static void __devexit piix4_remove(struct pci_dev *dev) | |||
462 | } | 462 | } |
463 | 463 | ||
464 | static struct pci_driver piix4_driver = { | 464 | static struct pci_driver piix4_driver = { |
465 | .owner = THIS_MODULE, | ||
465 | .name = "piix4_smbus", | 466 | .name = "piix4_smbus", |
466 | .id_table = piix4_ids, | 467 | .id_table = piix4_ids, |
467 | .probe = piix4_probe, | 468 | .probe = piix4_probe, |
diff --git a/drivers/i2c/busses/i2c-pmac-smu.c b/drivers/i2c/busses/i2c-pmac-smu.c index 8a9f5648a23d..bfefe7f7a53d 100644 --- a/drivers/i2c/busses/i2c-pmac-smu.c +++ b/drivers/i2c/busses/i2c-pmac-smu.c | |||
@@ -211,12 +211,11 @@ static int create_iface(struct device_node *np, struct device *dev) | |||
211 | } | 211 | } |
212 | busid = *reg; | 212 | busid = *reg; |
213 | 213 | ||
214 | iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL); | 214 | iface = kzalloc(sizeof(struct smu_iface), GFP_KERNEL); |
215 | if (iface == NULL) { | 215 | if (iface == NULL) { |
216 | printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); | 216 | printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); |
217 | return -ENOMEM; | 217 | return -ENOMEM; |
218 | } | 218 | } |
219 | memset(iface, 0, sizeof(struct smu_iface)); | ||
220 | init_completion(&iface->complete); | 219 | init_completion(&iface->complete); |
221 | iface->busid = busid; | 220 | iface->busid = busid; |
222 | 221 | ||
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 83fd16d61ce5..42cb1d8ca659 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -83,11 +83,6 @@ struct s_i2c_chip { | |||
83 | /* | 83 | /* |
84 | * i2c configuration | 84 | * i2c configuration |
85 | */ | 85 | */ |
86 | #ifndef I2C_HW_B_S3VIA | ||
87 | #define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */ | ||
88 | #endif | ||
89 | |||
90 | /* delays */ | ||
91 | #define CYCLE_DELAY 10 | 86 | #define CYCLE_DELAY 10 |
92 | #define TIMEOUT (HZ / 2) | 87 | #define TIMEOUT (HZ / 2) |
93 | 88 | ||
@@ -241,14 +236,12 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic | |||
241 | struct s_i2c_chip *chip; | 236 | struct s_i2c_chip *chip; |
242 | struct s_i2c_bus *bus; | 237 | struct s_i2c_bus *bus; |
243 | 238 | ||
244 | pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); | 239 | pci_set_drvdata(dev, kzalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); |
245 | chip = (struct s_i2c_chip *)pci_get_drvdata(dev); | 240 | chip = (struct s_i2c_chip *)pci_get_drvdata(dev); |
246 | if (chip == NULL) { | 241 | if (chip == NULL) { |
247 | return -ENOMEM; | 242 | return -ENOMEM; |
248 | } | 243 | } |
249 | 244 | ||
250 | memset(chip, 0, sizeof(struct s_i2c_chip)); | ||
251 | |||
252 | base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; | 245 | base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; |
253 | len = dev->resource[0].end - base + 1; | 246 | len = dev->resource[0].end - base + 1; |
254 | chip->mmio = ioremap_nocache(base, len); | 247 | chip->mmio = ioremap_nocache(base, len); |
@@ -308,6 +301,7 @@ static struct pci_device_id prosavage_pci_tbl[] = { | |||
308 | MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); | 301 | MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); |
309 | 302 | ||
310 | static struct pci_driver prosavage_driver = { | 303 | static struct pci_driver prosavage_driver = { |
304 | .owner = THIS_MODULE, | ||
311 | .name = "prosavage_smbus", | 305 | .name = "prosavage_smbus", |
312 | .id_table = prosavage_pci_tbl, | 306 | .id_table = prosavage_pci_tbl, |
313 | .probe = prosavage_probe, | 307 | .probe = prosavage_probe, |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 69fa282df2d5..6ced28e90070 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -896,6 +896,7 @@ static int s3c24xx_i2c_resume(struct device *dev) | |||
896 | /* device driver for platform bus bits */ | 896 | /* device driver for platform bus bits */ |
897 | 897 | ||
898 | static struct device_driver s3c2410_i2c_driver = { | 898 | static struct device_driver s3c2410_i2c_driver = { |
899 | .owner = THIS_MODULE, | ||
899 | .name = "s3c2410-i2c", | 900 | .name = "s3c2410-i2c", |
900 | .bus = &platform_bus_type, | 901 | .bus = &platform_bus_type, |
901 | .probe = s3c24xx_i2c_probe, | 902 | .probe = s3c24xx_i2c_probe, |
@@ -904,6 +905,7 @@ static struct device_driver s3c2410_i2c_driver = { | |||
904 | }; | 905 | }; |
905 | 906 | ||
906 | static struct device_driver s3c2440_i2c_driver = { | 907 | static struct device_driver s3c2440_i2c_driver = { |
908 | .owner = THIS_MODULE, | ||
907 | .name = "s3c2440-i2c", | 909 | .name = "s3c2440-i2c", |
908 | .bus = &platform_bus_type, | 910 | .bus = &platform_bus_type, |
909 | .probe = s3c24xx_i2c_probe, | 911 | .probe = s3c24xx_i2c_probe, |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 0c8518298e4d..aebe87ba4033 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -179,6 +179,7 @@ static void __devexit savage4_remove(struct pci_dev *dev) | |||
179 | } | 179 | } |
180 | 180 | ||
181 | static struct pci_driver savage4_driver = { | 181 | static struct pci_driver savage4_driver = { |
182 | .owner = THIS_MODULE, | ||
182 | .name = "savage4_smbus", | 183 | .name = "savage4_smbus", |
183 | .id_table = savage4_ids, | 184 | .id_table = savage4_ids, |
184 | .probe = savage4_probe, | 185 | .probe = savage4_probe, |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 080318d6f54b..3ad27c3ba15b 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -123,11 +123,12 @@ static int blacklist[] = { | |||
123 | 123 | ||
124 | /* If force_addr is set to anything different from 0, we forcibly enable | 124 | /* If force_addr is set to anything different from 0, we forcibly enable |
125 | the device at the given address. */ | 125 | the device at the given address. */ |
126 | static u16 force_addr = 0; | 126 | static u16 force_addr; |
127 | module_param(force_addr, ushort, 0); | 127 | module_param(force_addr, ushort, 0); |
128 | MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); | 128 | MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); |
129 | 129 | ||
130 | static unsigned short sis5595_base = 0; | 130 | static struct pci_driver sis5595_driver; |
131 | static unsigned short sis5595_base; | ||
131 | 132 | ||
132 | static u8 sis5595_read(u8 reg) | 133 | static u8 sis5595_read(u8 reg) |
133 | { | 134 | { |
@@ -172,7 +173,8 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) | |||
172 | 173 | ||
173 | /* NB: We grab just the two SMBus registers here, but this may still | 174 | /* NB: We grab just the two SMBus registers here, but this may still |
174 | * interfere with ACPI :-( */ | 175 | * interfere with ACPI :-( */ |
175 | if (!request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus")) { | 176 | if (!request_region(sis5595_base + SMB_INDEX, 2, |
177 | sis5595_driver.name)) { | ||
176 | dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", | 178 | dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", |
177 | sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); | 179 | sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); |
178 | return -ENODEV; | 180 | return -ENODEV; |
@@ -364,7 +366,6 @@ static struct i2c_algorithm smbus_algorithm = { | |||
364 | static struct i2c_adapter sis5595_adapter = { | 366 | static struct i2c_adapter sis5595_adapter = { |
365 | .owner = THIS_MODULE, | 367 | .owner = THIS_MODULE, |
366 | .class = I2C_CLASS_HWMON, | 368 | .class = I2C_CLASS_HWMON, |
367 | .name = "unset", | ||
368 | .algo = &smbus_algorithm, | 369 | .algo = &smbus_algorithm, |
369 | }; | 370 | }; |
370 | 371 | ||
@@ -397,6 +398,7 @@ static void __devexit sis5595_remove(struct pci_dev *dev) | |||
397 | } | 398 | } |
398 | 399 | ||
399 | static struct pci_driver sis5595_driver = { | 400 | static struct pci_driver sis5595_driver = { |
401 | .owner = THIS_MODULE, | ||
400 | .name = "sis5595_smbus", | 402 | .name = "sis5595_smbus", |
401 | .id_table = sis5595_ids, | 403 | .id_table = sis5595_ids, |
402 | .probe = sis5595_probe, | 404 | .probe = sis5595_probe, |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 86f0f448fa0b..7f49e5fd3ff0 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -92,6 +92,8 @@ | |||
92 | #define SIS630_PCALL 0x04 | 92 | #define SIS630_PCALL 0x04 |
93 | #define SIS630_BLOCK_DATA 0x05 | 93 | #define SIS630_BLOCK_DATA 0x05 |
94 | 94 | ||
95 | static struct pci_driver sis630_driver; | ||
96 | |||
95 | /* insmod parameters */ | 97 | /* insmod parameters */ |
96 | static int high_clock; | 98 | static int high_clock; |
97 | static int force; | 99 | static int force; |
@@ -101,7 +103,7 @@ module_param(force, bool, 0); | |||
101 | MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); | 103 | MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); |
102 | 104 | ||
103 | /* acpi base address */ | 105 | /* acpi base address */ |
104 | static unsigned short acpi_base = 0; | 106 | static unsigned short acpi_base; |
105 | 107 | ||
106 | /* supported chips */ | 108 | /* supported chips */ |
107 | static int supported[] = { | 109 | static int supported[] = { |
@@ -432,7 +434,8 @@ static int sis630_setup(struct pci_dev *sis630_dev) | |||
432 | dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); | 434 | dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); |
433 | 435 | ||
434 | /* Everything is happy, let's grab the memory and set things up. */ | 436 | /* Everything is happy, let's grab the memory and set things up. */ |
435 | if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")) { | 437 | if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, |
438 | sis630_driver.name)) { | ||
436 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " | 439 | dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " |
437 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); | 440 | "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); |
438 | goto exit; | 441 | goto exit; |
@@ -455,7 +458,6 @@ static struct i2c_algorithm smbus_algorithm = { | |||
455 | static struct i2c_adapter sis630_adapter = { | 458 | static struct i2c_adapter sis630_adapter = { |
456 | .owner = THIS_MODULE, | 459 | .owner = THIS_MODULE, |
457 | .class = I2C_CLASS_HWMON, | 460 | .class = I2C_CLASS_HWMON, |
458 | .name = "unset", | ||
459 | .algo = &smbus_algorithm, | 461 | .algo = &smbus_algorithm, |
460 | }; | 462 | }; |
461 | 463 | ||
@@ -494,6 +496,7 @@ static void __devexit sis630_remove(struct pci_dev *dev) | |||
494 | 496 | ||
495 | 497 | ||
496 | static struct pci_driver sis630_driver = { | 498 | static struct pci_driver sis630_driver = { |
499 | .owner = THIS_MODULE, | ||
497 | .name = "sis630_smbus", | 500 | .name = "sis630_smbus", |
498 | .id_table = sis630_ids, | 501 | .id_table = sis630_ids, |
499 | .probe = sis630_probe, | 502 | .probe = sis630_probe, |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index ead2ff3cf60e..6a134c091324 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -82,8 +82,9 @@ | |||
82 | #define SIS96x_PROC_CALL 0x04 | 82 | #define SIS96x_PROC_CALL 0x04 |
83 | #define SIS96x_BLOCK_DATA 0x05 | 83 | #define SIS96x_BLOCK_DATA 0x05 |
84 | 84 | ||
85 | static struct pci_driver sis96x_driver; | ||
85 | static struct i2c_adapter sis96x_adapter; | 86 | static struct i2c_adapter sis96x_adapter; |
86 | static u16 sis96x_smbus_base = 0; | 87 | static u16 sis96x_smbus_base; |
87 | 88 | ||
88 | static inline u8 sis96x_read(u8 reg) | 89 | static inline u8 sis96x_read(u8 reg) |
89 | { | 90 | { |
@@ -257,7 +258,6 @@ static struct i2c_adapter sis96x_adapter = { | |||
257 | .owner = THIS_MODULE, | 258 | .owner = THIS_MODULE, |
258 | .class = I2C_CLASS_HWMON, | 259 | .class = I2C_CLASS_HWMON, |
259 | .algo = &smbus_algorithm, | 260 | .algo = &smbus_algorithm, |
260 | .name = "unset", | ||
261 | }; | 261 | }; |
262 | 262 | ||
263 | static struct pci_device_id sis96x_ids[] = { | 263 | static struct pci_device_id sis96x_ids[] = { |
@@ -294,7 +294,8 @@ static int __devinit sis96x_probe(struct pci_dev *dev, | |||
294 | sis96x_smbus_base); | 294 | sis96x_smbus_base); |
295 | 295 | ||
296 | /* Everything is happy, let's grab the memory and set things up. */ | 296 | /* Everything is happy, let's grab the memory and set things up. */ |
297 | if (!request_region(sis96x_smbus_base, SMB_IOSIZE, "sis96x-smbus")) { | 297 | if (!request_region(sis96x_smbus_base, SMB_IOSIZE, |
298 | sis96x_driver.name)) { | ||
298 | dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " | 299 | dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " |
299 | "already in use!\n", sis96x_smbus_base, | 300 | "already in use!\n", sis96x_smbus_base, |
300 | sis96x_smbus_base + SMB_IOSIZE - 1); | 301 | sis96x_smbus_base + SMB_IOSIZE - 1); |
@@ -328,6 +329,7 @@ static void __devexit sis96x_remove(struct pci_dev *dev) | |||
328 | } | 329 | } |
329 | 330 | ||
330 | static struct pci_driver sis96x_driver = { | 331 | static struct pci_driver sis96x_driver = { |
332 | .owner = THIS_MODULE, | ||
331 | .name = "sis96x_smbus", | 333 | .name = "sis96x_smbus", |
332 | .id_table = sis96x_ids, | 334 | .id_table = sis96x_ids, |
333 | .probe = sis96x_probe, | 335 | .probe = sis96x_probe, |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 040b8abeabba..544a38e64394 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -43,9 +43,9 @@ | |||
43 | 43 | ||
44 | /* io-region reservation */ | 44 | /* io-region reservation */ |
45 | #define IOSPACE 0x06 | 45 | #define IOSPACE 0x06 |
46 | #define IOTEXT "via-i2c" | ||
47 | 46 | ||
48 | static u16 pm_io_base = 0; | 47 | static struct pci_driver vt586b_driver; |
48 | static u16 pm_io_base; | ||
49 | 49 | ||
50 | /* | 50 | /* |
51 | It does not appear from the datasheet that the GPIO pins are | 51 | It does not appear from the datasheet that the GPIO pins are |
@@ -130,7 +130,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i | |||
130 | pci_read_config_word(dev, base, &pm_io_base); | 130 | pci_read_config_word(dev, base, &pm_io_base); |
131 | pm_io_base &= (0xff << 8); | 131 | pm_io_base &= (0xff << 8); |
132 | 132 | ||
133 | if (!request_region(I2C_DIR, IOSPACE, IOTEXT)) { | 133 | if (!request_region(I2C_DIR, IOSPACE, vt586b_driver.name)) { |
134 | dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); | 134 | dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); |
135 | return -ENODEV; | 135 | return -ENODEV; |
136 | } | 136 | } |
@@ -159,6 +159,7 @@ static void __devexit vt586b_remove(struct pci_dev *dev) | |||
159 | 159 | ||
160 | 160 | ||
161 | static struct pci_driver vt586b_driver = { | 161 | static struct pci_driver vt586b_driver = { |
162 | .owner = THIS_MODULE, | ||
162 | .name = "vt586b_smbus", | 163 | .name = "vt586b_smbus", |
163 | .id_table = vt586b_ids, | 164 | .id_table = vt586b_ids, |
164 | .probe = vt586b_probe, | 165 | .probe = vt586b_probe, |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 99d209e0485a..c9366b504833 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | monitoring |
4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, | 5 | Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, |
6 | Mark D. Studebaker <mdsxyz123@yahoo.com> | 6 | Mark D. Studebaker <mdsxyz123@yahoo.com> |
7 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | ||
7 | 8 | ||
8 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by |
@@ -21,15 +22,19 @@ | |||
21 | */ | 22 | */ |
22 | 23 | ||
23 | /* | 24 | /* |
24 | Supports Via devices: | 25 | Supports the following VIA south bridges: |
25 | 82C596A/B (0x3050) | 26 | |
26 | 82C596B (0x3051) | 27 | Chip name PCI ID REV I2C block |
27 | 82C686A/B | 28 | VT82C596A 0x3050 no |
28 | 8231 | 29 | VT82C596B 0x3051 no |
29 | 8233 | 30 | VT82C686A 0x3057 0x30 no |
30 | 8233A (0x3147 and 0x3177) | 31 | VT82C686B 0x3057 0x40 yes |
31 | 8235 | 32 | VT8231 0x8235 no? |
32 | 8237 | 33 | VT8233 0x3074 yes |
34 | VT8233A 0x3147 yes? | ||
35 | VT8235 0x3177 yes | ||
36 | VT8237R 0x3227 yes | ||
37 | |||
33 | Note: we assume there can only be one device, with one SMBus interface. | 38 | Note: we assume there can only be one device, with one SMBus interface. |
34 | */ | 39 | */ |
35 | 40 | ||
@@ -38,7 +43,6 @@ | |||
38 | #include <linux/pci.h> | 43 | #include <linux/pci.h> |
39 | #include <linux/kernel.h> | 44 | #include <linux/kernel.h> |
40 | #include <linux/stddef.h> | 45 | #include <linux/stddef.h> |
41 | #include <linux/sched.h> | ||
42 | #include <linux/ioport.h> | 46 | #include <linux/ioport.h> |
43 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
44 | #include <linux/init.h> | 48 | #include <linux/init.h> |
@@ -46,48 +50,37 @@ | |||
46 | 50 | ||
47 | static struct pci_dev *vt596_pdev; | 51 | static struct pci_dev *vt596_pdev; |
48 | 52 | ||
49 | #define SMBBA1 0x90 | 53 | #define SMBBA1 0x90 |
50 | #define SMBBA2 0x80 | 54 | #define SMBBA2 0x80 |
51 | #define SMBBA3 0xD0 | 55 | #define SMBBA3 0xD0 |
52 | 56 | ||
53 | /* SMBus address offsets */ | 57 | /* SMBus address offsets */ |
54 | static unsigned short vt596_smba; | 58 | static unsigned short vt596_smba; |
55 | #define SMBHSTSTS (vt596_smba + 0) | 59 | #define SMBHSTSTS (vt596_smba + 0) |
56 | #define SMBHSLVSTS (vt596_smba + 1) | ||
57 | #define SMBHSTCNT (vt596_smba + 2) | 60 | #define SMBHSTCNT (vt596_smba + 2) |
58 | #define SMBHSTCMD (vt596_smba + 3) | 61 | #define SMBHSTCMD (vt596_smba + 3) |
59 | #define SMBHSTADD (vt596_smba + 4) | 62 | #define SMBHSTADD (vt596_smba + 4) |
60 | #define SMBHSTDAT0 (vt596_smba + 5) | 63 | #define SMBHSTDAT0 (vt596_smba + 5) |
61 | #define SMBHSTDAT1 (vt596_smba + 6) | 64 | #define SMBHSTDAT1 (vt596_smba + 6) |
62 | #define SMBBLKDAT (vt596_smba + 7) | 65 | #define SMBBLKDAT (vt596_smba + 7) |
63 | #define SMBSLVCNT (vt596_smba + 8) | ||
64 | #define SMBSHDWCMD (vt596_smba + 9) | ||
65 | #define SMBSLVEVT (vt596_smba + 0xA) | ||
66 | #define SMBSLVDAT (vt596_smba + 0xC) | ||
67 | 66 | ||
68 | /* PCI Address Constants */ | 67 | /* PCI Address Constants */ |
69 | 68 | ||
70 | /* SMBus data in configuration space can be found in two places, | 69 | /* SMBus data in configuration space can be found in two places, |
71 | We try to select the better one*/ | 70 | We try to select the better one */ |
72 | |||
73 | static unsigned short smb_cf_hstcfg = 0xD2; | ||
74 | 71 | ||
75 | #define SMBHSTCFG (smb_cf_hstcfg) | 72 | static unsigned short SMBHSTCFG = 0xD2; |
76 | #define SMBSLVC (smb_cf_hstcfg + 1) | ||
77 | #define SMBSHDW1 (smb_cf_hstcfg + 2) | ||
78 | #define SMBSHDW2 (smb_cf_hstcfg + 3) | ||
79 | #define SMBREV (smb_cf_hstcfg + 4) | ||
80 | 73 | ||
81 | /* Other settings */ | 74 | /* Other settings */ |
82 | #define MAX_TIMEOUT 500 | 75 | #define MAX_TIMEOUT 500 |
83 | #define ENABLE_INT9 0 | ||
84 | 76 | ||
85 | /* VT82C596 constants */ | 77 | /* VT82C596 constants */ |
86 | #define VT596_QUICK 0x00 | 78 | #define VT596_QUICK 0x00 |
87 | #define VT596_BYTE 0x04 | 79 | #define VT596_BYTE 0x04 |
88 | #define VT596_BYTE_DATA 0x08 | 80 | #define VT596_BYTE_DATA 0x08 |
89 | #define VT596_WORD_DATA 0x0C | 81 | #define VT596_WORD_DATA 0x0C |
90 | #define VT596_BLOCK_DATA 0x14 | 82 | #define VT596_BLOCK_DATA 0x14 |
83 | #define VT596_I2C_BLOCK_DATA 0x34 | ||
91 | 84 | ||
92 | 85 | ||
93 | /* If force is set to anything different from 0, we forcibly enable the | 86 | /* If force is set to anything different from 0, we forcibly enable the |
@@ -105,40 +98,65 @@ MODULE_PARM_DESC(force_addr, | |||
105 | "EXTREMELY DANGEROUS!"); | 98 | "EXTREMELY DANGEROUS!"); |
106 | 99 | ||
107 | 100 | ||
101 | static struct pci_driver vt596_driver; | ||
108 | static struct i2c_adapter vt596_adapter; | 102 | static struct i2c_adapter vt596_adapter; |
109 | 103 | ||
110 | /* Another internally used function */ | 104 | #define FEATURE_I2CBLOCK (1<<0) |
111 | static int vt596_transaction(void) | 105 | static unsigned int vt596_features; |
106 | |||
107 | #ifdef DEBUG | ||
108 | static void vt596_dump_regs(const char *msg, u8 size) | ||
109 | { | ||
110 | dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x " | ||
111 | "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), | ||
112 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
113 | inb_p(SMBHSTDAT1)); | ||
114 | |||
115 | if (size == VT596_BLOCK_DATA | ||
116 | || size == VT596_I2C_BLOCK_DATA) { | ||
117 | int i; | ||
118 | |||
119 | dev_dbg(&vt596_adapter.dev, "BLK="); | ||
120 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++) | ||
121 | printk("%02x,", inb_p(SMBBLKDAT)); | ||
122 | printk("\n"); | ||
123 | dev_dbg(&vt596_adapter.dev, " "); | ||
124 | for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++) | ||
125 | printk("%02x,", inb_p(SMBBLKDAT)); | ||
126 | printk("%02x\n", inb_p(SMBBLKDAT)); | ||
127 | } | ||
128 | } | ||
129 | #else | ||
130 | static inline void vt596_dump_regs(const char *msg, u8 size) { } | ||
131 | #endif | ||
132 | |||
133 | /* Return -1 on error, 0 on success */ | ||
134 | static int vt596_transaction(u8 size) | ||
112 | { | 135 | { |
113 | int temp; | 136 | int temp; |
114 | int result = 0; | 137 | int result = 0; |
115 | int timeout = 0; | 138 | int timeout = 0; |
116 | 139 | ||
117 | dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " | 140 | vt596_dump_regs("Transaction (pre)", size); |
118 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | ||
119 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
120 | inb_p(SMBHSTDAT1)); | ||
121 | 141 | ||
122 | /* Make sure the SMBus host is ready to start transmitting */ | 142 | /* Make sure the SMBus host is ready to start transmitting */ |
123 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 143 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { |
124 | dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " | 144 | dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " |
125 | "Resetting...\n", temp); | 145 | "Resetting... ", temp); |
126 | 146 | ||
127 | outb_p(temp, SMBHSTSTS); | 147 | outb_p(temp, SMBHSTSTS); |
128 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 148 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { |
129 | dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp); | 149 | printk("Failed! (0x%02x)\n", temp); |
130 | |||
131 | return -1; | 150 | return -1; |
132 | } else { | 151 | } else { |
133 | dev_dbg(&vt596_adapter.dev, "Successfull!\n"); | 152 | printk("Successful!\n"); |
134 | } | 153 | } |
135 | } | 154 | } |
136 | 155 | ||
137 | /* start the transaction by setting bit 6 */ | 156 | /* Start the transaction by setting bit 6 */ |
138 | outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); | 157 | outb_p(0x40 | (size & 0x3C), SMBHSTCNT); |
139 | 158 | ||
140 | /* We will always wait for a fraction of a second! | 159 | /* We will always wait for a fraction of a second */ |
141 | I don't know if VIA needs this, Intel did */ | ||
142 | do { | 160 | do { |
143 | msleep(1); | 161 | msleep(1); |
144 | temp = inb_p(SMBHSTSTS); | 162 | temp = inb_p(SMBHSTSTS); |
@@ -147,77 +165,61 @@ static int vt596_transaction(void) | |||
147 | /* If the SMBus is still busy, we give up */ | 165 | /* If the SMBus is still busy, we give up */ |
148 | if (timeout >= MAX_TIMEOUT) { | 166 | if (timeout >= MAX_TIMEOUT) { |
149 | result = -1; | 167 | result = -1; |
150 | dev_dbg(&vt596_adapter.dev, "SMBus Timeout!\n"); | 168 | dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); |
151 | } | 169 | } |
152 | 170 | ||
153 | if (temp & 0x10) { | 171 | if (temp & 0x10) { |
154 | result = -1; | 172 | result = -1; |
155 | dev_dbg(&vt596_adapter.dev, "Error: Failed bus transaction\n"); | 173 | dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n", |
174 | inb_p(SMBHSTCNT) & 0x3C); | ||
156 | } | 175 | } |
157 | 176 | ||
158 | if (temp & 0x08) { | 177 | if (temp & 0x08) { |
159 | result = -1; | 178 | result = -1; |
160 | dev_info(&vt596_adapter.dev, "Bus collision! SMBus may be " | 179 | dev_err(&vt596_adapter.dev, "SMBus collision!\n"); |
161 | "locked until next hard\nreset. (sorry!)\n"); | ||
162 | /* Clock stops and slave is stuck in mid-transmission */ | ||
163 | } | 180 | } |
164 | 181 | ||
165 | if (temp & 0x04) { | 182 | if (temp & 0x04) { |
166 | result = -1; | 183 | result = -1; |
167 | dev_dbg(&vt596_adapter.dev, "Error: no response!\n"); | 184 | /* Quick commands are used to probe for chips, so |
185 | errors are expected, and we don't want to frighten the | ||
186 | user. */ | ||
187 | if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK) | ||
188 | dev_err(&vt596_adapter.dev, "Transaction error!\n"); | ||
168 | } | 189 | } |
169 | 190 | ||
170 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | 191 | /* Resetting status register */ |
192 | if (temp & 0x1F) | ||
171 | outb_p(temp, SMBHSTSTS); | 193 | outb_p(temp, SMBHSTSTS); |
172 | if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { | ||
173 | dev_warn(&vt596_adapter.dev, "Failed reset at end " | ||
174 | "of transaction (%02x)\n", temp); | ||
175 | } | ||
176 | } | ||
177 | 194 | ||
178 | dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " | 195 | vt596_dump_regs("Transaction (post)", size); |
179 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | 196 | |
180 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | ||
181 | inb_p(SMBHSTDAT1)); | ||
182 | |||
183 | return result; | 197 | return result; |
184 | } | 198 | } |
185 | 199 | ||
186 | /* Return -1 on error. */ | 200 | /* Return -1 on error, 0 on success */ |
187 | static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | 201 | static s32 vt596_access(struct i2c_adapter *adap, u16 addr, |
188 | unsigned short flags, char read_write, u8 command, | 202 | unsigned short flags, char read_write, u8 command, |
189 | int size, union i2c_smbus_data *data) | 203 | int size, union i2c_smbus_data *data) |
190 | { | 204 | { |
191 | int i, len; | 205 | int i; |
192 | 206 | ||
193 | switch (size) { | 207 | switch (size) { |
194 | case I2C_SMBUS_PROC_CALL: | ||
195 | dev_info(&vt596_adapter.dev, | ||
196 | "I2C_SMBUS_PROC_CALL not supported!\n"); | ||
197 | return -1; | ||
198 | case I2C_SMBUS_QUICK: | 208 | case I2C_SMBUS_QUICK: |
199 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
200 | SMBHSTADD); | ||
201 | size = VT596_QUICK; | 209 | size = VT596_QUICK; |
202 | break; | 210 | break; |
203 | case I2C_SMBUS_BYTE: | 211 | case I2C_SMBUS_BYTE: |
204 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
205 | SMBHSTADD); | ||
206 | if (read_write == I2C_SMBUS_WRITE) | 212 | if (read_write == I2C_SMBUS_WRITE) |
207 | outb_p(command, SMBHSTCMD); | 213 | outb_p(command, SMBHSTCMD); |
208 | size = VT596_BYTE; | 214 | size = VT596_BYTE; |
209 | break; | 215 | break; |
210 | case I2C_SMBUS_BYTE_DATA: | 216 | case I2C_SMBUS_BYTE_DATA: |
211 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
212 | SMBHSTADD); | ||
213 | outb_p(command, SMBHSTCMD); | 217 | outb_p(command, SMBHSTCMD); |
214 | if (read_write == I2C_SMBUS_WRITE) | 218 | if (read_write == I2C_SMBUS_WRITE) |
215 | outb_p(data->byte, SMBHSTDAT0); | 219 | outb_p(data->byte, SMBHSTDAT0); |
216 | size = VT596_BYTE_DATA; | 220 | size = VT596_BYTE_DATA; |
217 | break; | 221 | break; |
218 | case I2C_SMBUS_WORD_DATA: | 222 | case I2C_SMBUS_WORD_DATA: |
219 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
220 | SMBHSTADD); | ||
221 | outb_p(command, SMBHSTCMD); | 223 | outb_p(command, SMBHSTCMD); |
222 | if (read_write == I2C_SMBUS_WRITE) { | 224 | if (read_write == I2C_SMBUS_WRITE) { |
223 | outb_p(data->word & 0xff, SMBHSTDAT0); | 225 | outb_p(data->word & 0xff, SMBHSTDAT0); |
@@ -225,28 +227,33 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
225 | } | 227 | } |
226 | size = VT596_WORD_DATA; | 228 | size = VT596_WORD_DATA; |
227 | break; | 229 | break; |
230 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
231 | if (!(vt596_features & FEATURE_I2CBLOCK)) | ||
232 | goto exit_unsupported; | ||
233 | if (read_write == I2C_SMBUS_READ) | ||
234 | outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0); | ||
235 | /* Fall through */ | ||
228 | case I2C_SMBUS_BLOCK_DATA: | 236 | case I2C_SMBUS_BLOCK_DATA: |
229 | outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), | ||
230 | SMBHSTADD); | ||
231 | outb_p(command, SMBHSTCMD); | 237 | outb_p(command, SMBHSTCMD); |
232 | if (read_write == I2C_SMBUS_WRITE) { | 238 | if (read_write == I2C_SMBUS_WRITE) { |
233 | len = data->block[0]; | 239 | u8 len = data->block[0]; |
234 | if (len < 0) | ||
235 | len = 0; | ||
236 | if (len > I2C_SMBUS_BLOCK_MAX) | 240 | if (len > I2C_SMBUS_BLOCK_MAX) |
237 | len = I2C_SMBUS_BLOCK_MAX; | 241 | len = I2C_SMBUS_BLOCK_MAX; |
238 | outb_p(len, SMBHSTDAT0); | 242 | outb_p(len, SMBHSTDAT0); |
239 | i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ | 243 | inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ |
240 | for (i = 1; i <= len; i++) | 244 | for (i = 1; i <= len; i++) |
241 | outb_p(data->block[i], SMBBLKDAT); | 245 | outb_p(data->block[i], SMBBLKDAT); |
242 | } | 246 | } |
243 | size = VT596_BLOCK_DATA; | 247 | size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ? |
248 | VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA; | ||
244 | break; | 249 | break; |
250 | default: | ||
251 | goto exit_unsupported; | ||
245 | } | 252 | } |
246 | 253 | ||
247 | outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); | 254 | outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD); |
248 | 255 | ||
249 | if (vt596_transaction()) /* Error in transaction */ | 256 | if (vt596_transaction(size)) /* Error in transaction */ |
250 | return -1; | 257 | return -1; |
251 | 258 | ||
252 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) | 259 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) |
@@ -254,35 +261,39 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
254 | 261 | ||
255 | switch (size) { | 262 | switch (size) { |
256 | case VT596_BYTE: | 263 | case VT596_BYTE: |
257 | /* Where is the result put? I assume here it is in | ||
258 | * SMBHSTDAT0 but it might just as well be in the | ||
259 | * SMBHSTCMD. No clue in the docs | ||
260 | */ | ||
261 | data->byte = inb_p(SMBHSTDAT0); | ||
262 | break; | ||
263 | case VT596_BYTE_DATA: | 264 | case VT596_BYTE_DATA: |
264 | data->byte = inb_p(SMBHSTDAT0); | 265 | data->byte = inb_p(SMBHSTDAT0); |
265 | break; | 266 | break; |
266 | case VT596_WORD_DATA: | 267 | case VT596_WORD_DATA: |
267 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); | 268 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); |
268 | break; | 269 | break; |
270 | case VT596_I2C_BLOCK_DATA: | ||
269 | case VT596_BLOCK_DATA: | 271 | case VT596_BLOCK_DATA: |
270 | data->block[0] = inb_p(SMBHSTDAT0); | 272 | data->block[0] = inb_p(SMBHSTDAT0); |
271 | if (data->block[0] > I2C_SMBUS_BLOCK_MAX) | 273 | if (data->block[0] > I2C_SMBUS_BLOCK_MAX) |
272 | data->block[0] = I2C_SMBUS_BLOCK_MAX; | 274 | data->block[0] = I2C_SMBUS_BLOCK_MAX; |
273 | i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ | 275 | inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ |
274 | for (i = 1; i <= data->block[0]; i++) | 276 | for (i = 1; i <= data->block[0]; i++) |
275 | data->block[i] = inb_p(SMBBLKDAT); | 277 | data->block[i] = inb_p(SMBBLKDAT); |
276 | break; | 278 | break; |
277 | } | 279 | } |
278 | return 0; | 280 | return 0; |
281 | |||
282 | exit_unsupported: | ||
283 | dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", | ||
284 | size); | ||
285 | return -1; | ||
279 | } | 286 | } |
280 | 287 | ||
281 | static u32 vt596_func(struct i2c_adapter *adapter) | 288 | static u32 vt596_func(struct i2c_adapter *adapter) |
282 | { | 289 | { |
283 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 290 | u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
284 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 291 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
285 | I2C_FUNC_SMBUS_BLOCK_DATA; | 292 | I2C_FUNC_SMBUS_BLOCK_DATA; |
293 | |||
294 | if (vt596_features & FEATURE_I2CBLOCK) | ||
295 | func |= I2C_FUNC_SMBUS_I2C_BLOCK; | ||
296 | return func; | ||
286 | } | 297 | } |
287 | 298 | ||
288 | static struct i2c_algorithm smbus_algorithm = { | 299 | static struct i2c_algorithm smbus_algorithm = { |
@@ -294,7 +305,6 @@ static struct i2c_adapter vt596_adapter = { | |||
294 | .owner = THIS_MODULE, | 305 | .owner = THIS_MODULE, |
295 | .class = I2C_CLASS_HWMON, | 306 | .class = I2C_CLASS_HWMON, |
296 | .algo = &smbus_algorithm, | 307 | .algo = &smbus_algorithm, |
297 | .name = "unset", | ||
298 | }; | 308 | }; |
299 | 309 | ||
300 | static int __devinit vt596_probe(struct pci_dev *pdev, | 310 | static int __devinit vt596_probe(struct pci_dev *pdev, |
@@ -302,7 +312,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
302 | { | 312 | { |
303 | unsigned char temp; | 313 | unsigned char temp; |
304 | int error = -ENODEV; | 314 | int error = -ENODEV; |
305 | 315 | ||
306 | /* Determine the address of the SMBus areas */ | 316 | /* Determine the address of the SMBus areas */ |
307 | if (force_addr) { | 317 | if (force_addr) { |
308 | vt596_smba = force_addr & 0xfff0; | 318 | vt596_smba = force_addr & 0xfff0; |
@@ -311,12 +321,12 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
311 | } | 321 | } |
312 | 322 | ||
313 | if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || | 323 | if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || |
314 | !(vt596_smba & 0x1)) { | 324 | !(vt596_smba & 0x0001)) { |
315 | /* try 2nd address and config reg. for 596 */ | 325 | /* try 2nd address and config reg. for 596 */ |
316 | if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && | 326 | if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && |
317 | !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && | 327 | !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && |
318 | (vt596_smba & 0x1)) { | 328 | (vt596_smba & 0x0001)) { |
319 | smb_cf_hstcfg = 0x84; | 329 | SMBHSTCFG = 0x84; |
320 | } else { | 330 | } else { |
321 | /* no matches at all */ | 331 | /* no matches at all */ |
322 | dev_err(&pdev->dev, "Cannot configure " | 332 | dev_err(&pdev->dev, "Cannot configure " |
@@ -333,10 +343,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
333 | return -ENODEV; | 343 | return -ENODEV; |
334 | } | 344 | } |
335 | 345 | ||
336 | found: | 346 | found: |
337 | if (!request_region(vt596_smba, 8, "viapro-smbus")) { | 347 | if (!request_region(vt596_smba, 8, vt596_driver.name)) { |
338 | dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", | 348 | dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", |
339 | vt596_smba); | 349 | vt596_smba); |
340 | return -ENODEV; | 350 | return -ENODEV; |
341 | } | 351 | } |
342 | 352 | ||
@@ -348,16 +358,16 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
348 | pci_write_config_word(pdev, id->driver_data, vt596_smba); | 358 | pci_write_config_word(pdev, id->driver_data, vt596_smba); |
349 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); | 359 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); |
350 | dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " | 360 | dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " |
351 | "address 0x%04x!\n", vt596_smba); | 361 | "address 0x%04x!\n", vt596_smba); |
352 | } else if ((temp & 1) == 0) { | 362 | } else if (!(temp & 0x01)) { |
353 | if (force) { | 363 | if (force) { |
354 | /* NOTE: This assumes I/O space and other allocations | 364 | /* NOTE: This assumes I/O space and other allocations |
355 | * WERE done by the Bios! Don't complain if your | 365 | * WERE done by the Bios! Don't complain if your |
356 | * hardware does weird things after enabling this. | 366 | * hardware does weird things after enabling this. |
357 | * :') Check for Bios updates before resorting to | 367 | * :') Check for Bios updates before resorting to |
358 | * this. | 368 | * this. |
359 | */ | 369 | */ |
360 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 1); | 370 | pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); |
361 | dev_info(&pdev->dev, "Enabling SMBus device\n"); | 371 | dev_info(&pdev->dev, "Enabling SMBus device\n"); |
362 | } else { | 372 | } else { |
363 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " | 373 | dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " |
@@ -367,22 +377,28 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
367 | } | 377 | } |
368 | } | 378 | } |
369 | 379 | ||
370 | if ((temp & 0x0E) == 8) | ||
371 | dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n"); | ||
372 | else if ((temp & 0x0E) == 0) | ||
373 | dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n"); | ||
374 | else | ||
375 | dev_dbg(&pdev->dev, "Illegal Interrupt configuration " | ||
376 | "(or code out of date)!\n"); | ||
377 | |||
378 | pci_read_config_byte(pdev, SMBREV, &temp); | ||
379 | dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp); | ||
380 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); | 380 | dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); |
381 | 381 | ||
382 | switch (pdev->device) { | ||
383 | case PCI_DEVICE_ID_VIA_8237: | ||
384 | case PCI_DEVICE_ID_VIA_8235: | ||
385 | case PCI_DEVICE_ID_VIA_8233A: | ||
386 | case PCI_DEVICE_ID_VIA_8233_0: | ||
387 | vt596_features |= FEATURE_I2CBLOCK; | ||
388 | break; | ||
389 | case PCI_DEVICE_ID_VIA_82C686_4: | ||
390 | /* The VT82C686B (rev 0x40) does support I2C block | ||
391 | transactions, but the VT82C686A (rev 0x30) doesn't */ | ||
392 | if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp) | ||
393 | && temp >= 0x40) | ||
394 | vt596_features |= FEATURE_I2CBLOCK; | ||
395 | break; | ||
396 | } | ||
397 | |||
382 | vt596_adapter.dev.parent = &pdev->dev; | 398 | vt596_adapter.dev.parent = &pdev->dev; |
383 | snprintf(vt596_adapter.name, I2C_NAME_SIZE, | 399 | snprintf(vt596_adapter.name, I2C_NAME_SIZE, |
384 | "SMBus Via Pro adapter at %04x", vt596_smba); | 400 | "SMBus Via Pro adapter at %04x", vt596_smba); |
385 | 401 | ||
386 | vt596_pdev = pci_dev_get(pdev); | 402 | vt596_pdev = pci_dev_get(pdev); |
387 | if (i2c_add_adapter(&vt596_adapter)) { | 403 | if (i2c_add_adapter(&vt596_adapter)) { |
388 | pci_dev_put(vt596_pdev); | 404 | pci_dev_put(vt596_pdev); |
@@ -395,7 +411,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
395 | */ | 411 | */ |
396 | return -ENODEV; | 412 | return -ENODEV; |
397 | 413 | ||
398 | release_region: | 414 | release_region: |
399 | release_region(vt596_smba, 8); | 415 | release_region(vt596_smba, 8); |
400 | return error; | 416 | return error; |
401 | } | 417 | } |
@@ -420,9 +436,10 @@ static struct pci_device_id vt596_ids[] = { | |||
420 | { 0, } | 436 | { 0, } |
421 | }; | 437 | }; |
422 | 438 | ||
423 | MODULE_DEVICE_TABLE (pci, vt596_ids); | 439 | MODULE_DEVICE_TABLE(pci, vt596_ids); |
424 | 440 | ||
425 | static struct pci_driver vt596_driver = { | 441 | static struct pci_driver vt596_driver = { |
442 | .owner = THIS_MODULE, | ||
426 | .name = "vt596_smbus", | 443 | .name = "vt596_smbus", |
427 | .id_table = vt596_ids, | 444 | .id_table = vt596_ids, |
428 | .probe = vt596_probe, | 445 | .probe = vt596_probe, |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index b675773b0cc1..650c3ebde84c 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -225,6 +225,7 @@ static void __devexit voodoo3_remove(struct pci_dev *dev) | |||
225 | } | 225 | } |
226 | 226 | ||
227 | static struct pci_driver voodoo3_driver = { | 227 | static struct pci_driver voodoo3_driver = { |
228 | .owner = THIS_MODULE, | ||
228 | .name = "voodoo3_smbus", | 229 | .name = "voodoo3_smbus", |
229 | .id_table = voodoo3_ids, | 230 | .id_table = voodoo3_ids, |
230 | .probe = voodoo3_probe, | 231 | .probe = voodoo3_probe, |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index a1d580e05361..d3478e084522 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -442,14 +442,13 @@ static int __init scx200_acb_create(int base, int index) | |||
442 | int rc = 0; | 442 | int rc = 0; |
443 | char description[64]; | 443 | char description[64]; |
444 | 444 | ||
445 | iface = kmalloc(sizeof(*iface), GFP_KERNEL); | 445 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
446 | if (!iface) { | 446 | if (!iface) { |
447 | printk(KERN_ERR NAME ": can't allocate memory\n"); | 447 | printk(KERN_ERR NAME ": can't allocate memory\n"); |
448 | rc = -ENOMEM; | 448 | rc = -ENOMEM; |
449 | goto errout; | 449 | goto errout; |
450 | } | 450 | } |
451 | 451 | ||
452 | memset(iface, 0, sizeof(*iface)); | ||
453 | adapter = &iface->adapter; | 452 | adapter = &iface->adapter; |
454 | i2c_set_adapdata(adapter, iface); | 453 | i2c_set_adapdata(adapter, iface); |
455 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); | 454 | snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 6bd44a44cd28..f9fae28f5612 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -126,4 +126,13 @@ config SENSORS_MAX6875 | |||
126 | This driver can also be built as a module. If so, the module | 126 | This driver can also be built as a module. If so, the module |
127 | will be called max6875. | 127 | will be called max6875. |
128 | 128 | ||
129 | config RTC_X1205_I2C | ||
130 | tristate "Xicor X1205 RTC chip" | ||
131 | depends on I2C && EXPERIMENTAL | ||
132 | help | ||
133 | If you say yes here you get support for the Xicor X1205 RTC chip. | ||
134 | |||
135 | This driver can also be built as a module. If so, the module | ||
136 | will be called x1205. | ||
137 | |||
129 | endmenu | 138 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index a876dd42b860..46178b57b1f1 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | |||
13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
15 | obj-$(CONFIG_TPS65010) += tps65010.o | 15 | obj-$(CONFIG_TPS65010) += tps65010.o |
16 | obj-$(CONFIG_RTC_X1205_I2C) += x1205.o | ||
16 | 17 | ||
17 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 18 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
18 | EXTRA_CFLAGS += -DDEBUG | 19 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 9d3175c03395..01b037007410 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -243,11 +243,10 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) | |||
243 | I2C_FUNC_I2C)) | 243 | I2C_FUNC_I2C)) |
244 | goto exit; | 244 | goto exit; |
245 | 245 | ||
246 | if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { | 246 | if (!(data = kzalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { |
247 | err = -ENOMEM; | 247 | err = -ENOMEM; |
248 | goto exit; | 248 | goto exit; |
249 | } | 249 | } |
250 | memset(data, 0, sizeof(struct ds1337_data)); | ||
251 | INIT_LIST_HEAD(&data->list); | 250 | INIT_LIST_HEAD(&data->list); |
252 | 251 | ||
253 | /* The common I2C client data is placed right before the | 252 | /* The common I2C client data is placed right before the |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0936327a946d..da488b735abf 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -167,7 +167,8 @@ static void ds1374_set_tlet(ulong arg) | |||
167 | 167 | ||
168 | static ulong new_time; | 168 | static ulong new_time; |
169 | 169 | ||
170 | DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); | 170 | static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, |
171 | (ulong) & new_time); | ||
171 | 172 | ||
172 | int ds1374_set_rtc_time(ulong nowtime) | 173 | int ds1374_set_rtc_time(ulong nowtime) |
173 | { | 174 | { |
@@ -193,13 +194,11 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) | |||
193 | struct i2c_client *client; | 194 | struct i2c_client *client; |
194 | int rc; | 195 | int rc; |
195 | 196 | ||
196 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 197 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
197 | if (!client) | 198 | if (!client) |
198 | return -ENOMEM; | 199 | return -ENOMEM; |
199 | 200 | ||
200 | memset(client, 0, sizeof(struct i2c_client)); | ||
201 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); | 201 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); |
202 | client->flags = I2C_DF_NOTIFY; | ||
203 | client->addr = addr; | 202 | client->addr = addr; |
204 | client->adapter = adap; | 203 | client->adapter = adap; |
205 | client->driver = &ds1374_driver; | 204 | client->driver = &ds1374_driver; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index d58403a47908..4baf573fa04f 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -88,8 +88,8 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice) | |||
88 | dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); | 88 | dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); |
89 | 89 | ||
90 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { | 90 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { |
91 | for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_I2C_BLOCK_MAX) | 91 | for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_BLOCK_MAX) |
92 | if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_I2C_BLOCK_MAX) | 92 | if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_BLOCK_MAX) |
93 | goto exit; | 93 | goto exit; |
94 | } else { | 94 | } else { |
95 | if (i2c_smbus_write_byte(client, slice << 5)) { | 95 | if (i2c_smbus_write_byte(client, slice << 5)) { |
@@ -155,7 +155,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | /* This function is called by i2c_probe */ | 157 | /* This function is called by i2c_probe */ |
158 | int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | 158 | static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) |
159 | { | 159 | { |
160 | struct i2c_client *new_client; | 160 | struct i2c_client *new_client; |
161 | struct eeprom_data *data; | 161 | struct eeprom_data *data; |
@@ -171,11 +171,10 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
171 | | I2C_FUNC_SMBUS_BYTE)) | 171 | | I2C_FUNC_SMBUS_BYTE)) |
172 | goto exit; | 172 | goto exit; |
173 | 173 | ||
174 | if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { | 174 | if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { |
175 | err = -ENOMEM; | 175 | err = -ENOMEM; |
176 | goto exit; | 176 | goto exit; |
177 | } | 177 | } |
178 | memset(data, 0, sizeof(struct eeprom_data)); | ||
179 | 178 | ||
180 | new_client = &data->client; | 179 | new_client = &data->client; |
181 | memset(data->data, 0xff, EEPROM_SIZE); | 180 | memset(data->data, 0xff, EEPROM_SIZE); |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 8ee56d4b3891..eaa4742e04fa 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -888,6 +888,7 @@ static int otg_remove(struct device *dev) | |||
888 | } | 888 | } |
889 | 889 | ||
890 | struct device_driver omap_otg_driver = { | 890 | struct device_driver omap_otg_driver = { |
891 | .owner = THIS_MODULE, | ||
891 | .name = "omap_otg", | 892 | .name = "omap_otg", |
892 | .bus = &platform_bus_type, | 893 | .bus = &platform_bus_type, |
893 | .probe = otg_probe, | 894 | .probe = otg_probe, |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 3f14528a52a9..3df309ae44a6 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -174,13 +174,11 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind) | |||
174 | struct i2c_client *client; | 174 | struct i2c_client *client; |
175 | int rc; | 175 | int rc; |
176 | 176 | ||
177 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 177 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
178 | if (!client) | 178 | if (!client) |
179 | return -ENOMEM; | 179 | return -ENOMEM; |
180 | 180 | ||
181 | memset(client, 0, sizeof(struct i2c_client)); | ||
182 | strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); | 181 | strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); |
183 | client->flags = I2C_DF_NOTIFY; | ||
184 | client->addr = addr; | 182 | client->addr = addr; |
185 | client->adapter = adap; | 183 | client->adapter = adap; |
186 | client->driver = &m41t00_driver; | 184 | client->driver = &m41t00_driver; |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 9e1aeb69abf9..b376a006883c 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -179,16 +179,14 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
179 | if (address & 1) | 179 | if (address & 1) |
180 | return 0; | 180 | return 0; |
181 | 181 | ||
182 | if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) | 182 | if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL))) |
183 | return -ENOMEM; | 183 | return -ENOMEM; |
184 | memset(data, 0, sizeof(struct max6875_data)); | ||
185 | 184 | ||
186 | /* A fake client is created on the odd address */ | 185 | /* A fake client is created on the odd address */ |
187 | if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { | 186 | if (!(fake_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { |
188 | err = -ENOMEM; | 187 | err = -ENOMEM; |
189 | goto exit_kfree1; | 188 | goto exit_kfree1; |
190 | } | 189 | } |
191 | memset(fake_client, 0, sizeof(struct i2c_client)); | ||
192 | 190 | ||
193 | /* Init real i2c_client */ | 191 | /* Init real i2c_client */ |
194 | real_client = &data->client; | 192 | real_client = &data->client; |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 225577fdda4d..59a930346229 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -122,11 +122,10 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) | |||
122 | 122 | ||
123 | /* OK. For now, we presume we have a valid client. We now create the | 123 | /* OK. For now, we presume we have a valid client. We now create the |
124 | client structure, even though we cannot fill it completely yet. */ | 124 | client structure, even though we cannot fill it completely yet. */ |
125 | if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { | 125 | if (!(data = kzalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { |
126 | err = -ENOMEM; | 126 | err = -ENOMEM; |
127 | goto exit; | 127 | goto exit; |
128 | } | 128 | } |
129 | memset(data, 0, sizeof(struct pca9539_data)); | ||
130 | 129 | ||
131 | new_client = &data->client; | 130 | new_client = &data->client; |
132 | i2c_set_clientdata(new_client, data); | 131 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 6525743ff9fd..c323c2de236c 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -115,7 +115,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter) | |||
115 | } | 115 | } |
116 | 116 | ||
117 | /* This function is called by i2c_probe */ | 117 | /* This function is called by i2c_probe */ |
118 | int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) | 118 | static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) |
119 | { | 119 | { |
120 | struct i2c_client *new_client; | 120 | struct i2c_client *new_client; |
121 | struct pcf8574_data *data; | 121 | struct pcf8574_data *data; |
@@ -127,11 +127,10 @@ int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) | |||
127 | 127 | ||
128 | /* OK. For now, we presume we have a valid client. We now create the | 128 | /* OK. For now, we presume we have a valid client. We now create the |
129 | client structure, even though we cannot fill it completely yet. */ | 129 | client structure, even though we cannot fill it completely yet. */ |
130 | if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { | 130 | if (!(data = kzalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { |
131 | err = -ENOMEM; | 131 | err = -ENOMEM; |
132 | goto exit; | 132 | goto exit; |
133 | } | 133 | } |
134 | memset(data, 0, sizeof(struct pcf8574_data)); | ||
135 | 134 | ||
136 | new_client = &data->client; | 135 | new_client = &data->client; |
137 | i2c_set_clientdata(new_client, data); | 136 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 80f1df9a4500..ce420a67560b 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -166,7 +166,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* This function is called by i2c_probe */ | 168 | /* This function is called by i2c_probe */ |
169 | int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | 169 | static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) |
170 | { | 170 | { |
171 | struct i2c_client *new_client; | 171 | struct i2c_client *new_client; |
172 | struct pcf8591_data *data; | 172 | struct pcf8591_data *data; |
@@ -178,11 +178,10 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) | |||
178 | 178 | ||
179 | /* OK. For now, we presume we have a valid client. We now create the | 179 | /* OK. For now, we presume we have a valid client. We now create the |
180 | client structure, even though we cannot fill it completely yet. */ | 180 | client structure, even though we cannot fill it completely yet. */ |
181 | if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { | 181 | if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { |
182 | err = -ENOMEM; | 182 | err = -ENOMEM; |
183 | goto exit; | 183 | goto exit; |
184 | } | 184 | } |
185 | memset(data, 0, sizeof(struct pcf8591_data)); | ||
186 | 185 | ||
187 | new_client = &data->client; | 186 | new_client = &data->client; |
188 | i2c_set_clientdata(new_client, data); | 187 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 0b5385c892b1..916cdc1af23c 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -148,17 +148,16 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind) | |||
148 | {addr, I2C_M_RD, 2, data} | 148 | {addr, I2C_M_RD, 2, data} |
149 | }; | 149 | }; |
150 | 150 | ||
151 | d = kmalloc(sizeof(struct rtc8564_data), GFP_KERNEL); | 151 | d = kzalloc(sizeof(struct rtc8564_data), GFP_KERNEL); |
152 | if (!d) { | 152 | if (!d) { |
153 | ret = -ENOMEM; | 153 | ret = -ENOMEM; |
154 | goto done; | 154 | goto done; |
155 | } | 155 | } |
156 | memset(d, 0, sizeof(struct rtc8564_data)); | ||
157 | new_client = &d->client; | 156 | new_client = &d->client; |
158 | 157 | ||
159 | strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); | 158 | strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); |
160 | i2c_set_clientdata(new_client, d); | 159 | i2c_set_clientdata(new_client, d); |
161 | new_client->flags = I2C_CLIENT_ALLOW_USE | I2C_DF_NOTIFY; | 160 | new_client->flags = I2C_CLIENT_ALLOW_USE; |
162 | new_client->addr = addr; | 161 | new_client->addr = addr; |
163 | new_client->adapter = adap; | 162 | new_client->adapter = adap; |
164 | new_client->driver = &rtc8564_driver; | 163 | new_client->driver = &rtc8564_driver; |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 280e9638c0f8..280dd7a45db6 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -500,11 +500,10 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
500 | return 0; | 500 | return 0; |
501 | } | 501 | } |
502 | 502 | ||
503 | tps = kmalloc(sizeof *tps, GFP_KERNEL); | 503 | tps = kzalloc(sizeof *tps, GFP_KERNEL); |
504 | if (!tps) | 504 | if (!tps) |
505 | return 0; | 505 | return 0; |
506 | 506 | ||
507 | memset(tps, 0, sizeof *tps); | ||
508 | init_MUTEX(&tps->lock); | 507 | init_MUTEX(&tps->lock); |
509 | INIT_WORK(&tps->work, tps65010_work, tps); | 508 | INIT_WORK(&tps->work, tps65010_work, tps); |
510 | tps->irq = -1; | 509 | tps->irq = -1; |
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c new file mode 100644 index 000000000000..7da366cdc18c --- /dev/null +++ b/drivers/i2c/chips/x1205.c | |||
@@ -0,0 +1,698 @@ | |||
1 | /* | ||
2 | * x1205.c - An i2c driver for the Xicor X1205 RTC | ||
3 | * Copyright 2004 Karen Spearel | ||
4 | * Copyright 2005 Alessandro Zummo | ||
5 | * | ||
6 | * please send all reports to: | ||
7 | * kas11 at tampabay dot rr dot com | ||
8 | * a dot zummo at towertech dot it | ||
9 | * | ||
10 | * based on the other drivers in this same directory. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/i2c.h> | ||
22 | #include <linux/string.h> | ||
23 | #include <linux/bcd.h> | ||
24 | #include <linux/rtc.h> | ||
25 | #include <linux/list.h> | ||
26 | |||
27 | #include <linux/x1205.h> | ||
28 | |||
29 | #define DRV_VERSION "0.9.9" | ||
30 | |||
31 | /* Addresses to scan: none. This chip is located at | ||
32 | * 0x6f and uses a two bytes register addressing. | ||
33 | * Two bytes need to be written to read a single register, | ||
34 | * while most other chips just require one and take the second | ||
35 | * one as the data to be written. To prevent corrupting | ||
36 | * unknown chips, the user must explicitely set the probe parameter. | ||
37 | */ | ||
38 | |||
39 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
40 | |||
41 | /* Insmod parameters */ | ||
42 | I2C_CLIENT_INSMOD; | ||
43 | I2C_CLIENT_MODULE_PARM(hctosys, | ||
44 | "Set the system time from the hardware clock upon initialization"); | ||
45 | |||
46 | /* offsets into CCR area */ | ||
47 | |||
48 | #define CCR_SEC 0 | ||
49 | #define CCR_MIN 1 | ||
50 | #define CCR_HOUR 2 | ||
51 | #define CCR_MDAY 3 | ||
52 | #define CCR_MONTH 4 | ||
53 | #define CCR_YEAR 5 | ||
54 | #define CCR_WDAY 6 | ||
55 | #define CCR_Y2K 7 | ||
56 | |||
57 | #define X1205_REG_SR 0x3F /* status register */ | ||
58 | #define X1205_REG_Y2K 0x37 | ||
59 | #define X1205_REG_DW 0x36 | ||
60 | #define X1205_REG_YR 0x35 | ||
61 | #define X1205_REG_MO 0x34 | ||
62 | #define X1205_REG_DT 0x33 | ||
63 | #define X1205_REG_HR 0x32 | ||
64 | #define X1205_REG_MN 0x31 | ||
65 | #define X1205_REG_SC 0x30 | ||
66 | #define X1205_REG_DTR 0x13 | ||
67 | #define X1205_REG_ATR 0x12 | ||
68 | #define X1205_REG_INT 0x11 | ||
69 | #define X1205_REG_0 0x10 | ||
70 | #define X1205_REG_Y2K1 0x0F | ||
71 | #define X1205_REG_DWA1 0x0E | ||
72 | #define X1205_REG_YRA1 0x0D | ||
73 | #define X1205_REG_MOA1 0x0C | ||
74 | #define X1205_REG_DTA1 0x0B | ||
75 | #define X1205_REG_HRA1 0x0A | ||
76 | #define X1205_REG_MNA1 0x09 | ||
77 | #define X1205_REG_SCA1 0x08 | ||
78 | #define X1205_REG_Y2K0 0x07 | ||
79 | #define X1205_REG_DWA0 0x06 | ||
80 | #define X1205_REG_YRA0 0x05 | ||
81 | #define X1205_REG_MOA0 0x04 | ||
82 | #define X1205_REG_DTA0 0x03 | ||
83 | #define X1205_REG_HRA0 0x02 | ||
84 | #define X1205_REG_MNA0 0x01 | ||
85 | #define X1205_REG_SCA0 0x00 | ||
86 | |||
87 | #define X1205_CCR_BASE 0x30 /* Base address of CCR */ | ||
88 | #define X1205_ALM0_BASE 0x00 /* Base address of ALARM0 */ | ||
89 | |||
90 | #define X1205_SR_RTCF 0x01 /* Clock failure */ | ||
91 | #define X1205_SR_WEL 0x02 /* Write Enable Latch */ | ||
92 | #define X1205_SR_RWEL 0x04 /* Register Write Enable */ | ||
93 | |||
94 | #define X1205_DTR_DTR0 0x01 | ||
95 | #define X1205_DTR_DTR1 0x02 | ||
96 | #define X1205_DTR_DTR2 0x04 | ||
97 | |||
98 | #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ | ||
99 | |||
100 | /* Prototypes */ | ||
101 | static int x1205_attach(struct i2c_adapter *adapter); | ||
102 | static int x1205_detach(struct i2c_client *client); | ||
103 | static int x1205_probe(struct i2c_adapter *adapter, int address, int kind); | ||
104 | static int x1205_command(struct i2c_client *client, unsigned int cmd, | ||
105 | void *arg); | ||
106 | |||
107 | static struct i2c_driver x1205_driver = { | ||
108 | .owner = THIS_MODULE, | ||
109 | .name = "x1205", | ||
110 | .flags = I2C_DF_NOTIFY, | ||
111 | .attach_adapter = &x1205_attach, | ||
112 | .detach_client = &x1205_detach, | ||
113 | }; | ||
114 | |||
115 | struct x1205_data { | ||
116 | struct i2c_client client; | ||
117 | struct list_head list; | ||
118 | unsigned int epoch; | ||
119 | }; | ||
120 | |||
121 | static const unsigned char days_in_mo[] = | ||
122 | { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
123 | |||
124 | static LIST_HEAD(x1205_clients); | ||
125 | |||
126 | /* Workaround until the I2C subsytem will allow to send | ||
127 | * commands to a specific client. This function will send the command | ||
128 | * to the first client. | ||
129 | */ | ||
130 | int x1205_do_command(unsigned int cmd, void *arg) | ||
131 | { | ||
132 | struct list_head *walk; | ||
133 | struct list_head *tmp; | ||
134 | struct x1205_data *data; | ||
135 | |||
136 | list_for_each_safe(walk, tmp, &x1205_clients) { | ||
137 | data = list_entry(walk, struct x1205_data, list); | ||
138 | return x1205_command(&data->client, cmd, arg); | ||
139 | } | ||
140 | |||
141 | return -ENODEV; | ||
142 | } | ||
143 | |||
144 | #define is_leap(year) \ | ||
145 | ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) | ||
146 | |||
147 | /* make sure the rtc_time values are in bounds */ | ||
148 | static int x1205_validate_tm(struct rtc_time *tm) | ||
149 | { | ||
150 | int year = tm->tm_year + 1900; | ||
151 | |||
152 | if ((tm->tm_year < 70) || (tm->tm_year > 255)) | ||
153 | return -EINVAL; | ||
154 | |||
155 | if ((tm->tm_mon > 11) || (tm->tm_mday == 0)) | ||
156 | return -EINVAL; | ||
157 | |||
158 | if (tm->tm_mday > days_in_mo[tm->tm_mon] | ||
159 | + ((tm->tm_mon == 1) && is_leap(year))) | ||
160 | return -EINVAL; | ||
161 | |||
162 | if ((tm->tm_hour >= 24) || (tm->tm_min >= 60) || (tm->tm_sec >= 60)) | ||
163 | return -EINVAL; | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | /* | ||
169 | * In the routines that deal directly with the x1205 hardware, we use | ||
170 | * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch | ||
171 | * Epoch is initialized as 2000. Time is set to UTC. | ||
172 | */ | ||
173 | static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | ||
174 | u8 reg_base) | ||
175 | { | ||
176 | unsigned char dt_addr[2] = { 0, reg_base }; | ||
177 | static unsigned char sr_addr[2] = { 0, X1205_REG_SR }; | ||
178 | |||
179 | unsigned char buf[8], sr; | ||
180 | |||
181 | struct i2c_msg msgs[] = { | ||
182 | { client->addr, 0, 2, sr_addr }, /* setup read ptr */ | ||
183 | { client->addr, I2C_M_RD, 1, &sr }, /* read status */ | ||
184 | { client->addr, 0, 2, dt_addr }, /* setup read ptr */ | ||
185 | { client->addr, I2C_M_RD, 8, buf }, /* read date */ | ||
186 | }; | ||
187 | |||
188 | struct x1205_data *data = i2c_get_clientdata(client); | ||
189 | |||
190 | /* read status register */ | ||
191 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
192 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
193 | return -EIO; | ||
194 | } | ||
195 | |||
196 | /* check for battery failure */ | ||
197 | if (sr & X1205_SR_RTCF) { | ||
198 | dev_warn(&client->dev, | ||
199 | "Clock had a power failure, you must set the date.\n"); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
203 | /* read date registers */ | ||
204 | if ((i2c_transfer(client->adapter, &msgs[2], 2)) != 2) { | ||
205 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
206 | return -EIO; | ||
207 | } | ||
208 | |||
209 | dev_dbg(&client->dev, | ||
210 | "%s: raw read data - sec=%02x, min=%02x, hr=%02x, " | ||
211 | "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n", | ||
212 | __FUNCTION__, | ||
213 | buf[0], buf[1], buf[2], buf[3], | ||
214 | buf[4], buf[5], buf[6], buf[7]); | ||
215 | |||
216 | tm->tm_sec = BCD2BIN(buf[CCR_SEC]); | ||
217 | tm->tm_min = BCD2BIN(buf[CCR_MIN]); | ||
218 | tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ | ||
219 | tm->tm_mday = BCD2BIN(buf[CCR_MDAY]); | ||
220 | tm->tm_mon = BCD2BIN(buf[CCR_MONTH]); | ||
221 | data->epoch = BCD2BIN(buf[CCR_Y2K]) * 100; | ||
222 | tm->tm_year = BCD2BIN(buf[CCR_YEAR]) + data->epoch - 1900; | ||
223 | tm->tm_wday = buf[CCR_WDAY]; | ||
224 | |||
225 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | ||
226 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
227 | __FUNCTION__, | ||
228 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
229 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
230 | |||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | ||
235 | int datetoo, u8 reg_base) | ||
236 | { | ||
237 | int i, err, xfer; | ||
238 | |||
239 | unsigned char buf[8]; | ||
240 | |||
241 | static const unsigned char wel[3] = { 0, X1205_REG_SR, | ||
242 | X1205_SR_WEL }; | ||
243 | |||
244 | static const unsigned char rwel[3] = { 0, X1205_REG_SR, | ||
245 | X1205_SR_WEL | X1205_SR_RWEL }; | ||
246 | |||
247 | static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 }; | ||
248 | |||
249 | struct x1205_data *data = i2c_get_clientdata(client); | ||
250 | |||
251 | /* check if all values in the tm struct are correct */ | ||
252 | if ((err = x1205_validate_tm(tm)) < 0) | ||
253 | return err; | ||
254 | |||
255 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " | ||
256 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
257 | __FUNCTION__, | ||
258 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
259 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
260 | |||
261 | buf[CCR_SEC] = BIN2BCD(tm->tm_sec); | ||
262 | buf[CCR_MIN] = BIN2BCD(tm->tm_min); | ||
263 | |||
264 | /* set hour and 24hr bit */ | ||
265 | buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL; | ||
266 | |||
267 | /* should we also set the date? */ | ||
268 | if (datetoo) { | ||
269 | buf[CCR_MDAY] = BIN2BCD(tm->tm_mday); | ||
270 | |||
271 | /* month, 0 - 11 */ | ||
272 | buf[CCR_MONTH] = BIN2BCD(tm->tm_mon); | ||
273 | |||
274 | /* year, since 1900 */ | ||
275 | buf[CCR_YEAR] = BIN2BCD(tm->tm_year + 1900 - data->epoch); | ||
276 | buf[CCR_WDAY] = tm->tm_wday & 0x07; | ||
277 | buf[CCR_Y2K] = BIN2BCD(data->epoch / 100); | ||
278 | } | ||
279 | |||
280 | /* this sequence is required to unlock the chip */ | ||
281 | xfer = i2c_master_send(client, wel, 3); | ||
282 | if (xfer != 3) { | ||
283 | dev_err(&client->dev, "%s: wel - %d\n", __FUNCTION__, xfer); | ||
284 | return -EIO; | ||
285 | } | ||
286 | |||
287 | xfer = i2c_master_send(client, rwel, 3); | ||
288 | if (xfer != 3) { | ||
289 | dev_err(&client->dev, "%s: rwel - %d\n", __FUNCTION__, xfer); | ||
290 | return -EIO; | ||
291 | } | ||
292 | |||
293 | /* write register's data */ | ||
294 | for (i = 0; i < (datetoo ? 8 : 3); i++) { | ||
295 | unsigned char rdata[3] = { 0, reg_base + i, buf[i] }; | ||
296 | |||
297 | xfer = i2c_master_send(client, rdata, 3); | ||
298 | if (xfer != 3) { | ||
299 | dev_err(&client->dev, | ||
300 | "%s: xfer=%d addr=%02x, data=%02x\n", | ||
301 | __FUNCTION__, | ||
302 | xfer, rdata[1], rdata[2]); | ||
303 | return -EIO; | ||
304 | } | ||
305 | }; | ||
306 | |||
307 | /* disable further writes */ | ||
308 | xfer = i2c_master_send(client, diswe, 3); | ||
309 | if (xfer != 3) { | ||
310 | dev_err(&client->dev, "%s: diswe - %d\n", __FUNCTION__, xfer); | ||
311 | return -EIO; | ||
312 | } | ||
313 | |||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static int x1205_get_dtrim(struct i2c_client *client, int *trim) | ||
318 | { | ||
319 | unsigned char dtr; | ||
320 | static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR }; | ||
321 | |||
322 | struct i2c_msg msgs[] = { | ||
323 | { client->addr, 0, 2, dtr_addr }, /* setup read ptr */ | ||
324 | { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */ | ||
325 | }; | ||
326 | |||
327 | /* read dtr register */ | ||
328 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
329 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
330 | return -EIO; | ||
331 | } | ||
332 | |||
333 | dev_dbg(&client->dev, "%s: raw dtr=%x\n", __FUNCTION__, dtr); | ||
334 | |||
335 | *trim = 0; | ||
336 | |||
337 | if (dtr & X1205_DTR_DTR0) | ||
338 | *trim += 20; | ||
339 | |||
340 | if (dtr & X1205_DTR_DTR1) | ||
341 | *trim += 10; | ||
342 | |||
343 | if (dtr & X1205_DTR_DTR2) | ||
344 | *trim = -*trim; | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | static int x1205_get_atrim(struct i2c_client *client, int *trim) | ||
350 | { | ||
351 | s8 atr; | ||
352 | static unsigned char atr_addr[2] = { 0, X1205_REG_ATR }; | ||
353 | |||
354 | struct i2c_msg msgs[] = { | ||
355 | { client->addr, 0, 2, atr_addr }, /* setup read ptr */ | ||
356 | { client->addr, I2C_M_RD, 1, &atr }, /* read atr */ | ||
357 | }; | ||
358 | |||
359 | /* read atr register */ | ||
360 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | ||
361 | dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | ||
362 | return -EIO; | ||
363 | } | ||
364 | |||
365 | dev_dbg(&client->dev, "%s: raw atr=%x\n", __FUNCTION__, atr); | ||
366 | |||
367 | /* atr is a two's complement value on 6 bits, | ||
368 | * perform sign extension. The formula is | ||
369 | * Catr = (atr * 0.25pF) + 11.00pF. | ||
370 | */ | ||
371 | if (atr & 0x20) | ||
372 | atr |= 0xC0; | ||
373 | |||
374 | dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __FUNCTION__, atr, atr); | ||
375 | |||
376 | *trim = (atr * 250) + 11000; | ||
377 | |||
378 | dev_dbg(&client->dev, "%s: real=%d\n", __FUNCTION__, *trim); | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static int x1205_hctosys(struct i2c_client *client) | ||
384 | { | ||
385 | int err; | ||
386 | |||
387 | struct rtc_time tm; | ||
388 | struct timespec tv; | ||
389 | |||
390 | err = x1205_command(client, X1205_CMD_GETDATETIME, &tm); | ||
391 | |||
392 | if (err) { | ||
393 | dev_err(&client->dev, | ||
394 | "Unable to set the system clock\n"); | ||
395 | return err; | ||
396 | } | ||
397 | |||
398 | /* IMPORTANT: the RTC only stores whole seconds. It is arbitrary | ||
399 | * whether it stores the most close value or the value with partial | ||
400 | * seconds truncated. However, it is important that we use it to store | ||
401 | * the truncated value. This is because otherwise it is necessary, | ||
402 | * in an rtc sync function, to read both xtime.tv_sec and | ||
403 | * xtime.tv_nsec. On some processors (i.e. ARM), an atomic read | ||
404 | * of >32bits is not possible. So storing the most close value would | ||
405 | * slow down the sync API. So here we have the truncated value and | ||
406 | * the best guess is to add 0.5s. | ||
407 | */ | ||
408 | |||
409 | tv.tv_nsec = NSEC_PER_SEC >> 1; | ||
410 | |||
411 | /* WARNING: this is not the C library 'mktime' call, it is a built in | ||
412 | * inline function from include/linux/time.h. It expects (requires) | ||
413 | * the month to be in the range 1-12 | ||
414 | */ | ||
415 | |||
416 | tv.tv_sec = mktime(tm.tm_year + 1900, tm.tm_mon + 1, | ||
417 | tm.tm_mday, tm.tm_hour, | ||
418 | tm.tm_min, tm.tm_sec); | ||
419 | |||
420 | do_settimeofday(&tv); | ||
421 | |||
422 | dev_info(&client->dev, | ||
423 | "setting the system clock to %d-%d-%d %d:%d:%d\n", | ||
424 | tm.tm_year + 1900, tm.tm_mon + 1, | ||
425 | tm.tm_mday, tm.tm_hour, tm.tm_min, | ||
426 | tm.tm_sec); | ||
427 | |||
428 | return 0; | ||
429 | } | ||
430 | |||
431 | struct x1205_limit | ||
432 | { | ||
433 | unsigned char reg; | ||
434 | unsigned char mask; | ||
435 | unsigned char min; | ||
436 | unsigned char max; | ||
437 | }; | ||
438 | |||
439 | static int x1205_validate_client(struct i2c_client *client) | ||
440 | { | ||
441 | int i, xfer; | ||
442 | |||
443 | /* Probe array. We will read the register at the specified | ||
444 | * address and check if the given bits are zero. | ||
445 | */ | ||
446 | static const unsigned char probe_zero_pattern[] = { | ||
447 | /* register, mask */ | ||
448 | X1205_REG_SR, 0x18, | ||
449 | X1205_REG_DTR, 0xF8, | ||
450 | X1205_REG_ATR, 0xC0, | ||
451 | X1205_REG_INT, 0x18, | ||
452 | X1205_REG_0, 0xFF, | ||
453 | }; | ||
454 | |||
455 | static const struct x1205_limit probe_limits_pattern[] = { | ||
456 | /* register, mask, min, max */ | ||
457 | { X1205_REG_Y2K, 0xFF, 19, 20 }, | ||
458 | { X1205_REG_DW, 0xFF, 0, 6 }, | ||
459 | { X1205_REG_YR, 0xFF, 0, 99 }, | ||
460 | { X1205_REG_MO, 0xFF, 0, 12 }, | ||
461 | { X1205_REG_DT, 0xFF, 0, 31 }, | ||
462 | { X1205_REG_HR, 0x7F, 0, 23 }, | ||
463 | { X1205_REG_MN, 0xFF, 0, 59 }, | ||
464 | { X1205_REG_SC, 0xFF, 0, 59 }, | ||
465 | { X1205_REG_Y2K1, 0xFF, 19, 20 }, | ||
466 | { X1205_REG_Y2K0, 0xFF, 19, 20 }, | ||
467 | }; | ||
468 | |||
469 | /* check that registers have bits a 0 where expected */ | ||
470 | for (i = 0; i < ARRAY_SIZE(probe_zero_pattern); i += 2) { | ||
471 | unsigned char buf; | ||
472 | |||
473 | unsigned char addr[2] = { 0, probe_zero_pattern[i] }; | ||
474 | |||
475 | struct i2c_msg msgs[2] = { | ||
476 | { client->addr, 0, 2, addr }, | ||
477 | { client->addr, I2C_M_RD, 1, &buf }, | ||
478 | }; | ||
479 | |||
480 | xfer = i2c_transfer(client->adapter, msgs, 2); | ||
481 | if (xfer != 2) { | ||
482 | dev_err(&client->adapter->dev, | ||
483 | "%s: could not read register %x\n", | ||
484 | __FUNCTION__, addr[1]); | ||
485 | |||
486 | return -EIO; | ||
487 | } | ||
488 | |||
489 | if ((buf & probe_zero_pattern[i+1]) != 0) { | ||
490 | dev_err(&client->adapter->dev, | ||
491 | "%s: register=%02x, zero pattern=%d, value=%x\n", | ||
492 | __FUNCTION__, addr[1], i, buf); | ||
493 | |||
494 | return -ENODEV; | ||
495 | } | ||
496 | } | ||
497 | |||
498 | /* check limits (only registers with bcd values) */ | ||
499 | for (i = 0; i < ARRAY_SIZE(probe_limits_pattern); i++) { | ||
500 | unsigned char reg, value; | ||
501 | |||
502 | unsigned char addr[2] = { 0, probe_limits_pattern[i].reg }; | ||
503 | |||
504 | struct i2c_msg msgs[2] = { | ||
505 | { client->addr, 0, 2, addr }, | ||
506 | { client->addr, I2C_M_RD, 1, ® }, | ||
507 | }; | ||
508 | |||
509 | xfer = i2c_transfer(client->adapter, msgs, 2); | ||
510 | |||
511 | if (xfer != 2) { | ||
512 | dev_err(&client->adapter->dev, | ||
513 | "%s: could not read register %x\n", | ||
514 | __FUNCTION__, addr[1]); | ||
515 | |||
516 | return -EIO; | ||
517 | } | ||
518 | |||
519 | value = BCD2BIN(reg & probe_limits_pattern[i].mask); | ||
520 | |||
521 | if (value > probe_limits_pattern[i].max || | ||
522 | value < probe_limits_pattern[i].min) { | ||
523 | dev_dbg(&client->adapter->dev, | ||
524 | "%s: register=%x, lim pattern=%d, value=%d\n", | ||
525 | __FUNCTION__, addr[1], i, value); | ||
526 | |||
527 | return -ENODEV; | ||
528 | } | ||
529 | } | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int x1205_attach(struct i2c_adapter *adapter) | ||
535 | { | ||
536 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); | ||
537 | |||
538 | return i2c_probe(adapter, &addr_data, x1205_probe); | ||
539 | } | ||
540 | |||
541 | int x1205_direct_attach(int adapter_id, | ||
542 | struct i2c_client_address_data *address_data) | ||
543 | { | ||
544 | int err; | ||
545 | struct i2c_adapter *adapter = i2c_get_adapter(adapter_id); | ||
546 | |||
547 | if (adapter) { | ||
548 | err = i2c_probe(adapter, | ||
549 | address_data, x1205_probe); | ||
550 | |||
551 | i2c_put_adapter(adapter); | ||
552 | |||
553 | return err; | ||
554 | } | ||
555 | |||
556 | return -ENODEV; | ||
557 | } | ||
558 | |||
559 | static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) | ||
560 | { | ||
561 | struct i2c_client *client; | ||
562 | struct x1205_data *data; | ||
563 | |||
564 | int err = 0; | ||
565 | |||
566 | dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); | ||
567 | |||
568 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { | ||
569 | err = -ENODEV; | ||
570 | goto exit; | ||
571 | } | ||
572 | |||
573 | if (!(data = kzalloc(sizeof(struct x1205_data), GFP_KERNEL))) { | ||
574 | err = -ENOMEM; | ||
575 | goto exit; | ||
576 | } | ||
577 | |||
578 | /* Initialize our structures */ | ||
579 | data->epoch = 2000; | ||
580 | |||
581 | client = &data->client; | ||
582 | client->addr = address; | ||
583 | client->driver = &x1205_driver; | ||
584 | client->adapter = adapter; | ||
585 | |||
586 | strlcpy(client->name, "x1205", I2C_NAME_SIZE); | ||
587 | |||
588 | i2c_set_clientdata(client, data); | ||
589 | |||
590 | /* Verify the chip is really an X1205 */ | ||
591 | if (kind < 0) { | ||
592 | if (x1205_validate_client(client) < 0) { | ||
593 | err = -ENODEV; | ||
594 | goto exit_kfree; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | /* Inform the i2c layer */ | ||
599 | if ((err = i2c_attach_client(client))) | ||
600 | goto exit_kfree; | ||
601 | |||
602 | list_add(&data->list, &x1205_clients); | ||
603 | |||
604 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | ||
605 | |||
606 | /* If requested, set the system time */ | ||
607 | if (hctosys) | ||
608 | x1205_hctosys(client); | ||
609 | |||
610 | return 0; | ||
611 | |||
612 | exit_kfree: | ||
613 | kfree(data); | ||
614 | |||
615 | exit: | ||
616 | return err; | ||
617 | } | ||
618 | |||
619 | static int x1205_detach(struct i2c_client *client) | ||
620 | { | ||
621 | int err; | ||
622 | struct x1205_data *data = i2c_get_clientdata(client); | ||
623 | |||
624 | dev_dbg(&client->dev, "%s\n", __FUNCTION__); | ||
625 | |||
626 | if ((err = i2c_detach_client(client))) | ||
627 | return err; | ||
628 | |||
629 | list_del(&data->list); | ||
630 | |||
631 | kfree(data); | ||
632 | |||
633 | return 0; | ||
634 | } | ||
635 | |||
636 | static int x1205_command(struct i2c_client *client, unsigned int cmd, | ||
637 | void *param) | ||
638 | { | ||
639 | if (param == NULL) | ||
640 | return -EINVAL; | ||
641 | |||
642 | if (!capable(CAP_SYS_TIME)) | ||
643 | return -EACCES; | ||
644 | |||
645 | dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); | ||
646 | |||
647 | switch (cmd) { | ||
648 | case X1205_CMD_GETDATETIME: | ||
649 | return x1205_get_datetime(client, param, X1205_CCR_BASE); | ||
650 | |||
651 | case X1205_CMD_SETTIME: | ||
652 | return x1205_set_datetime(client, param, 0, | ||
653 | X1205_CCR_BASE); | ||
654 | |||
655 | case X1205_CMD_SETDATETIME: | ||
656 | return x1205_set_datetime(client, param, 1, | ||
657 | X1205_CCR_BASE); | ||
658 | |||
659 | case X1205_CMD_GETALARM: | ||
660 | return x1205_get_datetime(client, param, X1205_ALM0_BASE); | ||
661 | |||
662 | case X1205_CMD_SETALARM: | ||
663 | return x1205_set_datetime(client, param, 1, | ||
664 | X1205_ALM0_BASE); | ||
665 | |||
666 | case X1205_CMD_GETDTRIM: | ||
667 | return x1205_get_dtrim(client, param); | ||
668 | |||
669 | case X1205_CMD_GETATRIM: | ||
670 | return x1205_get_atrim(client, param); | ||
671 | |||
672 | default: | ||
673 | return -EINVAL; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | static int __init x1205_init(void) | ||
678 | { | ||
679 | return i2c_add_driver(&x1205_driver); | ||
680 | } | ||
681 | |||
682 | static void __exit x1205_exit(void) | ||
683 | { | ||
684 | i2c_del_driver(&x1205_driver); | ||
685 | } | ||
686 | |||
687 | MODULE_AUTHOR( | ||
688 | "Karen Spearel <kas11@tampabay.rr.com>, " | ||
689 | "Alessandro Zummo <a.zummo@towertech.it>"); | ||
690 | MODULE_DESCRIPTION("Xicor X1205 RTC driver"); | ||
691 | MODULE_LICENSE("GPL"); | ||
692 | MODULE_VERSION(DRV_VERSION); | ||
693 | |||
694 | EXPORT_SYMBOL_GPL(x1205_do_command); | ||
695 | EXPORT_SYMBOL_GPL(x1205_direct_attach); | ||
696 | |||
697 | module_init(x1205_init); | ||
698 | module_exit(x1205_exit); | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 45aa0e54e297..02e335a04f09 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -19,7 +19,8 @@ | |||
19 | 19 | ||
20 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. | 20 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. |
21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> | 21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> |
22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ | 22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and |
23 | Jean Delvare <khali@linux-fr.org> */ | ||
23 | 24 | ||
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -85,6 +86,7 @@ void i2c_adapter_dev_release(struct device *dev) | |||
85 | } | 86 | } |
86 | 87 | ||
87 | struct device_driver i2c_adapter_driver = { | 88 | struct device_driver i2c_adapter_driver = { |
89 | .owner = THIS_MODULE, | ||
88 | .name = "i2c_adapter", | 90 | .name = "i2c_adapter", |
89 | .bus = &i2c_bus_type, | 91 | .bus = &i2c_bus_type, |
90 | .probe = i2c_device_probe, | 92 | .probe = i2c_device_probe, |
@@ -98,6 +100,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev) | |||
98 | } | 100 | } |
99 | 101 | ||
100 | struct class i2c_adapter_class = { | 102 | struct class i2c_adapter_class = { |
103 | .owner = THIS_MODULE, | ||
101 | .name = "i2c-adapter", | 104 | .name = "i2c-adapter", |
102 | .release = &i2c_adapter_class_dev_release, | 105 | .release = &i2c_adapter_class_dev_release, |
103 | }; | 106 | }; |
@@ -291,6 +294,7 @@ int i2c_add_driver(struct i2c_driver *driver) | |||
291 | down(&core_lists); | 294 | down(&core_lists); |
292 | 295 | ||
293 | /* add the driver to the list of i2c drivers in the driver core */ | 296 | /* add the driver to the list of i2c drivers in the driver core */ |
297 | driver->driver.owner = driver->owner; | ||
294 | driver->driver.name = driver->name; | 298 | driver->driver.name = driver->name; |
295 | driver->driver.bus = &i2c_bus_type; | 299 | driver->driver.bus = &i2c_bus_type; |
296 | driver->driver.probe = i2c_device_probe; | 300 | driver->driver.probe = i2c_device_probe; |
@@ -706,10 +710,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
706 | int i, err; | 710 | int i, err; |
707 | int adap_id = i2c_adapter_id(adapter); | 711 | int adap_id = i2c_adapter_id(adapter); |
708 | 712 | ||
709 | /* Forget it if we can't probe using SMBUS_QUICK */ | ||
710 | if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) | ||
711 | return -1; | ||
712 | |||
713 | /* Force entries are done first, and are not affected by ignore | 713 | /* Force entries are done first, and are not affected by ignore |
714 | entries */ | 714 | entries */ |
715 | if (address_data->forces) { | 715 | if (address_data->forces) { |
@@ -736,6 +736,17 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | /* Stop here if we can't use SMBUS_QUICK */ | ||
740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | ||
741 | if (address_data->probe[0] == I2C_CLIENT_END | ||
742 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | ||
743 | return 0; | ||
744 | |||
745 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | ||
746 | "can't probe for chips\n"); | ||
747 | return -1; | ||
748 | } | ||
749 | |||
739 | /* Probe entries are done second, and are not affected by ignore | 750 | /* Probe entries are done second, and are not affected by ignore |
740 | entries either */ | 751 | entries either */ |
741 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { | 752 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { |
@@ -820,101 +831,44 @@ crc8(u16 data) | |||
820 | return (u8)(data >> 8); | 831 | return (u8)(data >> 8); |
821 | } | 832 | } |
822 | 833 | ||
823 | /* CRC over count bytes in the first array plus the bytes in the rest | 834 | /* Incremental CRC8 over count bytes in the array pointed to by p */ |
824 | array if it is non-null. rest[0] is the (length of rest) - 1 | 835 | static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) |
825 | and is included. */ | ||
826 | static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) | ||
827 | { | 836 | { |
828 | int i; | 837 | int i; |
829 | 838 | ||
830 | for(i = 0; i < count; i++) | 839 | for(i = 0; i < count; i++) |
831 | crc = crc8((crc ^ first[i]) << 8); | 840 | crc = crc8((crc ^ p[i]) << 8); |
832 | if(rest != NULL) | ||
833 | for(i = 0; i <= rest[0]; i++) | ||
834 | crc = crc8((crc ^ rest[i]) << 8); | ||
835 | return crc; | 841 | return crc; |
836 | } | 842 | } |
837 | 843 | ||
838 | static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) | 844 | /* Assume a 7-bit address, which is reasonable for SMBus */ |
845 | static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg) | ||
839 | { | 846 | { |
840 | return i2c_smbus_partial_pec(0, count, first, rest); | 847 | /* The address will be sent first */ |
848 | u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD); | ||
849 | pec = i2c_smbus_pec(pec, &addr, 1); | ||
850 | |||
851 | /* The data buffer follows */ | ||
852 | return i2c_smbus_pec(pec, msg->buf, msg->len); | ||
841 | } | 853 | } |
842 | 854 | ||
843 | /* Returns new "size" (transaction type) | 855 | /* Used for write only transactions */ |
844 | Note that we convert byte to byte_data and byte_data to word_data | 856 | static inline void i2c_smbus_add_pec(struct i2c_msg *msg) |
845 | rather than invent new xxx_PEC transactions. */ | ||
846 | static int i2c_smbus_add_pec(u16 addr, u8 command, int size, | ||
847 | union i2c_smbus_data *data) | ||
848 | { | 857 | { |
849 | u8 buf[3]; | 858 | msg->buf[msg->len] = i2c_smbus_msg_pec(0, msg); |
850 | 859 | msg->len++; | |
851 | buf[0] = addr << 1; | ||
852 | buf[1] = command; | ||
853 | switch(size) { | ||
854 | case I2C_SMBUS_BYTE: | ||
855 | data->byte = i2c_smbus_pec(2, buf, NULL); | ||
856 | size = I2C_SMBUS_BYTE_DATA; | ||
857 | break; | ||
858 | case I2C_SMBUS_BYTE_DATA: | ||
859 | buf[2] = data->byte; | ||
860 | data->word = buf[2] || | ||
861 | (i2c_smbus_pec(3, buf, NULL) << 8); | ||
862 | size = I2C_SMBUS_WORD_DATA; | ||
863 | break; | ||
864 | case I2C_SMBUS_WORD_DATA: | ||
865 | /* unsupported */ | ||
866 | break; | ||
867 | case I2C_SMBUS_BLOCK_DATA: | ||
868 | data->block[data->block[0] + 1] = | ||
869 | i2c_smbus_pec(2, buf, data->block); | ||
870 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
871 | break; | ||
872 | } | ||
873 | return size; | ||
874 | } | 860 | } |
875 | 861 | ||
876 | static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, | 862 | /* Return <0 on CRC error |
877 | union i2c_smbus_data *data) | 863 | If there was a write before this read (most cases) we need to take the |
864 | partial CRC from the write part into account. | ||
865 | Note that this function does modify the message (we need to decrease the | ||
866 | message length to hide the CRC byte from the caller). */ | ||
867 | static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) | ||
878 | { | 868 | { |
879 | u8 buf[3], rpec, cpec; | 869 | u8 rpec = msg->buf[--msg->len]; |
870 | cpec = i2c_smbus_msg_pec(cpec, msg); | ||
880 | 871 | ||
881 | buf[1] = command; | ||
882 | switch(size) { | ||
883 | case I2C_SMBUS_BYTE_DATA: | ||
884 | buf[0] = (addr << 1) | 1; | ||
885 | cpec = i2c_smbus_pec(2, buf, NULL); | ||
886 | rpec = data->byte; | ||
887 | break; | ||
888 | case I2C_SMBUS_WORD_DATA: | ||
889 | buf[0] = (addr << 1) | 1; | ||
890 | buf[2] = data->word & 0xff; | ||
891 | cpec = i2c_smbus_pec(3, buf, NULL); | ||
892 | rpec = data->word >> 8; | ||
893 | break; | ||
894 | case I2C_SMBUS_WORD_DATA_PEC: | ||
895 | /* unsupported */ | ||
896 | cpec = rpec = 0; | ||
897 | break; | ||
898 | case I2C_SMBUS_PROC_CALL_PEC: | ||
899 | /* unsupported */ | ||
900 | cpec = rpec = 0; | ||
901 | break; | ||
902 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
903 | buf[0] = (addr << 1); | ||
904 | buf[2] = (addr << 1) | 1; | ||
905 | cpec = i2c_smbus_pec(3, buf, data->block); | ||
906 | rpec = data->block[data->block[0] + 1]; | ||
907 | break; | ||
908 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
909 | buf[0] = (addr << 1) | 1; | ||
910 | rpec = i2c_smbus_partial_pec(partial, 1, | ||
911 | buf, data->block); | ||
912 | cpec = data->block[data->block[0] + 1]; | ||
913 | break; | ||
914 | default: | ||
915 | cpec = rpec = 0; | ||
916 | break; | ||
917 | } | ||
918 | if (rpec != cpec) { | 872 | if (rpec != cpec) { |
919 | pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", | 873 | pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", |
920 | rpec, cpec); | 874 | rpec, cpec); |
@@ -941,9 +895,8 @@ s32 i2c_smbus_read_byte(struct i2c_client *client) | |||
941 | 895 | ||
942 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) | 896 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) |
943 | { | 897 | { |
944 | union i2c_smbus_data data; /* only for PEC */ | ||
945 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 898 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
946 | I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); | 899 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); |
947 | } | 900 | } |
948 | 901 | ||
949 | s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) | 902 | s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) |
@@ -1026,13 +979,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1026 | need to use only one message; when reading, we need two. We initialize | 979 | need to use only one message; when reading, we need two. We initialize |
1027 | most things with sane defaults, to keep the code below somewhat | 980 | most things with sane defaults, to keep the code below somewhat |
1028 | simpler. */ | 981 | simpler. */ |
1029 | unsigned char msgbuf0[34]; | 982 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; |
1030 | unsigned char msgbuf1[34]; | 983 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; |
1031 | int num = read_write == I2C_SMBUS_READ?2:1; | 984 | int num = read_write == I2C_SMBUS_READ?2:1; |
1032 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, | 985 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, |
1033 | { addr, flags | I2C_M_RD, 0, msgbuf1 } | 986 | { addr, flags | I2C_M_RD, 0, msgbuf1 } |
1034 | }; | 987 | }; |
1035 | int i; | 988 | int i; |
989 | u8 partial_pec = 0; | ||
1036 | 990 | ||
1037 | msgbuf0[0] = command; | 991 | msgbuf0[0] = command; |
1038 | switch(size) { | 992 | switch(size) { |
@@ -1075,7 +1029,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1075 | msgbuf0[2] = (data->word >> 8) & 0xff; | 1029 | msgbuf0[2] = (data->word >> 8) & 0xff; |
1076 | break; | 1030 | break; |
1077 | case I2C_SMBUS_BLOCK_DATA: | 1031 | case I2C_SMBUS_BLOCK_DATA: |
1078 | case I2C_SMBUS_BLOCK_DATA_PEC: | ||
1079 | if (read_write == I2C_SMBUS_READ) { | 1032 | if (read_write == I2C_SMBUS_READ) { |
1080 | dev_err(&adapter->dev, "Block read not supported " | 1033 | dev_err(&adapter->dev, "Block read not supported " |
1081 | "under I2C emulation!\n"); | 1034 | "under I2C emulation!\n"); |
@@ -1088,23 +1041,20 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1088 | data->block[0]); | 1041 | data->block[0]); |
1089 | return -1; | 1042 | return -1; |
1090 | } | 1043 | } |
1091 | if(size == I2C_SMBUS_BLOCK_DATA_PEC) | 1044 | for (i = 1; i < msg[0].len; i++) |
1092 | (msg[0].len)++; | ||
1093 | for (i = 1; i <= msg[0].len; i++) | ||
1094 | msgbuf0[i] = data->block[i-1]; | 1045 | msgbuf0[i] = data->block[i-1]; |
1095 | } | 1046 | } |
1096 | break; | 1047 | break; |
1097 | case I2C_SMBUS_BLOCK_PROC_CALL: | 1048 | case I2C_SMBUS_BLOCK_PROC_CALL: |
1098 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: | ||
1099 | dev_dbg(&adapter->dev, "Block process call not supported " | 1049 | dev_dbg(&adapter->dev, "Block process call not supported " |
1100 | "under I2C emulation!\n"); | 1050 | "under I2C emulation!\n"); |
1101 | return -1; | 1051 | return -1; |
1102 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1052 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1103 | if (read_write == I2C_SMBUS_READ) { | 1053 | if (read_write == I2C_SMBUS_READ) { |
1104 | msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; | 1054 | msg[1].len = I2C_SMBUS_BLOCK_MAX; |
1105 | } else { | 1055 | } else { |
1106 | msg[0].len = data->block[0] + 1; | 1056 | msg[0].len = data->block[0] + 1; |
1107 | if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { | 1057 | if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { |
1108 | dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " | 1058 | dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " |
1109 | "invalid block write size (%d)\n", | 1059 | "invalid block write size (%d)\n", |
1110 | data->block[0]); | 1060 | data->block[0]); |
@@ -1120,9 +1070,30 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1120 | return -1; | 1070 | return -1; |
1121 | } | 1071 | } |
1122 | 1072 | ||
1073 | i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK | ||
1074 | && size != I2C_SMBUS_I2C_BLOCK_DATA); | ||
1075 | if (i) { | ||
1076 | /* Compute PEC if first message is a write */ | ||
1077 | if (!(msg[0].flags & I2C_M_RD)) { | ||
1078 | if (num == 1) /* Write only */ | ||
1079 | i2c_smbus_add_pec(&msg[0]); | ||
1080 | else /* Write followed by read */ | ||
1081 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); | ||
1082 | } | ||
1083 | /* Ask for PEC if last message is a read */ | ||
1084 | if (msg[num-1].flags & I2C_M_RD) | ||
1085 | msg[num-1].len++; | ||
1086 | } | ||
1087 | |||
1123 | if (i2c_transfer(adapter, msg, num) < 0) | 1088 | if (i2c_transfer(adapter, msg, num) < 0) |
1124 | return -1; | 1089 | return -1; |
1125 | 1090 | ||
1091 | /* Check PEC if last message is a read */ | ||
1092 | if (i && (msg[num-1].flags & I2C_M_RD)) { | ||
1093 | if (i2c_smbus_check_pec(partial_pec, &msg[num-1]) < 0) | ||
1094 | return -1; | ||
1095 | } | ||
1096 | |||
1126 | if (read_write == I2C_SMBUS_READ) | 1097 | if (read_write == I2C_SMBUS_READ) |
1127 | switch(size) { | 1098 | switch(size) { |
1128 | case I2C_SMBUS_BYTE: | 1099 | case I2C_SMBUS_BYTE: |
@@ -1137,8 +1108,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1137 | break; | 1108 | break; |
1138 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1109 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1139 | /* fixed at 32 for now */ | 1110 | /* fixed at 32 for now */ |
1140 | data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; | 1111 | data->block[0] = I2C_SMBUS_BLOCK_MAX; |
1141 | for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) | 1112 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) |
1142 | data->block[i+1] = msgbuf1[i]; | 1113 | data->block[i+1] = msgbuf1[i]; |
1143 | break; | 1114 | break; |
1144 | } | 1115 | } |
@@ -1151,28 +1122,8 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1151 | union i2c_smbus_data * data) | 1122 | union i2c_smbus_data * data) |
1152 | { | 1123 | { |
1153 | s32 res; | 1124 | s32 res; |
1154 | int swpec = 0; | ||
1155 | u8 partial = 0; | ||
1156 | 1125 | ||
1157 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1126 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1158 | if((flags & I2C_CLIENT_PEC) && | ||
1159 | !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { | ||
1160 | swpec = 1; | ||
1161 | if(read_write == I2C_SMBUS_READ && | ||
1162 | size == I2C_SMBUS_BLOCK_DATA) | ||
1163 | size = I2C_SMBUS_BLOCK_DATA_PEC; | ||
1164 | else if(size == I2C_SMBUS_PROC_CALL) | ||
1165 | size = I2C_SMBUS_PROC_CALL_PEC; | ||
1166 | else if(size == I2C_SMBUS_BLOCK_PROC_CALL) { | ||
1167 | i2c_smbus_add_pec(addr, command, | ||
1168 | I2C_SMBUS_BLOCK_DATA, data); | ||
1169 | partial = data->block[data->block[0] + 1]; | ||
1170 | size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; | ||
1171 | } else if(read_write == I2C_SMBUS_WRITE && | ||
1172 | size != I2C_SMBUS_QUICK && | ||
1173 | size != I2C_SMBUS_I2C_BLOCK_DATA) | ||
1174 | size = i2c_smbus_add_pec(addr, command, size, data); | ||
1175 | } | ||
1176 | 1127 | ||
1177 | if (adapter->algo->smbus_xfer) { | 1128 | if (adapter->algo->smbus_xfer) { |
1178 | down(&adapter->bus_lock); | 1129 | down(&adapter->bus_lock); |
@@ -1183,13 +1134,6 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | |||
1183 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1134 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1184 | command,size,data); | 1135 | command,size,data); |
1185 | 1136 | ||
1186 | if(res >= 0 && swpec && | ||
1187 | size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && | ||
1188 | (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || | ||
1189 | size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) { | ||
1190 | if(i2c_smbus_check_pec(addr, command, size, partial, data)) | ||
1191 | return -1; | ||
1192 | } | ||
1193 | return res; | 1137 | return res; |
1194 | } | 1138 | } |
1195 | 1139 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index aa7a4fadef64..ea14c8f1c82b 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -26,15 +26,11 @@ | |||
26 | 26 | ||
27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ | 27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ |
28 | 28 | ||
29 | /* The devfs code is contributed by Philipp Matthias Hahn | ||
30 | <pmhahn@titan.lahn.de> */ | ||
31 | |||
32 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 30 | #include <linux/module.h> |
34 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
35 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
36 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
37 | #include <linux/devfs_fs_kernel.h> | ||
38 | #include <linux/init.h> | 34 | #include <linux/init.h> |
39 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
40 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
@@ -80,10 +76,9 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) | |||
80 | { | 76 | { |
81 | struct i2c_dev *i2c_dev; | 77 | struct i2c_dev *i2c_dev; |
82 | 78 | ||
83 | i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); | 79 | i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); |
84 | if (!i2c_dev) | 80 | if (!i2c_dev) |
85 | return ERR_PTR(-ENOMEM); | 81 | return ERR_PTR(-ENOMEM); |
86 | memset(i2c_dev, 0x00, sizeof(*i2c_dev)); | ||
87 | 82 | ||
88 | spin_lock(&i2c_dev_array_lock); | 83 | spin_lock(&i2c_dev_array_lock); |
89 | if (i2c_dev_array[adap->nr]) { | 84 | if (i2c_dev_array[adap->nr]) { |
@@ -177,8 +172,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
177 | int i,datasize,res; | 172 | int i,datasize,res; |
178 | unsigned long funcs; | 173 | unsigned long funcs; |
179 | 174 | ||
180 | dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", | 175 | dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", |
181 | iminor(inode),cmd, arg); | 176 | cmd, arg); |
182 | 177 | ||
183 | switch ( cmd ) { | 178 | switch ( cmd ) { |
184 | case I2C_SLAVE: | 179 | case I2C_SLAVE: |
@@ -432,8 +427,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
432 | if (IS_ERR(i2c_dev)) | 427 | if (IS_ERR(i2c_dev)) |
433 | return PTR_ERR(i2c_dev); | 428 | return PTR_ERR(i2c_dev); |
434 | 429 | ||
435 | devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), | ||
436 | S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); | ||
437 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", | 430 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", |
438 | adap->name, i2c_dev->minor); | 431 | adap->name, i2c_dev->minor); |
439 | 432 | ||
@@ -466,7 +459,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
466 | return -ENODEV; | 459 | return -ENODEV; |
467 | 460 | ||
468 | init_completion(&i2c_dev->released); | 461 | init_completion(&i2c_dev->released); |
469 | devfs_remove("i2c/%d", i2c_dev->minor); | ||
470 | return_i2c_dev(i2c_dev); | 462 | return_i2c_dev(i2c_dev); |
471 | class_device_unregister(&i2c_dev->class_dev); | 463 | class_device_unregister(&i2c_dev->class_dev); |
472 | wait_for_completion(&i2c_dev->released); | 464 | wait_for_completion(&i2c_dev->released); |
@@ -522,8 +514,6 @@ static int __init i2c_dev_init(void) | |||
522 | if (res) | 514 | if (res) |
523 | goto out_unreg_class; | 515 | goto out_unreg_class; |
524 | 516 | ||
525 | devfs_mk_dir("i2c"); | ||
526 | |||
527 | return 0; | 517 | return 0; |
528 | 518 | ||
529 | out_unreg_class: | 519 | out_unreg_class: |
@@ -539,7 +529,6 @@ static void __exit i2c_dev_exit(void) | |||
539 | { | 529 | { |
540 | i2c_del_driver(&i2cdev_driver); | 530 | i2c_del_driver(&i2cdev_driver); |
541 | class_unregister(&i2c_dev_class); | 531 | class_unregister(&i2c_dev_class); |
542 | devfs_remove("i2c"); | ||
543 | unregister_chrdev(I2C_MAJOR,"i2c"); | 532 | unregister_chrdev(I2C_MAJOR,"i2c"); |
544 | } | 533 | } |
545 | 534 | ||