Skip to content

Commit 71a3346

Browse files
ukleinekjenswi-linaro
authored andcommitted
tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
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> Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
1 parent a707eda commit 71a3346

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

drivers/tee/tee_core.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,19 +1398,87 @@ static int tee_client_device_uevent(const struct device *dev,
13981398
return add_uevent_var(env, "MODALIAS=tee:%pUb", dev_id);
13991399
}
14001400

1401+
static int tee_client_device_probe(struct device *dev)
1402+
{
1403+
struct tee_client_device *tcdev = to_tee_client_device(dev);
1404+
struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
1405+
1406+
if (drv->probe)
1407+
return drv->probe(tcdev);
1408+
else
1409+
return 0;
1410+
}
1411+
1412+
static void tee_client_device_remove(struct device *dev)
1413+
{
1414+
struct tee_client_device *tcdev = to_tee_client_device(dev);
1415+
struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
1416+
1417+
if (drv->remove)
1418+
drv->remove(tcdev);
1419+
}
1420+
1421+
static void tee_client_device_shutdown(struct device *dev)
1422+
{
1423+
struct tee_client_device *tcdev = to_tee_client_device(dev);
1424+
struct tee_client_driver *drv = to_tee_client_driver(dev->driver);
1425+
1426+
if (dev->driver && drv->shutdown)
1427+
drv->shutdown(tcdev);
1428+
}
1429+
14011430
const struct bus_type tee_bus_type = {
14021431
.name = "tee",
14031432
.match = tee_client_device_match,
14041433
.uevent = tee_client_device_uevent,
1434+
.probe = tee_client_device_probe,
1435+
.remove = tee_client_device_remove,
1436+
.shutdown = tee_client_device_shutdown,
14051437
};
14061438
EXPORT_SYMBOL_GPL(tee_bus_type);
14071439

1440+
static int tee_client_device_probe_legacy(struct tee_client_device *tcdev)
1441+
{
1442+
struct device *dev = &tcdev->dev;
1443+
struct device_driver *driver = dev->driver;
1444+
1445+
return driver->probe(dev);
1446+
}
1447+
1448+
static void tee_client_device_remove_legacy(struct tee_client_device *tcdev)
1449+
{
1450+
struct device *dev = &tcdev->dev;
1451+
struct device_driver *driver = dev->driver;
1452+
1453+
driver->remove(dev);
1454+
}
1455+
1456+
static void tee_client_device_shutdown_legacy(struct tee_client_device *tcdev)
1457+
{
1458+
struct device *dev = &tcdev->dev;
1459+
struct device_driver *driver = dev->driver;
1460+
1461+
driver->shutdown(dev);
1462+
}
1463+
14081464
int __tee_client_driver_register(struct tee_client_driver *tee_driver,
14091465
struct module *owner)
14101466
{
14111467
tee_driver->driver.owner = owner;
14121468
tee_driver->driver.bus = &tee_bus_type;
14131469

1470+
/*
1471+
* Drivers that have callbacks set for tee_driver->driver need updating
1472+
* to use the callbacks in tee_driver instead. driver_register() warns
1473+
* about that, so no need to warn here, too.
1474+
*/
1475+
if (!tee_driver->probe && tee_driver->driver.probe)
1476+
tee_driver->probe = tee_client_device_probe_legacy;
1477+
if (!tee_driver->remove && tee_driver->driver.remove)
1478+
tee_driver->remove = tee_client_device_remove_legacy;
1479+
if (!tee_driver->shutdown && tee_driver->driver.probe)
1480+
tee_driver->shutdown = tee_client_device_shutdown_legacy;
1481+
14141482
return driver_register(&tee_driver->driver);
14151483
}
14161484
EXPORT_SYMBOL_GPL(__tee_client_driver_register);

include/linux/tee_drv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ struct tee_client_device {
315315
* @driver: driver structure
316316
*/
317317
struct tee_client_driver {
318+
int (*probe)(struct tee_client_device *);
319+
void (*remove)(struct tee_client_device *);
320+
void (*shutdown)(struct tee_client_device *);
318321
const struct tee_client_device_id *id_table;
319322
struct device_driver driver;
320323
};

0 commit comments

Comments
 (0)