From patchwork Wed Dec 9 13:49: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: 58127 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp680420lbb; Wed, 9 Dec 2015 05:49:45 -0800 (PST) X-Received: by 10.98.12.151 with SMTP id 23mr13038069pfm.60.1449668985784; Wed, 09 Dec 2015 05:49:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id af1si12828618pad.198.2015.12.09.05.49.45; Wed, 09 Dec 2015 05:49:45 -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 S1754777AbbLINtm (ORCPT + 4 others); Wed, 9 Dec 2015 08:49:42 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:34146 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754640AbbLINtk (ORCPT ); Wed, 9 Dec 2015 08:49:40 -0500 Received: by lffu14 with SMTP id u14so34652533lff.1 for ; Wed, 09 Dec 2015 05:49:39 -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=is/BJBQvTYyZNAuzudkHF5egC3leay3DmVAhUglktlw=; b=fVXO8i9S0T2Yq9BPH2zHZTZ3M0trtlA7pgq2qzxQicKvxVA4R9YwHYObSz2TJ3ZSCz HXBS8XjJqXNGUst+Aw2TopaVhcI4F429AUStP/ffTLNmX6IlroTfXrHR3BV+dnfnGrWo aWQ6tpcaBoc/9GDuNCjPr2C5H/rWnYP0dnNNmbz65kZUnohkIuT4qM4T0x37cEFjkIjO 7MB3YZUywGXgAA0R13qoCLjbdmEH8EZ1FcLLIfWWpmdGFEGc1UFrUHmdOtbNmEDtd4Ou SRHD3IfQG897XObwpJfIPWsl3PTnIIfi4FPwxOQLKYyyK0XO8M02xg3r3tkh4aWu6Bee caNQ== 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=is/BJBQvTYyZNAuzudkHF5egC3leay3DmVAhUglktlw=; b=FmE5f51atwIXW0g/NbCO0Yv7RsnwWhIZHmlwpmgvOg+ziqoug6nPEm8AsjzwB9z2XU HVLXbxqG7JW0ra2sfMG7VbZc0n6oFxNJlzsnFjuFr4tzH1LzA4onO82B/mnwNUQMCcz8 UYs/LLRjaKdEBfqUAGH3wLEbKKPR2twusNi5/lfkFu16r7PMEV5FUFcfQW2KtvX1RGV/ 7toYVIxjOWpZOJITwT1teuvfRtjelhvtTsgh7kP0nWreUCGsKpTilcZi/CMRpIZZoU6/ SSybI0iJZsBwQBIYV+gQSatbmPOUy3kYwXUR6zWq7/+E+nL9UYlIos+FnF135j+XwezV t/+Q== X-Gm-Message-State: ALoCoQkRjBKU6NlDgrwpfjyvWxwj9EhS6WruvSOTAlbRCAZQwTiyPD1SQdJh3sFsspRo0xUCijB4y4xssQOYadv/nYu1QPpnlQ== X-Received: by 10.25.168.140 with SMTP id r134mr2433559lfe.34.1449668979007; Wed, 09 Dec 2015 05:49:39 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id us1sm1422459lbc.25.2015.12.09.05.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:49:38 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Hauke Mehrtens , Michael Buesch Cc: Linus Walleij Subject: [PATCH 171/182] ssb: gpio_driver: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:49:35 +0100 Message-Id: <1449668975-6737-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: Hauke Mehrtens Cc: Michael Buesch Signed-off-by: Linus Walleij --- Micael please ACK this so I can take it through the GPIO tree. --- drivers/ssb/driver_gpio.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 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/ssb/driver_gpio.c b/drivers/ssb/driver_gpio.c index f92e266d48f8..180e027b1c8a 100644 --- a/drivers/ssb/driver_gpio.c +++ b/drivers/ssb/driver_gpio.c @@ -8,7 +8,7 @@ * Licensed under the GNU/GPL. See COPYING for details. */ -#include +#include #include #include #include @@ -22,15 +22,10 @@ * Shared **************************************************/ -static struct ssb_bus *ssb_gpio_get_bus(struct gpio_chip *chip) -{ - return container_of(chip, struct ssb_bus, gpio); -} - #if IS_ENABLED(CONFIG_SSB_EMBEDDED) static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); if (bus->bustype == SSB_BUSTYPE_SSB) return irq_find_mapping(bus->irq_domain, gpio); @@ -45,7 +40,7 @@ static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); return !!ssb_chipco_gpio_in(&bus->chipco, 1 << gpio); } @@ -53,7 +48,7 @@ static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio) static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0); } @@ -61,7 +56,7 @@ static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned gpio, static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 0); return 0; @@ -70,7 +65,7 @@ static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip, static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 1 << gpio); ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0); @@ -79,7 +74,7 @@ static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip, static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_chipco_gpio_control(&bus->chipco, 1 << gpio, 0); /* clear pulldown */ @@ -92,7 +87,7 @@ static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned gpio) static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); /* clear pullup */ ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0); @@ -246,7 +241,7 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus) if (err) return err; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, bus); if (err) { ssb_gpio_irq_chipco_domain_exit(bus); return err; @@ -263,7 +258,7 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus) static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); return !!ssb_extif_gpio_in(&bus->extif, 1 << gpio); } @@ -271,7 +266,7 @@ static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio) static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned gpio, int value) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0); } @@ -279,7 +274,7 @@ static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned gpio, static int ssb_gpio_extif_direction_input(struct gpio_chip *chip, unsigned gpio) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 0); return 0; @@ -288,7 +283,7 @@ static int ssb_gpio_extif_direction_input(struct gpio_chip *chip, static int ssb_gpio_extif_direction_output(struct gpio_chip *chip, unsigned gpio, int value) { - struct ssb_bus *bus = ssb_gpio_get_bus(chip); + struct ssb_bus *bus = gpiochip_get_data(chip); ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 1 << gpio); ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0); @@ -439,7 +434,7 @@ static int ssb_gpio_extif_init(struct ssb_bus *bus) if (err) return err; - err = gpiochip_add(chip); + err = gpiochip_add_data(chip, bus); if (err) { ssb_gpio_irq_extif_domain_exit(bus); return err;