Current spi bus_num.chip_select "spix.y" based device naming scheme may not be stable enough to be used in name based matching, for instance within ALSA SoC subsystem. This can be problem in PC kind of platforms if there are changes in SPI bus configuration, amount of busses or probe order. This patch addresses the problem by using the ACPI device name with "spi-" prefix for ACPI enumerated SPI slave. For them device name "spix.y" becomes "spi-INTABCD:ij". Signed-off-by: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx> --- drivers/spi/spi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 740f9dd..4c0c801 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -38,6 +38,7 @@ #include <linux/kthread.h> #include <linux/ioport.h> #include <linux/acpi.h> +#include <acpi/acpi_bus.h> static void spidev_release(struct device *dev) { @@ -352,6 +353,21 @@ struct spi_device *spi_alloc_device(struct spi_master *master) } EXPORT_SYMBOL_GPL(spi_alloc_device); +void spi_dev_set_name(struct spi_device *spi) +{ + if (ACPI_HANDLE(&spi->dev)) { + struct acpi_device *adev; + if (!acpi_bus_get_device(ACPI_HANDLE(&spi->dev), &adev)) { + dev_set_name(&spi->dev, "spi-%s", + dev_name(&adev->dev)); + return; + } + } + + dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), + spi->chip_select); +} + /** * spi_add_device - Add spi_device allocated with spi_alloc_device * @spi: spi_device to register @@ -378,9 +394,7 @@ int spi_add_device(struct spi_device *spi) } /* Set the bus ID string */ - dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), - spi->chip_select); - + spi_dev_set_name(spi); /* We need to make sure there's no other device with this * chipselect **BEFORE** we call setup(), else we'll trash -- 1.8.4.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html