From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF5E73FCB3D for ; Tue, 19 May 2026 09:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779181334; cv=none; b=NnhhWATfRNA4yLACWOlE8wpTnUOqECm8klrx7uW54FOosxr3ZjNvYVDPQdQ6cyWM5wB48fa0h1dFJJRKA/Y7jrMlKNhMQxzZH2O+MlkRv1ktRS/sy6Sdss0x6v0wVaPBhD1X2YhSrBdxaRT/iYgelceqHd2GFY/JDJ7nMMYaJx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779181334; c=relaxed/simple; bh=LJEEPChwdcM1KLq1Y/q8j56wOB4WvOPShmezx9DGSgE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DXT4DDu+DpxpJIFPRdIisFLAeKiuLKMRwNSwBJBrOCWBXsaB5jPwwZLtvdZ0S2Tbk9F00U72NnXeOdxvligGHviwN6cEThEyJcqEKdZG373fgW3Eb/Z0yY2qY0zOLw7UJxOEXMgVUvNuMyA6tDMuAw7QpafeB62c9kr2kMfu3ds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=Br0O6lEI; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Br0O6lEI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1779181333; x=1810717333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LJEEPChwdcM1KLq1Y/q8j56wOB4WvOPShmezx9DGSgE=; b=Br0O6lEIIkqrU+ec3LNsx0g1Q3PDWR85at7ec1aXTC0kNx9bI+hNetNJ YMy1U6zex1RK3APyTnAZiVwZyQQ77eCiYhBB8rFH/yLFi26IrMpOKEC3e hr43UFwxkz4vUiBDiqYAdIaKS0rev1aUpv57CzR7bbkBCdc42as5jLvZ1 BuZ/09AiL9KnYNWop+8TecgVVsuhiBBaTAlzC3B+IiEoLGUrS7ylIwvI4 +UXkKjWlruDewBgb8lhKHKZec4e3zcsD/3mxlt0Ckg7cmsT/O3J1EpWPT GuxuvfAKpoXpmKUbEhFMa24XsBIctJYaDvOEzOKwL62YDCyHcAN+vMVfI A==; X-CSE-ConnectionGUID: ELPhaqqSSbm0Etnr8wDe8w== X-CSE-MsgGUID: ckea46Z1S+epLY2sBN5gKQ== X-IronPort-AV: E=Sophos;i="6.23,243,1770620400"; d="scan'208";a="57719362" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2026 02:02:12 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex4.mchp-main.com (10.10.87.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.37; Tue, 19 May 2026 02:02:11 -0700 Received: from che-lt-i67131.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Tue, 19 May 2026 02:02:06 -0700 From: Manikandan Muralidharan To: , , , , , , , , , , , CC: Subject: [PATCH 3/8] drm: atmel-hlcdc: simplify clock divider selection with DIV_ROUND_CLOSEST Date: Tue, 19 May 2026 14:31:30 +0530 Message-ID: <20260519090135.1188405-4-manikandan.m@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260519090135.1188405-1-manikandan.m@microchip.com> References: <20260519090135.1188405-1-manikandan.m@microchip.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain DIV_ROUND_CLOSEST naturally selects the nearest divider, making the manual 10x proximity check redundant. Drop it and switch from DIV_ROUND_UP accordingly. Signed-off-by: Manikandan Muralidharan --- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index 9673fbce42a7..f30138da1ed8 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -112,28 +112,16 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) mask |= ATMEL_HLCDC_CLKSEL; } - div = DIV_ROUND_UP(prate, mode_rate); + div = DIV_ROUND_CLOSEST(prate, mode_rate); if (div < 2) { div = 2; } else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) { /* The divider ended up too big, try a lower base rate. */ cfg &= ~ATMEL_HLCDC_CLKSEL; prate /= 2; - div = DIV_ROUND_UP(prate, mode_rate); + div = DIV_ROUND_CLOSEST(prate, mode_rate); if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) div = ATMEL_HLCDC_CLKDIV_MASK; - } else { - int div_low = prate / mode_rate; - - if (div_low >= 2 && - (10 * (prate / div_low - mode_rate) < - (mode_rate - prate / div))) - /* - * At least 10 times better when using a higher - * frequency than requested, instead of a lower. - * So, go with that. - */ - div = div_low; } cfg |= ATMEL_HLCDC_CLKDIV(div); -- 2.25.1