drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / iio / accel / adxl355_i2c.c
blob32398cde9608e226c8ee21147a7785ff5aef0e66
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ADXL355 3-Axis Digital Accelerometer I2C driver
5 * Copyright (c) 2021 Puranjay Mohan <puranjay12@gmail.com>
6 */
8 #include <linux/i2c.h>
9 #include <linux/module.h>
10 #include <linux/mod_devicetable.h>
11 #include <linux/regmap.h>
13 #include "adxl355.h"
15 static const struct regmap_config adxl355_i2c_regmap_config = {
16 .reg_bits = 8,
17 .val_bits = 8,
18 .max_register = 0x2F,
19 .rd_table = &adxl355_readable_regs_tbl,
20 .wr_table = &adxl355_writeable_regs_tbl,
23 static int adxl355_i2c_probe(struct i2c_client *client)
25 struct regmap *regmap;
26 const struct adxl355_chip_info *chip_data;
28 chip_data = i2c_get_match_data(client);
29 if (!chip_data)
30 return -ENODEV;
32 regmap = devm_regmap_init_i2c(client, &adxl355_i2c_regmap_config);
33 if (IS_ERR(regmap)) {
34 dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
35 PTR_ERR(regmap));
37 return PTR_ERR(regmap);
40 return adxl355_core_probe(&client->dev, regmap, chip_data);
43 static const struct i2c_device_id adxl355_i2c_id[] = {
44 { "adxl355", (kernel_ulong_t)&adxl35x_chip_info[ADXL355] },
45 { "adxl359", (kernel_ulong_t)&adxl35x_chip_info[ADXL359] },
46 { }
48 MODULE_DEVICE_TABLE(i2c, adxl355_i2c_id);
50 static const struct of_device_id adxl355_of_match[] = {
51 { .compatible = "adi,adxl355", .data = &adxl35x_chip_info[ADXL355] },
52 { .compatible = "adi,adxl359", .data = &adxl35x_chip_info[ADXL359] },
53 { }
55 MODULE_DEVICE_TABLE(of, adxl355_of_match);
57 static struct i2c_driver adxl355_i2c_driver = {
58 .driver = {
59 .name = "adxl355_i2c",
60 .of_match_table = adxl355_of_match,
62 .probe = adxl355_i2c_probe,
63 .id_table = adxl355_i2c_id,
65 module_i2c_driver(adxl355_i2c_driver);
67 MODULE_AUTHOR("Puranjay Mohan <puranjay12@gmail.com>");
68 MODULE_DESCRIPTION("ADXL355 3-Axis Digital Accelerometer I2C driver");
69 MODULE_LICENSE("GPL v2");
70 MODULE_IMPORT_NS(IIO_ADXL355);