forked from Minki/linux
staging:iio:accel: Use dev_to_iio_dev()
Replace open-coded instances of getting a iio_dev struct from a device struct with dev_to_iio_dev(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
62c5183971
commit
4b522ce709
@ -171,7 +171,7 @@ static ssize_t adis16201_write_reset(struct device *dev,
|
||||
ret = strtobool(buf, &res);
|
||||
if (ret || !res)
|
||||
return ret;
|
||||
return adis16201_reset(dev_get_drvdata(dev));
|
||||
return adis16201_reset(dev_to_iio_dev(dev));
|
||||
}
|
||||
|
||||
int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
|
||||
|
@ -182,7 +182,7 @@ static ssize_t adis16203_write_reset(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
if (len < 1)
|
||||
return -EINVAL;
|
||||
switch (buf[0]) {
|
||||
|
@ -173,7 +173,7 @@ static ssize_t adis16204_read_14bit_signed(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
s16 val = 0;
|
||||
ssize_t ret;
|
||||
@ -211,7 +211,7 @@ static ssize_t adis16204_write_reset(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
if (len < 1)
|
||||
return -EINVAL;
|
||||
|
@ -157,7 +157,7 @@ static ssize_t adis16209_write_reset(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
if (len < 1)
|
||||
return -EINVAL;
|
||||
|
@ -145,7 +145,7 @@ static ssize_t adis16220_read_16bit(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
ssize_t ret;
|
||||
s16 val = 0;
|
||||
|
||||
@ -164,7 +164,7 @@ static ssize_t adis16220_write_16bit(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
int ret;
|
||||
u16 val;
|
||||
@ -208,7 +208,7 @@ static ssize_t adis16220_write_reset(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
bool val;
|
||||
int ret;
|
||||
|
||||
@ -228,7 +228,7 @@ static ssize_t adis16220_write_capture(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
bool val;
|
||||
int ret;
|
||||
|
||||
@ -393,7 +393,7 @@ static ssize_t adis16220_accel_bin_read(struct file *filp, struct kobject *kobj,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = container_of(kobj, struct device, kobj);
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
return adis16220_capture_buffer_read(indio_dev, buf,
|
||||
off, count,
|
||||
@ -415,7 +415,7 @@ static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = container_of(kobj, struct device, kobj);
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
return adis16220_capture_buffer_read(indio_dev, buf,
|
||||
off, count,
|
||||
@ -437,7 +437,7 @@ static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj,
|
||||
size_t count)
|
||||
{
|
||||
struct device *dev = container_of(kobj, struct device, kobj);
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
return adis16220_capture_buffer_read(indio_dev, buf,
|
||||
off, count,
|
||||
|
@ -154,7 +154,7 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
|
||||
char *buf,
|
||||
unsigned bits)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
int ret;
|
||||
s16 val = 0;
|
||||
unsigned shift = 16 - bits;
|
||||
@ -177,7 +177,7 @@ static ssize_t adis16240_read_12bit_signed(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
ssize_t ret;
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
/* Take the iio_dev status lock */
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
@ -203,7 +203,7 @@ static ssize_t adis16240_write_reset(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
if (len < 1)
|
||||
return -EINVAL;
|
||||
|
@ -297,7 +297,7 @@ static ssize_t lis3l02dq_read_frequency(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
int ret, len = 0;
|
||||
s8 t;
|
||||
ret = lis3l02dq_spi_read_reg_8(indio_dev,
|
||||
@ -328,7 +328,7 @@ static ssize_t lis3l02dq_write_frequency(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
u8 t;
|
||||
|
@ -241,7 +241,7 @@ error_ret:
|
||||
static int sca3000_check_status(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
@ -268,7 +268,7 @@ static ssize_t sca3000_show_rev(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
int len = 0, ret;
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
@ -296,7 +296,7 @@ sca3000_show_available_measurement_modes(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int len = 0;
|
||||
|
||||
@ -328,7 +328,7 @@ sca3000_show_measurement_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int len = 0, ret;
|
||||
|
||||
@ -379,7 +379,7 @@ sca3000_store_measurement_mode(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
u8 mask = 0x03;
|
||||
@ -517,7 +517,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int len = 0, ret, val;
|
||||
|
||||
@ -588,7 +588,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int ret, len = 0, base_freq = 0, val;
|
||||
|
||||
@ -630,7 +630,7 @@ static ssize_t sca3000_set_frequency(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int ret, base_freq = 0;
|
||||
int ctrlval;
|
||||
@ -690,7 +690,7 @@ static ssize_t sca3000_read_temp(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
int val;
|
||||
@ -911,7 +911,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
int ret, len;
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
int val;
|
||||
|
||||
@ -939,7 +939,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
long val;
|
||||
int ret;
|
||||
|
@ -157,7 +157,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev,
|
||||
{
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
int ret, val;
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
@ -178,7 +178,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev,
|
||||
const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
long val;
|
||||
@ -219,7 +219,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct sca3000_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "0.%06d\n", 4*st->info->scale);
|
||||
|
Loading…
Reference in New Issue
Block a user