core: dt_driver: swap TEE_result and retrieved device reference - #6098
Conversation
|
Checkpatch warns on |
|
This P-R is related to discussion thread #5954 (comment). |
|
Bug found in dt_driver_test.c and fixed. CI make check should run ok now. |
|
I pushed 2 fixup commits. (edited) |
jenswikl
left a comment
There was a problem hiding this comment.
What do others think? Is it worth it to swap the TEE_Result and device reference?
| res = dt_driver_device_from_node_idx_prop(prop_name, fdt, | ||
| nodeoffset, conf_id, | ||
| DT_DRIVER_PINCTRL, | ||
| (void **)pinconf); |
There was a problem hiding this comment.
This cast might be a problem, depending on the compiler. It may not be a problem in practice since all pointers use the same size, but a zealous compiler could complain about strict aliasing rules. I guess this is the reason why this somewhat backward way of returning the error value was chosen.
I'd prefer
void *pinconf = NULL;
res = dt_driver_device_from_node_idx_prop(prop_name, fdt,
nodeoffset, conf_id,
DT_DRIVER_PINCTRL,
&pinconf);
if (res) {
free(state);
return res;
}
state->confs[conf_id] = pinconf;to avoid that ugly cast.
No strong opinion, but judging by the diffstat (+269 -334) it makes the code a bit more compact, and having a TEE_Result as a return value is indeed much more natural. So I'd say yes, it's worth it.
+1 |
|
Thanks @jforissier. |
|
I pushed a fixup before I saw your last commit. I'll squash up all fixup commits and update the P-R. |
|
fixed and squashed. |
|
|
Changes dt_driver callback function to return a TEE_Result value and pass retrieved device reference by a output argument rather than the opposite. This change updates dt_driver.c, dt_driver.h and all drivers implementing related dt_driver callback function. As a consequence, this change removes all type definition related to device specific callback handler function types which are useless as all these now comply with type dt_driver_probe_func defined in dt_driver.h. Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Fixes pin ctrl.h header file prototype declaration as per preferred by toolchains as clang. Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
|
review tag applied |
Changes dt_driver callback function to return a
TEE_Resultvalue and pass retrieved device reference by a output argument rather than the opposite.This change updates dt_driver.c, dt_driver.h, dt_driver_test.c and all drivers implementing related dt_driver callback functions.
As a consequence, this change removes all type definition related to device specific callback handler function types which are useless as all these now comply with type
dt_driver_probe_funcdefined in dt_driver.h.This P-R is related to discussion thread #5954 (comment).