* [PATCH v1 1/2] pinctrl-mcp23s08: Dup full chunk of memory for regmap configuration
@ 2020-10-09 17:11 Andy Shevchenko
2020-10-09 17:11 ` [PATCH v1 2/2] pinctrl: mcp23s08: Print error message when regmap init fails Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-10-09 17:11 UTC (permalink / raw)
To: Linus Walleij, linux-gpio; +Cc: Andy Shevchenko, Martin Hundebøll
It appears that simplification of mcp23s08_spi_regmap_init() made
a regression due to wrong size calculation for dev,_kmemdup() call.
It mises the fact that config variable is already a pointer, thus
the sizeof() calculation is wrong and only 4/8 bytes were copied.
Fix the parameters to devm_kmemdup() to copy full chunk of memory.
Fixes: 0874758ecb2b ("pinctrl: mcp23s08: Refactor mcp23s08_spi_regmap_init()")
Reported-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 1f47a661b0a7..7c72cffe1412 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -119,7 +119,7 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,
return -EINVAL;
}
- copy = devm_kmemdup(dev, &config, sizeof(config), GFP_KERNEL);
+ copy = devm_kmemdup(dev, config, sizeof(*config), GFP_KERNEL);
if (!copy)
return -ENOMEM;
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v1 2/2] pinctrl: mcp23s08: Print error message when regmap init fails
2020-10-09 17:11 [PATCH v1 1/2] pinctrl-mcp23s08: Dup full chunk of memory for regmap configuration Andy Shevchenko
@ 2020-10-09 17:11 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-10-09 17:11 UTC (permalink / raw)
To: Linus Walleij, linux-gpio; +Cc: Andy Shevchenko, Martin Hundebøll
It is useful for debugging to have the error message printed
when regmap initialisation fails. Add it to the driver.
Cc: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 7c72cffe1412..9ae10318f6f3 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -126,6 +126,8 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,
copy->name = name;
mcp->regmap = devm_regmap_init(dev, &mcp23sxx_spi_regmap, mcp, copy);
+ if (IS_ERR(mcp->regmap))
+ dev_err(dev, "regmap init failed for %s\n", mcp->chip.label);
return PTR_ERR_OR_ZERO(mcp->regmap);
}
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-09 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-09 17:11 [PATCH v1 1/2] pinctrl-mcp23s08: Dup full chunk of memory for regmap configuration Andy Shevchenko
2020-10-09 17:11 ` [PATCH v1 2/2] pinctrl: mcp23s08: Print error message when regmap init fails Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).