diff mbox series

pinctrl: mcp23s08: spi: Fix regmap allocation for mcp23s18

Message ID 20190108215158.16374-1-jdk@ti.com
State New
Headers show
Series pinctrl: mcp23s08: spi: Fix regmap allocation for mcp23s18 | expand

Commit Message

Jason Kridner Jan. 8, 2019, 9:51 p.m. UTC
Fixes issue created by 9b3e4207661e67f04c72af15e29f74cd944f5964.

It wasn't possible for one_regmap_config to be non-NULL at the point
it was tested for mcp23s18 devices.

Applied the same pattern of allocating one_regmap_config using
devm_kmemdump() and then initializing the local regmap structure
from that.

Signed-off-by: Jason Kridner <jdk@ti.com>
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Linus Walleij Jan. 11, 2019, 2:17 p.m. UTC | #1
On Tue, Jan 8, 2019 at 10:53 PM Jason Kridner <jkridner@gmail.com> wrote:

> Fixes issue created by 9b3e4207661e67f04c72af15e29f74cd944f5964.
>
> It wasn't possible for one_regmap_config to be non-NULL at the point
> it was tested for mcp23s18 devices.
>
> Applied the same pattern of allocating one_regmap_config using
> devm_kmemdump() and then initializing the local regmap structure
> from that.
>
> Signed-off-by: Jason Kridner <jdk@ti.com>

This does not apply on my kernel tree (a plain v5.0-rc1).

Am I doing something wrong or do you need to rebase/resend?

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 22558bf29424..3b3ec4a8d602 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -836,10 +836,13 @@  static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 		break;
 
 	case MCP_TYPE_S18:
+		one_regmap_config =
+			devm_kmemdup(dev, &mcp23x17_regmap,
+				sizeof(struct regmap_config), GFP_KERNEL);
 		if (!one_regmap_config)
 			return -ENOMEM;
 		mcp->regmap = devm_regmap_init(dev, &mcp23sxx_spi_regmap, mcp,
-					       &mcp23x17_regmap);
+					       one_regmap_config);
 		mcp->reg_shift = 1;
 		mcp->chip.ngpio = 16;
 		mcp->chip.label = "mcp23s18";