in overlay.c [1192:1257]
int of_overlay_remove(int *ovcs_id)
{
struct overlay_changeset *ovcs;
int ret, ret_apply, ret_tmp;
if (devicetree_corrupt()) {
pr_err("suspect devicetree state, refuse to remove overlay\n");
ret = -EBUSY;
goto out;
}
mutex_lock(&of_mutex);
ovcs = idr_find(&ovcs_idr, *ovcs_id);
if (!ovcs) {
ret = -ENODEV;
pr_err("remove: Could not find overlay #%d\n", *ovcs_id);
goto out_unlock;
}
if (!overlay_removal_is_ok(ovcs)) {
ret = -EBUSY;
goto out_unlock;
}
ret = overlay_notify(ovcs, OF_OVERLAY_PRE_REMOVE);
if (ret) {
pr_err("overlay changeset pre-remove notify error %d\n", ret);
goto out_unlock;
}
list_del(&ovcs->ovcs_list);
ret_apply = 0;
ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply);
if (ret) {
if (ret_apply)
devicetree_state_flags |= DTSF_REVERT_FAIL;
goto out_unlock;
}
ret = __of_changeset_revert_notify(&ovcs->cset);
if (ret)
pr_err("overlay remove changeset entry notify error %d\n", ret);
/* notify failure is not fatal, continue */
*ovcs_id = 0;
ret_tmp = overlay_notify(ovcs, OF_OVERLAY_POST_REMOVE);
if (ret_tmp) {
pr_err("overlay changeset post-remove notify error %d\n",
ret_tmp);
if (!ret)
ret = ret_tmp;
}
free_overlay_changeset(ovcs);
out_unlock:
mutex_unlock(&of_mutex);
out:
pr_debug("%s() err=%d\n", __func__, ret);
return ret;
}