From patchwork Wed Dec 9 13:14:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57966 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp660050lbb; Wed, 9 Dec 2015 05:14:20 -0800 (PST) X-Received: by 10.66.121.4 with SMTP id lg4mr7801457pab.22.1449666860311; Wed, 09 Dec 2015 05:14:20 -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.19; Wed, 09 Dec 2015 05:14:20 -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 S1753145AbbLINOT (ORCPT + 4 others); Wed, 9 Dec 2015 08:14:19 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33973 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754104AbbLINOS (ORCPT ); Wed, 9 Dec 2015 08:14:18 -0500 Received: by lbbcs9 with SMTP id cs9so29652778lbb.1 for ; Wed, 09 Dec 2015 05:14:17 -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=1tNOlH015E1Bn9b7HescWGZPXJF9vTLJqw1AEcUpIfY=; b=dZivJLCgrIVp0pJSdBMFCICbJd/4c6df5HipjU7covtEQythZGhnsUnsY2gDUJ1Yix 2lnjSFDNuL/5L5uYpV0fRGr6xhUgbR/j0VCsYNHCAK7LDZv3r8Pbj7bEEUk/KO/eZX0y s8ToCrVNh2TlgwDa+Deb6zflywa0mCVte9fiutu7J83lMlACk0YB8IYNBU5vH6isi0QX tmrdTZSkDX1s30eek3EoeHISvJ0fExLa8MaUDoB7K7baj+/a7PKRCHUuWsvcWLqjB6XS X55h5i8PO0pTQSNCupDaohALCGqK4/QmJ5j7sBpyxTSIUk1hRxXwhx8PupGpfCuJNQKj xQKQ== 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=1tNOlH015E1Bn9b7HescWGZPXJF9vTLJqw1AEcUpIfY=; b=fpythEo5Uiqhs0fAQqjTZEZ/vlIEs7uFr2bviCZ/mJ3lu0ZQ7RFRvrnFMEpg6Yr9rq iwB1if4oodIjuA+h8WBMP3lfM/N+/6XM4EFH0qwSXFC1kECeG3Z1oewm92m2C9y/TZ09 TcpCw7rD225Eu0yAHx1iGJ1lXmClaD0riP5fxzPu9Q45NwSinekqu/+5ntbXH3ceWr2G koMdjBSXqqyfi9wUPIHtrGkiKt/3VMrrN/tBsQ07+KP/oSnIXnl69bZi/gsUq2TYGT9t PWnuf5JJbuoZ52WEA/ZirUarffPWKX789sEJtMlMgpHEF3aAvhXBVK5ClvzbNVpfi11j jH6A== X-Gm-Message-State: ALoCoQl6aEEfZhdD3+l+kS5VRx1Pf+fTfvyGkT5HNc9AEbIUCK9S2mgDLt9nMLTPMnjT2dbOWbuB2FcW4/SiXP1q2VheQp9iaA== X-Received: by 10.112.140.166 with SMTP id rh6mr1310512lbb.77.1449666857398; Wed, 09 Dec 2015 05:14:17 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 93sm1451641lfx.1.2015.12.09.05.14.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:14:15 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Tien Hock Loh Subject: [PATCH 011/182] gpio: altera: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:14:11 +0100 Message-Id: <1449666851-30263-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: Tien Hock Loh Signed-off-by: Linus Walleij --- drivers/gpio/gpio-altera.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 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-altera.c b/drivers/gpio/gpio-altera.c index 84a20af01a9a..2aeaebd1c6e7 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -42,11 +42,6 @@ struct altera_gpio_chip { int mapped_irq; }; -static struct altera_gpio_chip *to_altera(struct gpio_chip *gc) -{ - return container_of(gc, struct altera_gpio_chip, mmchip.gc); -} - static void altera_gpio_irq_unmask(struct irq_data *d) { struct altera_gpio_chip *altera_gc; @@ -54,7 +49,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -72,7 +67,7 @@ static void altera_gpio_irq_mask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -92,7 +87,7 @@ static int altera_gpio_irq_set_type(struct irq_data *d, { struct altera_gpio_chip *altera_gc; - altera_gc = to_altera(irq_data_get_irq_chip_data(d)); + altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); if (type == IRQ_TYPE_NONE) return 0; @@ -145,7 +140,7 @@ static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value) unsigned int data_reg; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); @@ -165,7 +160,7 @@ static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) unsigned int gpio_ddr; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); /* Set pin as input, assumes software controlled IP */ @@ -186,7 +181,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, unsigned int data_reg, gpio_ddr; mm_gc = to_of_mm_gpio_chip(gc); - chip = container_of(mm_gc, struct altera_gpio_chip, mmchip); + chip = gpiochip_get_data(gc); spin_lock_irqsave(&chip->gpio_lock, flags); /* Sets the GPIO value */ @@ -215,7 +210,7 @@ static void altera_gpio_irq_edge_handler(struct irq_desc *desc) unsigned long status; int i; - altera_gc = to_altera(irq_desc_get_handler_data(desc)); + altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain; @@ -244,7 +239,7 @@ static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc) unsigned long status; int i; - altera_gc = to_altera(irq_desc_get_handler_data(desc)); + altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain; @@ -292,7 +287,7 @@ static int altera_gpio_probe(struct platform_device *pdev) altera_gc->mmchip.gc.owner = THIS_MODULE; altera_gc->mmchip.gc.parent = &pdev->dev; - ret = of_mm_gpiochip_add(node, &altera_gc->mmchip); + ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); if (ret) { dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); return ret;