From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390475; b=0E/8hD2E0qPPfmnmfrcgAoJt8KUBY1EzYbGa6uGzbHOh19lG8YNMIhHKpX6GTDKOu7s2 dWhP4fhytvl/ehzE+zqZl2CUCZ9UKaQGkgI9xR10Gho/R43hsexJu9SVRETyASeQiQEGU vhRK6ueVWIiofjVNdNO0EEyQxsTZKQfnY8tT7iquPXRkK1BH2hNczMSM7dVyrODQbAB3d S2oEFBsTMF0oCNwqt/wg24k2QxgVJvExTUYc1/7Ux/UUxiuNGgc1YVVAo+vOqUtINGxHR Q6VZiaPycOuvz/pJA6pMemIsJC/6XPx6jD7N/SsH7+Zmgm2WeKFeS7OjigLPKZNtT5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390475; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=/2iuP/jyspx5AABuP+kzjfcNQfpXTyqC+VPGcMORXm8=; b=n7aBzcgbs0d/yq8ZJa+XXSRTszD6DTdy08Mvs6v9SdNOWggKB1Tjn0dP12+uOxS+2Qv/ i21fvBwZFvkG/QJIri6fkFbGKUp8m51LvEcoaaIuxegj9fj1B0IXnRyChUsNMolLdMCaj W8aILxOlfYtJ75IzsuI19ojeNBfVLtIM9eru7dl42/7XLAfPcDcEo0fuTE9GP2HGgB27Z +CPpkvgJ09wODCodfQ23UuFKdt02mGYcI3/6hJdsNKhst4SgPa/SmfxjFMuIhx+VO+m9j tD9ep4UyYUDHJTzymoQerpxm1TEYqS12vGgkdWov4KbJkisa1HKwZz0Ksg/GVNEtQiA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GZRSNdyn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD495606A686 for ; Fri, 4 Dec 2026 13:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GZRSNdyn Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFEC71F00A09; Fri, 4 Dec 2026 13:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796390475; bh=/2iuP/jyspx5AABuP+kzjfcNQfpXTyqC+VPGcMORXm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GZRSNdynXzDbK0lv0kPyH0rbCyOkJv0GCfKbQXi8iGjXW1pBmjTM+56tIdN4WaUfl vRk/1tWj7EmTB9s/aBme3HqZr6fwRwdQT3pIaQ67BwRpUape8VbbikmAqUgKQDxU8J 2tUzvM+jCrM9n4KIa4/Owx+ZI7uuhmUUKfZErbjGlOyHzNXg2lKlICQ/98UxMxDyG/ DMyMN8yYp6IajcmzKQyjcQdHy9WuFzAP0DQykGGs6uRJx1zAe9Z6JpwWFLyDJmj9Zn vwAVud86fAf5qgnUazaaJIASF39qU/tZh/1OGtOkIAlCbN+wwVDjMDoOYnyielNHm7 8DWzFYd/NRqmw== From: Sasha Levin To: stable@vger.kernel.org Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Sumit Garg , Jens Wiklander , Sasha Levin Subject: [PATCH 6.12.y 2/5] tee: Add probe, remove and shutdown bus callbacks to tee_client_driver Date: Fri, 4 Dec 2026 08:21:09 -0500 Message-ID: <20261204132104.3150260-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204132104.3150260-1-sashal@kernel.org> References: <2026120350-nape-five-95c1@gregkh> <20261204132104.3150260-1-sashal@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Uwe Kleine-König [ Upstream commit 71a33465726e4125f5ef33705ce5bc7ec1bf5b1f ] 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 Reviewed-by: Sumit Garg Signed-off-by: Jens Wiklander Stable-dep-of: b8d381d5ed79 ("KEYS: trusted: TEE: Synchronize session lifetime") Signed-off-by: Sasha Levin --- 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 1483931900b39..2ddeee91d0864 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -1234,19 +1234,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); + 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); + 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); + struct tee_client_driver *drv = to_tee_client_driver(dev->driver); + + if (dev->driver && drv->shutdown) + drv->shutdown(tcdev); +} + 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; + if (!tee_driver->shutdown && tee_driver->driver.probe) + 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 0ca142e827bc9..cbf401e717ebb 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -293,6 +293,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.53.0