From patchwork Sat Apr 9 19:56:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 65433 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp698319lbl; Sat, 9 Apr 2016 12:57:08 -0700 (PDT) X-Received: by 10.107.134.151 with SMTP id q23mr16316496ioi.25.1460231828649; Sat, 09 Apr 2016 12:57:08 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m25si10512282iod.164.2016.04.09.12.57.08; Sat, 09 Apr 2016 12:57:08 -0700 (PDT) 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 S1754286AbcDIT5H (ORCPT + 4 others); Sat, 9 Apr 2016 15:57:07 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33248 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753097AbcDIT5H (ORCPT ); Sat, 9 Apr 2016 15:57:07 -0400 Received: by mail-lf0-f49.google.com with SMTP id e190so111492622lfe.0 for ; Sat, 09 Apr 2016 12:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=VsVYbs866MgW9UqKaeIim65o1VsSBhwiJJrCoAIVM/4=; b=imNkEUiHvr6rGoWFGS2jL1ti+q+W5rGeSKzPYiOd+ZKoIweGXtd1Zm7Mma/FLSiSQJ CwTH3rtI76mglwlmF+mRDiZwqOVgnmT+3FlrzHrQ5eaI9iNBQ21LVtJiLT5TIK8QUi9c VkOoaaQKl+4cmKiKEcBsGlvIVIOY5AQwBvGjQ= 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=VsVYbs866MgW9UqKaeIim65o1VsSBhwiJJrCoAIVM/4=; b=Hx1EG7EkEo3dyKK2lTSPBnFQYZ7+4sqZ/Hq7zO3S28xXQxrRgl/PaHf/o85v7JSUmh JrREBLSu3HumsyHO6acaCtz/YL+fMnqsfGCgvFpfEtyuEBkXxS6gzneRvE2kd4r6Ln14 6a9sHlPc50p+18inxQI8vpwa/yu9iDDCn4kDKa1qwL8rD9dgYas7MA7Jv2KzobcibBMs xriDyiuK8kEVGidpXDvJywxHpzeOoR6We2w3WoHnMfdJwVaLNx7IeYKInsyup6fxzN6T d7st+2K6PjhO9k0fH00rLHGPnITfsInbavWZ3dNu8JsseiQi62nIqsZBxigWFLMHJqhh KxYQ== X-Gm-Message-State: AOPr4FWs/X1nXV16JTREWXS45NAuolOfNDKKCsgFhsTV0nBkCMayPTLWpuEFBIjoM8PGBdhh X-Received: by 10.25.160.13 with SMTP id j13mr823462lfe.57.1460231824468; Sat, 09 Apr 2016 12:57:04 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-927b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.146]) by smtp.gmail.com with ESMTPSA id l191sm3138787lfl.19.2016.04.09.12.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Apr 2016 12:57:02 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Andreas Werner Subject: [PATCH] gpio: menz127: use the new open drain callback Date: Sat, 9 Apr 2016 21:56:55 +0200 Message-Id: <1460231815-8635-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The menz127 driver tries to support open drain by detecting it at request time. However: without the new callbacks from the gpiolib it is not really working: the core will still just emulate the open drain mode by switching the line to an input. By adding a hook into the new .set_single_ended() call rather than trying to autodetect at request() time, proper open drain can be supported. Cc: Andreas Werner Signed-off-by: Linus Walleij --- drivers/gpio/gpio-menz127.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) -- 2.4.3 -- 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-menz127.c b/drivers/gpio/gpio-menz127.c index 8c1ab8e1974f..334fe270dcf1 100644 --- a/drivers/gpio/gpio-menz127.c +++ b/drivers/gpio/gpio-menz127.c @@ -88,21 +88,25 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio, return 0; } -static int men_z127_request(struct gpio_chip *gc, unsigned gpio_pin) +static int men_z127_set_single_ended(struct gpio_chip *gc, + unsigned offset, + enum single_ended_mode mode) { struct men_z127_gpio *priv = gpiochip_get_data(gc); u32 od_en; - if (gpio_pin >= gc->ngpio) - return -EINVAL; + if (mode != LINE_MODE_OPEN_DRAIN && + mode != LINE_MODE_PUSH_PULL) + return -ENOTSUPP; spin_lock(&priv->lock); od_en = readl(priv->reg_base + MEN_Z127_ODER); - if (gpiochip_line_is_open_drain(gc, gpio_pin)) - od_en |= BIT(gpio_pin); + if (mode == LINE_MODE_OPEN_DRAIN) + od_en |= BIT(offset); else - od_en &= ~BIT(gpio_pin); + /* Implicitly LINE_MODE_PUSH_PULL */ + od_en &= ~BIT(offset); writel(od_en, priv->reg_base + MEN_Z127_ODER); spin_unlock(&priv->lock); @@ -147,7 +151,7 @@ static int men_z127_probe(struct mcb_device *mdev, goto err_unmap; men_z127_gpio->gc.set_debounce = men_z127_debounce; - men_z127_gpio->gc.request = men_z127_request; + men_z127_gpio->gc.set_single_ended = men_z127_set_single_ended; ret = gpiochip_add_data(&men_z127_gpio->gc, men_z127_gpio); if (ret) {