Linux 4.16.11
[linux/fpc-iii.git] / drivers / iio / accel / mma7455_i2c.c
blob73bf81a8ab147684566670090e2152ebeeaee4eb
1 /*
2 * IIO accel I2C 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/i2c.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
14 #include "mma7455.h"
16 static int mma7455_i2c_probe(struct i2c_client *i2c,
17 const struct i2c_device_id *id)
19 struct regmap *regmap;
20 const char *name = NULL;
22 regmap = devm_regmap_init_i2c(i2c, &mma7455_core_regmap);
23 if (IS_ERR(regmap))
24 return PTR_ERR(regmap);
26 if (id)
27 name = id->name;
29 return mma7455_core_probe(&i2c->dev, regmap, name);
32 static int mma7455_i2c_remove(struct i2c_client *i2c)
34 return mma7455_core_remove(&i2c->dev);
37 static const struct i2c_device_id mma7455_i2c_ids[] = {
38 { "mma7455", 0 },
39 { "mma7456", 0 },
40 { }
42 MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
44 static const struct of_device_id mma7455_of_match[] = {
45 { .compatible = "fsl,mma7455" },
46 { .compatible = "fsl,mma7456" },
47 { }
49 MODULE_DEVICE_TABLE(of, mma7455_of_match);
51 static struct i2c_driver mma7455_i2c_driver = {
52 .probe = mma7455_i2c_probe,
53 .remove = mma7455_i2c_remove,
54 .id_table = mma7455_i2c_ids,
55 .driver = {
56 .name = "mma7455-i2c",
57 .of_match_table = mma7455_of_match,
60 module_i2c_driver(mma7455_i2c_driver);
62 MODULE_AUTHOR("Joachim Eastwood <manabian@gmail.com>");
63 MODULE_DESCRIPTION("Freescale MMA7455L I2C accelerometer driver");
64 MODULE_LICENSE("GPL v2");