Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / iio / accel / bma400_i2c.c
blob24a390c3ae66d152fa3c30639270423809c0e5e6
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * I2C IIO driver for Bosch BMA400 triaxial acceleration sensor.
5 * Copyright 2019 Dan Robertson <dan@dlrobertson.com>
7 * I2C address is either 0x14 or 0x15 depending on SDO
8 */
9 #include <linux/i2c.h>
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
14 #include "bma400.h"
16 static int bma400_i2c_probe(struct i2c_client *client)
18 const struct i2c_device_id *id = i2c_client_get_device_id(client);
19 struct regmap *regmap;
21 regmap = devm_regmap_init_i2c(client, &bma400_regmap_config);
22 if (IS_ERR(regmap)) {
23 dev_err(&client->dev, "failed to create regmap\n");
24 return PTR_ERR(regmap);
27 return bma400_probe(&client->dev, regmap, client->irq, id->name);
30 static const struct i2c_device_id bma400_i2c_ids[] = {
31 { "bma400" },
32 { }
34 MODULE_DEVICE_TABLE(i2c, bma400_i2c_ids);
36 static const struct of_device_id bma400_of_i2c_match[] = {
37 { .compatible = "bosch,bma400" },
38 { }
40 MODULE_DEVICE_TABLE(of, bma400_of_i2c_match);
42 static struct i2c_driver bma400_i2c_driver = {
43 .driver = {
44 .name = "bma400",
45 .of_match_table = bma400_of_i2c_match,
47 .probe = bma400_i2c_probe,
48 .id_table = bma400_i2c_ids,
51 module_i2c_driver(bma400_i2c_driver);
53 MODULE_AUTHOR("Dan Robertson <dan@dlrobertson.com>");
54 MODULE_DESCRIPTION("Bosch BMA400 triaxial acceleration sensor (I2C)");
55 MODULE_LICENSE("GPL");
56 MODULE_IMPORT_NS("IIO_BMA400");