Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3346437pxv; Sun, 4 Jul 2021 16:11:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8x+OyYnJ+Jrlbu1tjoyxQxrGBU8rZWV8HO1WYTagR+dYAwzKD7RCIZpkW6+CMVodnN3ss X-Received: by 2002:a92:8e04:: with SMTP id c4mr8385741ild.219.1625440264998; Sun, 04 Jul 2021 16:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440264; cv=none; d=google.com; s=arc-20160816; b=yl0Sgf5WONYOvcvR/kLzPeyd6m8wjeSiaPZdo6znWOdnr1Ip4JwUf69O2rRLJCO7+J XdyHOYio9CDJst3HuNknQCh60qy0ZRtFrlK0eM5uLyj4c5QRRgD47Vy68akkoBjVlS1J 90eBZknAoz0p1q7Fl6yBrm2MqgX6TPV4gibTg9aitqq9mK4Gk+0/4ROeA0suJWpTGi5H Ad+IHZQg1zSmikAzQND77F35FUepSjeZ5aeZ1ZXsCQ6dCB71jI+shFS9qbWf7TUMMCKg 7diyQEt2wuXTf5USiMaRzWfi8s0pFj/XWQfnU4KqNcsxkUgb9jQkHFE5BOESHXjbMHfd sRKg== 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=MCvVsG6b6KNCDOVvnWnTcbqqviCwgxjA1+8sn65MHRVlq/lWXqsrj2xYuj9REgct/5 pigMHko3DzTWUooThtVfEfKLUWMjQJfQZ6PYBUFl2pl7O0M87NK37VwHNx96unaW6rJT QtSCTm4ZK/qkq64EEMAVz2HnOjlG/0qBIyvzaRxlQPIPpj7rKKyuonOXD3eppj6Fb4RV gjZWHs9XYWhHYHeM68oG4mZ0UZz6u2ccHyAasd9lSvRQbyVlJ6Qtf2Zj1m8xFNhEEYK8 ribpC11ZIrFYvvaf1l+p3FY/wHaFPsLVt6qL8OaYTGeaFOIQplWHbhamLwTsYnAM1fbK LCUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ea+BhstP; 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 u12si12259600ior.23.2021.07.04.16.10.53; Sun, 04 Jul 2021 16:11:04 -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=Ea+BhstP; 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 S231952AbhGDXND (ORCPT + 99 others); Sun, 4 Jul 2021 19:13:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232359AbhGDXLI (ORCPT ); Sun, 4 Jul 2021 19:11:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A977661935; Sun, 4 Jul 2021 23:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440081; bh=9vnRA3Wy++7LojlzO1B1ztaIrIE2VgJhbNw4DsA2KLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ea+BhstPmuIxbgLZxhzoc5EejIRrtcvZBFjNhOYUJ8HXv/tia1Hb5G0jbgRrjmSp5 9TzVpcV3b7qFhI4v/XCPLjd1kLHK1GrCtmuoE3LnD2Vf5aU5Oc45wDBFaAsRetNkS8 tf0R/w8ZoLceHIatOIDE6qaeThA4nOvJatVe9GaMk5pdGpvOfXyHkoFxSxdArBzACW zZuI3o61sSwhlrgp8sZnXo2CZ+oM/07r4eFBL7GOaV0ffRGFg31gULdJcg5jvjkCMb BXZ/e68hC/plP2IRCph+3+b/pt5nXY6/2dyeeZYdPzdm0cpCyfioYcQC8saEeJO9dW RdGdNX+/PwVzw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.12 79/80] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Date: Sun, 4 Jul 2021 19:06:15 -0400 Message-Id: <20210704230616.1489200-79-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-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