Re: [PATCH v1 01/17] tee: Add some helpers to reduce boilerplate for tee client drivers

Sumit Garg
2025-12-15T07:05:34Z

On Thu, Dec 11, 2025 at 06:14:55PM +0100, Uwe Kleine-König wrote:
> Similar to platform drivers (and others) create dedicated register and
> unregister functions and a macro to simplify modules that only need to
> handle driver registration in their init and exit handlers.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> drivers/tee/tee_core.c | 16 ++++++++++++++++
> include/linux/tee_drv.h | 9 +++++++++
> 2 files changed, 25 insertions(+)

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

>
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index d65d47cc154e..51379f7fc5d5 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -1405,6 +1405,22 @@ const struct bus_type tee_bus_type = {
> };
> EXPORT_SYMBOL_GPL(tee_bus_type);
>
> +int __tee_client_driver_register(struct tee_client_driver *tee_driver,
> + struct module *owner)
> +{
> + tee_driver->driver.owner = owner;
> + tee_driver->driver.bus = &tee_bus_type;
> +
> + return driver_register(&tee_driver->driver);
> +}
> +EXPORT_SYMBOL_GPL(__tee_client_driver_register);
> +
> +void tee_client_driver_unregister(struct tee_client_driver *tee_driver)
> +{
> + driver_unregister(&tee_driver->driver);
> +}
> +EXPORT_SYMBOL_GPL(tee_client_driver_unregister);
> +
> static int __init tee_init(void)
> {
> int rc;
> diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
> index 88a6f9697c89..850c03b2cdea 100644
> --- a/include/linux/tee_drv.h
> +++ b/include/linux/tee_drv.h
> @@ -322,4 +322,13 @@ struct tee_client_driver {
> #define to_tee_client_driver(d) \
> container_of_const(d, struct tee_client_driver, driver)
>
> +#define tee_client_driver_register(drv) \
> + __tee_client_driver_register(drv, THIS_MODULE)
> +int __tee_client_driver_register(struct tee_client_driver *, struct module *);
> +void tee_client_driver_unregister(struct tee_client_driver *);
> +
> +#define module_tee_client_driver(__tee_client_driver) \
> + module_driver(__tee_client_driver, tee_client_driver_register, \
> + tee_client_driver_unregister)
> +
> #endif /*__TEE_DRV_H*/
> --
> 2.47.3
>