token = opal_async_get_token_interruptible(); if (token < 0) { if (token != -ERESTARTSYS)
pr_err("%s: Couldn't get the token, returning\n",
__func__);
ret = token; goto out;
}
ret = opal_get_param(token, param_id, (u64)buffer, length); if (ret != OPAL_ASYNC_COMPLETION) {
ret = opal_error_code(ret); goto out_token;
}
ret = opal_async_wait_response(token, &msg); if (ret) {
pr_err("%s: Failed to wait for the async response, %zd\n",
__func__, ret); goto out_token;
}
token = opal_async_get_token_interruptible(); if (token < 0) { if (token != -ERESTARTSYS)
pr_err("%s: Couldn't get the token, returning\n",
__func__);
ret = token; goto out;
}
ret = opal_set_param(token, param_id, (u64)buffer, length);
if (ret != OPAL_ASYNC_COMPLETION) {
ret = opal_error_code(ret); goto out_token;
}
ret = opal_async_wait_response(token, &msg); if (ret) {
pr_err("%s: Failed to wait for the async response, %d\n",
__func__, ret); goto out_token;
}
if (!opal_kobj) {
pr_warn("SYSPARAM: opal kobject is not available\n"); goto out;
}
/* Some systems do not use sysparams; this is not an error */
sysparam = of_find_node_by_path("/ibm,opal/sysparams"); if (!sysparam) goto out;
if (!of_device_is_compatible(sysparam, "ibm,opal-sysparams")) {
pr_err("SYSPARAM: Opal sysparam node not compatible\n"); goto out_node_put;
}
sysparam_kobj = kobject_create_and_add("sysparams", opal_kobj); if (!sysparam_kobj) {
pr_err("SYSPARAM: Failed to create sysparam kobject\n"); goto out_node_put;
}
/* Allocate big enough buffer for any get/set transactions */
param_data_buf = kzalloc(MAX_PARAM_DATA_LEN, GFP_KERNEL); if (!param_data_buf) {
pr_err("SYSPARAM: Failed to allocate memory for param data " "buf\n"); goto out_kobj_put;
}
/* Number of parameters exposed through DT */
count = of_property_count_strings(sysparam, "param-name"); if (count < 0) {
pr_err("SYSPARAM: No string found of property param-name in " "the node %pOFn\n", sysparam); goto out_param_buf;
}
id = kcalloc(count, sizeof(*id), GFP_KERNEL); if (!id) {
pr_err("SYSPARAM: Failed to allocate memory to read parameter " "id\n"); goto out_param_buf;
}
size = kcalloc(count, sizeof(*size), GFP_KERNEL); if (!size) {
pr_err("SYSPARAM: Failed to allocate memory to read parameter " "size\n"); goto out_free_id;
}
perm = kcalloc(count, sizeof(*perm), GFP_KERNEL); if (!perm) {
pr_err("SYSPARAM: Failed to allocate memory to read supported " "action on the parameter"); goto out_free_size;
}
if (of_property_read_u32_array(sysparam, "param-id", id, count)) {
pr_err("SYSPARAM: Missing property param-id in the DT\n"); goto out_free_perm;
}
if (of_property_read_u32_array(sysparam, "param-len", size, count)) {
pr_err("SYSPARAM: Missing property param-len in the DT\n"); goto out_free_perm;
}
if (of_property_read_u8_array(sysparam, "param-perm", perm, count)) {
pr_err("SYSPARAM: Missing property param-perm in the DT\n"); goto out_free_perm;
}
attr = kcalloc(count, sizeof(*attr), GFP_KERNEL); if (!attr) {
pr_err("SYSPARAM: Failed to allocate memory for parameter " "attributes\n"); goto out_free_perm;
}
/* For each of the parameters, populate the parameter attributes */ for (i = 0; i < count; i++) { if (size[i] > MAX_PARAM_DATA_LEN) {
pr_warn("SYSPARAM: Not creating parameter %d as size " "exceeds buffer length\n", i); continue;
}
sysfs_attr_init(&attr[i].kobj_attr.attr);
attr[i].param_id = id[i];
attr[i].param_size = size[i]; if (of_property_read_string_index(sysparam, "param-name", i,
&attr[i].kobj_attr.attr.name)) continue;
/* If the parameter is read-only or read-write */ switch (perm[i] & 3) { case OPAL_SYSPARAM_READ:
attr[i].kobj_attr.attr.mode = 0444; break; case OPAL_SYSPARAM_WRITE:
attr[i].kobj_attr.attr.mode = 0200; break; case OPAL_SYSPARAM_RW:
attr[i].kobj_attr.attr.mode = 0644; break; default: break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.