Commit graph

8 commits

Author SHA1 Message Date
Wen Yang
44b9f86cd4 pinctrl: samsung: fix leaked of_node references
The call to of_find_compatible_node returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:76:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:82:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Tomasz Figa <tomasz.figa@gmail.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-04-23 10:59:47 +02:00
Krzysztof Kozlowski
cafec5a7e0 pinctrl: samsung: Define suspend and resume callbacks for all banks and SoCs
Suspend and resume callbacks in Exynos/S5Pv210 pin controller drivers,
save and restore state of registers.  This operations should be done for
all banks which have external interrupts (as denoted by using
EXYNOS_PIN_BANK_EINTG/EINTW macros).

Add all banks of Exynos5260 and Exynos5420.  This is necessary step for
supporting suspend to RAM on these SoCs.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Tomasz Figa <tomasz.figa@gmail.com>
Cc: Sylwester Nawrocki <snawrocki@kernel.org>
Acked-by: Tomasz Figa <tomasz.figa@gmail.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
2018-07-24 21:35:54 +02:00
Paweł Chmiel
938a10bb49 pinctrl: samsung: Document required order of banks
This patch documents requirement coming from the way
exynos_eint_gpio_irq() is working now, which expects EINTG banks to be
at the beginning of the bank arrays.

Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
2018-04-18 17:48:39 +02:00
Paweł Chmiel
5cf9a338db pinctrl: samsung: Correct EINTG banks order
All banks with GPIO interrupts should be at beginning of bank array and
without any other types of banks between them.  This order is expected
by exynos_eint_gpio_irq, when doing interrupt group to bank translation.
Otherwise, kernel NULL pointer dereference would happen when trying to
handle interrupt, due to wrong bank being looked up.  Observed on
s5pv210, when trying to handle gpj0 interrupt, where kernel was mapping
it to gpi bank.

Cc: stable@vger.kernel.org
Fixes: 023e06dfa6 ("pinctrl: exynos: add exynos5410 SoC specific data")
Fixes: 608a26a7bc ("pinctrl: Add s5pv210 support to pinctrl-exynos)
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
2018-04-18 17:45:08 +02:00
Krzysztof Kozlowski
93b0beae72 pinctrl: samsung: Validate alias coming from DT
Driver uses alias from Device Tree as an index of pin controller data
array.  In case of a wrong DTB or an out-of-tree DTB, the alias could be
outside of this data array leading to out-of-bounds access.

Depending on binary and memory layout, this could be handled properly
(showing error like "samsung-pinctrl 3860000.pinctrl: driver data not
available") or could lead to exceptions.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: <stable@vger.kernel.org>
Fixes: 30574f0db1 ("pinctrl: add samsung pinctrl and gpiolib driver")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Tomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-03-08 13:02:26 +01:00
Krzysztof Kozlowski
221173a3fc pinctrl: samsung: Add SPDX license identifiers
Replace GPL license statements with SPDX GPL-2.0+ license identifiers.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-01-03 08:46:54 +01:00
Krzysztof Kozlowski
a453f3693f pinctrl: samsung: Explicitly cast pointer returned by of_iomap() to iomem
For S5Pv210 retention control, the driver stores the iomem pointer from
of_iomap() under a void pointer member.  This makes sparse unhappy:

    drivers/pinctrl/samsung/pinctrl-exynos.c:664:36: warning: incorrect type in argument 1 (different address spaces)
    drivers/pinctrl/samsung/pinctrl-exynos.c:664:36:    expected void const volatile [noderef] <asn:2>*addr
    drivers/pinctrl/samsung/pinctrl-exynos.c:664:36:    got void *

The iomem pointer is used safely (stored under priv by
s5pv210_retention_init(), used by s5pv210_retention_disable()) thus we
can add explicit casts to iomem to silence the warning.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
2017-06-07 20:40:48 +02:00
Krzysztof Kozlowski
cfa76ddf5b pinctrl: samsung: Split Exynos drivers per ARMv7 and ARMv8
Exynos pinctrl drivers contain pretty big per-SoC data structures.  The
pinctrl-exynos object file contained code and data for both ARMv7 and
ARMv8 SoCs thus it grew big.  There will not be a shared image between
ARMv7 and ARMv8 so there is no need to combine all of this into one
driver.

Splitting the data allows to make it more granular (e.g. code related to
ARMv8 Exynos is self-contained), slightly speed up the compilation and
reduce the effective size of compiled kernel.

The common data structures and functions reside still in existing
pinctrl-exynos.c.  Only the SoC-specific parts were moved out to new
files.  Except marking few functions non-static and adding them to
header, there were no functional changes in the code.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
2017-06-07 20:40:47 +02:00