From patchwork Wed Dec 9 13:51:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58136 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp681634lbb; Wed, 9 Dec 2015 05:52:03 -0800 (PST) X-Received: by 10.67.5.2 with SMTP id ci2mr8018613pad.47.1449669123387; Wed, 09 Dec 2015 05:52:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si12828839pap.237.2015.12.09.05.52.02; Wed, 09 Dec 2015 05:52:03 -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 S1753942AbbLINwA (ORCPT + 4 others); Wed, 9 Dec 2015 08:52:00 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:35633 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbbLINv7 (ORCPT ); Wed, 9 Dec 2015 08:51:59 -0500 Received: by lbpu9 with SMTP id u9so30164499lbp.2 for ; Wed, 09 Dec 2015 05:51:57 -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=FRIvkwne7V7VpplZnx7/eNsF/5/cXrJqo3ur+XHMvIs=; b=X3sZx6CY2mUWpIIXp/Sd56e5NL+K3WA262NzrqMdXuQKVx99TnHD9AOjMuS1RPEfSB x1xxPmyOZ83EBQZ5ljdxA/wfuvjEmSdYJs/e27aQWh0e8FHcIG5ErfVvxsSVj5AYqBM7 yzypy05LuTa3ELGi8tjRhtf31/T+v1al5c+MUXtQGzo0c+t4CQ3p6ha2y9dMrJpgBiKk 1/8tMKaanABjwaAO6Sdi86LNJg4flhPddT/39P3JCcaKJdAv2HZ0B0Car70Ylycjr9Lm 0R2mSKxSIUL3ry4nLPMruLM+O3gRQu9BUtDiaBQKMI62EQLrnOC6UZaxFBpCq/qDq63k rrOQ== 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=FRIvkwne7V7VpplZnx7/eNsF/5/cXrJqo3ur+XHMvIs=; b=jYCgSbdTYf7o6d+/A56uz5E1sLwKMjW6lNbmrF6SWn73e2BgEyIq64md5BJRQvxMUR kP5TuXDLebcWBDL70s2Vb1GVmvDxuY+De3SnKXG6xJgUFGrFw0iLMfBkhgtHVzJlwZ4d sl/HXMBCkvdNwd89lm3U6oS0/0lXml7KzFubgi5wpH0fB/Ym/G0p3TUdAGRktzhWRl2h BLVLSGI9/w/0KNTjTb8zJHvRyudDD1BAMsDFDryDE3uOevuTYRmW+H0LrSU8WlsECttn b89QbyFJ8EHzMp9Fh8nlq2w8HkYej26LP8aDQg5rynVJpxAgL/hfNmBPNdqhrC+lI6iv hQwQ== X-Gm-Message-State: ALoCoQnhiXzs7VfITf/91Zj+z3FNd1XuWrtN6R/sNQBXtduZqHC7EAse8NVYugh3t65p80ZfeU0l+X9sHjF3hD1mikZg7uS+/w== X-Received: by 10.112.16.162 with SMTP id h2mr2043461lbd.89.1449669117888; Wed, 09 Dec 2015 05:51:57 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e9sm1434088lbs.13.2015.12.09.05.51.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Dec 2015 05:51:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Johan Hovold , Alexandre Courbot , Michael Welling , Markus Pargmann , Liam Girdwood , Mark Brown Cc: Linus Walleij , alsa-devel@alsa-project.org Subject: [PATCH 180/182] ASoC: wm8996: use gpiochip data pointer Date: Wed, 9 Dec 2015 14:51:54 +0100 Message-Id: <1449669114-7317-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: Liam Girdwood Cc: Mark Brown Cc: alsa-devel@alsa-project.org Signed-off-by: Linus Walleij --- Liam/Mark: please ACK this so I can merge it into the GPIO tree. --- sound/soc/codecs/wm8996.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 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 Acked-by: Charles Keepax Acked-by: Mark Brown diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 8d7d6c01a2f7..f9656df9dccc 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -2139,14 +2140,9 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, } #ifdef CONFIG_GPIOLIB -static inline struct wm8996_priv *gpio_to_wm8996(struct gpio_chip *chip) -{ - return container_of(chip, struct wm8996_priv, gpio_chip); -} - static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, WM8996_GP1_LVL, !!value << WM8996_GP1_LVL_SHIFT); @@ -2155,7 +2151,7 @@ static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int wm8996_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); int val; val = (1 << WM8996_GP1_FN_SHIFT) | (!!value << WM8996_GP1_LVL_SHIFT); @@ -2167,7 +2163,7 @@ static int wm8996_gpio_direction_out(struct gpio_chip *chip, static int wm8996_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); unsigned int reg; int ret; @@ -2180,7 +2176,7 @@ static int wm8996_gpio_get(struct gpio_chip *chip, unsigned offset) static int wm8996_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, WM8996_GP1_FN_MASK | WM8996_GP1_DIR, @@ -2211,7 +2207,7 @@ static void wm8996_init_gpio(struct wm8996_priv *wm8996) else wm8996->gpio_chip.base = -1; - ret = gpiochip_add(&wm8996->gpio_chip); + ret = gpiochip_add_data(&wm8996->gpio_chip, wm8996); if (ret != 0) dev_err(wm8996->dev, "Failed to add GPIOs: %d\n", ret); }