From patchwork Wed Dec 9 13:15:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57974 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp660768lbb; Wed, 9 Dec 2015 05:15:26 -0800 (PST) X-Received: by 10.98.13.218 with SMTP id 87mr12785650pfn.153.1449666926761; Wed, 09 Dec 2015 05:15:26 -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.15.26; Wed, 09 Dec 2015 05:15:26 -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 S1754132AbbLINP0 (ORCPT + 4 others); Wed, 9 Dec 2015 08:15:26 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:36732 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLINPZ (ORCPT ); Wed, 9 Dec 2015 08:15:25 -0500 Received: by lfs39 with SMTP id 39so34119074lfs.3 for ; Wed, 09 Dec 2015 05:15:24 -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=M7WY+RRHC5lmTso7POZkIJeYb5k70WXlenRoKOXSDxA=; b=jJE+ZmxVf+FOjBMxmWiAl9AWlheLC8OS22AiRdMq76s8tDlhFC93lYzRIIhgq/PLQ+ 8B6Tk3IjtDI4qRnSOfkeSkP9qfnDzJ421Z81YZ8BYUg9JIqHZ9X8ESnWLkQt7WeL4WHs yvZtL6z7AvYXcO/umnxo30VDlKmL6iPFR2xgU2Yn1aVq1a4aLkCFYJfo7V2vA32CIF+R 04bXrudd5inWrYhBHhVFavdOBB9VDDzSkH92twBO9YGW+P45IbbdOuyJvLkTgHw2PO8v gz7Qqh1MUHowyIJXXnaYx4NXmMlktQAMhdwTbK50sdSlY+fFQuktRPWs3YXe8RE1jjhI H+ug== 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=M7WY+RRHC5lmTso7POZkIJeYb5k70WXlenRoKOXSDxA=; b=dhumZQe8H4noWBX914epLGLJPPLJtYMTv876SMR37gtZBN7QHqTPFx8Ggbr4at/wTO LKLtqI0z+ufizLmEPm+8pNXEmPCsyJsfhLdCQbNF650rLJWa0pW9WWK0ojRXddCnWnp9 ZeIlF7s7KWNw3o50T4vyqkFKkvYTzZcHkXVU0K/dlpfnTtAnfRfcGHlI1Ux07ZgFaKGR ipsZ2zSmdFE7PXuV7AZVPya07RNpW5rCOqpnDY4bbS8kUgMuqjxqli0kthyS8GJdQ68y ZpMAEuNVYOOjRm0vAKTgCieO3k8WssdYJFclG6rELHimfiBSaOTC/pnvUcg1pyOBS6kD EgWg== X-Gm-Message-State: ALoCoQkSGgUouDkBAqb4eu3zx5YV6Bb7yZfZIlW9ExXD9ag3kNLPKV2LqgBhKGlMigaSP+uMmpVLB0dFz6mAxVrDNCFOue6iEw== X-Received: by 10.25.27.147 with SMTP id b141mr2182761lfb.87.1449666924303; Wed, 09 Dec 2015 05:15:24 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id oq10sm1417508lbb.29.2015.12.09.05.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:15:23 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Fabian Frederick Subject: [PATCH 019/182] gpio: cs5535: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:15:20 +0100 Message-Id: <1449666920-30643-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: Fabian Frederick Signed-off-by: Linus Walleij --- drivers/gpio/gpio-cs5535.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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-cs5535.c b/drivers/gpio/gpio-cs5535.c index 7b0b198a563d..eccb712e09fb 100644 --- a/drivers/gpio/gpio-cs5535.c +++ b/drivers/gpio/gpio-cs5535.c @@ -42,6 +42,10 @@ static ulong mask = GPIO_DEFAULT_MASK; module_param_named(mask, mask, ulong, 0444); MODULE_PARM_DESC(mask, "GPIO channel mask."); +/* + * FIXME: convert this singleton driver to use the state container + * design pattern, see Documentation/driver-model/design-patterns.txt + */ static struct cs5535_gpio_chip { struct gpio_chip chip; resource_size_t base; @@ -201,8 +205,7 @@ EXPORT_SYMBOL_GPL(cs5535_gpio_setup_event); static int chip_gpio_request(struct gpio_chip *c, unsigned offset) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -242,8 +245,7 @@ static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int chip_direction_input(struct gpio_chip *c, unsigned offset) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -256,8 +258,7 @@ static int chip_direction_input(struct gpio_chip *c, unsigned offset) static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val) { - struct cs5535_gpio_chip *chip = - container_of(c, struct cs5535_gpio_chip, chip); + struct cs5535_gpio_chip *chip = gpiochip_get_data(c); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -347,7 +348,7 @@ static int cs5535_gpio_probe(struct platform_device *pdev) mask_orig, mask); /* finally, register with the generic GPIO API */ - err = gpiochip_add(&cs5535_gpio_chip.chip); + err = gpiochip_add_data(&cs5535_gpio_chip.chip, &cs5535_gpio_chip); if (err) goto done;