From patchwork Thu Aug 27 14:54:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 52768 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 7DF5D22E8B for ; Thu, 27 Aug 2015 14:54:32 +0000 (UTC) Received: by labd1 with SMTP id d1sf7992249lab.0 for ; Thu, 27 Aug 2015 07:54:31 -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=cmqphPCN6zf5sJb8e90ZjNbOdjVDYDDqfGo3efcN1CE=; b=MlxYXTSPDU2C8L9XrhCV6ab/cdBSvCxGe6kolIkqfCwvk+fkCO7WnZUkSD2yW09Lin LTGuizdqrqY28IDvAHPdzh4Y9CS3knJR0aLwYKi1SQ9OGsTIve15Ygor/CqQ1qOrGRmG TYpmt0TA9BVmdKQaO7Z7lkE/XCG4PodR35s9JLh/RN13PoDIk4IuaznoqZGyMKhkudOV HtIw3W9YHwTY3yO+vZgZ5MCG4qBSIg7Iaeuf9+i4Ohd+QUnTAPUmfIrlVVOupWrinGAQ 5yUIpaS8mIDLS+61RKvpKaKDmXNY5I9jdvkbmk3fhmoepu6h98ZDKqtS8o7eVroesg/2 Q5rg== X-Gm-Message-State: ALoCoQldUx3TM0pciohvlVTnv2U4RwBRZ33yXSzrNKosaT3S+ZTpa6sRPizRm47uLgOWUY3Xt9xS X-Received: by 10.180.90.106 with SMTP id bv10mr2652328wib.6.1440687271428; Thu, 27 Aug 2015 07:54:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.8 with SMTP id ls8ls89997lac.71.gmail; Thu, 27 Aug 2015 07:54:31 -0700 (PDT) X-Received: by 10.152.5.169 with SMTP id t9mr2476125lat.55.1440687271275; Thu, 27 Aug 2015 07:54:31 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id 6si2432493lam.37.2015.08.27.07.54.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 07:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbsx3 with SMTP id sx3so13083578lbb.0 for ; Thu, 27 Aug 2015 07:54:31 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr2418623laf.112.1440687271170; Thu, 27 Aug 2015 07:54:31 -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 yc8csp4700090lbb; Thu, 27 Aug 2015 07:54:29 -0700 (PDT) X-Received: by 10.66.142.132 with SMTP id rw4mr7136064pab.19.1440687268318; Thu, 27 Aug 2015 07:54:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ux5si4077382pbc.212.2015.08.27.07.54.27; Thu, 27 Aug 2015 07:54:28 -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 S1752666AbbH0Oy0 (ORCPT + 2 others); Thu, 27 Aug 2015 10:54:26 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:33886 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbbH0Oy0 (ORCPT ); Thu, 27 Aug 2015 10:54:26 -0400 Received: by lbbtg9 with SMTP id tg9so13087078lbb.1 for ; Thu, 27 Aug 2015 07:54:24 -0700 (PDT) X-Received: by 10.112.234.165 with SMTP id uf5mr2364304lbc.91.1440687264443; Thu, 27 Aug 2015 07:54:24 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by smtp.gmail.com with ESMTPSA id c5sm636412lbd.49.2015.08.27.07.54.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 07:54:23 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Rabin Vincent Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH 1/5] gpio: etraxfs: use container_of() to get state container Date: Thu, 27 Aug 2015 16:54:18 +0200 Message-Id: <1440687258-16977-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.217.179 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 etraxfs GPIO driver is extracted from the gpio_chip exploiting the fact that offsetof() the struct gpio_chip inside the struct bgpio_chip are both 0, so the container_of() is in practice a noop. However if a member is added to struct etraxfs_gpio_chip in front of struct bgpio_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: Rabin Vincent Signed-off-by: Linus Walleij --- drivers/gpio/gpio-etraxfs.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c index ca33bda8ec55..b5dc0d14780d 100644 --- a/drivers/gpio/gpio-etraxfs.c +++ b/drivers/gpio/gpio-etraxfs.c @@ -176,6 +176,11 @@ static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = { .rw_intr_pins = ARTPEC3_rw_intr_pins, }; +static struct etraxfs_gpio_chip *to_etraxfs(struct gpio_chip *gc) +{ + return container_of(gc, struct etraxfs_gpio_chip, bgc.gc); +} + static unsigned int etraxfs_gpio_chip_to_port(struct gpio_chip *gc) { return gc->label[0] - 'A'; @@ -220,7 +225,8 @@ static unsigned int etraxfs_gpio_to_group_pin(struct etraxfs_gpio_chip *chip, static void etraxfs_gpio_irq_ack(struct irq_data *d) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -229,7 +235,8 @@ static void etraxfs_gpio_irq_ack(struct irq_data *d) static void etraxfs_gpio_irq_mask(struct irq_data *d) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -241,7 +248,8 @@ static void etraxfs_gpio_irq_mask(struct irq_data *d) static void etraxfs_gpio_irq_unmask(struct irq_data *d) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -253,7 +261,8 @@ static void etraxfs_gpio_irq_unmask(struct irq_data *d) static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); u32 cfg; @@ -289,7 +298,8 @@ static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) static int etraxfs_gpio_irq_request_resources(struct irq_data *d) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); @@ -318,7 +328,8 @@ out: static void etraxfs_gpio_irq_release_resources(struct irq_data *d) { - struct etraxfs_gpio_chip *chip = irq_data_get_irq_chip_data(d); + struct etraxfs_gpio_chip *chip = + to_etraxfs(irq_data_get_irq_chip_data(d)); struct etraxfs_gpio_block *block = chip->block; unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq);