[PATCH 00/19] dm: core: Fully separate ofdata_to_platdata() from probe()

Simon Glass sjg at chromium.org
Mon Dec 30 05:19:09 CET 2019


At present ofdata_to_platdata() is done as part of device_probe(). Drivers
are supposed to read their platdata in the ofdata_to_platdata method() but
this requirement is not always followed.

Having these methods separate helps deal with of-platdata, where the
probe() method is common to both DT/of-platdata operation, but the
ofdata_to_platdata() method is implemented differently.

Another case has come up where this separate is useful. Generation of ACPI
tables uses the of-platdata but does not want to probe the device. Probing
would cause U-Boot to violate one of its design principles, viz that it
should only probe devices that are used. For ACPI we want to generate a
table for each device, even if U-Boot does not use it. In fact it may not
even be possible to probe the device - e.g. an SD card which is not
present will cause an error on probe, yet we still must tell Linux about
the SD card connector in case it is used while Linux is running.

This series splits out the ofdata_to_platdata() part of device_probe() so
that it can be used separately from device_probe(). Thus devices now go
through two distinct states when probing: reading platform data and
actually touching the hardware to bring the device up.

This should not break existing boards since the operations still happen in
mostly the same order. The main change is that parents and uclasses are
probed after ofdata_to_platdata() is called.

HOWEVER it is quite possible that some boards break the rules and due to
a series of unfortunate events, something will break. Two boards were
found in this category already. SO this series may require some tidying up
from board maintainers, if problems arise.

Note that there are cases where devices must be probed in the
ofdata_to_platdata() method. An example is where a GPIO is selected - this
obviously requires that the GPIO device is probed.

One board was found to burst its size limit with this series, despite the
very small size increase. The patches to remove use of BUG_ON() are to
ensure that this series passes tests.


Simon Glass (19):
  common: Add a noisy assert()
  dm: core: Use assert_noisy() in devres
  usb: Drop use of BUG_ON() and WARN_ON()
  x86: apl: Avoid accessing the PCI bus before it is probed
  pci: Print a warning if the bus is accessed before probing
  aspeed: ast2500: Read clock ofdata in the correct method
  dm: core: Don't clear active flag twice when probe() fails
  dm: core: Move ofdata_to_platdata() call earlier
  dm: core: Allocate parent data separate from probing parent
  dm: core: Add a comment for DM_FLAG_OF_PLATDATA
  dm: core: Export a new function to read platdata
  dm: core: Add a new flag to track platform data
  dm: devres: Create a new devres header file
  test: Add functions to find the amount of allocated memory
  dm: devres: Convert to use logging
  dm: test: Add a test driver for devres
  dm: devres: Add tests
  dm: devres: Use an enum for the allocation phase
  dm: devres: Add a new OFDATA phase

 arch/sandbox/dts/test.dts              |   4 +
 arch/x86/cpu/apollolake/p2sb.c         |  20 +-
 arch/x86/cpu/apollolake/pmc.c          |  20 +-
 drivers/clk/aspeed/clk_ast2500.c       |   4 +-
 drivers/core/device-remove.c           |   1 +
 drivers/core/device.c                  |  56 +++--
 drivers/core/devres.c                  |  57 ++++-
 drivers/pci/pci-uclass.c               |  13 ++
 drivers/usb/gadget/composite.c         |   4 +
 drivers/usb/gadget/f_mass_storage.c    |   4 +
 drivers/usb/musb-new/musb_core.c       |   4 +
 drivers/usb/musb-new/musb_gadget_ep0.c |   2 +-
 include/dm/device-internal.h           |  16 ++
 include/dm/device.h                    | 259 +---------------------
 include/dm/devres.h                    | 289 +++++++++++++++++++++++++
 include/dm/uclass-id.h                 |   1 +
 include/log.h                          |  15 ++
 include/test/test.h                    |  10 +
 include/test/ut.h                      |  16 ++
 test/dm/Makefile                       |   1 +
 test/dm/devres.c                       | 186 ++++++++++++++++
 test/dm/test-fdt.c                     |  58 +++++
 test/ut.c                              |  14 ++
 23 files changed, 760 insertions(+), 294 deletions(-)
 create mode 100644 include/dm/devres.h
 create mode 100644 test/dm/devres.c

-- 
2.24.1.735.g03f4e72817-goog



More information about the U-Boot mailing list