From patchwork Wed Dec 9 13:19:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58003 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp663323lbb; Wed, 9 Dec 2015 05:19:38 -0800 (PST) X-Received: by 10.66.251.226 with SMTP id zn2mr7901119pac.44.1449667178802; Wed, 09 Dec 2015 05:19:38 -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.19.38; Wed, 09 Dec 2015 05:19:38 -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 S1754108AbbLINTi (ORCPT + 4 others); Wed, 9 Dec 2015 08:19:38 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:34956 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751673AbbLINTh (ORCPT ); Wed, 9 Dec 2015 08:19:37 -0500 Received: by lfdl133 with SMTP id l133so33874151lfd.2 for ; Wed, 09 Dec 2015 05:19:36 -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=pUqOfmEhgeuM/YceQahA1AdV8zs8DCdiYRMiSBiITZE=; b=jF/ClJ/uQJTKvMLnffmJPAXrZLCIeXye5yVDxv/AT51Y6bjuaMEIRc3bI7vP3wKtgH AyvYE6i6RljqYUnRwEOZjHLjHCinYSSALANRt9Gn5qzl1fxWnZ3ROKH+mYaW5GW5x50+ YUnta0z3VKKCsh2UO6wvYyNQM3Ex0LMeFS2d/hm/INpNm5om/6uBi39JL2zH9Go77dWO KIME23HRRk5Zj3Wopb85ytIHvh+0UBci03Uh0ygqQiAKNhEG+IUw/CYuA3WJyvqq5x2s w/a7Lfx1zDyIAQ+oN+UZn4amBieXooNogt7JEYIMOLZ0mhE2L3ygMVX3F+FoS0QX6/th OsVQ== 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=pUqOfmEhgeuM/YceQahA1AdV8zs8DCdiYRMiSBiITZE=; b=lHMMRt7lMJIkhf0vHNiAh84dDt3+dAD8Ezk0xCG3ZaSzLIIIk9UGO5wGcEzg2NRb69 TCo0M6ec/mAlKBlYbjt82iZ8Qg+HybqHS0nxa3wCFt3iRhu8KTCiwpaLzy0Rwo+uFmQ6 uoZkQQz5sAR/0R3wl/AzC+VogVSbZ4DpvJAt2qNya+1mwhSKRCtr4XkPqWV+7c2uRMey jYo4M2P7qxVb4wRu1pGSlBsk8PkHX5i0OWsfO9fyNim9P2b9GGIXyp3C7RE5mt3GsoEG 6k33M0cbiP98Fb+Mf7u7xbydMVSnubf91d5SjDWVOE9spmIbKDolt8CGFlTpXuZvyVZl 2jRw== X-Gm-Message-State: ALoCoQlnm+AJFyNymx+8e05kSaiTkVFxCMi587bkiPfD48jGCvIbMcRtVegesHp5f7vR+PHo8jw01Dk9qSf6aSBPPRh1OPYvvQ== X-Received: by 10.25.136.193 with SMTP id k184mr2244921lfd.88.1449667176061; Wed, 09 Dec 2015 05:19:36 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id qp7sm1431624lbc.24.2015.12.09.05.19.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:19:35 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Grygorii Strashko , Toby Smith Subject: [PATCH 048/182] gpio: pca953x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:19:32 +0100 Message-Id: <1449667172-32024-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: Grygorii Strashko Cc: Markus Pargmann Cc: Toby Smith Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.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-pca953x.c b/drivers/gpio/gpio-pca953x.c index 2eaf235a39e5..deef862fc87a 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -107,11 +107,6 @@ struct pca953x_chip { unsigned long driver_data; }; -static inline struct pca953x_chip *to_pca(struct gpio_chip *gc) -{ - return container_of(gc, struct pca953x_chip, gpio_chip); -} - static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val, int off) { @@ -214,7 +209,7 @@ static int pca953x_read_regs(struct pca953x_chip *chip, int reg, u8 *val) static int pca953x_gpio_direction_input(struct gpio_chip *gc, unsigned off) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -243,7 +238,7 @@ exit: static int pca953x_gpio_direction_output(struct gpio_chip *gc, unsigned off, int val) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -293,7 +288,7 @@ exit: static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u32 reg_val; int ret, offset = 0; @@ -321,7 +316,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) { - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 reg_val; int ret, offset = 0; @@ -374,7 +369,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) static void pca953x_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); chip->irq_mask[d->hwirq / BANK_SZ] &= ~(1 << (d->hwirq % BANK_SZ)); } @@ -382,7 +377,7 @@ static void pca953x_irq_mask(struct irq_data *d) static void pca953x_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ); } @@ -390,7 +385,7 @@ static void pca953x_irq_unmask(struct irq_data *d) static void pca953x_irq_bus_lock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); mutex_lock(&chip->irq_lock); } @@ -398,7 +393,7 @@ static void pca953x_irq_bus_lock(struct irq_data *d) static void pca953x_irq_bus_sync_unlock(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 new_irqs; int level, i; @@ -421,7 +416,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d) static int pca953x_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct pca953x_chip *chip = to_pca(gc); + struct pca953x_chip *chip = gpiochip_get_data(gc); int bank_nb = d->hwirq / BANK_SZ; u8 mask = 1 << (d->hwirq % BANK_SZ); @@ -721,7 +716,7 @@ static int pca953x_probe(struct i2c_client *client, if (ret) return ret; - ret = gpiochip_add(&chip->gpio_chip); + ret = gpiochip_add_data(&chip->gpio_chip, chip); if (ret) return ret;