From patchwork Wed Dec 9 13:39:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58093 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp674827lbb; Wed, 9 Dec 2015 05:39:36 -0800 (PST) X-Received: by 10.98.72.18 with SMTP id v18mr12952907pfa.68.1449668376807; Wed, 09 Dec 2015 05:39:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wp13si12766750pac.180.2015.12.09.05.39.36; Wed, 09 Dec 2015 05:39:36 -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 S1754686AbbLINjg (ORCPT + 4 others); Wed, 9 Dec 2015 08:39:36 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:35299 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbbLINjQ (ORCPT ); Wed, 9 Dec 2015 08:39:16 -0500 Received: by lfdl133 with SMTP id l133so34253863lfd.2 for ; Wed, 09 Dec 2015 05:39:15 -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=TmM1qu+NHLYWJ5rfma6quL7s2FUxzbq+MdINQI67HO0=; b=saQ5PHoB9FtX2DvTFOPMeN9hLfSq35BcTfL9una2REVet4OCPu+L/XBPv0ze8xf9fn gJmYk/NmZvYU4RVZV7PpRy3syFctgxifkx7xL8UrWlXa6cESQckbdDy+iOc4eG6ltngH GIELljT9Px9wLJfOu9VJ72VkrQmJB/jwFMS3k/+Vg1LAzvK66Sxdflh2qakRfYMGzG1s shQwAAny6c+G4TcG+6psxMnzYcttUDlC/V8Llx3lQsZmWp7v6Qx51ODoN3zZBVWeutfs bNT2lwADD5h9UvWu0AfjHqskjzLtqNX8+GyWxo7LHlMpgoxjV/zOHks/8r098pvjFDk6 8zYw== 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=TmM1qu+NHLYWJ5rfma6quL7s2FUxzbq+MdINQI67HO0=; b=AK9jWYiVCNgDQrgGfysSWUPL+S5pn9VpZzxo3tcMinYD3Sd9CNOKu3uZVX74229PeE 4oGOIF9uwW93t08MZNIJA4ZsGg8EFjMieWAoDKmMIVYepwqNVGpYPxq8cmcGTnJeR6mK rRtRgLvTIC9eAa9DEy7BXNtu0eLuPVXLaFCB873C9oihxCR5eO41SX325vT0FFvrkt03 NEBrKcM0I4Wx3qNiFz66QcSpsEjLPUoJ41G7fcuwumnZ9Y+FN//FH8AwatHO7A33czKI 95N8zZf1HzN3ZV0YoW0HGgGadd/eAOVDwek1V/AMnRF6Sadc8hriQe/crH76wpk1EsKx s6Ag== X-Gm-Message-State: ALoCoQm0Ws7a5MonjRdfaoqX7wlU/Ek+AkMV2vW0rO8U8cLgUzIsVNEdb+aihyEBcbbNpan4ZV/AgZJNPXHVgVbjceeAnk9YlQ== X-Received: by 10.25.152.133 with SMTP id a127mr2278402lfe.152.1449668355281; Wed, 09 Dec 2015 05:39:15 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t82sm1446369lfe.14.2015.12.09.05.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:39:14 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Ralf Baechle Cc: Linus Walleij , linux-mips@linux-mips.org, Alban Bedel Subject: [PATCH 136/182] MIPS: ar7: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:39:11 +0100 Message-Id: <1449668351-4493-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: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: Alban Bedel Signed-off-by: Linus Walleij --- Ralf: please ACK this so I can take it through the GPIO tree. BTW: would be nice if the MIPS GPIO drivers could move down to drivers/gpio in the long run. --- arch/mips/ar7/gpio.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 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/arch/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c index f4930456eb8e..0b4485697d10 100644 --- a/arch/mips/ar7/gpio.c +++ b/arch/mips/ar7/gpio.c @@ -33,8 +33,7 @@ struct ar7_gpio_chip { static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_in = gpch->regs + AR7_GPIO_INPUT; return readl(gpio_in) & (1 << gpio); @@ -42,8 +41,7 @@ static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_in0 = gpch->regs + TITAN_GPIO_INPUT_0; void __iomem *gpio_in1 = gpch->regs + TITAN_GPIO_INPUT_1; @@ -53,8 +51,7 @@ static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio) static void ar7_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_out = gpch->regs + AR7_GPIO_OUTPUT; unsigned tmp; @@ -67,8 +64,7 @@ static void ar7_gpio_set_value(struct gpio_chip *chip, static void titan_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_out0 = gpch->regs + TITAN_GPIO_OUTPUT_0; void __iomem *gpio_out1 = gpch->regs + TITAN_GPIO_OUTPUT_1; unsigned tmp; @@ -81,8 +77,7 @@ static void titan_gpio_set_value(struct gpio_chip *chip, static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; writel(readl(gpio_dir) | (1 << gpio), gpio_dir); @@ -92,8 +87,7 @@ static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; @@ -108,8 +102,7 @@ static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) static int ar7_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; ar7_gpio_set_value(chip, gpio, value); @@ -121,8 +114,7 @@ static int ar7_gpio_direction_output(struct gpio_chip *chip, static int titan_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct ar7_gpio_chip *gpch = - container_of(chip, struct ar7_gpio_chip, chip); + struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; @@ -335,7 +327,7 @@ int __init ar7_gpio_init(void) return -ENOMEM; } - ret = gpiochip_add(&gpch->chip); + ret = gpiochip_add_data(&gpch->chip, gpch); if (ret) { printk(KERN_ERR "%s: failed to add gpiochip\n", gpch->chip.label);