lkml.org 
[lkml]   [2013]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sysfs: add sysfs_create/remove_groups()
On 08/21/13 13:35, Greg Kroah-Hartman wrote:
>
> --- a/fs/sysfs/group.c
> +++ b/fs/sysfs/group.c
> @@ -131,6 +131,39 @@ int sysfs_create_group(struct kobject *k
> }
>
> /**
> + * sysfs_create_groups - given a directory kobject, create a bunch of attribute groups
> + * @kobj: The kobject to create the group on
> + * @groups: The attribute groups to create, NULL terminated
> + *
> + * This function creates a bunch of attribute groups. If an error occurs when
> + * creating a group, all previously created groups will be removed, unwinding
> + * everything back to the original state when this function was called.
> + * It will explicitly warn and error if any of the attribute files being
> + * created already exist.
> + *
> + * Returns 0 on success or error.

ambiguous. How about:
Returns 0 on success or error code on error.

> + */
> +int sysfs_create_groups(struct kobject *kobj,
> + const struct attribute_group **groups)
> +{
> + int error = 0;
> + int i;
> +
> + if (!groups)
> + return 0;
> +
> + for (i = 0; groups[i]; i++) {
> + error = sysfs_create_group(kobj, groups[i]);
> + if (error) {
> + while (--i >= 0)
> + sysfs_remove_group(kobj, groups[i]);
> + break;
> + }
> + }
> + return error;
> +}


--
~Randy


\
 
 \ /
  Last update: 2013-08-21 23:21    [W:0.081 / U:1.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site