From patchwork Wed Dec 9 13:28:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58039 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668394lbb; Wed, 9 Dec 2015 05:28:32 -0800 (PST) X-Received: by 10.98.0.137 with SMTP id 131mr12916054pfa.137.1449667712641; Wed, 09 Dec 2015 05:28:32 -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.28.32; Wed, 09 Dec 2015 05:28:32 -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 S1754087AbbLIN2c (ORCPT + 4 others); Wed, 9 Dec 2015 08:28:32 -0500 Received: from mail-lb0-f177.google.com ([209.85.217.177]:34553 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLIN2b (ORCPT ); Wed, 9 Dec 2015 08:28:31 -0500 Received: by lbbcs9 with SMTP id cs9so29892930lbb.1 for ; Wed, 09 Dec 2015 05:28:30 -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:mime-version:content-type :content-transfer-encoding; bh=W4r3CGhId8ik7q0g3DyC+b99fOW0wxhCB+VArkEj9tU=; b=dxyHK7YTB4px26LwbzYrf79CJ7prMo6vON5JXlTuNYnQ2R8wtTYsEZNNNOQde4AtBo pVqt/X+6j1sTFJxSppP5XRJFd591NpT3EaAiYBJvZrTTrtVGpBb4EdXWop34n4+RGPAO z/Xa14ARjMWHZulI0LOEKfrSlS8Wl+1VLgyraHqmDb5Z1vVmGdpr91UjwQr5/EEvdp+6 YE63PlUtlq2eIb5NXI7wZkDgYmQeS0QOTaAZZlkG1uyRI53BOOzTuDK3pEbKsdUdPD44 306fiohxdgNwHvn7IcmDujyOZQZHiiStpXVg5D29i3npQ2E5Bk3CsoY7V4ncRn7K+Sah 989Q== 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:mime-version :content-type:content-transfer-encoding; bh=W4r3CGhId8ik7q0g3DyC+b99fOW0wxhCB+VArkEj9tU=; b=D5qlGmej72mSh02n8kmioLZY1iruc5UMkc1PbPglD7TipBDWCJn1dFsxg+GWoSo+T7 A3q/gLhGYe2km8n2xVvqzTKUlGkkDaAbVzsBG3pckrJUc5YIXhaUCv+qZjJlNN3KknZ4 74hM01ILOrcZuJaQFrSSaeDPIx30RbSrq91+YA9HfEOjOTMtl79t0sa42VzUxpXHprEL Zl+Me6U4rSLNkvt8pQ6n3JQX2Lcn/RJTStq70bTLFjlk24E6ttuRoeIBPlyzm1lg2wPr IfVuswq1C6JPq9RyUr43hDTiFd5So0fLaxn+35O7Ts840jUU6psvsqF+jRocBGQstEVk pbcA== X-Gm-Message-State: ALoCoQnniJKTiDTVkoulU+6Cc2HqhFDPQk8uux9jU00sAaL8EjsGQzxs8jDQTrok9DXOzhMI3vImk06fXC+jbO/2d4TBj9A+dA== X-Received: by 10.112.11.169 with SMTP id r9mr2501390lbb.8.1449667709999; Wed, 09 Dec 2015 05:28:29 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b7sm1433437lbv.0.2015.12.09.05.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:28:29 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= Subject: [PATCH 083/182] gpio: xilinx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:28:24 +0100 Message-Id: <1449667704-1395-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 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: Michal Simek Cc: Sören Brinkmann Signed-off-by: Linus Walleij --- drivers/gpio/gpio-xilinx.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 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-xilinx.c b/drivers/gpio/gpio-xilinx.c index 5c2971e1cb08..3345ab0ba1b3 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -92,8 +92,7 @@ static inline int xgpio_offset(struct xgpio_instance *chip, int gpio) static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); u32 val; val = xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET + @@ -115,8 +114,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -147,8 +145,7 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -180,8 +177,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { unsigned long flags; struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(gc); int index = xgpio_index(chip, gpio); int offset = xgpio_offset(chip, gpio); @@ -211,8 +207,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) */ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) { - struct xgpio_instance *chip = - container_of(mm_gc, struct xgpio_instance, mmchip); + struct xgpio_instance *chip = gpiochip_get_data(&mm_gc->gc); xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); @@ -314,7 +309,7 @@ static int xgpio_probe(struct platform_device *pdev) chip->mmchip.save_regs = xgpio_save_regs; /* Call the OF gpio helper to setup and register the GPIO device */ - status = of_mm_gpiochip_add(np, &chip->mmchip); + status = of_mm_gpiochip_add_data(np, &chip->mmchip, chip); if (status) { pr_err("%s: error in probe function with status %d\n", np->full_name, status);