From patchwork Wed Dec 9 13:17:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57987 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp661948lbb; Wed, 9 Dec 2015 05:17:20 -0800 (PST) X-Received: by 10.98.42.209 with SMTP id q200mr12920639pfq.1.1449667040623; Wed, 09 Dec 2015 05:17:20 -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.17.20; Wed, 09 Dec 2015 05:17:20 -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 S1753900AbbLINRU (ORCPT + 4 others); Wed, 9 Dec 2015 08:17:20 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:36148 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753598AbbLINRT (ORCPT ); Wed, 9 Dec 2015 08:17:19 -0500 Received: by lbblt2 with SMTP id lt2so29889758lbb.3 for ; Wed, 09 Dec 2015 05:17:18 -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=BP7ZJpwODLXe65g7on1FuSRZXiUXVwhY2uFU13Ge0Fk=; b=Thbg/n+ln1Mlb/eX0gKjVaPzRgKN2SYwc8enEtuHcUCbmEh2JfYCi1O7DLNw3+Hg9N bOOVZE7q6QiyW0IsO8dUnsK+1VII1sPKXBrNkWUzS6cVTxPGAZexrw5NrvGDVBAsS7jq JBSW2HVmvWBlaVDADNTKzU7yaH+P2/VBCWmmwAUaLoUWCSLG7Ci3DJ86j2l5T98SXbun 7fhqUdTBm7U5xlX266bzp7UkCewRNkRWigjMebS15eKgDw8qs9JfmRfAB79/AcLbAQub Uz/Ke+D9LIWEo+67EhPQMvpEDq1+9rksEdd62ZR5cPjoJRjUtyWPKPMuIRFDHW1RR5yB m1ow== 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=BP7ZJpwODLXe65g7on1FuSRZXiUXVwhY2uFU13Ge0Fk=; b=Oq8DZDWwxFYWeVUTBTyZxu6B3mjWZSuUoTUKQRnKlgLuIvFit0z90Tb4Z1U90PSqJg UODXtMOFR/XxVWvxiAnARGccbvtXw+N19pRciymn0zQbHmb2wEEw60EeC/IYq5/NTGve zO+H24tKBOX/W1YJSh9ITRaKv2s2kBoAO1DdDXmFsAMs4Yqed3+dIU1DYo2qneObQy2E D3J8YuUwRAYFkYlq3OCaVhIQX5x4yXwQiREiZP8R0Hc+MbzOidEuMrT68C1Xlrmhlko2 +JsdmvNwviYBJpRyZ9ECuce8gJ6bQSz29sG+5Egp8omIOnwkcwYZTwNIn8+lemj+uW/w Ti/Q== X-Gm-Message-State: ALoCoQkIJjnAdGEvlRDLPiACtOdT1YMCZLa4AY7la/iAOHPKxLzy3hh159MlTjAoARCoX8p3FzyiTD8TCsFrH9FureFmZVAD+g== X-Received: by 10.112.184.45 with SMTP id er13mr2261742lbc.133.1449667038018; Wed, 09 Dec 2015 05:17:18 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l81sm1422245lfb.40.2015.12.09.05.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:17:17 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Mathias Nyman , Mika Westerberg Subject: [PATCH 032/182] gpio: lynxpoint: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:17:13 +0100 Message-Id: <1449667033-31266-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: Mathias Nyman Cc: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lynxpoint.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 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-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 6a48ffd6e0db..13107772be4f 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c @@ -97,7 +97,7 @@ struct lp_gpio { static unsigned long lp_gpio_reg(struct gpio_chip *chip, unsigned offset, int reg) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); int reg_offset; if (reg == LP_CONFIG1 || reg == LP_CONFIG2) @@ -112,7 +112,7 @@ static unsigned long lp_gpio_reg(struct gpio_chip *chip, unsigned offset, static int lp_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2); unsigned long acpi_use = lp_gpio_reg(chip, offset, LP_ACPI_OWNED); @@ -137,7 +137,7 @@ static int lp_gpio_request(struct gpio_chip *chip, unsigned offset) static void lp_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2); /* disable input sensing */ @@ -149,7 +149,7 @@ static void lp_gpio_free(struct gpio_chip *chip, unsigned offset) static int lp_irq_type(struct irq_data *d, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long flags; u32 value; @@ -191,7 +191,7 @@ static int lp_gpio_get(struct gpio_chip *chip, unsigned offset) static void lp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -207,7 +207,7 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -221,7 +221,7 @@ static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int lp_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct lp_gpio *lg = container_of(chip, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(chip); unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1); unsigned long flags; @@ -238,7 +238,7 @@ static void lp_gpio_irq_handler(struct irq_desc *desc) { struct irq_data *data = irq_desc_get_irq_data(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); struct irq_chip *chip = irq_data_get_irq_chip(data); u32 base, pin, mask; unsigned long reg, ena, pending; @@ -273,7 +273,7 @@ static void lp_irq_mask(struct irq_data *d) static void lp_irq_enable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE); unsigned long flags; @@ -286,7 +286,7 @@ static void lp_irq_enable(struct irq_data *d) static void lp_irq_disable(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct lp_gpio *lg = container_of(gc, struct lp_gpio, chip); + struct lp_gpio *lg = gpiochip_get_data(gc); u32 hwirq = irqd_to_hwirq(d); unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE); unsigned long flags; @@ -370,7 +370,7 @@ static int lp_gpio_probe(struct platform_device *pdev) gc->can_sleep = false; gc->parent = dev; - ret = gpiochip_add(gc); + ret = gpiochip_add_data(gc, lg); if (ret) { dev_err(dev, "failed adding lp-gpio chip\n"); return ret;