diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2014-02-23 08:11:49 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2014-02-23 08:11:49 +0000 |
commit | 6686b2a76f966aafb90c0173c5f24773e34690b9 (patch) | |
tree | 272159d7485d6766d002a37f0ffb904c50b3f4cc /target/linux/ar71xx/patches-3.10 | |
parent | 55d0d060ef66bcf4d9f426aadb4564b0d0b9e0a7 (diff) | |
download | upstream-6686b2a76f966aafb90c0173c5f24773e34690b9.tar.gz upstream-6686b2a76f966aafb90c0173c5f24773e34690b9.tar.bz2 upstream-6686b2a76f966aafb90c0173c5f24773e34690b9.zip |
ar71xx: improve platform device support in the gpio-74x164 driver
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39701 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/patches-3.10')
-rw-r--r-- | target/linux/ar71xx/patches-3.10/451-gpio-74x164-improve-platform-device-support.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/target/linux/ar71xx/patches-3.10/451-gpio-74x164-improve-platform-device-support.patch b/target/linux/ar71xx/patches-3.10/451-gpio-74x164-improve-platform-device-support.patch new file mode 100644 index 0000000000..b19bb85c85 --- /dev/null +++ b/target/linux/ar71xx/patches-3.10/451-gpio-74x164-improve-platform-device-support.patch @@ -0,0 +1,74 @@ +--- a/drivers/gpio/gpio-74x164.c ++++ b/drivers/gpio/gpio-74x164.c +@@ -109,10 +109,14 @@ static int gen_74x164_probe(struct spi_d + { + struct gen_74x164_chip *chip; + struct gen_74x164_chip_platform_data *pdata; ++ struct device_node *np; + int ret; + +- if (!spi->dev.of_node) { +- dev_err(&spi->dev, "No device tree data available.\n"); ++ pdata = spi->dev.platform_data; ++ np = spi->dev.of_node; ++ ++ if (!np && !pdata) { ++ dev_err(&spi->dev, "No configuration data available.\n"); + return -EINVAL; + } + +@@ -129,7 +133,6 @@ static int gen_74x164_probe(struct spi_d + if (!chip) + return -ENOMEM; + +- pdata = spi->dev.platform_data; + if (pdata && pdata->base) + chip->gpio_chip.base = pdata->base; + else +@@ -146,12 +149,19 @@ static int gen_74x164_probe(struct spi_d + chip->gpio_chip.get = gen_74x164_get_value; + chip->gpio_chip.set = gen_74x164_set_value; + +- if (of_property_read_u32(spi->dev.of_node, "registers-number", &chip->registers)) { +- dev_err(&spi->dev, "Missing registers-number property in the DT.\n"); +- ret = -EINVAL; +- goto exit_destroy; ++ if (np) { ++ if (of_property_read_u32(spi->dev.of_node, "registers-number", &chip->registers)) { ++ dev_err(&spi->dev, "Missing registers-number property in the DT.\n"); ++ ret = -EINVAL; ++ goto exit_destroy; ++ } ++ } else if (pdata) { ++ chip->registers = pdata->num_registers; + } + ++ if (!chip->registers) ++ chip->registers = 1; ++ + chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; + chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL); + if (!chip->buffer) { +@@ -159,6 +169,9 @@ static int gen_74x164_probe(struct spi_d + goto exit_destroy; + } + ++ if (pdata && pdata->init_data) ++ memcpy(chip->buffer, pdata->init_data, chip->registers); ++ + chip->gpio_chip.can_sleep = 1; + chip->gpio_chip.dev = &spi->dev; + chip->gpio_chip.owner = THIS_MODULE; +--- a/include/linux/spi/74x164.h ++++ b/include/linux/spi/74x164.h +@@ -4,6 +4,10 @@ + struct gen_74x164_chip_platform_data { + /* number assigned to the first GPIO */ + unsigned base; ++ /* number of chained registers */ ++ unsigned num_registers; ++ /* address of a buffer containing initial data */ ++ u8 *init_data; + }; + + #endif |