diff options
author | Jan Kundrát <jan.kundrat@cesnet.cz> | 2018-01-26 20:16:47 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-02-12 10:47:24 +0100 |
commit | ed231751413d4f33403f0bf0d5a957b41824f940 (patch) | |
tree | 4d4263854356a2ea5bceb40bdcc07e0849e7c3e8 /drivers/pinctrl/pinctrl-mcp23s08.c | |
parent | 9b3e4207661e67f04c72af15e29f74cd944f5964 (diff) | |
download | linux-ed231751413d4f33403f0bf0d5a957b41824f940.tar.gz linux-ed231751413d4f33403f0bf0d5a957b41824f940.tar.bz2 linux-ed231751413d4f33403f0bf0d5a957b41824f940.zip |
pinctrl: mcp23s08: spi: Add HW address to gpio_chip.label
When several devices are sharing one hardware SPI CS, there is no visual
clue in `lsgpio` or in /sys/kernel/debug/gpio about which one is which
one. Stuff depends on the enumeration order, and therefore lower chip
addresses always go first, but that's just an implementation detail.
This change includes the device-specific address in the debug output:
gpiochip4: GPIOs 464-479, parent: spi/spi1.1, mcp23s17.2, can sleep:
gpiochip3: GPIOs 480-495, parent: spi/spi1.1, mcp23s17.1, can sleep:
Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-mcp23s08.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-mcp23s08.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index e86d23279ac1..ab2d9393b935 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -772,6 +772,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, int status, ret; bool mirror = false; struct regmap_config *one_regmap_config = NULL; + int raw_chip_address = (addr & ~0x40) >> 1; mutex_init(&mcp->lock); @@ -800,7 +801,8 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, sizeof(struct regmap_config), GFP_KERNEL); mcp->reg_shift = 0; mcp->chip.ngpio = 8; - mcp->chip.label = "mcp23s08"; + mcp->chip.label = devm_kasprintf(dev, GFP_KERNEL, + "mcp23s08.%d", raw_chip_address); break; case MCP_TYPE_S17: one_regmap_config = @@ -808,13 +810,14 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, sizeof(struct regmap_config), GFP_KERNEL); mcp->reg_shift = 1; mcp->chip.ngpio = 16; - mcp->chip.label = "mcp23s17"; + mcp->chip.label = devm_kasprintf(dev, GFP_KERNEL, + "mcp23s17.%d", raw_chip_address); break; } if (!one_regmap_config) return -ENOMEM; - one_regmap_config->name = devm_kasprintf(dev, GFP_KERNEL, "%d", (addr & ~0x40) >> 1); + one_regmap_config->name = devm_kasprintf(dev, GFP_KERNEL, "%d", raw_chip_address); mcp->regmap = devm_regmap_init(dev, &mcp23sxx_spi_regmap, mcp, one_regmap_config); break; |