struct typec_switch *sw;
struct typec_mux *mux;
+ const struct typec_capability *orig_cap; /* to be removed */
const struct typec_capability *cap;
};
return -EINVAL;
}
- ret = port->cap->try_role(port->cap, role);
+ ret = port->cap->try_role(port->orig_cap, role);
if (ret)
return ret;
goto unlock_and_ret;
}
- ret = port->cap->dr_set(port->cap, ret);
+ ret = port->cap->dr_set(port->orig_cap, ret);
if (ret)
goto unlock_and_ret;
goto unlock_and_ret;
}
- ret = port->cap->pr_set(port->cap, ret);
+ ret = port->cap->pr_set(port->orig_cap, ret);
if (ret)
goto unlock_and_ret;
goto unlock_and_ret;
}
- ret = port->cap->port_type_set(port->cap, type);
+ ret = port->cap->port_type_set(port->orig_cap, type);
if (ret)
goto unlock_and_ret;
if (ret)
return ret;
- ret = port->cap->vconn_set(port->cap, (enum typec_role)source);
+ ret = port->cap->vconn_set(port->orig_cap, (enum typec_role)source);
if (ret)
return ret;
ida_destroy(&port->mode_ids);
typec_switch_put(port->sw);
typec_mux_put(port->mux);
+ kfree(port->cap);
kfree(port);
}
mutex_init(&port->port_type_lock);
port->id = id;
- port->cap = cap;
+ port->orig_cap = cap;
port->port_type = cap->type;
port->prefer_role = cap->prefer_role;
port->dev.type = &typec_port_dev_type;
dev_set_name(&port->dev, "port%d", id);
+ port->cap = kmemdup(cap, sizeof(*cap), GFP_KERNEL);
+ if (!port->cap) {
+ put_device(&port->dev);
+ return ERR_PTR(-ENOMEM);
+ }
+
port->sw = typec_switch_get(&port->dev);
if (IS_ERR(port->sw)) {
put_device(&port->dev);