From patchwork Wed Nov 30 09:09:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84979 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp143357qgi; Wed, 30 Nov 2016 01:09:47 -0800 (PST) X-Received: by 10.99.202.72 with SMTP id o8mr57432208pgi.41.1480496987265; Wed, 30 Nov 2016 01:09:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si36200143pgu.53.2016.11.30.01.09.47; Wed, 30 Nov 2016 01:09:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757462AbcK3JJo (ORCPT + 4 others); Wed, 30 Nov 2016 04:09:44 -0500 Received: from mail-lf0-f41.google.com ([209.85.215.41]:35151 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757264AbcK3JJd (ORCPT ); Wed, 30 Nov 2016 04:09:33 -0500 Received: by mail-lf0-f41.google.com with SMTP id b14so141524315lfg.2 for ; Wed, 30 Nov 2016 01:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LL91NxyGSiKFyZl9GLPs89LWY97/uxdwGbXqy/vrhTk=; b=FpX+zbiIqVAoqMsqSCc5P8S+keeMtROUJ8QZ8BBLTppiVLwuGAkvkgbODTWoonlRN/ tw0VlYgl2RLusb4KsEIeoaRFudqDl2KRvFpJxoDVj6hQitn1NwR4j21w45pJJHm1QGCq nX5wLV5qVca9QWSa1NlLGqLQRpVyOWxv0JLrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LL91NxyGSiKFyZl9GLPs89LWY97/uxdwGbXqy/vrhTk=; b=gs9LY7FLu9GdJX4yevwBkpTtDAECPaH3VrEGcNtIH7S83wO4IWk/kQdIVSTdOJHvES f+GgboWtQdNwI510zuEvu0J74oxjpqBqhW4Wa40MTgUSmd6Eih5dCYzg7s/u0st8eLKk wDLYADSThOfsh6UniW1/HTMnIpCgc8ZTqQ7B5FFRvnuXmXgCMqSca9M2/b9Ztoz92WSF xlZ3AT1AOxUKXnR+TNKVqKTiYkHipDerGn3RuouuBX13JmxZJ2NbQJ+ZVAoZMWid66I1 D/c+uRk+zDgL6V4+Do6/pWvlj/1xHHOLSxg6IYLgaGn0Fi0NhaVWCUij2e4FwYHqlmX1 9KMQ== X-Gm-Message-State: AKaTC00IrWaQ6HCROeFa6YOio4WDw//9E1o/j1dJ/lMFKFNS6ehNBEXrmdDJZRtnXNkuq/QB X-Received: by 10.46.32.76 with SMTP id g73mr13508896ljg.22.1480496971120; Wed, 30 Nov 2016 01:09:31 -0800 (PST) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id a9sm14068118ljb.9.2016.11.30.01.09.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 01:09:30 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH 2/2] gpio: htc-egpio: read output value from cache Date: Wed, 30 Nov 2016 10:09:28 +0100 Message-Id: <1480496968-5829-1-git-send-email-linus.walleij@linaro.org> 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 When the hardware is in output mode, reading the value from the hardware is not giving the correct value back. Instead read the value from the cache so we get the right value. Suggested-by: Russell King Signed-off-by: Linus Walleij --- drivers/gpio/gpio-htc-egpio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c index 27af52850927..271356effb2e 100644 --- a/drivers/gpio/gpio-htc-egpio.c +++ b/drivers/gpio/gpio-htc-egpio.c @@ -160,10 +160,14 @@ static int egpio_get(struct gpio_chip *chip, unsigned offset) bit = egpio_bit(ei, offset); reg = egpio->reg_start + egpio_pos(ei, offset); - value = egpio_readw(ei, reg); - pr_debug("readw(%p + %x) = %x\n", - ei->base_addr, reg << ei->bus_shift, value); - return !!(value & bit); + if (test_bit(offset, &egpio->is_out)) { + return !!(egpio->cached_values & (1 << offset)); + } else { + value = egpio_readw(ei, reg); + pr_debug("readw(%p + %x) = %x\n", + ei->base_addr, reg << ei->bus_shift, value); + return !!(value & bit); + } } static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)