From patchwork Fri Jun 23 03:54:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhushan Shah X-Patchwork-Id: 9805553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8236C60349 for ; Fri, 23 Jun 2017 03:58:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D08528402 for ; Fri, 23 Jun 2017 03:58:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61216286AC; Fri, 23 Jun 2017 03:58:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E68328402 for ; Fri, 23 Jun 2017 03:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754160AbdFWD6Z (ORCPT ); Thu, 22 Jun 2017 23:58:25 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35056 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754137AbdFWD6Y (ORCPT ); Thu, 22 Jun 2017 23:58:24 -0400 Received: by mail-pf0-f193.google.com with SMTP id s66so5717597pfs.2; Thu, 22 Jun 2017 20:58:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uKR4YH7XhsPRQv4o9Mojf8jTR9fFPHyDDLWRNPZ+Gdk=; b=XFAqLs2ZEX478zcOd6nvnyOCubPOeOuC6EIZVUOHpehbvHD1CpBZaeSrMOTfFJ3jSW RrMPo6StqO1gccIJgvgUqtaMLAvUTicJ/ewrI8GFtvuV2xVxitgQ0uZz9ikzY2IlBHCd NNmQHUVIOw+y/RXd8lPSYpBVPeZgXCuCK9YQ7KvNZ0aVXDR0EQGU7VcVOa6druFqUk9C L8ZLdRsrQtvaCna3S67mtKEP7SrSWqqfJkcOfvp0QVXiwzdtQY2QN1VS+ev/h/GK38Ki 8kz4P9+8ixsLDhmhNXJjpcMUkW8eFHNgrhCQmurHxzKjJBhcu2rtbEFxLWdFWGgw4ojv /CnQ== X-Gm-Message-State: AKS2vOxKJnxFnH2jQ0kBBkcCTCz1T9Yr0WVLAllDP6vvAFiM3be146Ht JqpAT9kYPuCQ8w== X-Received: by 10.101.75.199 with SMTP id p7mr300310pgr.164.1498190303947; Thu, 22 Jun 2017 20:58:23 -0700 (PDT) Received: from localhost.localdomain ([123.201.91.13]) by smtp.gmail.com with ESMTPSA id k18sm978763pgf.5.2017.06.22.20.58.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 20:58:23 -0700 (PDT) From: Bhushan Shah To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bhushan Shah Subject: [PATCH v3] backlight: lm3630a: bump REG_MAX value to 0x50 instead of 0x1F Date: Fri, 23 Jun 2017 09:24:33 +0530 Message-Id: <20170623035433.3446-1-bshah@kde.org> X-Mailer: git-send-email 2.13.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the lm3630a_chip_init we try to write to 0x50 register, which is higher value then the max_register value, this resulted in regmap_write return -EIO. Fix this by bumping REG_MAX value to 0x50. This code was introduced with the chip revision in commit 28e64a68a2ef, however setting filter strength was failing silently because it used unsigned int for storing and comparing the return values. Bug related to signedness was fixed in 2a0c316bf3cc, which made it error out correctly instead of failing silently. I found this issue by using this driver on LGE Nexus 5 (hammerhead). After this commit lm3630a_chip_init succeeds instead of failing with -EIO. Fixes: 28e64a68a2ef ("backlight: lm3630: apply chip revision") Fixes: 2a0c316bf3cc ("drivers/video/backlight/lm3630a_bl.c: fix signedness bug in lm3630a_chip_init()") Signed-off-by: Bhushan Shah Suggested-by: Bjorn Andersson Reviewed-by: Daniel Thompson --- Changes since v2: - Include information about commits which introduced bug in commit message - Include information about test hardware in commit message - Expand define name to REG_FILTER_STRENGTH drivers/video/backlight/lm3630a_bl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 60d6c2ac87aa..2030a6b77a09 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -31,7 +31,8 @@ #define REG_FAULT 0x0B #define REG_PWM_OUTLOW 0x12 #define REG_PWM_OUTHIGH 0x13 -#define REG_MAX 0x1F +#define REG_FILTER_STRENGTH 0x50 +#define REG_MAX 0x50 #define INT_DEBOUNCE_MSEC 10 struct lm3630a_chip { @@ -80,7 +81,7 @@ static int lm3630a_chip_init(struct lm3630a_chip *pchip) usleep_range(1000, 2000); /* set Filter Strength Register */ - rval = lm3630a_write(pchip, 0x50, 0x03); + rval = lm3630a_write(pchip, REG_FILTER_STRENGTH, 0x03); /* set Cofig. register */ rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl); /* set boost control */