From patchwork Wed Oct 26 07:18:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 686925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3t3hGJ4Y6gz9t0Z; Wed, 26 Oct 2016 18:19:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=sHt1lM+v; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1bzIUI-0004MW-1q; Wed, 26 Oct 2016 07:19:02 +0000 Received: from mail-oi0-f66.google.com ([209.85.218.66]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bzIUC-0004LO-GX for kernel-team@lists.ubuntu.com; Wed, 26 Oct 2016 07:18:56 +0000 Received: by mail-oi0-f66.google.com with SMTP id p136so10389196oic.1 for ; Wed, 26 Oct 2016 00:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=AQa+aFhCYnglxh6OvmaZYpL3omTWs7yw7ni2bSiYSHw=; b=sHt1lM+vWZKj23ZZSnEUaF4kOvAItA4o1RhPMmAztbazyiaG/o13Ob9KFTRuZkmZwI BP+aH1GQ8iXchMccMpSwae/12FEivUDKP+mBGZ1z+xqJWAgGyW3Z/6FCNjtUKzkZKi9j w9oIc8fJpee0W+Ndt1xl1lvCwVJy8QdMGzmdZf+heo/bfjCPY/hUPTG6bNSGar3rKT5Z JJiKtofxeRyUQe7MOUfiHECkCynqpoQDldvuUNVlaN9L//z8nVacIm0LOMq1OsByTYzV qvm9KMxJs9ZBceT+3n7YencBEzKEqErASzSd2D6zQ12ZvDvHeGyNt5R5BAmgtP/1V4f5 n35w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=AQa+aFhCYnglxh6OvmaZYpL3omTWs7yw7ni2bSiYSHw=; b=l+Cpv2qLthMFxcgJonNSfLjHp/fLKCcYUT0qwTmjaJKrDwbx3GGBdjsCQ+mf/IoS6B SydEzbw9qBJzrxO+tK1MEVJTRC7L43yG95LSvzDPM6Smbc+9IgyKTRD6f8syClQqO5PX Ys187ACiCZv93XMww1geArVuQaZ2GXoeyUoRFtpsWRFrABfJq7OV/q+VvFqoe7vYs1IQ iCW2duYdlcIuKTvDhOdSTlE1dyUUHFjj1M3lk3AlPBZ8fpjZSK7nlGqtt52epwb1/I3I 88KAIMsCMFDJe0x6rNwZE2qjWw0ceiqq0tnE917HsA11XbXp1Wn1kSubvx3KzHyBTWhZ jAmQ== X-Gm-Message-State: ABUngvcSXpZD9M5H48zpIwGmBUeAEkunXFD/IJ6HA14NMa2SKf5UVwBRP03/K05FHrs39w== X-Received: by 10.157.14.29 with SMTP id c29mr417385otc.55.1477466335205; Wed, 26 Oct 2016 00:18:55 -0700 (PDT) Received: from localhost ([2001:67c:1562:8007::aac:4468]) by smtp.gmail.com with ESMTPSA id v79sm238947oif.20.2016.10.26.00.18.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Oct 2016 00:18:54 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2] gpio/pinctrl: sunxi: stop poking around in private vars Date: Wed, 26 Oct 2016 15:18:33 +0800 Message-Id: <1477466314-4443-2-git-send-email-acelan.kao@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477466314-4443-1-git-send-email-acelan.kao@canonical.com> References: <1477466314-4443-1-git-send-email-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Linus Walleij BugLink: http://bugs.launchpad.net/bugs/1632527 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 (backported from commit 6cee3821e4e4bd6e6cdf0870b6c72d455460bd39) Signed-off-by: AceLan Kao --- 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(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 06d345b..3bb7ae5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1641,6 +1641,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->desc[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 a4a5b50..3a6cdbb 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 = dev_get_drvdata(chip->dev); 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 d1baebf..6ca8a6e 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -174,6 +174,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); struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);