From patchwork Wed Dec 9 13:28:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58040 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668688lbb; Wed, 9 Dec 2015 05:29:06 -0800 (PST) X-Received: by 10.98.87.83 with SMTP id l80mr12925503pfb.126.1449667746355; Wed, 09 Dec 2015 05:29:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ny6si12718088pab.215.2015.12.09.05.29.06; Wed, 09 Dec 2015 05:29:06 -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 S1753942AbbLIN3F (ORCPT + 4 others); Wed, 9 Dec 2015 08:29:05 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34868 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLIN3E (ORCPT ); Wed, 9 Dec 2015 08:29:04 -0500 Received: by lfdl133 with SMTP id l133so34054281lfd.2 for ; Wed, 09 Dec 2015 05:29:02 -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=Gz/0plhjiYuQYuWnVrDt6pA8jvcvxh843xw1UXWLuJ4=; b=m34kX7+SEIE77dMvHS+sV0KEGCEPzItfVILEUI1+cYr5h8a5CkoZTyuq+WRp8zRlEy KQt/G3RB7+Kt9+jDD/rKmKcjjWDH+w0fDvYHsM2zAMQAbct3f9ZWxtrzWdERTaTvN9vM TjX+k1ZfsMRyyc0dUXs+/D3GijQ0mSEmacKz5Gp5X7eeUbV+LlDuG/4ecysl4WtHiwlL qR4ChecAnBlTiT2q1sqQNCUqs3ejTPktk/VkgxOsk/rzNc1riABSP594uIo+jxOIUtVi O9u9IVX8oZJcupw2GUJqucXwflZdBCVIWYbLQ6zQvMRNWNJfQyXbYQo2b1y2lhxZ+W03 qmTA== 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=Gz/0plhjiYuQYuWnVrDt6pA8jvcvxh843xw1UXWLuJ4=; b=TeycXDEQNkjKYDRghF4tW34fqrzLSpHe2RkxKKAzvUx7tdj22LmNNl03N0JS7+GlKk B/7vL6a+arBa77IncYBtglc2gr1RE4AyyQ6q5VmC0yB5BH1JFMmT24cSoD2gHG6ZDRea FJGwiDx36IWatEbBoRzb01RoQKwgsx3yHrxacpYJXKXM3FwA0L8HTwZfIVqqabeigMkm DnUsUQv+LQ3LqGByEtgyGeDWePqTwEG+6dgDL+023MyZndCh+lfexoVKDdW/zzqlUyZc 0raEVDgSkipLgIaTrvt5z43CVpeYniCIhFpsYgqKae6r5uOBppAZMRozwh2cJpOC0Q0J HmOw== X-Gm-Message-State: ALoCoQn8DLtX0f3AyftePEozspbTslHY86vipzXcH8NrkrIVH6Ai4/s1wvM/rRuzVO6N3J8Rk8CuGy/wEuhSf26hipRSLRRa7Q== X-Received: by 10.25.150.204 with SMTP id y195mr2265302lfd.66.1449667742685; Wed, 09 Dec 2015 05:29:02 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s185sm1425182lfe.24.2015.12.09.05.29.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:29:01 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Kamlakant Patel Subject: [PATCH 084/182] gpio: xlp: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:28:59 +0100 Message-Id: <1449667739-1455-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: Kamlakant Patel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xlp.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 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-xlp.c b/drivers/gpio/gpio-xlp.c index 3f31aac2ba3c..aa5813d2deb1 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c @@ -100,11 +100,6 @@ struct xlp_gpio_priv { spinlock_t lock; }; -static struct xlp_gpio_priv *gpio_chip_to_xlp_priv(struct gpio_chip *gc) -{ - return container_of(gc, struct xlp_gpio_priv, chip); -} - static int xlp_gpio_get_reg(void __iomem *addr, unsigned gpio) { u32 pos, regset; @@ -133,7 +128,7 @@ static void xlp_gpio_set_reg(void __iomem *addr, unsigned gpio, int state) static void xlp_gpio_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -145,7 +140,7 @@ static void xlp_gpio_irq_disable(struct irq_data *d) static void xlp_gpio_irq_mask_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -158,7 +153,7 @@ static void xlp_gpio_irq_mask_ack(struct irq_data *d) static void xlp_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -170,7 +165,7 @@ static void xlp_gpio_irq_unmask(struct irq_data *d) static int xlp_gpio_set_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); int pol, irq_type; switch (type) { @@ -235,7 +230,7 @@ static void xlp_gpio_generic_handler(struct irq_desc *desc) static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x1); @@ -245,7 +240,7 @@ static int xlp_gpio_dir_output(struct gpio_chip *gc, unsigned gpio, int state) static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_out_en, gpio, 0x0); @@ -255,7 +250,7 @@ static int xlp_gpio_dir_input(struct gpio_chip *gc, unsigned gpio) static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); return xlp_gpio_get_reg(priv->gpio_paddrv, gpio); @@ -263,7 +258,7 @@ static int xlp_gpio_get(struct gpio_chip *gc, unsigned gpio) static void xlp_gpio_set(struct gpio_chip *gc, unsigned gpio, int state) { - struct xlp_gpio_priv *priv = gpio_chip_to_xlp_priv(gc); + struct xlp_gpio_priv *priv = gpiochip_get_data(gc); BUG_ON(gpio >= gc->ngpio); xlp_gpio_set_reg(priv->gpio_paddrv, gpio, state); @@ -388,7 +383,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) return -ENODEV; } - err = gpiochip_add(gc); + err = gpiochip_add_data(gc, priv); if (err < 0) goto out_free_desc;