Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Uwe Kleine-König and committed by
Jens Wiklander
71a33465 a707eda3

+71
+68
drivers/tee/tee_core.c
··· 1398 1398 return add_uevent_var(env, "MODALIAS=tee:%pUb", dev_id); 1399 1399 } 1400 1400 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 + 1401 1430 const struct bus_type tee_bus_type = { 1402 1431 .name = "tee", 1403 1432 .match = tee_client_device_match, 1404 1433 .uevent = tee_client_device_uevent, 1434 + .probe = tee_client_device_probe, 1435 + .remove = tee_client_device_remove, 1436 + .shutdown = tee_client_device_shutdown, 1405 1437 }; 1406 1438 EXPORT_SYMBOL_GPL(tee_bus_type); 1439 + 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 + } 1407 1463 1408 1464 int __tee_client_driver_register(struct tee_client_driver *tee_driver, 1409 1465 struct module *owner) 1410 1466 { 1411 1467 tee_driver->driver.owner = owner; 1412 1468 tee_driver->driver.bus = &tee_bus_type; 1469 + 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; 1413 1481 1414 1482 return driver_register(&tee_driver->driver); 1415 1483 }
+3
include/linux/tee_drv.h
··· 315 315 * @driver: driver structure 316 316 */ 317 317 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 *); 318 321 const struct tee_client_device_id *id_table; 319 322 struct device_driver driver; 320 323 };