From: Sumit Garg via OP-TEE <op-tee@lists.trustedfirmware.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 02/17] tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
Date: Mon, 15 Dec 2025 16:23:08 +0900 [thread overview]
Message-ID: <aT-3XEEpOIAl5R_Q@sumit-X1> (raw)
In-Reply-To: <7f73b2ee784c0b78fa3bfee3aaa3b95f47041178.1765472125.git.u.kleine-koenig@baylibre.com>
On Thu, Dec 11, 2025 at 06:14:56PM +0100, Uwe Kleine-König wrote:
> Introduce a bus specific probe, remove and shutdown function. For now
> this only allows to get rid of a cast of the generic device to a
> tee_client device in the drivers and changes the remove prototype to
> return void---a non-zero return value is ignored anyhow.
>
> The objective is to get rid of users of struct device_driver callbacks
> .probe(), .remove() and .shutdown() to eventually remove these. Until
> all tee_client drivers are converted this results in a runtime warning
> about the drivers needing an update because there is a bus probe
> function and a driver probe function.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> drivers/tee/tee_core.c | 68 +++++++++++++++++++++++++++++++++++++++++
> include/linux/tee_drv.h | 3 ++
> 2 files changed, 71 insertions(+)
>
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index 51379f7fc5d5..89164d35fc5c 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -1398,19 +1398,87 @@ static int tee_client_device_uevent(const struct device *dev,
> return add_uevent_var(env, "MODALIAS=tee:%pUb", dev_id);
> }
>
> +static int tee_client_device_probe(struct device *dev)
> +{
> + struct tee_client_device *tcdev= to_tee_client_device(dev);
missing space: s/tcdev=/tcdev =/
> + struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
> +
> + if (drv->probe)
> + return drv->probe(tcdev);
> + else
> + return 0;
> +}
> +
> +static void tee_client_device_remove(struct device *dev)
> +{
> + struct tee_client_device *tcdev= to_tee_client_device(dev);
ditto.
> + struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
> +
> + if (drv->remove)
> + drv->remove(tcdev);
> +}
> +
> +static void tee_client_device_shutdown(struct device *dev)
> +{
> + struct tee_client_device *tcdev= to_tee_client_device(dev);
ditto.
> + struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
> +
> + if (dev->driver && drv->remove)
> + drv->remove(tcdev);
don't we need to check and invoke drv->shutdown here?
> +}
> +
> const struct bus_type tee_bus_type = {
> .name = "tee",
> .match = tee_client_device_match,
> .uevent = tee_client_device_uevent,
> + .probe = tee_client_device_probe,
> + .remove = tee_client_device_remove,
> + .shutdown = tee_client_device_shutdown,
> };
> EXPORT_SYMBOL_GPL(tee_bus_type);
>
> +static int tee_client_device_probe_legacy(struct tee_client_device *tcdev)
> +{
> + struct device *dev = &tcdev->dev;
> + struct device_driver *driver = dev->driver;
> +
> + return driver->probe(dev);
> +}
> +
> +static void tee_client_device_remove_legacy(struct tee_client_device *tcdev)
> +{
> + struct device *dev = &tcdev->dev;
> + struct device_driver *driver = dev->driver;
> +
> + driver->remove(dev);
> +}
> +
> +static void tee_client_device_shutdown_legacy(struct tee_client_device *tcdev)
> +{
> + struct device *dev = &tcdev->dev;
> + struct device_driver *driver = dev->driver;
> +
> + driver->shutdown(dev);
> +}
> +
> 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;
>
> + /*
> + * Drivers that have callbacks set for tee_driver->driver need updating
> + * to use the callbacks in tee_driver instead. driver_register() warns
> + * about that, so no need to warn here, too.
> + */
> + if (!tee_driver->probe && tee_driver->driver.probe)
> + tee_driver->probe = tee_client_device_probe_legacy;
> + if (!tee_driver->remove && tee_driver->driver.remove)
> + tee_driver->remove= tee_client_device_remove_legacy;
missing space: s/tee_driver->remove=/tee_driver->remove =/
> + if (!tee_driver->shutdown && tee_driver->driver.probe)
you should rather check here for tee_driver->driver.shutdown?
-Sumit
> + tee_driver->shutdown = tee_client_device_shutdown_legacy;
> +
> return driver_register(&tee_driver->driver);
> }
> EXPORT_SYMBOL_GPL(__tee_client_driver_register);
> diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
> index 850c03b2cdea..e561a26f537a 100644
> --- a/include/linux/tee_drv.h
> +++ b/include/linux/tee_drv.h
> @@ -315,6 +315,9 @@ struct tee_client_device {
> * @driver: driver structure
> */
> struct tee_client_driver {
> + int (*probe)(struct tee_client_device *);
> + void (*remove)(struct tee_client_device *);
> + void (*shutdown)(struct tee_client_device *);
> const struct tee_client_device_id *id_table;
> struct device_driver driver;
> };
> --
> 2.47.3
>
next prev parent reply other threads:[~2025-12-15 7:23 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 17:14 [PATCH v1 00/17] tee: Use bus callbacks instead of driver callbacks Uwe Kleine-König
2025-12-11 17:14 ` [PATCH v1 01/17] tee: Add some helpers to reduce boilerplate for tee client drivers Uwe Kleine-König
2025-12-15 7:05 ` Sumit Garg via OP-TEE
2025-12-11 17:14 ` [PATCH v1 02/17] tee: Add probe, remove and shutdown bus callbacks to tee_client_driver Uwe Kleine-König
2025-12-15 7:23 ` Sumit Garg via OP-TEE [this message]
2025-12-11 17:14 ` [PATCH v1 03/17] tee: Adapt documentation to cover recent additions Uwe Kleine-König
2025-12-15 7:24 ` Sumit Garg via OP-TEE
2025-12-11 17:14 ` [PATCH v1 04/17] hwrng: optee - Make use of module_tee_client_driver() Uwe Kleine-König
2025-12-15 7:26 ` Sumit Garg via OP-TEE
2025-12-11 17:14 ` [PATCH v1 05/17] hwrng: optee - Make use of tee bus methods Uwe Kleine-König
2025-12-15 7:27 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 06/17] rtc: optee: Migrate to use tee specific driver registration function Uwe Kleine-König
2025-12-15 7:28 ` Sumit Garg via OP-TEE
2025-12-15 10:41 ` Alexandre Belloni via OP-TEE
2025-12-11 17:15 ` [PATCH v1 07/17] rtc: optee: Make use of tee bus methods Uwe Kleine-König
2025-12-15 7:30 ` Sumit Garg via OP-TEE
2025-12-15 10:42 ` Alexandre Belloni via OP-TEE
2025-12-11 17:15 ` [PATCH v1 08/17] efi: stmm: Make use of module_tee_client_driver() Uwe Kleine-König
2025-12-15 7:55 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 09/17] efi: stmm: Make use of tee bus methods Uwe Kleine-König
2025-12-15 7:55 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 10/17] firmware: arm_scmi: optee: Make use of module_tee_client_driver() Uwe Kleine-König
2025-12-12 12:33 ` Sudeep Holla
2025-12-15 7:30 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 11/17] firmware: arm_scmi: Make use of tee bus methods Uwe Kleine-König
2025-12-12 12:34 ` Sudeep Holla
2025-12-15 7:32 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 12/17] firmware: tee_bnxt: Make use of module_tee_client_driver() Uwe Kleine-König
2025-12-15 7:33 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 13/17] firmware: tee_bnxt: Make use of tee bus methods Uwe Kleine-König
2025-12-15 7:34 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 14/17] KEYS: trusted: Migrate to use tee specific driver registration function Uwe Kleine-König
2025-12-15 7:36 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 15/17] KEYS: trusted: Make use of tee bus methods Uwe Kleine-König
2025-12-15 7:36 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 16/17] tpm/tpm_ftpm_tee: Make use of tee specific driver registration Uwe Kleine-König
2025-12-15 7:38 ` Sumit Garg via OP-TEE
2025-12-11 17:15 ` [PATCH v1 17/17] tpm/tpm_ftpm_tee: Make use of tee bus methods Uwe Kleine-König
2025-12-11 20:22 ` Jarkko Sakkinen via OP-TEE
2025-12-11 20:22 ` Jarkko Sakkinen via OP-TEE
2025-12-15 7:40 ` Sumit Garg via OP-TEE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aT-3XEEpOIAl5R_Q@sumit-X1 \
--to=op-tee@lists.trustedfirmware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sumit.garg@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox