From patchwork Wed Dec 9 13:14:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57970 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp660375lbb; Wed, 9 Dec 2015 05:14:52 -0800 (PST) X-Received: by 10.66.248.106 with SMTP id yl10mr7743019pac.140.1449666892414; Wed, 09 Dec 2015 05:14:52 -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.14.52; Wed, 09 Dec 2015 05:14:52 -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 S1754108AbbLINOv (ORCPT + 4 others); Wed, 9 Dec 2015 08:14:51 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:35355 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753592AbbLINOv (ORCPT ); Wed, 9 Dec 2015 08:14:51 -0500 Received: by lbpu9 with SMTP id u9so29532915lbp.2 for ; Wed, 09 Dec 2015 05:14:49 -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=OUzbCRXzusXbmDm42qZM//HTsFEW4moil5a+XR7Nq1c=; b=KdMKu9wzAPfVk+Pttzx9QFjmMlVm0kLK7Ga5yIU85BNg4qCK2LUJS0WMxxm9Q1YV5P AW3Wi1ovsE+pz5s0TLFvxqKiZekUtiYgQekP5BXJd5EnGIrrwh2dwcV4SviQirpdZVn8 xNZ4TSvoOkv67fIbkoRywOOVbxx43ymXa3ow5SRoNQlaAWRNwxj/Zf4lep1fy8mbVctJ CqbrdTyITqe2SUddYa6TtZd6qnZePMSmP0OjV1R7tLdxX++y+n4PVNRaklmagdGdNaV4 ZMZWad+YVJWwqTU0RwjNQ41H1JgDx2AlWpEnjm97WH+s5yCbXntAaIcDHhkTzvbNlspt hJjg== 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=OUzbCRXzusXbmDm42qZM//HTsFEW4moil5a+XR7Nq1c=; b=WHjgKwFmE9Me5P7pKiCqUclkPxlqJXRsjMm8yQvOPrunfoSQDgZ/GJh/JChrssHO3m mU0/mnB7XEpKen8Ya8qH9f21bGPD4CSuWk58jH0ytAOTUnMQuW7iBjV71FvhMHruIfAz z97AHPH8f52NkEYYyh21v7kIfj2SaJ2XgXmh0v0TR/KR4WTFjqoofxW7+JmO9zPBm54a 3ARG3MGBDosfjsIFJLgzJRmf7hQYyjoskK1Z1If74NFGOXBGgN0Z2uAfakvcW7Mmvjl8 9vziTfwWPFvKeOvA9YypATZEToHs3QHckXPbjzmiIEYFphHo35BPb4+eeV1YP1x1FgiS SuKA== X-Gm-Message-State: ALoCoQkCMYgXkXTq5JS+GnLkKGzd4sgK3aeucQ/5i5eHez/p0Wqx25jIDDvsjSwhW+1KKs1nLptj5IYGgK4i+69mGXNcM+ndgw== X-Received: by 10.112.173.134 with SMTP id bk6mr2359979lbc.34.1449666889782; Wed, 09 Dec 2015 05:14:49 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id wu10sm1419848lbb.44.2015.12.09.05.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:14:49 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Alban Bedel Subject: [PATCH 015/182] gpio: ath79: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:14:46 +0100 Message-Id: <1449666886-30451-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: Alban Bedel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ath79.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 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-ath79.c b/drivers/gpio/gpio-ath79.c index e7e38af11ec9..2c208e1d9350 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c @@ -24,12 +24,10 @@ struct ath79_gpio_ctrl { spinlock_t lock; }; -#define to_ath79_gpio_ctrl(c) container_of(c, struct ath79_gpio_ctrl, chip) - static void ath79_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); if (value) __raw_writel(BIT(gpio), ctrl->base + AR71XX_GPIO_REG_SET); @@ -39,7 +37,7 @@ static void ath79_gpio_set_value(struct gpio_chip *chip, static int ath79_gpio_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); return (__raw_readl(ctrl->base + AR71XX_GPIO_REG_IN) >> gpio) & 1; } @@ -47,7 +45,7 @@ static int ath79_gpio_get_value(struct gpio_chip *chip, unsigned gpio) static int ath79_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -64,7 +62,7 @@ static int ath79_gpio_direction_input(struct gpio_chip *chip, static int ath79_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -85,7 +83,7 @@ static int ath79_gpio_direction_output(struct gpio_chip *chip, static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -102,7 +100,7 @@ static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct ath79_gpio_ctrl *ctrl = to_ath79_gpio_ctrl(chip); + struct ath79_gpio_ctrl *ctrl = gpiochip_get_data(chip); unsigned long flags; spin_lock_irqsave(&ctrl->lock, flags); @@ -184,7 +182,7 @@ static int ath79_gpio_probe(struct platform_device *pdev) ctrl->chip.direction_output = ar934x_gpio_direction_output; } - err = gpiochip_add(&ctrl->chip); + err = gpiochip_add_data(&ctrl->chip, ctrl); if (err) { dev_err(&pdev->dev, "cannot add AR71xx GPIO chip, error=%d", err);