From patchwork Mon Dec 12 22:55:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 130945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AA6DC1007D7 for ; Tue, 13 Dec 2011 09:55:45 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751750Ab1LLWzo (ORCPT ); Mon, 12 Dec 2011 17:55:44 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:38202 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751821Ab1LLWzo (ORCPT ); Mon, 12 Dec 2011 17:55:44 -0500 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 0F83661EA; Mon, 12 Dec 2011 15:59:26 -0700 (MST) Received: from localhost.localdomain (searspoint.nvidia.com [216.228.112.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id D861BE40F5; Mon, 12 Dec 2011 15:55:41 -0700 (MST) From: Stephen Warren To: Mark Brown , Liam Girdwood Cc: alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org, Stephen Warren Subject: [PATCH v4 1/3] ASoC: Add utility to set a card's name from device tree Date: Mon, 12 Dec 2011 15:55:34 -0700 Message-Id: <1323730536-19915-1-git-send-email-swarren@nvidia.com> X-Mailer: git-send-email 1.7.0.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Implement snd_soc_of_parse_card_name(), a utility function that sets a card's name from device tree. The machine driver specifies the DT property to use, since this is binding-specific. Signed-off-by: Stephen Warren --- This series is based on my previously posted patch "ASoC: Allow DAI links to be specified using device tree nodes" v4. Patches 1 & 2 at most rely on that for context. Patch 3 relies on it for functionality. v2: New patch implementing new functionality v3: Name this embedded-audio-complex instead of soc-audio-complex. Change property name from user-visible-name to model. Remove compatible property from binding. v4: Convert this to a utility function that cards can call if desired. Modify snd_soc_register_card() not to call this automatically. Allow cards to specify the name of the device tree property that stores that card's name. Don't specify the property as a generic binding; remove embedded-audio-complex.txt include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 40c256e..6e51a3f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -966,6 +966,9 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) int snd_soc_util_init(void); void snd_soc_util_exit(void); +int snd_soc_of_parse_card_name(struct snd_soc_card *card, + const char *propname); + #include #ifdef CONFIG_DEBUG_FS diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 83aa82e..4e8d762 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -3367,6 +3368,30 @@ found: } EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); +/* Retrieve a card's name from device tree */ +int snd_soc_of_parse_card_name(struct snd_soc_card *card, + const char *propname) +{ + struct device_node *np = card->dev->of_node; + int ret; + + ret = of_property_read_string_index(np, propname, 0, &card->name); + /* + * EINVAL means the property does not exist. This is fine providing + * card->name was previously set, which is checked later in + * snd_soc_register_card. + */ + if (ret < 0 && ret != -EINVAL) { + dev_err(card->dev, + "Property '%s' could not be read: %d\n", + propname, ret); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name); + static int __init snd_soc_init(void) { #ifdef CONFIG_DEBUG_FS