powerpc/rtas: introduce rtas_function_token() API
authorNathan Lynch <nathanl@linux.ibm.com>
Fri, 10 Feb 2023 18:42:07 +0000 (12:42 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Feb 2023 11:35:03 +0000 (22:35 +1100)
commit716bfc97bd5fb7b442cdd06081f49df097f2e27b
treec231fb6c57715de2748d3bbe44e60f8f7fca4e73
parente58d9e17b11b776e32b1d3d80bdc63d39de3463d
powerpc/rtas: introduce rtas_function_token() API

Users of rtas_token() supply a string argument that can't be validated
at build time. A typo or misspelling has to be caught by inspection or
by observing wrong behavior at runtime.

Since the core RTAS code now has consolidated the names of all
possible RTAS functions and mapped them to their tokens, token lookup
can be implemented using symbolic constants to index a static array.

So introduce rtas_function_token(), a replacement API which does that,
along with a rtas_service_present()-equivalent helper,
rtas_function_implemented(). Callers supply an opaque predefined
function handle which is used internally to index the function
table. Typos or other inappropriate arguments yield build errors, and
the function handle is a type that can't be easily confused with RTAS
tokens or other integer types.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-19-26929c8cce78@linux.ibm.com
arch/powerpc/include/asm/rtas.h
arch/powerpc/kernel/rtas.c