Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1813177pxb; Mon, 13 Sep 2021 06:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ7jEwihF4WiPtPRyw7JV7DhitTEa+UWR+sqInuBwLVAFoUDYsINUW0eWZIC/l7V6FCjfC X-Received: by 2002:a02:9204:: with SMTP id x4mr9632135jag.45.1631538627987; Mon, 13 Sep 2021 06:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631538627; cv=none; d=google.com; s=arc-20160816; b=s0veIZF927Su0FHAshvs5sLMQX9D/myyCpVpe1j9w2+rYkbWc9HjN5uThZJ7bt0oHt pOdaXWD75VZKscL9goNV0fbufphpvSXPiKPR/AkVxWXySOIIFqs4SJVhG+aujReSOBz3 RaZ97MScirr25/kPOBREFRECLxDH2mhfH/y3Zq5ewPtfYdAgZTHJI1r48KkT99xEbqvH /KJEEQmqcbqWzNd62O6IGz8G5Zd4oYl/iIduoxaz54YWzHTSjPYVHWQ9JCMCG7ibHir7 3HOR9s05ppdLEG/WN9C4AaWmYDMzCXoag3tDCD5kUHvwnEajNiQvCb2qxWFjmiLZiOKI 4oIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=snqO+zpJPkBw6zZQNVMY27Q3942wUhbd/kP+elYWU54=; b=YK6xNrdwOmzbEF99o4BRG1TLq17Jj1XgtBFD0ki4+t5lg1uFlQzZf0bhhRU+TfMBeK hIu6WC/ucdfXyfqx+8HHMRAVL81SEK3crZxxYsf7k4Q6y3Y1n7IXJxN0A4+w+VBfTGCC DXO5MckeeVVYtw3xM1YW5x3DN7CAHwZCoAlwstZaWVJ9i5z5XzARN4r0VFOPOplM3JuF kbRt9Qz2/j73jwegJ13JdwnOZc8kH6ruqHIe1mz9nvC36nsfYtTJ5chMC9iKuWeHTNGu tzZhsn2o92/6WMMDnCxAWd5wU87AFvdR3105Y6jKgNMRwG5vyZZfOx6By5cJCzUhAk4f S3HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=hQTpWxCe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si6207498jaf.107.2021.09.13.06.10.15; Mon, 13 Sep 2021 06:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=hQTpWxCe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234951AbhIMNJW (ORCPT + 99 others); Mon, 13 Sep 2021 09:09:22 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:33228 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237538AbhIMNHi (ORCPT ); Mon, 13 Sep 2021 09:07:38 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B3FC240269 for ; Mon, 13 Sep 2021 13:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631538381; bh=snqO+zpJPkBw6zZQNVMY27Q3942wUhbd/kP+elYWU54=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=hQTpWxCeeh5J29mXlTU3P8KIYs/Hl90OezAM8s30s93yiVe0+i7uVXmrV0haJHKIz niPM2FuT7LZSrdhJMo6v0DdQgB9Ml1Prs9kYI5OUzfZDSLRSDBDGMuEORHr8lv6N2O 3R9gPnvH1GfUienuOA2ruqI5cl2MHmB55roRg9EQbgl3+tIhbu2lXoeJMXILmTGu12 P57LI5/Y4uXmHNn/mOIuzZ11zyE7RdESRXlhHbH1yyctQ808PYDt2D/ZlP0zafJCst aHQEWex8YA1KxxgmJJCYfNDRNSydTmmcdPPbIR8okYFwHMIu2sJ2ObJvRnE1YjgTmq 70umV3SuuPwKg== Received: by mail-wm1-f69.google.com with SMTP id 5-20020a1c00050000b02902e67111d9f0so4895629wma.4 for ; Mon, 13 Sep 2021 06:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=snqO+zpJPkBw6zZQNVMY27Q3942wUhbd/kP+elYWU54=; b=Njj8nA0SehIlg0AtXAjhV6AZtfl5wVaSuC37B4duCiGH3KT94vX0HsarPgBnR2SX1/ UD9lfaAbkDUao1FZzOS4kOKkBbl0eMgQeaBbkSbETiw63U43NLcEGFC3Xo6vTOKImQzs gZKO+WfMl8y8yIQUnDNzSjB3QA3N+CdgGScKZSZF0mP9j9rbYaWTdiFN8oW6ql9+pUsZ DjrNMhnqFxJUrWeggWy4bjId7AruzYmlp+YxUNYqzuxjci+TVgHwuTfKi2VQKaJAJ8bd m8KRZaeEYcJJ6NxIxpzNPnzQuYa1oDg8VyqA/MFeN4YaqiRi+UpsX88kIX+fFsjPOu/r S/qw== X-Gm-Message-State: AOAM533/OrspQog9Zsw8Dnz9LrRHc3tNHTc8yubQXrW9COR5mJjlFWpV R8En4HoTMoD1UHaIPn2KBIpr7VU3NdwzJLmwLuPYCs1+hG/4fFEX9ObY1PFAgoFTjfZpDAUZmbc LSEuQqvLTUdg49XLZfFlfP3ludvXzd4T9iVbuQWaBaQ== X-Received: by 2002:adf:e684:: with SMTP id r4mr5333340wrm.229.1631538381348; Mon, 13 Sep 2021 06:06:21 -0700 (PDT) X-Received: by 2002:adf:e684:: with SMTP id r4mr5333323wrm.229.1631538381171; Mon, 13 Sep 2021 06:06:21 -0700 (PDT) Received: from [192.168.3.211] (lk.84.20.244.219.dc.cable.static.lj-kabel.net. [84.20.244.219]) by smtp.gmail.com with ESMTPSA id q19sm2279358wmq.29.2021.09.13.06.05.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Sep 2021 06:06:00 -0700 (PDT) Subject: Re: [PATCH 2/2] power: supply: max17042_battery: Prevent int underflow in set_soc_threshold To: Sebastian Krzyszkowiak , Sebastian Reichel , linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Anton Vorontsov , Ramakrishna Pallala , Dirk Brandewie , stable@vger.kernel.org References: <20210912205402.160939-1-sebastian.krzyszkowiak@puri.sm> <20210912205402.160939-2-sebastian.krzyszkowiak@puri.sm> From: Krzysztof Kozlowski Message-ID: <82021f13-f535-1535-4af9-80bef81fbde5@canonical.com> Date: Mon, 13 Sep 2021 15:05:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210912205402.160939-2-sebastian.krzyszkowiak@puri.sm> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/09/2021 22:54, Sebastian Krzyszkowiak wrote: > Fixes: e5f3872d2044 ("max17042: Add support for signalling change in SOC") You need commit and bug description. > Cc: > Signed-off-by: Sebastian Krzyszkowiak > --- > drivers/power/supply/max17042_battery.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c > index c53980c8432a..caf83b4d622f 100644 > --- a/drivers/power/supply/max17042_battery.c > +++ b/drivers/power/supply/max17042_battery.c > @@ -857,7 +857,8 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) > regmap_read(map, MAX17042_RepSOC, &soc); > soc >>= 8; > soc_tr = (soc + off) << 8; > - soc_tr |= (soc - off); > + if (off < soc) > + soc_tr |= soc - off; > regmap_write(map, MAX17042_SALRT_Th, soc_tr); > } > > Best regards, Krzysztof