Commit 724b619d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: core: check for valid hcd callbacks

When registering a host controller, verify that all of the needed
callbacks are present, so we don't have to do the testing on any "hot"
paths when we want to send real data.
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org.
parent d8144884
......@@ -208,6 +208,19 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
{
struct greybus_host_device *hd;
/*
* Validate that the driver implements all of the callbacks
* so that we don't have to every time we make them.
*/
if ((!driver->alloc_gbuf_data) ||
(!driver->free_gbuf_data) ||
(!driver->submit_svc) ||
(!driver->submit_gbuf) ||
(!driver->abort_gbuf)) {
pr_err("Must implement all greybus_host_driver callbacks!\n");
return NULL;
}
hd = kzalloc(sizeof(*hd) + driver->hd_priv_size, GFP_KERNEL);
if (!hd)
return NULL;
......
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