From patchwork Wed Dec 9 13:13:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57963 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp659723lbb; Wed, 9 Dec 2015 05:13:50 -0800 (PST) X-Received: by 10.66.193.73 with SMTP id hm9mr7768043pac.117.1449666830603; Wed, 09 Dec 2015 05:13:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc9si12670093pad.140.2015.12.09.05.13.50; Wed, 09 Dec 2015 05:13:50 -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 S1753331AbbLINNu (ORCPT + 4 others); Wed, 9 Dec 2015 08:13:50 -0500 Received: from mail-lb0-f172.google.com ([209.85.217.172]:34864 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbbLINNt (ORCPT ); Wed, 9 Dec 2015 08:13:49 -0500 Received: by lbpu9 with SMTP id u9so29515104lbp.2 for ; Wed, 09 Dec 2015 05:13:47 -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=SIcXiBKzHEX35jUfXtbKkBINvQRZGO0MAh/UoJ8pi54=; b=dx3c7colxKzubuL9/N/LpJ13AcB2djMa/naS4XmBjP0hYR9jUWc/6sJ8+44JYbjdsJ jmBZFRuONEkrEAh8ev4OECMT0f4aXrmTzO3Br4kPrHeTgQSN7UvSb4tN070hhjK0uhrm gO0zEr9AoKDOFBVBbn3hpwY+r8/eKvXSsgnvvqF2DE1I/mCBz5MXCKb/J0vpFxtockui ZwrsrJD/KZionWsLH0kCHHuWJaeGQ1Bi92S1pDcCdtiMKjINO8+xe/1kyRCyl7j3GcPY pae7L8ZP6DBoI3iTqYpU2SZtfFk2LlWcOXiPboDtkKyXw+3vzmtwvHO1cvcGaYU0c9b9 0CQA== 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=SIcXiBKzHEX35jUfXtbKkBINvQRZGO0MAh/UoJ8pi54=; b=eudhmqkMexCNAnHVD63BunqESmA5cyiWDbru0LUoajE2TjHnMzk13cXPyUYPXL9BbQ c0t2ghWCG1RsjNSmhlWMTJzf7LvYa+8fRfLk+xwBvjtJoS6sCvcp8um+BWkeXV1nq24Z Eo4eOyxtiTZRlA5IK6U/+Fb4NUqUlLrVHeNFIk29D3XvoXij2iIEkb4X+KYkv3pG1ivc cqRRY4u8gm1SQ/+QdxGUun8MMNbWdkEQ6CCXVGiqby5cPAYvJwxNGHJgtqB9DsyBxBCr BIsRWpD7Y+wcB1p1NQEU7wQ5GeJtd3+omvVHjXM77d2A2wReg9l7XQM91vAn+1Bj8RXs OC7w== X-Gm-Message-State: ALoCoQlLpnmDiN5PQma6La6ywON4281HeL3XHnLqkmmsDU+yx9BWIp4hPzvo7WVFlWyxXOKIPCWQ83eQUgs5ZfnDlVWleiQHUQ== X-Received: by 10.112.129.134 with SMTP id nw6mr2388558lbb.10.1449666827869; Wed, 09 Dec 2015 05:13:47 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id aa4sm1415764lbc.10.2015.12.09.05.13.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:13:47 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij Subject: [PATCH 008/182] gpio: adnp: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:13:44 +0100 Message-Id: <1449666824-30112-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-adnp.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 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-adnp.c b/drivers/gpio/gpio-adnp.c index b8a1ac133390..fb5b47b69f14 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -36,11 +36,6 @@ struct adnp { u8 *irq_low; }; -static inline struct adnp *to_adnp(struct gpio_chip *chip) -{ - return container_of(chip, struct adnp, gpio); -} - static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value) { int err; @@ -72,7 +67,7 @@ static int adnp_write(struct adnp *adnp, unsigned offset, uint8_t value) static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; u8 value; @@ -106,7 +101,7 @@ static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value) static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); mutex_lock(&adnp->i2c_lock); __adnp_gpio_set(adnp, offset, value); @@ -115,7 +110,7 @@ static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; u8 value; @@ -150,7 +145,7 @@ out: static int adnp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int reg = offset >> adnp->reg_shift; unsigned int pos = offset & 7; int err; @@ -187,7 +182,7 @@ out: static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - struct adnp *adnp = to_adnp(chip); + struct adnp *adnp = gpiochip_get_data(chip); unsigned int num_regs = 1 << adnp->reg_shift, i, j; int err; @@ -270,7 +265,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios) chip->of_node = chip->parent->of_node; chip->owner = THIS_MODULE; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, adnp); if (err) return err; @@ -340,7 +335,7 @@ static irqreturn_t adnp_irq(int irq, void *data) static void adnp_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -350,7 +345,7 @@ static void adnp_irq_mask(struct irq_data *d) static void adnp_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -360,7 +355,7 @@ static void adnp_irq_unmask(struct irq_data *d) static int adnp_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int reg = d->hwirq >> adnp->reg_shift; unsigned int pos = d->hwirq & 7; @@ -390,7 +385,7 @@ static int adnp_irq_set_type(struct irq_data *d, unsigned int type) static void adnp_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); mutex_lock(&adnp->irq_lock); } @@ -398,7 +393,7 @@ static void adnp_irq_bus_lock(struct irq_data *d) static void adnp_irq_bus_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct adnp *adnp = to_adnp(gc); + struct adnp *adnp = gpiochip_get_data(gc); unsigned int num_regs = 1 << adnp->reg_shift, i; mutex_lock(&adnp->i2c_lock);