Commit 62248758 authored by Peter Meerwald's avatar Peter Meerwald Committed by Jonathan Cameron

staging:iio:hmc5843: Rename _configure() to _set_mode()

and be consistent with other setter functions in that first argument
is hmc5843_data
Signed-off-by: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7183de94
...@@ -131,12 +131,18 @@ struct hmc5843_data { ...@@ -131,12 +131,18 @@ struct hmc5843_data {
}; };
/* The lower two bits contain the current conversion mode */ /* The lower two bits contain the current conversion mode */
static s32 hmc5843_configure(struct i2c_client *client, static s32 hmc5843_set_mode(struct hmc5843_data *data, u8 operating_mode)
u8 operating_mode)
{ {
return i2c_smbus_write_byte_data(client, int ret;
HMC5843_MODE_REG,
mutex_lock(&data->lock);
ret = i2c_smbus_write_byte_data(data->client, HMC5843_MODE_REG,
operating_mode & HMC5843_MODE_MASK); operating_mode & HMC5843_MODE_MASK);
if (ret >= 0)
data->operating_mode = operating_mode;
mutex_unlock(&data->lock);
return ret;
} }
static int hmc5843_wait_measurement(struct hmc5843_data *data) static int hmc5843_wait_measurement(struct hmc5843_data *data)
...@@ -495,7 +501,7 @@ static void hmc5843_init(struct hmc5843_data *data) ...@@ -495,7 +501,7 @@ static void hmc5843_init(struct hmc5843_data *data)
{ {
hmc5843_set_meas_conf(data, HMC5843_MEAS_CONF_NORMAL); hmc5843_set_meas_conf(data, HMC5843_MEAS_CONF_NORMAL);
hmc5843_set_rate(data, HMC5843_RATE_DEFAULT); hmc5843_set_rate(data, HMC5843_RATE_DEFAULT);
hmc5843_configure(data->client, HMC5843_MODE_CONVERSION_CONTINUOUS); hmc5843_set_mode(data, HMC5843_MODE_CONVERSION_CONTINUOUS);
i2c_smbus_write_byte_data(data->client, HMC5843_CONFIG_REG_B, i2c_smbus_write_byte_data(data->client, HMC5843_CONFIG_REG_B,
HMC5843_RANGE_GAIN_DEFAULT); HMC5843_RANGE_GAIN_DEFAULT);
} }
...@@ -562,7 +568,7 @@ static int hmc5843_remove(struct i2c_client *client) ...@@ -562,7 +568,7 @@ static int hmc5843_remove(struct i2c_client *client)
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
/* sleep mode to save power */ /* sleep mode to save power */
hmc5843_configure(client, HMC5843_MODE_SLEEP); hmc5843_set_mode(iio_priv(indio_dev), HMC5843_MODE_SLEEP);
return 0; return 0;
} }
...@@ -570,9 +576,10 @@ static int hmc5843_remove(struct i2c_client *client) ...@@ -570,9 +576,10 @@ static int hmc5843_remove(struct i2c_client *client)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int hmc5843_suspend(struct device *dev) static int hmc5843_suspend(struct device *dev)
{ {
hmc5843_configure(to_i2c_client(dev), HMC5843_MODE_SLEEP); struct hmc5843_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev)));
return 0; return hmc5843_set_mode(data, HMC5843_MODE_SLEEP);
} }
static int hmc5843_resume(struct device *dev) static int hmc5843_resume(struct device *dev)
...@@ -580,9 +587,7 @@ static int hmc5843_resume(struct device *dev) ...@@ -580,9 +587,7 @@ static int hmc5843_resume(struct device *dev)
struct hmc5843_data *data = iio_priv(i2c_get_clientdata( struct hmc5843_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev))); to_i2c_client(dev)));
hmc5843_configure(data->client, data->operating_mode); return hmc5843_set_mode(data, HMC5843_MODE_CONVERSION_CONTINUOUS);
return 0;
} }
static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_suspend, hmc5843_resume); static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_suspend, hmc5843_resume);
......
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