Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3345540pxv; Sun, 4 Jul 2021 16:09:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp3LNx2tO8Ug7pFF+oyc1/20cKa35d3iQ3nflARNTTUa4BnS8JyLS9zictK0WO6WdDk8gn X-Received: by 2002:a05:6602:2595:: with SMTP id p21mr9348257ioo.51.1625440160293; Sun, 04 Jul 2021 16:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440160; cv=none; d=google.com; s=arc-20160816; b=G7EcWKgTldUrMOzx7I2r6PvM3qSxSeIO+nZ/Vg+p2+/s17bXAxJjusuxbBAcrXQiO9 IwjU02VMnIIwhJgl8dACc+FTved+7BgzLWvYboFITJwJnnFLqSUO9lRydEs+gbFOQTfG +Edj28wrUFDdhcUra+lbb0+C8kpmlYB5slsjjttn6vMYGaM2iCV49R8zpXThCcdxZK82 37sdlp/ejm8Frhq7B6DohOotdwtqoAadG5H254CDB4Lb7/OcNZ+mW7zREXUSQ6oAEDt1 uezfLAi9fYnuRgwch9NQHhH5mDw8N8vtItMSPaiUGaxsZBxZc2XzcW8jKVF8D5KjBmst nH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JXJ4jovvzivV8tK/FwBTAvEIBLZid7EZm5VY4kf+Xsw=; b=pF4j2unLcSvUIFct2t2HTMvlHg0CxJ2Ta/ffT6EKKJgXCXOTLDC1nUHi/toumBCdDH GJ02d7N0EAmgP7JmcixWfL+zXENd+wnxrlkC3F9SKp3TgMC47fZcQ08XiJ3xKtgiK+qi YCoDDoMNy84wl4uGTDLxWq7j2nNovsVnwmpdgEe/DQyJF3sxhhqUXsCmgyFOB38wT/j2 K11NdWSkh5XQpJ4scneNo8iIYpB1/nRMogXuZtBz8/4+VzjDwG6hLkMvNCQV9gGUgxpz 8eryAmt0VrR5v1a67rJPXHVuGBaPrjppLet1bzMgP9TUSvi19+fbQSxQtY8yOyA3b097 h0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fs/DADPH"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si12272437jan.103.2021.07.04.16.09.08; Sun, 04 Jul 2021 16:09:20 -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=@kernel.org header.s=k20201202 header.b="fs/DADPH"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbhGDXJp (ORCPT + 99 others); Sun, 4 Jul 2021 19:09:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:48260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbhGDXIs (ORCPT ); Sun, 4 Jul 2021 19:08:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D0E16145D; Sun, 4 Jul 2021 23:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439972; bh=9vnRA3Wy++7LojlzO1B1ztaIrIE2VgJhbNw4DsA2KLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fs/DADPH1Mzi2TTFvYIjaKKhbW/+xywc6GMNqw8MpSTky6S9H0jXxy0/6B8ADLaJG nJzcvE52neh6iVcjUjRl3fwQtV9QStMZw3RV0xJOTnbQJb91fVmX4hTg5uB2bUilJn JIqMioEDWM6drRDgMlBJzb4PobRQTCaKXcPXghYAAvS6EP+e3clOltW4rSDkRtIWVV XJuvOS6/dUmsnqKuZo1Dvu0HC6q4bnwYstEJLy1CD1PzwIKtBktrWjqm9KjfQPFQFx hfK/A0e9ivm6ZPA18/JtotbmONZHLrLm7Ua0bKpLHDzDwFrdoeijJaGzq2y7vqTFId 9aE5zj7pSV8Yw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.13 83/85] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Date: Sun, 4 Jul 2021 19:04:18 -0400 Message-Id: <20210704230420.1488358-83-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin [ Upstream commit a336dc8f683e5be794186b5643cd34cb28dd2c53 ] Use DIV_ROUND_UP to prevent truncation by integer division issue. This ensures we return enough delay time. Also fix returning negative value when new_sel < old_sel. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20210618141412.4014912-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/da9052-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index e18d291c7f21..23fa429ebe76 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev, case DA9052_ID_BUCK3: case DA9052_ID_LDO2: case DA9052_ID_LDO3: - ret = (new_sel - old_sel) * info->step_uV / 6250; + ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV, + 6250); break; } -- 2.30.2