aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r--drivers/hwmon/pmbus/Kconfig17
-rw-r--r--drivers/hwmon/pmbus/adm1275.c124
-rw-r--r--drivers/hwmon/pmbus/lm25066.c46
-rw-r--r--drivers/hwmon/pmbus/ltc2978.c50
-rw-r--r--drivers/hwmon/pmbus/max16064.c20
-rw-r--r--drivers/hwmon/pmbus/max34440.c139
-rw-r--r--drivers/hwmon/pmbus/max8688.c20
-rw-r--r--drivers/hwmon/pmbus/pmbus.c40
-rw-r--r--drivers/hwmon/pmbus/pmbus.h57
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c87
-rw-r--r--drivers/hwmon/pmbus/ucd9000.c47
-rw-r--r--drivers/hwmon/pmbus/ucd9200.c43
-rw-r--r--drivers/hwmon/pmbus/zl6100.c44
13 files changed, 351 insertions, 383 deletions
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index cfec923f42b7..2ca6a5a4f5a7 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -20,7 +20,8 @@ config SENSORS_PMBUS
20 help 20 help
21 If you say yes here you get hardware monitoring support for generic 21 If you say yes here you get hardware monitoring support for generic
22 PMBus devices, including but not limited to ADP4000, BMR453, BMR454, 22 PMBus devices, including but not limited to ADP4000, BMR453, BMR454,
23 NCP4200, and NCP4208. 23 MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012, UDT020, TPS40400,
24 and TPS40422.
24 25
25 This driver can also be built as a module. If so, the module will 26 This driver can also be built as a module. If so, the module will
26 be called pmbus. 27 be called pmbus.
@@ -30,8 +31,8 @@ config SENSORS_ADM1275
30 default n 31 default n
31 help 32 help
32 If you say yes here you get hardware monitoring support for Analog 33 If you say yes here you get hardware monitoring support for Analog
33 Devices ADM1275 and ADM1276 Hot-Swap Controller and Digital Power 34 Devices ADM1075, ADM1275, and ADM1276 Hot-Swap Controller and Digital
34 Monitor. 35 Power Monitors.
35 36
36 This driver can also be built as a module. If so, the module will 37 This driver can also be built as a module. If so, the module will
37 be called adm1275. 38 be called adm1275.
@@ -67,11 +68,11 @@ config SENSORS_MAX16064
67 be called max16064. 68 be called max16064.
68 69
69config SENSORS_MAX34440 70config SENSORS_MAX34440
70 tristate "Maxim MAX34440/MAX34441" 71 tristate "Maxim MAX34440 and compatibles"
71 default n 72 default n
72 help 73 help
73 If you say yes here you get hardware monitoring support for Maxim 74 If you say yes here you get hardware monitoring support for Maxim
74 MAX34440 and MAX34441. 75 MAX34440, MAX34441, and MAX34446.
75 76
76 This driver can also be built as a module. If so, the module will 77 This driver can also be built as a module. If so, the module will
77 be called max34440. 78 be called max34440.
@@ -113,9 +114,9 @@ config SENSORS_ZL6100
113 default n 114 default n
114 help 115 help
115 If you say yes here you get hardware monitoring support for Intersil 116 If you say yes here you get hardware monitoring support for Intersil
116 ZL2004, ZL2005, ZL2006, ZL2008, ZL2105, ZL2106, ZL6100, and ZL6105 117 ZL2004, ZL2005, ZL2006, ZL2008, ZL2105, ZL2106, ZL6100, ZL6105,
117 Digital DC/DC Controllers, as well as for Ericsson BMR450, BMR451, 118 ZL9101M, and ZL9117M Digital DC/DC Controllers, as well as for
118 BMR462, BMR463, and BMR464. 119 Ericsson BMR450, BMR451, BMR462, BMR463, and BMR464.
119 120
120 This driver can also be built as a module. If so, the module will 121 This driver can also be built as a module. If so, the module will
121 be called zl6100. 122 be called zl6100.
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 81c7c2ead6f3..60aad9570f01 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -23,7 +23,7 @@
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include "pmbus.h" 24#include "pmbus.h"
25 25
26enum chips { adm1275, adm1276 }; 26enum chips { adm1075, adm1275, adm1276 };
27 27
28#define ADM1275_PEAK_IOUT 0xd0 28#define ADM1275_PEAK_IOUT 0xd0
29#define ADM1275_PEAK_VIN 0xd1 29#define ADM1275_PEAK_VIN 0xd1
@@ -32,6 +32,9 @@ enum chips { adm1275, adm1276 };
32 32
33#define ADM1275_VIN_VOUT_SELECT (1 << 6) 33#define ADM1275_VIN_VOUT_SELECT (1 << 6)
34#define ADM1275_VRANGE (1 << 5) 34#define ADM1275_VRANGE (1 << 5)
35#define ADM1075_IRANGE_50 (1 << 4)
36#define ADM1075_IRANGE_25 (1 << 3)
37#define ADM1075_IRANGE_MASK ((1 << 3) | (1 << 4))
35 38
36#define ADM1275_IOUT_WARN2_LIMIT 0xd7 39#define ADM1275_IOUT_WARN2_LIMIT 0xd7
37#define ADM1275_DEVICE_CONFIG 0xd8 40#define ADM1275_DEVICE_CONFIG 0xd8
@@ -42,6 +45,14 @@ enum chips { adm1275, adm1276 };
42 45
43#define ADM1275_MFR_STATUS_IOUT_WARN2 (1 << 0) 46#define ADM1275_MFR_STATUS_IOUT_WARN2 (1 << 0)
44 47
48#define ADM1075_READ_VAUX 0xdd
49#define ADM1075_VAUX_OV_WARN_LIMIT 0xde
50#define ADM1075_VAUX_UV_WARN_LIMIT 0xdf
51#define ADM1075_VAUX_STATUS 0xf6
52
53#define ADM1075_VAUX_OV_WARN (1<<7)
54#define ADM1075_VAUX_UV_WARN (1<<6)
55
45struct adm1275_data { 56struct adm1275_data {
46 int id; 57 int id;
47 bool have_oc_fault; 58 bool have_oc_fault;
@@ -74,6 +85,29 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
74 } 85 }
75 ret = pmbus_read_word_data(client, 0, ADM1275_IOUT_WARN2_LIMIT); 86 ret = pmbus_read_word_data(client, 0, ADM1275_IOUT_WARN2_LIMIT);
76 break; 87 break;
88 case PMBUS_VOUT_OV_WARN_LIMIT:
89 if (data->id != adm1075) {
90 ret = -ENODATA;
91 break;
92 }
93 ret = pmbus_read_word_data(client, 0,
94 ADM1075_VAUX_OV_WARN_LIMIT);
95 break;
96 case PMBUS_VOUT_UV_WARN_LIMIT:
97 if (data->id != adm1075) {
98 ret = -ENODATA;
99 break;
100 }
101 ret = pmbus_read_word_data(client, 0,
102 ADM1075_VAUX_UV_WARN_LIMIT);
103 break;
104 case PMBUS_READ_VOUT:
105 if (data->id != adm1075) {
106 ret = -ENODATA;
107 break;
108 }
109 ret = pmbus_read_word_data(client, 0, ADM1075_READ_VAUX);
110 break;
77 case PMBUS_VIRT_READ_IOUT_MAX: 111 case PMBUS_VIRT_READ_IOUT_MAX:
78 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_IOUT); 112 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_IOUT);
79 break; 113 break;
@@ -84,7 +118,7 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
84 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN); 118 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN);
85 break; 119 break;
86 case PMBUS_VIRT_READ_PIN_MAX: 120 case PMBUS_VIRT_READ_PIN_MAX:
87 if (data->id != adm1276) { 121 if (data->id == adm1275) {
88 ret = -ENXIO; 122 ret = -ENXIO;
89 break; 123 break;
90 } 124 }
@@ -95,7 +129,7 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
95 case PMBUS_VIRT_RESET_VIN_HISTORY: 129 case PMBUS_VIRT_RESET_VIN_HISTORY:
96 break; 130 break;
97 case PMBUS_VIRT_RESET_PIN_HISTORY: 131 case PMBUS_VIRT_RESET_PIN_HISTORY:
98 if (data->id != adm1276) 132 if (data->id == adm1275)
99 ret = -ENXIO; 133 ret = -ENXIO;
100 break; 134 break;
101 default: 135 default:
@@ -163,6 +197,19 @@ static int adm1275_read_byte_data(struct i2c_client *client, int page, int reg)
163 PB_IOUT_OC_FAULT : PB_IOUT_UC_FAULT; 197 PB_IOUT_OC_FAULT : PB_IOUT_UC_FAULT;
164 } 198 }
165 break; 199 break;
200 case PMBUS_STATUS_VOUT:
201 if (data->id != adm1075) {
202 ret = -ENODATA;
203 break;
204 }
205 ret = 0;
206 mfr_status = pmbus_read_byte_data(client, 0,
207 ADM1075_VAUX_STATUS);
208 if (mfr_status & ADM1075_VAUX_OV_WARN)
209 ret |= PB_VOLTAGE_OV_WARNING;
210 if (mfr_status & ADM1075_VAUX_UV_WARN)
211 ret |= PB_VOLTAGE_UV_WARNING;
212 break;
166 default: 213 default:
167 ret = -ENODATA; 214 ret = -ENODATA;
168 break; 215 break;
@@ -171,6 +218,7 @@ static int adm1275_read_byte_data(struct i2c_client *client, int page, int reg)
171} 218}
172 219
173static const struct i2c_device_id adm1275_id[] = { 220static const struct i2c_device_id adm1275_id[] = {
221 { "adm1075", adm1075 },
174 { "adm1275", adm1275 }, 222 { "adm1275", adm1275 },
175 { "adm1276", adm1276 }, 223 { "adm1276", adm1276 },
176 { } 224 { }
@@ -229,7 +277,8 @@ static int adm1275_probe(struct i2c_client *client,
229 if (device_config < 0) 277 if (device_config < 0)
230 return device_config; 278 return device_config;
231 279
232 data = kzalloc(sizeof(struct adm1275_data), GFP_KERNEL); 280 data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data),
281 GFP_KERNEL);
233 if (!data) 282 if (!data)
234 return -ENOMEM; 283 return -ENOMEM;
235 284
@@ -250,7 +299,14 @@ static int adm1275_probe(struct i2c_client *client,
250 info->read_byte_data = adm1275_read_byte_data; 299 info->read_byte_data = adm1275_read_byte_data;
251 info->write_word_data = adm1275_write_word_data; 300 info->write_word_data = adm1275_write_word_data;
252 301
253 if (config & ADM1275_VRANGE) { 302 if (data->id == adm1075) {
303 info->m[PSC_VOLTAGE_IN] = 27169;
304 info->b[PSC_VOLTAGE_IN] = 0;
305 info->R[PSC_VOLTAGE_IN] = -1;
306 info->m[PSC_VOLTAGE_OUT] = 27169;
307 info->b[PSC_VOLTAGE_OUT] = 0;
308 info->R[PSC_VOLTAGE_OUT] = -1;
309 } else if (config & ADM1275_VRANGE) {
254 info->m[PSC_VOLTAGE_IN] = 19199; 310 info->m[PSC_VOLTAGE_IN] = 19199;
255 info->b[PSC_VOLTAGE_IN] = 0; 311 info->b[PSC_VOLTAGE_IN] = 0;
256 info->R[PSC_VOLTAGE_IN] = -2; 312 info->R[PSC_VOLTAGE_IN] = -2;
@@ -270,6 +326,31 @@ static int adm1275_probe(struct i2c_client *client,
270 data->have_oc_fault = true; 326 data->have_oc_fault = true;
271 327
272 switch (data->id) { 328 switch (data->id) {
329 case adm1075:
330 info->format[PSC_POWER] = direct;
331 info->b[PSC_POWER] = 0;
332 info->R[PSC_POWER] = -1;
333 switch (config & ADM1075_IRANGE_MASK) {
334 case ADM1075_IRANGE_25:
335 info->m[PSC_POWER] = 8549;
336 info->m[PSC_CURRENT_OUT] = 806;
337 break;
338 case ADM1075_IRANGE_50:
339 info->m[PSC_POWER] = 4279;
340 info->m[PSC_CURRENT_OUT] = 404;
341 break;
342 default:
343 dev_err(&client->dev, "Invalid input current range");
344 info->m[PSC_POWER] = 0;
345 info->m[PSC_CURRENT_OUT] = 0;
346 break;
347 }
348 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN
349 | PMBUS_HAVE_STATUS_INPUT;
350 if (config & ADM1275_VIN_VOUT_SELECT)
351 info->func[0] |=
352 PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT;
353 break;
273 case adm1275: 354 case adm1275:
274 if (config & ADM1275_VIN_VOUT_SELECT) 355 if (config & ADM1275_VIN_VOUT_SELECT)
275 info->func[0] |= 356 info->func[0] |=
@@ -297,24 +378,7 @@ static int adm1275_probe(struct i2c_client *client,
297 break; 378 break;
298 } 379 }
299 380
300 ret = pmbus_do_probe(client, id, info); 381 return pmbus_do_probe(client, id, info);
301 if (ret)
302 goto err_mem;
303 return 0;
304
305err_mem:
306 kfree(data);
307 return ret;
308}
309
310static int adm1275_remove(struct i2c_client *client)
311{
312 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
313 const struct adm1275_data *data = to_adm1275_data(info);
314
315 pmbus_do_remove(client);
316 kfree(data);
317 return 0;
318} 382}
319 383
320static struct i2c_driver adm1275_driver = { 384static struct i2c_driver adm1275_driver = {
@@ -322,22 +386,12 @@ static struct i2c_driver adm1275_driver = {
322 .name = "adm1275", 386 .name = "adm1275",
323 }, 387 },
324 .probe = adm1275_probe, 388 .probe = adm1275_probe,
325 .remove = adm1275_remove, 389 .remove = pmbus_do_remove,
326 .id_table = adm1275_id, 390 .id_table = adm1275_id,
327}; 391};
328 392
329static int __init adm1275_init(void) 393module_i2c_driver(adm1275_driver);
330{
331 return i2c_add_driver(&adm1275_driver);
332}
333
334static void __exit adm1275_exit(void)
335{
336 i2c_del_driver(&adm1275_driver);
337}
338 394
339MODULE_AUTHOR("Guenter Roeck"); 395MODULE_AUTHOR("Guenter Roeck");
340MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275 and compatibles"); 396MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275 and compatibles");
341MODULE_LICENSE("GPL"); 397MODULE_LICENSE("GPL");
342module_init(adm1275_init);
343module_exit(adm1275_exit);
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 84a37f0c8db6..c299392716af 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -176,7 +176,6 @@ static int lm25066_probe(struct i2c_client *client,
176 const struct i2c_device_id *id) 176 const struct i2c_device_id *id)
177{ 177{
178 int config; 178 int config;
179 int ret;
180 struct lm25066_data *data; 179 struct lm25066_data *data;
181 struct pmbus_driver_info *info; 180 struct pmbus_driver_info *info;
182 181
@@ -184,15 +183,14 @@ static int lm25066_probe(struct i2c_client *client,
184 I2C_FUNC_SMBUS_READ_BYTE_DATA)) 183 I2C_FUNC_SMBUS_READ_BYTE_DATA))
185 return -ENODEV; 184 return -ENODEV;
186 185
187 data = kzalloc(sizeof(struct lm25066_data), GFP_KERNEL); 186 data = devm_kzalloc(&client->dev, sizeof(struct lm25066_data),
187 GFP_KERNEL);
188 if (!data) 188 if (!data)
189 return -ENOMEM; 189 return -ENOMEM;
190 190
191 config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP); 191 config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP);
192 if (config < 0) { 192 if (config < 0)
193 ret = config; 193 return config;
194 goto err_mem;
195 }
196 194
197 data->id = id->driver_data; 195 data->id = id->driver_data;
198 info = &data->info; 196 info = &data->info;
@@ -291,28 +289,10 @@ static int lm25066_probe(struct i2c_client *client,
291 } 289 }
292 break; 290 break;
293 default: 291 default:
294 ret = -ENODEV; 292 return -ENODEV;
295 goto err_mem;
296 } 293 }
297 294
298 ret = pmbus_do_probe(client, id, info); 295 return pmbus_do_probe(client, id, info);
299 if (ret)
300 goto err_mem;
301 return 0;
302
303err_mem:
304 kfree(data);
305 return ret;
306}
307
308static int lm25066_remove(struct i2c_client *client)
309{
310 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
311 const struct lm25066_data *data = to_lm25066_data(info);
312
313 pmbus_do_remove(client);
314 kfree(data);
315 return 0;
316} 296}
317 297
318static const struct i2c_device_id lm25066_id[] = { 298static const struct i2c_device_id lm25066_id[] = {
@@ -330,22 +310,12 @@ static struct i2c_driver lm25066_driver = {
330 .name = "lm25066", 310 .name = "lm25066",
331 }, 311 },
332 .probe = lm25066_probe, 312 .probe = lm25066_probe,
333 .remove = lm25066_remove, 313 .remove = pmbus_do_remove,
334 .id_table = lm25066_id, 314 .id_table = lm25066_id,
335}; 315};
336 316
337static int __init lm25066_init(void) 317module_i2c_driver(lm25066_driver);
338{
339 return i2c_add_driver(&lm25066_driver);
340}
341
342static void __exit lm25066_exit(void)
343{
344 i2c_del_driver(&lm25066_driver);
345}
346 318
347MODULE_AUTHOR("Guenter Roeck"); 319MODULE_AUTHOR("Guenter Roeck");
348MODULE_DESCRIPTION("PMBus driver for LM25066/LM5064/LM5066"); 320MODULE_DESCRIPTION("PMBus driver for LM25066/LM5064/LM5066");
349MODULE_LICENSE("GPL"); 321MODULE_LICENSE("GPL");
350module_init(lm25066_init);
351module_exit(lm25066_exit);
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index 820fff48910b..9652a2c92a24 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -287,7 +287,7 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id);
287static int ltc2978_probe(struct i2c_client *client, 287static int ltc2978_probe(struct i2c_client *client,
288 const struct i2c_device_id *id) 288 const struct i2c_device_id *id)
289{ 289{
290 int chip_id, ret, i; 290 int chip_id, i;
291 struct ltc2978_data *data; 291 struct ltc2978_data *data;
292 struct pmbus_driver_info *info; 292 struct pmbus_driver_info *info;
293 293
@@ -295,15 +295,14 @@ static int ltc2978_probe(struct i2c_client *client,
295 I2C_FUNC_SMBUS_READ_WORD_DATA)) 295 I2C_FUNC_SMBUS_READ_WORD_DATA))
296 return -ENODEV; 296 return -ENODEV;
297 297
298 data = kzalloc(sizeof(struct ltc2978_data), GFP_KERNEL); 298 data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data),
299 GFP_KERNEL);
299 if (!data) 300 if (!data)
300 return -ENOMEM; 301 return -ENOMEM;
301 302
302 chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID); 303 chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID);
303 if (chip_id < 0) { 304 if (chip_id < 0)
304 ret = chip_id; 305 return chip_id;
305 goto err_mem;
306 }
307 306
308 if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) { 307 if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) {
309 data->id = ltc2978; 308 data->id = ltc2978;
@@ -311,8 +310,7 @@ static int ltc2978_probe(struct i2c_client *client,
311 data->id = ltc3880; 310 data->id = ltc3880;
312 } else { 311 } else {
313 dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id); 312 dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id);
314 ret = -ENODEV; 313 return -ENODEV;
315 goto err_mem;
316 } 314 }
317 if (data->id != id->driver_data) 315 if (data->id != id->driver_data)
318 dev_warn(&client->dev, 316 dev_warn(&client->dev,
@@ -357,28 +355,10 @@ static int ltc2978_probe(struct i2c_client *client,
357 data->vout_min[1] = 0xffff; 355 data->vout_min[1] = 0xffff;
358 break; 356 break;
359 default: 357 default:
360 ret = -ENODEV; 358 return -ENODEV;
361 goto err_mem;
362 } 359 }
363 360
364 ret = pmbus_do_probe(client, id, info); 361 return pmbus_do_probe(client, id, info);
365 if (ret)
366 goto err_mem;
367 return 0;
368
369err_mem:
370 kfree(data);
371 return ret;
372}
373
374static int ltc2978_remove(struct i2c_client *client)
375{
376 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
377 const struct ltc2978_data *data = to_ltc2978_data(info);
378
379 pmbus_do_remove(client);
380 kfree(data);
381 return 0;
382} 362}
383 363
384/* This is the driver that will be inserted */ 364/* This is the driver that will be inserted */
@@ -387,22 +367,12 @@ static struct i2c_driver ltc2978_driver = {
387 .name = "ltc2978", 367 .name = "ltc2978",
388 }, 368 },
389 .probe = ltc2978_probe, 369 .probe = ltc2978_probe,
390 .remove = ltc2978_remove, 370 .remove = pmbus_do_remove,
391 .id_table = ltc2978_id, 371 .id_table = ltc2978_id,
392}; 372};
393 373
394static int __init ltc2978_init(void) 374module_i2c_driver(ltc2978_driver);
395{
396 return i2c_add_driver(&ltc2978_driver);
397}
398
399static void __exit ltc2978_exit(void)
400{
401 i2c_del_driver(&ltc2978_driver);
402}
403 375
404MODULE_AUTHOR("Guenter Roeck"); 376MODULE_AUTHOR("Guenter Roeck");
405MODULE_DESCRIPTION("PMBus driver for LTC2978 and LTC3880"); 377MODULE_DESCRIPTION("PMBus driver for LTC2978 and LTC3880");
406MODULE_LICENSE("GPL"); 378MODULE_LICENSE("GPL");
407module_init(ltc2978_init);
408module_exit(ltc2978_exit);
diff --git a/drivers/hwmon/pmbus/max16064.c b/drivers/hwmon/pmbus/max16064.c
index 1d77cf4d2d44..fa237a3c3291 100644
--- a/drivers/hwmon/pmbus/max16064.c
+++ b/drivers/hwmon/pmbus/max16064.c
@@ -103,12 +103,6 @@ static int max16064_probe(struct i2c_client *client,
103 return pmbus_do_probe(client, id, &max16064_info); 103 return pmbus_do_probe(client, id, &max16064_info);
104} 104}
105 105
106static int max16064_remove(struct i2c_client *client)
107{
108 pmbus_do_remove(client);
109 return 0;
110}
111
112static const struct i2c_device_id max16064_id[] = { 106static const struct i2c_device_id max16064_id[] = {
113 {"max16064", 0}, 107 {"max16064", 0},
114 {} 108 {}
@@ -122,22 +116,12 @@ static struct i2c_driver max16064_driver = {
122 .name = "max16064", 116 .name = "max16064",
123 }, 117 },
124 .probe = max16064_probe, 118 .probe = max16064_probe,
125 .remove = max16064_remove, 119 .remove = pmbus_do_remove,
126 .id_table = max16064_id, 120 .id_table = max16064_id,
127}; 121};
128 122
129static int __init max16064_init(void) 123module_i2c_driver(max16064_driver);
130{
131 return i2c_add_driver(&max16064_driver);
132}
133
134static void __exit max16064_exit(void)
135{
136 i2c_del_driver(&max16064_driver);
137}
138 124
139MODULE_AUTHOR("Guenter Roeck"); 125MODULE_AUTHOR("Guenter Roeck");
140MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064"); 126MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
141MODULE_LICENSE("GPL"); 127MODULE_LICENSE("GPL");
142module_init(max16064_init);
143module_exit(max16064_exit);
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index 9b97a5b3cf3d..2ada7b021fbe 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -25,34 +25,82 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include "pmbus.h" 26#include "pmbus.h"
27 27
28enum chips { max34440, max34441 }; 28enum chips { max34440, max34441, max34446 };
29 29
30#define MAX34440_MFR_VOUT_PEAK 0xd4 30#define MAX34440_MFR_VOUT_PEAK 0xd4
31#define MAX34440_MFR_IOUT_PEAK 0xd5 31#define MAX34440_MFR_IOUT_PEAK 0xd5
32#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6 32#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
33#define MAX34440_MFR_VOUT_MIN 0xd7
34
35#define MAX34446_MFR_POUT_PEAK 0xe0
36#define MAX34446_MFR_POUT_AVG 0xe1
37#define MAX34446_MFR_IOUT_AVG 0xe2
38#define MAX34446_MFR_TEMPERATURE_AVG 0xe3
33 39
34#define MAX34440_STATUS_OC_WARN (1 << 0) 40#define MAX34440_STATUS_OC_WARN (1 << 0)
35#define MAX34440_STATUS_OC_FAULT (1 << 1) 41#define MAX34440_STATUS_OC_FAULT (1 << 1)
36#define MAX34440_STATUS_OT_FAULT (1 << 5) 42#define MAX34440_STATUS_OT_FAULT (1 << 5)
37#define MAX34440_STATUS_OT_WARN (1 << 6) 43#define MAX34440_STATUS_OT_WARN (1 << 6)
38 44
45struct max34440_data {
46 int id;
47 struct pmbus_driver_info info;
48};
49
50#define to_max34440_data(x) container_of(x, struct max34440_data, info)
51
39static int max34440_read_word_data(struct i2c_client *client, int page, int reg) 52static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
40{ 53{
41 int ret; 54 int ret;
55 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
56 const struct max34440_data *data = to_max34440_data(info);
42 57
43 switch (reg) { 58 switch (reg) {
59 case PMBUS_VIRT_READ_VOUT_MIN:
60 ret = pmbus_read_word_data(client, page,
61 MAX34440_MFR_VOUT_MIN);
62 break;
44 case PMBUS_VIRT_READ_VOUT_MAX: 63 case PMBUS_VIRT_READ_VOUT_MAX:
45 ret = pmbus_read_word_data(client, page, 64 ret = pmbus_read_word_data(client, page,
46 MAX34440_MFR_VOUT_PEAK); 65 MAX34440_MFR_VOUT_PEAK);
47 break; 66 break;
67 case PMBUS_VIRT_READ_IOUT_AVG:
68 if (data->id != max34446)
69 return -ENXIO;
70 ret = pmbus_read_word_data(client, page,
71 MAX34446_MFR_IOUT_AVG);
72 break;
48 case PMBUS_VIRT_READ_IOUT_MAX: 73 case PMBUS_VIRT_READ_IOUT_MAX:
49 ret = pmbus_read_word_data(client, page, 74 ret = pmbus_read_word_data(client, page,
50 MAX34440_MFR_IOUT_PEAK); 75 MAX34440_MFR_IOUT_PEAK);
51 break; 76 break;
77 case PMBUS_VIRT_READ_POUT_AVG:
78 if (data->id != max34446)
79 return -ENXIO;
80 ret = pmbus_read_word_data(client, page,
81 MAX34446_MFR_POUT_AVG);
82 break;
83 case PMBUS_VIRT_READ_POUT_MAX:
84 if (data->id != max34446)
85 return -ENXIO;
86 ret = pmbus_read_word_data(client, page,
87 MAX34446_MFR_POUT_PEAK);
88 break;
89 case PMBUS_VIRT_READ_TEMP_AVG:
90 if (data->id != max34446)
91 return -ENXIO;
92 ret = pmbus_read_word_data(client, page,
93 MAX34446_MFR_TEMPERATURE_AVG);
94 break;
52 case PMBUS_VIRT_READ_TEMP_MAX: 95 case PMBUS_VIRT_READ_TEMP_MAX:
53 ret = pmbus_read_word_data(client, page, 96 ret = pmbus_read_word_data(client, page,
54 MAX34440_MFR_TEMPERATURE_PEAK); 97 MAX34440_MFR_TEMPERATURE_PEAK);
55 break; 98 break;
99 case PMBUS_VIRT_RESET_POUT_HISTORY:
100 if (data->id != max34446)
101 return -ENXIO;
102 ret = 0;
103 break;
56 case PMBUS_VIRT_RESET_VOUT_HISTORY: 104 case PMBUS_VIRT_RESET_VOUT_HISTORY:
57 case PMBUS_VIRT_RESET_IOUT_HISTORY: 105 case PMBUS_VIRT_RESET_IOUT_HISTORY:
58 case PMBUS_VIRT_RESET_TEMP_HISTORY: 106 case PMBUS_VIRT_RESET_TEMP_HISTORY:
@@ -68,21 +116,42 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
68static int max34440_write_word_data(struct i2c_client *client, int page, 116static int max34440_write_word_data(struct i2c_client *client, int page,
69 int reg, u16 word) 117 int reg, u16 word)
70{ 118{
119 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
120 const struct max34440_data *data = to_max34440_data(info);
71 int ret; 121 int ret;
72 122
73 switch (reg) { 123 switch (reg) {
124 case PMBUS_VIRT_RESET_POUT_HISTORY:
125 ret = pmbus_write_word_data(client, page,
126 MAX34446_MFR_POUT_PEAK, 0);
127 if (ret)
128 break;
129 ret = pmbus_write_word_data(client, page,
130 MAX34446_MFR_POUT_AVG, 0);
131 break;
74 case PMBUS_VIRT_RESET_VOUT_HISTORY: 132 case PMBUS_VIRT_RESET_VOUT_HISTORY:
75 ret = pmbus_write_word_data(client, page, 133 ret = pmbus_write_word_data(client, page,
134 MAX34440_MFR_VOUT_MIN, 0x7fff);
135 if (ret)
136 break;
137 ret = pmbus_write_word_data(client, page,
76 MAX34440_MFR_VOUT_PEAK, 0); 138 MAX34440_MFR_VOUT_PEAK, 0);
77 break; 139 break;
78 case PMBUS_VIRT_RESET_IOUT_HISTORY: 140 case PMBUS_VIRT_RESET_IOUT_HISTORY:
79 ret = pmbus_write_word_data(client, page, 141 ret = pmbus_write_word_data(client, page,
80 MAX34440_MFR_IOUT_PEAK, 0); 142 MAX34440_MFR_IOUT_PEAK, 0);
143 if (!ret && data->id == max34446)
144 ret = pmbus_write_word_data(client, page,
145 MAX34446_MFR_IOUT_AVG, 0);
146
81 break; 147 break;
82 case PMBUS_VIRT_RESET_TEMP_HISTORY: 148 case PMBUS_VIRT_RESET_TEMP_HISTORY:
83 ret = pmbus_write_word_data(client, page, 149 ret = pmbus_write_word_data(client, page,
84 MAX34440_MFR_TEMPERATURE_PEAK, 150 MAX34440_MFR_TEMPERATURE_PEAK,
85 0x8000); 151 0x8000);
152 if (!ret && data->id == max34446)
153 ret = pmbus_write_word_data(client, page,
154 MAX34446_MFR_TEMPERATURE_AVG, 0);
86 break; 155 break;
87 default: 156 default:
88 ret = -ENODATA; 157 ret = -ENODATA;
@@ -216,26 +285,66 @@ static struct pmbus_driver_info max34440_info[] = {
216 .read_word_data = max34440_read_word_data, 285 .read_word_data = max34440_read_word_data,
217 .write_word_data = max34440_write_word_data, 286 .write_word_data = max34440_write_word_data,
218 }, 287 },
288 [max34446] = {
289 .pages = 7,
290 .format[PSC_VOLTAGE_IN] = direct,
291 .format[PSC_VOLTAGE_OUT] = direct,
292 .format[PSC_TEMPERATURE] = direct,
293 .format[PSC_CURRENT_OUT] = direct,
294 .format[PSC_POWER] = direct,
295 .m[PSC_VOLTAGE_IN] = 1,
296 .b[PSC_VOLTAGE_IN] = 0,
297 .R[PSC_VOLTAGE_IN] = 3,
298 .m[PSC_VOLTAGE_OUT] = 1,
299 .b[PSC_VOLTAGE_OUT] = 0,
300 .R[PSC_VOLTAGE_OUT] = 3,
301 .m[PSC_CURRENT_OUT] = 1,
302 .b[PSC_CURRENT_OUT] = 0,
303 .R[PSC_CURRENT_OUT] = 3,
304 .m[PSC_POWER] = 1,
305 .b[PSC_POWER] = 0,
306 .R[PSC_POWER] = 3,
307 .m[PSC_TEMPERATURE] = 1,
308 .b[PSC_TEMPERATURE] = 0,
309 .R[PSC_TEMPERATURE] = 2,
310 .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
311 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
312 .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
313 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
314 .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
315 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
316 .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
317 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
318 .func[4] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
319 .func[5] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
320 .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
321 .read_byte_data = max34440_read_byte_data,
322 .read_word_data = max34440_read_word_data,
323 .write_word_data = max34440_write_word_data,
324 },
219}; 325};
220 326
221static int max34440_probe(struct i2c_client *client, 327static int max34440_probe(struct i2c_client *client,
222 const struct i2c_device_id *id) 328 const struct i2c_device_id *id)
223{ 329{
224 return pmbus_do_probe(client, id, &max34440_info[id->driver_data]); 330 struct max34440_data *data;
225}
226 331
227static int max34440_remove(struct i2c_client *client) 332 data = devm_kzalloc(&client->dev, sizeof(struct max34440_data),
228{ 333 GFP_KERNEL);
229 pmbus_do_remove(client); 334 if (!data)
230 return 0; 335 return -ENOMEM;
336 data->id = id->driver_data;
337 data->info = max34440_info[id->driver_data];
338
339 return pmbus_do_probe(client, id, &data->info);
231} 340}
232 341
233static const struct i2c_device_id max34440_id[] = { 342static const struct i2c_device_id max34440_id[] = {
234 {"max34440", max34440}, 343 {"max34440", max34440},
235 {"max34441", max34441}, 344 {"max34441", max34441},
345 {"max34446", max34446},
236 {} 346 {}
237}; 347};
238
239MODULE_DEVICE_TABLE(i2c, max34440_id); 348MODULE_DEVICE_TABLE(i2c, max34440_id);
240 349
241/* This is the driver that will be inserted */ 350/* This is the driver that will be inserted */
@@ -244,22 +353,12 @@ static struct i2c_driver max34440_driver = {
244 .name = "max34440", 353 .name = "max34440",
245 }, 354 },
246 .probe = max34440_probe, 355 .probe = max34440_probe,
247 .remove = max34440_remove, 356 .remove = pmbus_do_remove,
248 .id_table = max34440_id, 357 .id_table = max34440_id,
249}; 358};
250 359
251static int __init max34440_init(void) 360module_i2c_driver(max34440_driver);
252{
253 return i2c_add_driver(&max34440_driver);
254}
255
256static void __exit max34440_exit(void)
257{
258 i2c_del_driver(&max34440_driver);
259}
260 361
261MODULE_AUTHOR("Guenter Roeck"); 362MODULE_AUTHOR("Guenter Roeck");
262MODULE_DESCRIPTION("PMBus driver for Maxim MAX34440/MAX34441"); 363MODULE_DESCRIPTION("PMBus driver for Maxim MAX34440/MAX34441");
263MODULE_LICENSE("GPL"); 364MODULE_LICENSE("GPL");
264module_init(max34440_init);
265module_exit(max34440_exit);
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c
index e2b74bb399ba..f04454a42fdd 100644
--- a/drivers/hwmon/pmbus/max8688.c
+++ b/drivers/hwmon/pmbus/max8688.c
@@ -180,12 +180,6 @@ static int max8688_probe(struct i2c_client *client,
180 return pmbus_do_probe(client, id, &max8688_info); 180 return pmbus_do_probe(client, id, &max8688_info);
181} 181}
182 182
183static int max8688_remove(struct i2c_client *client)
184{
185 pmbus_do_remove(client);
186 return 0;
187}
188
189static const struct i2c_device_id max8688_id[] = { 183static const struct i2c_device_id max8688_id[] = {
190 {"max8688", 0}, 184 {"max8688", 0},
191 { } 185 { }
@@ -199,22 +193,12 @@ static struct i2c_driver max8688_driver = {
199 .name = "max8688", 193 .name = "max8688",
200 }, 194 },
201 .probe = max8688_probe, 195 .probe = max8688_probe,
202 .remove = max8688_remove, 196 .remove = pmbus_do_remove,
203 .id_table = max8688_id, 197 .id_table = max8688_id,
204}; 198};
205 199
206static int __init max8688_init(void) 200module_i2c_driver(max8688_driver);
207{
208 return i2c_add_driver(&max8688_driver);
209}
210
211static void __exit max8688_exit(void)
212{
213 i2c_del_driver(&max8688_driver);
214}
215 201
216MODULE_AUTHOR("Guenter Roeck"); 202MODULE_AUTHOR("Guenter Roeck");
217MODULE_DESCRIPTION("PMBus driver for Maxim MAX8688"); 203MODULE_DESCRIPTION("PMBus driver for Maxim MAX8688");
218MODULE_LICENSE("GPL"); 204MODULE_LICENSE("GPL");
219module_init(max8688_init);
220module_exit(max8688_exit);
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 18a385e753d7..7e91700131a7 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -166,33 +166,16 @@ static int pmbus_probe(struct i2c_client *client,
166 const struct i2c_device_id *id) 166 const struct i2c_device_id *id)
167{ 167{
168 struct pmbus_driver_info *info; 168 struct pmbus_driver_info *info;
169 int ret;
170 169
171 info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); 170 info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
171 GFP_KERNEL);
172 if (!info) 172 if (!info)
173 return -ENOMEM; 173 return -ENOMEM;
174 174
175 info->pages = id->driver_data; 175 info->pages = id->driver_data;
176 info->identify = pmbus_identify; 176 info->identify = pmbus_identify;
177 177
178 ret = pmbus_do_probe(client, id, info); 178 return pmbus_do_probe(client, id, info);
179 if (ret < 0)
180 goto out;
181 return 0;
182
183out:
184 kfree(info);
185 return ret;
186}
187
188static int pmbus_remove(struct i2c_client *client)
189{
190 const struct pmbus_driver_info *info;
191
192 info = pmbus_get_driver_info(client);
193 pmbus_do_remove(client);
194 kfree(info);
195 return 0;
196} 179}
197 180
198/* 181/*
@@ -202,12 +185,15 @@ static const struct i2c_device_id pmbus_id[] = {
202 {"adp4000", 1}, 185 {"adp4000", 1},
203 {"bmr453", 1}, 186 {"bmr453", 1},
204 {"bmr454", 1}, 187 {"bmr454", 1},
188 {"mdt040", 1},
205 {"ncp4200", 1}, 189 {"ncp4200", 1},
206 {"ncp4208", 1}, 190 {"ncp4208", 1},
207 {"pdt003", 1}, 191 {"pdt003", 1},
208 {"pdt006", 1}, 192 {"pdt006", 1},
209 {"pdt012", 1}, 193 {"pdt012", 1},
210 {"pmbus", 0}, 194 {"pmbus", 0},
195 {"tps40400", 1},
196 {"tps40422", 2},
211 {"udt020", 1}, 197 {"udt020", 1},
212 {} 198 {}
213}; 199};
@@ -220,22 +206,12 @@ static struct i2c_driver pmbus_driver = {
220 .name = "pmbus", 206 .name = "pmbus",
221 }, 207 },
222 .probe = pmbus_probe, 208 .probe = pmbus_probe,
223 .remove = pmbus_remove, 209 .remove = pmbus_do_remove,
224 .id_table = pmbus_id, 210 .id_table = pmbus_id,
225}; 211};
226 212
227static int __init pmbus_init(void) 213module_i2c_driver(pmbus_driver);
228{
229 return i2c_add_driver(&pmbus_driver);
230}
231
232static void __exit pmbus_exit(void)
233{
234 i2c_del_driver(&pmbus_driver);
235}
236 214
237MODULE_AUTHOR("Guenter Roeck"); 215MODULE_AUTHOR("Guenter Roeck");
238MODULE_DESCRIPTION("Generic PMBus driver"); 216MODULE_DESCRIPTION("Generic PMBus driver");
239MODULE_LICENSE("GPL"); 217MODULE_LICENSE("GPL");
240module_init(pmbus_init);
241module_exit(pmbus_exit);
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index 5d31d1c2c0f5..3fe03dc47eb7 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -146,31 +146,36 @@
146 * code when reading or writing virtual registers. 146 * code when reading or writing virtual registers.
147 */ 147 */
148#define PMBUS_VIRT_BASE 0x100 148#define PMBUS_VIRT_BASE 0x100
149#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 0) 149#define PMBUS_VIRT_READ_TEMP_AVG (PMBUS_VIRT_BASE + 0)
150#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 1) 150#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 1)
151#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 2) 151#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 2)
152#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 3) 152#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 3)
153#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 4) 153#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 4)
154#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 5) 154#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 5)
155#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 6) 155#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 6)
156#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 7) 156#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 7)
157#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 8) 157#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 8)
158#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 9) 158#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 9)
159#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 10) 159#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 10)
160#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 11) 160#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 11)
161#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 12) 161#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 12)
162#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 13) 162#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 13)
163#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 14) 163#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 14)
164#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 15) 164#define PMBUS_VIRT_READ_POUT_AVG (PMBUS_VIRT_BASE + 15)
165#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 16) 165#define PMBUS_VIRT_READ_POUT_MAX (PMBUS_VIRT_BASE + 16)
166#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 17) 166#define PMBUS_VIRT_RESET_POUT_HISTORY (PMBUS_VIRT_BASE + 17)
167#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 18) 167#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 18)
168#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 19) 168#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 19)
169#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 20) 169#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 20)
170#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 21) 170#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 21)
171#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 22) 171#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 22)
172#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 23) 172#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 23)
173#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 24) 173#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 24)
174#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 25)
175#define PMBUS_VIRT_READ_TEMP2_AVG (PMBUS_VIRT_BASE + 26)
176#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 27)
177#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 28)
178#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 29)
174 179
175/* 180/*
176 * CAPABILITY 181 * CAPABILITY
@@ -364,7 +369,7 @@ bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
364bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); 369bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
365int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 370int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
366 struct pmbus_driver_info *info); 371 struct pmbus_driver_info *info);
367void pmbus_do_remove(struct i2c_client *client); 372int pmbus_do_remove(struct i2c_client *client);
368const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client 373const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
369 *client); 374 *client);
370 375
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index d89b33967a85..be51037363c8 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -40,11 +40,14 @@
40#define PMBUS_IOUT_SENSORS_PER_PAGE 8 /* input, min, max, crit, 40#define PMBUS_IOUT_SENSORS_PER_PAGE 8 /* input, min, max, crit,
41 lowest, highest, avg, 41 lowest, highest, avg,
42 reset */ 42 reset */
43#define PMBUS_POUT_SENSORS_PER_PAGE 4 /* input, cap, max, crit */ 43#define PMBUS_POUT_SENSORS_PER_PAGE 7 /* input, cap, max, crit,
44 * highest, avg, reset
45 */
44#define PMBUS_MAX_SENSORS_PER_FAN 1 /* input */ 46#define PMBUS_MAX_SENSORS_PER_FAN 1 /* input */
45#define PMBUS_MAX_SENSORS_PER_TEMP 8 /* input, min, max, lcrit, 47#define PMBUS_MAX_SENSORS_PER_TEMP 9 /* input, min, max, lcrit,
46 crit, lowest, highest, 48 * crit, lowest, highest, avg,
47 reset */ 49 * reset
50 */
48 51
49#define PMBUS_MAX_INPUT_BOOLEANS 7 /* v: min_alarm, max_alarm, 52#define PMBUS_MAX_INPUT_BOOLEANS 7 /* v: min_alarm, max_alarm,
50 lcrit_alarm, crit_alarm; 53 lcrit_alarm, crit_alarm;
@@ -782,7 +785,7 @@ static ssize_t pmbus_set_sensor(struct device *dev,
782 int ret; 785 int ret;
783 u16 regval; 786 u16 regval;
784 787
785 if (strict_strtol(buf, 10, &val) < 0) 788 if (kstrtol(buf, 10, &val) < 0)
786 return -EINVAL; 789 return -EINVAL;
787 790
788 mutex_lock(&data->update_lock); 791 mutex_lock(&data->update_lock);
@@ -1334,6 +1337,17 @@ static const struct pmbus_limit_attr pout_limit_attrs[] = {
1334 .attr = "crit", 1337 .attr = "crit",
1335 .alarm = "crit_alarm", 1338 .alarm = "crit_alarm",
1336 .sbit = PB_POUT_OP_FAULT, 1339 .sbit = PB_POUT_OP_FAULT,
1340 }, {
1341 .reg = PMBUS_VIRT_READ_POUT_AVG,
1342 .update = true,
1343 .attr = "average",
1344 }, {
1345 .reg = PMBUS_VIRT_READ_POUT_MAX,
1346 .update = true,
1347 .attr = "input_highest",
1348 }, {
1349 .reg = PMBUS_VIRT_RESET_POUT_HISTORY,
1350 .attr = "reset_history",
1337 } 1351 }
1338}; 1352};
1339 1353
@@ -1389,6 +1403,9 @@ static const struct pmbus_limit_attr temp_limit_attrs[] = {
1389 .reg = PMBUS_VIRT_READ_TEMP_MIN, 1403 .reg = PMBUS_VIRT_READ_TEMP_MIN,
1390 .attr = "lowest", 1404 .attr = "lowest",
1391 }, { 1405 }, {
1406 .reg = PMBUS_VIRT_READ_TEMP_AVG,
1407 .attr = "average",
1408 }, {
1392 .reg = PMBUS_VIRT_READ_TEMP_MAX, 1409 .reg = PMBUS_VIRT_READ_TEMP_MAX,
1393 .attr = "highest", 1410 .attr = "highest",
1394 }, { 1411 }, {
@@ -1424,6 +1441,9 @@ static const struct pmbus_limit_attr temp_limit_attrs2[] = {
1424 .reg = PMBUS_VIRT_READ_TEMP2_MIN, 1441 .reg = PMBUS_VIRT_READ_TEMP2_MIN,
1425 .attr = "lowest", 1442 .attr = "lowest",
1426 }, { 1443 }, {
1444 .reg = PMBUS_VIRT_READ_TEMP2_AVG,
1445 .attr = "average",
1446 }, {
1427 .reg = PMBUS_VIRT_READ_TEMP2_MAX, 1447 .reg = PMBUS_VIRT_READ_TEMP2_MAX,
1428 .attr = "highest", 1448 .attr = "highest",
1429 }, { 1449 }, {
@@ -1676,7 +1696,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1676 | I2C_FUNC_SMBUS_WORD_DATA)) 1696 | I2C_FUNC_SMBUS_WORD_DATA))
1677 return -ENODEV; 1697 return -ENODEV;
1678 1698
1679 data = kzalloc(sizeof(*data), GFP_KERNEL); 1699 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
1680 if (!data) { 1700 if (!data) {
1681 dev_err(&client->dev, "No memory to allocate driver data\n"); 1701 dev_err(&client->dev, "No memory to allocate driver data\n");
1682 return -ENOMEM; 1702 return -ENOMEM;
@@ -1688,8 +1708,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1688 /* Bail out if PMBus status register does not exist. */ 1708 /* Bail out if PMBus status register does not exist. */
1689 if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) { 1709 if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
1690 dev_err(&client->dev, "PMBus status register not found\n"); 1710 dev_err(&client->dev, "PMBus status register not found\n");
1691 ret = -ENODEV; 1711 return -ENODEV;
1692 goto out_data;
1693 } 1712 }
1694 1713
1695 if (pdata) 1714 if (pdata)
@@ -1702,50 +1721,49 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1702 ret = (*info->identify)(client, info); 1721 ret = (*info->identify)(client, info);
1703 if (ret < 0) { 1722 if (ret < 0) {
1704 dev_err(&client->dev, "Chip identification failed\n"); 1723 dev_err(&client->dev, "Chip identification failed\n");
1705 goto out_data; 1724 return ret;
1706 } 1725 }
1707 } 1726 }
1708 1727
1709 if (info->pages <= 0 || info->pages > PMBUS_PAGES) { 1728 if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
1710 dev_err(&client->dev, "Bad number of PMBus pages: %d\n", 1729 dev_err(&client->dev, "Bad number of PMBus pages: %d\n",
1711 info->pages); 1730 info->pages);
1712 ret = -ENODEV; 1731 return -ENODEV;
1713 goto out_data;
1714 } 1732 }
1715 1733
1716 ret = pmbus_identify_common(client, data); 1734 ret = pmbus_identify_common(client, data);
1717 if (ret < 0) { 1735 if (ret < 0) {
1718 dev_err(&client->dev, "Failed to identify chip capabilities\n"); 1736 dev_err(&client->dev, "Failed to identify chip capabilities\n");
1719 goto out_data; 1737 return ret;
1720 } 1738 }
1721 1739
1722 ret = -ENOMEM; 1740 ret = -ENOMEM;
1723 data->sensors = kzalloc(sizeof(struct pmbus_sensor) * data->max_sensors, 1741 data->sensors = devm_kzalloc(&client->dev, sizeof(struct pmbus_sensor)
1724 GFP_KERNEL); 1742 * data->max_sensors, GFP_KERNEL);
1725 if (!data->sensors) { 1743 if (!data->sensors) {
1726 dev_err(&client->dev, "No memory to allocate sensor data\n"); 1744 dev_err(&client->dev, "No memory to allocate sensor data\n");
1727 goto out_data; 1745 return -ENOMEM;
1728 } 1746 }
1729 1747
1730 data->booleans = kzalloc(sizeof(struct pmbus_boolean) 1748 data->booleans = devm_kzalloc(&client->dev, sizeof(struct pmbus_boolean)
1731 * data->max_booleans, GFP_KERNEL); 1749 * data->max_booleans, GFP_KERNEL);
1732 if (!data->booleans) { 1750 if (!data->booleans) {
1733 dev_err(&client->dev, "No memory to allocate boolean data\n"); 1751 dev_err(&client->dev, "No memory to allocate boolean data\n");
1734 goto out_sensors; 1752 return -ENOMEM;
1735 } 1753 }
1736 1754
1737 data->labels = kzalloc(sizeof(struct pmbus_label) * data->max_labels, 1755 data->labels = devm_kzalloc(&client->dev, sizeof(struct pmbus_label)
1738 GFP_KERNEL); 1756 * data->max_labels, GFP_KERNEL);
1739 if (!data->labels) { 1757 if (!data->labels) {
1740 dev_err(&client->dev, "No memory to allocate label data\n"); 1758 dev_err(&client->dev, "No memory to allocate label data\n");
1741 goto out_booleans; 1759 return -ENOMEM;
1742 } 1760 }
1743 1761
1744 data->attributes = kzalloc(sizeof(struct attribute *) 1762 data->attributes = devm_kzalloc(&client->dev, sizeof(struct attribute *)
1745 * data->max_attributes, GFP_KERNEL); 1763 * data->max_attributes, GFP_KERNEL);
1746 if (!data->attributes) { 1764 if (!data->attributes) {
1747 dev_err(&client->dev, "No memory to allocate attribute data\n"); 1765 dev_err(&client->dev, "No memory to allocate attribute data\n");
1748 goto out_labels; 1766 return -ENOMEM;
1749 } 1767 }
1750 1768
1751 pmbus_find_attributes(client, data); 1769 pmbus_find_attributes(client, data);
@@ -1756,8 +1774,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1756 */ 1774 */
1757 if (!data->num_attributes) { 1775 if (!data->num_attributes) {
1758 dev_err(&client->dev, "No attributes found\n"); 1776 dev_err(&client->dev, "No attributes found\n");
1759 ret = -ENODEV; 1777 return -ENODEV;
1760 goto out_attributes;
1761 } 1778 }
1762 1779
1763 /* Register sysfs hooks */ 1780 /* Register sysfs hooks */
@@ -1765,7 +1782,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1765 ret = sysfs_create_group(&client->dev.kobj, &data->group); 1782 ret = sysfs_create_group(&client->dev.kobj, &data->group);
1766 if (ret) { 1783 if (ret) {
1767 dev_err(&client->dev, "Failed to create sysfs entries\n"); 1784 dev_err(&client->dev, "Failed to create sysfs entries\n");
1768 goto out_attributes; 1785 return ret;
1769 } 1786 }
1770 data->hwmon_dev = hwmon_device_register(&client->dev); 1787 data->hwmon_dev = hwmon_device_register(&client->dev);
1771 if (IS_ERR(data->hwmon_dev)) { 1788 if (IS_ERR(data->hwmon_dev)) {
@@ -1777,30 +1794,16 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1777 1794
1778out_hwmon_device_register: 1795out_hwmon_device_register:
1779 sysfs_remove_group(&client->dev.kobj, &data->group); 1796 sysfs_remove_group(&client->dev.kobj, &data->group);
1780out_attributes:
1781 kfree(data->attributes);
1782out_labels:
1783 kfree(data->labels);
1784out_booleans:
1785 kfree(data->booleans);
1786out_sensors:
1787 kfree(data->sensors);
1788out_data:
1789 kfree(data);
1790 return ret; 1797 return ret;
1791} 1798}
1792EXPORT_SYMBOL_GPL(pmbus_do_probe); 1799EXPORT_SYMBOL_GPL(pmbus_do_probe);
1793 1800
1794void pmbus_do_remove(struct i2c_client *client) 1801int pmbus_do_remove(struct i2c_client *client)
1795{ 1802{
1796 struct pmbus_data *data = i2c_get_clientdata(client); 1803 struct pmbus_data *data = i2c_get_clientdata(client);
1797 hwmon_device_unregister(data->hwmon_dev); 1804 hwmon_device_unregister(data->hwmon_dev);
1798 sysfs_remove_group(&client->dev.kobj, &data->group); 1805 sysfs_remove_group(&client->dev.kobj, &data->group);
1799 kfree(data->attributes); 1806 return 0;
1800 kfree(data->labels);
1801 kfree(data->booleans);
1802 kfree(data->sensors);
1803 kfree(data);
1804} 1807}
1805EXPORT_SYMBOL_GPL(pmbus_do_remove); 1808EXPORT_SYMBOL_GPL(pmbus_do_remove);
1806 1809
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index 4ff6cf289f85..fbb1479d3ad4 100644
--- a/drivers/hwmon/pmbus/ucd9000.c
+++ b/drivers/hwmon/pmbus/ucd9000.c
@@ -155,7 +155,8 @@ static int ucd9000_probe(struct i2c_client *client,
155 "Device mismatch: Configured %s, detected %s\n", 155 "Device mismatch: Configured %s, detected %s\n",
156 id->name, mid->name); 156 id->name, mid->name);
157 157
158 data = kzalloc(sizeof(struct ucd9000_data), GFP_KERNEL); 158 data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data),
159 GFP_KERNEL);
159 if (!data) 160 if (!data)
160 return -ENOMEM; 161 return -ENOMEM;
161 info = &data->info; 162 info = &data->info;
@@ -164,13 +165,12 @@ static int ucd9000_probe(struct i2c_client *client,
164 if (ret < 0) { 165 if (ret < 0) {
165 dev_err(&client->dev, 166 dev_err(&client->dev,
166 "Failed to read number of active pages\n"); 167 "Failed to read number of active pages\n");
167 goto out; 168 return ret;
168 } 169 }
169 info->pages = ret; 170 info->pages = ret;
170 if (!info->pages) { 171 if (!info->pages) {
171 dev_err(&client->dev, "No pages configured\n"); 172 dev_err(&client->dev, "No pages configured\n");
172 ret = -ENODEV; 173 return -ENODEV;
173 goto out;
174 } 174 }
175 175
176 /* The internal temperature sensor is always active */ 176 /* The internal temperature sensor is always active */
@@ -181,8 +181,7 @@ static int ucd9000_probe(struct i2c_client *client,
181 block_buffer); 181 block_buffer);
182 if (ret <= 0) { 182 if (ret <= 0) {
183 dev_err(&client->dev, "Failed to read configuration data\n"); 183 dev_err(&client->dev, "Failed to read configuration data\n");
184 ret = -ENODEV; 184 return -ENODEV;
185 goto out;
186 } 185 }
187 for (i = 0; i < ret; i++) { 186 for (i = 0; i < ret; i++) {
188 int page = UCD9000_MON_PAGE(block_buffer[i]); 187 int page = UCD9000_MON_PAGE(block_buffer[i]);
@@ -218,7 +217,7 @@ static int ucd9000_probe(struct i2c_client *client,
218 UCD9000_FAN_CONFIG, 217 UCD9000_FAN_CONFIG,
219 data->fan_data[i]); 218 data->fan_data[i]);
220 if (ret < 0) 219 if (ret < 0)
221 goto out; 220 return ret;
222 } 221 }
223 i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0); 222 i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0);
224 223
@@ -227,49 +226,21 @@ static int ucd9000_probe(struct i2c_client *client,
227 | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34; 226 | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34;
228 } 227 }
229 228
230 ret = pmbus_do_probe(client, mid, info); 229 return pmbus_do_probe(client, mid, info);
231 if (ret < 0)
232 goto out;
233 return 0;
234
235out:
236 kfree(data);
237 return ret;
238}
239
240static int ucd9000_remove(struct i2c_client *client)
241{
242 struct ucd9000_data *data;
243
244 data = to_ucd9000_data(pmbus_get_driver_info(client));
245 pmbus_do_remove(client);
246 kfree(data);
247 return 0;
248} 230}
249 231
250
251/* This is the driver that will be inserted */ 232/* This is the driver that will be inserted */
252static struct i2c_driver ucd9000_driver = { 233static struct i2c_driver ucd9000_driver = {
253 .driver = { 234 .driver = {
254 .name = "ucd9000", 235 .name = "ucd9000",
255 }, 236 },
256 .probe = ucd9000_probe, 237 .probe = ucd9000_probe,
257 .remove = ucd9000_remove, 238 .remove = pmbus_do_remove,
258 .id_table = ucd9000_id, 239 .id_table = ucd9000_id,
259}; 240};
260 241
261static int __init ucd9000_init(void) 242module_i2c_driver(ucd9000_driver);
262{
263 return i2c_add_driver(&ucd9000_driver);
264}
265
266static void __exit ucd9000_exit(void)
267{
268 i2c_del_driver(&ucd9000_driver);
269}
270 243
271MODULE_AUTHOR("Guenter Roeck"); 244MODULE_AUTHOR("Guenter Roeck");
272MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx"); 245MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx");
273MODULE_LICENSE("GPL"); 246MODULE_LICENSE("GPL");
274module_init(ucd9000_init);
275module_exit(ucd9000_exit);
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c
index 6e1c1a80ab85..033d6aca47d3 100644
--- a/drivers/hwmon/pmbus/ucd9200.c
+++ b/drivers/hwmon/pmbus/ucd9200.c
@@ -81,7 +81,8 @@ static int ucd9200_probe(struct i2c_client *client,
81 "Device mismatch: Configured %s, detected %s\n", 81 "Device mismatch: Configured %s, detected %s\n",
82 id->name, mid->name); 82 id->name, mid->name);
83 83
84 info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); 84 info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
85 GFP_KERNEL);
85 if (!info) 86 if (!info)
86 return -ENOMEM; 87 return -ENOMEM;
87 88
@@ -89,7 +90,7 @@ static int ucd9200_probe(struct i2c_client *client,
89 block_buffer); 90 block_buffer);
90 if (ret < 0) { 91 if (ret < 0) {
91 dev_err(&client->dev, "Failed to read phase information\n"); 92 dev_err(&client->dev, "Failed to read phase information\n");
92 goto out; 93 return ret;
93 } 94 }
94 95
95 /* 96 /*
@@ -106,8 +107,7 @@ static int ucd9200_probe(struct i2c_client *client,
106 } 107 }
107 if (!info->pages) { 108 if (!info->pages) {
108 dev_err(&client->dev, "No rails configured\n"); 109 dev_err(&client->dev, "No rails configured\n");
109 ret = -ENODEV; 110 return -ENODEV;
110 goto out;
111 } 111 }
112 dev_info(&client->dev, "%d rails configured\n", info->pages); 112 dev_info(&client->dev, "%d rails configured\n", info->pages);
113 113
@@ -137,7 +137,7 @@ static int ucd9200_probe(struct i2c_client *client,
137 if (ret < 0) { 137 if (ret < 0) {
138 dev_err(&client->dev, 138 dev_err(&client->dev,
139 "Failed to initialize PHASE registers\n"); 139 "Failed to initialize PHASE registers\n");
140 goto out; 140 return ret;
141 } 141 }
142 } 142 }
143 if (info->pages > 1) 143 if (info->pages > 1)
@@ -160,48 +160,21 @@ static int ucd9200_probe(struct i2c_client *client,
160 if (mid->driver_data == ucd9240) 160 if (mid->driver_data == ucd9240)
161 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; 161 info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12;
162 162
163 ret = pmbus_do_probe(client, mid, info); 163 return pmbus_do_probe(client, mid, info);
164 if (ret < 0)
165 goto out;
166 return 0;
167out:
168 kfree(info);
169 return ret;
170}
171
172static int ucd9200_remove(struct i2c_client *client)
173{
174 const struct pmbus_driver_info *info;
175
176 info = pmbus_get_driver_info(client);
177 pmbus_do_remove(client);
178 kfree(info);
179 return 0;
180} 164}
181 165
182
183/* This is the driver that will be inserted */ 166/* This is the driver that will be inserted */
184static struct i2c_driver ucd9200_driver = { 167static struct i2c_driver ucd9200_driver = {
185 .driver = { 168 .driver = {
186 .name = "ucd9200", 169 .name = "ucd9200",
187 }, 170 },
188 .probe = ucd9200_probe, 171 .probe = ucd9200_probe,
189 .remove = ucd9200_remove, 172 .remove = pmbus_do_remove,
190 .id_table = ucd9200_id, 173 .id_table = ucd9200_id,
191}; 174};
192 175
193static int __init ucd9200_init(void) 176module_i2c_driver(ucd9200_driver);
194{
195 return i2c_add_driver(&ucd9200_driver);
196}
197
198static void __exit ucd9200_exit(void)
199{
200 i2c_del_driver(&ucd9200_driver);
201}
202 177
203MODULE_AUTHOR("Guenter Roeck"); 178MODULE_AUTHOR("Guenter Roeck");
204MODULE_DESCRIPTION("PMBus driver for TI UCD922x, UCD924x"); 179MODULE_DESCRIPTION("PMBus driver for TI UCD922x, UCD924x");
205MODULE_LICENSE("GPL"); 180MODULE_LICENSE("GPL");
206module_init(ucd9200_init);
207module_exit(ucd9200_exit);
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c
index e3e8420b7b81..fc5eed8e85bb 100644
--- a/drivers/hwmon/pmbus/zl6100.c
+++ b/drivers/hwmon/pmbus/zl6100.c
@@ -28,7 +28,8 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include "pmbus.h" 29#include "pmbus.h"
30 30
31enum chips { zl2004, zl2005, zl2006, zl2008, zl2105, zl2106, zl6100, zl6105 }; 31enum chips { zl2004, zl2005, zl2006, zl2008, zl2105, zl2106, zl6100, zl6105,
32 zl9101, zl9117 };
32 33
33struct zl6100_data { 34struct zl6100_data {
34 int id; 35 int id;
@@ -152,6 +153,8 @@ static const struct i2c_device_id zl6100_id[] = {
152 {"zl2106", zl2106}, 153 {"zl2106", zl2106},
153 {"zl6100", zl6100}, 154 {"zl6100", zl6100},
154 {"zl6105", zl6105}, 155 {"zl6105", zl6105},
156 {"zl9101", zl9101},
157 {"zl9117", zl9117},
155 { } 158 { }
156}; 159};
157MODULE_DEVICE_TABLE(i2c, zl6100_id); 160MODULE_DEVICE_TABLE(i2c, zl6100_id);
@@ -193,7 +196,8 @@ static int zl6100_probe(struct i2c_client *client,
193 "Device mismatch: Configured %s, detected %s\n", 196 "Device mismatch: Configured %s, detected %s\n",
194 id->name, mid->name); 197 id->name, mid->name);
195 198
196 data = kzalloc(sizeof(struct zl6100_data), GFP_KERNEL); 199 data = devm_kzalloc(&client->dev, sizeof(struct zl6100_data),
200 GFP_KERNEL);
197 if (!data) 201 if (!data)
198 return -ENOMEM; 202 return -ENOMEM;
199 203
@@ -223,7 +227,8 @@ static int zl6100_probe(struct i2c_client *client,
223 227
224 ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG); 228 ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG);
225 if (ret < 0) 229 if (ret < 0)
226 goto err_mem; 230 return ret;
231
227 if (ret & ZL6100_MFR_XTEMP_ENABLE) 232 if (ret & ZL6100_MFR_XTEMP_ENABLE)
228 info->func[0] |= PMBUS_HAVE_TEMP2; 233 info->func[0] |= PMBUS_HAVE_TEMP2;
229 234
@@ -235,24 +240,7 @@ static int zl6100_probe(struct i2c_client *client,
235 info->write_word_data = zl6100_write_word_data; 240 info->write_word_data = zl6100_write_word_data;
236 info->write_byte = zl6100_write_byte; 241 info->write_byte = zl6100_write_byte;
237 242
238 ret = pmbus_do_probe(client, mid, info); 243 return pmbus_do_probe(client, mid, info);
239 if (ret)
240 goto err_mem;
241 return 0;
242
243err_mem:
244 kfree(data);
245 return ret;
246}
247
248static int zl6100_remove(struct i2c_client *client)
249{
250 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
251 const struct zl6100_data *data = to_zl6100_data(info);
252
253 pmbus_do_remove(client);
254 kfree(data);
255 return 0;
256} 244}
257 245
258static struct i2c_driver zl6100_driver = { 246static struct i2c_driver zl6100_driver = {
@@ -260,22 +248,12 @@ static struct i2c_driver zl6100_driver = {
260 .name = "zl6100", 248 .name = "zl6100",
261 }, 249 },
262 .probe = zl6100_probe, 250 .probe = zl6100_probe,
263 .remove = zl6100_remove, 251 .remove = pmbus_do_remove,
264 .id_table = zl6100_id, 252 .id_table = zl6100_id,
265}; 253};
266 254
267static int __init zl6100_init(void) 255module_i2c_driver(zl6100_driver);
268{
269 return i2c_add_driver(&zl6100_driver);
270}
271
272static void __exit zl6100_exit(void)
273{
274 i2c_del_driver(&zl6100_driver);
275}
276 256
277MODULE_AUTHOR("Guenter Roeck"); 257MODULE_AUTHOR("Guenter Roeck");
278MODULE_DESCRIPTION("PMBus driver for ZL6100 and compatibles"); 258MODULE_DESCRIPTION("PMBus driver for ZL6100 and compatibles");
279MODULE_LICENSE("GPL"); 259MODULE_LICENSE("GPL");
280module_init(zl6100_init);
281module_exit(zl6100_exit);