Re: [PATCH] fix serdev bind/unbind

From: Andy Shevchenko
Date: Fri Jan 21 2022 - 12:23:42 EST


On Fri, Jan 21, 2022 at 8:55 AM julian schroeder
<julianmarcusschroeder@xxxxxxxxx> wrote:
>
> On some chromebooks, the serdev is used to communicate with

Chromebooks ?

> 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.

Seems legit (we do this for i2c and spi serial buses in ACPI case).
After addressing the following nit-pick
Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

...

> 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);

As I mentioned i2c and SPI cases, I think it would be nice to use same
pattern of this code, i.e.


if (ACPI_COMPANION(&serdev->dev))
acpi_device_clear_enumerated(ACPI_COMPANION(&serdev->dev));

drivers/i2c/i2c-core-base.c, line 1007
drivers/spi/spi.c, line 779

> device_unregister(&serdev->dev);
> ctrl->serdev = NULL;
> }


--
With Best Regards,
Andy Shevchenko