|
@@ -119,9 +119,9 @@ struct iio_event_interface {
|
|
|
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;
|
|
|
int ret = 0;
|
|
|
|
|
@@ -567,7 +567,7 @@ error_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)
|
|
|
{
|
|
|
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),
|
|
|
0,
|
|
|
0,
|
|
|
- &dev_info->dev,
|
|
|
- &dev_info->channel_attr_list);
|
|
|
+ &indio_dev->dev,
|
|
|
+ &indio_dev->channel_attr_list);
|
|
|
if (ret)
|
|
|
goto error_ret;
|
|
|
attrcount++;
|
|
@@ -595,8 +595,8 @@ static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
|
|
|
&iio_write_channel_info,
|
|
|
(1 << i),
|
|
|
!(i%2),
|
|
|
- &dev_info->dev,
|
|
|
- &dev_info->channel_attr_list);
|
|
|
+ &indio_dev->dev,
|
|
|
+ &indio_dev->channel_attr_list);
|
|
|
if (ret == -EBUSY && (i%2 == 0)) {
|
|
|
ret = 0;
|
|
|
continue;
|
|
@@ -610,7 +610,7 @@ error_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)
|
|
|
{
|
|
|
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 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;
|
|
|
struct iio_dev_attr *p, *n;
|
|
|
struct attribute **attr;
|
|
|
|
|
|
/* First count elements in any existing group */
|
|
|
- if (dev_info->info->attrs) {
|
|
|
- attr = dev_info->info->attrs->attrs;
|
|
|
+ if (indio_dev->info->attrs) {
|
|
|
+ attr = indio_dev->info->attrs->attrs;
|
|
|
while (*attr++ != NULL)
|
|
|
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
|
|
|
* not need to be initialized if it is name is NULL.
|
|
|
*/
|
|
|
- INIT_LIST_HEAD(&dev_info->channel_attr_list);
|
|
|
- if (dev_info->channels)
|
|
|
- for (i = 0; i < dev_info->num_channels; i++) {
|
|
|
- ret = iio_device_add_channel_sysfs(dev_info,
|
|
|
- &dev_info
|
|
|
+ INIT_LIST_HEAD(&indio_dev->channel_attr_list);
|
|
|
+ if (indio_dev->channels)
|
|
|
+ for (i = 0; i < indio_dev->num_channels; i++) {
|
|
|
+ ret = iio_device_add_channel_sysfs(indio_dev,
|
|
|
+ &indio_dev
|
|
|
->channels[i]);
|
|
|
if (ret < 0)
|
|
|
goto error_clear_attrs;
|
|
|
attrcount += ret;
|
|
|
}
|
|
|
|
|
|
- if (dev_info->name)
|
|
|
+ if (indio_dev->name)
|
|
|
attrcount++;
|
|
|
|
|
|
- dev_info->chan_attr_group.attrs
|
|
|
- = kzalloc(sizeof(dev_info->chan_attr_group.attrs[0])*
|
|
|
+ indio_dev->chan_attr_group.attrs
|
|
|
+ = kzalloc(sizeof(indio_dev->chan_attr_group.attrs[0])*
|
|
|
(attrcount + 1),
|
|
|
GFP_KERNEL);
|
|
|
- if (dev_info->chan_attr_group.attrs == NULL) {
|
|
|
+ if (indio_dev->chan_attr_group.attrs == NULL) {
|
|
|
ret = -ENOMEM;
|
|
|
goto error_clear_attrs;
|
|
|
}
|
|
|
/* Copy across original attributes */
|
|
|
- if (dev_info->info->attrs)
|
|
|
- memcpy(dev_info->chan_attr_group.attrs,
|
|
|
- dev_info->info->attrs->attrs,
|
|
|
- sizeof(dev_info->chan_attr_group.attrs[0])
|
|
|
+ if (indio_dev->info->attrs)
|
|
|
+ memcpy(indio_dev->chan_attr_group.attrs,
|
|
|
+ indio_dev->info->attrs->attrs,
|
|
|
+ sizeof(indio_dev->chan_attr_group.attrs[0])
|
|
|
*attrcount_orig);
|
|
|
attrn = attrcount_orig;
|
|
|
/* Add all elements from the list. */
|
|
|
- list_for_each_entry(p, &dev_info->channel_attr_list, l)
|
|
|
- dev_info->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
|
|
|
- if (dev_info->name)
|
|
|
- dev_info->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
|
|
|
+ list_for_each_entry(p, &indio_dev->channel_attr_list, l)
|
|
|
+ indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
|
|
|
+ if (indio_dev->name)
|
|
|
+ indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
|
|
|
|
|
|
- dev_info->groups[dev_info->groupcounter++] =
|
|
|
- &dev_info->chan_attr_group;
|
|
|
+ indio_dev->groups[indio_dev->groupcounter++] =
|
|
|
+ &indio_dev->chan_attr_group;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
error_clear_attrs:
|
|
|
list_for_each_entry_safe(p, n,
|
|
|
- &dev_info->channel_attr_list, l) {
|
|
|
+ &indio_dev->channel_attr_list, 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;
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
|
|
|
- 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);
|
|
|
- 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[] = {
|
|
@@ -793,7 +793,7 @@ static ssize_t iio_ev_value_store(struct device *dev,
|
|
|
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)
|
|
|
{
|
|
|
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,
|
|
|
mask,
|
|
|
0,
|
|
|
- &dev_info->dev,
|
|
|
- &dev_info->event_interface->
|
|
|
+ &indio_dev->dev,
|
|
|
+ &indio_dev->event_interface->
|
|
|
dev_attr_list);
|
|
|
kfree(postfix);
|
|
|
if (ret)
|
|
@@ -853,8 +853,8 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
|
|
|
iio_ev_value_store,
|
|
|
mask,
|
|
|
0,
|
|
|
- &dev_info->dev,
|
|
|
- &dev_info->event_interface->
|
|
|
+ &indio_dev->dev,
|
|
|
+ &indio_dev->event_interface->
|
|
|
dev_attr_list);
|
|
|
kfree(postfix);
|
|
|
if (ret)
|
|
@@ -866,26 +866,26 @@ error_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;
|
|
|
list_for_each_entry_safe(p, n,
|
|
|
- &dev_info->event_interface->
|
|
|
+ &indio_dev->event_interface->
|
|
|
dev_attr_list, l) {
|
|
|
kfree(p->dev_attr.attr.name);
|
|
|
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;
|
|
|
|
|
|
- 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 */
|
|
|
- for (j = 0; j < dev_info->num_channels; j++) {
|
|
|
- ret = iio_device_add_event_sysfs(dev_info,
|
|
|
- &dev_info->channels[j]);
|
|
|
+ for (j = 0; j < indio_dev->num_channels; j++) {
|
|
|
+ ret = iio_device_add_event_sysfs(indio_dev,
|
|
|
+ &indio_dev->channels[j]);
|
|
|
if (ret < 0)
|
|
|
goto error_clear_attrs;
|
|
|
attrcount += ret;
|
|
@@ -893,17 +893,17 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info)
|
|
|
return attrcount;
|
|
|
|
|
|
error_clear_attrs:
|
|
|
- __iio_remove_event_config_attrs(dev_info);
|
|
|
+ __iio_remove_event_config_attrs(indio_dev);
|
|
|
|
|
|
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;
|
|
|
|
|
|
- for (j = 0; j < dev_info->num_channels; j++)
|
|
|
- if (dev_info->channels[j].event_mask != 0)
|
|
|
+ for (j = 0; j < indio_dev->num_channels; j++)
|
|
|
+ if (indio_dev->channels[j].event_mask != 0)
|
|
|
return true;
|
|
|
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 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;
|
|
|
int ret = 0, attrcount_orig = 0, attrcount, attrn;
|
|
|
struct attribute **attr;
|
|
|
|
|
|
- if (!(dev_info->info->event_attrs ||
|
|
|
- iio_check_for_dynamic_events(dev_info)))
|
|
|
+ if (!(indio_dev->info->event_attrs ||
|
|
|
+ iio_check_for_dynamic_events(indio_dev)))
|
|
|
return 0;
|
|
|
|
|
|
- dev_info->event_interface =
|
|
|
+ indio_dev->event_interface =
|
|
|
kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
|
|
|
- if (dev_info->event_interface == NULL) {
|
|
|
+ if (indio_dev->event_interface == NULL) {
|
|
|
ret = -ENOMEM;
|
|
|
goto error_ret;
|
|
|
}
|
|
|
|
|
|
- iio_setup_ev_int(dev_info->event_interface);
|
|
|
- if (dev_info->info->event_attrs != NULL) {
|
|
|
- attr = dev_info->info->event_attrs->attrs;
|
|
|
+ iio_setup_ev_int(indio_dev->event_interface);
|
|
|
+ if (indio_dev->info->event_attrs != NULL) {
|
|
|
+ attr = indio_dev->info->event_attrs->attrs;
|
|
|
while (*attr++ != NULL)
|
|
|
attrcount_orig++;
|
|
|
}
|
|
|
attrcount = attrcount_orig;
|
|
|
- if (dev_info->channels) {
|
|
|
- ret = __iio_add_event_config_attrs(dev_info);
|
|
|
+ if (indio_dev->channels) {
|
|
|
+ ret = __iio_add_event_config_attrs(indio_dev);
|
|
|
if (ret < 0)
|
|
|
goto error_free_setup_event_lines;
|
|
|
attrcount += ret;
|
|
|
}
|
|
|
|
|
|
- dev_info->event_interface->group.name = iio_event_group_name;
|
|
|
- dev_info->event_interface->group.attrs =
|
|
|
- kzalloc(sizeof(dev_info->event_interface->group.attrs[0])
|
|
|
+ indio_dev->event_interface->group.name = iio_event_group_name;
|
|
|
+ indio_dev->event_interface->group.attrs =
|
|
|
+ kzalloc(sizeof(indio_dev->event_interface->group.attrs[0])
|
|
|
*(attrcount + 1),
|
|
|
GFP_KERNEL);
|
|
|
- if (dev_info->event_interface->group.attrs == NULL) {
|
|
|
+ if (indio_dev->event_interface->group.attrs == NULL) {
|
|
|
ret = -ENOMEM;
|
|
|
goto error_free_setup_event_lines;
|
|
|
}
|
|
|
- if (dev_info->info->event_attrs)
|
|
|
- memcpy(dev_info->event_interface->group.attrs,
|
|
|
- dev_info->info->event_attrs->attrs,
|
|
|
- sizeof(dev_info->event_interface->group.attrs[0])
|
|
|
+ if (indio_dev->info->event_attrs)
|
|
|
+ memcpy(indio_dev->event_interface->group.attrs,
|
|
|
+ indio_dev->info->event_attrs->attrs,
|
|
|
+ sizeof(indio_dev->event_interface->group.attrs[0])
|
|
|
*attrcount_orig);
|
|
|
attrn = attrcount_orig;
|
|
|
/* Add all elements from the list. */
|
|
|
list_for_each_entry(p,
|
|
|
- &dev_info->event_interface->dev_attr_list,
|
|
|
+ &indio_dev->event_interface->dev_attr_list,
|
|
|
l)
|
|
|
- dev_info->event_interface->group.attrs[attrn++] =
|
|
|
+ indio_dev->event_interface->group.attrs[attrn++] =
|
|
|
&p->dev_attr.attr;
|
|
|
|
|
|
- dev_info->groups[dev_info->groupcounter++] =
|
|
|
- &dev_info->event_interface->group;
|
|
|
+ indio_dev->groups[indio_dev->groupcounter++] =
|
|
|
+ &indio_dev->event_interface->group;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
error_free_setup_event_lines:
|
|
|
- __iio_remove_event_config_attrs(dev_info);
|
|
|
- kfree(dev_info->event_interface);
|
|
|
+ __iio_remove_event_config_attrs(indio_dev);
|
|
|
+ kfree(indio_dev->event_interface);
|
|
|
error_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;
|
|
|
- __iio_remove_event_config_attrs(dev_info);
|
|
|
- kfree(dev_info->event_interface->group.attrs);
|
|
|
- kfree(dev_info->event_interface);
|
|
|
+ __iio_remove_event_config_attrs(indio_dev);
|
|
|
+ kfree(indio_dev->event_interface->group.attrs);
|
|
|
+ kfree(indio_dev->event_interface);
|
|
|
}
|
|
|
|
|
|
static void iio_dev_release(struct device *device)
|
|
|
{
|
|
|
- struct iio_dev *dev_info = container_of(device, struct iio_dev, dev);
|
|
|
- cdev_del(&dev_info->chrdev);
|
|
|
- if (dev_info->modes & INDIO_BUFFER_TRIGGERED)
|
|
|
- iio_device_unregister_trigger_consumer(dev_info);
|
|
|
- iio_device_unregister_eventset(dev_info);
|
|
|
- iio_device_unregister_sysfs(dev_info);
|
|
|
- ida_simple_remove(&iio_ida, dev_info->id);
|
|
|
- kfree(dev_info);
|
|
|
+ struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev);
|
|
|
+ cdev_del(&indio_dev->chrdev);
|
|
|
+ if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
|
|
+ iio_device_unregister_trigger_consumer(indio_dev);
|
|
|
+ iio_device_unregister_eventset(indio_dev);
|
|
|
+ iio_device_unregister_sysfs(indio_dev);
|
|
|
+ ida_simple_remove(&iio_ida, indio_dev->id);
|
|
|
+ kfree(indio_dev);
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
- struct iio_dev *dev_info = container_of(inode->i_cdev,
|
|
|
+ struct iio_dev *indio_dev = container_of(inode->i_cdev,
|
|
|
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,
|
|
|
};
|
|
|
|
|
|
-int iio_device_register(struct iio_dev *dev_info)
|
|
|
+int iio_device_register(struct iio_dev *indio_dev)
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
|
/* 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) {
|
|
|
- dev_err(dev_info->dev.parent,
|
|
|
+ dev_err(indio_dev->dev.parent,
|
|
|
"Failed to register sysfs interfaces\n");
|
|
|
goto error_ret;
|
|
|
}
|
|
|
- ret = iio_device_register_eventset(dev_info);
|
|
|
+ ret = iio_device_register_eventset(indio_dev);
|
|
|
if (ret) {
|
|
|
- dev_err(dev_info->dev.parent,
|
|
|
+ dev_err(indio_dev->dev.parent,
|
|
|
"Failed to register event set\n");
|
|
|
goto error_free_sysfs;
|
|
|
}
|
|
|
- if (dev_info->modes & INDIO_BUFFER_TRIGGERED)
|
|
|
- iio_device_register_trigger_consumer(dev_info);
|
|
|
+ if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
|
|
+ iio_device_register_trigger_consumer(indio_dev);
|
|
|
|
|
|
- ret = device_add(&dev_info->dev);
|
|
|
+ ret = device_add(&indio_dev->dev);
|
|
|
if (ret < 0)
|
|
|
goto error_unreg_eventset;
|
|
|
- cdev_init(&dev_info->chrdev, &iio_buffer_fileops);
|
|
|
- dev_info->chrdev.owner = dev_info->info->driver_module;
|
|
|
- ret = cdev_add(&dev_info->chrdev, dev_info->dev.devt, 1);
|
|
|
+ cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
|
|
|
+ indio_dev->chrdev.owner = indio_dev->info->driver_module;
|
|
|
+ ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
|
|
|
if (ret < 0)
|
|
|
goto error_del_device;
|
|
|
return 0;
|
|
|
|
|
|
error_del_device:
|
|
|
- device_del(&dev_info->dev);
|
|
|
+ device_del(&indio_dev->dev);
|
|
|
error_unreg_eventset:
|
|
|
- iio_device_unregister_eventset(dev_info);
|
|
|
+ iio_device_unregister_eventset(indio_dev);
|
|
|
error_free_sysfs:
|
|
|
- iio_device_unregister_sysfs(dev_info);
|
|
|
+ iio_device_unregister_sysfs(indio_dev);
|
|
|
error_ret:
|
|
|
return ret;
|
|
|
}
|
|
|
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);
|
|
|
subsys_initcall(iio_init);
|