Joachim Eastwood | a84ef0d | 2015-10-31 13:49:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * IIO accel SPI driver for Freescale MMA7455L 3-axis 10-bit accelerometer |
| 3 | * Copyright 2015 Joachim Eastwood <manabian@gmail.com> |
| 4 | * |
| 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 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/regmap.h> |
| 12 | #include <linux/spi/spi.h> |
| 13 | |
| 14 | #include "mma7455.h" |
| 15 | |
| 16 | static int mma7455_spi_probe(struct spi_device *spi) |
| 17 | { |
| 18 | const struct spi_device_id *id = spi_get_device_id(spi); |
| 19 | struct regmap *regmap; |
| 20 | |
| 21 | regmap = devm_regmap_init_spi(spi, &mma7455_core_regmap); |
| 22 | if (IS_ERR(regmap)) |
| 23 | return PTR_ERR(regmap); |
| 24 | |
| 25 | return mma7455_core_probe(&spi->dev, regmap, id->name); |
| 26 | } |
| 27 | |
| 28 | static int mma7455_spi_remove(struct spi_device *spi) |
| 29 | { |
| 30 | return mma7455_core_remove(&spi->dev); |
| 31 | } |
| 32 | |
| 33 | static const struct spi_device_id mma7455_spi_ids[] = { |
| 34 | { "mma7455", 0 }, |
| 35 | { "mma7456", 0 }, |
| 36 | { } |
| 37 | }; |
| 38 | MODULE_DEVICE_TABLE(spi, mma7455_spi_ids); |
| 39 | |
| 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", |
| 46 | }, |
| 47 | }; |
| 48 | module_spi_driver(mma7455_spi_driver); |
| 49 | |
| 50 | MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>"); |
| 51 | MODULE_DESCRIPTION("Freescale MMA7455L SPI accelerometer driver"); |
| 52 | MODULE_LICENSE("GPL v2"); |