From patchwork Wed Dec 9 13:32:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58060 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670610lbb; Wed, 9 Dec 2015 05:32:16 -0800 (PST) X-Received: by 10.66.142.232 with SMTP id rz8mr8027142pab.74.1449667936145; Wed, 09 Dec 2015 05:32:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si12793619pfj.115.2015.12.09.05.32.15; Wed, 09 Dec 2015 05:32:16 -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 S1754257AbbLINcP (ORCPT + 4 others); Wed, 9 Dec 2015 08:32:15 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33121 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754181AbbLINcP (ORCPT ); Wed, 9 Dec 2015 08:32:15 -0500 Received: by lbbkw15 with SMTP id kw15so30039371lbb.0 for ; Wed, 09 Dec 2015 05:32:13 -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=6IozSnUpEQNOHKNBSwhUemPl+AQR97NMQPCV7jAH2s0=; b=zcGwxDEuqC10UOeS8JnWXbLLC9/ypHZe4tV6XDP13r3Zm0jqMw73Lf0mBe6ntjh8KU nj4nYEPlrbQVqLlw02njjEIhbVtJes2cE96ReFKU/DPNAibnG4CSLSEPd3bk3mlYnLib FcnV3kqSwuxnUjkVftsiY4EiNhO/CmkwR9w8oS9CKiqGclCs7dV7G6dnpZCKVObBqm4J bvztDmOsycpucYr7osCg4fuf8XNdnFj+8YFxpxOwKZ0TenIT45JMJjYROVMYbzztzbNX y/xE7PCWoCwrG+GkJQ9jUfU8XLSOeyJ5j++pzO1kVaES4kFuxmCsTObgoUPzm54keYr5 RRzw== 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=6IozSnUpEQNOHKNBSwhUemPl+AQR97NMQPCV7jAH2s0=; b=EUZ0/DaeIx7GlfT3VB2OMW4zMIeEiT5EU/dhJj8kVkMdOGe905SLHh0cwm6OJFpUJb xikdbXcXeokJP/QMUQuFL5j+XwhC6yebkNZ13TuCZe/tceQxJkFLaa7a+rPZxI2oxK2J JsO6oi2iIiSkkue1pTISwbSlLi/srfqUUySeRZ+TUmhCsT6pBMk8sRPY2xzlRx4fHDgK PNTOT+3XWie+GPkKImxo3OGuwh7dXCyKOTQPJvbYm2MX6qcYvIahMuX5qE7D1aQuVkRb 0+D5oyDDok7tU8RKRPvTqAqrxUXTvm7gTuTVIu0E98oeXz7B7v8IqNUk/jWlUVXP9jlg Ex6g== X-Gm-Message-State: ALoCoQnjAhFXM8oEnca5UZfYnbQUHw9EgQ695uwPKfodmSxiVFk8qe2ZfWUtk/NJIyBdi7y5L0rDODjKQ6KuvjzzR1uGtjWgYw== X-Received: by 10.112.99.199 with SMTP id es7mr2376196lbb.25.1449667933505; Wed, 09 Dec 2015 05:32:13 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l67sm1438983lfl.26.2015.12.09.05.32.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:32:12 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Andrew Bresticker Subject: [PATCH 104/182] pinctrl: pistachio: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:32:09 +0100 Message-Id: <1449667929-2705-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: Andrew Bresticker Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-pistachio.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/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index fd5148d106a3..856f736cb1a6 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c @@ -842,14 +842,9 @@ static inline void pctl_writel(struct pistachio_pinctrl *pctl, u32 val, u32 reg) writel(val, pctl->base + reg); } -static inline struct pistachio_gpio_bank *gc_to_bank(struct gpio_chip *gc) -{ - return container_of(gc, struct pistachio_gpio_bank, gpio_chip); -} - static inline struct pistachio_gpio_bank *irqd_to_bank(struct irq_data *d) { - return gc_to_bank(irq_data_get_irq_chip_data(d)); + return gpiochip_get_data(irq_data_get_irq_chip_data(d)); } static inline u32 gpio_readl(struct pistachio_gpio_bank *bank, u32 reg) @@ -992,7 +987,7 @@ static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev, range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, pg->pin); if (range) - gpio_disable(gc_to_bank(range->gc), pg->pin - range->pin_base); + gpio_disable(gpiochip_get_data(range->gc), pg->pin - range->pin_base); return 0; } @@ -1173,14 +1168,14 @@ static struct pinctrl_desc pistachio_pinctrl_desc = { static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); return !(gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)); } static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); u32 reg; if (gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)) @@ -1194,7 +1189,7 @@ static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); gpio_mask_writel(bank, GPIO_OUTPUT, offset, !!value); } @@ -1202,7 +1197,7 @@ static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, static int pistachio_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 0); gpio_enable(bank, offset); @@ -1213,7 +1208,7 @@ static int pistachio_gpio_direction_input(struct gpio_chip *chip, static int pistachio_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct pistachio_gpio_bank *bank = gc_to_bank(chip); + struct pistachio_gpio_bank *bank = gpiochip_get_data(chip); pistachio_gpio_set(chip, offset, value); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 1); @@ -1303,7 +1298,7 @@ static int pistachio_gpio_irq_set_type(struct irq_data *data, unsigned int type) static void pistachio_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct pistachio_gpio_bank *bank = gc_to_bank(gc); + struct pistachio_gpio_bank *bank = gpiochip_get_data(gc); struct irq_chip *chip = irq_desc_get_chip(desc); unsigned long pending; unsigned int pin; @@ -1390,7 +1385,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) bank->gpio_chip.parent = pctl->dev; bank->gpio_chip.of_node = child; - ret = gpiochip_add(&bank->gpio_chip); + ret = gpiochip_add_data(&bank->gpio_chip, bank); if (ret < 0) { dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n", i, ret);