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)
commitef7c7553039b3d1c847b38b0f1ea208f8d5d8370
treef4f867fe037e6d7d6eaae22e7dbc9e0f0ede2635
parented37915cb1fde446bd52069d7a708301b7e7b607
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