From patchwork Thu Dec 1 20:49:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 128763 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 4E6D0B6F6B for ; Fri, 2 Dec 2011 07:49:37 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753625Ab1LAUtg (ORCPT ); Thu, 1 Dec 2011 15:49:36 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:49887 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606Ab1LAUtf (ORCPT ); Thu, 1 Dec 2011 15:49:35 -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 C816D630C; Thu, 1 Dec 2011 13:52:43 -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 4CDB4E40F4; Thu, 1 Dec 2011 13:49:32 -0700 (MST) From: Stephen Warren To: Mark Brown , Liam Girdwood Cc: Rob Herring , John Bonesio , alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Stephen Warren Subject: [PATCH v3 1/6] ASoC: WM8903: Disallow all invalid gpio_cfg pdata values Date: Thu, 1 Dec 2011 13:49:19 -0700 Message-Id: <1322772564-27343-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 The GPIO registers are 15 bits wide. Hence values, higher than 0x7fff are not legal GPIO register values. Modify the pdata.gpio_cfg handling code to reject all illegal values, not just WM8903_GPIO_NO_CONFIG (0x8000). This will allow the later use of 0xffffffff as an invalid value in future device tree bindings, meaning "don't touch this GPIO's configuration". Signed-off-by: Stephen Warren --- sound/soc/codecs/wm8903.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 70a2268..0d1640e 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1936,11 +1936,11 @@ static int wm8903_probe(struct snd_soc_codec *codec) bool mic_gpio = false; for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) { - if (pdata->gpio_cfg[i] == WM8903_GPIO_NO_CONFIG) + if (pdata->gpio_cfg[i] > 0x7fff) continue; snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i, - pdata->gpio_cfg[i] & 0xffff); + pdata->gpio_cfg[i] & 0x7fff); val = (pdata->gpio_cfg[i] & WM8903_GP1_FN_MASK) >> WM8903_GP1_FN_SHIFT;