struct gb_control *gb_control_create(struct gb_interface *intf)
{
+ struct gb_connection *connection;
struct gb_control *control;
control = kzalloc(sizeof(*control), GFP_KERNEL);
if (!control)
- return NULL;
+ return ERR_PTR(-ENOMEM);
control->intf = intf;
- control->connection = gb_connection_create_control(intf);
- if (IS_ERR(control->connection)) {
+ connection = gb_connection_create_control(intf);
+ if (IS_ERR(connection)) {
dev_err(&intf->dev,
"failed to create control connection: %ld\n",
- PTR_ERR(control->connection));
+ PTR_ERR(connection));
kfree(control);
- return NULL;
+ return ERR_CAST(connection);
}
+ control->connection = connection;
+
control->dev.parent = &intf->dev;
control->dev.bus = &greybus_bus_type;
control->dev.type = &greybus_control_type;
struct gb_interface *gb_interface_create(struct gb_host_device *hd,
u8 interface_id)
{
+ struct gb_control *control;
struct gb_interface *intf;
intf = kzalloc(sizeof(*intf), GFP_KERNEL);
device_initialize(&intf->dev);
dev_set_name(&intf->dev, "%d-%d", hd->bus_id, interface_id);
- intf->control = gb_control_create(intf);
- if (!intf->control) {
+ control = gb_control_create(intf);
+ if (IS_ERR(control)) {
put_device(&intf->dev);
return NULL;
}
+ intf->control = control;
list_add(&intf->links, &hd->interfaces);