Linux 4.16.11
[linux/fpc-iii.git] / drivers / iio / accel / mma7455_spi.c
blob79df8f27cf998d7f6964b9d8c64220149c72cffa
1 /*
2 * IIO accel SPI driver for Freescale MMA7455L 3-axis 10-bit accelerometer
3 * Copyright 2015 Joachim Eastwood <manabian@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
10 #include <linux/module.h>
11 #include <linux/regmap.h>
12 #include <linux/spi/spi.h>
14 #include "mma7455.h"
16 static int mma7455_spi_probe(struct spi_device *spi)
18 const struct spi_device_id *id = spi_get_device_id(spi);
19 struct regmap *regmap;
21 regmap = devm_regmap_init_spi(spi, &mma7455_core_regmap);
22 if (IS_ERR(regmap))
23 return PTR_ERR(regmap);
25 return mma7455_core_probe(&spi->dev, regmap, id->name);
28 static int mma7455_spi_remove(struct spi_device *spi)
30 return mma7455_core_remove(&spi->dev);
33 static const struct spi_device_id mma7455_spi_ids[] = {
34 { "mma7455", 0 },
35 { "mma7456", 0 },
36 { }
38 MODULE_DEVICE_TABLE(spi, mma7455_spi_ids);
40 static struct spi_driver mma7455_spi_driver = {
41 .probe = mma7455_spi_probe,
42 .remove = mma7455_spi_remove,
43 .id_table = mma7455_spi_ids,
44 .driver = {
45 .name = "mma7455-spi",
48 module_spi_driver(mma7455_spi_driver);
50 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
51 MODULE_DESCRIPTION("Freescale MMA7455L SPI accelerometer driver");
52 MODULE_LICENSE("GPL v2");