[3.13.y.z extended stable] Patch "gpio: mcp23s08: Bug fix of SPI device tree registration." has been added to staging queue

Kamal Mostafa kamal at canonical.com
Tue Jun 17 21:42:15 UTC 2014


This is a note to let you know that I have just added a patch titled

    gpio: mcp23s08: Bug fix of SPI device tree registration.

to the linux-3.13.y-queue branch of the 3.13.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue

This patch is scheduled to be released in version 3.13.11.4.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From c9325199f907dd1a620996a3d13a638ea6108c2d Mon Sep 17 00:00:00 2001
From: Michael Welling <mwelling at ieee.org>
Date: Wed, 16 Apr 2014 20:00:24 -0500
Subject: gpio: mcp23s08: Bug fix of SPI device tree registration.

commit 99e4b98dbe3ad1fe38a74d12c3b8d44a55930de4 upstream.

The chips variable needs to be incremented for each chip that is
found in the spi_present_mask when registering via device tree.
Without this and the checking a negative index is passed to the
data->chip array in a subsequent loop.

Signed-off-by: Michael Welling <mwelling at ieee.org>
Acked-by: Peter Korsgaard <peter at korsgaard.com>
Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 drivers/gpio/gpio-mcp23s08.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 2deb0c5..114e1aa 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -656,9 +656,11 @@ static int mcp23s08_probe(struct spi_device *spi)
 			dev_err(&spi->dev, "invalid spi-present-mask\n");
 			return -ENODEV;
 		}
-
-		for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
+		for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
+			if ((spi_present_mask & (1 << addr)))
+				chips++;
 			pullups[addr] = 0;
+		}
 	} else {
 		type = spi_get_device_id(spi)->driver_data;
 		pdata = dev_get_platdata(&spi->dev);
@@ -681,12 +683,12 @@ static int mcp23s08_probe(struct spi_device *spi)
 			pullups[addr] = pdata->chip[addr].pullups;
 		}

-		if (!chips)
-			return -ENODEV;
-
 		base = pdata->base;
 	}

+	if (!chips)
+		return -ENODEV;
+
 	data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08),
 			GFP_KERNEL);
 	if (!data)
--
1.9.1





More information about the kernel-team mailing list