From patchwork Wed Dec 9 13:29:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58043 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp668877lbb; Wed, 9 Dec 2015 05:29:28 -0800 (PST) X-Received: by 10.98.69.157 with SMTP id n29mr12843535pfi.36.1449667768075; Wed, 09 Dec 2015 05:29:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ny6si12718088pab.215.2015.12.09.05.29.27; Wed, 09 Dec 2015 05:29:28 -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 S1752932AbbLIN31 (ORCPT + 4 others); Wed, 9 Dec 2015 08:29:27 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:35032 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753984AbbLIN30 (ORCPT ); Wed, 9 Dec 2015 08:29:26 -0500 Received: by lbpu9 with SMTP id u9so29779061lbp.2 for ; Wed, 09 Dec 2015 05:29:25 -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:mime-version:content-type :content-transfer-encoding; bh=GZ0VdObbGTVPlsyaN3ObZbd6Xm45l6RqLtw331XtK4E=; b=d1FT1TNE0Cvtbu7SMifh8/zGvuP2Elsf2Si0vXF3vdxGutGoHu24tpIYBOqH+FHua4 JWPh4O1KCuiCU5AnGTA1ZvVaL9zQYzmZymXTs5Jjuw0z7ZTMRGpwyVl0yEPm0kfNyXQ6 fs+8r8lvblV4gKPLP12pUpi997pA9if2YT3l3Uh+uRV17t4D+GMk48IHxDGDxgQ1XtCa ZTycF42J5PPoU/mrqNlLPSgDy1nnwtXhA0bKEZmQoGABfkSH5Sx/vaSaqWXkaPe+x6WF bfhVrR9VakSpxv1GKRg4ZhPWb8CFE+ogb/Cdg2gf3dHmjxReXWjRQRzgw6VehAFiZRXs 33tQ== 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:mime-version :content-type:content-transfer-encoding; bh=GZ0VdObbGTVPlsyaN3ObZbd6Xm45l6RqLtw331XtK4E=; b=KYlUlNzX4lJafqOnSrbis+ULhhE+Tm7lUskgHSzY3LhJh0gZ6jbxJMzsOiSQZN1wKE YR2za2Qm8+v9dcGd5e8+5xOzlu4adxUgKw7LMia2ie4kpUdwe3b/55rf0JqqcmOAnVKJ VjvUBS1QHZxXgEBXyAfYm7RPpGjY4oAjuF8rwwPK1XUcw1MNgHQJKaDPPCYeH/nzaoLJ ygkgtExEeOdC+viudA7doM8sZmqxQ6LxV8dsfcK/Mr3FyL6nkSpTBxxSZ3x+XPi7pRov j532ucTyofYBWIWrYevLzIk0glaLvtcaKbj/s0LK0BFhoLT2VGyuFknKwqA+xixgbCyp 8K3w== X-Gm-Message-State: ALoCoQl93Z4M0RrUBMDcklGlZbQwQpmeC4sMzAjrDBlFKgm+P8hjGC+cCLjbSntemTlC9yFArUrxY/vjq+x4Hm6LPkH3sD3mNQ== X-Received: by 10.112.169.34 with SMTP id ab2mr2420081lbc.140.1449667765266; Wed, 09 Dec 2015 05:29:25 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 88sm1442845lfq.3.2015.12.09.05.29.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:29:24 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= Subject: [PATCH 087/182] gpio: zynq: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:29:22 +0100 Message-Id: <1449667762-1664-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 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: Michal Simek Cc: Sören Brinkmann Signed-off-by: Linus Walleij --- drivers/gpio/gpio-zynq.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 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-zynq.c b/drivers/gpio/gpio-zynq.c index 8a04e00bef32..3a369a40ade4 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -131,11 +131,6 @@ struct zynq_platform_data { static struct irq_chip zynq_gpio_level_irqchip; static struct irq_chip zynq_gpio_edge_irqchip; -static struct zynq_gpio *to_zynq_gpio(struct gpio_chip *gc) -{ - return container_of(gc, struct zynq_gpio, chip); -} - /** * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank * for a given pin in the GPIO device @@ -183,7 +178,7 @@ static int zynq_gpio_get_value(struct gpio_chip *chip, unsigned int pin) { u32 data; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -207,7 +202,7 @@ static void zynq_gpio_set_value(struct gpio_chip *chip, unsigned int pin, int state) { unsigned int reg_offset, bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -244,7 +239,7 @@ static int zynq_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -277,7 +272,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio *gpio = to_zynq_gpio(chip); + struct zynq_gpio *gpio = gpiochip_get_data(chip); zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); @@ -308,7 +303,7 @@ static void zynq_gpio_irq_mask(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -329,7 +324,7 @@ static void zynq_gpio_irq_unmask(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -349,7 +344,7 @@ static void zynq_gpio_irq_ack(struct irq_data *irq_data) { unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -400,7 +395,7 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type) u32 int_type, int_pol, int_any; unsigned int device_pin_num, bank_num, bank_pin_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(irq_data)); + gpiochip_get_data(irq_data_get_irq_chip_data(irq_data)); device_pin_num = irq_data->hwirq; zynq_gpio_get_bank_pin(device_pin_num, &bank_num, &bank_pin_num, gpio); @@ -464,7 +459,7 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type) static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) { struct zynq_gpio *gpio = - to_zynq_gpio(irq_data_get_irq_chip_data(data)); + gpiochip_get_data(irq_data_get_irq_chip_data(data)); irq_set_irq_wake(gpio->irq, on); @@ -530,7 +525,7 @@ static void zynq_gpio_irqhandler(struct irq_desc *desc) u32 int_sts, int_enb; unsigned int bank_num; struct zynq_gpio *gpio = - to_zynq_gpio(irq_desc_get_handler_data(desc)); + gpiochip_get_data(irq_desc_get_handler_data(desc)); struct irq_chip *irqchip = irq_desc_get_chip(desc); chained_irq_enter(irqchip, desc); @@ -721,7 +716,7 @@ static int zynq_gpio_probe(struct platform_device *pdev) } /* report a bug if gpio chip registration fails */ - ret = gpiochip_add(chip); + ret = gpiochip_add_data(chip, gpio); if (ret) { dev_err(&pdev->dev, "Failed to add gpio chip\n"); goto err_disable_clk;