mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 20:24:02 -04:00
While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition. The mentioned robustness is relevant for a planned change to struct i2c_device_id that replaces .driver_data by an anonymous union. While touching all these arrays, unify indention and usage of commas. This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/65b77bcd452752c36d866069cc5790b26d2bf8dc.1778688803.git.u.kleine-koenig@baylibre.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Analog Devices LTC2947 high precision power and energy monitor over I2C
|
|
*
|
|
* Copyright 2019 Analog Devices Inc.
|
|
*/
|
|
#include <linux/i2c.h>
|
|
#include <linux/module.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "ltc2947.h"
|
|
|
|
static const struct regmap_config ltc2947_regmap_config = {
|
|
.reg_bits = 8,
|
|
.val_bits = 8,
|
|
};
|
|
|
|
static int ltc2947_probe(struct i2c_client *i2c)
|
|
{
|
|
struct regmap *map;
|
|
|
|
map = devm_regmap_init_i2c(i2c, <c2947_regmap_config);
|
|
if (IS_ERR(map))
|
|
return PTR_ERR(map);
|
|
|
|
return ltc2947_core_probe(map, i2c->name);
|
|
}
|
|
|
|
static const struct i2c_device_id ltc2947_id[] = {
|
|
{ .name = "ltc2947" },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, ltc2947_id);
|
|
|
|
static struct i2c_driver ltc2947_driver = {
|
|
.driver = {
|
|
.name = "ltc2947",
|
|
.of_match_table = ltc2947_of_match,
|
|
.pm = pm_sleep_ptr(<c2947_pm_ops),
|
|
},
|
|
.probe = ltc2947_probe,
|
|
.id_table = ltc2947_id,
|
|
};
|
|
module_i2c_driver(ltc2947_driver);
|
|
|
|
MODULE_AUTHOR("Nuno Sa <nuno.sa@analog.com>");
|
|
MODULE_DESCRIPTION("LTC2947 I2C power and energy monitor driver");
|
|
MODULE_LICENSE("GPL");
|