From patchwork Mon Jun 22 18:13:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Zhang X-Patchwork-Id: 6657411 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75005C05AC for ; Mon, 22 Jun 2015 18:14:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88663205DE for ; Mon, 22 Jun 2015 18:14:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 341AA205DA for ; Mon, 22 Jun 2015 18:14:13 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C7FB1265314; Mon, 22 Jun 2015 20:14:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D2491265351; Mon, 22 Jun 2015 20:13:57 +0200 (CEST) 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 228CA265344; Mon, 22 Jun 2015 20:13:56 +0200 (CEST) Received: from mail-ig0-f169.google.com (mail-ig0-f169.google.com [209.85.213.169]) by alsa0.perex.cz (Postfix) with ESMTP id F0B9A2652C1 for ; Mon, 22 Jun 2015 20:13:30 +0200 (CEST) Received: by igboe5 with SMTP id oe5so69795480igb.1 for ; Mon, 22 Jun 2015 11:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DPbGBUWb4Fej1qwDuImGHW2EpdK9fryr0dy2SWmiQZg=; b=aP2Q7Vz7JIl2hOdMJ8Et0F2hqg3MJnHSOTBPGykd1hbBxRUuTZTle8NK00sIuQl406 QWFTGJdXGHfhTnFuRI8nPEvTIGmEf/Z+im2Hd2FjRiuha3Jzzp+VFwAr+PmF8FWUwL35 iiHfzRs0LpIi5N9awYt+S51Z+QV31VDPWSszs= 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:in-reply-to :references; bh=DPbGBUWb4Fej1qwDuImGHW2EpdK9fryr0dy2SWmiQZg=; b=SX5LzPKzQTXWJNF0zJdUGQHKkoWOb4FE6hHXbvHZXNLi93HXhx1yOUfNZmI3i2+baw i5OVEYGuGoMW2wsfT8Xesn3MlHsLsw42iQUGYl5OigDb5KNL6VZBfa1FpX0JeNvm4lU4 ObEIi7pmK7OoF9gnNIbX8udeoLbOFRPTvQAOuCa0BowVXHGFpPdFu7KZCO7hZjQkeFOX 1PA9uh5wDEbbugBBbH7NHISIdxKi8UwWQWMUUnt6Wolp6ykdUVxYU0MNdj7OVHVQufqG df4ulCW8Xg5BHB25ZZHwagMJvFWAtUdvMED/QA1HVhOOsWaHsyVducCbF0frEiVorJ9t T7DA== X-Gm-Message-State: ALoCoQl3uX8LHxz/xwKEAZR9xWFs7Lo8Qx4GEC2qcaHFFln3pPFI24Metj6d9mYVyZrKZC4HAozX X-Received: by 10.43.76.195 with SMTP id zf3mr27003506icb.62.1434996803960; Mon, 22 Jun 2015 11:13:23 -0700 (PDT) Received: from benzh.mtv.corp.google.com ([172.22.65.67]) by mx.google.com with ESMTPSA id l128sm13234675iol.1.2015.06.22.11.13.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Jun 2015 11:13:23 -0700 (PDT) From: Ben Zhang To: Mark Brown Date: Mon, 22 Jun 2015 11:13:00 -0700 Message-Id: <1434996780-34535-2-git-send-email-benzh@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1434996780-34535-1-git-send-email-benzh@chromium.org> References: <1434996780-34535-1-git-send-email-benzh@chromium.org> Cc: Oder Chiou , alsa-devel@alsa-project.org, Liam Girdwood , Ben Zhang , Anatol Pomozov , Bard Liao , Dylan Reid Subject: [alsa-devel] [PATCH 2/2] ASoC: rt5677: Switch to use unified device property 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes the driver use the unified device property API so that platform data can be provided by Device Tree, ACPI or board files. Signed-off-by: Ben Zhang --- sound/soc/codecs/rt5677.c | 57 +++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index c166217..69e45d8 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -5018,27 +5019,29 @@ static const struct i2c_device_id rt5677_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); -static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) +static void rt5677_read_device_properties(struct rt5677_priv *rt5677, + struct device *dev) { - rt5677->pdata.in1_diff = of_property_read_bool(np, - "realtek,in1-differential"); - rt5677->pdata.in2_diff = of_property_read_bool(np, - "realtek,in2-differential"); - rt5677->pdata.lout1_diff = of_property_read_bool(np, - "realtek,lout1-differential"); - rt5677->pdata.lout2_diff = of_property_read_bool(np, - "realtek,lout2-differential"); - rt5677->pdata.lout3_diff = of_property_read_bool(np, - "realtek,lout3-differential"); - - of_property_read_u8_array(np, "realtek,gpio-config", - rt5677->pdata.gpio_config, RT5677_GPIO_NUM); - - of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio); - of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio); - of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio); - - return 0; + rt5677->pdata.in1_diff = device_property_read_bool(dev, + "realtek,in1-differential"); + rt5677->pdata.in2_diff = device_property_read_bool(dev, + "realtek,in2-differential"); + rt5677->pdata.lout1_diff = device_property_read_bool(dev, + "realtek,lout1-differential"); + rt5677->pdata.lout2_diff = device_property_read_bool(dev, + "realtek,lout2-differential"); + rt5677->pdata.lout3_diff = device_property_read_bool(dev, + "realtek,lout3-differential"); + + device_property_read_u8_array(dev, "realtek,gpio-config", + rt5677->pdata.gpio_config, RT5677_GPIO_NUM); + + device_property_read_u32(dev, "realtek,jd1-gpio", + &rt5677->pdata.jd1_gpio); + device_property_read_u32(dev, "realtek,jd2-gpio", + &rt5677->pdata.jd2_gpio); + device_property_read_u32(dev, "realtek,jd3-gpio", + &rt5677->pdata.jd3_gpio); } static struct regmap_irq rt5677_irqs[] = { @@ -5121,18 +5124,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, if (pdata) rt5677->pdata = *pdata; - - if (i2c->dev.of_node) { - ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); - if (ret) { - dev_err(&i2c->dev, "Failed to parse device tree: %d\n", - ret); - return ret; - } - } else { - rt5677->pow_ldo2 = -EINVAL; - rt5677->reset_pin = -EINVAL; - } + else + rt5677_read_device_properties(rt5677, &i2c->dev); /* pow-ldo2 and reset are optional. The codec pins may be statically * connected on the board without gpios. If the gpio device property