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=1796390173; b=pNjyATZZLGfosWUX1uCs2sSAWtMweRsII3AKQDv/ya25Q8uJ8pgoUwhbjGsXtF0DDklg +0lXaCXOdCtemBStUNVRee0a0VG33S39BmF+YwvQEKLg++iIOl4QPKys6FO1SFS0F2WD4 pcpLcTCxJkESkWhrZnAhJxx2qcdA9Pk4dWs7RXzU9p+7deg/I6UpUgfZPxQVOhnwMcqBd t0VboPq8og8OH6aDR5WY+Ka/iCZFCPG+vbYvE42NZslL9RuFzeFEyn1HjvcO4j/kdLF3d bBoldDUH9Uo6FAVEng1UrLX9Rcfi39X1wQWCSSDpPMartGSmsvgdb4Nqy3s+ifIAmXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390173; 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=knyiLb2oK5iW0ILCJiSDe8ZhGnItvlvroe7on2dSr/E=; b=hy1Rk7wwn2ov/nPH8ev19SQSkJkly1OZ3R7JniPOUG9rUVg/3Ro3uCGetgavW1UG0oyi eA217Ysb6LhNVuTtxtjKWQ1CJGYLleLSR47T6eV2LqHVDYDUy3Yk67d8b8qtFErkTs9gF 4AlDHxOxhJ9MAyZwM6F2JR1jEnwb3NztQGMFHexBgPua/41+bpwQw1wQiOGK+gj8luUV/ cbndiPu5Ex9TkedqGF4KHSwe9H9yiTZwjX8hgU1lNIQ10I2DNOPPNdsB7s8RrdES3KgO3 XUdB1qNBaR+F0nO2W7IJARTMrAaG4eComSwozWU5q6KE2ipGYdDOUbJtDowIA/9nwJA== 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=oeAd9ij0; 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 9CA88606A336 for ; Fri, 4 Dec 2026 13:16:13 +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=oeAd9ij0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D43161F0092C; Fri, 4 Dec 2026 13:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796390173; bh=knyiLb2oK5iW0ILCJiSDe8ZhGnItvlvroe7on2dSr/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oeAd9ij0h9H4vMYdyV8BBm21pyk4juNtN1v+i51eglvhcjhcFxQ/zMGSb4GJpz5wH DCeo5y5SJ60FPNRGtmbGNIprxn74l4Xvlg1A4RHz5Bprr51tIMZwhiX5XcuhJDhjy1 jtqUJ1usOVKSpffMhTQEdi/XRKQpfDxhI1dTUb7ExXCfFHUy1mMLsJVuSWNuxjJrs+ IZeiGa+jliL5gRbXua7Vqk23cGs5fXK6nysGkqdlveInwiPqzPkj35shoccwSsrq79 jk7Y3Vb6mudlvtbggC3KifRINWgmBFyM1XgRiA4Y83RIUibzGHwmc+7PQVO0pHDZW9 ZGXeecZkvpR1A== 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.18.y 2/5] tee: Add probe, remove and shutdown bus callbacks to tee_client_driver Date: Fri, 4 Dec 2026 08:16:07 -0500 Message-ID: <20261204131603.3126555-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204131603.3126555-1-sashal@kernel.org> References: <2026120349-ivy-angling-cb79@gregkh> <20261204131603.3126555-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 51379f7fc5d54..a015730664c79 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); + 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 850c03b2cdeac..e561a26f537ae 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.53.0