configfs: Allow ->make_item() and ->make_group() to return detailed errors.

The configfs operations ->make_item() and ->make_group() currently
return a new item/group.  A return of NULL signifies an error.  Because
of this, -ENOMEM is the only return code bubbled up the stack.

Multiple folks have requested the ability to return specific error codes
when these operations fail.  This patch adds that ability by changing the
->make_item/group() ops to return an int.

Also updated are the in-kernel users of configfs.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
This commit is contained in:
Joel Becker
2008-06-12 14:00:18 -07:00
committed by Mark Fasheh
parent 6d8344baee
commit 11c3b79218
8 changed files with 94 additions and 64 deletions

View File

@@ -585,8 +585,9 @@ static struct config_item_type netconsole_target_type = {
* Group operations and type for netconsole_subsys.
*/
static struct config_item *make_netconsole_target(struct config_group *group,
const char *name)
static int make_netconsole_target(struct config_group *group,
const char *name,
struct config_item **new_item)
{
unsigned long flags;
struct netconsole_target *nt;
@@ -598,7 +599,7 @@ static struct config_item *make_netconsole_target(struct config_group *group,
nt = kzalloc(sizeof(*nt), GFP_KERNEL);
if (!nt) {
printk(KERN_ERR "netconsole: failed to allocate memory\n");
return NULL;
return -ENOMEM;
}
nt->np.name = "netconsole";
@@ -615,7 +616,8 @@ static struct config_item *make_netconsole_target(struct config_group *group,
list_add(&nt->list, &target_list);
spin_unlock_irqrestore(&target_list_lock, flags);
return &nt->item;
*new_item = &nt->item;
return 0;
}
static void drop_netconsole_target(struct config_group *group,