Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6204545ybv; Tue, 18 Feb 2020 12:00:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzZ/VQuubtmtHq7XS37UWCVe3gID8l0a1YLmeUXA8jocbV48fo0gydiugUVMfVFwM1j8vUa X-Received: by 2002:a9d:138:: with SMTP id 53mr17562296otu.334.1582056025793; Tue, 18 Feb 2020 12:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056025; cv=none; d=google.com; s=arc-20160816; b=BImllhVaNv39f3b6IgdmDyhkho86JahaU866rFqYqcx6cGrfwzmqBihRkDdDO3HYZE yTlfsOvZ1eFsgwbYHPorCWPWROml5KI2rAbV7NGGERWvrA7dPriXhe/dha624l+2WIb8 rzko3Ufr3eGqH4usihzanwsQvF+xvj5t/9c5JqJAFL4HjAQ/r5pCfZbi95+D4A1ln/+C DrK9YRpuomgXlw5ilpSAFOxYlwhnsFXIQKbGQl7z3FQ5F6vuGqLJSTxSWv7cWp217HGv XXRcSvSPGR39fNrvCkFBzEcbEjfSlJWIUR88DVSC0LI8zQnxr4N76duLkE2JBzTrVG/5 91gg== 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=uEqPexCcrVD9htCwJTcqgGPd7dzvLs/hzXN/37I5ZWQ=; b=G41TjdCb/elE5W5MjaiW2Y8YO1+4WtIvKjW2sC6uxwTyRZB8Wic2AiqSgWFEg7c7Rq PzVXESPpEbmQKK24v/BR/iSZCCoSXHQazUZgVi2SBkFE/nR5/hZ8r2oSFhx+xJviSuus dcR2zlmqN8u9Mp/tLMiBELCF8xHm0gyF2PnoQlYvwGKreVjIPY7naZxSPxl1ByPV6ciN dk1e8G8fKt8InCRjNDxYGQJy7KsdIzyDVnYBj2f9e/dvSiEG919pNpgdDvObmco8DFCX cXDTbylhERWR2XMuPWHkvgFbWRQ3IepAI8rFwDdVm6fzkee/PmHXQSo/2INgRdtWmUou dG0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y+F57eAK; 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 w24si8053889oic.260.2020.02.18.12.00.13; Tue, 18 Feb 2020 12:00:25 -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=Y+F57eAK; 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 S1728512AbgBRUAI (ORCPT + 99 others); Tue, 18 Feb 2020 15:00:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:39176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728506AbgBRUAF (ORCPT ); Tue, 18 Feb 2020 15:00:05 -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 2421B24673; Tue, 18 Feb 2020 20:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582056004; bh=5Jf8cI4nOoxx6xZKEeoBi7W0xsvsAYOX+Lc69C/Hte8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+F57eAKINOvVqmdN2PQALTddwKwjDEfu+8T4pSOQ538uM97fSqjsUOSXVMuPyfPe p4uc7l9iY4P9huWwFsuJizrT97UbgwDQPq9x2zp7RquxIdCvEGOUKLAdDlUpT25jpQ TmwoyhtIepJGANrrC9LGg6VvL/Ln+z/58yKYlFSY= 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.4 65/66] gpio: add gpiod_toggle_active_low() Date: Tue, 18 Feb 2020 20:55:32 +0100 Message-Id: <20200218190434.273604722@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190428.035153861@linuxfoundation.org> References: <20200218190428.035153861@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 2476306e7030e..22506e4614b3f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3220,6 +3220,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 b70af921c6145..803bb63dd5ffb 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); @@ -479,6 +480,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