[PATCH] fix serdev bind/unbind

From: julian schroeder
Date: Tue Jan 18 2022 - 14:47:56 EST


On some chromebooks, the serdev is used to communicate with
an embedded controller. When the controller is updated, the
regular ttyS* is needed. Therefore unbind/bind needs to work
to be able to switch between the two modes without having to
reboot. In the case of ACPI enabled platforms, the underlying
serial device is marked as enumerated but this is not cleared
upon remove (unbind). In this state it can not be bound as
serdev.

Signed-off-by: julian schroeder <julianmarcusschroeder@xxxxxxxxx>
---
drivers/tty/serdev/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 92e3433276f8..668fa570bc07 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -138,7 +138,11 @@ EXPORT_SYMBOL_GPL(serdev_device_add);
void serdev_device_remove(struct serdev_device *serdev)
{
struct serdev_controller *ctrl = serdev->ctrl;
+ struct acpi_device *adev;

+ adev = ACPI_COMPANION(&serdev->dev);
+ if (adev)
+ acpi_device_clear_enumerated(adev);
device_unregister(&serdev->dev);
ctrl->serdev = NULL;
}
--
2.20.1