diff mbox

[1/3] spi/xilinx: Use automatic bus number on device tree

Message ID 1421855590-9210-2-git-send-email-ricardo.ribalda@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ricardo Ribalda Delgado Jan. 21, 2015, 3:53 p.m. UTC
If there is more than one spi device on a device tree, the second one
will fail to probe due to a duplicated bus_num.

This patch uses automatic bus number if the device is deined on a device
tree.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/spi/spi-xilinx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Lars-Peter Clausen Jan. 21, 2015, 4:02 p.m. UTC | #1
On 01/21/2015 04:53 PM, Ricardo Ribalda Delgado wrote:
> If there is more than one spi device on a device tree, the second one
> will fail to probe due to a duplicated bus_num.
 > [...]

This should already be fixed. See commit 4b153a2137c5 ("spi: xilinx: Use 
pdev->id instead of pdev->dev.id for the SPI bus number")[1]. If the device 
was registered using devicetree pdev->id is -1, so dynamic numbers will be used.

- Lars

[1] 
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/spi/spi-xilinx.c?id=4b153a2137c5d2914794c8944d78c731c1b0ae9d
Ricardo Ribalda Delgado Jan. 21, 2015, 4:51 p.m. UTC | #2
Hi Lars

I think you are right. The other patches on the set are still valid though


Thanks!

On Wed, Jan 21, 2015 at 5:02 PM, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 01/21/2015 04:53 PM, Ricardo Ribalda Delgado wrote:
>>
>> If there is more than one spi device on a device tree, the second one
>> will fail to probe due to a duplicated bus_num.
>
>> [...]
>
> This should already be fixed. See commit 4b153a2137c5 ("spi: xilinx: Use
> pdev->id instead of pdev->dev.id for the SPI bus number")[1]. If the device
> was registered using devicetree pdev->id is -1, so dynamic numbers will be
> used.
>
> - Lars
>
> [1]
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/spi/spi-xilinx.c?id=4b153a2137c5d2914794c8944d78c731c1b0ae9d
>
diff mbox

Patch

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 79bd84f..2ea4ca5 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -332,14 +332,17 @@  static int xilinx_spi_probe(struct platform_device *pdev)
 	struct spi_master *master;
 	u32 tmp;
 	u8 i;
+	s16 bus_num;
 
 	pdata = dev_get_platdata(&pdev->dev);
 	if (pdata) {
 		num_cs = pdata->num_chipselect;
 		bits_per_word = pdata->bits_per_word;
+		bus_num = pdev->id;
 	} else {
 		of_property_read_u32(pdev->dev.of_node, "xlnx,num-ss-bits",
 					  &num_cs);
+		bus_num = -1;
 	}
 
 	if (!num_cs) {
@@ -369,7 +372,7 @@  static int xilinx_spi_probe(struct platform_device *pdev)
 		goto put_master;
 	}
 
-	master->bus_num = pdev->id;
+	master->bus_num = bus_num;
 	master->num_chipselect = num_cs;
 	master->dev.of_node = pdev->dev.of_node;