From patchwork Wed Nov 14 11:34:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12837 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 A5B7623DEA for ; Wed, 14 Nov 2012 11:35:04 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4F252A185DF for ; Wed, 14 Nov 2012 11:35:04 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so391312iej.11 for ; Wed, 14 Nov 2012 03:35:03 -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=dyJcpo/eJvILjJmuwZDjgFL13zl0YSZGJN2tfP5cG88=; b=lBn/d12QDwVt6XIdb8Naohex2/aOip0PsHit3VaRQAVJYSqytdluChyZt+HD7LJuS0 asqknudvCDbkKtmY2QTEWEsODMf7mVp7Wid9C9U/IEYzhuwvaGEnLgvcRpNNqGALDPQf 9AwmiQbQGXgZs/9/ngo9VINDebjhDccNMTbZbEIHEpXci3DC5gWcQEC5wgoTtDfiXtJJ zMJ3jDhYalBRu+9W14v8x8kI+YgwGveGzlIdN6Jcm2wlfHevTSJYaIAZna/JYKv1WfSa ZUPcfNCoJ/Ak+30OEy1sMHFxJ8yAPrafZivQ5I9QKr/vrYAidKabnWqD5Z63wJ0JmS/U 11Pw== Received: by 10.43.46.2 with SMTP id um2mr17041181icb.18.1352892903713; Wed, 14 Nov 2012 03:35:03 -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 n20csp646282igt; Wed, 14 Nov 2012 03:35:02 -0800 (PST) Received: by 10.216.197.65 with SMTP id s43mr1478637wen.41.1352892901711; Wed, 14 Nov 2012 03:35:01 -0800 (PST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by mx.google.com with ESMTPS id g47si6510535wep.42.2012.11.14.03.35.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 03:35:01 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.43 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.43; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.43 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-f43.google.com with SMTP id dq11so141852wgb.0 for ; Wed, 14 Nov 2012 03:35:01 -0800 (PST) Received: by 10.180.102.166 with SMTP id fp6mr25435835wib.9.1352892900972; Wed, 14 Nov 2012 03:35:00 -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 ec3sm10736324wib.10.2012.11.14.03.34.59 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 03:35:00 -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:34:48 +0000 Message-Id: <1352892888-15546-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnmpZBu0gBn5fLBPAxkuM7NOpYUsnMCgjrFRYXM2eFxTdMS+dMjW08Z5fsRnMMnr+Zl16xB 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..827fa70 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 you don't have 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..c82edab 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,