Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1237247ybe; Wed, 11 Sep 2019 11:32:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkHugTAyyuFwXDDxn9n++E9nnZ5q8eRi40kG6+BepMGbPVlwo9ILbgAMfoQZNhLKPxo4ro X-Received: by 2002:a17:906:b298:: with SMTP id q24mr26838100ejz.93.1568226741343; Wed, 11 Sep 2019 11:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568226741; cv=none; d=google.com; s=arc-20160816; b=FoO3TVB/pU26lJcFfBW6l62iPt2ZXWnRSYMoQnyc0S7Y1G7h5vamLzudkwuVjqlv1m e1MtA1Y3ay7gXHCqovE8xQHhiFuvEGtjsTZialZhNzVAlFvzDdkTAV5dQHZK3NBntsgz myz8MkE/aYd0Lg2tqDCLL9LgkC4Iv0orml56atS+qR+1kkan2xbSDcl8/l9K0DkW2XPn +BpRd3FZQA+cqNHeP5YwRsk5ZX0O+T/c4Cze4Jr0U2NTSlL1hzhQf4/+ISCCjEqE/+2z 40xIidJNge2K/PTCEUgOwRvx0V58n9xTjjOI7cOGjJ4DB35KSK/BpVQhe5OtYiSVZjM/ /KpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AeW/DYP1zkaB9/BB4ZesrqQm2k+eZeF9Bifc81J4frk=; b=J5hvJES11THBuiUI8guIum5Z0ynHNwNPeKMwERj3gc8X+SHjPusSIKfJek4Wddt/Zy LaIJOEmfq4H7OuSerHJK9CI27RF4/lRUFjh0/jLGb+NkRTJ9aeWCaGIlmBtgFy0ZfMLK 1bAKtyB5K7HB9ttRrdWqcc96Y6Ieyjrw8FiprF/PDpEPJ8dyohPMzAOj/6i5fd60VKpv NGCux5jSIa22R0SurLcP/jzA9kk1atO2D7uXuNAJ5EpY1tbNF7b0rhMto0tlIipWs9XH 6JtH4sjqV3rxJNFp3WIyoPvuXOFZA3DV2F22aHrd0qswbQDnTQUiymc9WAc/xm13LZSL AXyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RPozfMIZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si11459442ejb.5.2019.09.11.11.31.57; Wed, 11 Sep 2019 11:32:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RPozfMIZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730026AbfIKS1g (ORCPT + 99 others); Wed, 11 Sep 2019 14:27:36 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:59228 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729758AbfIKS1f (ORCPT ); Wed, 11 Sep 2019 14:27:35 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8BIRWOh007757; Wed, 11 Sep 2019 13:27:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568226452; bh=AeW/DYP1zkaB9/BB4ZesrqQm2k+eZeF9Bifc81J4frk=; h=From:To:CC:Subject:Date; b=RPozfMIZ2vDTQYaxoPOFnOcEnciwqNCZ7cTzn4KcF5ddsRPOW4oWLJM6/HG0MXcB7 +pc0BxiBQXXihGDUog4Er0XNIDvZnZlb6MLeOZIJpXuNj723b845oRRW83Jzv013vw CvJyslAAtNRMAKO5H4A0Sbkhi/rWce3xyY+pUd8M= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8BIRWuM038829 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Sep 2019 13:27:32 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 11 Sep 2019 13:27:31 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 11 Sep 2019 13:27:31 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8BIRVEN099700; Wed, 11 Sep 2019 13:27:31 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v2] leds: lm3532: Fix optional led-max-microamp prop error handling Date: Wed, 11 Sep 2019 13:27:30 -0500 Message-ID: <20190911182730.22409-1-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the error handling for the led-max-microamp property. Need to check if the property is present and then if it is retrieve the setting and its max boundary Reported-by: Pavel Machek Signed-off-by: Dan Murphy --- v2 - Changed full scale current check to use min function drivers/leds/leds-lm3532.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 62ace6698d25..a1742dc1f6fa 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -601,11 +601,15 @@ static int lm3532_parse_node(struct lm3532_data *priv) goto child_out; } - ret = fwnode_property_read_u32(child, "led-max-microamp", - &led->full_scale_current); - - if (led->full_scale_current > LM3532_FS_CURR_MAX) - led->full_scale_current = LM3532_FS_CURR_MAX; + if (fwnode_property_present(child, "led-max-microamp")) { + if (fwnode_property_read_u32(child, "led-max-microamp", + &led->full_scale_current)) + dev_err(&priv->client->dev, + "Failed getting led-max-microamp\n"); + else + min(led->full_scale_current, + LM3532_FS_CURR_MAX); + } if (led->mode == LM3532_BL_MODE_ALS) { led->mode = LM3532_ALS_CTRL; -- 2.22.0.214.g8dca754b1e