From patchwork Wed Dec 9 13:17:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57989 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp662113lbb; Wed, 9 Dec 2015 05:17:36 -0800 (PST) X-Received: by 10.98.73.10 with SMTP id w10mr12845940pfa.164.1449667056235; Wed, 09 Dec 2015 05:17:36 -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.17.36; Wed, 09 Dec 2015 05:17:36 -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 S1753925AbbLINRf (ORCPT + 4 others); Wed, 9 Dec 2015 08:17:35 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:34036 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753598AbbLINRf (ORCPT ); Wed, 9 Dec 2015 08:17:35 -0500 Received: by lffu14 with SMTP id u14so34023749lff.1 for ; Wed, 09 Dec 2015 05:17:33 -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=DPh8ax6BA0jjXSebnB2rn8iGoYbv3lgmN7Ahpef0law=; b=Nd5NFIiUPZp/xE1jrI1vVJ34u8+6Dq0e4ruwKJWmrl8wrjVDCwAAGZiMrw9OEjJjyw gAxmcEdZRbK5UoKdoxe6s3pGZQollH2ANbMZl6KhDf1OSk7OY01MrmAe7s47kOkV3eTP ep7DVtogSYniyaVQ2pS6UCAK1VEqR9Nmtx/Rrn1q1l/K4tgj8gJ5+00c5JG0qCcIbWPA KdsuwoTB8CCPRVd8mhs7jNs3ZtLXRurcPddpBjXw9O6oc8M2wJsKVT+FDO9EAQ0WsJs3 OA9dyfsJ/sCuyaptkdmW606NUiiK7piieo8DCYh0prygIK3KIglPgNtP4mMWd0Io4JO/ ADHg== 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=DPh8ax6BA0jjXSebnB2rn8iGoYbv3lgmN7Ahpef0law=; b=eJEZkfsuyxmj25H++PiV2KYUNBcIo9Tk8ccr0XDYtBwMfud8xcwiN1i4Y/kU1Fitgt 0p5RTeZwNDRY2ssdpSGjmfsq2NmPzrrKuzZW4j2LipqYekKN9KSmVBpmRK1lxrJBJ63F SBpqx0waKBuJnbPMHo8gNzLXRyM/f+odt4Nq1tvNFeayLOdTVd9277pxWv4pnknQSo1u n4kDgUkDxga8YqBTfd7Ty/JHPW3vZGQKYEikshCrftDoXK67sQoqRYtLFbjs4xBFEx93 SXnr8CIJ0X7CIz/+onk8+EMb4263I0VzKnuv6p+zLPSZFvUr9fDb68hbTjpK7cfrgDVb cXMA== X-Gm-Message-State: ALoCoQkx3vZH1SU3ul76UQx6uRfMT8FjHPICmOOV7QxQ9kVIjnj80tEVErD8RxwuHJQ/xnPidmSjRPopXbu4OP602QLrFp7ljw== X-Received: by 10.25.206.203 with SMTP id e194mr1791210lfg.166.1449667053584; Wed, 09 Dec 2015 05:17:33 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id zc2sm1415538lbb.40.2015.12.09.05.17.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:17:32 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Nicholas Krause , Marek Vasut , Semen Protsenko Subject: [PATCH 034/182] gpio: max732x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:17:29 +0100 Message-Id: <1449667049-31361-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: Nicholas Krause Cc: Marek Vasut Cc: Semen Protsenko Signed-off-by: Linus Walleij --- drivers/gpio/gpio-max732x.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-max732x.c b/drivers/gpio/gpio-max732x.c index a1094984b666..e6d0c8d71c2a 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -158,11 +158,6 @@ struct max732x_chip { #endif }; -static inline struct max732x_chip *to_max732x(struct gpio_chip *gc) -{ - return container_of(gc, struct max732x_chip, gpio_chip); -} - static int max732x_writeb(struct max732x_chip *chip, int group_a, uint8_t val) { struct i2c_client *client; @@ -201,7 +196,7 @@ static inline int is_group_a(struct max732x_chip *chip, unsigned off) static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint8_t reg_val; int ret; @@ -215,7 +210,7 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask, int val) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint8_t reg_out; int ret; @@ -259,7 +254,7 @@ static void max732x_gpio_set_multiple(struct gpio_chip *gc, static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); unsigned int mask = 1u << off; if ((mask & chip->dir_input) == 0) { @@ -281,7 +276,7 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) static int max732x_gpio_direction_output(struct gpio_chip *gc, unsigned off, int val) { - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); unsigned int mask = 1u << off; if ((mask & chip->dir_output) == 0) { @@ -356,7 +351,7 @@ static void max732x_irq_update_mask(struct max732x_chip *chip) static void max732x_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); chip->irq_mask_cur &= ~(1 << d->hwirq); } @@ -364,7 +359,7 @@ static void max732x_irq_mask(struct irq_data *d) static void max732x_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); chip->irq_mask_cur |= 1 << d->hwirq; } @@ -372,7 +367,7 @@ static void max732x_irq_unmask(struct irq_data *d) static void max732x_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->irq_lock); chip->irq_mask_cur = chip->irq_mask; @@ -381,7 +376,7 @@ static void max732x_irq_bus_lock(struct irq_data *d) static void max732x_irq_bus_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint16_t new_irqs; uint16_t level; @@ -400,7 +395,7 @@ static void max732x_irq_bus_sync_unlock(struct irq_data *d) static int max732x_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct max732x_chip *chip = to_max732x(gc); + struct max732x_chip *chip = gpiochip_get_data(gc); uint16_t off = d->hwirq; uint16_t mask = 1 << off; @@ -694,7 +689,7 @@ static int max732x_probe(struct i2c_client *client, goto out_failed; } - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (ret) goto out_failed;