mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 17:31:37 -04:00
greybus: core: return error code when creating endo
Return a pointer-coded error from gb_endo_create() rather than just a null pointer in the event an error occurs. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ee3ecf8028
commit
6b7d5a1f47
@@ -177,6 +177,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
|
||||
size_t buffer_size_max)
|
||||
{
|
||||
struct greybus_host_device *hd;
|
||||
struct gb_endo *endo;
|
||||
u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC
|
||||
|
||||
/*
|
||||
@@ -211,11 +212,12 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
|
||||
ida_init(&hd->cport_id_map);
|
||||
hd->buffer_size_max = buffer_size_max;
|
||||
|
||||
hd->endo = gb_endo_create(hd, endo_id);
|
||||
if (!hd->endo) {
|
||||
endo = gb_endo_create(hd, endo_id);
|
||||
if (IS_ERR(endo)) {
|
||||
greybus_remove_hd(hd);
|
||||
return NULL;
|
||||
}
|
||||
hd->endo = endo;
|
||||
|
||||
return hd;
|
||||
}
|
||||
|
||||
@@ -430,16 +430,19 @@ struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id)
|
||||
|
||||
endo = kzalloc(sizeof(*endo), GFP_KERNEL);
|
||||
if (!endo)
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
/* First check if the value supplied is a valid endo id */
|
||||
if (gb_endo_validate_id(hd, &endo->layout, endo_id))
|
||||
if (gb_endo_validate_id(hd, &endo->layout, endo_id)) {
|
||||
retval = -EINVAL;
|
||||
goto free_endo;
|
||||
}
|
||||
|
||||
endo->id = endo_id;
|
||||
|
||||
/* Register Endo device */
|
||||
if (gb_endo_register(hd, endo))
|
||||
retval = gb_endo_register(hd, endo);
|
||||
if (retval)
|
||||
goto free_endo;
|
||||
|
||||
/* Create modules/interfaces */
|
||||
@@ -453,7 +456,8 @@ struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id)
|
||||
|
||||
free_endo:
|
||||
kfree(endo);
|
||||
return NULL;
|
||||
|
||||
return ERR_PTR(retval);
|
||||
}
|
||||
|
||||
void gb_endo_remove(struct gb_endo *endo)
|
||||
|
||||
Reference in New Issue
Block a user