diff options
Diffstat (limited to 'drivers/hwmon/pmbus/zl6100.c')
-rw-r--r-- | drivers/hwmon/pmbus/zl6100.c | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c index 48c7b4a716a..fc5eed8e85b 100644 --- a/drivers/hwmon/pmbus/zl6100.c +++ b/drivers/hwmon/pmbus/zl6100.c @@ -28,11 +28,13 @@ #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; ktime_t access; /* chip access time */ + int delay; /* Delay between chip accesses in uS */ struct pmbus_driver_info info; }; @@ -52,10 +54,10 @@ MODULE_PARM_DESC(delay, "Delay between chip accesses in uS"); /* Some chips need a delay between accesses */ static inline void zl6100_wait(const struct zl6100_data *data) { - if (delay) { + if (data->delay) { s64 delta = ktime_us_delta(ktime_get(), data->access); - if (delta < delay) - udelay(delay - delta); + if (delta < data->delay) + udelay(data->delay - delta); } } @@ -151,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); @@ -192,23 +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. */ - if (data->id == zl2004 || data->id == zl6105) - delay = 0; + data->delay = delay; /* * Since there was a direct I2C device access above, wait before @@ -227,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; @@ -239,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 = { @@ -264,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); |