Commit f8c6f4e9 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:core:naming: dev_info to indio_dev for consistency

We had a random missmatch of these two.  Lets pick the most common
and get rid of the other.  This patch covers the core.  Others
will clean up the drivers.
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ee760ab2
......@@ -120,10 +120,10 @@ struct iio_buffer {
/**
* iio_buffer_init() - Initialize the buffer structure
* @buffer: buffer to be initialized
* @dev_info: the iio device the buffer is assocated with
* @indio_dev: the iio device the buffer is assocated with
**/
void iio_buffer_init(struct iio_buffer *buffer,
struct iio_dev *dev_info);
struct iio_dev *indio_dev);
void iio_buffer_deinit(struct iio_buffer *buffer);
......
......@@ -323,23 +323,23 @@ struct iio_dev {
/**
* iio_device_register() - register a device with the IIO subsystem
* @dev_info: Device structure filled by the device driver
* @indio_dev: Device structure filled by the device driver
**/
int iio_device_register(struct iio_dev *dev_info);
int iio_device_register(struct iio_dev *indio_dev);
/**
* iio_device_unregister() - unregister a device from the IIO subsystem
* @dev_info: Device structure representing the device.
* @indio_dev: Device structure representing the device.
**/
void iio_device_unregister(struct iio_dev *dev_info);
void iio_device_unregister(struct iio_dev *indio_dev);
/**
* iio_push_event() - try to add event to the list for userspace reading
* @dev_info: IIO device structure
* @indio_dev: IIO device structure
* @ev_code: What event
* @timestamp: When the event occurred
**/
int iio_push_event(struct iio_dev *dev_info, u64 ev_code, s64 timestamp);
int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
extern struct bus_type iio_bus_type;
......@@ -347,10 +347,10 @@ extern struct bus_type iio_bus_type;
* iio_put_device() - reference counted deallocation of struct device
* @dev: the iio_device containing the device
**/
static inline void iio_put_device(struct iio_dev *dev)
static inline void iio_put_device(struct iio_dev *indio_dev)
{
if (dev)
put_device(&dev->dev);
if (indio_dev)
put_device(&indio_dev->dev);
};
/* Can we make this smaller? */
......@@ -361,9 +361,9 @@ static inline void iio_put_device(struct iio_dev *dev)
**/
struct iio_dev *iio_allocate_device(int sizeof_priv);
static inline void *iio_priv(const struct iio_dev *dev)
static inline void *iio_priv(const struct iio_dev *indio_dev)
{
return (char *)dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN);
return (char *)indio_dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN);
}
static inline struct iio_dev *iio_priv_to_dev(void *priv)
......@@ -376,15 +376,15 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv)
* iio_free_device() - free an iio_dev from a driver
* @dev: the iio_dev associated with the device
**/
void iio_free_device(struct iio_dev *dev);
void iio_free_device(struct iio_dev *indio_dev);
/**
* iio_buffer_enabled() - helper function to test if the buffer is enabled
* @dev_info: IIO device info structure for device
* @indio_dev: IIO device info structure for device
**/
static inline bool iio_buffer_enabled(struct iio_dev *dev_info)
static inline bool iio_buffer_enabled(struct iio_dev *indio_dev)
{
return dev_info->currentmode
return indio_dev->currentmode
& (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE);
};
......
......@@ -11,32 +11,33 @@
#ifdef CONFIG_IIO_TRIGGER
/**
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @dev_info: iio_dev associated with the device that will consume the trigger
* @indio_dev: iio_dev associated with the device that will consume the trigger
**/
int iio_device_register_trigger_consumer(struct iio_dev *dev_info);
int iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
/**
* iio_device_unregister_trigger_consumer() - reverse the registration process
* @dev_info: iio_dev associated with the device that consumed the trigger
* @indio_dev: iio_dev associated with the device that consumed the trigger
**/
void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info);
void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev);
#else
/**
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @dev_info: iio_dev associated with the device that will consume the trigger
* @indio_dev: iio_dev associated with the device that will consume the trigger
**/
static int iio_device_register_trigger_consumer(struct iio_dev *dev_info)
static int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
return 0;
};
/**
* iio_device_unregister_trigger_consumer() - reverse the registration process
* @dev_info: iio_dev associated with the device that consumed the trigger
* @indio_dev: iio_dev associated with the device that consumed the trigger
**/
static void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info)
static void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
{
};
......
......@@ -82,9 +82,9 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
rb->access->unmark_in_use(rb);
}
void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info)
void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *indio_dev)
{
buffer->indio_dev = dev_info;
buffer->indio_dev = indio_dev;
init_waitqueue_head(&buffer->pollq);
}
EXPORT_SYMBOL(iio_buffer_init);
......@@ -123,9 +123,9 @@ static ssize_t iio_scan_el_show(struct device *dev,
char *buf)
{
int ret;
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct iio_dev *indio_dev = dev_get_drvdata(dev);
ret = iio_scan_mask_query(dev_info->buffer,
ret = iio_scan_mask_query(indio_dev->buffer,
to_iio_dev_attr(attr)->address);
if (ret < 0)
return ret;
......@@ -180,8 +180,8 @@ static ssize_t iio_scan_el_ts_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", dev_info->buffer->scan_timestamp);
struct iio_dev *indio_dev = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp);
}
static ssize_t iio_scan_el_ts_store(struct device *dev,
......@@ -427,11 +427,11 @@ ssize_t iio_buffer_store_enable(struct device *dev,
int ret;
bool requested_state, current_state;
int previous_mode;
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct iio_buffer *buffer = dev_info->buffer;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct iio_buffer *buffer = indio_dev->buffer;
mutex_lock(&dev_info->mlock);
previous_mode = dev_info->currentmode;
mutex_lock(&indio_dev->mlock);
previous_mode = indio_dev->currentmode;
requested_state = !(buf[0] == '0');
current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES);
if (current_state == requested_state) {
......@@ -440,7 +440,7 @@ ssize_t iio_buffer_store_enable(struct device *dev,
}
if (requested_state) {
if (buffer->setup_ops->preenable) {
ret = buffer->setup_ops->preenable(dev_info);
ret = buffer->setup_ops->preenable(indio_dev);
if (ret) {
printk(KERN_ERR
"Buffer not started:"
......@@ -460,8 +460,8 @@ ssize_t iio_buffer_store_enable(struct device *dev,
if (buffer->access->mark_in_use)
buffer->access->mark_in_use(buffer);
/* Definitely possible for devices to support both of these.*/
if (dev_info->modes & INDIO_BUFFER_TRIGGERED) {
if (!dev_info->trig) {
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) {
if (!indio_dev->trig) {
printk(KERN_INFO
"Buffer not started: no trigger\n");
ret = -EINVAL;
......@@ -469,50 +469,50 @@ ssize_t iio_buffer_store_enable(struct device *dev,
buffer->access->unmark_in_use(buffer);
goto error_ret;
}
dev_info->currentmode = INDIO_BUFFER_TRIGGERED;
} else if (dev_info->modes & INDIO_BUFFER_HARDWARE)
dev_info->currentmode = INDIO_BUFFER_HARDWARE;
indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
} else if (indio_dev->modes & INDIO_BUFFER_HARDWARE)
indio_dev->currentmode = INDIO_BUFFER_HARDWARE;
else { /* should never be reached */
ret = -EINVAL;
goto error_ret;
}
if (buffer->setup_ops->postenable) {
ret = buffer->setup_ops->postenable(dev_info);
ret = buffer->setup_ops->postenable(indio_dev);
if (ret) {
printk(KERN_INFO
"Buffer not started:"
"postenable failed\n");
if (buffer->access->unmark_in_use)
buffer->access->unmark_in_use(buffer);
dev_info->currentmode = previous_mode;
indio_dev->currentmode = previous_mode;
if (buffer->setup_ops->postdisable)
buffer->setup_ops->
postdisable(dev_info);
postdisable(indio_dev);
goto error_ret;
}
}
} else {
if (buffer->setup_ops->predisable) {
ret = buffer->setup_ops->predisable(dev_info);
ret = buffer->setup_ops->predisable(indio_dev);
if (ret)
goto error_ret;
}
if (buffer->access->unmark_in_use)
buffer->access->unmark_in_use(buffer);
dev_info->currentmode = INDIO_DIRECT_MODE;
indio_dev->currentmode = INDIO_DIRECT_MODE;
if (buffer->setup_ops->postdisable) {
ret = buffer->setup_ops->postdisable(dev_info);
ret = buffer->setup_ops->postdisable(indio_dev);
if (ret)
goto error_ret;
}
}
done:
mutex_unlock(&dev_info->mlock);
mutex_unlock(&indio_dev->mlock);
return len;
error_ret:
mutex_unlock(&dev_info->mlock);
mutex_unlock(&indio_dev->mlock);
return ret;
}
EXPORT_SYMBOL(iio_buffer_store_enable);
......@@ -521,8 +521,8 @@ ssize_t iio_buffer_show_enable(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", !!(dev_info->currentmode
struct iio_dev *indio_dev = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", !!(indio_dev->currentmode
& INDIO_ALL_BUFFER_MODES));
}
EXPORT_SYMBOL(iio_buffer_show_enable);
......@@ -575,34 +575,34 @@ static unsigned long *iio_scan_mask_match(unsigned long *av_masks,
**/
int iio_scan_mask_set(struct iio_buffer *buffer, int bit)
{
struct iio_dev *dev_info = buffer->indio_dev;
struct iio_dev *indio_dev = buffer->indio_dev;
unsigned long *mask;
unsigned long *trialmask;
trialmask = kmalloc(sizeof(*trialmask)*
BITS_TO_LONGS(dev_info->masklength),
BITS_TO_LONGS(indio_dev->masklength),
GFP_KERNEL);
if (trialmask == NULL)
return -ENOMEM;
if (!dev_info->masklength) {
if (!indio_dev->masklength) {
WARN_ON("trying to set scanmask prior to registering buffer\n");
kfree(trialmask);
return -EINVAL;
}
bitmap_copy(trialmask, buffer->scan_mask, dev_info->masklength);
bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength);
set_bit(bit, trialmask);
if (dev_info->available_scan_masks) {
mask = iio_scan_mask_match(dev_info->available_scan_masks,
dev_info->masklength,
if (indio_dev->available_scan_masks) {
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
indio_dev->masklength,
trialmask);
if (!mask) {
kfree(trialmask);
return -EINVAL;
}
}
bitmap_copy(buffer->scan_mask, trialmask, dev_info->masklength);
bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength);
buffer->scan_count++;
kfree(trialmask);
......@@ -613,17 +613,17 @@ EXPORT_SYMBOL_GPL(iio_scan_mask_set);
int iio_scan_mask_query(struct iio_buffer *buffer, int bit)
{
struct iio_dev *dev_info = buffer->indio_dev;
struct iio_dev *indio_dev = buffer->indio_dev;
long *mask;
if (bit > dev_info->masklength)
if (bit > indio_dev->masklength)
return -EINVAL;
if (!buffer->scan_mask)
return 0;
if (dev_info->available_scan_masks)
mask = iio_scan_mask_match(dev_info->available_scan_masks,
dev_info->masklength,
if (indio_dev->available_scan_masks)
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
indio_dev->masklength,
buffer->scan_mask);
else
mask = buffer->scan_mask;
......
This diff is collapsed.
......@@ -304,10 +304,10 @@ static ssize_t iio_trigger_read_current(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct iio_dev *indio_dev = dev_get_drvdata(dev);
if (dev_info->trig)
return sprintf(buf, "%s\n", dev_info->trig->name);
if (indio_dev->trig)
return sprintf(buf, "%s\n", indio_dev->trig->name);
return 0;
}
......@@ -323,38 +323,38 @@ static ssize_t iio_trigger_write_current(struct device *dev,
const char *buf,
size_t len)
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct iio_trigger *oldtrig = dev_info->trig;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct iio_trigger *oldtrig = indio_dev->trig;
struct iio_trigger *trig;
int ret;
mutex_lock(&dev_info->mlock);
if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) {
mutex_unlock(&dev_info->mlock);
mutex_lock(&indio_dev->mlock);
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
mutex_unlock(&indio_dev->mlock);
return -EBUSY;
}
mutex_unlock(&dev_info->mlock);
mutex_unlock(&indio_dev->mlock);
trig = iio_trigger_find_by_name(buf, len);
if (trig && dev_info->info->validate_trigger) {
ret = dev_info->info->validate_trigger(dev_info, trig);
if (trig && indio_dev->info->validate_trigger) {
ret = indio_dev->info->validate_trigger(indio_dev, trig);
if (ret)
return ret;
}
if (trig && trig->ops && trig->ops->validate_device) {
ret = trig->ops->validate_device(trig, dev_info);
ret = trig->ops->validate_device(trig, indio_dev);
if (ret)
return ret;
}
dev_info->trig = trig;
indio_dev->trig = trig;
if (oldtrig && dev_info->trig != oldtrig)
if (oldtrig && indio_dev->trig != oldtrig)
iio_put_trigger(oldtrig);
if (dev_info->trig)
iio_get_trigger(dev_info->trig);
if (indio_dev->trig)
iio_get_trigger(indio_dev->trig);
return len;
}
......@@ -473,19 +473,19 @@ void iio_free_trigger(struct iio_trigger *trig)
}
EXPORT_SYMBOL(iio_free_trigger);
int iio_device_register_trigger_consumer(struct iio_dev *dev_info)
int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
dev_info->groups[dev_info->groupcounter++] =
indio_dev->groups[indio_dev->groupcounter++] =
&iio_trigger_consumer_attr_group;
return 0;
}
void iio_device_unregister_trigger_consumer(struct iio_dev *dev_info)
void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
{
/* Clean up and associated but not attached triggers references */
if (dev_info->trig)
iio_put_trigger(dev_info->trig);
if (indio_dev->trig)
iio_put_trigger(indio_dev->trig);
}
int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
......
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