From patchwork Thu Feb 11 19:29:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 61806 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp397868lbl; Thu, 11 Feb 2016 11:29:12 -0800 (PST) X-Received: by 10.98.89.78 with SMTP id n75mr67991625pfb.120.1455218952277; Thu, 11 Feb 2016 11:29:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id we3si14294180pab.52.2016.02.11.11.29.12; Thu, 11 Feb 2016 11:29:12 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751065AbcBKT3L (ORCPT + 4 others); Thu, 11 Feb 2016 14:29:11 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:36214 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbcBKT3K (ORCPT ); Thu, 11 Feb 2016 14:29:10 -0500 Received: by mail-lb0-f171.google.com with SMTP id tk3so21253966lbb.3 for ; Thu, 11 Feb 2016 11:29:09 -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=f1EMiOolQ9bGRkSPQ0aojN3xcJ61nUC2rIKlszNAKSA=; b=kr0Io2X/4+svXdVj9saEwdcVVoeyVclnUj0oMEbYJ2zRKNEAkcQ4JqyOd1OOnUuo6l d7CkO/IUE+jLon+6jMicuWY53rLsfyzf3SHMxacjtGQ+S9ea6lcfyxNW81t5cJlBoKtC 9lGoceqBXG6TcGAe69tbhHaAgtoVKoX3uF8aU= 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=f1EMiOolQ9bGRkSPQ0aojN3xcJ61nUC2rIKlszNAKSA=; b=bhil1JCkSb9moBy3n+KyJo0uiWoSdGHZgXFAqZ+20U0Vh49iOHlrhHH+AsYdcQeHcg ocsO6s/vS/ZpnW99hCRrkm3AHgmcf/KxDaPQ/XNj8cGiKsBmI/56xPzBJrLfGU/D9SDr U8SXpX7z+zlWkoLpVSHNNo2qaCblU7Yh9yEZ3We2KGt5KDzAHXgprgGCHLFgzay3weuf nAQW+o0jRURql5jODTkGlC8zqthLEHYAHSrR5cwTemIqpUD/B8sMAHT2PkWbt3Jt23NI PNcH+rERI0F+x02keyfh5tALU+8sFkcv+qgjPnHcLDB4XWDoPAR5pzMPwn3g5ba0d9we TWNw== X-Gm-Message-State: AG10YOQnYY1Jbdr+o425Wz7xG3BaACPYBq3pvFZxabqOokXKUsVpaiw42wpxqMYecpl+KaWI X-Received: by 10.112.172.200 with SMTP id be8mr18850972lbc.78.1455218949060; Thu, 11 Feb 2016 11:29:09 -0800 (PST) Received: from localhost.localdomain.localdomain (c-3d95db54.01-192-6c756e10.cust.bredbandsbolaget.se. [84.219.149.61]) by smtp.gmail.com with ESMTPSA id mp1sm1409256lbb.22.2016.02.11.11.29.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 11:29:07 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH] gpio/pinctrl: sunxi: stop poking around in private vars Date: Thu, 11 Feb 2016 20:29:03 +0100 Message-Id: <1455218943-25917-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 This kind of hacks disturbs the refactoring of the gpiolib. The descriptor table belongs to the gpiolib, if we want to know something about something in it, use or define the proper accessor functions. Let's add this gpiochip_lins_is_irq() to do what the sunxi driver is trying at so we can privatize the descriptors properly. Cc: Maxime Ripard Cc: Chen-Yu Tsai Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 9 +++++++++ drivers/pinctrl/sunxi/pinctrl-sunxi.c | 4 ++-- include/linux/gpio/driver.h | 1 + 3 files changed, 12 insertions(+), 2 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/gpiolib.c b/drivers/gpio/gpiolib.c index a60c6f28675e..aa4a60e19339 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1892,6 +1892,15 @@ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) } EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); +bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset) +{ + if (offset >= chip->ngpio) + return false; + + return test_bit(FLAG_USED_AS_IRQ, &chip->gpiodev->descs[offset].flags); +} +EXPORT_SYMBOL_GPL(gpiochip_line_is_irq); + /** * gpiod_get_raw_value_cansleep() - return a gpio's raw value * @desc: gpio whose value will be returned diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 7a2465f5e71e..3e95bfe66a06 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -457,8 +457,8 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) struct sunxi_pinctrl *pctl = gpiochip_get_data(chip); u32 reg = sunxi_data_reg(offset); u8 index = sunxi_data_offset(offset); - u32 set_mux = pctl->desc->irq_read_needs_mux && - test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags); + bool set_mux = pctl->desc->irq_read_needs_mux && + gpiochip_line_is_irq(chip, offset); u32 val; if (set_mux) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 363bf0eab6d0..b92ab9efdb69 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -197,6 +197,7 @@ extern struct gpio_chip *gpiochip_find(void *data, /* lock/unlock as IRQ */ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); +bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset); /* get driver data */ void *gpiochip_get_data(struct gpio_chip *chip);