Merge tag '9p-for-5.7-2' of git://github.com/martinetd/linux
[linux-2.6-block.git] / drivers / hwmon / ltc2947-i2c.c
CommitLineData
9f90fd65
NS
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Analog Devices LTC2947 high precision power and energy monitor over I2C
4 *
5 * Copyright 2019 Analog Devices Inc.
6 */
7#include <linux/i2c.h>
8#include <linux/module.h>
9#include <linux/regmap.h>
10
11#include "ltc2947.h"
12
13static const struct regmap_config ltc2947_regmap_config = {
14 .reg_bits = 8,
15 .val_bits = 8,
16};
17
18static int ltc2947_probe(struct i2c_client *i2c,
19 const struct i2c_device_id *id)
20{
21 struct regmap *map;
22
23 map = devm_regmap_init_i2c(i2c, &ltc2947_regmap_config);
24 if (IS_ERR(map))
25 return PTR_ERR(map);
26
27 return ltc2947_core_probe(map, i2c->name);
28}
29
30static const struct i2c_device_id ltc2947_id[] = {
31 {"ltc2947", 0},
32 {}
33};
34MODULE_DEVICE_TABLE(i2c, ltc2947_id);
35
36static struct i2c_driver ltc2947_driver = {
37 .driver = {
38 .name = "ltc2947",
39 .of_match_table = ltc2947_of_match,
40 .pm = &ltc2947_pm_ops,
41 },
42 .probe = ltc2947_probe,
43 .id_table = ltc2947_id,
44};
45module_i2c_driver(ltc2947_driver);
46
47MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
48MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
49MODULE_LICENSE("GPL");