mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 21:53:44 +00:00
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: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
ee760ab2a9
commit
f8c6f4e9a4
@ -120,10 +120,10 @@ struct iio_buffer {
|
|||||||
/**
|
/**
|
||||||
* iio_buffer_init() - Initialize the buffer structure
|
* iio_buffer_init() - Initialize the buffer structure
|
||||||
* @buffer: buffer to be initialized
|
* @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,
|
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);
|
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
|
* 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
|
* 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
|
* 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
|
* @ev_code: What event
|
||||||
* @timestamp: When the event occurred
|
* @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;
|
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
|
* iio_put_device() - reference counted deallocation of struct device
|
||||||
* @dev: the iio_device containing the 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)
|
if (indio_dev)
|
||||||
put_device(&dev->dev);
|
put_device(&indio_dev->dev);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Can we make this smaller? */
|
/* 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);
|
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)
|
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
|
* iio_free_device() - free an iio_dev from a driver
|
||||||
* @dev: the iio_dev associated with the device
|
* @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
|
* 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);
|
& (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,32 +11,33 @@
|
|||||||
#ifdef CONFIG_IIO_TRIGGER
|
#ifdef CONFIG_IIO_TRIGGER
|
||||||
/**
|
/**
|
||||||
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
|
* 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
|
* 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
|
#else
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
|
* 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;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iio_device_unregister_trigger_consumer() - reverse the registration process
|
* 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);
|
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);
|
init_waitqueue_head(&buffer->pollq);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_buffer_init);
|
EXPORT_SYMBOL(iio_buffer_init);
|
||||||
@ -123,9 +123,9 @@ static ssize_t iio_scan_el_show(struct device *dev,
|
|||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
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);
|
to_iio_dev_attr(attr)->address);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -180,8 +180,8 @@ 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 *dev_info = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
return sprintf(buf, "%d\n", dev_info->buffer->scan_timestamp);
|
return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t iio_scan_el_ts_store(struct device *dev,
|
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;
|
int ret;
|
||||||
bool requested_state, current_state;
|
bool requested_state, current_state;
|
||||||
int previous_mode;
|
int previous_mode;
|
||||||
struct iio_dev *dev_info = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
struct iio_buffer *buffer = dev_info->buffer;
|
struct iio_buffer *buffer = indio_dev->buffer;
|
||||||
|
|
||||||
mutex_lock(&dev_info->mlock);
|
mutex_lock(&indio_dev->mlock);
|
||||||
previous_mode = dev_info->currentmode;
|
previous_mode = indio_dev->currentmode;
|
||||||
requested_state = !(buf[0] == '0');
|
requested_state = !(buf[0] == '0');
|
||||||
current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES);
|
current_state = !!(previous_mode & INDIO_ALL_BUFFER_MODES);
|
||||||
if (current_state == requested_state) {
|
if (current_state == requested_state) {
|
||||||
@ -440,7 +440,7 @@ ssize_t iio_buffer_store_enable(struct device *dev,
|
|||||||
}
|
}
|
||||||
if (requested_state) {
|
if (requested_state) {
|
||||||
if (buffer->setup_ops->preenable) {
|
if (buffer->setup_ops->preenable) {
|
||||||
ret = buffer->setup_ops->preenable(dev_info);
|
ret = buffer->setup_ops->preenable(indio_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"Buffer not started:"
|
"Buffer not started:"
|
||||||
@ -460,8 +460,8 @@ ssize_t iio_buffer_store_enable(struct device *dev,
|
|||||||
if (buffer->access->mark_in_use)
|
if (buffer->access->mark_in_use)
|
||||||
buffer->access->mark_in_use(buffer);
|
buffer->access->mark_in_use(buffer);
|
||||||
/* Definitely possible for devices to support both of these.*/
|
/* Definitely possible for devices to support both of these.*/
|
||||||
if (dev_info->modes & INDIO_BUFFER_TRIGGERED) {
|
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) {
|
||||||
if (!dev_info->trig) {
|
if (!indio_dev->trig) {
|
||||||
printk(KERN_INFO
|
printk(KERN_INFO
|
||||||
"Buffer not started: no trigger\n");
|
"Buffer not started: no trigger\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@ -469,50 +469,50 @@ ssize_t iio_buffer_store_enable(struct device *dev,
|
|||||||
buffer->access->unmark_in_use(buffer);
|
buffer->access->unmark_in_use(buffer);
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
dev_info->currentmode = INDIO_BUFFER_TRIGGERED;
|
indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
|
||||||
} else if (dev_info->modes & INDIO_BUFFER_HARDWARE)
|
} else if (indio_dev->modes & INDIO_BUFFER_HARDWARE)
|
||||||
dev_info->currentmode = INDIO_BUFFER_HARDWARE;
|
indio_dev->currentmode = INDIO_BUFFER_HARDWARE;
|
||||||
else { /* should never be reached */
|
else { /* should never be reached */
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer->setup_ops->postenable) {
|
if (buffer->setup_ops->postenable) {
|
||||||
ret = buffer->setup_ops->postenable(dev_info);
|
ret = buffer->setup_ops->postenable(indio_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_INFO
|
printk(KERN_INFO
|
||||||
"Buffer not started:"
|
"Buffer not started:"
|
||||||
"postenable failed\n");
|
"postenable failed\n");
|
||||||
if (buffer->access->unmark_in_use)
|
if (buffer->access->unmark_in_use)
|
||||||
buffer->access->unmark_in_use(buffer);
|
buffer->access->unmark_in_use(buffer);
|
||||||
dev_info->currentmode = previous_mode;
|
indio_dev->currentmode = previous_mode;
|
||||||
if (buffer->setup_ops->postdisable)
|
if (buffer->setup_ops->postdisable)
|
||||||
buffer->setup_ops->
|
buffer->setup_ops->
|
||||||
postdisable(dev_info);
|
postdisable(indio_dev);
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (buffer->setup_ops->predisable) {
|
if (buffer->setup_ops->predisable) {
|
||||||
ret = buffer->setup_ops->predisable(dev_info);
|
ret = buffer->setup_ops->predisable(indio_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
if (buffer->access->unmark_in_use)
|
if (buffer->access->unmark_in_use)
|
||||||
buffer->access->unmark_in_use(buffer);
|
buffer->access->unmark_in_use(buffer);
|
||||||
dev_info->currentmode = INDIO_DIRECT_MODE;
|
indio_dev->currentmode = INDIO_DIRECT_MODE;
|
||||||
if (buffer->setup_ops->postdisable) {
|
if (buffer->setup_ops->postdisable) {
|
||||||
ret = buffer->setup_ops->postdisable(dev_info);
|
ret = buffer->setup_ops->postdisable(indio_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
mutex_unlock(&dev_info->mlock);
|
mutex_unlock(&indio_dev->mlock);
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
error_ret:
|
error_ret:
|
||||||
mutex_unlock(&dev_info->mlock);
|
mutex_unlock(&indio_dev->mlock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_buffer_store_enable);
|
EXPORT_SYMBOL(iio_buffer_store_enable);
|
||||||
@ -521,8 +521,8 @@ ssize_t iio_buffer_show_enable(struct device *dev,
|
|||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct iio_dev *dev_info = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
return sprintf(buf, "%d\n", !!(dev_info->currentmode
|
return sprintf(buf, "%d\n", !!(indio_dev->currentmode
|
||||||
& INDIO_ALL_BUFFER_MODES));
|
& INDIO_ALL_BUFFER_MODES));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_buffer_show_enable);
|
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)
|
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 *mask;
|
||||||
unsigned long *trialmask;
|
unsigned long *trialmask;
|
||||||
|
|
||||||
trialmask = kmalloc(sizeof(*trialmask)*
|
trialmask = kmalloc(sizeof(*trialmask)*
|
||||||
BITS_TO_LONGS(dev_info->masklength),
|
BITS_TO_LONGS(indio_dev->masklength),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
|
||||||
if (trialmask == NULL)
|
if (trialmask == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (!dev_info->masklength) {
|
if (!indio_dev->masklength) {
|
||||||
WARN_ON("trying to set scanmask prior to registering buffer\n");
|
WARN_ON("trying to set scanmask prior to registering buffer\n");
|
||||||
kfree(trialmask);
|
kfree(trialmask);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
bitmap_copy(trialmask, buffer->scan_mask, dev_info->masklength);
|
bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength);
|
||||||
set_bit(bit, trialmask);
|
set_bit(bit, trialmask);
|
||||||
|
|
||||||
if (dev_info->available_scan_masks) {
|
if (indio_dev->available_scan_masks) {
|
||||||
mask = iio_scan_mask_match(dev_info->available_scan_masks,
|
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
|
||||||
dev_info->masklength,
|
indio_dev->masklength,
|
||||||
trialmask);
|
trialmask);
|
||||||
if (!mask) {
|
if (!mask) {
|
||||||
kfree(trialmask);
|
kfree(trialmask);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitmap_copy(buffer->scan_mask, trialmask, dev_info->masklength);
|
bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength);
|
||||||
buffer->scan_count++;
|
buffer->scan_count++;
|
||||||
|
|
||||||
kfree(trialmask);
|
kfree(trialmask);
|
||||||
@ -613,17 +613,17 @@ EXPORT_SYMBOL_GPL(iio_scan_mask_set);
|
|||||||
|
|
||||||
int iio_scan_mask_query(struct iio_buffer *buffer, int bit)
|
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;
|
long *mask;
|
||||||
|
|
||||||
if (bit > dev_info->masklength)
|
if (bit > indio_dev->masklength)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!buffer->scan_mask)
|
if (!buffer->scan_mask)
|
||||||
return 0;
|
return 0;
|
||||||
if (dev_info->available_scan_masks)
|
if (indio_dev->available_scan_masks)
|
||||||
mask = iio_scan_mask_match(dev_info->available_scan_masks,
|
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
|
||||||
dev_info->masklength,
|
indio_dev->masklength,
|
||||||
buffer->scan_mask);
|
buffer->scan_mask);
|
||||||
else
|
else
|
||||||
mask = buffer->scan_mask;
|
mask = buffer->scan_mask;
|
||||||
|
@ -119,9 +119,9 @@ struct iio_event_interface {
|
|||||||
struct attribute_group group;
|
struct attribute_group group;
|
||||||
};
|
};
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct iio_event_interface *ev_int = dev_info->event_interface;
|
struct iio_event_interface *ev_int = indio_dev->event_interface;
|
||||||
struct iio_detected_event_list *ev;
|
struct iio_detected_event_list *ev;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ int __iio_add_chan_devattr(const char *postfix,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
|
static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
|
||||||
struct iio_chan_spec const *chan)
|
struct iio_chan_spec const *chan)
|
||||||
{
|
{
|
||||||
int ret, i, attrcount = 0;
|
int ret, i, attrcount = 0;
|
||||||
@ -582,8 +582,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
|
|||||||
&iio_write_channel_info : NULL),
|
&iio_write_channel_info : NULL),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
&dev_info->dev,
|
&indio_dev->dev,
|
||||||
&dev_info->channel_attr_list);
|
&indio_dev->channel_attr_list);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
attrcount++;
|
attrcount++;
|
||||||
@ -595,8 +595,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
|
|||||||
&iio_write_channel_info,
|
&iio_write_channel_info,
|
||||||
(1 << i),
|
(1 << i),
|
||||||
!(i%2),
|
!(i%2),
|
||||||
&dev_info->dev,
|
&indio_dev->dev,
|
||||||
&dev_info->channel_attr_list);
|
&indio_dev->channel_attr_list);
|
||||||
if (ret == -EBUSY && (i%2 == 0)) {
|
if (ret == -EBUSY && (i%2 == 0)) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
continue;
|
continue;
|
||||||
@ -610,7 +610,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iio_device_remove_and_free_read_attr(struct iio_dev *dev_info,
|
static void iio_device_remove_and_free_read_attr(struct iio_dev *indio_dev,
|
||||||
struct iio_dev_attr *p)
|
struct iio_dev_attr *p)
|
||||||
{
|
{
|
||||||
kfree(p->dev_attr.attr.name);
|
kfree(p->dev_attr.attr.name);
|
||||||
@ -627,15 +627,15 @@ static ssize_t iio_show_dev_name(struct device *dev,
|
|||||||
|
|
||||||
static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
|
static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
|
||||||
|
|
||||||
static int iio_device_register_sysfs(struct iio_dev *dev_info)
|
static int iio_device_register_sysfs(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
int i, ret = 0, attrcount, attrn, attrcount_orig = 0;
|
int i, ret = 0, attrcount, attrn, attrcount_orig = 0;
|
||||||
struct iio_dev_attr *p, *n;
|
struct iio_dev_attr *p, *n;
|
||||||
struct attribute **attr;
|
struct attribute **attr;
|
||||||
|
|
||||||
/* First count elements in any existing group */
|
/* First count elements in any existing group */
|
||||||
if (dev_info->info->attrs) {
|
if (indio_dev->info->attrs) {
|
||||||
attr = dev_info->info->attrs->attrs;
|
attr = indio_dev->info->attrs->attrs;
|
||||||
while (*attr++ != NULL)
|
while (*attr++ != NULL)
|
||||||
attrcount_orig++;
|
attrcount_orig++;
|
||||||
}
|
}
|
||||||
@ -644,66 +644,66 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info)
|
|||||||
* New channel registration method - relies on the fact a group does
|
* New channel registration method - relies on the fact a group does
|
||||||
* not need to be initialized if it is name is NULL.
|
* not need to be initialized if it is name is NULL.
|
||||||
*/
|
*/
|
||||||
INIT_LIST_HEAD(&dev_info->channel_attr_list);
|
INIT_LIST_HEAD(&indio_dev->channel_attr_list);
|
||||||
if (dev_info->channels)
|
if (indio_dev->channels)
|
||||||
for (i = 0; i < dev_info->num_channels; i++) {
|
for (i = 0; i < indio_dev->num_channels; i++) {
|
||||||
ret = iio_device_add_channel_sysfs(dev_info,
|
ret = iio_device_add_channel_sysfs(indio_dev,
|
||||||
&dev_info
|
&indio_dev
|
||||||
->channels[i]);
|
->channels[i]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_clear_attrs;
|
goto error_clear_attrs;
|
||||||
attrcount += ret;
|
attrcount += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_info->name)
|
if (indio_dev->name)
|
||||||
attrcount++;
|
attrcount++;
|
||||||
|
|
||||||
dev_info->chan_attr_group.attrs
|
indio_dev->chan_attr_group.attrs
|
||||||
= kzalloc(sizeof(dev_info->chan_attr_group.attrs[0])*
|
= kzalloc(sizeof(indio_dev->chan_attr_group.attrs[0])*
|
||||||
(attrcount + 1),
|
(attrcount + 1),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (dev_info->chan_attr_group.attrs == NULL) {
|
if (indio_dev->chan_attr_group.attrs == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto error_clear_attrs;
|
goto error_clear_attrs;
|
||||||
}
|
}
|
||||||
/* Copy across original attributes */
|
/* Copy across original attributes */
|
||||||
if (dev_info->info->attrs)
|
if (indio_dev->info->attrs)
|
||||||
memcpy(dev_info->chan_attr_group.attrs,
|
memcpy(indio_dev->chan_attr_group.attrs,
|
||||||
dev_info->info->attrs->attrs,
|
indio_dev->info->attrs->attrs,
|
||||||
sizeof(dev_info->chan_attr_group.attrs[0])
|
sizeof(indio_dev->chan_attr_group.attrs[0])
|
||||||
*attrcount_orig);
|
*attrcount_orig);
|
||||||
attrn = attrcount_orig;
|
attrn = attrcount_orig;
|
||||||
/* Add all elements from the list. */
|
/* Add all elements from the list. */
|
||||||
list_for_each_entry(p, &dev_info->channel_attr_list, l)
|
list_for_each_entry(p, &indio_dev->channel_attr_list, l)
|
||||||
dev_info->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
|
indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
|
||||||
if (dev_info->name)
|
if (indio_dev->name)
|
||||||
dev_info->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
|
indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
|
||||||
|
|
||||||
dev_info->groups[dev_info->groupcounter++] =
|
indio_dev->groups[indio_dev->groupcounter++] =
|
||||||
&dev_info->chan_attr_group;
|
&indio_dev->chan_attr_group;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_clear_attrs:
|
error_clear_attrs:
|
||||||
list_for_each_entry_safe(p, n,
|
list_for_each_entry_safe(p, n,
|
||||||
&dev_info->channel_attr_list, l) {
|
&indio_dev->channel_attr_list, l) {
|
||||||
list_del(&p->l);
|
list_del(&p->l);
|
||||||
iio_device_remove_and_free_read_attr(dev_info, p);
|
iio_device_remove_and_free_read_attr(indio_dev, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iio_device_unregister_sysfs(struct iio_dev *dev_info)
|
static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct iio_dev_attr *p, *n;
|
struct iio_dev_attr *p, *n;
|
||||||
|
|
||||||
list_for_each_entry_safe(p, n, &dev_info->channel_attr_list, l) {
|
list_for_each_entry_safe(p, n, &indio_dev->channel_attr_list, l) {
|
||||||
list_del(&p->l);
|
list_del(&p->l);
|
||||||
iio_device_remove_and_free_read_attr(dev_info, p);
|
iio_device_remove_and_free_read_attr(indio_dev, p);
|
||||||
}
|
}
|
||||||
kfree(dev_info->chan_attr_group.attrs);
|
kfree(indio_dev->chan_attr_group.attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * const iio_ev_type_text[] = {
|
static const char * const iio_ev_type_text[] = {
|
||||||
@ -793,7 +793,7 @@ static ssize_t iio_ev_value_store(struct device *dev,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
|
static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
|
||||||
struct iio_chan_spec const *chan)
|
struct iio_chan_spec const *chan)
|
||||||
{
|
{
|
||||||
int ret = 0, i, attrcount = 0;
|
int ret = 0, i, attrcount = 0;
|
||||||
@ -834,8 +834,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
|
|||||||
iio_ev_state_store,
|
iio_ev_state_store,
|
||||||
mask,
|
mask,
|
||||||
0,
|
0,
|
||||||
&dev_info->dev,
|
&indio_dev->dev,
|
||||||
&dev_info->event_interface->
|
&indio_dev->event_interface->
|
||||||
dev_attr_list);
|
dev_attr_list);
|
||||||
kfree(postfix);
|
kfree(postfix);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -853,8 +853,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
|
|||||||
iio_ev_value_store,
|
iio_ev_value_store,
|
||||||
mask,
|
mask,
|
||||||
0,
|
0,
|
||||||
&dev_info->dev,
|
&indio_dev->dev,
|
||||||
&dev_info->event_interface->
|
&indio_dev->event_interface->
|
||||||
dev_attr_list);
|
dev_attr_list);
|
||||||
kfree(postfix);
|
kfree(postfix);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -866,26 +866,26 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void __iio_remove_event_config_attrs(struct iio_dev *dev_info)
|
static inline void __iio_remove_event_config_attrs(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
struct iio_dev_attr *p, *n;
|
struct iio_dev_attr *p, *n;
|
||||||
list_for_each_entry_safe(p, n,
|
list_for_each_entry_safe(p, n,
|
||||||
&dev_info->event_interface->
|
&indio_dev->event_interface->
|
||||||
dev_attr_list, l) {
|
dev_attr_list, l) {
|
||||||
kfree(p->dev_attr.attr.name);
|
kfree(p->dev_attr.attr.name);
|
||||||
kfree(p);
|
kfree(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info)
|
static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
int j, ret, attrcount = 0;
|
int j, ret, attrcount = 0;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&dev_info->event_interface->dev_attr_list);
|
INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
|
||||||
/* Dynically created from the channels array */
|
/* Dynically created from the channels array */
|
||||||
for (j = 0; j < dev_info->num_channels; j++) {
|
for (j = 0; j < indio_dev->num_channels; j++) {
|
||||||
ret = iio_device_add_event_sysfs(dev_info,
|
ret = iio_device_add_event_sysfs(indio_dev,
|
||||||
&dev_info->channels[j]);
|
&indio_dev->channels[j]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_clear_attrs;
|
goto error_clear_attrs;
|
||||||
attrcount += ret;
|
attrcount += ret;
|
||||||
@ -893,17 +893,17 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info)
|
|||||||
return attrcount;
|
return attrcount;
|
||||||
|
|
||||||
error_clear_attrs:
|
error_clear_attrs:
|
||||||
__iio_remove_event_config_attrs(dev_info);
|
__iio_remove_event_config_attrs(indio_dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool iio_check_for_dynamic_events(struct iio_dev *dev_info)
|
static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < dev_info->num_channels; j++)
|
for (j = 0; j < indio_dev->num_channels; j++)
|
||||||
if (dev_info->channels[j].event_mask != 0)
|
if (indio_dev->channels[j].event_mask != 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -919,91 +919,91 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *iio_event_group_name = "events";
|
static const char *iio_event_group_name = "events";
|
||||||
static int iio_device_register_eventset(struct iio_dev *dev_info)
|
static int iio_device_register_eventset(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
struct iio_dev_attr *p;
|
struct iio_dev_attr *p;
|
||||||
int ret = 0, attrcount_orig = 0, attrcount, attrn;
|
int ret = 0, attrcount_orig = 0, attrcount, attrn;
|
||||||
struct attribute **attr;
|
struct attribute **attr;
|
||||||
|
|
||||||
if (!(dev_info->info->event_attrs ||
|
if (!(indio_dev->info->event_attrs ||
|
||||||
iio_check_for_dynamic_events(dev_info)))
|
iio_check_for_dynamic_events(indio_dev)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dev_info->event_interface =
|
indio_dev->event_interface =
|
||||||
kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
|
kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
|
||||||
if (dev_info->event_interface == NULL) {
|
if (indio_dev->event_interface == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
iio_setup_ev_int(dev_info->event_interface);
|
iio_setup_ev_int(indio_dev->event_interface);
|
||||||
if (dev_info->info->event_attrs != NULL) {
|
if (indio_dev->info->event_attrs != NULL) {
|
||||||
attr = dev_info->info->event_attrs->attrs;
|
attr = indio_dev->info->event_attrs->attrs;
|
||||||
while (*attr++ != NULL)
|
while (*attr++ != NULL)
|
||||||
attrcount_orig++;
|
attrcount_orig++;
|
||||||
}
|
}
|
||||||
attrcount = attrcount_orig;
|
attrcount = attrcount_orig;
|
||||||
if (dev_info->channels) {
|
if (indio_dev->channels) {
|
||||||
ret = __iio_add_event_config_attrs(dev_info);
|
ret = __iio_add_event_config_attrs(indio_dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_free_setup_event_lines;
|
goto error_free_setup_event_lines;
|
||||||
attrcount += ret;
|
attrcount += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info->event_interface->group.name = iio_event_group_name;
|
indio_dev->event_interface->group.name = iio_event_group_name;
|
||||||
dev_info->event_interface->group.attrs =
|
indio_dev->event_interface->group.attrs =
|
||||||
kzalloc(sizeof(dev_info->event_interface->group.attrs[0])
|
kzalloc(sizeof(indio_dev->event_interface->group.attrs[0])
|
||||||
*(attrcount + 1),
|
*(attrcount + 1),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (dev_info->event_interface->group.attrs == NULL) {
|
if (indio_dev->event_interface->group.attrs == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto error_free_setup_event_lines;
|
goto error_free_setup_event_lines;
|
||||||
}
|
}
|
||||||
if (dev_info->info->event_attrs)
|
if (indio_dev->info->event_attrs)
|
||||||
memcpy(dev_info->event_interface->group.attrs,
|
memcpy(indio_dev->event_interface->group.attrs,
|
||||||
dev_info->info->event_attrs->attrs,
|
indio_dev->info->event_attrs->attrs,
|
||||||
sizeof(dev_info->event_interface->group.attrs[0])
|
sizeof(indio_dev->event_interface->group.attrs[0])
|
||||||
*attrcount_orig);
|
*attrcount_orig);
|
||||||
attrn = attrcount_orig;
|
attrn = attrcount_orig;
|
||||||
/* Add all elements from the list. */
|
/* Add all elements from the list. */
|
||||||
list_for_each_entry(p,
|
list_for_each_entry(p,
|
||||||
&dev_info->event_interface->dev_attr_list,
|
&indio_dev->event_interface->dev_attr_list,
|
||||||
l)
|
l)
|
||||||
dev_info->event_interface->group.attrs[attrn++] =
|
indio_dev->event_interface->group.attrs[attrn++] =
|
||||||
&p->dev_attr.attr;
|
&p->dev_attr.attr;
|
||||||
|
|
||||||
dev_info->groups[dev_info->groupcounter++] =
|
indio_dev->groups[indio_dev->groupcounter++] =
|
||||||
&dev_info->event_interface->group;
|
&indio_dev->event_interface->group;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_free_setup_event_lines:
|
error_free_setup_event_lines:
|
||||||
__iio_remove_event_config_attrs(dev_info);
|
__iio_remove_event_config_attrs(indio_dev);
|
||||||
kfree(dev_info->event_interface);
|
kfree(indio_dev->event_interface);
|
||||||
error_ret:
|
error_ret:
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iio_device_unregister_eventset(struct iio_dev *dev_info)
|
static void iio_device_unregister_eventset(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
if (dev_info->event_interface == NULL)
|
if (indio_dev->event_interface == NULL)
|
||||||
return;
|
return;
|
||||||
__iio_remove_event_config_attrs(dev_info);
|
__iio_remove_event_config_attrs(indio_dev);
|
||||||
kfree(dev_info->event_interface->group.attrs);
|
kfree(indio_dev->event_interface->group.attrs);
|
||||||
kfree(dev_info->event_interface);
|
kfree(indio_dev->event_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iio_dev_release(struct device *device)
|
static void iio_dev_release(struct device *device)
|
||||||
{
|
{
|
||||||
struct iio_dev *dev_info = container_of(device, struct iio_dev, dev);
|
struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev);
|
||||||
cdev_del(&dev_info->chrdev);
|
cdev_del(&indio_dev->chrdev);
|
||||||
if (dev_info->modes & INDIO_BUFFER_TRIGGERED)
|
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
||||||
iio_device_unregister_trigger_consumer(dev_info);
|
iio_device_unregister_trigger_consumer(indio_dev);
|
||||||
iio_device_unregister_eventset(dev_info);
|
iio_device_unregister_eventset(indio_dev);
|
||||||
iio_device_unregister_sysfs(dev_info);
|
iio_device_unregister_sysfs(indio_dev);
|
||||||
ida_simple_remove(&iio_ida, dev_info->id);
|
ida_simple_remove(&iio_ida, indio_dev->id);
|
||||||
kfree(dev_info);
|
kfree(indio_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct device_type iio_dev_type = {
|
static struct device_type iio_dev_type = {
|
||||||
@ -1062,11 +1062,11 @@ EXPORT_SYMBOL(iio_free_device);
|
|||||||
**/
|
**/
|
||||||
static int iio_chrdev_open(struct inode *inode, struct file *filp)
|
static int iio_chrdev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct iio_dev *dev_info = container_of(inode->i_cdev,
|
struct iio_dev *indio_dev = container_of(inode->i_cdev,
|
||||||
struct iio_dev, chrdev);
|
struct iio_dev, chrdev);
|
||||||
filp->private_data = dev_info;
|
filp->private_data = indio_dev;
|
||||||
|
|
||||||
return iio_chrdev_buffer_open(dev_info);
|
return iio_chrdev_buffer_open(indio_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1107,52 +1107,52 @@ static const struct file_operations iio_buffer_fileops = {
|
|||||||
.compat_ioctl = iio_ioctl,
|
.compat_ioctl = iio_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
int iio_device_register(struct iio_dev *dev_info)
|
int iio_device_register(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* configure elements for the chrdev */
|
/* configure elements for the chrdev */
|
||||||
dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id);
|
indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
|
||||||
|
|
||||||
ret = iio_device_register_sysfs(dev_info);
|
ret = iio_device_register_sysfs(indio_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev_info->dev.parent,
|
dev_err(indio_dev->dev.parent,
|
||||||
"Failed to register sysfs interfaces\n");
|
"Failed to register sysfs interfaces\n");
|
||||||
goto error_ret;
|
goto error_ret;
|
||||||
}
|
}
|
||||||
ret = iio_device_register_eventset(dev_info);
|
ret = iio_device_register_eventset(indio_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev_info->dev.parent,
|
dev_err(indio_dev->dev.parent,
|
||||||
"Failed to register event set\n");
|
"Failed to register event set\n");
|
||||||
goto error_free_sysfs;
|
goto error_free_sysfs;
|
||||||
}
|
}
|
||||||
if (dev_info->modes & INDIO_BUFFER_TRIGGERED)
|
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
||||||
iio_device_register_trigger_consumer(dev_info);
|
iio_device_register_trigger_consumer(indio_dev);
|
||||||
|
|
||||||
ret = device_add(&dev_info->dev);
|
ret = device_add(&indio_dev->dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_unreg_eventset;
|
goto error_unreg_eventset;
|
||||||
cdev_init(&dev_info->chrdev, &iio_buffer_fileops);
|
cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
|
||||||
dev_info->chrdev.owner = dev_info->info->driver_module;
|
indio_dev->chrdev.owner = indio_dev->info->driver_module;
|
||||||
ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1);
|
ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_del_device;
|
goto error_del_device;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_del_device:
|
error_del_device:
|
||||||
device_del(&dev_info->dev);
|
device_del(&indio_dev->dev);
|
||||||
error_unreg_eventset:
|
error_unreg_eventset:
|
||||||
iio_device_unregister_eventset(dev_info);
|
iio_device_unregister_eventset(indio_dev);
|
||||||
error_free_sysfs:
|
error_free_sysfs:
|
||||||
iio_device_unregister_sysfs(dev_info);
|
iio_device_unregister_sysfs(indio_dev);
|
||||||
error_ret:
|
error_ret:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_device_register);
|
EXPORT_SYMBOL(iio_device_register);
|
||||||
|
|
||||||
void iio_device_unregister(struct iio_dev *dev_info)
|
void iio_device_unregister(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
device_unregister(&dev_info->dev);
|
device_unregister(&indio_dev->dev);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_device_unregister);
|
EXPORT_SYMBOL(iio_device_unregister);
|
||||||
subsys_initcall(iio_init);
|
subsys_initcall(iio_init);
|
||||||
|
@ -304,10 +304,10 @@ 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 *dev_info = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (dev_info->trig)
|
if (indio_dev->trig)
|
||||||
return sprintf(buf, "%s\n", dev_info->trig->name);
|
return sprintf(buf, "%s\n", indio_dev->trig->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,38 +323,38 @@ 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 *dev_info = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
struct iio_trigger *oldtrig = dev_info->trig;
|
struct iio_trigger *oldtrig = indio_dev->trig;
|
||||||
struct iio_trigger *trig;
|
struct iio_trigger *trig;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&dev_info->mlock);
|
mutex_lock(&indio_dev->mlock);
|
||||||
if (dev_info->currentmode == INDIO_BUFFER_TRIGGERED) {
|
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
|
||||||
mutex_unlock(&dev_info->mlock);
|
mutex_unlock(&indio_dev->mlock);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
mutex_unlock(&dev_info->mlock);
|
mutex_unlock(&indio_dev->mlock);
|
||||||
|
|
||||||
trig = iio_trigger_find_by_name(buf, len);
|
trig = iio_trigger_find_by_name(buf, len);
|
||||||
|
|
||||||
if (trig && dev_info->info->validate_trigger) {
|
if (trig && indio_dev->info->validate_trigger) {
|
||||||
ret = dev_info->info->validate_trigger(dev_info, trig);
|
ret = indio_dev->info->validate_trigger(indio_dev, trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trig && trig->ops && trig->ops->validate_device) {
|
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)
|
if (ret)
|
||||||
return 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);
|
iio_put_trigger(oldtrig);
|
||||||
if (dev_info->trig)
|
if (indio_dev->trig)
|
||||||
iio_get_trigger(dev_info->trig);
|
iio_get_trigger(indio_dev->trig);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@ -473,19 +473,19 @@ void iio_free_trigger(struct iio_trigger *trig)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(iio_free_trigger);
|
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;
|
&iio_trigger_consumer_attr_group;
|
||||||
|
|
||||||
return 0;
|
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 */
|
/* Clean up and associated but not attached triggers references */
|
||||||
if (dev_info->trig)
|
if (indio_dev->trig)
|
||||||
iio_put_trigger(dev_info->trig);
|
iio_put_trigger(indio_dev->trig);
|
||||||
}
|
}
|
||||||
|
|
||||||
int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
|
int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
|
||||||
|
Loading…
Reference in New Issue
Block a user