From patchwork Thu Oct 30 11:20:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5196231 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5D2CEC11AC for ; Thu, 30 Oct 2014 11:26:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2673620266 for ; Thu, 30 Oct 2014 11:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68DCF2024F for ; Thu, 30 Oct 2014 11:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759112AbaJ3L0I (ORCPT ); Thu, 30 Oct 2014 07:26:08 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:59728 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759113AbaJ3LVZ (ORCPT ); Thu, 30 Oct 2014 07:21:25 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE9007FI90EG770@mailout3.w1.samsung.com>; Thu, 30 Oct 2014 11:24:14 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-3c-54521f32cbf1 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id AF.AF.04619.23F12545; Thu, 30 Oct 2014 11:21:22 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NE9009H68VFGU90@eusync3.samsung.com>; Thu, 30 Oct 2014 11:21:22 +0000 (GMT) From: Krzysztof Kozlowski To: Samuel Ortiz , Lee Jones , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, Ben Dooks , Kukjin Kim , Russell King , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Cc: Kyungmin Park , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas , Chanwoo Choi , Krzysztof Kozlowski Subject: [RFT v3 05/14] regulator: max77802: Don't ignore return value of current opmode Date: Thu, 30 Oct 2014 12:20:44 +0100 Message-id: <1414668053-31370-6-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1414668053-31370-1-git-send-email-k.kozlowski@samsung.com> References: <1414668053-31370-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsVy+t/xq7pG8kEhBs/XcFhsnLGe1WLSugNM FlMfPmGzuP7lOavF/CPnWC2O/i6weP3C0KJ3wVU2i7NNb9gt7n89ymjx7UoHk8Wmx9dYLS7v msNmMeP8PiaL25d5LdYeuctucbqb1UHQo6W5h83j7/PrLB5/V71g9tg56y67x6ZVnWwed67t YfOYdzLQY/OSeo++LasYPT5vkgvgiuKySUnNySxLLdK3S+DK6D+5k71gFmdF06OFLA2MB9i7 GDk5JARMJI7fnsYGYYtJXLi3Hsjm4hASWMoo0TP3CyOE08ckMf1bNwtIFZuAscTm5UvAqkQE Opkleg72MoM4zAKrmSR+XjkF5HBwCAtESTzcKwTSwCKgKjF5/T+wFbwC7hJ7lq6BWi0ncfLY ZFYQm1PAQ2LNx3ZWkFYhoJp737QnMPIuYGRYxSiaWppcUJyUnmuoV5yYW1yal66XnJ+7iRES 4F92MC4+ZnWIUYCDUYmH12FjQIgQa2JZcWXuIUYJDmYlEd7VYkEhQrwpiZVVqUX58UWlOanF hxiZODilGhiVNtncU3XjS581QevqRFFf+3mt5QrnSqIC9l4qY41N0z4lxaNlGvCk2vDGnW+H 6mZW8BRPjW6MEpld/6H4u8e3a/MWJR7NS7baxuKdHvrU6tkt9y2vu9ZGXy5uEWFRmXNR5Pfn J6/Slx5w/b9tdZv22VcvReatkZtR7MSsuyTuWppC5KZTGZOUWIozEg21mIuKEwG2MnSwTgIA AA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The return value of regmap_read() of current opmode for regulator was silently ignored and whatever happened to be in 'val' variable was used as new opmode. This could lead to using bogus opmode. Don't ignore what regmap_read() returns. If it fails just fall back to normal opmode. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas --- drivers/regulator/max77802.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index b9958d927297..60daca2028e9 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -606,7 +606,13 @@ static int max77802_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); - val = val >> shift & MAX77802_OPMODE_MASK; + if (ret < 0) { + dev_warn(&pdev->dev, + "cannot read current mode for %d\n", i); + val = MAX77802_OPMODE_NORMAL; + } else { + val = val >> shift & MAX77802_OPMODE_MASK; + } /* * If the regulator is disabled and the system warm rebooted,