mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 16:18:09 -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. 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> Reviewed-by: Ivan Vecera <ivecera@redhat.com> Link: https://patch.msgid.link/20260519142710.1587324-2-u.kleine-koenig@baylibre.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <linux/dev_printk.h>
|
|
#include <linux/err.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/module.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "core.h"
|
|
|
|
static int zl3073x_i2c_probe(struct i2c_client *client)
|
|
{
|
|
struct device *dev = &client->dev;
|
|
struct zl3073x_dev *zldev;
|
|
|
|
zldev = zl3073x_devm_alloc(dev);
|
|
if (IS_ERR(zldev))
|
|
return PTR_ERR(zldev);
|
|
|
|
zldev->regmap = devm_regmap_init_i2c(client, &zl3073x_regmap_config);
|
|
if (IS_ERR(zldev->regmap))
|
|
return dev_err_probe(dev, PTR_ERR(zldev->regmap),
|
|
"Failed to initialize regmap\n");
|
|
|
|
return zl3073x_dev_probe(zldev);
|
|
}
|
|
|
|
static const struct i2c_device_id zl3073x_i2c_id[] = {
|
|
{ .name = "zl30731" },
|
|
{ .name = "zl30732" },
|
|
{ .name = "zl30733" },
|
|
{ .name = "zl30734" },
|
|
{ .name = "zl30735" },
|
|
{ /* sentinel */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, zl3073x_i2c_id);
|
|
|
|
static const struct of_device_id zl3073x_i2c_of_match[] = {
|
|
{ .compatible = "microchip,zl30731" },
|
|
{ .compatible = "microchip,zl30732" },
|
|
{ .compatible = "microchip,zl30733" },
|
|
{ .compatible = "microchip,zl30734" },
|
|
{ .compatible = "microchip,zl30735" },
|
|
{ /* sentinel */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, zl3073x_i2c_of_match);
|
|
|
|
static struct i2c_driver zl3073x_i2c_driver = {
|
|
.driver = {
|
|
.name = "zl3073x-i2c",
|
|
.of_match_table = zl3073x_i2c_of_match,
|
|
},
|
|
.probe = zl3073x_i2c_probe,
|
|
.id_table = zl3073x_i2c_id,
|
|
};
|
|
module_i2c_driver(zl3073x_i2c_driver);
|
|
|
|
MODULE_AUTHOR("Ivan Vecera <ivecera@redhat.com>");
|
|
MODULE_DESCRIPTION("Microchip ZL3073x I2C driver");
|
|
MODULE_IMPORT_NS("ZL3073X");
|
|
MODULE_LICENSE("GPL");
|