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

staging:iio: dummy sysfs group for autogenerated base directories.

Needed to ensure the reference counting is correct.
Temporary fix whilst discussions are ongoing.
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 70a876c5
...@@ -725,19 +725,29 @@ static ssize_t iio_show_dev_name(struct device *dev, ...@@ -725,19 +725,29 @@ 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 struct attribute *iio_base_dummy_attrs[] = {
NULL
};
static struct attribute_group iio_base_dummy_group = {
.attrs = iio_base_dummy_attrs,
};
static int iio_device_register_sysfs(struct iio_dev *dev_info) static int iio_device_register_sysfs(struct iio_dev *dev_info)
{ {
int i, ret = 0; int i, ret = 0;
struct iio_dev_attr *p, *n; struct iio_dev_attr *p, *n;
if (dev_info->info->attrs) { if (dev_info->info->attrs)
ret = sysfs_create_group(&dev_info->dev.kobj, ret = sysfs_create_group(&dev_info->dev.kobj,
dev_info->info->attrs); dev_info->info->attrs);
if (ret) { else
dev_err(dev_info->dev.parent, ret = sysfs_create_group(&dev_info->dev.kobj,
"Failed to register sysfs hooks\n"); &iio_base_dummy_group);
goto error_ret;
} if (ret) {
dev_err(dev_info->dev.parent,
"Failed to register sysfs hooks\n");
goto error_ret;
} }
/* /*
...@@ -753,7 +763,7 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) ...@@ -753,7 +763,7 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info)
if (ret < 0) if (ret < 0)
goto error_clear_attrs; goto error_clear_attrs;
} }
if (dev_info->name) { if (dev_info->name) {
ret = sysfs_add_file_to_group(&dev_info->dev.kobj, ret = sysfs_add_file_to_group(&dev_info->dev.kobj,
&dev_attr_name.attr, &dev_attr_name.attr,
NULL); NULL);
...@@ -770,6 +780,8 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) ...@@ -770,6 +780,8 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info)
} }
if (dev_info->info->attrs) if (dev_info->info->attrs)
sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs);
else
sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group);
error_ret: error_ret:
return ret; return ret;
...@@ -790,6 +802,8 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info) ...@@ -790,6 +802,8 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info)
if (dev_info->info->attrs) if (dev_info->info->attrs)
sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs);
else
sysfs_remove_group(&dev_info->dev.kobj, &iio_base_dummy_group);
} }
/* Return a negative errno on failure */ /* Return a negative errno on failure */
......
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