From patchwork Thu Dec 6 12:24:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10715973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C2681759 for ; Thu, 6 Dec 2018 13:02:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 899B32DD74 for ; Thu, 6 Dec 2018 13:02:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ACFE2E6BD; Thu, 6 Dec 2018 13:02:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABFCE2E6B8 for ; Thu, 6 Dec 2018 13:02:48 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 59DC8267C71; Thu, 6 Dec 2018 13:24:50 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 58930267C68; Thu, 6 Dec 2018 13:24:46 +0100 (CET) Received: from mail.bugwerft.de (mail.bugwerft.de [46.23.86.59]) by alsa0.perex.cz (Postfix) with ESMTP id 0E7CF267C67 for ; Thu, 6 Dec 2018 13:24:40 +0100 (CET) Received: from localhost.localdomain (pD95EF760.dip0.t-ipconnect.de [217.94.247.96]) by mail.bugwerft.de (Postfix) with ESMTPSA id 574062C5E36; Thu, 6 Dec 2018 12:24:17 +0000 (UTC) From: Daniel Mack To: broonie@kernel.org Date: Thu, 6 Dec 2018 13:24:26 +0100 Message-Id: <20181206122426.28194-2-daniel@zonque.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206122426.28194-1-daniel@zonque.org> References: <20181206122426.28194-1-daniel@zonque.org> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Daniel Mack Subject: [alsa-devel] [PATCH 2/2] ASoC: codecs: cs4270: move to GPIO consumer API X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Get the reset GPIO through the GPIO consumer API. This allows specifying the DT property as "reset-gpios" without breaking existing DT users. Signed-off-by: Daniel Mack --- sound/soc/codecs/cs4270.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 3c266eeb89bf..33d74f163bd7 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -29,8 +29,8 @@ #include #include #include +#include #include -#include /* * The codec isn't really big-endian or little-endian, since the I2S @@ -658,8 +658,8 @@ static const struct regmap_config cs4270_regmap = { static int cs4270_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { - struct device_node *np = i2c_client->dev.of_node; struct cs4270_private *cs4270; + struct gpio_desc *reset_gpiod; unsigned int val; int ret, i; @@ -678,20 +678,11 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, if (ret < 0) return ret; - /* See if we have a way to bring the codec out of reset */ - if (np) { - enum of_gpio_flags flags; - int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); - - if (gpio_is_valid(gpio)) { - ret = devm_gpio_request_one(&i2c_client->dev, gpio, - flags & OF_GPIO_ACTIVE_LOW ? - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, - "cs4270 reset"); - if (ret < 0) - return ret; - } - } + reset_gpiod = devm_gpiod_get_optional(&i2c_client->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpiod) && + PTR_ERR(reset_gpiod) == -EPROBE_DEFER) + return -EPROBE_DEFER; cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap); if (IS_ERR(cs4270->regmap))