From patchwork Wed Dec 9 13:14:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57971 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp660473lbb; Wed, 9 Dec 2015 05:15:01 -0800 (PST) X-Received: by 10.98.15.68 with SMTP id x65mr12956483pfi.146.1449666901400; Wed, 09 Dec 2015 05:15:01 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s26si12711651pfi.57.2015.12.09.05.15.01; Wed, 09 Dec 2015 05:15:01 -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.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbbLINPA (ORCPT + 4 others); Wed, 9 Dec 2015 08:15:00 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35536 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753592AbbLINPA (ORCPT ); Wed, 9 Dec 2015 08:15:00 -0500 Received: by lfdl133 with SMTP id l133so33783587lfd.2 for ; Wed, 09 Dec 2015 05:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=PV5tVJGNYqUBSwKSjuU4mBYtmMDbv4Bmg1Fs94n/llI=; b=rH93hkM6gw57EHEWnYTtY1Ng0cMV4NM4kcW3+tV0QlR6bGfnD5q4h/bEAseTUodGK6 tIcv30ntog/kewSp7vdgzu0rmJDN4cT7EUdHehD3yCKnGJWk/rpGxQKuib2MkLJIikqh HAivqrHV5R+YdPeCBekFadtkefm2TCYT9kaL623Ew3xI3AswsSrkanW07ic03zIkqJjX 1wxyG1Qnia4kdgdsN4xvMz4vG276CwzCtz2sPiMAaYkqYFkPpBxi1snmaXpMZ6bDeOQ7 T2ANaY+W8NU4rhhq9NYOvHbMGfCa5pg5cUxbxu4K1G0xTAIv6PpzEjrSu4V3Ja1eUcTJ 0+rQ== 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=PV5tVJGNYqUBSwKSjuU4mBYtmMDbv4Bmg1Fs94n/llI=; b=jJ2BH/g9fhW2EO6C/krc7T/0uTZ+9PldbMOtr1IwG7sKtAWSOF9gReXbSFrhFDICaV eAfSaxFX1U28eHKShUDy+Nei5KkahPLvPnt5c7QnuxRtSCcXIW/NnXGUK4J9DFwT0ogR IqJtNAZy4kOH4n09C8WDwNaccluU8k8F2UG73mOHHAUCmCtoxTjSq4hk9aAoTpZDTiU1 muIQB+qSjYDD7IBZ7iDumKjiQ+P5I2RRxXHgKzfCZFKBdltSzCx/E9YUQerd6aT2aqfI pOCFUdjuF8k4XXwLIEIeEJ5PRb4X+U9v2EVylPdMz4YtNcbGq48fEyaQVmgcq4225s8d pmEQ== X-Gm-Message-State: ALoCoQmVohIG1qNosoFeEbtQLxEc+7DSS8uKqK0hsWKA10wgGWEVEeNv3S7v0LvMLEfOhHOHKBAdvtLaMobVFmpuYd8OuMejcA== X-Received: by 10.25.146.201 with SMTP id u192mr2356383lfd.14.1449666898665; Wed, 09 Dec 2015 05:14:58 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id h9sm1399335lbj.42.2015.12.09.05.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:14:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Markus Mayer , Tim Kryger , Matt Porter Subject: [PATCH 016/182] gpio: bcm-kona: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:14:53 +0100 Message-Id: <1449666893-30498-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 makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: Markus Mayer Cc: Tim Kryger Cc: Matt Porter Signed-off-by: Linus Walleij --- drivers/gpio/gpio-bcm-kona.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 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-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 21c3280d66e1..b6c5abe85daf 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -78,11 +78,6 @@ struct bcm_kona_gpio_bank { struct bcm_kona_gpio *kona_gpio; }; -static inline struct bcm_kona_gpio *to_kona_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct bcm_kona_gpio, gpio_chip); -} - static inline void bcm_kona_gpio_write_lock_regs(void __iomem *reg_base, int bank_id, u32 lockcode) { @@ -124,7 +119,7 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); void __iomem *reg_base = kona_gpio->reg_base; u32 val; @@ -141,7 +136,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -168,7 +163,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -188,7 +183,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); bcm_kona_gpio_unlock_gpio(kona_gpio, gpio); return 0; @@ -196,7 +191,7 @@ static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio) static void bcm_kona_gpio_free(struct gpio_chip *chip, unsigned gpio) { - struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip); + struct bcm_kona_gpio *kona_gpio = gpiochip_get_data(chip); bcm_kona_gpio_lock_gpio(kona_gpio, gpio); } @@ -208,7 +203,7 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) u32 val; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -232,7 +227,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, u32 val, reg_offset; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; spin_lock_irqsave(&kona_gpio->lock, flags); @@ -255,7 +250,7 @@ static int bcm_kona_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) { struct bcm_kona_gpio *kona_gpio; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); if (gpio >= kona_gpio->gpio_chip.ngpio) return -ENXIO; return irq_create_mapping(kona_gpio->irq_domain, gpio); @@ -269,7 +264,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, u32 val, res; unsigned long flags; - kona_gpio = to_kona_gpio(chip); + kona_gpio = gpiochip_get_data(chip); reg_base = kona_gpio->reg_base; /* debounce must be 1-128ms (or 0) */ if ((debounce > 0 && debounce < 1000) || debounce > 128000) { @@ -635,7 +630,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) bcm_kona_gpio_reset(kona_gpio); - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, kona_gpio); if (ret < 0) { dev_err(dev, "Couldn't add GPIO chip -- %d\n", ret); goto err_irq_domain;