Commit 9a42a8a458c76c4583fcb5f8eaa336fd8157be20
Committed by
Greg Kroah-Hartman
1 parent
64f2260ea2
gpio: mcp23s08: handle default gpio base
commit b184c388f773f30b6c707d3d4599b2db80f4390c upstream. Create default gpio base if neither device node nor platform data is defined. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Tested-by: Antonio Fiol <antonio@fiol.es> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 10 additions and 7 deletions Side-by-side Diff
drivers/gpio/gpio-mcp23s08.c
... | ... | @@ -785,9 +785,11 @@ |
785 | 785 | client->irq = irq_of_parse_and_map(client->dev.of_node, 0); |
786 | 786 | } else { |
787 | 787 | pdata = dev_get_platdata(&client->dev); |
788 | - if (!pdata || !gpio_is_valid(pdata->base)) { | |
789 | - dev_dbg(&client->dev, "invalid platform data\n"); | |
790 | - return -EINVAL; | |
788 | + if (!pdata) { | |
789 | + pdata = devm_kzalloc(&client->dev, | |
790 | + sizeof(struct mcp23s08_platform_data), | |
791 | + GFP_KERNEL); | |
792 | + pdata->base = -1; | |
791 | 793 | } |
792 | 794 | } |
793 | 795 | |
... | ... | @@ -908,10 +910,11 @@ |
908 | 910 | } else { |
909 | 911 | type = spi_get_device_id(spi)->driver_data; |
910 | 912 | pdata = dev_get_platdata(&spi->dev); |
911 | - if (!pdata || !gpio_is_valid(pdata->base)) { | |
912 | - dev_dbg(&spi->dev, | |
913 | - "invalid or missing platform data\n"); | |
914 | - return -EINVAL; | |
913 | + if (!pdata) { | |
914 | + pdata = devm_kzalloc(&spi->dev, | |
915 | + sizeof(struct mcp23s08_platform_data), | |
916 | + GFP_KERNEL); | |
917 | + pdata->base = -1; | |
915 | 918 | } |
916 | 919 | |
917 | 920 | for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { |