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:
@ -1489,25 +1489,28 @@ static struct o2hb_heartbeat_group *to_o2hb_heartbeat_group(struct config_group
|
||||
: NULL;
|
||||
}
|
||||
|
||||
static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group,
|
||||
const char *name)
|
||||
static int o2hb_heartbeat_group_make_item(struct config_group *group,
|
||||
const char *name,
|
||||
struct config_item **new_item)
|
||||
{
|
||||
struct o2hb_region *reg = NULL;
|
||||
struct config_item *ret = NULL;
|
||||
int ret = 0;
|
||||
|
||||
reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
|
||||
if (reg == NULL)
|
||||
goto out; /* ENOMEM */
|
||||
if (reg == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
config_item_init_type_name(®->hr_item, name, &o2hb_region_type);
|
||||
|
||||
ret = ®->hr_item;
|
||||
*new_item = ®->hr_item;
|
||||
|
||||
spin_lock(&o2hb_live_lock);
|
||||
list_add_tail(®->hr_all_item, &o2hb_all_regions);
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
out:
|
||||
if (ret == NULL)
|
||||
if (ret)
|
||||
kfree(reg);
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user