]> git.baikalelectronics.ru Git - kernel.git/commit
gpiolib: improve overlap check of range of gpio
authorBamvor Jian Zhang <bamvor.zhangjian@linaro.org>
Mon, 16 Nov 2015 05:02:46 +0000 (13:02 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 19 Nov 2015 08:24:40 +0000 (09:24 +0100)
commitb02a4b893c5580342c97ba0a439bc14cb1923070
treef4f867fe037e6d7d6eaae22e7dbc9e0f0ede2635
parent13b1f52e5e7d74fc71fd486af2370a9cc718a04e
gpiolib: improve overlap check of range of gpio

There are limitations for the current checker:
1.  Could not check the overlap if the new gpiochip is the secondly
    gpiochip.
2.  Could not check the overlap if the new gpiochip is overlap
    with the left of gpiochip. E.g. if we insert [c, d] between
    [a,b] and [e, f], and e >= c + d, it will successful even if
    c < a + b.
3.  Allow overlap of base of different gpiochip.

This patch fix these issues by checking the overlap of both right and
left gpiochip in the same loop statement.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
[Tweaked to remove unnecessary ret variable]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c