drm/client: Fix drm client endless Kconfig loop
[drm/drm-misc.git] / drivers / iio / gyro / bmg160_i2c.c
blob9c5d7e8ee99cc699581abbc186c0424e244153ca
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/i2c.h>
3 #include <linux/regmap.h>
4 #include <linux/iio/iio.h>
5 #include <linux/module.h>
6 #include <linux/mod_devicetable.h>
8 #include "bmg160.h"
10 static const struct regmap_config bmg160_regmap_i2c_conf = {
11 .reg_bits = 8,
12 .val_bits = 8,
13 .max_register = 0x3f
16 static int bmg160_i2c_probe(struct i2c_client *client)
18 const struct i2c_device_id *id = i2c_client_get_device_id(client);
19 struct regmap *regmap;
20 const char *name;
22 regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
23 if (IS_ERR(regmap)) {
24 dev_err(&client->dev, "Failed to register i2c regmap: %pe\n",
25 regmap);
26 return PTR_ERR(regmap);
29 if (id)
30 name = id->name;
31 else
32 name = iio_get_acpi_device_name(&client->dev);
34 return bmg160_core_probe(&client->dev, regmap, client->irq, name);
37 static void bmg160_i2c_remove(struct i2c_client *client)
39 bmg160_core_remove(&client->dev);
42 static const struct acpi_device_id bmg160_acpi_match[] = {
43 {"BMG0160", 0},
44 {},
47 MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
49 static const struct i2c_device_id bmg160_i2c_id[] = {
50 { "bmg160" },
51 { "bmi055_gyro" },
52 { "bmi088_gyro" },
56 MODULE_DEVICE_TABLE(i2c, bmg160_i2c_id);
58 static const struct of_device_id bmg160_of_match[] = {
59 { .compatible = "bosch,bmg160" },
60 { .compatible = "bosch,bmi055_gyro" },
61 { }
64 MODULE_DEVICE_TABLE(of, bmg160_of_match);
66 static struct i2c_driver bmg160_i2c_driver = {
67 .driver = {
68 .name = "bmg160_i2c",
69 .acpi_match_table = bmg160_acpi_match,
70 .of_match_table = bmg160_of_match,
71 .pm = &bmg160_pm_ops,
73 .probe = bmg160_i2c_probe,
74 .remove = bmg160_i2c_remove,
75 .id_table = bmg160_i2c_id,
77 module_i2c_driver(bmg160_i2c_driver);
79 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
80 MODULE_LICENSE("GPL v2");
81 MODULE_DESCRIPTION("BMG160 I2C Gyro driver");