Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.8 61 lines 1.4 kB view raw
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * ADXL372 3-Axis Digital Accelerometer I2C driver 4 * 5 * Copyright 2018 Analog Devices Inc. 6 */ 7 8#include <linux/i2c.h> 9#include <linux/module.h> 10#include <linux/regmap.h> 11 12#include "adxl372.h" 13 14static const struct regmap_config adxl372_regmap_config = { 15 .reg_bits = 8, 16 .val_bits = 8, 17 .readable_noinc_reg = adxl372_readable_noinc_reg, 18}; 19 20static int adxl372_i2c_probe(struct i2c_client *client, 21 const struct i2c_device_id *id) 22{ 23 struct regmap *regmap; 24 unsigned int regval; 25 int ret; 26 27 regmap = devm_regmap_init_i2c(client, &adxl372_regmap_config); 28 if (IS_ERR(regmap)) 29 return PTR_ERR(regmap); 30 31 ret = regmap_read(regmap, ADXL372_REVID, &regval); 32 if (ret < 0) 33 return ret; 34 35 /* Starting with the 3rd revision an I2C chip bug was fixed */ 36 if (regval < 3) 37 dev_warn(&client->dev, 38 "I2C might not work properly with other devices on the bus"); 39 40 return adxl372_probe(&client->dev, regmap, client->irq, id->name); 41} 42 43static const struct i2c_device_id adxl372_i2c_id[] = { 44 { "adxl372", 0 }, 45 {} 46}; 47MODULE_DEVICE_TABLE(i2c, adxl372_i2c_id); 48 49static struct i2c_driver adxl372_i2c_driver = { 50 .driver = { 51 .name = "adxl372_i2c", 52 }, 53 .probe = adxl372_i2c_probe, 54 .id_table = adxl372_i2c_id, 55}; 56 57module_i2c_driver(adxl372_i2c_driver); 58 59MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>"); 60MODULE_DESCRIPTION("Analog Devices ADXL372 3-axis accelerometer I2C driver"); 61MODULE_LICENSE("GPL");