提交 e53f5ac5 编写于 作者: L Lars-Peter Clausen 提交者: Greg Kroah-Hartman

iio: 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: NLars-Peter Clausen <lars@metafoo.de>
Acked-by: NJonathan Cameron <jic23@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 7a7913f1
...@@ -105,7 +105,7 @@ static ssize_t iio_scan_el_show(struct device *dev, ...@@ -105,7 +105,7 @@ static ssize_t iio_scan_el_show(struct device *dev,
char *buf) char *buf)
{ {
int ret; int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
ret = test_bit(to_iio_dev_attr(attr)->address, ret = test_bit(to_iio_dev_attr(attr)->address,
indio_dev->buffer->scan_mask); indio_dev->buffer->scan_mask);
...@@ -126,7 +126,7 @@ static ssize_t iio_scan_el_store(struct device *dev, ...@@ -126,7 +126,7 @@ static ssize_t iio_scan_el_store(struct device *dev,
{ {
int ret; int ret;
bool state; bool state;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
...@@ -162,7 +162,7 @@ static ssize_t iio_scan_el_ts_show(struct device *dev, ...@@ -162,7 +162,7 @@ static ssize_t iio_scan_el_ts_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp); return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp);
} }
...@@ -172,7 +172,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, ...@@ -172,7 +172,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev,
size_t len) size_t len)
{ {
int ret; int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
bool state; bool state;
ret = strtobool(buf, &state); ret = strtobool(buf, &state);
...@@ -352,7 +352,7 @@ ssize_t iio_buffer_read_length(struct device *dev, ...@@ -352,7 +352,7 @@ ssize_t iio_buffer_read_length(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
if (buffer->access->get_length) if (buffer->access->get_length)
...@@ -370,7 +370,7 @@ ssize_t iio_buffer_write_length(struct device *dev, ...@@ -370,7 +370,7 @@ ssize_t iio_buffer_write_length(struct device *dev,
{ {
int ret; int ret;
ulong val; ulong val;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
ret = strict_strtoul(buf, 10, &val); ret = strict_strtoul(buf, 10, &val);
...@@ -403,7 +403,7 @@ ssize_t iio_buffer_store_enable(struct device *dev, ...@@ -403,7 +403,7 @@ ssize_t iio_buffer_store_enable(struct device *dev,
int ret; int ret;
bool requested_state, current_state; bool requested_state, current_state;
int previous_mode; int previous_mode;
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
...@@ -489,7 +489,7 @@ ssize_t iio_buffer_show_enable(struct device *dev, ...@@ -489,7 +489,7 @@ ssize_t iio_buffer_show_enable(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return sprintf(buf, "%d\n", iio_buffer_enabled(indio_dev)); return sprintf(buf, "%d\n", iio_buffer_enabled(indio_dev));
} }
EXPORT_SYMBOL(iio_buffer_show_enable); EXPORT_SYMBOL(iio_buffer_show_enable);
......
...@@ -265,7 +265,7 @@ static ssize_t iio_read_channel_ext_info(struct device *dev, ...@@ -265,7 +265,7 @@ static ssize_t iio_read_channel_ext_info(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
const struct iio_chan_spec_ext_info *ext_info; const struct iio_chan_spec_ext_info *ext_info;
...@@ -279,7 +279,7 @@ static ssize_t iio_write_channel_ext_info(struct device *dev, ...@@ -279,7 +279,7 @@ static ssize_t iio_write_channel_ext_info(struct device *dev,
const char *buf, const char *buf,
size_t len) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
const struct iio_chan_spec_ext_info *ext_info; const struct iio_chan_spec_ext_info *ext_info;
...@@ -293,7 +293,7 @@ static ssize_t iio_read_channel_info(struct device *dev, ...@@ -293,7 +293,7 @@ static ssize_t iio_read_channel_info(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int val, val2; int val, val2;
bool scale_db = false; bool scale_db = false;
...@@ -330,7 +330,7 @@ static ssize_t iio_write_channel_info(struct device *dev, ...@@ -330,7 +330,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
const char *buf, const char *buf,
size_t len) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret, integer = 0, fract = 0, fract_mult = 100000; int ret, integer = 0, fract = 0, fract_mult = 100000;
bool integer_part = true, negative = false; bool integer_part = true, negative = false;
...@@ -638,7 +638,7 @@ static ssize_t iio_show_dev_name(struct device *dev, ...@@ -638,7 +638,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return sprintf(buf, "%s\n", indio_dev->name); return sprintf(buf, "%s\n", indio_dev->name);
} }
...@@ -724,7 +724,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev) ...@@ -724,7 +724,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
static void iio_dev_release(struct device *device) static void iio_dev_release(struct device *device)
{ {
struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev); struct iio_dev *indio_dev = dev_to_iio_dev(device);
cdev_del(&indio_dev->chrdev); cdev_del(&indio_dev->chrdev);
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
iio_device_unregister_trigger_consumer(indio_dev); iio_device_unregister_trigger_consumer(indio_dev);
......
...@@ -186,7 +186,7 @@ static ssize_t iio_ev_state_store(struct device *dev, ...@@ -186,7 +186,7 @@ static ssize_t iio_ev_state_store(struct device *dev,
const char *buf, const char *buf,
size_t len) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret; int ret;
bool val; bool val;
...@@ -205,7 +205,7 @@ static ssize_t iio_ev_state_show(struct device *dev, ...@@ -205,7 +205,7 @@ static ssize_t iio_ev_state_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int val = indio_dev->info->read_event_config(indio_dev, int val = indio_dev->info->read_event_config(indio_dev,
this_attr->address); this_attr->address);
...@@ -220,7 +220,7 @@ static ssize_t iio_ev_value_show(struct device *dev, ...@@ -220,7 +220,7 @@ static ssize_t iio_ev_value_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int val, ret; int val, ret;
...@@ -237,7 +237,7 @@ static ssize_t iio_ev_value_store(struct device *dev, ...@@ -237,7 +237,7 @@ static ssize_t iio_ev_value_store(struct device *dev,
const char *buf, const char *buf,
size_t len) 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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
unsigned long val; unsigned long val;
int ret; int ret;
......
...@@ -310,7 +310,7 @@ static ssize_t iio_trigger_read_current(struct device *dev, ...@@ -310,7 +310,7 @@ static ssize_t iio_trigger_read_current(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (indio_dev->trig) if (indio_dev->trig)
return sprintf(buf, "%s\n", indio_dev->trig->name); return sprintf(buf, "%s\n", indio_dev->trig->name);
...@@ -329,7 +329,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, ...@@ -329,7 +329,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_trigger *oldtrig = indio_dev->trig; struct iio_trigger *oldtrig = indio_dev->trig;
struct iio_trigger *trig; struct iio_trigger *trig;
int ret; int ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册