WIP FPC-III support
[linux/fpc-iii.git] / drivers / iio / accel / mma7455_spi.c
blobeb82cdfa8abc514b8cc7dc3d3a86957ca95f0596
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * IIO accel SPI driver for Freescale MMA7455L 3-axis 10-bit accelerometer
4 * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
5 */
7 #include <linux/module.h>
8 #include <linux/regmap.h>
9 #include <linux/spi/spi.h>
11 #include "mma7455.h"
13 static int mma7455_spi_probe(struct spi_device *spi)
15 const struct spi_device_id *id = spi_get_device_id(spi);
16 struct regmap *regmap;
18 regmap = devm_regmap_init_spi(spi, &mma7455_core_regmap);
19 if (IS_ERR(regmap))
20 return PTR_ERR(regmap);
22 return mma7455_core_probe(&spi->dev, regmap, id->name);
25 static int mma7455_spi_remove(struct spi_device *spi)
27 return mma7455_core_remove(&spi->dev);
30 static const struct spi_device_id mma7455_spi_ids[] = {
31 { "mma7455", 0 },
32 { "mma7456", 0 },
33 { }
35 MODULE_DEVICE_TABLE(spi, mma7455_spi_ids);
37 static struct spi_driver mma7455_spi_driver = {
38 .probe = mma7455_spi_probe,
39 .remove = mma7455_spi_remove,
40 .id_table = mma7455_spi_ids,
41 .driver = {
42 .name = "mma7455-spi",
45 module_spi_driver(mma7455_spi_driver);
47 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
48 MODULE_DESCRIPTION("Freescale MMA7455L SPI accelerometer driver");
49 MODULE_LICENSE("GPL v2");