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: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Alex Elder 2015-05-22 09:52:45 -05:00 committed by Greg Kroah-Hartman
parent 6b7d5a1f47
commit 8ea70fe049
3 changed files with 7 additions and 7 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);