From patchwork Wed Dec 9 13:15:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 554490 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 A10F9140297 for ; Thu, 10 Dec 2015 00:15:40 +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=mwWSWsEC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753927AbbLINPk (ORCPT ); Wed, 9 Dec 2015 08:15:40 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:36861 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLINPj (ORCPT ); Wed, 9 Dec 2015 08:15:39 -0500 Received: by lfs39 with SMTP id 39so34123448lfs.3 for ; Wed, 09 Dec 2015 05:15:38 -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=KZnu6L5X/gmizEKpNwaktUUIs9PQMpkAB+mxTkAEPic=; b=mwWSWsECBcGo3DE/HZmHEQ5EtyQX2yyKSqxHh6w09PiZGxQgwyqdp6QCfPFrya3K/1 weVm++o1fs3ZL3zeDEtfFjmPvD5YlCs488TFb5/cSovb5jVDKWI8XXJpcYmjCWnJIGK7 g7TNxNQOgZMcZSuZO/bmgL/LgNBDtiFZfirNWBBkG4/9KDCjdSZfQG9FesK4RbCoovXB p80JGXeGwu1ibwFgKDK3stGabI8CIPG/QP5dDj87wvwIlvpCtniXVUCtuAXDoX5Mn5Jl 9TcncWAInWsIOnuC4xioziBu+6xV44Z/AUIWA11IFhIsNqP9RJEJBZpZ3u1422ZS3LM4 c11g== 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=KZnu6L5X/gmizEKpNwaktUUIs9PQMpkAB+mxTkAEPic=; b=CvPmAH6auz0FG0UhOu84mla3/kogEUZEQNH39gfXeRYt0pCa2X0ma00epdXQqnx96/ b1HmyaiMG2AV/UVLGuCN6Eg2X3A9kfpGuIzVCPZRAuLpQXWbATO4XrZ5SRPO9wyUZo81 yXcXQzbCzg9iV7+UoyOQjQt+st4Nqq8az4fosX32CG1cECXHt/EfE8rQ7ESPMWcJ4oTp 6GS1gCSDiWPES0QFqOlaFh37Jr/y0MFDgVCyvORjtVs8aSGO4/s5IOIngKdJCnq/YBCB hU4Ty+brhX7wJqY+4x9XF3/v0gOKofozTjXF3wxH7bweMQqAngymPYnkprBoqE+RhQev oOnQ== X-Gm-Message-State: ALoCoQn4PdWFtXcxaPP1fj1ToteURNLw8L1db+S/n2hMQQNxqfjv4vyU9tM/J6+srH+HaOZgrIzh2X6AhziHBs11NSxBkOAA+g== X-Received: by 10.25.208.11 with SMTP id h11mr2294096lfg.109.1449666938371; Wed, 09 Dec 2015 05:15:38 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m70sm1429262lfb.17.2015.12.09.05.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:15:37 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Ashish Jangam Subject: [PATCH 021/182] gpio: da9055: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:15:35 +0100 Message-Id: <1449666935-30737-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: Ashish Jangam Signed-off-by: Linus Walleij --- drivers/gpio/gpio-da9055.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-da9055.c b/drivers/gpio/gpio-da9055.c index 7227e6ed3cb9..18210fb2cb13 100644 --- a/drivers/gpio/gpio-da9055.c +++ b/drivers/gpio/gpio-da9055.c @@ -35,14 +35,9 @@ struct da9055_gpio { struct gpio_chip gp; }; -static inline struct da9055_gpio *to_da9055_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct da9055_gpio, gp); -} - static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); int gpio_direction = 0; int ret; @@ -71,7 +66,7 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); da9055_reg_update(gpio->da9055, DA9055_REG_GPIO_MODE0_2, @@ -81,7 +76,7 @@ static void da9055_gpio_set(struct gpio_chip *gc, unsigned offset, int value) static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); unsigned char reg_byte; reg_byte = (DA9055_ACT_LOW | DA9055_GPI) @@ -97,7 +92,7 @@ static int da9055_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int da9055_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); unsigned char reg_byte; int ret; @@ -119,7 +114,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc, static int da9055_gpio_to_irq(struct gpio_chip *gc, u32 offset) { - struct da9055_gpio *gpio = to_da9055_gpio(gc); + struct da9055_gpio *gpio = gpiochip_get_data(gc); struct da9055 *da9055 = gpio->da9055; return regmap_irq_get_virq(da9055->irq_data, @@ -156,7 +151,7 @@ static int da9055_gpio_probe(struct platform_device *pdev) if (pdata && pdata->gpio_base) gpio->gp.base = pdata->gpio_base; - ret = gpiochip_add(&gpio->gp); + ret = gpiochip_add_data(&gpio->gp, gpio); if (ret < 0) { dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); goto err_mem;