From patchwork Wed Dec 9 13:14:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57967 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp660136lbb; Wed, 9 Dec 2015 05:14:29 -0800 (PST) X-Received: by 10.98.67.68 with SMTP id q65mr12717349pfa.63.1449666869080; Wed, 09 Dec 2015 05:14:29 -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.14.28; Wed, 09 Dec 2015 05:14:29 -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 S1754104AbbLINO2 (ORCPT + 4 others); Wed, 9 Dec 2015 08:14:28 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:34045 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbbLINO1 (ORCPT ); Wed, 9 Dec 2015 08:14:27 -0500 Received: by lbbcs9 with SMTP id cs9so29655435lbb.1 for ; Wed, 09 Dec 2015 05:14:26 -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=gbjrZt0gPqI/EMbxM+nKHtkcv/kq8/AUpqxhTGMXp/U=; b=MsTNNPOqV60RMcVOFYId5dgPlSCL7OtPoTBdLsovlsdvMZmXaFRVuS6wlvRThbEbwd HAhG5rTIOn1Yu6iNAchBgVbbcDyZbfe6uhvMj89ahcq3x9FmXbkkpzepLCwoTdotwr/f 651lwEofLVhs7V3ckwmzqFwCIBPE7n927IwGBVSj07Dc3r0rrlFVMmER1xR3NjN3n6MS fHDo+ARpB3tUaJicALqxguEKhoIsQhk2sXjpE4LuFTeqerSfvlasa8GXEfisK18NKYZD hCCN49O//p53Niz/Xg5veZ03oFOVlhddZDxy15IOouVatBQJmO+mrSRRhySn+DK6P3r/ hbJA== 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=gbjrZt0gPqI/EMbxM+nKHtkcv/kq8/AUpqxhTGMXp/U=; b=SPGegXT26652HsZSJsHP8pXg2MGcl9F1UC8kYx2N6ooopQKpI8bd7KGc39q6Erb43j h2NnrsCjG6g4J1Ffm+5Fwk+ZBaoBpCx25yBVlWHISlCE/8pFiNf9JDPoxUd1exVPZwcy whTXzfeKwyC6X4NFKTMAtBbxHT2Q0kNnGNUmgKCoUEman5rWun2UyQDrpgIpLSMiMZ45 T6ceCbqgKxoyBL4iT6fg+GtAIhy/PhQKZupWVLdYk/GFyfT6/evfEVqoKMz4RdZU1LUd lAeidjJ3RWEkKVQ9RWsbTpj4KXOS8IiOk9vjxZwTa/fgIYqgC3Y2sBZ2zpKXAMxN6jA9 EGYg== X-Gm-Message-State: ALoCoQln6xaCJsh8qfPLKV1dRLk44+IVIbzFtbMhGLcW5+PPBFLX1JehS/hFcqf3IpFyIl2IElyXxal0uHWRMcJNs15Xlb/7qQ== X-Received: by 10.112.199.194 with SMTP id jm2mr1896889lbc.109.1449666866563; Wed, 09 Dec 2015 05:14:26 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id w7sm1421592lbb.14.2015.12.09.05.14.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:14:25 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Dmitry Eremin-Solenikov Subject: [PATCH 012/182] gpio: amd8111: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:14:21 +0100 Message-Id: <1449666861-30310-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: Dmitry Eremin-Solenikov Signed-off-by: Linus Walleij --- drivers/gpio/gpio-amd8111.c | 16 +++++++--------- 1 file changed, 7 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-amd8111.c b/drivers/gpio/gpio-amd8111.c index 5c378e9f53a0..c7040fffc5b4 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -75,11 +75,9 @@ struct amd_gpio { u8 orig[32]; }; -#define to_agp(chip) container_of(chip, struct amd_gpio, chip) - static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); agp->orig[offset] = ioread8(agp->pm + AMD_REG_GPIO(offset)) & (AMD_GPIO_DEBOUNCE | AMD_GPIO_MODE_MASK | AMD_GPIO_X_MASK); @@ -91,7 +89,7 @@ static int amd_gpio_request(struct gpio_chip *chip, unsigned offset) static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); dev_dbg(&agp->pdev->dev, "Freed gpio %d, data %x\n", offset, agp->orig[offset]); @@ -100,7 +98,7 @@ static void amd_gpio_free(struct gpio_chip *chip, unsigned offset) static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -115,7 +113,7 @@ static void amd_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; temp = ioread8(agp->pm + AMD_REG_GPIO(offset)); @@ -127,7 +125,7 @@ static int amd_gpio_get(struct gpio_chip *chip, unsigned offset) static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -144,7 +142,7 @@ static int amd_gpio_dirout(struct gpio_chip *chip, unsigned offset, int value) static int amd_gpio_dirin(struct gpio_chip *chip, unsigned offset) { - struct amd_gpio *agp = to_agp(chip); + struct amd_gpio *agp = gpiochip_get_data(chip); u8 temp; unsigned long flags; @@ -225,7 +223,7 @@ found: spin_lock_init(&gp.lock); printk(KERN_INFO "AMD-8111 GPIO detected\n"); - err = gpiochip_add(&gp.chip); + err = gpiochip_add_data(&gp.chip, &gp); if (err) { printk(KERN_ERR "GPIO registering failed (%d)\n", err);