From patchwork Wed Dec 9 13:41:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58103 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp676022lbb; Wed, 9 Dec 2015 05:41:44 -0800 (PST) X-Received: by 10.67.7.101 with SMTP id db5mr7939646pad.53.1449668504813; Wed, 09 Dec 2015 05:41:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si12808196pfn.188.2015.12.09.05.41.44; Wed, 09 Dec 2015 05:41:44 -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 S1754327AbbLINlo (ORCPT + 4 others); Wed, 9 Dec 2015 08:41:44 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:36599 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbLINln (ORCPT ); Wed, 9 Dec 2015 08:41:43 -0500 Received: by lfs39 with SMTP id 39so34630400lfs.3 for ; Wed, 09 Dec 2015 05:41:42 -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=RxgvZXklKvJsLwKGgSJq5BdD1QakXfOH5PygqLmTEXo=; b=ThbX3egRBrGHWdonEwwERb/nZuR1FOA+gPPUbCy9Cl5KyPKwHRE2UXZsCEC23htC47 CekuUTriZEcOvW7z/glmJpNp77o8/esxbuFRyISCOgT3Q79ALR6f3DQfRt8TRYBcx2qV pQ8qpelp0cuGhV52fmWhyZWYvGtRNu3fCAWmgzYtZVFZClvY5nVzhQNqKcakHB36QKTL 5auXOlGQAabFyW7aE1XiyxY/3eaFTDmR3RYGyllooqplAbKpVG9N/Xj/CcFTPII7oZst UjfX3tutZZuG3R7JGh7RlMbb5GYkwXvaWvyXrnpUrtGO88AhB/8DTtp2NNFVPGmYRsZj EWew== 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=RxgvZXklKvJsLwKGgSJq5BdD1QakXfOH5PygqLmTEXo=; b=Ia1Wo3OwaJIUnQddRjA+Amgbi4zfYNFuGDC/3ICndCF2Y8Q5YycKZPUvP+G8WXuxuk AiElrvocGa64X8u/vL2jaNFniBvZtIbMKw4SRt5YCePwvie51b+5oYQdf6AiiVCNNKmT DAD0gwSMcFohJWijzeHGWKxGXAFw4WychuAGR4QALmvQnLduFt2A5A/At4XDtIVH46qo rnDDvEus60zBhNCnTu5wuR4GfyaTqdFqNMc2/hCcP78gnODbBekpU6eSolj3X6SvqDBR 8H/23xY+wKssUYGTpxlcI4nFcUH3YOOPWrKp/MG1I1hSp4JkvREoNlXIdlHoVxXuG9N9 hEjg== X-Gm-Message-State: ALoCoQnKmz9slXFvlQqmD56iD8928TTRNs2VbI3Q67A/ShUVB7dtUFDaN8Ui8nRzLinHWrEAnEHpWxQWnChI1FBDVEUsTyYGBQ== X-Received: by 10.25.80.204 with SMTP id e195mr2445564lfb.133.1449668502377; Wed, 09 Dec 2015 05:41:42 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b7sm1441998lbv.0.2015.12.09.05.41.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:41:41 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Anatolij Gustschin , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Linus Walleij Subject: [PATCH 147/182] powerpc: ppc4xx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:41:39 +0100 Message-Id: <1449668499-5071-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: Anatolij Gustschin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Linus Walleij --- Power maintainers: please ACK this. This looks like a pretty clean GPIO driver that should ideally move to drivers/gpio. It should be fine to change the include from to on this as it does not appear to use the consumer API. --- arch/powerpc/sysdev/ppc4xx_gpio.c | 16 +++++----------- 1 file changed, 5 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/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c index fc65ad1b3293..96145ea09835 100644 --- a/arch/powerpc/sysdev/ppc4xx_gpio.c +++ b/arch/powerpc/sysdev/ppc4xx_gpio.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -67,12 +67,6 @@ struct ppc4xx_gpio_chip { * There are a maximum of 32 gpios in each gpio controller. */ -static inline struct ppc4xx_gpio_chip * -to_ppc4xx_gpiochip(struct of_mm_gpio_chip *mm_gc) -{ - return container_of(mm_gc, struct ppc4xx_gpio_chip, mm_gc); -} - static int ppc4xx_gpio_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); @@ -97,7 +91,7 @@ static void ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -112,7 +106,7 @@ ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); struct ppc4xx_gpio __iomem *regs = mm_gc->regs; unsigned long flags; @@ -142,7 +136,7 @@ static int ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); struct ppc4xx_gpio __iomem *regs = mm_gc->regs; unsigned long flags; @@ -200,7 +194,7 @@ static int __init ppc4xx_add_gpiochips(void) gc->get = ppc4xx_gpio_get; gc->set = ppc4xx_gpio_set; - ret = of_mm_gpiochip_add(np, mm_gc); + ret = of_mm_gpiochip_add_data(np, mm_gc, ppc4xx_gc); if (ret) goto err; continue;