From patchwork Wed Dec 9 13:23:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58021 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp665756lbb; Wed, 9 Dec 2015 05:23:43 -0800 (PST) X-Received: by 10.98.11.133 with SMTP id 5mr12978176pfl.26.1449667423860; Wed, 09 Dec 2015 05:23:43 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc7si12732909pab.144.2015.12.09.05.23.43; Wed, 09 Dec 2015 05:23: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 S1752937AbbLINXn (ORCPT + 4 others); Wed, 9 Dec 2015 08:23:43 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:34295 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbLINXm (ORCPT ); Wed, 9 Dec 2015 08:23:42 -0500 Received: by lffu14 with SMTP id u14so34144216lff.1 for ; Wed, 09 Dec 2015 05:23:41 -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=GLhNIeVbnEYi8pozxvgJ3A95iyn5sD0hGIbYPu/PF/w=; b=ZkB1tNQ33F7qdyfKSiCdaLSS0tygqdRED53+wokqluDvm8Fq4/v1devxi4WGTa7sY5 nfS6OWl0iod/yVoColexkUERmU1S3GXvFys14fM0c/DV3wpf1l56DbFGA2f9E/06/Cv5 m0D0gkCnuQ5qgoRVhkscNMxSbN7ivwetxWx7dEVzbzi3ai4sSSkpjDJwByFem6iCI6Qm mmG25vJTK3cgZ2aVqZjgxF8WTbU6n9QuPBJNHQiQ1FpnP0coIhVeOKxDWVjA6LXdTar4 rtUnES3ewtv4tqWTwgLqxEybbgxaAumwHkPayWe/fvzOENbdXP87XNR3TsIiH55aaHhz 16Fw== 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=GLhNIeVbnEYi8pozxvgJ3A95iyn5sD0hGIbYPu/PF/w=; b=MMdZjmImhHQkAURXOESJfPQKcmx9XQda3GA4IcsSZbHNsTSn7EiVTsKgDmtviV/QLo i8lUP6jvK9pNeEMzzN4tKdnqkRkZpYoPatrgMg8XLoJ/0dALGhjzaEsWlVpG7LORUocb lKJSfx8NuQSTQfWVXc8l2obXOuRX+IObMBGUWx6l4zacv1qDZEFPnFbWOhUHzJTIXiDC n5KnP+3d6+lJS8G2vlWSgtkUUjzXS1iTyY21TaLSn+4Qrn0JJDTPYSkjKmxqiDH6ncAT NRY7ND+fdR93B9Bcg9Jn7aLR/90hcOEOBNHnAnuyj0xDz8P3QfjxNsW0+fbczah70/7+ BvGQ== X-Gm-Message-State: ALoCoQldQYD2rHL63MSYhYioiJMptAYiOkM+JCK+6aYZ4S5n+U6KCabMEDETNWrU82vn8ml+d1ZVAiQQhcDci/hap4P5kJbkxQ== X-Received: by 10.25.153.144 with SMTP id b138mr1848710lfe.167.1449667420988; Wed, 09 Dec 2015 05:23:40 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l67sm1433534lfl.26.2015.12.09.05.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:23:40 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij Subject: [PATCH 066/182] gpio: tc3589x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:23:37 +0100 Message-Id: <1449667417-467-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(). Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tc3589x.c | 25 ++++++++++--------------- 1 file changed, 10 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-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 7c1537ed6dff..8f3fbf83c6e8 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -34,14 +34,9 @@ struct tc3589x_gpio { u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; }; -static inline struct tc3589x_gpio *to_tc3589x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tc3589x_gpio, chip); -} - static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; u8 mask = 1 << (offset % 8); @@ -56,7 +51,7 @@ static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; unsigned pos = offset % 8; @@ -68,7 +63,7 @@ static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int tc3589x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODIR0 + offset / 8; unsigned pos = offset % 8; @@ -81,7 +76,7 @@ static int tc3589x_gpio_direction_output(struct gpio_chip *chip, static int tc3589x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(chip); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; u8 reg = TC3589x_GPIODIR0 + offset / 8; unsigned pos = offset % 8; @@ -102,7 +97,7 @@ static struct gpio_chip template_chip = { static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -130,7 +125,7 @@ static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type) static void tc3589x_gpio_irq_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); mutex_lock(&tc3589x_gpio->irq_lock); } @@ -138,7 +133,7 @@ static void tc3589x_gpio_irq_lock(struct irq_data *d) static void tc3589x_gpio_irq_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; static const u8 regmap[] = { [REG_IBE] = TC3589x_GPIOIBE0, @@ -167,7 +162,7 @@ static void tc3589x_gpio_irq_sync_unlock(struct irq_data *d) static void tc3589x_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -178,7 +173,7 @@ static void tc3589x_gpio_irq_mask(struct irq_data *d) static void tc3589x_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct tc3589x_gpio *tc3589x_gpio = to_tc3589x_gpio(gc); + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); int offset = d->hwirq; int regoffset = offset / 8; int mask = 1 << (offset % 8); @@ -277,7 +272,7 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) return ret; } - ret = gpiochip_add(&tc3589x_gpio->chip); + ret = gpiochip_add_data(&tc3589x_gpio->chip, tc3589x_gpio); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); return ret;