From patchwork Wed Dec 9 13:23:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 554539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 27AD1140291 for ; Thu, 10 Dec 2015 00:23:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro-org.20150623.gappssmtp.com header.i=@linaro-org.20150623.gappssmtp.com header.b=mg+im6/A; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900AbbLINXf (ORCPT ); Wed, 9 Dec 2015 08:23:35 -0500 Received: from mail-lb0-f170.google.com ([209.85.217.170]:34289 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753331AbbLINXf (ORCPT ); Wed, 9 Dec 2015 08:23:35 -0500 Received: by lbbcs9 with SMTP id cs9so29809486lbb.1 for ; Wed, 09 Dec 2015 05:23:33 -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=sx4bX4sOwUhQi+Mmbzm/eEk2eNT84p4ip3jvoiG7K78=; b=mg+im6/ANfuaul4vL43fYrVjRYv3MMqOOm32T6Q6ci0jbjMp63NBxdsmlaSWNW4FzA 1ic5A3nLeTgeLYEvnPFFXZ0ZuCkzUmMkBcfWzOIqElP3YgpmsZRYS7GpzYd/TZIeH5wz UkC7vQcmJNzmICNY18KeMTbZEdLU0F0SbymvKI8/9UYEMWHbfmxD6Y9q5DNxMoGpdf8u 9cPBLx/rvPD7QPx5vhBSD6+AJ6+9TY8eMZpyPkKcnElzAWPpNNJDhSMIPMeZ2A1/UwE+ dLAiGeRwB5/bgC0MtYT/3yTb5H5WNWvkPih4UmgN6nE/EfoslZA28E3/MKeGxfPKOzyC qdsw== 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=sx4bX4sOwUhQi+Mmbzm/eEk2eNT84p4ip3jvoiG7K78=; b=M0JdXEs9L3POvSZ2uzcZRHBddURT4xtoI5xs0o6w3uwxsWkYjK4ZcQvG9d7czk3FxY AXVcq7bZW3blJIxsay76nBt2TCQvbtsaSYpaLGGyU5JyuXRXa6v4nVERXiUmTMn3aKUO gq7oe0gyGsHuvM82FpbgnV2ieBXY7gmQFQJuLHjmWv+7ikNEEgpfyQtdP7fg3M4wxoIX 89ETsIKlWGc4WPOA6eOtwEgskkKZOnheyZzstURzzlqrUUo4J2F4bm1DxMxxAeVVSOoC Zi8B1AO/BE2Req4CSknHwME6NV9HYDdpSp51Or3qp0UBFgC7hyVgQgQxqir4t8EzruVx Lfhg== X-Gm-Message-State: ALoCoQnJduSU5PwGw7eYWJd55xnm+mp0tmKVljtdD53cEN9qHEMPjSbqySVN5c+R1zRJ0kDadmEgD6ak3iHU4XZjBvgEQ8HbOw== X-Received: by 10.112.198.69 with SMTP id ja5mr2307570lbc.121.1449667413689; Wed, 09 Dec 2015 05:23:33 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b7sm1430126lbv.0.2015.12.09.05.23.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:23:32 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Christian Ruppert Subject: [PATCH 065/182] gpio: tb10x: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:23:30 +0100 Message-Id: <1449667410-418-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: Christian Ruppert Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tb10x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 1a7c3efae5d8..5eaec20ddbc7 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c @@ -87,14 +87,9 @@ static inline void tb10x_set_bits(struct tb10x_gpio *gpio, unsigned int offs, spin_unlock_irqrestore(&gpio->spinlock, flags); } -static inline struct tb10x_gpio *to_tb10x_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct tb10x_gpio, gc); -} - static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = TB10X_GPIO_DIR_IN << offset; @@ -105,7 +100,7 @@ static int tb10x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int val; val = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_DATA); @@ -118,7 +113,7 @@ static int tb10x_gpio_get(struct gpio_chip *chip, unsigned offset) static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = value << offset; @@ -128,7 +123,7 @@ static void tb10x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int tb10x_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); int mask = BIT(offset); int val = TB10X_GPIO_DIR_OUT << offset; @@ -140,7 +135,7 @@ static int tb10x_gpio_direction_out(struct gpio_chip *chip, static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) { - struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); + struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip); return irq_create_mapping(tb10x_gpio->domain, offset); } @@ -210,7 +205,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) tb10x_gpio->gc.can_sleep = false; - ret = gpiochip_add(&tb10x_gpio->gc); + ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not add gpiochip.\n"); goto fail_gpiochip_registration;