Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753756AbbLJQyE (ORCPT ); Thu, 10 Dec 2015 11:54:04 -0500 Received: from mail-ob0-f174.google.com ([209.85.214.174]:35831 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752571AbbLJQyC (ORCPT ); Thu, 10 Dec 2015 11:54:02 -0500 MIME-Version: 1.0 In-Reply-To: <1448904631-30230-1-git-send-email-Jose.DiazdeGrenudePedro@digi.com> References: <1448904631-30230-1-git-send-email-Jose.DiazdeGrenudePedro@digi.com> Date: Thu, 10 Dec 2015 17:54:01 +0100 Message-ID: Subject: Re: [PATCH v2] gpiolib: return 0 or 1 in gpiod_get_value*() functions From: Linus Walleij To: Jose Diaz de Grenu de Pedro Cc: "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Alexandre Courbot , Hector Palacios Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1153 Lines: 34 On Mon, Nov 30, 2015 at 6:30 PM, Jose Diaz de Grenu de Pedro wrote: > Commit 79a9becda894 moved the awareness of active low state > into the gpiod_get_value*() functions, but it only inverts the > GPIO's raw value when it is active low. If the GPIO is active > high, the gpiod_get_value*() functions return the raw value of > the register, which can be any positive value. No, because: static int _gpiod_get_raw_value(const struct gpio_desc *desc) { struct gpio_chip *chip; int offset; int value; chip = desc->chip; offset = gpio_chip_hwgpio(desc); value = chip->get ? chip->get(chip, offset) : -EIO; value = value < 0 ? value : !!value; trace_gpio_value(desc_to_gpio(desc), 1, value); return value; } This returns a negative error code or the value clamped to [0,1] Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/