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

iio: accel: adxl345: Make use of device properties

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
266be7cb c1db3d5c

+9 -11
+1 -1
drivers/iio/accel/adxl345.h
··· 13 13 ADXL375 = 2, 14 14 }; 15 15 16 - int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type); 16 + int adxl345_core_probe(struct device *dev, struct regmap *regmap); 17 17 18 18 #endif /* _ADXL345_H_ */
+4 -1
drivers/iio/accel/adxl345_core.c
··· 8 8 */ 9 9 10 10 #include <linux/module.h> 11 + #include <linux/property.h> 11 12 #include <linux/regmap.h> 12 13 13 14 #include <linux/iio/iio.h> ··· 214 213 regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY); 215 214 } 216 215 217 - int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type) 216 + int adxl345_core_probe(struct device *dev, struct regmap *regmap) 218 217 { 218 + enum adxl345_device_type type; 219 219 struct adxl345_data *data; 220 220 struct iio_dev *indio_dev; 221 221 const char *name; 222 222 u32 regval; 223 223 int ret; 224 224 225 + type = (uintptr_t)device_get_match_data(dev); 225 226 switch (type) { 226 227 case ADXL345: 227 228 name = "adxl345";
+3 -7
drivers/iio/accel/adxl345_i2c.c
··· 19 19 .val_bits = 8, 20 20 }; 21 21 22 - static int adxl345_i2c_probe(struct i2c_client *client, 23 - const struct i2c_device_id *id) 22 + static int adxl345_i2c_probe(struct i2c_client *client) 24 23 { 25 24 struct regmap *regmap; 26 - 27 - if (!id) 28 - return -ENODEV; 29 25 30 26 regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config); 31 27 if (IS_ERR(regmap)) 32 28 return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n"); 33 29 34 - return adxl345_core_probe(&client->dev, regmap, id->driver_data); 30 + return adxl345_core_probe(&client->dev, regmap); 35 31 } 36 32 37 33 static const struct i2c_device_id adxl345_i2c_id[] = { ··· 51 55 .name = "adxl345_i2c", 52 56 .of_match_table = adxl345_of_match, 53 57 }, 54 - .probe = adxl345_i2c_probe, 58 + .probe_new = adxl345_i2c_probe, 55 59 .id_table = adxl345_i2c_id, 56 60 }; 57 61
+1 -2
drivers/iio/accel/adxl345_spi.c
··· 22 22 23 23 static int adxl345_spi_probe(struct spi_device *spi) 24 24 { 25 - const struct spi_device_id *id = spi_get_device_id(spi); 26 25 struct regmap *regmap; 27 26 28 27 /* Bail out if max_speed_hz exceeds 5 MHz */ ··· 33 34 if (IS_ERR(regmap)) 34 35 return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n"); 35 36 36 - return adxl345_core_probe(&spi->dev, regmap, id->driver_data); 37 + return adxl345_core_probe(&spi->dev, regmap); 37 38 } 38 39 39 40 static const struct spi_device_id adxl345_spi_id[] = {