Commit 0ef4c311 authored by Alison Schofield's avatar Alison Schofield Committed by Jonathan Cameron

iio: accel: bmc150: use regmap to retrieve struct device

Driver includes struct regmap and struct device in its global data.
Remove the struct device and use regmap API to retrieve device info.

Patch created using Coccinelle plus manual edits.
Signed-off-by: default avatarAlison Schofield <amsfield22@gmail.com>
Reviewed-by: default avatarIrina Tirdea <irina.tirdea@intel.com>
Reviewed-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent dfd2ab8d
...@@ -188,7 +188,6 @@ enum bmc150_accel_trigger_id { ...@@ -188,7 +188,6 @@ enum bmc150_accel_trigger_id {
struct bmc150_accel_data { struct bmc150_accel_data {
struct regmap *regmap; struct regmap *regmap;
struct device *dev;
int irq; int irq;
struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
atomic_t active_intr; atomic_t active_intr;
...@@ -257,6 +256,7 @@ static int bmc150_accel_set_mode(struct bmc150_accel_data *data, ...@@ -257,6 +256,7 @@ static int bmc150_accel_set_mode(struct bmc150_accel_data *data,
enum bmc150_power_modes mode, enum bmc150_power_modes mode,
int dur_us) int dur_us)
{ {
struct device *dev = regmap_get_device(data->regmap);
int i; int i;
int ret; int ret;
u8 lpw_bits; u8 lpw_bits;
...@@ -280,11 +280,11 @@ static int bmc150_accel_set_mode(struct bmc150_accel_data *data, ...@@ -280,11 +280,11 @@ static int bmc150_accel_set_mode(struct bmc150_accel_data *data,
lpw_bits = mode << BMC150_ACCEL_PMU_MODE_SHIFT; lpw_bits = mode << BMC150_ACCEL_PMU_MODE_SHIFT;
lpw_bits |= (dur_val << BMC150_ACCEL_PMU_BIT_SLEEP_DUR_SHIFT); lpw_bits |= (dur_val << BMC150_ACCEL_PMU_BIT_SLEEP_DUR_SHIFT);
dev_dbg(data->dev, "Set Mode bits %x\n", lpw_bits); dev_dbg(dev, "Set Mode bits %x\n", lpw_bits);
ret = regmap_write(data->regmap, BMC150_ACCEL_REG_PMU_LPW, lpw_bits); ret = regmap_write(data->regmap, BMC150_ACCEL_REG_PMU_LPW, lpw_bits);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error writing reg_pmu_lpw\n"); dev_err(dev, "Error writing reg_pmu_lpw\n");
return ret; return ret;
} }
...@@ -317,23 +317,24 @@ static int bmc150_accel_set_bw(struct bmc150_accel_data *data, int val, ...@@ -317,23 +317,24 @@ static int bmc150_accel_set_bw(struct bmc150_accel_data *data, int val,
static int bmc150_accel_update_slope(struct bmc150_accel_data *data) static int bmc150_accel_update_slope(struct bmc150_accel_data *data)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret; int ret;
ret = regmap_write(data->regmap, BMC150_ACCEL_REG_INT_6, ret = regmap_write(data->regmap, BMC150_ACCEL_REG_INT_6,
data->slope_thres); data->slope_thres);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error writing reg_int_6\n"); dev_err(dev, "Error writing reg_int_6\n");
return ret; return ret;
} }
ret = regmap_update_bits(data->regmap, BMC150_ACCEL_REG_INT_5, ret = regmap_update_bits(data->regmap, BMC150_ACCEL_REG_INT_5,
BMC150_ACCEL_SLOPE_DUR_MASK, data->slope_dur); BMC150_ACCEL_SLOPE_DUR_MASK, data->slope_dur);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error updating reg_int_5\n"); dev_err(dev, "Error updating reg_int_5\n");
return ret; return ret;
} }
dev_dbg(data->dev, "%s: %x %x\n", __func__, data->slope_thres, dev_dbg(dev, "%s: %x %x\n", __func__, data->slope_thres,
data->slope_dur); data->slope_dur);
return ret; return ret;
...@@ -379,20 +380,21 @@ static int bmc150_accel_get_startup_times(struct bmc150_accel_data *data) ...@@ -379,20 +380,21 @@ static int bmc150_accel_get_startup_times(struct bmc150_accel_data *data)
static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret; int ret;
if (on) { if (on) {
ret = pm_runtime_get_sync(data->dev); ret = pm_runtime_get_sync(dev);
} else { } else {
pm_runtime_mark_last_busy(data->dev); pm_runtime_mark_last_busy(dev);
ret = pm_runtime_put_autosuspend(data->dev); ret = pm_runtime_put_autosuspend(dev);
} }
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev,
"Failed: bmc150_accel_set_power_state for %d\n", on); "Failed: bmc150_accel_set_power_state for %d\n", on);
if (on) if (on)
pm_runtime_put_noidle(data->dev); pm_runtime_put_noidle(dev);
return ret; return ret;
} }
...@@ -446,6 +448,7 @@ static void bmc150_accel_interrupts_setup(struct iio_dev *indio_dev, ...@@ -446,6 +448,7 @@ static void bmc150_accel_interrupts_setup(struct iio_dev *indio_dev,
static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i, static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
bool state) bool state)
{ {
struct device *dev = regmap_get_device(data->regmap);
struct bmc150_accel_interrupt *intr = &data->interrupts[i]; struct bmc150_accel_interrupt *intr = &data->interrupts[i];
const struct bmc150_accel_interrupt_info *info = intr->info; const struct bmc150_accel_interrupt_info *info = intr->info;
int ret; int ret;
...@@ -475,7 +478,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i, ...@@ -475,7 +478,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
ret = regmap_update_bits(data->regmap, info->map_reg, info->map_bitmask, ret = regmap_update_bits(data->regmap, info->map_reg, info->map_bitmask,
(state ? info->map_bitmask : 0)); (state ? info->map_bitmask : 0));
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error updating reg_int_map\n"); dev_err(dev, "Error updating reg_int_map\n");
goto out_fix_power_state; goto out_fix_power_state;
} }
...@@ -483,7 +486,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i, ...@@ -483,7 +486,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
ret = regmap_update_bits(data->regmap, info->en_reg, info->en_bitmask, ret = regmap_update_bits(data->regmap, info->en_reg, info->en_bitmask,
(state ? info->en_bitmask : 0)); (state ? info->en_bitmask : 0));
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error updating reg_int_en\n"); dev_err(dev, "Error updating reg_int_en\n");
goto out_fix_power_state; goto out_fix_power_state;
} }
...@@ -501,6 +504,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i, ...@@ -501,6 +504,7 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val) static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret, i; int ret, i;
for (i = 0; i < ARRAY_SIZE(data->chip_info->scale_table); ++i) { for (i = 0; i < ARRAY_SIZE(data->chip_info->scale_table); ++i) {
...@@ -509,8 +513,7 @@ static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val) ...@@ -509,8 +513,7 @@ static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val)
BMC150_ACCEL_REG_PMU_RANGE, BMC150_ACCEL_REG_PMU_RANGE,
data->chip_info->scale_table[i].reg_range); data->chip_info->scale_table[i].reg_range);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev, "Error writing pmu_range\n");
"Error writing pmu_range\n");
return ret; return ret;
} }
...@@ -524,6 +527,7 @@ static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val) ...@@ -524,6 +527,7 @@ static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val)
static int bmc150_accel_get_temp(struct bmc150_accel_data *data, int *val) static int bmc150_accel_get_temp(struct bmc150_accel_data *data, int *val)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret; int ret;
unsigned int value; unsigned int value;
...@@ -531,7 +535,7 @@ static int bmc150_accel_get_temp(struct bmc150_accel_data *data, int *val) ...@@ -531,7 +535,7 @@ static int bmc150_accel_get_temp(struct bmc150_accel_data *data, int *val)
ret = regmap_read(data->regmap, BMC150_ACCEL_REG_TEMP, &value); ret = regmap_read(data->regmap, BMC150_ACCEL_REG_TEMP, &value);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error reading reg_temp\n"); dev_err(dev, "Error reading reg_temp\n");
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
} }
...@@ -546,6 +550,7 @@ static int bmc150_accel_get_axis(struct bmc150_accel_data *data, ...@@ -546,6 +550,7 @@ static int bmc150_accel_get_axis(struct bmc150_accel_data *data,
struct iio_chan_spec const *chan, struct iio_chan_spec const *chan,
int *val) int *val)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret; int ret;
int axis = chan->scan_index; int axis = chan->scan_index;
unsigned int raw_val; unsigned int raw_val;
...@@ -560,7 +565,7 @@ static int bmc150_accel_get_axis(struct bmc150_accel_data *data, ...@@ -560,7 +565,7 @@ static int bmc150_accel_get_axis(struct bmc150_accel_data *data,
ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_AXIS_TO_REG(axis), ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_AXIS_TO_REG(axis),
&raw_val, 2); &raw_val, 2);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error reading axis %d\n", axis); dev_err(dev, "Error reading axis %d\n", axis);
bmc150_accel_set_power_state(data, false); bmc150_accel_set_power_state(data, false);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
...@@ -832,6 +837,7 @@ static int bmc150_accel_set_watermark(struct iio_dev *indio_dev, unsigned val) ...@@ -832,6 +837,7 @@ static int bmc150_accel_set_watermark(struct iio_dev *indio_dev, unsigned val)
static int bmc150_accel_fifo_transfer(struct bmc150_accel_data *data, static int bmc150_accel_fifo_transfer(struct bmc150_accel_data *data,
char *buffer, int samples) char *buffer, int samples)
{ {
struct device *dev = regmap_get_device(data->regmap);
int sample_length = 3 * 2; int sample_length = 3 * 2;
int ret; int ret;
int total_length = samples * sample_length; int total_length = samples * sample_length;
...@@ -855,7 +861,8 @@ static int bmc150_accel_fifo_transfer(struct bmc150_accel_data *data, ...@@ -855,7 +861,8 @@ static int bmc150_accel_fifo_transfer(struct bmc150_accel_data *data,
} }
if (ret) if (ret)
dev_err(data->dev, "Error transferring data from fifo in single steps of %zu\n", dev_err(dev,
"Error transferring data from fifo in single steps of %zu\n",
step); step);
return ret; return ret;
...@@ -865,6 +872,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev, ...@@ -865,6 +872,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
unsigned samples, bool irq) unsigned samples, bool irq)
{ {
struct bmc150_accel_data *data = iio_priv(indio_dev); struct bmc150_accel_data *data = iio_priv(indio_dev);
struct device *dev = regmap_get_device(data->regmap);
int ret, i; int ret, i;
u8 count; u8 count;
u16 buffer[BMC150_ACCEL_FIFO_LENGTH * 3]; u16 buffer[BMC150_ACCEL_FIFO_LENGTH * 3];
...@@ -874,7 +882,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev, ...@@ -874,7 +882,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
ret = regmap_read(data->regmap, BMC150_ACCEL_REG_FIFO_STATUS, &val); ret = regmap_read(data->regmap, BMC150_ACCEL_REG_FIFO_STATUS, &val);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error reading reg_fifo_status\n"); dev_err(dev, "Error reading reg_fifo_status\n");
return ret; return ret;
} }
...@@ -1136,6 +1144,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig) ...@@ -1136,6 +1144,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig)
{ {
struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig); struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig);
struct bmc150_accel_data *data = t->data; struct bmc150_accel_data *data = t->data;
struct device *dev = regmap_get_device(data->regmap);
int ret; int ret;
/* new data interrupts don't need ack */ /* new data interrupts don't need ack */
...@@ -1149,8 +1158,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig) ...@@ -1149,8 +1158,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig)
BMC150_ACCEL_INT_MODE_LATCH_RESET); BMC150_ACCEL_INT_MODE_LATCH_RESET);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev, "Error writing reg_int_rst_latch\n");
"Error writing reg_int_rst_latch\n");
return ret; return ret;
} }
...@@ -1201,13 +1209,14 @@ static const struct iio_trigger_ops bmc150_accel_trigger_ops = { ...@@ -1201,13 +1209,14 @@ static const struct iio_trigger_ops bmc150_accel_trigger_ops = {
static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev) static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
{ {
struct bmc150_accel_data *data = iio_priv(indio_dev); struct bmc150_accel_data *data = iio_priv(indio_dev);
struct device *dev = regmap_get_device(data->regmap);
int dir; int dir;
int ret; int ret;
unsigned int val; unsigned int val;
ret = regmap_read(data->regmap, BMC150_ACCEL_REG_INT_STATUS_2, &val); ret = regmap_read(data->regmap, BMC150_ACCEL_REG_INT_STATUS_2, &val);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error reading reg_int_status_2\n"); dev_err(dev, "Error reading reg_int_status_2\n");
return ret; return ret;
} }
...@@ -1250,6 +1259,7 @@ static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private) ...@@ -1250,6 +1259,7 @@ static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private)
{ {
struct iio_dev *indio_dev = private; struct iio_dev *indio_dev = private;
struct bmc150_accel_data *data = iio_priv(indio_dev); struct bmc150_accel_data *data = iio_priv(indio_dev);
struct device *dev = regmap_get_device(data->regmap);
bool ack = false; bool ack = false;
int ret; int ret;
...@@ -1273,7 +1283,7 @@ static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private) ...@@ -1273,7 +1283,7 @@ static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private)
BMC150_ACCEL_INT_MODE_LATCH_INT | BMC150_ACCEL_INT_MODE_LATCH_INT |
BMC150_ACCEL_INT_MODE_LATCH_RESET); BMC150_ACCEL_INT_MODE_LATCH_RESET);
if (ret) if (ret)
dev_err(data->dev, "Error writing reg_int_rst_latch\n"); dev_err(dev, "Error writing reg_int_rst_latch\n");
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
} else { } else {
...@@ -1344,13 +1354,14 @@ static void bmc150_accel_unregister_triggers(struct bmc150_accel_data *data, ...@@ -1344,13 +1354,14 @@ static void bmc150_accel_unregister_triggers(struct bmc150_accel_data *data,
static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev, static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev,
struct bmc150_accel_data *data) struct bmc150_accel_data *data)
{ {
struct device *dev = regmap_get_device(data->regmap);
int i, ret; int i, ret;
for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) { for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) {
struct bmc150_accel_trigger *t = &data->triggers[i]; struct bmc150_accel_trigger *t = &data->triggers[i];
t->indio_trig = devm_iio_trigger_alloc(data->dev, t->indio_trig = devm_iio_trigger_alloc(dev,
bmc150_accel_triggers[i].name, bmc150_accel_triggers[i].name,
indio_dev->name, indio_dev->name,
indio_dev->id); indio_dev->id);
if (!t->indio_trig) { if (!t->indio_trig) {
...@@ -1358,7 +1369,7 @@ static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev, ...@@ -1358,7 +1369,7 @@ static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev,
break; break;
} }
t->indio_trig->dev.parent = data->dev; t->indio_trig->dev.parent = dev;
t->indio_trig->ops = &bmc150_accel_trigger_ops; t->indio_trig->ops = &bmc150_accel_trigger_ops;
t->intr = bmc150_accel_triggers[i].intr; t->intr = bmc150_accel_triggers[i].intr;
t->data = data; t->data = data;
...@@ -1382,12 +1393,13 @@ static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev, ...@@ -1382,12 +1393,13 @@ static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev,
static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data) static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data)
{ {
struct device *dev = regmap_get_device(data->regmap);
u8 reg = BMC150_ACCEL_REG_FIFO_CONFIG1; u8 reg = BMC150_ACCEL_REG_FIFO_CONFIG1;
int ret; int ret;
ret = regmap_write(data->regmap, reg, data->fifo_mode); ret = regmap_write(data->regmap, reg, data->fifo_mode);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error writing reg_fifo_config1\n"); dev_err(dev, "Error writing reg_fifo_config1\n");
return ret; return ret;
} }
...@@ -1397,7 +1409,7 @@ static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data) ...@@ -1397,7 +1409,7 @@ static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data)
ret = regmap_write(data->regmap, BMC150_ACCEL_REG_FIFO_CONFIG0, ret = regmap_write(data->regmap, BMC150_ACCEL_REG_FIFO_CONFIG0,
data->watermark); data->watermark);
if (ret < 0) if (ret < 0)
dev_err(data->dev, "Error writing reg_fifo_config0\n"); dev_err(dev, "Error writing reg_fifo_config0\n");
return ret; return ret;
} }
...@@ -1481,17 +1493,17 @@ static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = { ...@@ -1481,17 +1493,17 @@ static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = {
static int bmc150_accel_chip_init(struct bmc150_accel_data *data) static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
{ {
struct device *dev = regmap_get_device(data->regmap);
int ret, i; int ret, i;
unsigned int val; unsigned int val;
ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val); ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev, "Error: Reading chip id\n");
"Error: Reading chip id\n");
return ret; return ret;
} }
dev_dbg(data->dev, "Chip Id %x\n", val); dev_dbg(dev, "Chip Id %x\n", val);
for (i = 0; i < ARRAY_SIZE(bmc150_accel_chip_info_tbl); i++) { for (i = 0; i < ARRAY_SIZE(bmc150_accel_chip_info_tbl); i++) {
if (bmc150_accel_chip_info_tbl[i].chip_id == val) { if (bmc150_accel_chip_info_tbl[i].chip_id == val) {
data->chip_info = &bmc150_accel_chip_info_tbl[i]; data->chip_info = &bmc150_accel_chip_info_tbl[i];
...@@ -1500,7 +1512,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) ...@@ -1500,7 +1512,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
} }
if (!data->chip_info) { if (!data->chip_info) {
dev_err(data->dev, "Invalid chip %x\n", val); dev_err(dev, "Invalid chip %x\n", val);
return -ENODEV; return -ENODEV;
} }
...@@ -1517,8 +1529,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) ...@@ -1517,8 +1529,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
ret = regmap_write(data->regmap, BMC150_ACCEL_REG_PMU_RANGE, ret = regmap_write(data->regmap, BMC150_ACCEL_REG_PMU_RANGE,
BMC150_ACCEL_DEF_RANGE_4G); BMC150_ACCEL_DEF_RANGE_4G);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev, "Error writing reg_pmu_range\n");
"Error writing reg_pmu_range\n");
return ret; return ret;
} }
...@@ -1536,8 +1547,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) ...@@ -1536,8 +1547,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
BMC150_ACCEL_INT_MODE_LATCH_INT | BMC150_ACCEL_INT_MODE_LATCH_INT |
BMC150_ACCEL_INT_MODE_LATCH_RESET); BMC150_ACCEL_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, dev_err(dev, "Error writing reg_int_rst_latch\n");
"Error writing reg_int_rst_latch\n");
return ret; return ret;
} }
...@@ -1557,7 +1567,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, ...@@ -1557,7 +1567,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
data = iio_priv(indio_dev); data = iio_priv(indio_dev);
dev_set_drvdata(dev, indio_dev); dev_set_drvdata(dev, indio_dev);
data->dev = dev;
data->irq = irq; data->irq = irq;
data->regmap = regmap; data->regmap = regmap;
...@@ -1581,13 +1590,13 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, ...@@ -1581,13 +1590,13 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
bmc150_accel_trigger_handler, bmc150_accel_trigger_handler,
&bmc150_accel_buffer_ops); &bmc150_accel_buffer_ops);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Failed: iio triggered buffer setup\n"); dev_err(dev, "Failed: iio triggered buffer setup\n");
return ret; return ret;
} }
if (data->irq > 0) { if (data->irq > 0) {
ret = devm_request_threaded_irq( ret = devm_request_threaded_irq(
data->dev, data->irq, dev, data->irq,
bmc150_accel_irq_handler, bmc150_accel_irq_handler,
bmc150_accel_irq_thread_handler, bmc150_accel_irq_thread_handler,
IRQF_TRIGGER_RISING, IRQF_TRIGGER_RISING,
...@@ -1605,7 +1614,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, ...@@ -1605,7 +1614,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
ret = regmap_write(data->regmap, BMC150_ACCEL_REG_INT_RST_LATCH, ret = regmap_write(data->regmap, BMC150_ACCEL_REG_INT_RST_LATCH,
BMC150_ACCEL_INT_MODE_LATCH_RESET); BMC150_ACCEL_INT_MODE_LATCH_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(data->dev, "Error writing reg_int_rst_latch\n"); dev_err(dev, "Error writing reg_int_rst_latch\n");
goto err_buffer_cleanup; goto err_buffer_cleanup;
} }
...@@ -1654,9 +1663,9 @@ int bmc150_accel_core_remove(struct device *dev) ...@@ -1654,9 +1663,9 @@ int bmc150_accel_core_remove(struct device *dev)
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
pm_runtime_disable(data->dev); pm_runtime_disable(dev);
pm_runtime_set_suspended(data->dev); pm_runtime_set_suspended(dev);
pm_runtime_put_noidle(data->dev); pm_runtime_put_noidle(dev);
bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
...@@ -1705,7 +1714,7 @@ static int bmc150_accel_runtime_suspend(struct device *dev) ...@@ -1705,7 +1714,7 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
struct bmc150_accel_data *data = iio_priv(indio_dev); struct bmc150_accel_data *data = iio_priv(indio_dev);
int ret; int ret;
dev_dbg(data->dev, __func__); dev_dbg(dev, __func__);
ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
if (ret < 0) if (ret < 0)
return -EAGAIN; return -EAGAIN;
...@@ -1720,7 +1729,7 @@ static int bmc150_accel_runtime_resume(struct device *dev) ...@@ -1720,7 +1729,7 @@ static int bmc150_accel_runtime_resume(struct device *dev)
int ret; int ret;
int sleep_val; int sleep_val;
dev_dbg(data->dev, __func__); dev_dbg(dev, __func__);
ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0); ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment