]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.16.3/spi-orion-fix-incorrect-handling-of-cell-index-dt-property.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / spi-orion-fix-incorrect-handling-of-cell-index-dt-property.patch
1 From e06871cd2c92e5c65d7ca1d32866b4ca5dd4ac30 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Sun, 27 Jul 2014 23:53:19 +0200
4 Subject: spi: orion: fix incorrect handling of cell-index DT property
5
6 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7
8 commit e06871cd2c92e5c65d7ca1d32866b4ca5dd4ac30 upstream.
9
10 In commit f814f9ac5a81 ("spi/orion: add device tree binding"), Device
11 Tree support was added to the spi-orion driver. However, this commit
12 reads the "cell-index" property, without taking into account the fact
13 that DT properties are big-endian encoded.
14
15 Since most of the platforms using spi-orion with DT have apparently
16 not used anything but cell-index = <0>, the problem was not
17 visible. But as soon as one starts using cell-index = <1>, the problem
18 becomes clearly visible, as the master->bus_num gets a wrong value
19 (actually it gets the value 0, which conflicts with the first bus that
20 has cell-index = <0>).
21
22 This commit fixes that by using of_property_read_u32() to read the
23 property value, which does the appropriate endianness conversion when
24 needed.
25
26 Fixes: f814f9ac5a81 ("spi/orion: add device tree binding")
27 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
28 Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
29 Signed-off-by: Mark Brown <broonie@linaro.org>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31
32 ---
33 drivers/spi/spi-orion.c | 10 ++++------
34 1 file changed, 4 insertions(+), 6 deletions(-)
35
36 --- a/drivers/spi/spi-orion.c
37 +++ b/drivers/spi/spi-orion.c
38 @@ -346,8 +346,6 @@ static int orion_spi_probe(struct platfo
39 struct resource *r;
40 unsigned long tclk_hz;
41 int status = 0;
42 - const u32 *iprop;
43 - int size;
44
45 master = spi_alloc_master(&pdev->dev, sizeof(*spi));
46 if (master == NULL) {
47 @@ -358,10 +356,10 @@ static int orion_spi_probe(struct platfo
48 if (pdev->id != -1)
49 master->bus_num = pdev->id;
50 if (pdev->dev.of_node) {
51 - iprop = of_get_property(pdev->dev.of_node, "cell-index",
52 - &size);
53 - if (iprop && size == sizeof(*iprop))
54 - master->bus_num = *iprop;
55 + u32 cell_index;
56 + if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
57 + &cell_index))
58 + master->bus_num = cell_index;
59 }
60
61 /* we support only mode 0, and no options */