From patchwork Wed Dec 9 13:15:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57978 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp661075lbb; Wed, 9 Dec 2015 05:15:57 -0800 (PST) X-Received: by 10.98.72.152 with SMTP id q24mr12837187pfi.156.1449666957442; Wed, 09 Dec 2015 05:15:57 -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.15.57; Wed, 09 Dec 2015 05:15:57 -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 S1752937AbbLINP4 (ORCPT + 4 others); Wed, 9 Dec 2015 08:15:56 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36515 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbbLINP4 (ORCPT ); Wed, 9 Dec 2015 08:15:56 -0500 Received: by lbblt2 with SMTP id lt2so29866054lbb.3 for ; Wed, 09 Dec 2015 05:15:54 -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=r7U/hnoxGYoaD6QEfwbcFCArli5tU7rTkGlhGcvlqNU=; b=VflOLOGzuwLP4tBwNedVquvxJ8H78xT0rRGksV33Snp1NoKPDNnz2EBr8ELOK/Me7u JCT2syX9iGXe4YyJy47+2V58Ts+vvCQbwt0O5sZRzgKS/NFvjAF7SbNjqgwsA+JKPlU4 rSNlEs+nda4ryvJYSirnHB+tuvoQSS92fJkbrMLXMRxQJrPvbMwnJrO0lZAeiZIC6QxF JyNSJVnQH0CuLms7gVTQltkoh9ohnRiSnwxNuctQyNt16hLKgUXlVGu8cFX44ef27MXA jU2O24X8TGsoKQbj7yt+IhifDEUnMP1yvoA48YlJxkrAWEH4S1QezdSIOGOlz5IZE5i/ kn5g== 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=r7U/hnoxGYoaD6QEfwbcFCArli5tU7rTkGlhGcvlqNU=; b=KNZT031JTLqt+p0TCpuLypR4TTsNCsPegpUBs1rgjkALPeZCHj1Blt8OmompKZTDVe PXD0KAhPxmP9F8PpOlquNYlcA2KgnSJCNdnsPOALfxr1nvN0OnW159SDkzHdVCJlh55N EIa4F80XO+a8KfBMdAFmmMOqPpfe0gWd47IIW2Ezlues4bQwJmqwAvNbNfNUAxGGx4ZM AzAetHVvkpDiJZFxk1971l7z0ISqC2MjwUkKFGBR7ubfpp1FrADo8mKbqVylnPsmnvbp fywtUizkRDa7YL0YoOq8bBODqYLQ4FLn1xKzOTQimxUL/A4BuZZxUJFkGiBniWfb5F+H XlZA== X-Gm-Message-State: ALoCoQm90yNKIbFru5e1M+sPUe3jph6CE9HAc39icqvMqDhD8rS+aFzyLv0QAG1ltVoJ8xeF5E9fte34mfVnN2HV1CvEVQi96w== X-Received: by 10.112.165.69 with SMTP id yw5mr2297574lbb.1.1449666954844; Wed, 09 Dec 2015 05:15:54 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id h9sm1400103lbj.42.2015.12.09.05.15.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:15:54 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Octavian Purdila , Daniel Baluta Subject: [PATCH 023/182] gpio: dln2: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:15:50 +0100 Message-Id: <1449666950-30831-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: Octavian Purdila Cc: Daniel Baluta Signed-off-by: Linus Walleij --- drivers/gpio/gpio-dln2.c | 28 ++++++++++++++-------------- 1 file changed, 14 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-dln2.c b/drivers/gpio/gpio-dln2.c index e541af03dd45..e11a7d126e74 100644 --- a/drivers/gpio/gpio-dln2.c +++ b/drivers/gpio/gpio-dln2.c @@ -153,7 +153,7 @@ static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2, static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin req = { .pin = cpu_to_le16(offset), }; @@ -194,14 +194,14 @@ out_disable: static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset); } static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); if (test_bit(offset, dln2->output_enabled)) return GPIOF_DIR_OUT; @@ -211,7 +211,7 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int dir; dir = dln2_gpio_get_direction(chip, offset); @@ -226,7 +226,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset) static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); dln2_gpio_pin_set_out_val(dln2, offset, value); } @@ -234,7 +234,7 @@ static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset, unsigned dir) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); struct dln2_gpio_pin_val req = { .pin = cpu_to_le16(offset), .value = dir, @@ -262,7 +262,7 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset) static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); int ret; ret = dln2_gpio_pin_set_out_val(dln2, offset, value); @@ -275,7 +275,7 @@ static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset, static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { - struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(chip); __le32 duration = cpu_to_le32(debounce); return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE, @@ -302,7 +302,7 @@ static int dln2_gpio_set_event_cfg(struct dln2_gpio *dln2, unsigned pin, static void dln2_irq_unmask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); set_bit(pin, dln2->unmasked_irqs); @@ -311,7 +311,7 @@ static void dln2_irq_unmask(struct irq_data *irqd) static void dln2_irq_mask(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); clear_bit(pin, dln2->unmasked_irqs); @@ -320,7 +320,7 @@ static void dln2_irq_mask(struct irq_data *irqd) static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); switch (type) { @@ -349,7 +349,7 @@ static int dln2_irq_set_type(struct irq_data *irqd, unsigned type) static void dln2_irq_bus_lock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); mutex_lock(&dln2->irq_lock); } @@ -357,7 +357,7 @@ static void dln2_irq_bus_lock(struct irq_data *irqd) static void dln2_irq_bus_unlock(struct irq_data *irqd) { struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); - struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio); + struct dln2_gpio *dln2 = gpiochip_get_data(gc); int pin = irqd_to_hwirq(irqd); int enabled, unmasked; unsigned type; @@ -479,7 +479,7 @@ static int dln2_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dln2); - ret = gpiochip_add(&dln2->gpio); + ret = gpiochip_add_data(&dln2->gpio, dln2); if (ret < 0) { dev_err(dev, "failed to add gpio chip: %d\n", ret); goto out;