Commit 6b7d5a1f authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman
Browse files

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent ee3ecf80
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;
}
+8 −4
Original line number Diff line number Diff line
@@ -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)