From patchwork Wed Dec 9 13:29:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58042 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668820lbb; Wed, 9 Dec 2015 05:29:20 -0800 (PST) X-Received: by 10.98.8.3 with SMTP id c3mr13006248pfd.89.1449667759964; Wed, 09 Dec 2015 05:29:19 -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.29.19; Wed, 09 Dec 2015 05:29:19 -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 S1754080AbbLIN3T (ORCPT + 4 others); Wed, 9 Dec 2015 08:29:19 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:34258 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLIN3S (ORCPT ); Wed, 9 Dec 2015 08:29:18 -0500 Received: by lffu14 with SMTP id u14so34253490lff.1 for ; Wed, 09 Dec 2015 05:29:17 -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=APqG6kvIDKZoO42TrHRPjA6DOjm8L6/DvncOf7U/UJs=; b=1YCEgfIZdBC5nQPFPGSMOiimo/s7WU8zo5lHldmG3EHYdapuRRgHYcEugtE7jnWeV5 L9n1e9KIuj0NeXt+BZo1jEKPGjXMhwETrXOsBTK4h5OsxdqFUnddA948JSUuWPV/3ivx 0+ByCG28hnZ1pM305PpgJuIdDntH9SAghZO7jNBjHI6cKvMTpOq3LYik07C95SRKA4SY PxLejbP+KLGX45FzEjr/ZOMea9SJT/KhGrFd97vJESY+pAQf/Qjm0Q3WqDmuP2WFu0KV YIJB4x3r1N/IKLD2EBZgiaQLuBx7RtjYjIaZgZJ2+jn8UnkgtRjxEjT7iscqPmY6pAzy ZCcQ== 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=APqG6kvIDKZoO42TrHRPjA6DOjm8L6/DvncOf7U/UJs=; b=TW3ElTls1Mq8MJUb2QBxjQPj2zE+Pc5zmsf581mo+gVWjcit3qNgcnk8pCV4yQ0jG/ BJixAfTtboopZWvuDP0fkf4Mdzku+Qn3SnF7n2VVtKkK5FbCcuUq4kK95WMgaHFVyEY3 navt+hGDnsU2BbCBgLL3w2QbHeZwEVPn4NfDrX/lQbKmtkovuSPqEOYayc1hFg3XJhJg JLHsowKE5VrLDOotVupMHR3CAZcrtaCpB3tQT0LTDvauMZJsS3tVXVnI9p0mASgudIvv XX1rnc4vDoL7g8LdfxBa8YQFDQghdZ4b60vkWb4mhTEcjU2UkRXuB4Qi7vPrj0I9CCIv 43OQ== X-Gm-Message-State: ALoCoQm8k8v1yHzPYzHsbAXT6myWOv6ViTxb770CPOupLmkCcJszEWA55izFjZ+ECmp2Kx8voymaB0EK2vTj0r2htWkN7kK3Pg== X-Received: by 10.25.168.6 with SMTP id r6mr2241260lfe.94.1449667757386; Wed, 09 Dec 2015 05:29:17 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id pd9sm1400305lbc.48.2015.12.09.05.29.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:29:16 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Jun Nie Subject: [PATCH 086/182] gpio: zx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:29:14 +0100 Message-Id: <1449667754-1611-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: Jun Nie Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zx.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 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-zx.c b/drivers/gpio/gpio-zx.c index ab2e54fa46cf..47c79fa65670 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c @@ -43,14 +43,9 @@ struct zx_gpio { struct gpio_chip gc; }; -static inline struct zx_gpio *to_zx(struct gpio_chip *gc) -{ - return container_of(gc, struct zx_gpio, gc); -} - static int zx_direction_input(struct gpio_chip *gc, unsigned offset) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); unsigned long flags; u16 gpiodir; @@ -69,7 +64,7 @@ static int zx_direction_input(struct gpio_chip *gc, unsigned offset) static int zx_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); unsigned long flags; u16 gpiodir; @@ -92,14 +87,14 @@ static int zx_direction_output(struct gpio_chip *gc, unsigned offset, static int zx_get_value(struct gpio_chip *gc, unsigned offset) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); return !!(readw_relaxed(chip->base + ZX_GPIO_DI) & BIT(offset)); } static void zx_set_value(struct gpio_chip *gc, unsigned offset, int value) { - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); if (value) writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO1); @@ -110,7 +105,7 @@ static void zx_set_value(struct gpio_chip *gc, unsigned offset, int value) static int zx_irq_type(struct irq_data *d, unsigned trigger) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); int offset = irqd_to_hwirq(d); unsigned long flags; u16 gpiois, gpioi_epos, gpioi_eneg, gpioiev; @@ -162,7 +157,7 @@ static void zx_irq_handler(struct irq_desc *desc) unsigned long pending; int offset; struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); @@ -181,7 +176,7 @@ static void zx_irq_handler(struct irq_desc *desc) static void zx_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); u16 gpioie; @@ -196,7 +191,7 @@ static void zx_irq_mask(struct irq_data *d) static void zx_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct zx_gpio *chip = to_zx(gc); + struct zx_gpio *chip = gpiochip_get_data(gc); u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); u16 gpioie; @@ -248,7 +243,7 @@ static int zx_gpio_probe(struct platform_device *pdev) chip->gc.parent = dev; chip->gc.owner = THIS_MODULE; - ret = gpiochip_add(&chip->gc); + ret = gpiochip_add_data(&chip->gc, chip); if (ret) return ret;