summaryrefslogtreecommitdiffstats
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.c56
13 files changed, 354 insertions, 392 deletions
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index cfec923f42b..2ca6a5a4f5a 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -20,7 +20,8 @@ config SENSORS_PMBUS
help
If you say yes here you get hardware monitoring support for generic
PMBus devices, including but not limited to ADP4000, BMR453, BMR454,
- NCP4200, and NCP4208.
+ MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012, UDT020, TPS40400,
+ and TPS40422.
This driver can also be built as a module. If so, the module will
be called pmbus.
@@ -30,8 +31,8 @@ config SENSORS_ADM1275
default n
help
If you say yes here you get hardware monitoring support for Analog
- Devices ADM1275 and ADM1276 Hot-Swap Controller and Digital Power
- Monitor.
+ Devices ADM1075, ADM1275, and ADM1276 Hot-Swap Controller and Digital
+ Power Monitors.
This driver can also be built as a module. If so, the module will
be called adm1275.
@@ -67,11 +68,11 @@ config SENSORS_MAX16064
be called max16064.
config SENSORS_MAX34440
- tristate "Maxim MAX34440/MAX34441"
+ tristate "Maxim MAX34440 and compatibles"
default n
help
If you say yes here you get hardware monitoring support for Maxim
- MAX34440 and MAX34441.
+ MAX34440, MAX34441, and MAX34446.
This driver can also be built as a module. If so, the module will
be called max34440.
@@ -113,9 +114,9 @@ config SENSORS_ZL6100
default n
help
If you say yes here you get hardware monitoring support for Intersil
- ZL2004, ZL2005, ZL2006, ZL2008, ZL2105, ZL2106, ZL6100, and ZL6105
- Digital DC/DC Controllers, as well as for Ericsson BMR450, BMR451,
- BMR462, BMR463, and BMR464.
+ ZL2004, ZL2005, ZL2006, ZL2008, ZL2105, ZL2106, ZL6100, ZL6105,
+ ZL9101M, and ZL9117M Digital DC/DC Controllers, as well as for
+ Ericsson BMR450, BMR451, BMR462, BMR463, and BMR464.
This driver can also be built as a module. If so, the module will
be called zl6100.
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 81c7c2ead6f..60aad9570f0 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -23,7 +23,7 @@
#include <linux/i2c.h>
#include "pmbus.h"
-enum chips { adm1275, adm1276 };
+enum chips { adm1075, adm1275, adm1276 };
#define ADM1275_PEAK_IOUT 0xd0
#define ADM1275_PEAK_VIN 0xd1
@@ -32,6 +32,9 @@ enum chips { adm1275, adm1276 };
#define ADM1275_VIN_VOUT_SELECT (1 << 6)
#define ADM1275_VRANGE (1 << 5)
+#define ADM1075_IRANGE_50 (1 << 4)
+#define ADM1075_IRANGE_25 (1 << 3)
+#define ADM1075_IRANGE_MASK ((1 << 3) | (1 << 4))
#define ADM1275_IOUT_WARN2_LIMIT 0xd7
#define ADM1275_DEVICE_CONFIG 0xd8
@@ -42,6 +45,14 @@ enum chips { adm1275, adm1276 };
#define ADM1275_MFR_STATUS_IOUT_WARN2 (1 << 0)
+#define ADM1075_READ_VAUX 0xdd
+#define ADM1075_VAUX_OV_WARN_LIMIT 0xde
+#define ADM1075_VAUX_UV_WARN_LIMIT 0xdf
+#define ADM1075_VAUX_STATUS 0xf6
+
+#define ADM1075_VAUX_OV_WARN (1<<7)
+#define ADM1075_VAUX_UV_WARN (1<<6)
+
struct adm1275_data {
int id;
bool have_oc_fault;
@@ -74,6 +85,29 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
}
ret = pmbus_read_word_data(client, 0, ADM1275_IOUT_WARN2_LIMIT);
break;
+ case PMBUS_VOUT_OV_WARN_LIMIT:
+ if (data->id != adm1075) {
+ ret = -ENODATA;
+ break;
+ }
+ ret = pmbus_read_word_data(client, 0,
+ ADM1075_VAUX_OV_WARN_LIMIT);
+ break;
+ case PMBUS_VOUT_UV_WARN_LIMIT:
+ if (data->id != adm1075) {
+ ret = -ENODATA;
+ break;
+ }
+ ret = pmbus_read_word_data(client, 0,
+ ADM1075_VAUX_UV_WARN_LIMIT);
+ break;
+ case PMBUS_READ_VOUT:
+ if (data->id != adm1075) {
+ ret = -ENODATA;
+ break;
+ }
+ ret = pmbus_read_word_data(client, 0, ADM1075_READ_VAUX);
+ break;
case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_IOUT);
break;
@@ -84,7 +118,7 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN);
break;
case PMBUS_VIRT_READ_PIN_MAX:
- if (data->id != adm1276) {
+ if (data->id == adm1275) {
ret = -ENXIO;
break;
}
@@ -95,7 +129,7 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
case PMBUS_VIRT_RESET_VIN_HISTORY:
break;
case PMBUS_VIRT_RESET_PIN_HISTORY:
- if (data->id != adm1276)
+ if (data->id == adm1275)
ret = -ENXIO;
break;
default:
@@ -163,6 +197,19 @@ static int adm1275_read_byte_data(struct i2c_client *client, int page, int reg)
PB_IOUT_OC_FAULT : PB_IOUT_UC_FAULT;
}
break;
+ case PMBUS_STATUS_VOUT:
+ if (data->id != adm1075) {
+ ret = -ENODATA;
+ break;
+ }
+ ret = 0;
+ mfr_status = pmbus_read_byte_data(client, 0,
+ ADM1075_VAUX_STATUS);
+ if (mfr_status & ADM1075_VAUX_OV_WARN)
+ ret |= PB_VOLTAGE_OV_WARNING;
+ if (mfr_status & ADM1075_VAUX_UV_WARN)
+ ret |= PB_VOLTAGE_UV_WARNING;
+ break;
default:
ret = -ENODATA;
break;
@@ -171,6 +218,7 @@ static int adm1275_read_byte_data(struct i2c_client *client, int page, int reg)
}
static const struct i2c_device_id adm1275_id[] = {
+ { "adm1075", adm1075 },
{ "adm1275", adm1275 },
{ "adm1276", adm1276 },
{ }
@@ -229,7 +277,8 @@ static int adm1275_probe(struct i2c_client *client,
if (device_config < 0)
return device_config;
- data = kzalloc(sizeof(struct adm1275_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -250,7 +299,14 @@ static int adm1275_probe(struct i2c_client *client,
info->read_byte_data = adm1275_read_byte_data;
info->write_word_data = adm1275_write_word_data;
- if (config & ADM1275_VRANGE) {
+ if (data->id == adm1075) {
+ info->m[PSC_VOLTAGE_IN] = 27169;
+ info->b[PSC_VOLTAGE_IN] = 0;
+ info->R[PSC_VOLTAGE_IN] = -1;
+ info->m[PSC_VOLTAGE_OUT] = 27169;
+ info->b[PSC_VOLTAGE_OUT] = 0;
+ info->R[PSC_VOLTAGE_OUT] = -1;
+ } else if (config & ADM1275_VRANGE) {
info->m[PSC_VOLTAGE_IN] = 19199;
info->b[PSC_VOLTAGE_IN] = 0;
info->R[PSC_VOLTAGE_IN] = -2;
@@ -270,6 +326,31 @@ static int adm1275_probe(struct i2c_client *client,
data->have_oc_fault = true;
switch (data->id) {
+ case adm1075:
+ info->format[PSC_POWER] = direct;
+ info->b[PSC_POWER] = 0;
+ info->R[PSC_POWER] = -1;
+ switch (config & ADM1075_IRANGE_MASK) {
+ case ADM1075_IRANGE_25:
+ info->m[PSC_POWER] = 8549;
+ info->m[PSC_CURRENT_OUT] = 806;
+ break;
+ case ADM1075_IRANGE_50:
+ info->m[PSC_POWER] = 4279;
+ info->m[PSC_CURRENT_OUT] = 404;
+ break;
+ default:
+ dev_err(&client->dev, "Invalid input current range");
+ info->m[PSC_POWER] = 0;
+ info->m[PSC_CURRENT_OUT] = 0;
+ break;
+ }
+ info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN
+ | PMBUS_HAVE_STATUS_INPUT;
+ if (config & ADM1275_VIN_VOUT_SELECT)
+ info->func[0] |=
+ PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT;
+ break;
case adm1275:
if (config & ADM1275_VIN_VOUT_SELECT)
info->func[0] |=
@@ -297,24 +378,7 @@ static int adm1275_probe(struct i2c_client *client,
break;
}
- ret = pmbus_do_probe(client, id, info);
- if (ret)
- goto err_mem;
- return 0;
-
-err_mem:
- kfree(data);
- return ret;
-}
-
-static int adm1275_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct adm1275_data *data = to_adm1275_data(info);
-
- pmbus_do_remove(client);
- kfree(data);
- return 0;
+ return pmbus_do_probe(client, id, info);
}
static struct i2c_driver adm1275_driver = {
@@ -322,22 +386,12 @@ static struct i2c_driver adm1275_driver = {
.name = "adm1275",
},
.probe = adm1275_probe,
- .remove = adm1275_remove,
+ .remove = pmbus_do_remove,
.id_table = adm1275_id,
};
-static int __init adm1275_init(void)
-{
- return i2c_add_driver(&adm1275_driver);
-}
-
-static void __exit adm1275_exit(void)
-{
- i2c_del_driver(&adm1275_driver);
-}
+module_i2c_driver(adm1275_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275 and compatibles");
MODULE_LICENSE("GPL");
-module_init(adm1275_init);
-module_exit(adm1275_exit);
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 84a37f0c8db..c299392716a 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,
const struct i2c_device_id *id)
{
int config;
- int ret;
struct lm25066_data *data;
struct pmbus_driver_info *info;
@@ -184,15 +183,14 @@ static int lm25066_probe(struct i2c_client *client,
I2C_FUNC_SMBUS_READ_BYTE_DATA))
return -ENODEV;
- data = kzalloc(sizeof(struct lm25066_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct lm25066_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP);
- if (config < 0) {
- ret = config;
- goto err_mem;
- }
+ if (config < 0)
+ return config;
data->id = id->driver_data;
info = &data->info;
@@ -291,28 +289,10 @@ static int lm25066_probe(struct i2c_client *client,
}
break;
default:
- ret = -ENODEV;
- goto err_mem;
+ return -ENODEV;
}
- ret = pmbus_do_probe(client, id, info);
- if (ret)
- goto err_mem;
- return 0;
-
-err_mem:
- kfree(data);
- return ret;
-}
-
-static int lm25066_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct lm25066_data *data = to_lm25066_data(info);
-
- pmbus_do_remove(client);
- kfree(data);
- return 0;
+ return pmbus_do_probe(client, id, info);
}
static const struct i2c_device_id lm25066_id[] = {
@@ -330,22 +310,12 @@ static struct i2c_driver lm25066_driver = {
.name = "lm25066",
},
.probe = lm25066_probe,
- .remove = lm25066_remove,
+ .remove = pmbus_do_remove,
.id_table = lm25066_id,
};
-static int __init lm25066_init(void)
-{
- return i2c_add_driver(&lm25066_driver);
-}
-
-static void __exit lm25066_exit(void)
-{
- i2c_del_driver(&lm25066_driver);
-}
+module_i2c_driver(lm25066_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for LM25066/LM5064/LM5066");
MODULE_LICENSE("GPL");
-module_init(lm25066_init);
-module_exit(lm25066_exit);
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index 820fff48910..9652a2c92a2 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -287,7 +287,7 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id);
static int ltc2978_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- int chip_id, ret, i;
+ int chip_id, i;
struct ltc2978_data *data;
struct pmbus_driver_info *info;
@@ -295,15 +295,14 @@ static int ltc2978_probe(struct i2c_client *client,
I2C_FUNC_SMBUS_READ_WORD_DATA))
return -ENODEV;
- data = kzalloc(sizeof(struct ltc2978_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID);
- if (chip_id < 0) {
- ret = chip_id;
- goto err_mem;
- }
+ if (chip_id < 0)
+ return chip_id;
if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) {
data->id = ltc2978;
@@ -311,8 +310,7 @@ static int ltc2978_probe(struct i2c_client *client,
data->id = ltc3880;
} else {
dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id);
- ret = -ENODEV;
- goto err_mem;
+ return -ENODEV;
}
if (data->id != id->driver_data)
dev_warn(&client->dev,
@@ -357,28 +355,10 @@ static int ltc2978_probe(struct i2c_client *client,
data->vout_min[1] = 0xffff;
break;
default:
- ret = -ENODEV;
- goto err_mem;
+ return -ENODEV;
}
- ret = pmbus_do_probe(client, id, info);
- if (ret)
- goto err_mem;
- return 0;
-
-err_mem:
- kfree(data);
- return ret;
-}
-
-static int ltc2978_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct ltc2978_data *data = to_ltc2978_data(info);
-
- pmbus_do_remove(client);
- kfree(data);
- return 0;
+ return pmbus_do_probe(client, id, info);
}
/* This is the driver that will be inserted */
@@ -387,22 +367,12 @@ static struct i2c_driver ltc2978_driver = {
.name = "ltc2978",
},
.probe = ltc2978_probe,
- .remove = ltc2978_remove,
+ .remove = pmbus_do_remove,
.id_table = ltc2978_id,
};
-static int __init ltc2978_init(void)
-{
- return i2c_add_driver(&ltc2978_driver);
-}
-
-static void __exit ltc2978_exit(void)
-{
- i2c_del_driver(&ltc2978_driver);
-}
+module_i2c_driver(ltc2978_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for LTC2978 and LTC3880");
MODULE_LICENSE("GPL");
-module_init(ltc2978_init);
-module_exit(ltc2978_exit);
diff --git a/drivers/hwmon/pmbus/max16064.c b/drivers/hwmon/pmbus/max16064.c
index 1d77cf4d2d4..fa237a3c329 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,
return pmbus_do_probe(client, id, &max16064_info);
}
-static int max16064_remove(struct i2c_client *client)
-{
- pmbus_do_remove(client);
- return 0;
-}
-
static const struct i2c_device_id max16064_id[] = {
{"max16064", 0},
{}
@@ -122,22 +116,12 @@ static struct i2c_driver max16064_driver = {
.name = "max16064",
},
.probe = max16064_probe,
- .remove = max16064_remove,
+ .remove = pmbus_do_remove,
.id_table = max16064_id,
};
-static int __init max16064_init(void)
-{
- return i2c_add_driver(&max16064_driver);
-}
-
-static void __exit max16064_exit(void)
-{
- i2c_del_driver(&max16064_driver);
-}
+module_i2c_driver(max16064_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
MODULE_LICENSE("GPL");
-module_init(max16064_init);
-module_exit(max16064_exit);
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c
index 9b97a5b3cf3..2ada7b021fb 100644
--- a/drivers/hwmon/pmbus/max34440.c
+++ b/drivers/hwmon/pmbus/max34440.c
@@ -25,34 +25,82 @@
#include <linux/i2c.h>
#include "pmbus.h"
-enum chips { max34440, max34441 };
+enum chips { max34440, max34441, max34446 };
#define MAX34440_MFR_VOUT_PEAK 0xd4
#define MAX34440_MFR_IOUT_PEAK 0xd5
#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
+#define MAX34440_MFR_VOUT_MIN 0xd7
+
+#define MAX34446_MFR_POUT_PEAK 0xe0
+#define MAX34446_MFR_POUT_AVG 0xe1
+#define MAX34446_MFR_IOUT_AVG 0xe2
+#define MAX34446_MFR_TEMPERATURE_AVG 0xe3
#define MAX34440_STATUS_OC_WARN (1 << 0)
#define MAX34440_STATUS_OC_FAULT (1 << 1)
#define MAX34440_STATUS_OT_FAULT (1 << 5)
#define MAX34440_STATUS_OT_WARN (1 << 6)
+struct max34440_data {
+ int id;
+ struct pmbus_driver_info info;
+};
+
+#define to_max34440_data(x) container_of(x, struct max34440_data, info)
+
static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
{
int ret;
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+ const struct max34440_data *data = to_max34440_data(info);
switch (reg) {
+ case PMBUS_VIRT_READ_VOUT_MIN:
+ ret = pmbus_read_word_data(client, page,
+ MAX34440_MFR_VOUT_MIN);
+ break;
case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page,
MAX34440_MFR_VOUT_PEAK);
break;
+ case PMBUS_VIRT_READ_IOUT_AVG:
+ if (data->id != max34446)
+ return -ENXIO;
+ ret = pmbus_read_word_data(client, page,
+ MAX34446_MFR_IOUT_AVG);
+ break;
case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, page,
MAX34440_MFR_IOUT_PEAK);
break;
+ case PMBUS_VIRT_READ_POUT_AVG:
+ if (data->id != max34446)
+ return -ENXIO;
+ ret = pmbus_read_word_data(client, page,
+ MAX34446_MFR_POUT_AVG);
+ break;
+ case PMBUS_VIRT_READ_POUT_MAX:
+ if (data->id != max34446)
+ return -ENXIO;
+ ret = pmbus_read_word_data(client, page,
+ MAX34446_MFR_POUT_PEAK);
+ break;
+ case PMBUS_VIRT_READ_TEMP_AVG:
+ if (data->id != max34446)
+ return -ENXIO;
+ ret = pmbus_read_word_data(client, page,
+ MAX34446_MFR_TEMPERATURE_AVG);
+ break;
case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page,
MAX34440_MFR_TEMPERATURE_PEAK);
break;
+ case PMBUS_VIRT_RESET_POUT_HISTORY:
+ if (data->id != max34446)
+ return -ENXIO;
+ ret = 0;
+ break;
case PMBUS_VIRT_RESET_VOUT_HISTORY:
case PMBUS_VIRT_RESET_IOUT_HISTORY:
case PMBUS_VIRT_RESET_TEMP_HISTORY:
@@ -68,21 +116,42 @@ static int max34440_read_word_data(struct i2c_client *client, int page, int reg)
static int max34440_write_word_data(struct i2c_client *client, int page,
int reg, u16 word)
{
+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
+ const struct max34440_data *data = to_max34440_data(info);
int ret;
switch (reg) {
+ case PMBUS_VIRT_RESET_POUT_HISTORY:
+ ret = pmbus_write_word_data(client, page,
+ MAX34446_MFR_POUT_PEAK, 0);
+ if (ret)
+ break;
+ ret = pmbus_write_word_data(client, page,
+ MAX34446_MFR_POUT_AVG, 0);
+ break;
case PMBUS_VIRT_RESET_VOUT_HISTORY:
ret = pmbus_write_word_data(client, page,
+ MAX34440_MFR_VOUT_MIN, 0x7fff);
+ if (ret)
+ break;
+ ret = pmbus_write_word_data(client, page,
MAX34440_MFR_VOUT_PEAK, 0);
break;
case PMBUS_VIRT_RESET_IOUT_HISTORY:
ret = pmbus_write_word_data(client, page,
MAX34440_MFR_IOUT_PEAK, 0);
+ if (!ret && data->id == max34446)
+ ret = pmbus_write_word_data(client, page,
+ MAX34446_MFR_IOUT_AVG, 0);
+
break;
case PMBUS_VIRT_RESET_TEMP_HISTORY:
ret = pmbus_write_word_data(client, page,
MAX34440_MFR_TEMPERATURE_PEAK,
0x8000);
+ if (!ret && data->id == max34446)
+ ret = pmbus_write_word_data(client, page,
+ MAX34446_MFR_TEMPERATURE_AVG, 0);
break;
default:
ret = -ENODATA;
@@ -216,26 +285,66 @@ static struct pmbus_driver_info max34440_info[] = {
.read_word_data = max34440_read_word_data,
.write_word_data = max34440_write_word_data,
},
+ [max34446] = {
+ .pages = 7,
+ .format[PSC_VOLTAGE_IN] = direct,
+ .format[PSC_VOLTAGE_OUT] = direct,
+ .format[PSC_TEMPERATURE] = direct,
+ .format[PSC_CURRENT_OUT] = direct,
+ .format[PSC_POWER] = direct,
+ .m[PSC_VOLTAGE_IN] = 1,
+ .b[PSC_VOLTAGE_IN] = 0,
+ .R[PSC_VOLTAGE_IN] = 3,
+ .m[PSC_VOLTAGE_OUT] = 1,
+ .b[PSC_VOLTAGE_OUT] = 0,
+ .R[PSC_VOLTAGE_OUT] = 3,
+ .m[PSC_CURRENT_OUT] = 1,
+ .b[PSC_CURRENT_OUT] = 0,
+ .R[PSC_CURRENT_OUT] = 3,
+ .m[PSC_POWER] = 1,
+ .b[PSC_POWER] = 0,
+ .R[PSC_POWER] = 3,
+ .m[PSC_TEMPERATURE] = 1,
+ .b[PSC_TEMPERATURE] = 0,
+ .R[PSC_TEMPERATURE] = 2,
+ .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+ | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
+ .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+ | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+ .func[2] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+ | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
+ .func[3] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+ | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT,
+ .func[4] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+ .func[5] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+ .func[6] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+ .read_byte_data = max34440_read_byte_data,
+ .read_word_data = max34440_read_word_data,
+ .write_word_data = max34440_write_word_data,
+ },
};
static int max34440_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- return pmbus_do_probe(client, id, &max34440_info[id->driver_data]);
-}
+ struct max34440_data *data;
-static int max34440_remove(struct i2c_client *client)
-{
- pmbus_do_remove(client);
- return 0;
+ data = devm_kzalloc(&client->dev, sizeof(struct max34440_data),
+ GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+ data->id = id->driver_data;
+ data->info = max34440_info[id->driver_data];
+
+ return pmbus_do_probe(client, id, &data->info);
}
static const struct i2c_device_id max34440_id[] = {
{"max34440", max34440},
{"max34441", max34441},
+ {"max34446", max34446},
{}
};
-
MODULE_DEVICE_TABLE(i2c, max34440_id);
/* This is the driver that will be inserted */
@@ -244,22 +353,12 @@ static struct i2c_driver max34440_driver = {
.name = "max34440",
},
.probe = max34440_probe,
- .remove = max34440_remove,
+ .remove = pmbus_do_remove,
.id_table = max34440_id,
};
-static int __init max34440_init(void)
-{
- return i2c_add_driver(&max34440_driver);
-}
-
-static void __exit max34440_exit(void)
-{
- i2c_del_driver(&max34440_driver);
-}
+module_i2c_driver(max34440_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for Maxim MAX34440/MAX34441");
MODULE_LICENSE("GPL");
-module_init(max34440_init);
-module_exit(max34440_exit);
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c
index e2b74bb399b..f04454a42fd 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,
return pmbus_do_probe(client, id, &max8688_info);
}
-static int max8688_remove(struct i2c_client *client)
-{
- pmbus_do_remove(client);
- return 0;
-}
-
static const struct i2c_device_id max8688_id[] = {
{"max8688", 0},
{ }
@@ -199,22 +193,12 @@ static struct i2c_driver max8688_driver = {
.name = "max8688",
},
.probe = max8688_probe,
- .remove = max8688_remove,
+ .remove = pmbus_do_remove,
.id_table = max8688_id,
};
-static int __init max8688_init(void)
-{
- return i2c_add_driver(&max8688_driver);
-}
-
-static void __exit max8688_exit(void)
-{
- i2c_del_driver(&max8688_driver);
-}
+module_i2c_driver(max8688_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for Maxim MAX8688");
MODULE_LICENSE("GPL");
-module_init(max8688_init);
-module_exit(max8688_exit);
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 18a385e753d..7e91700131a 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,
const struct i2c_device_id *id)
{
struct pmbus_driver_info *info;
- int ret;
- info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL);
+ info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
+ GFP_KERNEL);
if (!info)
return -ENOMEM;
info->pages = id->driver_data;
info->identify = pmbus_identify;
- ret = pmbus_do_probe(client, id, info);
- if (ret < 0)
- goto out;
- return 0;
-
-out:
- kfree(info);
- return ret;
-}
-
-static int pmbus_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info;
-
- info = pmbus_get_driver_info(client);
- pmbus_do_remove(client);
- kfree(info);
- return 0;
+ return pmbus_do_probe(client, id, info);
}
/*
@@ -202,12 +185,15 @@ static const struct i2c_device_id pmbus_id[] = {
{"adp4000", 1},
{"bmr453", 1},
{"bmr454", 1},
+ {"mdt040", 1},
{"ncp4200", 1},
{"ncp4208", 1},
{"pdt003", 1},
{"pdt006", 1},
{"pdt012", 1},
{"pmbus", 0},
+ {"tps40400", 1},
+ {"tps40422", 2},
{"udt020", 1},
{}
};
@@ -220,22 +206,12 @@ static struct i2c_driver pmbus_driver = {
.name = "pmbus",
},
.probe = pmbus_probe,
- .remove = pmbus_remove,
+ .remove = pmbus_do_remove,
.id_table = pmbus_id,
};
-static int __init pmbus_init(void)
-{
- return i2c_add_driver(&pmbus_driver);
-}
-
-static void __exit pmbus_exit(void)
-{
- i2c_del_driver(&pmbus_driver);
-}
+module_i2c_driver(pmbus_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("Generic PMBus driver");
MODULE_LICENSE("GPL");
-module_init(pmbus_init);
-module_exit(pmbus_exit);
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index 5d31d1c2c0f..3fe03dc47eb 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -146,31 +146,36 @@
* code when reading or writing virtual registers.
*/
#define PMBUS_VIRT_BASE 0x100
-#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 0)
-#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 1)
-#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 2)
-#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 3)
-#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 4)
-#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 5)
-#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 6)
-#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 7)
-#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 8)
-#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 9)
-#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 10)
-#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 11)
-#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 12)
-#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 13)
-#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 14)
-#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 15)
-#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 16)
-#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 17)
-#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 18)
-#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 19)
-#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 20)
-#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 21)
-#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 22)
-#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 23)
-#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 24)
+#define PMBUS_VIRT_READ_TEMP_AVG (PMBUS_VIRT_BASE + 0)
+#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 1)
+#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 2)
+#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 3)
+#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 4)
+#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 5)
+#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 6)
+#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 7)
+#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 8)
+#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 9)
+#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 10)
+#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 11)
+#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 12)
+#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 13)
+#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 14)
+#define PMBUS_VIRT_READ_POUT_AVG (PMBUS_VIRT_BASE + 15)
+#define PMBUS_VIRT_READ_POUT_MAX (PMBUS_VIRT_BASE + 16)
+#define PMBUS_VIRT_RESET_POUT_HISTORY (PMBUS_VIRT_BASE + 17)
+#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 18)
+#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 19)
+#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 20)
+#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 21)
+#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 22)
+#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 23)
+#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 24)
+#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 25)
+#define PMBUS_VIRT_READ_TEMP2_AVG (PMBUS_VIRT_BASE + 26)
+#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 27)
+#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 28)
+#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 29)
/*
* CAPABILITY
@@ -364,7 +369,7 @@ bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
struct pmbus_driver_info *info);
-void pmbus_do_remove(struct i2c_client *client);
+int pmbus_do_remove(struct i2c_client *client);
const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
*client);
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index d89b33967a8..be51037363c 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -40,11 +40,14 @@
#define PMBUS_IOUT_SENSORS_PER_PAGE 8 /* input, min, max, crit,
lowest, highest, avg,
reset */
-#define PMBUS_POUT_SENSORS_PER_PAGE 4 /* input, cap, max, crit */
+#define PMBUS_POUT_SENSORS_PER_PAGE 7 /* input, cap, max, crit,
+ * highest, avg, reset
+ */
#define PMBUS_MAX_SENSORS_PER_FAN 1 /* input */
-#define PMBUS_MAX_SENSORS_PER_TEMP 8 /* input, min, max, lcrit,
- crit, lowest, highest,
- reset */
+#define PMBUS_MAX_SENSORS_PER_TEMP 9 /* input, min, max, lcrit,
+ * crit, lowest, highest, avg,
+ * reset
+ */
#define PMBUS_MAX_INPUT_BOOLEANS 7 /* v: min_alarm, max_alarm,
lcrit_alarm, crit_alarm;
@@ -782,7 +785,7 @@ static ssize_t pmbus_set_sensor(struct device *dev,
int ret;
u16 regval;
- if (strict_strtol(buf, 10, &val) < 0)
+ if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
mutex_lock(&data->update_lock);
@@ -1334,6 +1337,17 @@ static const struct pmbus_limit_attr pout_limit_attrs[] = {
.attr = "crit",
.alarm = "crit_alarm",
.sbit = PB_POUT_OP_FAULT,
+ }, {
+ .reg = PMBUS_VIRT_READ_POUT_AVG,
+ .update = true,
+ .attr = "average",
+ }, {
+ .reg = PMBUS_VIRT_READ_POUT_MAX,
+ .update = true,
+ .attr = "input_highest",
+ }, {
+ .reg = PMBUS_VIRT_RESET_POUT_HISTORY,
+ .attr = "reset_history",
}
};
@@ -1389,6 +1403,9 @@ static const struct pmbus_limit_attr temp_limit_attrs[] = {
.reg = PMBUS_VIRT_READ_TEMP_MIN,
.attr = "lowest",
}, {
+ .reg = PMBUS_VIRT_READ_TEMP_AVG,
+ .attr = "average",
+ }, {
.reg = PMBUS_VIRT_READ_TEMP_MAX,
.attr = "highest",
}, {
@@ -1424,6 +1441,9 @@ static const struct pmbus_limit_attr temp_limit_attrs2[] = {
.reg = PMBUS_VIRT_READ_TEMP2_MIN,
.attr = "lowest",
}, {
+ .reg = PMBUS_VIRT_READ_TEMP2_AVG,
+ .attr = "average",
+ }, {
.reg = PMBUS_VIRT_READ_TEMP2_MAX,
.attr = "highest",
}, {
@@ -1676,7 +1696,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
| I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&client->dev, "No memory to allocate driver data\n");
return -ENOMEM;
@@ -1688,8 +1708,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
/* Bail out if PMBus status register does not exist. */
if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
dev_err(&client->dev, "PMBus status register not found\n");
- ret = -ENODEV;
- goto out_data;
+ return -ENODEV;
}
if (pdata)
@@ -1702,50 +1721,49 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
ret = (*info->identify)(client, info);
if (ret < 0) {
dev_err(&client->dev, "Chip identification failed\n");
- goto out_data;
+ return ret;
}
}
if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
dev_err(&client->dev, "Bad number of PMBus pages: %d\n",
info->pages);
- ret = -ENODEV;
- goto out_data;
+ return -ENODEV;
}
ret = pmbus_identify_common(client, data);
if (ret < 0) {
dev_err(&client->dev, "Failed to identify chip capabilities\n");
- goto out_data;
+ return ret;
}
ret = -ENOMEM;
- data->sensors = kzalloc(sizeof(struct pmbus_sensor) * data->max_sensors,
- GFP_KERNEL);
+ data->sensors = devm_kzalloc(&client->dev, sizeof(struct pmbus_sensor)
+ * data->max_sensors, GFP_KERNEL);
if (!data->sensors) {
dev_err(&client->dev, "No memory to allocate sensor data\n");
- goto out_data;
+ return -ENOMEM;
}
- data->booleans = kzalloc(sizeof(struct pmbus_boolean)
+ data->booleans = devm_kzalloc(&client->dev, sizeof(struct pmbus_boolean)
* data->max_booleans, GFP_KERNEL);
if (!data->booleans) {
dev_err(&client->dev, "No memory to allocate boolean data\n");
- goto out_sensors;
+ return -ENOMEM;
}
- data->labels = kzalloc(sizeof(struct pmbus_label) * data->max_labels,
- GFP_KERNEL);
+ data->labels = devm_kzalloc(&client->dev, sizeof(struct pmbus_label)
+ * data->max_labels, GFP_KERNEL);
if (!data->labels) {
dev_err(&client->dev, "No memory to allocate label data\n");
- goto out_booleans;
+ return -ENOMEM;
}
- data->attributes = kzalloc(sizeof(struct attribute *)
- * data->max_attributes, GFP_KERNEL);
+ data->attributes = devm_kzalloc(&client->dev, sizeof(struct attribute *)
+ * data->max_attributes, GFP_KERNEL);
if (!data->attributes) {
dev_err(&client->dev, "No memory to allocate attribute data\n");
- goto out_labels;
+ return -ENOMEM;
}
pmbus_find_attributes(client, data);
@@ -1756,8 +1774,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
*/
if (!data->num_attributes) {
dev_err(&client->dev, "No attributes found\n");
- ret = -ENODEV;
- goto out_attributes;
+ return -ENODEV;
}
/* Register sysfs hooks */
@@ -1765,7 +1782,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
ret = sysfs_create_group(&client->dev.kobj, &data->group);
if (ret) {
dev_err(&client->dev, "Failed to create sysfs entries\n");
- goto out_attributes;
+ return ret;
}
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
@@ -1777,30 +1794,16 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
out_hwmon_device_register:
sysfs_remove_group(&client->dev.kobj, &data->group);
-out_attributes:
- kfree(data->attributes);
-out_labels:
- kfree(data->labels);
-out_booleans:
- kfree(data->booleans);
-out_sensors:
- kfree(data->sensors);
-out_data:
- kfree(data);
return ret;
}
EXPORT_SYMBOL_GPL(pmbus_do_probe);
-void pmbus_do_remove(struct i2c_client *client)
+int pmbus_do_remove(struct i2c_client *client)
{
struct pmbus_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &data->group);
- kfree(data->attributes);
- kfree(data->labels);
- kfree(data->booleans);
- kfree(data->sensors);
- kfree(data);
+ return 0;
}
EXPORT_SYMBOL_GPL(pmbus_do_remove);
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index 4ff6cf289f8..fbb1479d3ad 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,
"Device mismatch: Configured %s, detected %s\n",
id->name, mid->name);
- data = kzalloc(sizeof(struct ucd9000_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
info = &data->info;
@@ -164,13 +165,12 @@ static int ucd9000_probe(struct i2c_client *client,
if (ret < 0) {
dev_err(&client->dev,
"Failed to read number of active pages\n");
- goto out;
+ return ret;
}
info->pages = ret;
if (!info->pages) {
dev_err(&client->dev, "No pages configured\n");
- ret = -ENODEV;
- goto out;
+ return -ENODEV;
}
/* The internal temperature sensor is always active */
@@ -181,8 +181,7 @@ static int ucd9000_probe(struct i2c_client *client,
block_buffer);
if (ret <= 0) {
dev_err(&client->dev, "Failed to read configuration data\n");
- ret = -ENODEV;
- goto out;
+ return -ENODEV;
}
for (i = 0; i < ret; i++) {
int page = UCD9000_MON_PAGE(block_buffer[i]);
@@ -218,7 +217,7 @@ static int ucd9000_probe(struct i2c_client *client,
UCD9000_FAN_CONFIG,
data->fan_data[i]);
if (ret < 0)
- goto out;
+ return ret;
}
i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0);
@@ -227,49 +226,21 @@ static int ucd9000_probe(struct i2c_client *client,
| PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34;
}
- ret = pmbus_do_probe(client, mid, info);
- if (ret < 0)
- goto out;
- return 0;
-
-out:
- kfree(data);
- return ret;
-}
-
-static int ucd9000_remove(struct i2c_client *client)
-{
- struct ucd9000_data *data;
-
- data = to_ucd9000_data(pmbus_get_driver_info(client));
- pmbus_do_remove(client);
- kfree(data);
- return 0;
+ return pmbus_do_probe(client, mid, info);
}
-
/* This is the driver that will be inserted */
static struct i2c_driver ucd9000_driver = {
.driver = {
.name = "ucd9000",
},
.probe = ucd9000_probe,
- .remove = ucd9000_remove,
+ .remove = pmbus_do_remove,
.id_table = ucd9000_id,
};
-static int __init ucd9000_init(void)
-{
- return i2c_add_driver(&ucd9000_driver);
-}
-
-static void __exit ucd9000_exit(void)
-{
- i2c_del_driver(&ucd9000_driver);
-}
+module_i2c_driver(ucd9000_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx");
MODULE_LICENSE("GPL");
-module_init(ucd9000_init);
-module_exit(ucd9000_exit);
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c
index 6e1c1a80ab8..033d6aca47d 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,
"Device mismatch: Configured %s, detected %s\n",
id->name, mid->name);
- info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL);
+ info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info),
+ GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -89,7 +90,7 @@ static int ucd9200_probe(struct i2c_client *client,
block_buffer);
if (ret < 0) {
dev_err(&client->dev, "Failed to read phase information\n");
- goto out;
+ return ret;
}
/*
@@ -106,8 +107,7 @@ static int ucd9200_probe(struct i2c_client *client,
}
if (!info->pages) {
dev_err(&client->dev, "No rails configured\n");
- ret = -ENODEV;
- goto out;
+ return -ENODEV;
}
dev_info(&client->dev, "%d rails configured\n", info->pages);
@@ -137,7 +137,7 @@ static int ucd9200_probe(struct i2c_client *client,
if (ret < 0) {
dev_err(&client->dev,
"Failed to initialize PHASE registers\n");
- goto out;
+ return ret;
}
}
if (info->pages > 1)
@@ -160,48 +160,21 @@ static int ucd9200_probe(struct i2c_client *client,
if (mid->driver_data == ucd9240)
info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12;
- ret = pmbus_do_probe(client, mid, info);
- if (ret < 0)
- goto out;
- return 0;
-out:
- kfree(info);
- return ret;
-}
-
-static int ucd9200_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info;
-
- info = pmbus_get_driver_info(client);
- pmbus_do_remove(client);
- kfree(info);
- return 0;
+ return pmbus_do_probe(client, mid, info);
}
-
/* This is the driver that will be inserted */
static struct i2c_driver ucd9200_driver = {
.driver = {
.name = "ucd9200",
},
.probe = ucd9200_probe,
- .remove = ucd9200_remove,
+ .remove = pmbus_do_remove,
.id_table = ucd9200_id,
};
-static int __init ucd9200_init(void)
-{
- return i2c_add_driver(&ucd9200_driver);
-}
-
-static void __exit ucd9200_exit(void)
-{
- i2c_del_driver(&ucd9200_driver);
-}
+module_i2c_driver(ucd9200_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for TI UCD922x, UCD924x");
MODULE_LICENSE("GPL");
-module_init(ucd9200_init);
-module_exit(ucd9200_exit);
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c
index 880b90cf4d3..fc5eed8e85b 100644
--- a/drivers/hwmon/pmbus/zl6100.c
+++ b/drivers/hwmon/pmbus/zl6100.c
@@ -28,7 +28,8 @@
#include <linux/delay.h>
#include "pmbus.h"
-enum chips { zl2004, zl2005, zl2006, zl2008, zl2105, zl2106, zl6100, zl6105 };
+enum chips { zl2004, zl2005, zl2006, zl2008, zl2105, zl2106, zl6100, zl6105,
+ zl9101, zl9117 };
struct zl6100_data {
int id;
@@ -152,6 +153,8 @@ static const struct i2c_device_id zl6100_id[] = {
{"zl2106", zl2106},
{"zl6100", zl6100},
{"zl6105", zl6105},
+ {"zl9101", zl9101},
+ {"zl9117", zl9117},
{ }
};
MODULE_DEVICE_TABLE(i2c, zl6100_id);
@@ -193,24 +196,19 @@ static int zl6100_probe(struct i2c_client *client,
"Device mismatch: Configured %s, detected %s\n",
id->name, mid->name);
- data = kzalloc(sizeof(struct zl6100_data), GFP_KERNEL);
+ data = devm_kzalloc(&client->dev, sizeof(struct zl6100_data),
+ GFP_KERNEL);
if (!data)
return -ENOMEM;
data->id = mid->driver_data;
/*
- * ZL2005, ZL2008, ZL2105, and ZL6100 are known to require a wait time
- * between I2C accesses. ZL2004 and ZL6105 are known to be safe.
- * Other chips have not yet been tested.
- *
- * Only clear the wait time for chips known to be safe. The wait time
- * can be cleared later for additional chips if tests show that it
- * is not needed (in other words, better be safe than sorry).
+ * According to information from the chip vendor, all currently
+ * supported chips are known to require a wait time between I2C
+ * accesses.
*/
data->delay = delay;
- if (data->id == zl2004 || data->id == zl6105)
- data->delay = 0;
/*
* Since there was a direct I2C device access above, wait before
@@ -229,7 +227,8 @@ static int zl6100_probe(struct i2c_client *client,
ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG);
if (ret < 0)
- goto err_mem;
+ return ret;
+
if (ret & ZL6100_MFR_XTEMP_ENABLE)
info->func[0] |= PMBUS_HAVE_TEMP2;
@@ -241,24 +240,7 @@ static int zl6100_probe(struct i2c_client *client,
info->write_word_data = zl6100_write_word_data;
info->write_byte = zl6100_write_byte;
- ret = pmbus_do_probe(client, mid, info);
- if (ret)
- goto err_mem;
- return 0;
-
-err_mem:
- kfree(data);
- return ret;
-}
-
-static int zl6100_remove(struct i2c_client *client)
-{
- const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
- const struct zl6100_data *data = to_zl6100_data(info);
-
- pmbus_do_remove(client);
- kfree(data);
- return 0;
+ return pmbus_do_probe(client, mid, info);
}
static struct i2c_driver zl6100_driver = {
@@ -266,22 +248,12 @@ static struct i2c_driver zl6100_driver = {
.name = "zl6100",
},
.probe = zl6100_probe,
- .remove = zl6100_remove,
+ .remove = pmbus_do_remove,
.id_table = zl6100_id,
};
-static int __init zl6100_init(void)
-{
- return i2c_add_driver(&zl6100_driver);
-}
-
-static void __exit zl6100_exit(void)
-{
- i2c_del_driver(&zl6100_driver);
-}
+module_i2c_driver(zl6100_driver);
MODULE_AUTHOR("Guenter Roeck");
MODULE_DESCRIPTION("PMBus driver for ZL6100 and compatibles");
MODULE_LICENSE("GPL");
-module_init(zl6100_init);
-module_exit(zl6100_exit);