OSDN Git Service

spi/acpi: enumerate all SPI slaves in the namespace
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 30 May 2019 11:16:34 +0000 (13:16 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 13 Jun 2019 19:04:32 +0000 (20:04 +0100)
commit4c3c59544f33e97cf8557f27e05a9904ead16363
tree22b2abadc8a5eb8d938fd97202f45990aa9c2614
parent4343f61103cdb8ccd6f3d5dd7168f1176a1cee37
spi/acpi: enumerate all SPI slaves in the namespace

Currently, the ACPI enumeration that takes place when registering a
SPI master only considers immediate child devices in the ACPI namespace,
rather than checking the ResourceSource field in the SpiSerialBus()
resource descriptor.

This is incorrect: SPI slaves could reside anywhere in the ACPI
namespace, and so we should enumerate the entire namespace and look for
any device that refers to the newly registered SPI master in its
resource descriptor.

So refactor the existing code and use a lookup structure so that
allocating the SPI device structure is deferred until we have identified
the device as an actual child of the controller. This approach is
loosely based on the way the I2C subsystem handles ACPI enumeration.

Note that Apple x86 hardware does not rely on SpiSerialBus() resources
in _CRS but uses nested devices below the controller's device node in
the ACPI namespace, with a special set of device properties. This means
we have to take care to only parse those properties for device nodes
that are direct children of the controller node.

Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-spi@vger.kernel.org
Cc: broonie@kernel.org
Cc: andy.shevchenko@gmail.com
Cc: masahisa.kojima@linaro.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: linux-acpi@vger.kernel.org
Cc: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c