Skip to content

Commit a1927fb

Browse files
Thadeu Lima de Souza CascardoTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_typec: add remove driver hook
This allows the driver to be unbound and bound again. Otherwise, when unbinding the driver, there will be leftover sysfs entries. When rebinding the driver, it also ends up touching freed memory when adding to the notifier chain as the old one was not removed and ends up being traversed. Add a remove_new driver hook, which removes the notifier from the chain and unregisters the typec ports. Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 62be134 commit a1927fb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,15 @@ static int cros_typec_probe(struct platform_device *pdev)
12851285
return ret;
12861286
}
12871287

1288+
static void cros_typec_remove(struct platform_device *pdev)
1289+
{
1290+
struct cros_typec_data *typec = platform_get_drvdata(pdev);
1291+
1292+
cros_usbpd_unregister_notify(&typec->nb);
1293+
cancel_work_sync(&typec->port_work);
1294+
cros_unregister_ports(typec);
1295+
}
1296+
12881297
static int __maybe_unused cros_typec_suspend(struct device *dev)
12891298
{
12901299
struct cros_typec_data *typec = dev_get_drvdata(dev);
@@ -1316,6 +1325,7 @@ static struct platform_driver cros_typec_driver = {
13161325
.pm = &cros_typec_pm_ops,
13171326
},
13181327
.probe = cros_typec_probe,
1328+
.remove_new = cros_typec_remove,
13191329
};
13201330

13211331
module_platform_driver(cros_typec_driver);

0 commit comments

Comments
 (0)