drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / iio / accel / adxl345_i2c.c
blob4065b8f7c8a8aeb744cd054b6b906bb74f54b697
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ADXL345 3-Axis Digital Accelerometer I2C driver
5 * Copyright (c) 2017 Eva Rachel Retuya <eraretuya@gmail.com>
7 * 7-bit I2C slave address: 0x1D (ALT ADDRESS pin tied to VDDIO) or
8 * 0x53 (ALT ADDRESS pin grounded)
9 */
11 #include <linux/i2c.h>
12 #include <linux/module.h>
13 #include <linux/regmap.h>
15 #include "adxl345.h"
17 static const struct regmap_config adxl345_i2c_regmap_config = {
18 .reg_bits = 8,
19 .val_bits = 8,
22 static int adxl345_i2c_probe(struct i2c_client *client)
24 struct regmap *regmap;
26 regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config);
27 if (IS_ERR(regmap))
28 return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
30 return adxl345_core_probe(&client->dev, regmap, NULL);
33 static const struct adxl345_chip_info adxl345_i2c_info = {
34 .name = "adxl345",
35 .uscale = ADXL345_USCALE,
38 static const struct adxl345_chip_info adxl375_i2c_info = {
39 .name = "adxl375",
40 .uscale = ADXL375_USCALE,
43 static const struct i2c_device_id adxl345_i2c_id[] = {
44 { "adxl345", (kernel_ulong_t)&adxl345_i2c_info },
45 { "adxl375", (kernel_ulong_t)&adxl375_i2c_info },
46 { }
48 MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id);
50 static const struct of_device_id adxl345_of_match[] = {
51 { .compatible = "adi,adxl345", .data = &adxl345_i2c_info },
52 { .compatible = "adi,adxl375", .data = &adxl375_i2c_info },
53 { }
55 MODULE_DEVICE_TABLE(of, adxl345_of_match);
57 static const struct acpi_device_id adxl345_acpi_match[] = {
58 { "ADS0345", (kernel_ulong_t)&adxl345_i2c_info },
59 { }
61 MODULE_DEVICE_TABLE(acpi, adxl345_acpi_match);
63 static struct i2c_driver adxl345_i2c_driver = {
64 .driver = {
65 .name = "adxl345_i2c",
66 .of_match_table = adxl345_of_match,
67 .acpi_match_table = adxl345_acpi_match,
69 .probe = adxl345_i2c_probe,
70 .id_table = adxl345_i2c_id,
72 module_i2c_driver(adxl345_i2c_driver);
74 MODULE_AUTHOR("Eva Rachel Retuya <eraretuya@gmail.com>");
75 MODULE_DESCRIPTION("ADXL345 3-Axis Digital Accelerometer I2C driver");
76 MODULE_LICENSE("GPL v2");
77 MODULE_IMPORT_NS(IIO_ADXL345);