static int mma8452_change_config(struct mma8452_data *data, u8 reg, u8 val) { int ret; mutex_lock(&data->lock); /* config can only be changed when in standby */ ret = mma8452_standby(data); if (ret < 0) goto fail; ret = i2c_smbus_write_byte_data(data->client, reg, val); if (ret < 0) goto fail; ret = mma8452_active(data); if (ret < 0) goto fail; ret = 0; fail: mutex_unlock(&data->lock); return ret; }
static int mma8452_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct mma8452_data *data = iio_priv(indio_dev); int ret, sleep_val; ret = mma8452_active(data); if (ret < 0) return ret; ret = mma8452_get_odr_index(data); sleep_val = 1000 / mma8452_samp_freq[ret][0]; if (sleep_val < 20) usleep_range(sleep_val * 1000, 20000); else msleep_interruptible(sleep_val); return 0; }
static int mma8452_resume(struct device *dev) { return mma8452_active(iio_priv(i2c_get_clientdata( to_i2c_client(dev)))); }