staging:iio:trigger handle name attr in core, remove old alloc and register any control_attrs via struct device

As the majority of triggers don't actually have any other control_attrs lets use the fact
that struct device has a groups element when we do need to have these attributes registered.
A vargs function is used to cut down on lots of building strings in every single driver
just in order to pass them into the allocate.

Also iio_allocate_trigger_named -> iio_allocate_trigger as there is no
unamed version any more, so that is now just confusing.

Blackfin tested and fixed by Michael Hennerich.

V2: Elements from Michael Hennerich's patches for the ade7758

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/staging/iio/trigger/iio-trig-sysfs.c b/drivers/staging/iio/trigger/iio-trig-sysfs.c
index 6d3dee3..47248cd 100644
--- a/drivers/staging/iio/trigger/iio-trig-sysfs.c
+++ b/drivers/staging/iio/trigger/iio-trig-sysfs.c
@@ -92,11 +92,9 @@
 }
 
 static DEVICE_ATTR(trigger_now, S_IWUSR, NULL, iio_sysfs_trigger_poll);
-static IIO_TRIGGER_NAME_ATTR;
 
 static struct attribute *iio_sysfs_trigger_attrs[] = {
 	&dev_attr_trigger_now.attr,
-	&dev_attr_name.attr,
 	NULL,
 };
 
@@ -104,11 +102,15 @@
 	.attrs = iio_sysfs_trigger_attrs,
 };
 
+static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = {
+	&iio_sysfs_trigger_attr_group,
+	NULL
+};
+
 static int iio_sysfs_trigger_probe(int id)
 {
 	struct iio_sysfs_trig *t;
 	int ret;
-	char *name;
 	bool foundit = false;
 	mutex_lock(&iio_syfs_trig_list_mut);
 	list_for_each_entry(t, &iio_sysfs_trig_list, l)
@@ -120,25 +122,19 @@
 		ret = -EINVAL;
 		goto out1;
 	}
-
-	name = kasprintf(GFP_KERNEL, "sysfstrig%d", id);
-	if (name == NULL) {
-		ret = -ENOMEM;
-		goto out1;
-	}
 	t = kmalloc(sizeof(*t), GFP_KERNEL);
 	if (t == NULL) {
 		ret = -ENOMEM;
-		goto free_name;
+		goto out1;
 	}
 	t->id = id;
-	t->trig = iio_allocate_trigger_named(name);
+	t->trig = iio_allocate_trigger("sysfstrig%d", id);
 	if (!t->trig) {
 		ret = -ENOMEM;
 		goto free_t;
 	}
 
-	t->trig->control_attrs = &iio_sysfs_trigger_attr_group;
+	t->trig->dev.groups = iio_sysfs_trigger_attr_groups;
 	t->trig->owner = THIS_MODULE;
 	t->trig->dev.parent = &iio_sysfs_trig_dev;
 
@@ -154,8 +150,6 @@
 	iio_put_trigger(t->trig);
 free_t:
 	kfree(t);
-free_name:
-	kfree(name);
 out1:
 	mutex_unlock(&iio_syfs_trig_list_mut);
 	return ret;
@@ -177,7 +171,6 @@
 	}
 
 	iio_trigger_unregister(t->trig);
-	kfree(t->trig->name);
 	iio_free_trigger(t->trig);
 
 	list_del(&t->l);