From patchwork Wed Dec 9 13:29: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: 58046 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp669238lbb; Wed, 9 Dec 2015 05:30:05 -0800 (PST) X-Received: by 10.98.2.213 with SMTP id 204mr12902787pfc.9.1449667805696; Wed, 09 Dec 2015 05:30:05 -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.30.05; Wed, 09 Dec 2015 05:30:05 -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 S1754118AbbLINaF (ORCPT + 4 others); Wed, 9 Dec 2015 08:30:05 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34663 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753984AbbLINaE (ORCPT ); Wed, 9 Dec 2015 08:30:04 -0500 Received: by lffu14 with SMTP id u14so34267853lff.1 for ; Wed, 09 Dec 2015 05:30: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=8lmgKb+dC8EDdFITn7GGBvcsumYyNm3JtwuttH8F+fU=; b=fhqD5B7CZa8MLx/JTGms8DAOsW0jkwEFidc+y4U4Nm0s978a+niNMwn5d7f+HPMP8d X4dxUTrj6wWNA8zjbRtRlR9KvWOiy4Ml7/tigYVA3ttBPX4AP2FeyZDLMj+PonTV/6dq N4we4ZmaNZmO2MMVs6l6xsfEqe/3WB7EAS1hnKZnOjj8NhZl0d4pfGUYfZdUQEGsMC7e R91puqz6MelXj+1cKyPnZfDy3fmj/98k6BSgP3kJSHzRM1d2ohzOEj5rGV2LZv6yiGIh eMa8Tjz/GDjTkY+tU/A0Lw+kw4w7bU/aX1k/0CJOZQ6FCkwTgzUAujxmm5tZM+X9V8vg Dj5A== 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=8lmgKb+dC8EDdFITn7GGBvcsumYyNm3JtwuttH8F+fU=; b=ERg9A/vHSatu3rkOXMstmPDM5/IQKO67GYxWUVKpTsY/q9eBH8I7fTZR074C2QosIh zMqlTiebheldV66OPCGI2ZB1d5ptMPU3yCGDYwDsMc7bIYFJGEeCx0oquOPk3aefARsj 1968mjgUUJDN44tYRomacqAP2EM8ErGDkUbt/GXbyqp0tkKgMMG49jqhgKNLWEbkfHp1 23mETH+xIp0ULIM9lVyDPJcNMDJ6ZnVO3GioqKspBTG2MX7brnv+uW2RqSs/vaY/jiVU Eb0lhsJTPm6EOtswDgPvyxAUFKGc+fmKKphCW3lVIhtVueAXifxktBu43Ne39D0k1zOe MviA== X-Gm-Message-State: ALoCoQnKWIAPW4yRTASdOw8onUMA6pE8qxzraPoDr25n7t52efXnYuahIj3/A4sX+JjQ3wKNSFPuo51LRja8LtnPqj8x9sMz3w== X-Received: by 10.25.15.101 with SMTP id e98mr2233931lfi.49.1449667802484; Wed, 09 Dec 2015 05:30:02 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id us1sm1409162lbc.25.2015.12.09.05.29.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:30:01 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , bcm-kernel-feedback-list@broadcom.com, Ray Jui , Scott Branden , Jon Mason Subject: [PATCH 090/182] pinctrl: cygnus-gpio: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:29:53 +0100 Message-Id: <1449667793-1826-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: bcm-kernel-feedback-list@broadcom.com Cc: Ray Jui Cc: Scott Branden Cc: Jon Mason Signed-off-by: Linus Walleij --- drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 33 +++++++++++++------------------ 1 file changed, 14 insertions(+), 19 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/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c index bd212b269094..d15e52c40c83 100644 --- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -96,11 +96,6 @@ struct cygnus_gpio { struct pinctrl_desc pctldesc; }; -static inline struct cygnus_gpio *to_cygnus_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct cygnus_gpio, gc); -} - /* * Mapping from PINCONF pins to GPIO pins is 1-to-1 */ @@ -145,7 +140,7 @@ static inline bool cygnus_get_bit(struct cygnus_gpio *chip, unsigned int reg, static void cygnus_gpio_irq_handler(struct irq_desc *desc) { struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); struct irq_chip *irq_chip = irq_desc_get_chip(desc); int i, bit; @@ -178,7 +173,7 @@ static void cygnus_gpio_irq_handler(struct irq_desc *desc) static void cygnus_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned gpio = d->hwirq; unsigned int offset = CYGNUS_GPIO_REG(gpio, CYGNUS_GPIO_INT_CLR_OFFSET); @@ -197,7 +192,7 @@ static void cygnus_gpio_irq_ack(struct irq_data *d) static void cygnus_gpio_irq_set_mask(struct irq_data *d, bool unmask) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned gpio = d->hwirq; cygnus_set_bit(chip, CYGNUS_GPIO_INT_MSK_OFFSET, gpio, unmask); @@ -206,7 +201,7 @@ static void cygnus_gpio_irq_set_mask(struct irq_data *d, bool unmask) static void cygnus_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -217,7 +212,7 @@ static void cygnus_gpio_irq_mask(struct irq_data *d) static void cygnus_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -228,7 +223,7 @@ static void cygnus_gpio_irq_unmask(struct irq_data *d) static int cygnus_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned gpio = d->hwirq; bool level_triggered = false; bool dual_edge = false; @@ -290,7 +285,7 @@ static struct irq_chip cygnus_gpio_irq_chip = { */ static int cygnus_gpio_request(struct gpio_chip *gc, unsigned offset) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned gpio = gc->base + offset; /* not all Cygnus GPIO pins can be muxed individually */ @@ -302,7 +297,7 @@ static int cygnus_gpio_request(struct gpio_chip *gc, unsigned offset) static void cygnus_gpio_free(struct gpio_chip *gc, unsigned offset) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned gpio = gc->base + offset; if (!chip->pinmux_is_supported) @@ -313,7 +308,7 @@ static void cygnus_gpio_free(struct gpio_chip *gc, unsigned offset) static int cygnus_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -328,7 +323,7 @@ static int cygnus_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) static int cygnus_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, int val) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -343,7 +338,7 @@ static int cygnus_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, static void cygnus_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -355,7 +350,7 @@ static void cygnus_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) static int cygnus_gpio_get(struct gpio_chip *gc, unsigned gpio) { - struct cygnus_gpio *chip = to_cygnus_gpio(gc); + struct cygnus_gpio *chip = gpiochip_get_data(gc); unsigned int offset = CYGNUS_GPIO_REG(gpio, CYGNUS_GPIO_DATA_IN_OFFSET); unsigned int shift = CYGNUS_GPIO_SHIFT(gpio); @@ -732,7 +727,7 @@ static int cygnus_gpio_probe(struct platform_device *pdev) chip->pinmux_is_supported = of_property_read_bool(dev->of_node, "gpio-ranges"); - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, chip); if (ret < 0) { dev_err(dev, "unable to add GPIO chip\n"); return ret;