From patchwork Wed Jul 19 22:34:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 791250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KEb09szc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xCX035vxVz9t2r for ; Thu, 20 Jul 2017 08:34:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933000AbdGSWem (ORCPT ); Wed, 19 Jul 2017 18:34:42 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:36539 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932078AbdGSWel (ORCPT ); Wed, 19 Jul 2017 18:34:41 -0400 Received: by mail-qk0-f195.google.com with SMTP id d136so907640qkg.3 for ; Wed, 19 Jul 2017 15:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wjfYeCcRMMSXg5+U0B+OmqyU+6a4JYFduwazgbsSaa4=; b=KEb09szczwErQecOBW//WtdIJsn/oJtxQsAoujktFL+2JRw/GnmW3EpVr+S1lnzLlX dVwkR2UUWvsS/w2NagHg3g5/t197vKzj2VbyB5NF+azI5R0zouiGwh3dsfFNb5Rc7nGd wqHGz6S55H1hZMC/FVFiiusGkn9rYEr5kXJ3buc5VamdgOgQOBfP3jIq/2yD02gCj7iY RubNP8p8KaGPcHmhHB3hogARay1u/xEeBey6nq56F+bjn8GjthfXwThZKrDd8L9eOzEq g0Sn/t421KMlITRXSxItJERlJsQHzsaJocxNcbCCST7010ATE2D7GBL/XPHMqo6kwbFM 4B7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wjfYeCcRMMSXg5+U0B+OmqyU+6a4JYFduwazgbsSaa4=; b=SLNy60vD1GWaIPyyonQ6TsoiifV6kOgqD5K1mSW0wzoLNyH0tBxvGvogpyJUVUD8pH dTHsDViBiTmbVIy+FGmmwlGI+hz5cIchXST6JX0z3Oe98NhmoXxITyoqtMJkJalls+9s xz73xVIkyr36jenHeKVCztdjcQVUddL30V4T8GeK2g2SrG2qtLdAoKIgwqzGLEpiT624 UuWvwdwWwYwkAtadJhDpLqLxpvVQMZAA3l9kXu6xnmuR8zAIwT6t10bCh8ejfQYgOEXK t3VP6bHmnyKgFjPddxj2D7BMY+6Rs7MMYUKc2m9o3oVN9v2sKLxO6uW5nq8vsvp48Oyz cBpA== X-Gm-Message-State: AIVw111/zHqlS8sa3kd5VoXwFuAvYaZXsIWTAmJYjAFuiVLDhuIJGjf0 hGZkyqXf6Eo7TtzG X-Received: by 10.55.126.198 with SMTP id z189mr2220445qkc.299.1500503681058; Wed, 19 Jul 2017 15:34:41 -0700 (PDT) Received: from localhost.localdomain ([189.61.213.245]) by smtp.gmail.com with ESMTPSA id t189sm729749qkf.92.2017.07.19.15.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jul 2017 15:34:40 -0700 (PDT) From: Fabio Estevam To: linus.walleij@linaro.org Cc: sergei.shtylyov@cogentembedded.com, andrew@lunn.ch, dmitry.torokhov@gmail.com, linux-gpio@vger.kernel.org, Fabio Estevam Subject: [RFC] gpio: consumer: Remove WARN_ON(1) when GPIOLIB is disabled Date: Wed, 19 Jul 2017 19:34:25 -0300 Message-Id: <1500503665-21278-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Fabio Estevam gpiod_get_optional() returns NULL when GPIOLIB is disabled since commit 22c403676dbbb7c6 ("gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled"). However, many gpiod functions still have WARN_ON(1) in their GPIOLIB=n stubs, which causes warnings in drivers even if the GPIO descriptior is requested via gpiod_get_optional(). Remove the WARN_ON(1) so that drivers can silently work fine without kernel warnings when GPIOLIB is disabled. Reported-by: Sergei Shtylyov Signed-off-by: Fabio Estevam --- include/linux/gpio/consumer.h | 59 ------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 8f702fc..40c1be5 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -197,17 +197,11 @@ gpiod_get_array_optional(struct device *dev, const char *con_id, static inline void gpiod_put(struct gpio_desc *desc) { might_sleep(); - - /* GPIO can never have been requested */ - WARN_ON(1); } static inline void gpiod_put_array(struct gpio_descs *descs) { might_sleep(); - - /* GPIO can never have been requested */ - WARN_ON(1); } static inline struct gpio_desc *__must_check @@ -254,150 +248,99 @@ devm_gpiod_get_array_optional(struct device *dev, const char *con_id, { return NULL; } - static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) { might_sleep(); - - /* GPIO can never have been requested */ - WARN_ON(1); } - static inline void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs) { might_sleep(); - - /* GPIO can never have been requested */ - WARN_ON(1); } - - static inline int gpiod_get_direction(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return -ENOSYS; } static inline int gpiod_direction_input(struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return -ENOSYS; } static inline int gpiod_direction_output(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); return -ENOSYS; } static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); return -ENOSYS; } - static inline int gpiod_get_value(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline void gpiod_set_value(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline void gpiod_set_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline int gpiod_get_raw_value(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline void gpiod_set_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline void gpiod_set_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline void gpiod_set_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array) { - /* GPIO can never have been requested */ - WARN_ON(1); } static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) { - /* GPIO can never have been requested */ - WARN_ON(1); return -ENOSYS; } static inline int gpiod_is_active_low(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline int gpiod_cansleep(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return 0; } static inline int gpiod_to_irq(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return -EINVAL; } @@ -408,8 +351,6 @@ static inline struct gpio_desc *gpio_to_desc(unsigned gpio) static inline int desc_to_gpio(const struct gpio_desc *desc) { - /* GPIO can never have been requested */ - WARN_ON(1); return -EINVAL; }