From patchwork Wed Dec 9 13:16:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57985 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp661793lbb; Wed, 9 Dec 2015 05:17:06 -0800 (PST) X-Received: by 10.66.251.226 with SMTP id zn2mr7881237pac.44.1449667026201; Wed, 09 Dec 2015 05:17:06 -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.05; Wed, 09 Dec 2015 05:17:06 -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 S1753317AbbLINRF (ORCPT + 4 others); Wed, 9 Dec 2015 08:17:05 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:36030 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753592AbbLINRE (ORCPT ); Wed, 9 Dec 2015 08:17:04 -0500 Received: by lbblt2 with SMTP id lt2so29885389lbb.3 for ; Wed, 09 Dec 2015 05:17:02 -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=bXqC7GWHoEwZ3ggtD3mrqi5JBuiFzphjwZHJUgcFH+k=; b=KPadW8nYD0ZnDnGNAAc/CnWTbLVxf0vF4nk8L/xcvtfA4PuKWuArdQqk323snUDBbH ywsuIdJ8PLEgOTLmD1bh2nrvWs/b4C+NsF0lsRvVXDMs1Q73KltdlHf+f3z2uxiz/Lsk cMh+cQjb9g7dw0TIpWpnTp+V5mfRmFImLUKN3t/G4iHpdSqYtxouCZUwUfzINAKYc426 lGZdQcgwp4Hud0qquEtJIVH6n9ccU0r5KmK8BfJxfoKB/XNH38PZwOBWVYmQiukqTQig WDo1sjira6WdZ+MmAtZNFhFpcPgILi4JRHM5KFdNSP5qBmi86ijiTzO2SF+EzbAdSYdm Oslw== 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=bXqC7GWHoEwZ3ggtD3mrqi5JBuiFzphjwZHJUgcFH+k=; b=UHJoYEn6NLiznTyQcB9Z3ZnPNFWWYOOrNqZYmxpM93Q6+xPCfH4jl0PRbcRk0+SbIW oMr7c576GVcOtYDG6iwFCFAgX2mgivHvghNRghFTL8C0HL2JL0cKp2W/BDkOAMjazso+ eKeX07OERCRo0wco0Stju4GZPJfokcnsHNt8KVo54ef8RmQe+Z4pRrrQiHOwUxdjqWmk 48i8U02Z78Pp+nIHLqYtPwNvcLSOuBEFmnp/FfbWQxrLSOBhcV8yZ+S51UTBqEpPe857 /bm/Vi5oFpgDrayk90Jb1pBccpYYi5v12GLvghhAdyjaU3K9MDMRlU4v5eo8uw8TnXFq qm9Q== X-Gm-Message-State: ALoCoQkZSkKA/5GQ0cegqHJ1QyAWyfRXsgKI+QVch1cscX7eAO7c/nV/jzKSuhm8jr76a+Bm/JmNXde2CAFof34e/9h5WPziZA== X-Received: by 10.112.219.98 with SMTP id pn2mr2373625lbc.93.1449667022633; Wed, 09 Dec 2015 05:17:02 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m5sm1415911lfe.22.2015.12.09.05.17.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:17:02 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Joachim Eastwood Subject: [PATCH 030/182] gpio: lpc18xx: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:16:53 +0100 Message-Id: <1449667013-31170-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: Joachim Eastwood Signed-off-by: Linus Walleij --- Joachim: this driver looks very simplistic, it seems it can be totally replaced with drivers/gpio/gpio-generic.c provided that some (optional) clock handling is added to the generic GPIO driver, if you have some time, please look into that. --- drivers/gpio/gpio-lpc18xx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 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-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c index b01fbc9db7cd..98832c9f614a 100644 --- a/drivers/gpio/gpio-lpc18xx.c +++ b/drivers/gpio/gpio-lpc18xx.c @@ -31,27 +31,22 @@ struct lpc18xx_gpio_chip { spinlock_t lock; }; -static inline struct lpc18xx_gpio_chip *to_lpc18xx_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct lpc18xx_gpio_chip, gpio); -} - static void lpc18xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); writeb(value ? 1 : 0, gc->base + offset); } static int lpc18xx_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); return !!readb(gc->base + offset); } static int lpc18xx_gpio_direction(struct gpio_chip *chip, unsigned offset, bool out) { - struct lpc18xx_gpio_chip *gc = to_lpc18xx_gpio(chip); + struct lpc18xx_gpio_chip *gc = gpiochip_get_data(chip); unsigned long flags; u32 port, pin, dir; @@ -129,7 +124,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev) gc->gpio.parent = &pdev->dev; - ret = gpiochip_add(&gc->gpio); + ret = gpiochip_add_data(&gc->gpio, gc); if (ret) { dev_err(&pdev->dev, "failed to add gpio chip\n"); clk_disable_unprepare(gc->clk);