From patchwork Wed Dec 9 13:18:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57997 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp662787lbb; Wed, 9 Dec 2015 05:18:43 -0800 (PST) X-Received: by 10.98.44.193 with SMTP id s184mr12902602pfs.8.1449667123681; Wed, 09 Dec 2015 05:18:43 -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.18.43; Wed, 09 Dec 2015 05:18:43 -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 S1754083AbbLINSn (ORCPT + 4 others); Wed, 9 Dec 2015 08:18:43 -0500 Received: from mail-lf0-f41.google.com ([209.85.215.41]:34648 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751673AbbLINSm (ORCPT ); Wed, 9 Dec 2015 08:18:42 -0500 Received: by lffu14 with SMTP id u14so34045936lff.1 for ; Wed, 09 Dec 2015 05:18:40 -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=C1wZrUKhd2REEsNHQhvnS++gn0e8TTlCW7BJzmX67s4=; b=grdEoOmV6/YmyiQb5+KuG/MlrW4Ra98Hy3zbPdOyoMOc6OsOmaebRyKMnke0U6Cfp0 5TnQGzaUYhRHZ8ZGAlms3PXhPdHKNyW0GY19eFyZHtgVIt1D+Y5G4hFW/TOTcZL38hC7 iWz4Je/Pw9QkPiQljM5WlJ/b8M1KLExNY/50tot4wHNx0y5QKWuXz2Cpn1+1kCu1ff+I LFkD9V57QtEqGJgLsORjazb4dKYrkSvk47mSTIaywlVp85uXKS6lNWJ83BvNB4p6pLAn kkwjQtje540h2YmsImSlpnACrBK53TmPF33HxNgbVcJum4zwKUNtuYblP4tcZWK/ZFNX 2rSQ== 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=C1wZrUKhd2REEsNHQhvnS++gn0e8TTlCW7BJzmX67s4=; b=BZlo5aSg6u6/FPpSBd4am0HSRUD0smkpaIwJfyvDgesCkbR0c7tjfcwKO2xRaUwZgJ rxiSXLoSIZ/HV8+UBZL87CWYZAJ26GofVmwUdTxmgjNhAoNOJwNlk2xG50kaw9PvTi80 5UNFliUceAYgLeUv6MStalwEi/0orMXTxSVog2+M7Y5rQZybCTsybtcdlsw98zyqx+t/ z0EckKO6YX6FdkZ4sVGJqtneBiyxXNtXfNoWhOrPp/caRn32ZrdWxgg07UqtXa4j+XWK NGvvp2U1JeOiRsuKyleskiFUWCLwjlnhh4aNqpUXCyuDzV9vE1exiDD00/THmDSi0fUx EsaA== X-Gm-Message-State: ALoCoQke9VKJHQUNIvnBNAsw1lx0ZV+c0bB1rP/Vu2WBjoNtfNY5GykOT/jsHZ5xZ4T99Qh2/3SfHsVnwBvt68oetWNt0JQLZA== X-Received: by 10.25.90.71 with SMTP id o68mr2310379lfb.120.1449667120852; Wed, 09 Dec 2015 05:18:40 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id nq2sm1410755lbb.33.2015.12.09.05.18.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:18:40 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Alexander Stein , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH 042/182] gpio: mpc8xxx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:18:37 +0100 Message-Id: <1449667117-31740-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: Alexander Stein Cc: Uwe Kleine-König Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc8xxx.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 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-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 48ef368347ab..34b6ebe63638 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -49,15 +49,9 @@ static inline u32 mpc8xxx_gpio2mask(unsigned int gpio) return 1u << (MPC8XXX_GPIO_PINS - 1 - gpio); } -static inline struct mpc8xxx_gpio_chip * -to_mpc8xxx_gpio_chip(struct of_mm_gpio_chip *mm) -{ - return container_of(mm, struct mpc8xxx_gpio_chip, mm_gc); -} - static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) { - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(&mm->gc); mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT); } @@ -71,7 +65,7 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) { u32 val; struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); u32 out_mask, out_shadow; out_mask = in_be32(mm->regs + GPIO_DIR); @@ -92,7 +86,7 @@ static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio) static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); @@ -111,7 +105,7 @@ static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; int i; @@ -136,7 +130,7 @@ static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); @@ -151,7 +145,7 @@ static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); unsigned long flags; mpc8xxx_gpio_set(gc, gpio, val); @@ -185,8 +179,7 @@ static int mpc5125_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) { - struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); - struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); + struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); if (mpc8xxx_gc->irq && offset < MPC8XXX_GPIO_PINS) return irq_create_mapping(mpc8xxx_gc->irq, offset); @@ -417,7 +410,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) gc->set_multiple = mpc8xxx_gpio_set_multiple; gc->to_irq = mpc8xxx_gpio_to_irq; - ret = of_mm_gpiochip_add(np, mm_gc); + ret = of_mm_gpiochip_add_data(np, mm_gc, mpc8xxx_gc); if (ret) return ret;