aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2014-07-27 17:53:19 -0400
committerMark Brown <broonie@linaro.org>2014-07-28 17:30:43 -0400
commite06871cd2c92e5c65d7ca1d32866b4ca5dd4ac30 (patch)
treef29742cee9356fa0883df89eba0473207832bb62
parent7171511eaec5bf23fb06078f59784a3a0626b38f (diff)
spi: orion: fix incorrect handling of cell-index DT property
In commit f814f9ac5a81 ("spi/orion: add device tree binding"), Device Tree support was added to the spi-orion driver. However, this commit reads the "cell-index" property, without taking into account the fact that DT properties are big-endian encoded. Since most of the platforms using spi-orion with DT have apparently not used anything but cell-index = <0>, the problem was not visible. But as soon as one starts using cell-index = <1>, the problem becomes clearly visible, as the master->bus_num gets a wrong value (actually it gets the value 0, which conflicts with the first bus that has cell-index = <0>). This commit fixes that by using of_property_read_u32() to read the property value, which does the appropriate endianness conversion when needed. Fixes: f814f9ac5a81 ("spi/orion: add device tree binding") Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: <stable@vger.kernel.org> # v3.6+
-rw-r--r--drivers/spi/spi-orion.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index d018a4aac3a1..c206a4ad83cd 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -346,8 +346,6 @@ static int orion_spi_probe(struct platform_device *pdev)
346 struct resource *r; 346 struct resource *r;
347 unsigned long tclk_hz; 347 unsigned long tclk_hz;
348 int status = 0; 348 int status = 0;
349 const u32 *iprop;
350 int size;
351 349
352 master = spi_alloc_master(&pdev->dev, sizeof(*spi)); 350 master = spi_alloc_master(&pdev->dev, sizeof(*spi));
353 if (master == NULL) { 351 if (master == NULL) {
@@ -358,10 +356,10 @@ static int orion_spi_probe(struct platform_device *pdev)
358 if (pdev->id != -1) 356 if (pdev->id != -1)
359 master->bus_num = pdev->id; 357 master->bus_num = pdev->id;
360 if (pdev->dev.of_node) { 358 if (pdev->dev.of_node) {
361 iprop = of_get_property(pdev->dev.of_node, "cell-index", 359 u32 cell_index;
362 &size); 360 if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
363 if (iprop && size == sizeof(*iprop)) 361 &cell_index))
364 master->bus_num = *iprop; 362 master->bus_num = cell_index;
365 } 363 }
366 364
367 /* we support only mode 0, and no options */ 365 /* we support only mode 0, and no options */