From patchwork Wed Apr 27 13:14:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1195 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:50:04 -0000 Delivered-To: patches@linaro.org Received: by 10.224.2.73 with SMTP id 9cs108498qai; Wed, 27 Apr 2011 06:14:50 -0700 (PDT) Received: by 10.213.31.69 with SMTP id x5mr2450971ebc.91.1303910089378; Wed, 27 Apr 2011 06:14:49 -0700 (PDT) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com [207.126.144.139]) by mx.google.com with SMTP id y52si2708616eei.10.2011.04.27.06.14.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Apr 2011 06:14:49 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKTbgWuLvlo80o9fnQQztpZp0joZJZNBB1@postini.com; Wed, 27 Apr 2011 13:14:49 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 552D63C; Wed, 27 Apr 2011 13:14:31 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id AD66A6B; Wed, 27 Apr 2011 13:14:30 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 43BC124C303; Wed, 27 Apr 2011 15:14:23 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.2.254.0; Wed, 27 Apr 2011 15:14:30 +0200 From: Linus Walleij To: Grant Likely , , Cc: Lee Jones , Linus Walleij Subject: [PATCH 09/10] gpio/nomadik-gpio: factor out state cast function Date: Wed, 27 Apr 2011 15:14:27 +0200 Message-ID: <1303910067-3571-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Linus Walleij This factors out the container_of() magic to dereference the state struct from the gpio_chip into an inline function and adds a dummy config function. Signed-off-by: Linus Walleij --- drivers/gpio/nomadik-gpio.c | 34 ++++++++++++++++++++++------------ include/linux/gpio/nomadik.h | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/nomadik-gpio.c b/drivers/gpio/nomadik-gpio.c index b30b6a2..b8d5bae 100644 --- a/drivers/gpio/nomadik-gpio.c +++ b/drivers/gpio/nomadik-gpio.c @@ -67,6 +67,14 @@ static DEFINE_SPINLOCK(nmk_gpio_slpm_lock); #define NUM_BANKS ARRAY_SIZE(nmk_gpio_chips) +static inline struct nmk_gpio_chip *to_nmk_chip(struct gpio_chip *chip) +{ + struct nmk_gpio_chip *nmk_chip = + container_of(chip, struct nmk_gpio_chip, chip); + + return nmk_chip; +} + static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, unsigned offset, int gpio_mode) { @@ -512,6 +520,13 @@ int nmk_gpio_get_mode(int gpio) } EXPORT_SYMBOL(nmk_gpio_get_mode); +static int nmk_gpio_config(struct gpio_chip *chip, unsigned offset, + u16 param, unsigned long *data) +{ + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); + + return 0; +} /* IRQ functions */ static inline int nmk_gpio_get_bitmask(int gpio) @@ -804,8 +819,7 @@ static int nmk_gpio_init_irq(struct nmk_gpio_chip *nmk_chip) /* I/O Functions */ static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); clk_enable(nmk_chip->clk); @@ -818,8 +832,7 @@ static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); u32 bit = 1 << offset; int value; @@ -835,8 +848,7 @@ static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, int val) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); clk_enable(nmk_chip->clk); @@ -848,8 +860,7 @@ static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, int val) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); clk_enable(nmk_chip->clk); @@ -862,8 +873,7 @@ static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); return NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base) + offset; } @@ -878,8 +888,7 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) unsigned i; unsigned gpio = chip->base; int is_out; - struct nmk_gpio_chip *nmk_chip = - container_of(chip, struct nmk_gpio_chip, chip); + struct nmk_gpio_chip *nmk_chip = to_nmk_chip(chip); const char *modes[] = { [NMK_GPIO_ALT_GPIO] = "gpio", [NMK_GPIO_ALT_A] = "altA", @@ -947,6 +956,7 @@ static struct gpio_chip nmk_gpio_template = { .get = nmk_gpio_get_input, .direction_output = nmk_gpio_make_output, .set = nmk_gpio_set_output, + .config = nmk_gpio_config, .to_irq = nmk_gpio_to_irq, .dbg_show = nmk_gpio_dbg_show, .can_sleep = 0, diff --git a/include/linux/gpio/nomadik.h b/include/linux/gpio/nomadik.h index cc956d1..c16ee56 100644 --- a/include/linux/gpio/nomadik.h +++ b/include/linux/gpio/nomadik.h @@ -12,6 +12,8 @@ #ifndef __GPIO_NOMADIK_H #define __GPIO_NOMADIK_H +#include + /* * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving * the "gpio" namespace for generic and cross-machine functions