From patchwork Wed Dec 9 13:32:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58062 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp670796lbb; Wed, 9 Dec 2015 05:32:32 -0800 (PST) X-Received: by 10.98.7.129 with SMTP id 1mr13056842pfh.70.1449667951976; Wed, 09 Dec 2015 05:32:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si12793619pfj.115.2015.12.09.05.32.31; Wed, 09 Dec 2015 05:32:31 -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 S1754201AbbLINcb (ORCPT + 4 others); Wed, 9 Dec 2015 08:32:31 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:36756 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754153AbbLINca (ORCPT ); Wed, 9 Dec 2015 08:32:30 -0500 Received: by lfs39 with SMTP id 39so34452112lfs.3 for ; Wed, 09 Dec 2015 05:32:29 -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=bT6ePl4cGtwFSAfxRKwmk3BXmjZGnIbx93fjFZLZ3v4=; b=W0xqFPCOueU97DvNnw6vT/jPar2ciPe9CBFDnTkmVtbgygLWKhv6yy2I7WzaGTZdI4 NUX7YDofpebQrx6YkMxFUFfnI6xtVjnHsQZ965uHgmq10ytf33xl6nJWiU8hMENpWnGt pH0/70yBTVgJ0ZS5da1/7UkuTHtj7bVgNhQqZIu41ywtjp6SYuQXcyknTfUPNv/KxI/z GVLRegvENhlPjuOiccUSfQQ73A8oERiP69+9lZDKbggExmcow81s5qqJHvs5QTBaGPss 6QfWMUHTX69HCLIsqkCDc/UjQiGHuUQ6O+1Z2NOtjk1XJyboF+N31xC44AYZYwYZoqQT tbhQ== 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=bT6ePl4cGtwFSAfxRKwmk3BXmjZGnIbx93fjFZLZ3v4=; b=SIq25siVsIQs/nxDOesBFT8eIrDXb8Wx4XNTZIrdtP+Nvhqd8sCOwTANMMR+Fdpwod cMSxyjdgQ8xUsQVZxbzYFIOxBPN2BX5MSjI5kN01zUNH9zYx83xizI86XQ5KUsyveM+Z 4lbg4axyqbjobLXgkbxMnDK1vR3som6396suHaQ+lAuW5/v1Pzr5WJanAJWfbOzRJcOx /DcTK/kWlN6dxQSOcleaxfLagqyqGWMtqa/XSM1dh+1vx9R0ZQm00aLT4lfNGKNmI1bX HdJawR525fzzglL7PXRxpu7QY7PhE5j1+qD/S+byjLz0737hyiUjhq4HCozuQArghZ8+ wCAQ== X-Gm-Message-State: ALoCoQlySbeLOTpg5VfPd2fVq06nD/plrIUHPY4IYmwfkqGaOo+ilOPoquf0ChFpuIYYl0Av/4Vk0vByGNuyiemG1u8XQ2o5Xw== X-Received: by 10.25.1.205 with SMTP id 196mr1857270lfb.21.1449667949243; Wed, 09 Dec 2015 05:32:29 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id g7sm1407392lbs.34.2015.12.09.05.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:32:28 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard Subject: [PATCH 106/182] pinctrl: st: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:32:26 +0100 Message-Id: <1449667946-2800-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: Srinivas Kandagatla Cc: Maxime Coquelin Cc: Patrice Chotard Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 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 Acked-by: Maxime Coquelin diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 52639e65ea67..fac844a85cb4 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -203,9 +203,6 @@ #define gpio_range_to_bank(chip) \ container_of(chip, struct st_gpio_bank, range) -#define gpio_chip_to_bank(chip) \ - container_of(chip, struct st_gpio_bank, gpio_chip) - #define pc_to_bank(pc) \ container_of(pc, struct st_gpio_bank, pc) @@ -744,14 +741,14 @@ static void st_gpio_direction(struct st_gpio_bank *bank, static int st_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset)); } static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); __st_gpio_set(bank, offset, value); } @@ -765,7 +762,7 @@ static int st_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int st_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); __st_gpio_set(bank, offset, value); pinctrl_gpio_direction_output(chip->base + offset); @@ -775,7 +772,7 @@ static int st_gpio_direction_output(struct gpio_chip *chip, static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct st_gpio_bank *bank = gpio_chip_to_bank(chip); + struct st_gpio_bank *bank = gpiochip_get_data(chip); struct st_pio_control pc = bank->pc; unsigned long config; unsigned int direction = 0; @@ -1325,7 +1322,7 @@ static int st_pctl_parse_functions(struct device_node *np, static void st_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); } @@ -1333,7 +1330,7 @@ static void st_gpio_irq_mask(struct irq_data *d) static void st_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); } @@ -1341,7 +1338,7 @@ static void st_gpio_irq_unmask(struct irq_data *d) static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); unsigned long flags; int comp, pin = d->hwirq; u32 val; @@ -1455,7 +1452,7 @@ static void st_gpio_irq_handler(struct irq_desc *desc) /* interrupt dedicated per bank */ struct irq_chip *chip = irq_desc_get_chip(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct st_gpio_bank *bank = gpio_chip_to_bank(gc); + struct st_gpio_bank *bank = gpiochip_get_data(gc); chained_irq_enter(chip, desc); __gpio_irq_handler(bank); @@ -1532,7 +1529,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK; range->npins = bank->gpio_chip.ngpio; range->gc = &bank->gpio_chip; - err = gpiochip_add(&bank->gpio_chip); + err = gpiochip_add_data(&bank->gpio_chip, bank); if (err) { dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); return err;