From patchwork Tue Jul 21 13:50:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AA0D39F380 for ; Tue, 21 Jul 2015 13:57:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD565206A0 for ; Tue, 21 Jul 2015 13:57:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C47DA2069A for ; Tue, 21 Jul 2015 13:57:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHY0Y-0006Wk-6Z; Tue, 21 Jul 2015 13:54:58 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXyA-0004jK-0g for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:31 +0000 Received: by wicgb10 with SMTP id gb10so56398451wic.1 for ; Tue, 21 Jul 2015 06:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=um7WbvyzAvRTUg9rhwGckT6TAAhH5aPEHFZ8klztKik=; b=y5OvZnQeYje3+3IkSwx/mLZVqfxd+tFNZCR964ORsNigMTO1yLzJYhM89FcLAAWWz+ 3kci4A7QpSpQ5BfaLtADptQa9J3gFi6EfjWmLGTPS8RA/QIVzGZGPK4GIRib+q2gMI2Z 0DK93MPlyZPZBoqmedW+iEvPX81ojx0UE3eGG9uOVQE1QTnlmUACi3d8Geh/vAFcNrA4 wSB8XdLB9bF3qaz2iBthB5BNlTlTmHGF0F5IMkzCYx/5NzIMoZdd8OWDfRZZUpBUuB3m N45lqhppmDjtHIwWQKq+5QAtYg9FSKA/ovbAZic+x1bWTwwmfWJrQcNrnJ0Tt9BWTCdP d36Q== X-Received: by 10.194.57.232 with SMTP id l8mr19411753wjq.48.1437486731150; Tue, 21 Jul 2015 06:52:11 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.52.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:52:10 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 15/16] tegra-max98090: Use devm_resource Date: Tue, 21 Jul 2015 15:50:57 +0200 Message-Id: <1437486658-28365-16-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_065230_240592_AE56077B X-CRM114-Status: GOOD ( 15.65 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tomeu Vizoso --- sound/soc/tegra/tegra_max98090.c | 69 +++++++++++++++------------------------- 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index 902da36581d1..e5767559aae7 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -41,8 +41,10 @@ struct tegra_max98090 { struct tegra_asoc_utils_data util_data; - int gpio_hp_det; - int gpio_mic_det; + struct gpio_desc *gpio_hp_det; + struct gpio_desc *gpio_mic_det; + struct fwnode_handle *codec_node; + struct fwnode_handle *cpu_node; }; static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, @@ -147,27 +149,29 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) { struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); - if (gpio_is_valid(machine->gpio_hp_det)) { + if (machine->gpio_hp_det) { snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE, &tegra_max98090_hp_jack, tegra_max98090_hp_jack_pins, ARRAY_SIZE(tegra_max98090_hp_jack_pins)); - tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; + tegra_max98090_hp_jack_gpio.gpio = + desc_to_gpio(machine->gpio_hp_det); snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, 1, &tegra_max98090_hp_jack_gpio); } - if (gpio_is_valid(machine->gpio_mic_det)) { + if (machine->gpio_mic_det) { snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, &tegra_max98090_mic_jack, tegra_max98090_mic_jack_pins, ARRAY_SIZE(tegra_max98090_mic_jack_pins)); - tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; + tegra_max98090_mic_jack_gpio.gpio = + desc_to_gpio(machine->gpio_mic_det); snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, 1, &tegra_max98090_mic_jack_gpio); @@ -180,12 +184,12 @@ static int tegra_max98090_card_remove(struct snd_soc_card *card) { struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); - if (gpio_is_valid(machine->gpio_hp_det)) { + if (machine->gpio_hp_det) { snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, &tegra_max98090_hp_jack_gpio); } - if (gpio_is_valid(machine->gpio_mic_det)) { + if (machine->gpio_mic_det) { snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1, &tegra_max98090_mic_jack_gpio); } @@ -218,31 +222,14 @@ static struct snd_soc_card snd_soc_tegra_max98090 = { static int tegra_max98090_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; struct snd_soc_card *card = &snd_soc_tegra_max98090; - struct tegra_max98090 *machine; + struct tegra_max98090 *machine = platform_get_drvdata(pdev); int ret; - machine = devm_kzalloc(&pdev->dev, - sizeof(struct tegra_max98090), GFP_KERNEL); - if (!machine) { - dev_err(&pdev->dev, "Can't allocate tegra_max98090\n"); - return -ENOMEM; - } - card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); - machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); - if (machine->gpio_hp_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - - machine->gpio_mic_det = - of_get_named_gpio(np, "nvidia,mic-det-gpios", 0); - if (machine->gpio_mic_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) goto err; @@ -251,24 +238,8 @@ static int tegra_max98090_probe(struct platform_device *pdev) if (ret) goto err; - tegra_max98090_dai.codec_of_node = of_parse_phandle(np, - "nvidia,audio-codec", 0); - if (!tegra_max98090_dai.codec_of_node) { - dev_err(&pdev->dev, - "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; - } - - tegra_max98090_dai.cpu_of_node = of_parse_phandle(np, - "nvidia,i2s-controller", 0); - if (!tegra_max98090_dai.cpu_of_node) { - dev_err(&pdev->dev, - "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; - } - + tegra_max98090_dai.codec_of_node = to_of_node(machine->codec_node); + tegra_max98090_dai.cpu_of_node = to_of_node(machine->cpu_node); tegra_max98090_dai.platform_of_node = tegra_max98090_dai.cpu_of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); @@ -307,11 +278,21 @@ static const struct of_device_id tegra_max98090_of_match[] = { {}, }; +static const struct devm_resource tegra_max98090_resources[] = { + DEVM_ALLOC(tegra_max98090), + DEVM_GPIO_NAMED(tegra_max98090, gpio_hp_det, "nvidia,hp-det"), + DEVM_GPIO_NAMED(tegra_max98090, gpio_mic_det, "nvidia,mic-det"), + DEVM_FWNODE(tegra_max98090, codec_node, "nvidia,audio-codec"), + DEVM_FWNODE(tegra_max98090, cpu_node, "nvidia,i2s-controller"), + {}, +}; + static struct platform_driver tegra_max98090_driver = { .driver = { .name = DRV_NAME, .pm = &snd_soc_pm_ops, .of_match_table = tegra_max98090_of_match, + .resources = tegra_max98090_resources, }, .probe = tegra_max98090_probe, .remove = tegra_max98090_remove,