drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / iio / accel / adxl380_spi.c
blobe7b5778cb6cfe9f78dc9e4277f6c9b0fe2361fd3
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * ADXL380 3-Axis Digital Accelerometer SPI driver
5 * Copyright 2024 Analog Devices Inc.
6 */
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/regmap.h>
11 #include <linux/spi/spi.h>
13 #include "adxl380.h"
15 static const struct regmap_config adxl380_spi_regmap_config = {
16 .reg_bits = 7,
17 .pad_bits = 1,
18 .val_bits = 8,
19 .read_flag_mask = BIT(0),
20 .readable_noinc_reg = adxl380_readable_noinc_reg,
23 static int adxl380_spi_probe(struct spi_device *spi)
25 const struct adxl380_chip_info *chip_data;
26 struct regmap *regmap;
28 chip_data = spi_get_device_match_data(spi);
30 regmap = devm_regmap_init_spi(spi, &adxl380_spi_regmap_config);
31 if (IS_ERR(regmap))
32 return PTR_ERR(regmap);
34 return adxl380_probe(&spi->dev, regmap, chip_data);
37 static const struct spi_device_id adxl380_spi_id[] = {
38 { "adxl380", (kernel_ulong_t)&adxl380_chip_info },
39 { "adxl382", (kernel_ulong_t)&adxl382_chip_info },
40 { }
42 MODULE_DEVICE_TABLE(spi, adxl380_spi_id);
44 static const struct of_device_id adxl380_of_match[] = {
45 { .compatible = "adi,adxl380", .data = &adxl380_chip_info },
46 { .compatible = "adi,adxl382", .data = &adxl382_chip_info },
47 { }
49 MODULE_DEVICE_TABLE(of, adxl380_of_match);
51 static struct spi_driver adxl380_spi_driver = {
52 .driver = {
53 .name = "adxl380_spi",
54 .of_match_table = adxl380_of_match,
56 .probe = adxl380_spi_probe,
57 .id_table = adxl380_spi_id,
60 module_spi_driver(adxl380_spi_driver);
62 MODULE_AUTHOR("Ramona Gradinariu <ramona.gradinariu@analog.com>");
63 MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>");
64 MODULE_DESCRIPTION("Analog Devices ADXL380 3-axis accelerometer SPI driver");
65 MODULE_LICENSE("GPL");
66 MODULE_IMPORT_NS(IIO_ADXL380);