From patchwork Wed Dec 9 13:23: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: 58018 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp665568lbb; Wed, 9 Dec 2015 05:23:24 -0800 (PST) X-Received: by 10.98.74.221 with SMTP id c90mr12892887pfj.127.1449667403962; Wed, 09 Dec 2015 05:23:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66si12740587pfb.179.2015.12.09.05.23.23; Wed, 09 Dec 2015 05:23:23 -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 S1753927AbbLINXV (ORCPT + 4 others); Wed, 9 Dec 2015 08:23:21 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:34906 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbLINXT (ORCPT ); Wed, 9 Dec 2015 08:23:19 -0500 Received: by lfdl133 with SMTP id l133so33946473lfd.2 for ; Wed, 09 Dec 2015 05:23:18 -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=565UOea+yL8fBEAygNTJKVtEU7wcYuPpLdNYv+Cgy5A=; b=LdF/LAJ8eiS0MFUZo80wt0ud3ALO7CSPHyaxoLyqwL/mG2QLPsBmkcAwo8Y1FBC/+t nmYBwUYptirgie0Mh3yy5sWyQibx1ck2V8VkvCZkObEQq5BrvgQBIVLHLA88oH/lGqWz +7X3NzGUluGQ7iJtH3LFyxwvVsE301YF7HKYonkyzg38P0RFt4WcBYl8Fly8AI795a+g 3hPI7A7V4JCHKTiy8IuxO+LUwdIgNr3UK68T5y1nud2uak6i6Td1RtPkpkqtbvLRgpbe Lnw5ZXyVYZtyBSWRpoAedy3ODxyjbbNcpWbdbCHgOq8P3wVhCZ3HiC5yfkEJADsBrtA3 VtHA== 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=565UOea+yL8fBEAygNTJKVtEU7wcYuPpLdNYv+Cgy5A=; b=lN4SPLy5ziDQWx1Oh3Ef5ugMqzY+jw9LWTexyMVojruoSmlALsRjtQjGJBM2qJagJp zfDi41erF4mUPKSIdYoEAF7B1SBgN32a5d4f9YjlZvVkAHUAH4TaYR9oA8eXvS+VzJCl 3NScShAxnjcETSFFikch7gwbCbbj59r641I2xom91w38Hb6CY3FhfEdLAirhGOmYpb3D o993A18su9VWIEtXnYFJRBGrjAgrkbt6IYfv1xfAQsSI5P/cmRP7Fc0ackfGur/ZPAE0 9x0UJa244U9bnpobGUpTqPT8FuY4Xcx8KqYCvFHJnfXWpyUScUmVIaWfoqe3zgZv121D eTmA== X-Gm-Message-State: ALoCoQl5j/YofQ1+OAHWR4M5j0fRS4xKr4NoRMgRiEistD6kk/YSLVSNvnnK1fHf0mjGYN9mgRwHTCf9IA+LOQV3aucmEcZxCQ== X-Received: by 10.25.166.146 with SMTP id p140mr2425877lfe.51.1449667398348; Wed, 09 Dec 2015 05:23:18 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id h196sm1432369lfb.48.2015.12.09.05.23.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:23:17 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Wei Chen Subject: [PATCH 063/182] gpio: sx150x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:23:14 +0100 Message-Id: <1449667394-32767-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: Wei Chen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sx150x.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-sx150x.c b/drivers/gpio/gpio-sx150x.c index cf12d8e3ce3e..43bc4406d4f6 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -160,11 +160,6 @@ static const struct of_device_id sx150x_of_match[] = { }; MODULE_DEVICE_TABLE(of, sx150x_of_match); -struct sx150x_chip *to_sx150x(struct gpio_chip *gc) -{ - return container_of(gc, struct sx150x_chip, gpio_chip); -} - static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val) { s32 err = i2c_smbus_write_byte_data(client, reg, val); @@ -301,7 +296,7 @@ static int sx150x_io_output(struct sx150x_chip *chip, unsigned offset, int val) static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = -EINVAL; if (!offset_is_oscio(chip, offset)) { @@ -315,7 +310,7 @@ static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->lock); if (offset_is_oscio(chip, offset)) @@ -327,7 +322,7 @@ static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val) static int sx150x_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = -EINVAL; if (!offset_is_oscio(chip, offset)) { @@ -342,7 +337,7 @@ static int sx150x_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int val) { - struct sx150x_chip *chip = to_sx150x(gc); + struct sx150x_chip *chip = gpiochip_get_data(gc); int status = 0; if (!offset_is_oscio(chip, offset)) { @@ -355,7 +350,7 @@ static int sx150x_gpio_direction_output(struct gpio_chip *gc, static void sx150x_irq_mask(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n = d->hwirq; chip->irq_masked |= (1 << n); @@ -364,7 +359,7 @@ static void sx150x_irq_mask(struct irq_data *d) static void sx150x_irq_unmask(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n = d->hwirq; chip->irq_masked &= ~(1 << n); @@ -373,7 +368,7 @@ static void sx150x_irq_unmask(struct irq_data *d) static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n, val = 0; if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) @@ -428,14 +423,14 @@ static irqreturn_t sx150x_irq_thread_fn(int irq, void *dev_id) static void sx150x_irq_bus_lock(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mutex_lock(&chip->lock); } static void sx150x_irq_bus_sync_unlock(struct irq_data *d) { - struct sx150x_chip *chip = to_sx150x(irq_data_get_irq_chip_data(d)); + struct sx150x_chip *chip = gpiochip_get_data(irq_data_get_irq_chip_data(d)); unsigned n; if (chip->irq_update == NO_UPDATE_PENDING) @@ -647,7 +642,7 @@ static int sx150x_probe(struct i2c_client *client, if (rc < 0) return rc; - rc = gpiochip_add(&chip->gpio_chip); + rc = gpiochip_add_data(&chip->gpio_chip, chip); if (rc) return rc;