diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2013-02-02 09:44:06 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-02-04 15:41:46 -0500 |
commit | 710b40eac4d91bd08f07f289cf6d6f3861c87187 (patch) | |
tree | fdd5afda03ff86731faeb100ae9e5a7d55b767c7 /drivers/gpio/gpiolib.c | |
parent | 6320c7b7990e1e759a18666b6c616aae9bd3b12d (diff) |
gpiolib: remove gpiochip_reserve()
gpiochip_reserve() has no user and stands in the way of the removal of
the static gpio_desc[] array. Remove this function as well as the now
unneeded RESERVED flag of struct gpio_desc.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 58 |
1 files changed, 8 insertions, 50 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 199fca15f270..e27877ad0163 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -52,14 +52,13 @@ struct gpio_desc { | |||
52 | /* flag symbols are bit numbers */ | 52 | /* flag symbols are bit numbers */ |
53 | #define FLAG_REQUESTED 0 | 53 | #define FLAG_REQUESTED 0 |
54 | #define FLAG_IS_OUT 1 | 54 | #define FLAG_IS_OUT 1 |
55 | #define FLAG_RESERVED 2 | 55 | #define FLAG_EXPORT 2 /* protected by sysfs_lock */ |
56 | #define FLAG_EXPORT 3 /* protected by sysfs_lock */ | 56 | #define FLAG_SYSFS 3 /* exported via /sys/class/gpio/control */ |
57 | #define FLAG_SYSFS 4 /* exported via /sys/class/gpio/control */ | 57 | #define FLAG_TRIG_FALL 4 /* trigger on falling edge */ |
58 | #define FLAG_TRIG_FALL 5 /* trigger on falling edge */ | 58 | #define FLAG_TRIG_RISE 5 /* trigger on rising edge */ |
59 | #define FLAG_TRIG_RISE 6 /* trigger on rising edge */ | 59 | #define FLAG_ACTIVE_LOW 6 /* sysfs value has active low */ |
60 | #define FLAG_ACTIVE_LOW 7 /* sysfs value has active low */ | 60 | #define FLAG_OPEN_DRAIN 7 /* Gpio is open drain type */ |
61 | #define FLAG_OPEN_DRAIN 8 /* Gpio is open drain type */ | 61 | #define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */ |
62 | #define FLAG_OPEN_SOURCE 9 /* Gpio is open source type */ | ||
63 | 62 | ||
64 | #define ID_SHIFT 16 /* add new flags before this one */ | 63 | #define ID_SHIFT 16 /* add new flags before this one */ |
65 | 64 | ||
@@ -132,7 +131,7 @@ static int gpiochip_find_base(int ngpio) | |||
132 | struct gpio_desc *desc = &gpio_desc[i]; | 131 | struct gpio_desc *desc = &gpio_desc[i]; |
133 | struct gpio_chip *chip = desc->chip; | 132 | struct gpio_chip *chip = desc->chip; |
134 | 133 | ||
135 | if (!chip && !test_bit(FLAG_RESERVED, &desc->flags)) { | 134 | if (!chip) { |
136 | spare++; | 135 | spare++; |
137 | if (spare == ngpio) { | 136 | if (spare == ngpio) { |
138 | base = i; | 137 | base = i; |
@@ -150,47 +149,6 @@ static int gpiochip_find_base(int ngpio) | |||
150 | return base; | 149 | return base; |
151 | } | 150 | } |
152 | 151 | ||
153 | /** | ||
154 | * gpiochip_reserve() - reserve range of gpios to use with platform code only | ||
155 | * @start: starting gpio number | ||
156 | * @ngpio: number of gpios to reserve | ||
157 | * Context: platform init, potentially before irqs or kmalloc will work | ||
158 | * | ||
159 | * Returns a negative errno if any gpio within the range is already reserved | ||
160 | * or registered, else returns zero as a success code. Use this function | ||
161 | * to mark a range of gpios as unavailable for dynamic gpio number allocation, | ||
162 | * for example because its driver support is not yet loaded. | ||
163 | */ | ||
164 | int __init gpiochip_reserve(int start, int ngpio) | ||
165 | { | ||
166 | int ret = 0; | ||
167 | unsigned long flags; | ||
168 | int i; | ||
169 | |||
170 | if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio - 1)) | ||
171 | return -EINVAL; | ||
172 | |||
173 | spin_lock_irqsave(&gpio_lock, flags); | ||
174 | |||
175 | for (i = start; i < start + ngpio; i++) { | ||
176 | struct gpio_desc *desc = &gpio_desc[i]; | ||
177 | |||
178 | if (desc->chip || test_bit(FLAG_RESERVED, &desc->flags)) { | ||
179 | ret = -EBUSY; | ||
180 | goto err; | ||
181 | } | ||
182 | |||
183 | set_bit(FLAG_RESERVED, &desc->flags); | ||
184 | } | ||
185 | |||
186 | pr_debug("%s: reserved gpios from %d to %d\n", | ||
187 | __func__, start, start + ngpio - 1); | ||
188 | err: | ||
189 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
190 | |||
191 | return ret; | ||
192 | } | ||
193 | |||
194 | /* caller ensures gpio is valid and requested, chip->get_direction may sleep */ | 152 | /* caller ensures gpio is valid and requested, chip->get_direction may sleep */ |
195 | static int gpio_get_direction(unsigned gpio) | 153 | static int gpio_get_direction(unsigned gpio) |
196 | { | 154 | { |