Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp630798yba; Fri, 5 Apr 2019 13:45:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHHB04yx9vlyILY+y1OzOBEvyYd+GHqCH9FAF6bKeuNg48VlLj8+IdRQmBPlyrUK3U5vrn X-Received: by 2002:a63:e20b:: with SMTP id q11mr14480494pgh.263.1554497150335; Fri, 05 Apr 2019 13:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554497150; cv=none; d=google.com; s=arc-20160816; b=fK1DcAq1cuPiDp85YYgkdArfYrX2vsNJiRd1tLAipLaBGgY5XF9Q44JLBJHjWDe7ZJ /XiX9doxhdGM0tqmEv5qJa44m25Pe2LrdGLK9zIeehouD+ffBfDoLWJGrBoUEn4Igla9 1GR/uilqZVFPd9lxuhIhGF/Ip/dCLJOkaG0l4P/JnsQMcTdEw6wbHSBGuiZ2oimjPbKx 5VuyImoelAtLJW28ivB6zToavVCbtNRs/gDv55TfViQixGduRkUeEzjxGLD7I7SHq6Ot hPwEgP6OagiVf2i1TrCooEsTVyWi6BCaPAyyQ2/txzA2FUBdpNMnPExYrkY4k8kyA2vP 4K1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tiYXHUCPtTh5KnYT2gNs43YlCtKkr08VxW+ZaVoGMmQ=; b=w0tvVmEiR0sVGryJGPTOIYVeu+Of3tzVnTp6Y0lbEObtNcmEiNGDn1ncGR8heZVs0i CHHjuofaWvknN/vtblqibfM5dUUgK5zM+FANJQZKYWPiGMnDlqTVOwY93bEly1Vs7ywK gRPXXuLdQym2rLll/hpqsLfWdA2FPadCrh5gWft1ylD3Vyq/4Q9ufl5TDBZHTw8rpQhw iRXk6ANXgwfff0OvbmMAo2JL8URFDHr+KoKcYn7Q+rEFAIOEdYW5GpLeQDBHMMnxeV4r eDhBpsigcdtFpouus/6zbhXqKdhbrefSrjxl2SM9Vbo+G5ttNkG6g8q1esqYJ126hnaR Cg0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DygSbeat; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si11001975pgn.530.2019.04.05.13.45.34; Fri, 05 Apr 2019 13:45:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DygSbeat; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbfDEUof (ORCPT + 99 others); Fri, 5 Apr 2019 16:44:35 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:38895 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725967AbfDEUoe (ORCPT ); Fri, 5 Apr 2019 16:44:34 -0400 Received: by mail-it1-f196.google.com with SMTP id f22so11788223ita.3 for ; Fri, 05 Apr 2019 13:44:33 -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 :mime-version:content-transfer-encoding; bh=tiYXHUCPtTh5KnYT2gNs43YlCtKkr08VxW+ZaVoGMmQ=; b=DygSbeatREyMDf6bMslTPSVzjOo/B4lsTJ3cL91RhUzoHfcvqBBuVjC2Gi6x0no/B5 idjPzfX+EVEyF458QOcJjgLDEJWsJq5yJrKJg4aA0KndBkhWrYwNuu0c6L2cAmvazAJE rxLngRGa0HByCi2kNekxV7Q2VIPC5uzOQ0Rsg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tiYXHUCPtTh5KnYT2gNs43YlCtKkr08VxW+ZaVoGMmQ=; b=id3TTqKtkIsK6ZZlyWCPItY5OWJezxNb+mV/CsCZxBeo3wIx4dCbGjzZzfqsmxdgmC 93ouAIAP/sMStho3uv7SI6iqdPvvtvNo34ViUAmoQJlycD6ySs99utmj83X32RT0q60X Soa/3iJL/jdeN4KFdmqdIbvFQ2pslB9JaZ1een0552BTTzT8a4RKsV5N+EoXRNP2/Hmw B5E8E0J8NW2r89oM/dOWz1NwTDJwIzbdb88h7Ncp42HWI+YxIQr4h2MmL1S/L31RWzhQ bmmMvAexVvPRl/B1p1lb4lJkKuxmHz/bWesQaWVPIpyGHN0EKMqRk5HgNsKNGgtsdzm8 FL8w== X-Gm-Message-State: APjAAAXP9QTUJ65ZKFGGGgNWVLyGKYqmnhkDh4gvdWSXyuMOhKs2/H3b SAiwTmwIzbWeGcJonVioMFmmhUSy9kt0qA== X-Received: by 2002:a05:6638:25a:: with SMTP id w26mr4968639jaq.112.1554497073177; Fri, 05 Apr 2019 13:44:33 -0700 (PDT) Received: from localhost ([2620:15c:183:200:70a8:812a:cdeb:6e0]) by smtp.gmail.com with ESMTPSA id i26sm9142859ioj.86.2019.04.05.13.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 13:44:32 -0700 (PDT) From: Fletcher Woodruff To: linux-kernel@vger.kernel.org Cc: Fletcher Woodruff , Jaroslav Kysela , Liam Girdwood , Mark Brown , Oder Chiou , Takashi Iwai , Curtis Malainey , Ross Zwisler , alsa-devel@alsa-project.org Subject: [PATCH v2 3/3] ASoC: rt5677: fall back to DT prop names on error Date: Fri, 5 Apr 2019 14:42:57 -0600 Message-Id: <20190405204257.87095-4-fletcherw@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190405204257.87095-1-fletcherw@chromium.org> References: <20190401205519.34023-2-fletcherw@chromium.org> <20190405204257.87095-1-fletcherw@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rt5677 driver uses ACPI-style property names to read from the device API. However, these do not match the property names in _DSD used on the Chromebook Pixel 2015, which are closer to the Device Tree style. Unify the two functions for reading from the device API so that they try ACPI-style names first and fall back to the DT names on error. Signed-off-by: Fletcher Woodruff --- sound/soc/codecs/rt5677.c | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 6bff0df53c6c6b..38e99580f09acd 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4998,48 +4998,50 @@ static const struct acpi_device_id rt5677_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); -static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677, +static void rt5677_read_device_properties(struct rt5677_priv *rt5677, struct device *dev) { u32 val; - if (!device_property_read_u32(dev, "DCLK", &val)) - rt5677->pdata.dmic2_clk_pin = val; + rt5677->pdata.in1_diff = + device_property_read_bool(dev, "IN1") || + device_property_read_bool(dev, "realtek,in1-differential"); - rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1"); - rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2"); - rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1"); - rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2"); - rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3"); + rt5677->pdata.in2_diff = + device_property_read_bool(dev, "IN2") || + device_property_read_bool(dev, "realtek,in2-differential"); - device_property_read_u32(dev, "JD1", &rt5677->pdata.jd1_gpio); - device_property_read_u32(dev, "JD2", &rt5677->pdata.jd2_gpio); - device_property_read_u32(dev, "JD3", &rt5677->pdata.jd3_gpio); -} + rt5677->pdata.lout1_diff = + device_property_read_bool(dev, "OUT1") || + device_property_read_bool(dev, "realtek,lout1-differential"); -static void rt5677_read_device_properties(struct rt5677_priv *rt5677, - struct device *dev) -{ - 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"); + rt5677->pdata.lout2_diff = + device_property_read_bool(dev, "OUT2") || + device_property_read_bool(dev, "realtek,lout2-differential"); + + rt5677->pdata.lout3_diff = + device_property_read_bool(dev, "OUT3") || + 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); + rt5677->pdata.gpio_config, + RT5677_GPIO_NUM); + + if (!device_property_read_u32(dev, "DCLK", &val) || + !device_property_read_u32(dev, "realtek,dmic2_clk_pin", &val)) + rt5677->pdata.dmic2_clk_pin = val; + + if (!device_property_read_u32(dev, "JD1", &val) || + !device_property_read_u32(dev, "realtek,jd1-gpio", &val)) + rt5677->pdata.jd1_gpio = val; + + if (!device_property_read_u32(dev, "JD2", &val) || + !device_property_read_u32(dev, "realtek,jd2-gpio", &val)) + rt5677->pdata.jd2_gpio = val; + + if (!device_property_read_u32(dev, "JD3", &val) || + !device_property_read_u32(dev, "realtek,jd3-gpio", &val)) + rt5677->pdata.jd3_gpio = val; } struct rt5677_irq_desc { @@ -5284,20 +5286,18 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) match_id = of_match_device(rt5677_of_match, &i2c->dev); if (match_id) rt5677->type = (enum rt5677_type)match_id->data; - - rt5677_read_device_properties(rt5677, &i2c->dev); } else if (ACPI_HANDLE(&i2c->dev)) { const struct acpi_device_id *acpi_id; acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev); if (acpi_id) rt5677->type = (enum rt5677_type)acpi_id->driver_data; - - rt5677_read_acpi_properties(rt5677, &i2c->dev); } else { return -EINVAL; } + 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 * isn't specified, devm_gpiod_get_optional returns NULL. -- 2.21.0.392.gf8f6787159e-goog