From patchwork Thu Sep 6 12:12:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1413901 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 4B5933FC85 for ; Thu, 6 Sep 2012 12:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352Ab2IFMQm (ORCPT ); Thu, 6 Sep 2012 08:16:42 -0400 Received: from na3sys009aog119.obsmtp.com ([74.125.149.246]:33141 "EHLO na3sys009aog119.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752803Ab2IFMMP (ORCPT ); Thu, 6 Sep 2012 08:12:15 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob119.postini.com ([74.125.148.12]) with SMTP ID DSNKUEiTHliGZ/M0OIG7++k8IoHy76yd6k/t@postini.com; Thu, 06 Sep 2012 05:12:14 PDT Received: by obbuo13 with SMTP id uo13so2296601obb.19 for ; Thu, 06 Sep 2012 05:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=IyYktOvm7q4KFiomWbkhyBhznGLr99prbGM0rbusnpU=; b=m1HGxdHADly8w5fwvHMF0CAr+KPe3oPdLgNcdDaLp716ijE3hBYkb5nJLMMmnvevbx e17KM2uVDYWkCE9vVfOYr8nbOD/MWWGY+Lmk41hsEE9SEDchJBMoRMHyjFMJJUbJc3Of EPet2mshmZOZrlOkB2kKD+lSAnpN5lTUOVzSR8TSF3g4JrQI2cj95nE29JzVaxpcWCAs wSMZ8WIoDjcI6vT7l5zbypzFqAX6EAvIeKrzlVLCmi5xJyRPLDRrkeA5j3n1XbPB3eaA 4HiuOgTVw24ZFI95XGZnqUS51m+Ujqu44/be/NkxPQD4LkdKm6Twh+Z02aS+RSjoR90I WBBA== Received: by 10.60.30.201 with SMTP id u9mr1671439oeh.51.1346933533758; Thu, 06 Sep 2012 05:12:13 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id zn9sm1795856obb.23.2012.09.06.05.12.10 (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 05:12:13 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Samuel Ortiz , Dmitry Torokhov , Grant Likely , Rob Herring Cc: Tero Kristo , alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org, Benoit Cousson , linux-kernel@vger.kernel.org Subject: [PATCH v3 03/14] MFD: twl4030-audio: Rearange and clean-up the probe function Date: Thu, 6 Sep 2012 15:12:10 +0300 Message-Id: <1346933541-21547-4-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1346933541-21547-1-git-send-email-peter.ujfalusi@ti.com> References: <1346933541-21547-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQmfrcaJRKdisI8UMv0nk3Mj2QbHiwS0KD3qnTdjfGotR5LhS8f96jNKCUaJi5FtKwiRlT10 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org To facilitate the device tree support the probe function need to be rearanged. Small cleanup in the APLL frequency selection part as well. Signed-off-by: Peter Ujfalusi --- drivers/mfd/twl4030-audio.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c index efa2d42..ca2d669 100644 --- a/drivers/mfd/twl4030-audio.c +++ b/drivers/mfd/twl4030-audio.c @@ -169,35 +169,30 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) return -EINVAL; } + audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio), + GFP_KERNEL); + if (!audio) + return -ENOMEM; + + mutex_init(&audio->mutex); + audio->audio_mclk = pdata->audio_mclk; + /* Configure APLL_INFREQ and disable APLL if enabled */ - val = 0; - switch (pdata->audio_mclk) { + switch (audio->audio_mclk) { case 19200000: - val |= TWL4030_APLL_INFREQ_19200KHZ; + val = TWL4030_APLL_INFREQ_19200KHZ; break; case 26000000: - val |= TWL4030_APLL_INFREQ_26000KHZ; + val = TWL4030_APLL_INFREQ_26000KHZ; break; case 38400000: - val |= TWL4030_APLL_INFREQ_38400KHZ; + val = TWL4030_APLL_INFREQ_38400KHZ; break; default: dev_err(&pdev->dev, "Invalid audio_mclk\n"); return -EINVAL; } - twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, - val, TWL4030_REG_APLL_CTL); - - audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio), - GFP_KERNEL); - if (!audio) - return -ENOMEM; - - platform_set_drvdata(pdev, audio); - - twl4030_audio_dev = pdev; - mutex_init(&audio->mutex); - audio->audio_mclk = pdata->audio_mclk; + twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, val, TWL4030_REG_APLL_CTL); /* Codec power */ audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE; @@ -222,6 +217,9 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) childs++; } + platform_set_drvdata(pdev, audio); + twl4030_audio_dev = pdev; + if (childs) ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells, childs, NULL, 0);