Commit 5d5dfc50 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpiolib: remove extra_checks

extra_checks is only used in a few places. It also depends on
a non-standard DEBUG define one needs to add to the source file. The
overhead of removing it should be minimal (we already use pure
might_sleep() in the code anyway) so drop it.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 7dd1871e
...@@ -47,19 +47,6 @@ ...@@ -47,19 +47,6 @@
* GPIOs can sometimes cost only an instruction or two per bit. * GPIOs can sometimes cost only an instruction or two per bit.
*/ */
/* When debugging, extend minimal trust to callers and platform code.
* Also emit diagnostic messages that may help initial bringup, when
* board setup or driver bugs are most common.
*
* Otherwise, minimize overhead in what may be bitbanging codepaths.
*/
#ifdef DEBUG
#define extra_checks 1
#else
#define extra_checks 0
#endif
/* Device and char device-related information */ /* Device and char device-related information */
static DEFINE_IDA(gpio_ida); static DEFINE_IDA(gpio_ida);
static dev_t gpio_devt; static dev_t gpio_devt;
...@@ -2351,7 +2338,7 @@ void gpiod_free(struct gpio_desc *desc) ...@@ -2351,7 +2338,7 @@ void gpiod_free(struct gpio_desc *desc)
return; return;
if (!gpiod_free_commit(desc)) if (!gpiod_free_commit(desc))
WARN_ON(extra_checks); WARN_ON(1);
module_put(desc->gdev->owner); module_put(desc->gdev->owner);
gpio_device_put(desc->gdev); gpio_device_put(desc->gdev);
...@@ -3729,7 +3716,7 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_persistent); ...@@ -3729,7 +3716,7 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_persistent);
*/ */
int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)
{ {
might_sleep_if(extra_checks); might_sleep();
VALIDATE_DESC(desc); VALIDATE_DESC(desc);
return gpiod_get_raw_value_commit(desc); return gpiod_get_raw_value_commit(desc);
} }
...@@ -3748,7 +3735,7 @@ int gpiod_get_value_cansleep(const struct gpio_desc *desc) ...@@ -3748,7 +3735,7 @@ int gpiod_get_value_cansleep(const struct gpio_desc *desc)
{ {
int value; int value;
might_sleep_if(extra_checks); might_sleep();
VALIDATE_DESC(desc); VALIDATE_DESC(desc);
value = gpiod_get_raw_value_commit(desc); value = gpiod_get_raw_value_commit(desc);
if (value < 0) if (value < 0)
...@@ -3779,7 +3766,7 @@ int gpiod_get_raw_array_value_cansleep(unsigned int array_size, ...@@ -3779,7 +3766,7 @@ int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
struct gpio_array *array_info, struct gpio_array *array_info,
unsigned long *value_bitmap) unsigned long *value_bitmap)
{ {
might_sleep_if(extra_checks); might_sleep();
if (!desc_array) if (!desc_array)
return -EINVAL; return -EINVAL;
return gpiod_get_array_value_complex(true, true, array_size, return gpiod_get_array_value_complex(true, true, array_size,
...@@ -3805,7 +3792,7 @@ int gpiod_get_array_value_cansleep(unsigned int array_size, ...@@ -3805,7 +3792,7 @@ int gpiod_get_array_value_cansleep(unsigned int array_size,
struct gpio_array *array_info, struct gpio_array *array_info,
unsigned long *value_bitmap) unsigned long *value_bitmap)
{ {
might_sleep_if(extra_checks); might_sleep();
if (!desc_array) if (!desc_array)
return -EINVAL; return -EINVAL;
return gpiod_get_array_value_complex(false, true, array_size, return gpiod_get_array_value_complex(false, true, array_size,
...@@ -3826,7 +3813,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep); ...@@ -3826,7 +3813,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep);
*/ */
void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value)
{ {
might_sleep_if(extra_checks); might_sleep();
VALIDATE_DESC_VOID(desc); VALIDATE_DESC_VOID(desc);
gpiod_set_raw_value_commit(desc, value); gpiod_set_raw_value_commit(desc, value);
} }
...@@ -3844,7 +3831,7 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value_cansleep); ...@@ -3844,7 +3831,7 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value_cansleep);
*/ */
void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
{ {
might_sleep_if(extra_checks); might_sleep();
VALIDATE_DESC_VOID(desc); VALIDATE_DESC_VOID(desc);
gpiod_set_value_nocheck(desc, value); gpiod_set_value_nocheck(desc, value);
} }
...@@ -3867,7 +3854,7 @@ int gpiod_set_raw_array_value_cansleep(unsigned int array_size, ...@@ -3867,7 +3854,7 @@ int gpiod_set_raw_array_value_cansleep(unsigned int array_size,
struct gpio_array *array_info, struct gpio_array *array_info,
unsigned long *value_bitmap) unsigned long *value_bitmap)
{ {
might_sleep_if(extra_checks); might_sleep();
if (!desc_array) if (!desc_array)
return -EINVAL; return -EINVAL;
return gpiod_set_array_value_complex(true, true, array_size, desc_array, return gpiod_set_array_value_complex(true, true, array_size, desc_array,
...@@ -3909,7 +3896,7 @@ int gpiod_set_array_value_cansleep(unsigned int array_size, ...@@ -3909,7 +3896,7 @@ int gpiod_set_array_value_cansleep(unsigned int array_size,
struct gpio_array *array_info, struct gpio_array *array_info,
unsigned long *value_bitmap) unsigned long *value_bitmap)
{ {
might_sleep_if(extra_checks); might_sleep();
if (!desc_array) if (!desc_array)
return -EINVAL; return -EINVAL;
return gpiod_set_array_value_complex(false, true, array_size, return gpiod_set_array_value_complex(false, true, array_size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment