From patchwork Mon Oct 15 13:13:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12229 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 789CD23F9B for ; Mon, 15 Oct 2012 13:13:35 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1DFD3A1887D for ; Mon, 15 Oct 2012 13:13:35 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so3592959iag.11 for ; Mon, 15 Oct 2012 06:13:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=yGwdR0wQlfy+15N3lYm9U91rQQS8UbwRQVrmqtH90wg=; b=QtVgqynprxRC1BeDTDVTrTsJchOHfeZ0wvQk2AYk1tPA/Kcqw3o7JObApCTsORwIUR O8QUcViriZzMTLiQDdwL+gKtiSsR/CM8OmgFIqSQ5kx13udKeRp5n/OXg+PoiAReNA8C i1ZHjDtIA5VxaDmlF9zBD0yJROxKwB0+IANtEIAYrijENJfG6uzYFZqf+GnltDB009cH GIbKZb/bePgC//DnjN3xNeOLjLiS9A6TtvQdmmn0lOczm5jku0wycbyvjWMzve+so07g +Z1mEjGQAlMIt+Yb5nnrSyu63cuYt1hOjBoRpntk35p6VFpo83342JjcwyTjtY48RJML UadQ== Received: by 10.50.100.137 with SMTP id ey9mr8558297igb.57.1350306814468; Mon, 15 Oct 2012 06:13:34 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp572545igt; Mon, 15 Oct 2012 06:13:33 -0700 (PDT) Received: by 10.180.82.35 with SMTP id f3mr23800364wiy.6.1350306812931; Mon, 15 Oct 2012 06:13:32 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id c28si16741476wej.88.2012.10.15.06.13.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 06:13:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f178.google.com with SMTP id hr7so1669400wib.13 for ; Mon, 15 Oct 2012 06:13:32 -0700 (PDT) Received: by 10.180.77.34 with SMTP id p2mr23834633wiw.0.1350306812184; Mon, 15 Oct 2012 06:13:32 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id dm3sm15817436wib.3.2012.10.15.06.13.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 06:13:31 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , alsa-devel@alsa-project.org, Liam Girdwood , Mark Brown Subject: [PATCH 1/2] ASoC: Ux500: Dispose of device nodes correctly Date: Mon, 15 Oct 2012 14:13:25 +0100 Message-Id: <1350306806-5688-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnZf44hyPsmSFJJ3NA8vgHJfAEIIyI9lgXZKIt1F3ooFk7EJEbmy3tHfqBfQXWM7QykAaJk When of_parse_phandle() is used to find a device node, its reference count is incremented by the helper. Once we're finished with them, it's our responsibly to ensure they are freed in the correct manor. Cc: alsa-devel@alsa-project.org Cc: Liam Girdwood Cc: Mark Brown Acked-by: Linus Walleij Signed-off-by: Lee Jones --- sound/soc/ux500/mop500.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index 6f67e6b..651a52a 100644 --- a/sound/soc/ux500/mop500.c +++ b/sound/soc/ux500/mop500.c @@ -57,6 +57,20 @@ static struct snd_soc_card mop500_card = { .num_links = ARRAY_SIZE(mop500_dai_links), }; +static void mop500_of_node_put(void) +{ + int i; + + for (i = 0; i < 2; i++) { + if (mop500_dai_links[i].cpu_of_node) + of_node_put((struct device_node *) + mop500_dai_links[i].cpu_of_node); + if (mop500_dai_links[i].codec_of_node) + of_node_put((struct device_node *) + mop500_dai_links[i].codec_of_node); + } +} + static int __devinit mop500_of_probe(struct platform_device *pdev, struct device_node *np) { @@ -69,6 +83,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev, if (!(msp_np[0] && msp_np[1] && codec_np)) { dev_err(&pdev->dev, "Phandle missing or invalid\n"); + mop500_of_node_put(); return -EINVAL; } @@ -83,6 +98,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev, return 0; } + static int __devinit mop500_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -128,6 +144,7 @@ static int __devexit mop500_remove(struct platform_device *pdev) snd_soc_unregister_card(mop500_card); mop500_ab8500_remove(mop500_card); + mop500_of_node_put(); return 0; }