From patchwork Wed Dec 9 13:34:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58076 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp671946lbb; Wed, 9 Dec 2015 05:34:21 -0800 (PST) X-Received: by 10.66.100.163 with SMTP id ez3mr8033940pab.5.1449668061207; Wed, 09 Dec 2015 05:34:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nx14si12797123pab.69.2015.12.09.05.34.20; Wed, 09 Dec 2015 05:34:21 -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 S1754219AbbLINeU (ORCPT + 4 others); Wed, 9 Dec 2015 08:34:20 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:35715 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754193AbbLINeU (ORCPT ); Wed, 9 Dec 2015 08:34:20 -0500 Received: by lfdl133 with SMTP id l133so34157786lfd.2 for ; Wed, 09 Dec 2015 05:34: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=VoZFr/Z7/nUxdRerr9ilNqp3irU06FnQhD1c/+Z2zhs=; b=SbeHU4EL3PP6kch+VwY5qmB64a0xCWPaO7ZNoBFwrJeU5z2RcTjmVwZovDlue3S6yR BVCXA2Xr0O/Qv/hUroTuHOZ0b2FqNoMm56MSnm5BB8dQOPwR3Y49ao0aAR0xTyh0RKsd X+DcTsX0DmP8qLsea9JkUFlGfkV/0bBvHCSzr4xf7Gcx9ci/jospvnOTGOeIWYIFEGL2 slbDziMpiOK4i3CEOGGmNsAb5tuR6izjmIAImEjUXX00iwZMKeVHKdouU8IkOC35OfUW 6j/Ehtlywz8Y3cmqxP2qhzMcCiZidSQFEjue5m19ceLsuqW/QpOEKj/F4Trcsm2RKui5 sobQ== 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=VoZFr/Z7/nUxdRerr9ilNqp3irU06FnQhD1c/+Z2zhs=; b=R2whp5mA/+AQp1uFjXzNUy0TQrUCE+Ew50Ocl6rkXdVRVsWf2KrKzH1Jy3ljRMh6Tr a/DwhWVo26ugtFZrDTcAKQjhzbY+gOnrUU91CDzSDEW2zq2qdhGuiJQTD+8GU0GCD9Tl PY2aP2dknsGZVPtvytmGgOrNRbUHV338qcbpXbJwvgA5p8bnjCv5hGypivsp/4EQfQeP FcMmNHPUHrIrK4FhBwc9OsXjR1ekirS8Q08cHx54h+WxehLksd4S3KsvSMqY3iTzO/hG 9R/Y00jvgsCzKTN6H8/r85+3xZFr4aiJXx2uxiiyV+l6h9N9SW4Xb5aLnMDOLxJBjgtC jYUw== X-Gm-Message-State: ALoCoQlZgRCtwYlS+AN5KYmOrpXZvXXIBWeP07V4bo+sbZBDyZFzAjc6sigFkOiKi564y40slMElOJH9XZa0IzojZgDpnG9j+Q== X-Received: by 10.25.153.144 with SMTP id b138mr1869688lfe.167.1449668058627; Wed, 09 Dec 2015 05:34:18 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l67sm1440387lfl.26.2015.12.09.05.34.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:34:18 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Pramod Gurav , John Crispin Subject: [PATCH 120/182] pinctrl: xway: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:34:10 +0100 Message-Id: <1449668050-3485-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: Pramod Gurav Cc: John Crispin Signed-off-by: Linus Walleij --- This driver looks a bit weird: it is registering the gpiochip before the pin controller, yet depend on resolving the pin controller state from the gpiochip callbacks. This patch means no semantic change but please look to see if you can register the gpiochip after the pin controller instead, if you have time. --- drivers/pinctrl/pinctrl-xway.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 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/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index b4380fb72001..e92aa05a741b 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -648,7 +648,7 @@ static struct ltq_pinmux_info xway_info = { /* --------- gpio_chip related code --------- */ static void xway_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); + struct ltq_pinmux_info *info = gpiochip_get_data(chip); if (val) gpio_setbit(info->membase[0], GPIO_OUT(pin), PORT_PIN(pin)); @@ -658,14 +658,14 @@ static void xway_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) static int xway_gpio_get(struct gpio_chip *chip, unsigned int pin) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); + struct ltq_pinmux_info *info = gpiochip_get_data(chip); return gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin)); } static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); + struct ltq_pinmux_info *info = gpiochip_get_data(chip); gpio_clearbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); @@ -674,7 +674,7 @@ static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val) { - struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); + struct ltq_pinmux_info *info = gpiochip_get_data(chip); gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); xway_gpio_set(chip, pin, val); @@ -784,7 +784,7 @@ static int pinmux_xway_probe(struct platform_device *pdev) /* load the gpio chip */ xway_chip.parent = &pdev->dev; - ret = gpiochip_add(&xway_chip); + ret = gpiochip_add_data(&xway_chip, &xway_info); if (ret) { dev_err(&pdev->dev, "Failed to register gpio chip\n"); return ret;