Skip to content

Commit

Permalink
iio: accel: adxl345: Extract adxl345_powerup() helper
Browse files Browse the repository at this point in the history
For the sake of symmetry and possible reuse in the future
extract adxl435_powerup() helper.

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-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Andy Shevchenko authored and Jonathan Cameron committed Feb 26, 2022
1 parent b9493d5 commit 5b4c63f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/iio/accel/adxl345_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ static const struct iio_info adxl345_info = {
.write_raw_get_fmt = adxl345_write_raw_get_fmt,
};

static int adxl345_powerup(void *regmap)
{
return regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_MEASURE);
}

static void adxl345_powerdown(void *regmap)
{
regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY);
Expand Down Expand Up @@ -265,8 +270,7 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap)
indio_dev->num_channels = ARRAY_SIZE(adxl345_channels);

/* Enable measurement mode */
ret = regmap_write(data->regmap, ADXL345_REG_POWER_CTL,
ADXL345_POWER_CTL_MEASURE);
ret = adxl345_powerup(data->regmap);
if (ret < 0)
return dev_err_probe(dev, ret, "Failed to enable measurement mode\n");

Expand Down

0 comments on commit 5b4c63f

Please sign in to comment.