From patchwork Fri Feb 15 12:56:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14899 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 5470C23E01 for ; Fri, 15 Feb 2013 12:57:50 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by fiordland.canonical.com (Postfix) with ESMTP id EF544A1844A for ; Fri, 15 Feb 2013 12:57:49 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id b10so3002925vea.2 for ; Fri, 15 Feb 2013 04:57:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=L3CDjSBfb/q777k/XKsbsReHrTNZUiNYwEZd8YRXjjc=; b=CDIBAWsRhU1S2FXMJuyucHPWBJLvZejsDlMt2veGndG3JzSI2F7neIE828M4d+H6ou MWRi3Y96rwc9Cldy+8gQNhimSt5XTt36CmxW5Mwy0ppl+g5UUXzTeKdY6ez6Ah74UMur axcoID6R1oz2qw70F01MfgMsQyFcjLUw2g9gf0C4spOw3RTxn8U7JJ5Py+3EDyt5LWcm VDdLwc7zUWf5AEIYUsKYvbI7fwNeWfphs7rTcbzXp45VY5phh2jiDw71Tfj1Qu+rtogq 7e6402ORwBgiw7QXSRO4Fk6CG+oPlJPSxZJrnA7mRwNByzjqlgj5vnfixx4uaya+Q8Sc 2mVA== X-Received: by 10.221.0.79 with SMTP id nl15mr2924425vcb.41.1360933069499; Fri, 15 Feb 2013 04:57:49 -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.221.4.5 with SMTP id oa5csp11387vcb; Fri, 15 Feb 2013 04:57:49 -0800 (PST) X-Received: by 10.180.100.169 with SMTP id ez9mr5948768wib.3.1360933068630; Fri, 15 Feb 2013 04:57:48 -0800 (PST) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by mx.google.com with ESMTPS id uw8si3183271wjc.252.2013.02.15.04.57.48 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:57:48 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.46 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.46 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-f46.google.com with SMTP id fg15so2698540wgb.25 for ; Fri, 15 Feb 2013 04:57:48 -0800 (PST) X-Received: by 10.180.79.6 with SMTP id f6mr5697088wix.26.1360933068095; Fri, 15 Feb 2013 04:57:48 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id j4sm2852410wiz.10.2013.02.15.04.57.46 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:57:47 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sameo@linux.intel.com Cc: arnd@arndb.de, linus.walleij@stericsson.com, Marcus Danielsson , Lee Jones Subject: [PATCH 14/35] mfd: ab8500-sysctrl: Error check clean up Date: Fri, 15 Feb 2013 12:56:45 +0000 Message-Id: <1360933026-30325-15-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360933026-30325-1-git-send-email-lee.jones@linaro.org> References: <1360933026-30325-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnIpoI2i9/+f+XucMPC2O27Iv2RQ1VLsyXpMDMhWfxOwFCCK9N//0a4COn2kPq05ZmZ7fJw From: Marcus Danielsson Add error checks to see if sysctrl was probed as it should. If the sysctrl_dev is not set the return value is -EINVAL. Signed-off-by: Marcus Danielsson Signed-off-by: Lee Jones Reviewed-by: Mattias WALLIN Tested-by: Per FORLIN --- drivers/mfd/ab8500-sysctrl.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index 108fd86..ab6bfd3 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -28,6 +28,11 @@ void ab8500_power_off(void) struct power_supply *psy; int ret; + if (sysctrl_dev == NULL) { + pr_err("%s: sysctrl not initialized\n", __func__); + return; + } + /* * If we have a charger connected and we're powering off, * reboot into charge-only mode. @@ -85,7 +90,7 @@ int ab8500_sysctrl_read(u16 reg, u8 *value) u8 bank; if (sysctrl_dev == NULL) - return -EAGAIN; + return -EINVAL; bank = (reg >> 8); if (!valid_bank(bank)) @@ -101,7 +106,7 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value) u8 bank; if (sysctrl_dev == NULL) - return -EAGAIN; + return -EINVAL; bank = (reg >> 8); if (!valid_bank(bank)) @@ -116,31 +121,32 @@ static int ab8500_sysctrl_probe(struct platform_device *pdev) { struct ab8500_platform_data *plat; struct ab8500_sysctrl_platform_data *pdata; + int ret, i, j; - sysctrl_dev = &pdev->dev; plat = dev_get_platdata(pdev->dev.parent); + + if (!(plat && plat->sysctrl)) + return -EINVAL; + if (plat->pm_power_off) pm_power_off = ab8500_power_off; pdata = plat->sysctrl; - if (pdata) { - int ret, i, j; - for (i = AB8500_SYSCLKREQ1RFCLKBUF; - i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) { - j = i - AB8500_SYSCLKREQ1RFCLKBUF; - ret = ab8500_sysctrl_write(i, 0xff, - pdata->initial_req_buf_config[j]); - dev_dbg(&pdev->dev, + for (i = AB8500_SYSCLKREQ1RFCLKBUF; + i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) { + j = i - AB8500_SYSCLKREQ1RFCLKBUF; + ret = ab8500_sysctrl_write(i, 0xff, + pdata->initial_req_buf_config[j]); + dev_dbg(&pdev->dev, "Setting SysClkReq%dRfClkBuf 0x%X\n", j + 1, pdata->initial_req_buf_config[j]); - if (ret < 0) { - dev_err(&pdev->dev, - "unable to set sysClkReq%dRfClkBuf: " - "%d\n", j + 1, ret); - } + if (ret < 0) { + dev_err(&pdev->dev, + "unable to set sysClkReq%dRfClkBuf: " + "%d\n", j + 1, ret); } }