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>
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);
}
/*
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;
endo = gb_endo_create(hd, endo_id);
if (IS_ERR(endo)) {
greybus_remove_hd(hd);
- return NULL;
+ return ERR_CAST(endo);
}
hd->endo = endo;
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);
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);