Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6210197ybv; Tue, 18 Feb 2020 12:05:33 -0800 (PST) X-Google-Smtp-Source: APXvYqx8NDvt3XNycDqpGPCBJaZEGldSOwAXu5VNCYAxEjuD8KrpSUGAMMOsUV5T1g6+Gaq6I0zd X-Received: by 2002:aca:ad11:: with SMTP id w17mr2467530oie.85.1582056333703; Tue, 18 Feb 2020 12:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056333; cv=none; d=google.com; s=arc-20160816; b=RtsEjbpoJTdUauIDx5m42ptxzDe77BoBORph5Qe1WZ4v+krHg2W+DstW5Wmnrd97aP PnsXLkqExzwdWvq0Rkivqzx7+2DxXZzNkjKYfHqTJRGt90feMARNB+nhQScldSH9hHiX ijhBMDqudsUs7010SD2bWXechOm70s9iyRAAwk68ZPJpgdf+J2G+/c+DcYKvceAz40bb pZEcPmUMQTlGv1FE4tv0Zmeva2pfpWpjRWW3SGVSdYc1qFTHSjkvfCDFvsNMjRPYsUxB O1jFdAmKqSTJE3QyTgAhFbpyYXJVZhveLDTOtvF1ytR1Tg1qAc18bvBku4dtSNaAiALe Qh8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IPHPhrNNzdfduB7Jua9dKTDrF8NXj8mADWfCJDNlBn4=; b=u1uI9liquoVnfrk6+FihN781DF7dgLw29+KZ5myfO61LCRn7j7W4zbHvN1T00BbEcn TE6CMurAeRUiYIM99G0dJV+RDidqDVwpEjoAhuw1Fy03xKnHIQupoh0uwokzqP4VSr7f 4F/ar7On1APm4zVvFvV6XmLZqzb3L1xYQBDyKApmLnkmyCMzpkAyi0Ft0lqrc71Ey5TM 4U4v6ToJLmJ6DJ1a3StmbyRYjIaVTRV+P12CXX0ufAhADgbuUz6YxcBiARSFA1uG3B6l P3FImAPlnyxUKb4wmdXQd4pJIGCFIg7xVOdbqWOhMv2j0AjosdT1dCK3MejQ7TdnDJke u0Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GAjzEAMY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si8179246oir.71.2020.02.18.12.05.21; Tue, 18 Feb 2020 12:05:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GAjzEAMY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729036AbgBRUEL (ORCPT + 99 others); Tue, 18 Feb 2020 15:04:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:45386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728305AbgBRUDz (ORCPT ); Tue, 18 Feb 2020 15:03:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8B1C2465A; Tue, 18 Feb 2020 20:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582056235; bh=VtW4n0e7ugqK2sqHKsCySy63GQ9Z4vHok72WIyQLeSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GAjzEAMYJfViRH215JHhXHL6QkNYEx+ap8ZveNFrsBSXNSjwYKC4KK2ib1y/U3qyt +JDh7eJEJSVnU/qnwEEzochLjgv2rzcauelIqtmbkaP2zoyH3ZzG9zhthrwfXb6num YhM7Hlr14qBaSc2A/8L99Sx0F0WEKZGURggh8ZYI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Ulf Hansson , Sasha Levin Subject: [PATCH 5.5 79/80] gpio: add gpiod_toggle_active_low() Date: Tue, 18 Feb 2020 20:55:40 +0100 Message-Id: <20200218190439.344619627@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190432.043414522@linuxfoundation.org> References: <20200218190432.043414522@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michał Mirosław [ Upstream commit d3a5bcb4a17f1ad072484bb92c42519ff3aba6e1 ] Add possibility to toggle active-low flag of a gpio descriptor. This is useful for compatibility code, where defaults are inverted vs DT gpio flags or the active-low flag is taken from elsewhere. Acked-by: Linus Walleij Signed-off-by: Michał Mirosław Link: https://lore.kernel.org/r/7ce0338e01ad17fa5a227176813941b41a7c35c1.1576031637.git.mirq-linux@rere.qmqm.pl Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 11 +++++++++++ include/linux/gpio/consumer.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 78a16e42f222e..bcfbfded9ba3f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3371,6 +3371,17 @@ int gpiod_is_active_low(const struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_is_active_low); +/** + * gpiod_toggle_active_low - toggle whether a GPIO is active-low or not + * @desc: the gpio descriptor to change + */ +void gpiod_toggle_active_low(struct gpio_desc *desc) +{ + VALIDATE_DESC_VOID(desc); + change_bit(FLAG_ACTIVE_LOW, &desc->flags); +} +EXPORT_SYMBOL_GPL(gpiod_toggle_active_low); + /* I/O calls are only valid after configuration completed; the relevant * "is this a valid GPIO" error checks should already have been done. * diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 5215fdba6b9a6..bf2d017dd7b71 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -158,6 +158,7 @@ int gpiod_set_raw_array_value_cansleep(unsigned int array_size, int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); +void gpiod_toggle_active_low(struct gpio_desc *desc); int gpiod_is_active_low(const struct gpio_desc *desc); int gpiod_cansleep(const struct gpio_desc *desc); @@ -483,6 +484,12 @@ static inline int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) return -ENOSYS; } +static inline void gpiod_toggle_active_low(struct gpio_desc *desc) +{ + /* GPIO can never have been requested */ + WARN_ON(desc); +} + static inline int gpiod_is_active_low(const struct gpio_desc *desc) { /* GPIO can never have been requested */ -- 2.20.1