remove 2.6.25 support
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-2.6.25 / 964-backport_gpiolib_fix_off_by_one_errors.patch
1 From: Trent Piepho <xyzzy@speakeasy.org>
2 Date: Fri, 23 May 2008 20:04:44 +0000 (-0700)
3 Subject: gpiolib: fix off by one errors
4 X-Git-Tag: v2.6.26-rc4~31
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=bff5fda972dc23bd1806a47c2098ae173585d013
6
7 gpiolib: fix off by one errors
8
9 The last gpio belonging to a chip is chip->base + chip->ngpios - 1. Some
10 places in the code, but not all, forgot the critical minus one.
11
12 Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
13 Acked-by: David Brownell <dbrownell@users.sourceforge.net>
14 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
15 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
16 ---
17
18 --- a/drivers/gpio/gpiolib.c
19 +++ b/drivers/gpio/gpiolib.c
20 @@ -127,7 +127,7 @@ int __init gpiochip_reserve(int start, i
21 unsigned long flags;
22 int i;
23
24 - if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio))
25 + if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio - 1))
26 return -EINVAL;
27
28 spin_lock_irqsave(&gpio_lock, flags);
29 @@ -170,7 +170,7 @@ int gpiochip_add(struct gpio_chip *chip)
30 unsigned id;
31 int base = chip->base;
32
33 - if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio))
34 + if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))
35 && base >= 0) {
36 status = -EINVAL;
37 goto fail;
38 @@ -207,7 +207,7 @@ fail:
39 /* failures here can mean systems won't boot... */
40 if (status)
41 pr_err("gpiochip_add: gpios %d..%d (%s) not registered\n",
42 - chip->base, chip->base + chip->ngpio,
43 + chip->base, chip->base + chip->ngpio - 1,
44 chip->label ? : "generic");
45 return status;
46 }