From patchwork Wed Dec 9 13:33:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58072 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp671573lbb; Wed, 9 Dec 2015 05:33:47 -0800 (PST) X-Received: by 10.66.178.225 with SMTP id db1mr7909082pac.46.1449668027434; Wed, 09 Dec 2015 05:33:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 81si12819810pfr.79.2015.12.09.05.33.47; Wed, 09 Dec 2015 05:33:47 -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 S1754525AbbLINdq (ORCPT + 4 others); Wed, 9 Dec 2015 08:33:46 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:34646 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754451AbbLINdp (ORCPT ); Wed, 9 Dec 2015 08:33:45 -0500 Received: by lffu14 with SMTP id u14so34340520lff.1 for ; Wed, 09 Dec 2015 05:33:44 -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=pYp9VPdV8x9WbU+lomKyXc4zoBFBqWdQ51Sy7ODdTDQ=; b=16mL9YU434nZ6FSDfLftH1HpWhK1AE2bncg/LxYXoM8XiBdFP9sD25w7Xfwjsp4Nul md96n+EEs5oushZA+9sUROo1DEC6OCZ1UJGX2/vN7iqbIgZq70VnaOCr+iIg4PkzAyd/ rXDkaYYpkMQ+kQutQ7lg8j2ljelxu+Ebptg2bRWoHT6mnttX4d3UxZ+sRj328OeL8Zmc GxRlL2t5h5mqdqW7cwZrR6e20PXvFHhp/PoL+DtG1H36HWrthvDG5IQJGL0BBURCNz8r 5APwAAx6cLUlGVnKqhQccJAFwJg5YA4P36D2TrZmgZYasVRaBnfDVNbWosds1p7bJwiC 2fnw== 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=pYp9VPdV8x9WbU+lomKyXc4zoBFBqWdQ51Sy7ODdTDQ=; b=lNqn8CeWzW58Fz04dlWXBvicbgj/85TavNfB6ESS8qt4STCX27+1jdAF6FapTICvN6 d34COuEHZ8yKhfwkDxrZCE/Kw1Ndg2mogvKOEyneEs612n8cYoR/KJZ4CF9UuQCHlWXR sYxr9RC60EutiUPiIrg+z5thj8Fkm5UJcu4P/NBt/yd7/+741ns21gUYD5mHPTBp8+60 SBAYx+gBXTmufinknmVDxDrXgzFlG12pNjpqcT0PYlgb/uuTSlDYLiC4ZMIqbS88+gPh 8ell7bY2rORjIFknJMTplaldzaz18zFmAPy1uNv0Pv6jjHxWODc7Y+H8bw5HCgjswuxY H4yQ== X-Gm-Message-State: ALoCoQmFzVfm2Y04YY2iO0+bNmI7HR6HxxBfsW823XjFYl/pBrUU/xr+1MWFB/uDDcFnaxJ2Y7qZ9l8+rSKsdycVuBvFtV1Fgw== X-Received: by 10.25.91.11 with SMTP id p11mr2270378lfb.35.1449668024331; Wed, 09 Dec 2015 05:33:44 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m5sm1427443lfe.22.2015.12.09.05.33.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:33:43 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Barry Song Subject: [PATCH 116/182] pinctrl: sirf: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:33:41 +0100 Message-Id: <1449668021-3293-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: Barry Song Signed-off-by: Linus Walleij --- drivers/pinctrl/sirf/pinctrl-sirf.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 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/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index ae97bdc75a69..aa87fa90b884 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -399,11 +399,6 @@ static int __init sirfsoc_pinmux_init(void) } arch_initcall(sirfsoc_pinmux_init); -static inline struct sirfsoc_gpio_chip *to_sirfsoc_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct sirfsoc_gpio_chip, chip.gc); -} - static inline struct sirfsoc_gpio_bank * sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) { @@ -418,7 +413,7 @@ static inline int sirfsoc_gpio_to_bankoff(unsigned int offset) static void sirfsoc_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -457,7 +452,7 @@ static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, static void sirfsoc_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); @@ -466,7 +461,7 @@ static void sirfsoc_gpio_irq_mask(struct irq_data *d) static void sirfsoc_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -487,7 +482,7 @@ static void sirfsoc_gpio_irq_unmask(struct irq_data *d) static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); int idx = sirfsoc_gpio_to_bankoff(d->hwirq); u32 val, offset; @@ -549,7 +544,7 @@ static void sirfsoc_gpio_handle_irq(struct irq_desc *desc) { unsigned int irq = irq_desc_get_irq(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(gc); struct sirfsoc_gpio_bank *bank; u32 status, ctrl; int idx = 0; @@ -607,7 +602,7 @@ static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -630,7 +625,7 @@ static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); unsigned long flags; @@ -646,7 +641,7 @@ static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset) static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); unsigned long flags; @@ -689,7 +684,7 @@ static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_chip *sgpio, static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); int idx = sirfsoc_gpio_to_bankoff(gpio); u32 offset; @@ -708,7 +703,7 @@ static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 val; unsigned long flags; @@ -725,7 +720,7 @@ static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset) static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { - struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); + struct sirfsoc_gpio_chip *sgpio = gpiochip_get_data(chip); struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); u32 ctrl; unsigned long flags; @@ -814,7 +809,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) sgpio->chip.gc.parent = &pdev->dev; sgpio->chip.regs = regs; - err = gpiochip_add(&sgpio->chip.gc); + err = gpiochip_add_data(&sgpio->chip.gc, sgpio); if (err) { dev_err(&pdev->dev, "%s: error in probe function with status %d\n", np->full_name, err);