pinctrl: mcp23s08: Fix probe issues
Subsystems (2)
v2 cover pinctrl: mcp23s08: Fix probe issues
MCP23S18 driver probe failures on AM62L3 BeagleBadge[0].
Fix MCP23S18 probe failures found with BeagleBadge which has a MCP23S18 on board chip. Fixes are made up of initializing chip data before regmap init, and using device_property_read_u8 to match binding spec. First fix prevents kernel oops and second fix prevents MCP chip probe failure.
[0] https://github.com/beagleboard/BeagleBadge
Changes since v1:
- Add #define for base address & use instead of 0x40 hardcode base address
- Add patch 2/2
Judith Mendez (2):
pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap
init
pinctrl: mcp23s08: Read spi-present-mask as u8 not u32
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/2 pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
Regmap initialization triggers regcache_maple_populate() which attempts SPI read to populate cache. SPI read requires mcp->dev and mcp->addr to be set, without them, NULL pointer dereference occurs during probe.
Move initialization before mcp23s08_spi_regmap_init() call.
---
Changes since v1:
- Add #define for base adress & use instead of 0x40 hardcode base address
--- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08_spi.c +4 -1
@@ -10,6 +10,7 @@#include "pinctrl-mcp23s08.h" #define MCP_MAX_DEV_PER_CS 8 +#define MCP23S08_SPI_BASE 0x40/* * A given spi_device can represent up to eight mcp23sxx chips
@@ -173,6 +174,8 @@ static int mcp23s08_probe(struct spi_device *spi)for_each_set_bit (addr, &spi_present_mask,MCP_MAX_DEV_PER_CS ) { data->mcp[addr] = &data->chip[--chips]; data->mcp[addr]->irq = spi->irq; + data->mcp[addr]->dev = dev; + data->mcp[addr]->addr =MCP23S08_SPI_BASE | (addr <<1 ); ret =mcp23s08_spi_regmap_init (data->mcp[addr], dev, addr, info);if (ret)
@@ -184,7 +187,7 @@ static int mcp23s08_probe(struct spi_device *spi)if (!data->mcp[addr]->pinctrl_desc.name)return -ENOMEM ; - ret =mcp23s08_probe_one (data->mcp[addr], dev,0x40 | (addr <<1 ), + ret =mcp23s08_probe_one (data->mcp[addr], dev,MCP23S08_SPI_BASE | (addr <<1 ), info->type,-1 );if (ret <0 )return ret;
Signature · 1 line
2.54.0
PATCH v2 2/2 pinctrl: mcp23s08: Read spi-present-mask as u8 not u32
In reply to Judith MendezThe binding (microchip,mcp23s08) specifies microchip,spi-present-mask as uint8, but driver would read u32, causing type mismatch. Use device_property_read_u8 to match binding spec, hardware (8 chips max), & prevent probe failure.
---
Changes since v1:
- Add patch 2/2
--- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-mcp23s08_spi.c +3 -3
@@ -144,13 +144,13 @@ static int mcp23s08_probe(struct spi_device *spi)unsigned int addr;int chips;int ret; -u32 v; +u8 v; info =spi_get_device_match_data (spi); - ret =device_property_read_u32 (dev,"microchip,spi-present-mask" , &v); + ret =device_property_read_u8 (dev,"microchip,spi-present-mask" , &v);if (ret) { - ret =device_property_read_u32 (dev,"mcp,spi-present-mask" , &v); + ret =device_property_read_u8 (dev,"mcp,spi-present-mask" , &v);if (ret) {dev_err (dev,"missing spi-present-mask" );return ret;
Signature · 1 line
2.54.0
Linus Walleij
maintainerQuoted 8 lines · Judith Mendez
MCP23S18 driver probe failures on AM62L3 BeagleBadge[0].
Fix MCP23S18 probe failures found with BeagleBadge which has a MCP23S18 on board chip. Fixes are made up of initializing chip data before regmap init, and using
device_property_read_u8to match binding spec. First fix prevents kernel oops and second fix prevents MCP chip probe failure.
Patches applied for fixes!
Thanks for digging in and solving this.
Yours,
Linus Walleij