Commit 8ea70fe0 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: core: return error code when creating host device

Return a pointer-coded error from greybus_create_hd() rather
than NULL 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 6b7d5a1f
......@@ -187,7 +187,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
if ((!driver->message_send) || (!driver->message_cancel) ||
(!driver->submit_svc)) {
pr_err("Must implement all greybus_host_driver callbacks!\n");
return NULL;
return ERR_PTR(-EINVAL);
}
/*
......@@ -202,7 +202,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
hd = kzalloc(sizeof(*hd) + driver->hd_priv_size, GFP_KERNEL);
if (!hd)
return NULL;
return ERR_PTR(-ENOMEM);
kref_init(&hd->kref);
hd->parent = parent;
......@@ -215,7 +215,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
endo = gb_endo_create(hd, endo_id);
if (IS_ERR(endo)) {
greybus_remove_hd(hd);
return NULL;
return ERR_CAST(endo);
}
hd->endo = endo;
......
......@@ -556,9 +556,9 @@ static int ap_probe(struct usb_interface *interface,
udev = usb_get_dev(interface_to_usbdev(interface));
hd = greybus_create_hd(&es1_driver, &udev->dev, ES1_GBUF_MSG_SIZE_MAX);
if (!hd) {
if (IS_ERR(hd)) {
usb_put_dev(udev);
return -ENOMEM;
return PTR_ERR(hd);
}
es1 = hd_to_es1(hd);
......
......@@ -556,9 +556,9 @@ static int ap_probe(struct usb_interface *interface,
udev = usb_get_dev(interface_to_usbdev(interface));
hd = greybus_create_hd(&es1_driver, &udev->dev, ES1_GBUF_MSG_SIZE_MAX);
if (!hd) {
if (IS_ERR(hd)) {
usb_put_dev(udev);
return -ENOMEM;
return PTR_ERR(hd);
}
es1 = hd_to_es1(hd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment