[U-Boot] [RFC PATCH 2/3] dm: core: Add dm_pre_os_remove() and hook it into device_remove()

Stefan Roese sr at denx.de
Fri Mar 3 06:26:41 UTC 2017


Hi Simon,

On 03.03.2017 05:53, Simon Glass wrote:
> On 1 March 2017 at 03:23, Stefan Roese <sr at denx.de> wrote:
>> The new function dm_pre_os_remove() is intented for driver specific
>> last-stage cleanup operations before the OS is started. This patch adds
>> this functionality and hooks it into the common device_remove()
>> function.
>>
>> To enable usage for custom driver (e.g. ethernet drivers), this patch
>> also sets the pre-OS remove flag for the root driver and simple-bus
>> drivers. Otherwise the recursive call starting from the root device
>> would not reach the drivers in need for this specific remove call.
>>
>> Signed-off-by: Stefan Roese <sr at denx.de>
>> Cc: Simon Glass <sjg at chromium.org>
>> ---
>>  drivers/core/device-remove.c | 7 +++++++
>>  drivers/core/root.c          | 8 ++++++++
>>  drivers/core/simple-bus.c    | 1 +
>>  include/dm/root.h            | 9 +++++++++
>>  4 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
>> index 4725d4751c..0dfb20cdce 100644
>> --- a/drivers/core/device-remove.c
>> +++ b/drivers/core/device-remove.c
>> @@ -166,6 +166,13 @@ int device_remove(struct udevice *dev, bool pre_os_remove)
>>         drv = dev->driver;
>>         assert(drv);
>>
>> +       /*
>> +        * If pre-OS remove is requested, only continue for drivers with this
>> +        * flag set
>> +        */
>> +       if (pre_os_remove && !(drv->flags & DM_FLAG_PRE_OS_REMOVE))
>> +               return 0;
>> +
>
> This doesn't seem good to me. I think it should scan the whole tree,
> and process devices with the flag set. That way you don't need the
> root node to have the flag.

Yes, thats better, I agree.

> If a device has DMA, it will be removed. But its parent may not, in
> which case the parent will not be removed. However any children of the
> device will need to be removed, even if they don't have DMA, because
> we cannot have active children of an inactive device. Does that make
> sense?

Yes. I'll change this in the next patchset version accordingly.

Thanks,
Stefan


More information about the U-Boot mailing list