]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/iio/accel/kxsd9-i2c.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / drivers / iio / accel / kxsd9-i2c.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
a483ab79
LW
2#include <linux/device.h>
3#include <linux/kernel.h>
4#include <linux/module.h>
5#include <linux/slab.h>
6#include <linux/i2c.h>
7#include <linux/delay.h>
8#include <linux/regmap.h>
9
10#include "kxsd9.h"
11
12static int kxsd9_i2c_probe(struct i2c_client *i2c,
13 const struct i2c_device_id *id)
14{
15 static const struct regmap_config config = {
16 .reg_bits = 8,
17 .val_bits = 8,
18 .max_register = 0x0e,
19 };
20 struct regmap *regmap;
21
22 regmap = devm_regmap_init_i2c(i2c, &config);
23 if (IS_ERR(regmap)) {
24 dev_err(&i2c->dev, "Failed to register i2c regmap %d\n",
25 (int)PTR_ERR(regmap));
26 return PTR_ERR(regmap);
27 }
28
29 return kxsd9_common_probe(&i2c->dev,
30 regmap,
31 i2c->name);
32}
33
34static int kxsd9_i2c_remove(struct i2c_client *client)
35{
36 return kxsd9_common_remove(&client->dev);
37}
38
39#ifdef CONFIG_OF
40static const struct of_device_id kxsd9_of_match[] = {
41 { .compatible = "kionix,kxsd9", },
42 { },
43};
44MODULE_DEVICE_TABLE(of, kxsd9_of_match);
45#else
46#define kxsd9_of_match NULL
47#endif
48
49static const struct i2c_device_id kxsd9_i2c_id[] = {
50 {"kxsd9", 0},
51 { },
52};
53MODULE_DEVICE_TABLE(i2c, kxsd9_i2c_id);
54
55static struct i2c_driver kxsd9_i2c_driver = {
56 .driver = {
57 .name = "kxsd9",
58 .of_match_table = of_match_ptr(kxsd9_of_match),
9a9a369d 59 .pm = &kxsd9_dev_pm_ops,
a483ab79
LW
60 },
61 .probe = kxsd9_i2c_probe,
62 .remove = kxsd9_i2c_remove,
63 .id_table = kxsd9_i2c_id,
64};
65module_i2c_driver(kxsd9_i2c_driver);