From patchwork Wed Dec 9 13:16:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 57984 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp661642lbb; Wed, 9 Dec 2015 05:16:51 -0800 (PST) X-Received: by 10.66.101.36 with SMTP id fd4mr7957687pab.76.1449667011448; Wed, 09 Dec 2015 05:16:51 -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.16.51; Wed, 09 Dec 2015 05:16:51 -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 S1753385AbbLINQu (ORCPT + 4 others); Wed, 9 Dec 2015 08:16:50 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:36447 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145AbbLINQu (ORCPT ); Wed, 9 Dec 2015 08:16:50 -0500 Received: by lfs39 with SMTP id 39so34145399lfs.3 for ; Wed, 09 Dec 2015 05:16:49 -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=ignqQl4zSIeVRVwPUIN6Aa0SKPrdS62iMh4AfQ4FQc8=; b=X3JBZeNtAYYo/xJ2SGPaPbaW/9WGqoUekyOyjz66IoV+fjeOPxrlotm1/Y8mDQpAXq FIZLoxk0WxCiZ4LiNOvT91b4TF4nGisAR+G152ZZKbGy8y3luET9ayA0OP86ie+7LWm1 l+hQJhd7PU8h5Dqnn2hqS5XPsAz0koY6Z3TuJCqU31twWa7c93DZnezwBjvh4OvPnFKp q8KhahLE5jeH6lyw82GnlH6UNxOtVO+C9vQtuOSAakqD7frBbgMIpQT0FCy10JMFGTgE yjQto7OkIEdRszsYAt1x2H+vxdXnPd8w8sjiZ1Cv2P+ayKoqVX3BwrQjWjs/3d6ZwIQA 9J3Q== 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=ignqQl4zSIeVRVwPUIN6Aa0SKPrdS62iMh4AfQ4FQc8=; b=fiCdHg1ZHOrMfewJUASUntpT2M1QZB9Dm/zLH1ju0b5bsJK7+Y7qwJxJ5cdAsAjZwM C+/4lJ+Uf9eOnKt/DTlhQmDj2JJJfy6XX5ppdI5E3AYRGd/5G8sA0hshYxGazmTwvnzQ 3aNFpN1/pyiUHNF4mQgg6ssFS/uVWwkrZYsi59YGOcp5+C12+7BxHV5TgM64P2Kwc4lo qbjgwIQ00nvNrLpN0btyZirZpu6DvtpTRcqAvUjeZPJ2yRGhKDtOg6Ztfm1ISWgCiI92 w5KBpQBtOqEagFZwLcxb13UrnhRfFQScno6mi7Pc4GhzoE/rg6Vp4y+6MNURal7W9Gq4 BFKQ== X-Gm-Message-State: ALoCoQkblt3ZFl5LeqBQufgs2T2UJZzDwhxmLYVcWneZ9IpBaUioLlMhRbBHTPlMZ+apQBldl2QM49TR0d4b8JYX9qiujWFy/g== X-Received: by 10.25.24.193 with SMTP id 62mr2289746lfy.84.1449667009045; Wed, 09 Dec 2015 05:16:49 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id pd9sm1391603lbc.48.2015.12.09.05.16.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:16:48 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann Cc: Linus Walleij , Milo Kim Subject: [PATCH 029/182] gpio: lp3943: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:16:45 +0100 Message-Id: <1449667005-31123-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: Milo Kim Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lp3943.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 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-lp3943.c b/drivers/gpio/gpio-lp3943.c index f979c3be217f..1c8e2ae26938 100644 --- a/drivers/gpio/gpio-lp3943.c +++ b/drivers/gpio/gpio-lp3943.c @@ -45,14 +45,9 @@ struct lp3943_gpio { u16 input_mask; /* 1 = GPIO is input direction, 0 = output */ }; -static inline struct lp3943_gpio *to_lp3943_gpio(struct gpio_chip *_chip) -{ - return container_of(_chip, struct lp3943_gpio, chip); -} - static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); struct lp3943 *lp3943 = lp3943_gpio->lp3943; /* Return an error if the pin is already assigned */ @@ -64,7 +59,7 @@ static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) static void lp3943_gpio_free(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); struct lp3943 *lp3943 = lp3943_gpio->lp3943; clear_bit(offset, &lp3943->pin_used); @@ -82,7 +77,7 @@ static int lp3943_gpio_set_mode(struct lp3943_gpio *lp3943_gpio, u8 offset, static int lp3943_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); lp3943_gpio->input_mask |= BIT(offset); @@ -138,7 +133,7 @@ static int lp3943_get_gpio_out_status(struct lp3943_gpio *lp3943_gpio, static int lp3943_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); /* * Limitation: @@ -157,7 +152,7 @@ static int lp3943_gpio_get(struct gpio_chip *chip, unsigned offset) static void lp3943_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); u8 data; if (value) @@ -171,7 +166,7 @@ static void lp3943_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int lp3943_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); + struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); lp3943_gpio_set(chip, offset, value); lp3943_gpio->input_mask &= ~BIT(offset); @@ -209,7 +204,7 @@ static int lp3943_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, lp3943_gpio); - return gpiochip_add(&lp3943_gpio->chip); + return gpiochip_add_data(&lp3943_gpio->chip, lp3943_gpio); } static int lp3943_gpio_remove(struct platform_device *pdev)