From patchwork Wed Nov 14 11:51:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12838 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 D6A3423DEA for ; Wed, 14 Nov 2012 11:51:46 +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 868EEA18D94 for ; Wed, 14 Nov 2012 11:51:46 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so197363iag.11 for ; Wed, 14 Nov 2012 03:51:45 -0800 (PST) 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=9y0+VQPA3rf2h1dZMjCXlmqnaBtV2jBdXx6vKMrgnDk=; b=Rvo1pjgLd5y9OANQcMb/w8F2JNlDVJP+cdbL7OAskSMDK9Y3vzV6QTzrf56ARz3lkO J0QITSdwSKPZWnqJVXcGkqiXvfLNdb3YLliAeUZLNBJw5SuVk4pjDbenR640xxNlr9ag Zl5TiL5p13H4tAT9MTL+4Z3+6/sstsGe9qvXFsQWMVsxK39EK4uIbQfEluzLxV8xH0Qz xUxseFOtxgB9TP9HFXfimpxZQ5vSIOD76jUIlAy8sjCHG6kiVDz9pmoOccZr1L7EuFCd FNpQanWoAefex2OSoS1k8sJgduNtz81BxFdV+A412+V5f828s1Bq4fil/I0YIxyEZ06S c33w== Received: by 10.50.173.34 with SMTP id bh2mr1453519igc.70.1352893905853; Wed, 14 Nov 2012 03:51:45 -0800 (PST) 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 n20csp648051igt; Wed, 14 Nov 2012 03:51:44 -0800 (PST) Received: by 10.216.201.140 with SMTP id b12mr1548458weo.223.1352893904091; Wed, 14 Nov 2012 03:51:44 -0800 (PST) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by mx.google.com with ESMTPS id u12si6523874wed.45.2012.11.14.03.51.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 03:51:43 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.44 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.44; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.44 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-wg0-f44.google.com with SMTP id dr13so134716wgb.13 for ; Wed, 14 Nov 2012 03:51:42 -0800 (PST) Received: by 10.216.140.131 with SMTP id e3mr1567782wej.134.1352893902076; Wed, 14 Nov 2012 03:51:42 -0800 (PST) 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 az2sm22930517wib.7.2012.11.14.03.51.40 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 03:51:41 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: Lee Jones , Mark Brown , Frank Li Subject: [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse Date: Wed, 14 Nov 2012 11:51:36 +0000 Message-Id: <1352893896-15956-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmQIuwzf5cIMBN0w29mi21LVY6Xis+Qg6vzqiwXi9Eb9YVug00KvAeHGMnUT+RyVmVLJ+b0 A selection of voltage or current values (AKA states) should always be specified when using a GPIO regulator. If there are no switchable states then the fixed regulators should be used instead. Cc: Mark Brown Cc: Frank Li Signed-off-by: Lee Jones --- .../bindings/regulator/gpio-regulator.txt | 3 ++- drivers/regulator/gpio-regulator.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt index 3703be2..51527c6 100644 --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt @@ -2,11 +2,12 @@ GPIO controlled regulators Required properties: - compatible : Must be "regulator-gpio". +- states : Selection of available voltages and GPIO configs. + if there are no states, then use a fixed regulator Optional properties: - gpio-enable : GPIO to use to enable/disable the regulator. - gpios : GPIO group used to control voltage. -- states : Selection of available voltages and GPIO configs. - startup-delay-us : Startup time in microseconds. - enable-active-high : Polarity of GPIO is active high (default is low). diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index e467d0a..a7a2974 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -183,6 +183,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) /* Fetch states. */ prop = of_find_property(np, "states", NULL); + if (!prop) { + dev_err(dev, "No 'states' property found\n"); + return ERR_PTR(-EINVAL); + } + proplen = prop->length / sizeof(int); config->states = devm_kzalloc(dev,