From patchwork Thu Aug 27 14:54:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 52769 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 79A4622EA3 for ; Thu, 27 Aug 2015 14:55:01 +0000 (UTC) Received: by wibcx1 with SMTP id cx1sf4464110wib.0 for ; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=oC6AuTcA2qRL6A8fZBGoQXOBXWp59Rx0CCEyPCsJrWE=; b=C/JO6eXXm9wg9dVG+GWiKMNDzU88Anv7Wnfo+Cm0alTgb2nAnOreWZeGOAcYAgcNnY kcbJdyNKcFpOBhj95SpZfOCb/OnPlL3UqakTSGzSwtjhs5n/um1WICJvTFUkezfaDQjW NczL2MJbxCg31azhIZm8VKEO0/LWto3hfsAztApiHkbhB9js0vVBaq8SCglW45grucPr PhhAKb/cgdDEABqZ9DM1/eMsQ30ysNvtYrghheTIlir9QW7njG4barGgLaRZgxZZVFJT 58S/nZj6rvIuDlXF+upDjkarzAS1P8hIZW5xozp5brMUEMGIrRDj+mqU92P5TrceZs4G e7GQ== X-Gm-Message-State: ALoCoQktaWjWw6ULZXb6KVHg4axkl0T7utv6RHPxqMZ5EAx+O7n15Jspb9SZLMF81bFcZyDdqyfn X-Received: by 10.112.99.37 with SMTP id en5mr1301581lbb.7.1440687300758; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.136 with SMTP id w8ls104694lal.16.gmail; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) X-Received: by 10.152.121.70 with SMTP id li6mr2406570lab.98.1440687300623; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id ld2si2415129lac.132.2015.08.27.07.55.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 07:55:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labns7 with SMTP id ns7so14348768lab.0 for ; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) X-Received: by 10.152.21.196 with SMTP id x4mr2349260lae.117.1440687300333; Thu, 27 Aug 2015 07:55:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.162.200 with SMTP id yc8csp4700421lbb; Thu, 27 Aug 2015 07:54:59 -0700 (PDT) X-Received: by 10.66.253.229 with SMTP id ad5mr7113304pad.101.1440687298187; Thu, 27 Aug 2015 07:54:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj5si4076603pab.238.2015.08.27.07.54.57; Thu, 27 Aug 2015 07:54:58 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753464AbbH0Oy4 (ORCPT + 2 others); Thu, 27 Aug 2015 10:54:56 -0400 Received: from mail-la0-f52.google.com ([209.85.215.52]:35853 "EHLO mail-la0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753495AbbH0Oyz (ORCPT ); Thu, 27 Aug 2015 10:54:55 -0400 Received: by labia3 with SMTP id ia3so14244904lab.3 for ; Thu, 27 Aug 2015 07:54:54 -0700 (PDT) X-Received: by 10.112.205.6 with SMTP id lc6mr2366954lbc.95.1440687294353; Thu, 27 Aug 2015 07:54:54 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by smtp.gmail.com with ESMTPSA id ut5sm641800lbc.33.2015.08.27.07.54.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 07:54:53 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Tien Hock Loh Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH 2/5] gpio: altera: use container_of() to get state container Date: Thu, 27 Aug 2015 16:54:48 +0200 Message-Id: <1440687288-17037-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The state container of the Altera GPIO driver is extracted from the gpio_chip exploiting the fact that offsetof() the struct gpio_chip inside the struct of_mm_gpio_chip are both 0, so the container_of() is in practice a noop. However if a member is added to struct altera_gpio_chip in front of struct of_mm_gpio_chip, things will break. Using proper container_of() avoids this problem. Semantically this is a noop, the compiler will optimize it away, but syntactically it makes me happier. Cc: Tien Hock Loh Signed-off-by: Linus Walleij --- drivers/gpio/gpio-altera.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 9b7e0b3db387..9087647e765a 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -42,6 +42,11 @@ 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; @@ -49,7 +54,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = irq_data_get_irq_chip_data(d); + altera_gc = to_altera(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -67,7 +72,7 @@ static void altera_gpio_irq_mask(struct irq_data *d) unsigned long flags; u32 intmask; - altera_gc = irq_data_get_irq_chip_data(d); + altera_gc = to_altera(irq_data_get_irq_chip_data(d)); mm_gc = &altera_gc->mmchip; spin_lock_irqsave(&altera_gc->gpio_lock, flags); @@ -87,7 +92,7 @@ static int altera_gpio_irq_set_type(struct irq_data *d, { struct altera_gpio_chip *altera_gc; - altera_gc = irq_data_get_irq_chip_data(d); + altera_gc = to_altera(irq_data_get_irq_chip_data(d)); if (type == IRQ_TYPE_NONE) return 0; @@ -211,7 +216,7 @@ static void altera_gpio_irq_edge_handler(unsigned int irq, unsigned long status; int i; - altera_gc = irq_desc_get_handler_data(desc); + altera_gc = to_altera(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain; @@ -241,7 +246,7 @@ static void altera_gpio_irq_leveL_high_handler(unsigned int irq, unsigned long status; int i; - altera_gc = irq_desc_get_handler_data(desc); + altera_gc = to_altera(irq_desc_get_handler_data(desc)); chip = irq_desc_get_chip(desc); mm_gc = &altera_gc->mmchip; irqdomain = altera_gc->mmchip.gc.irqdomain;