drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / iio / accel / kxsd9-spi.c
blob4414670dfb436be30a93364b1055a6b33868e727
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/device.h>
3 #include <linux/kernel.h>
4 #include <linux/spi/spi.h>
5 #include <linux/module.h>
6 #include <linux/mod_devicetable.h>
7 #include <linux/slab.h>
8 #include <linux/regmap.h>
10 #include "kxsd9.h"
12 static int kxsd9_spi_probe(struct spi_device *spi)
14 static const struct regmap_config config = {
15 .reg_bits = 8,
16 .val_bits = 8,
17 .max_register = 0x0e,
19 struct regmap *regmap;
21 spi->mode = SPI_MODE_0;
22 regmap = devm_regmap_init_spi(spi, &config);
23 if (IS_ERR(regmap)) {
24 dev_err(&spi->dev, "%s: regmap allocation failed: %ld\n",
25 __func__, PTR_ERR(regmap));
26 return PTR_ERR(regmap);
29 return kxsd9_common_probe(&spi->dev,
30 regmap,
31 spi_get_device_id(spi)->name);
34 static void kxsd9_spi_remove(struct spi_device *spi)
36 kxsd9_common_remove(&spi->dev);
39 static const struct spi_device_id kxsd9_spi_id[] = {
40 {"kxsd9", 0},
41 { },
43 MODULE_DEVICE_TABLE(spi, kxsd9_spi_id);
45 static const struct of_device_id kxsd9_of_match[] = {
46 { .compatible = "kionix,kxsd9" },
47 { }
49 MODULE_DEVICE_TABLE(of, kxsd9_of_match);
51 static struct spi_driver kxsd9_spi_driver = {
52 .driver = {
53 .name = "kxsd9",
54 .pm = pm_ptr(&kxsd9_dev_pm_ops),
55 .of_match_table = kxsd9_of_match,
57 .probe = kxsd9_spi_probe,
58 .remove = kxsd9_spi_remove,
59 .id_table = kxsd9_spi_id,
61 module_spi_driver(kxsd9_spi_driver);
63 MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
64 MODULE_DESCRIPTION("Kionix KXSD9 SPI driver");
65 MODULE_LICENSE("GPL v2");
66 MODULE_IMPORT_NS(IIO_KXSD9);