aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2013-11-14 07:03:53 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-14 17:20:45 -0500
commite13ac47bec20797fa9262cffcae9cf0e3aa1b9b2 (patch)
treeb783af9c4f87415ac9a264357da4875146d8fd00
parent70762abb9f89d97603a04cc3438988ca0cf886eb (diff)
spi: Use stable dev_name for ACPI enumerated SPI slaves
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@linux.intel.com> Acked-by: Mark Brown <broonie@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/spi/spi.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index a968d8549ee5..8763d93ce2b7 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -357,6 +357,19 @@ struct spi_device *spi_alloc_device(struct spi_master *master)
357} 357}
358EXPORT_SYMBOL_GPL(spi_alloc_device); 358EXPORT_SYMBOL_GPL(spi_alloc_device);
359 359
360static void spi_dev_set_name(struct spi_device *spi)
361{
362 struct acpi_device *adev = ACPI_COMPANION(&spi->dev);
363
364 if (adev) {
365 dev_set_name(&spi->dev, "spi-%s", acpi_dev_name(adev));
366 return;
367 }
368
369 dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev),
370 spi->chip_select);
371}
372
360/** 373/**
361 * spi_add_device - Add spi_device allocated with spi_alloc_device 374 * spi_add_device - Add spi_device allocated with spi_alloc_device
362 * @spi: spi_device to register 375 * @spi: spi_device to register
@@ -383,9 +396,7 @@ int spi_add_device(struct spi_device *spi)
383 } 396 }
384 397
385 /* Set the bus ID string */ 398 /* Set the bus ID string */
386 dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), 399 spi_dev_set_name(spi);
387 spi->chip_select);
388
389 400
390 /* We need to make sure there's no other device with this 401 /* We need to make sure there's no other device with this
391 * chipselect **BEFORE** we call setup(), else we'll trash 402 * chipselect **BEFORE** we call setup(), else we'll trash