From patchwork Wed Dec 17 09:47:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 422216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 65EB91400D2 for ; Wed, 17 Dec 2014 20:47:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751121AbaLQJrV (ORCPT ); Wed, 17 Dec 2014 04:47:21 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:61109 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbaLQJrU (ORCPT ); Wed, 17 Dec 2014 04:47:20 -0500 Received: by mail-pa0-f41.google.com with SMTP id rd3so16125039pab.0 for ; Wed, 17 Dec 2014 01:47:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=vk75F71Ia2Skv4Vzsv/THL4CpCqLK8pqdPpqzvwfupo=; b=XfQkqtyiXP6XiwSq4VkFXsD5ck29lG8EhNl1HH8p3wFEIhpS5GEXXZn1wRGmXFjknB DmKiXBEAk7TEhuoFV+qBuSBElLnAeBPbHXhz5LvlK20lfIep3tfu8mzsXonjvR8V5kIi fO5OD2/Jird80vmIH/44LI7n61T4L8Eh1jzx7Tj7XFF9eHf5XlMVCrxfR1YyPGZnjaFK 3XnYPrUdNwGHJMBMdrQSk0qz3Uh8GKncBgK9ZwJwem+qVzeoMADTCIWkFMHxq0sE+AjJ lY2OFx/28FP3tBRLTCEBz/qFf3LdiIA083nvvDU6ADt3GGdRu9Jtq+7qU9/ELW529SUW qchA== X-Gm-Message-State: ALoCoQn3/Fbw6rjlEJKUppktBCd0tfFP7XF/v2n4pMA8maiiO6RERn35HWAjgq/bbnB22QXJPvpL X-Received: by 10.70.124.200 with SMTP id mk8mr43129158pdb.147.1418809639342; Wed, 17 Dec 2014 01:47:19 -0800 (PST) Received: from [192.168.0.104] (218-164-101-83.dynamic.hinet.net. [218.164.101.83]) by mx.google.com with ESMTPSA id nt6sm3404480pdb.26.2014.12.17.01.47.17 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 01:47:18 -0800 (PST) Message-ID: <1418809634.15005.1.camel@phoenix> Subject: [PATCH v2] gpio: dln2: Fix gpio output value in dln2_gpio_direction_output() From: Axel Lin To: Linus Walleij , Alexandre Courbot Cc: Daniel Baluta , "linux-gpio@vger.kernel.org" , Octavian Purdila Date: Wed, 17 Dec 2014 17:47:14 +0800 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org dln2_gpio_direction_output() ignored the state passed into it. Fix it. Also make dln2_gpio_pin_set_out_val return int, so we can check the error value. Signed-off-by: Axel Lin Tested-by: Daniel Baluta Acked-by: Alexandre Courbot Reviewed-by: Octavian Purdila --- v2: Address Octavian's comment. drivers/gpio/gpio-dln2.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c index 978b51e..2481e8d 100644 --- a/drivers/gpio/gpio-dln2.c +++ b/drivers/gpio/gpio-dln2.c @@ -141,16 +141,16 @@ static int dln2_gpio_pin_get_out_val(struct dln2_gpio *dln2, unsigned int pin) return !!ret; } -static void dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2, - unsigned int pin, int value) +static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2, + unsigned int pin, int value) { struct dln2_gpio_pin_val req = { .pin = cpu_to_le16(pin), .value = value, }; - dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req, - sizeof(req)); + return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req, + sizeof(req)); } #define DLN2_GPIO_DIRECTION_IN 0 @@ -267,6 +267,13 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { + struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + int ret; + + ret = dln2_gpio_pin_set_out_val(dln2, offset, value); + if (ret < 0) + return ret; + return dln2_gpio_set_direction(chip, offset, DLN2_GPIO_DIRECTION_OUT); }