Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp854601pxk; Thu, 17 Sep 2020 19:11:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaG/WjppjQhuopovsiJZ088PQl+AX3MqrKYqJg5w8gY+8VFt8ikPgzl7dLlf8sx0wARB+F X-Received: by 2002:a17:906:455:: with SMTP id e21mr35266347eja.170.1600395071432; Thu, 17 Sep 2020 19:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395071; cv=none; d=google.com; s=arc-20160816; b=rcPFPpaBVXmuRCyAHhvuv7NDts+FVNeG+CvSR4LwoF8uIEsntOwRMripmpuUBDJy5L 1Vapc5bHiVMjjW+3o9gxjwUUAhnbkTT1DRtoGqfAAd1Nr5XjeDomWqCMLkM4ev1DdHiY xe/dPSn2UN4i6mDt+p8BOaoLIgAjhqlgOv+91Xoca2vTEUgzMtbZLS4oD4nCfyaBz89d u8LjCBkC7XLBuDu+FPvkzbt/rV/9rPQotmooGFnANBIzA/m1D+zLeltupKH7LKl1WRvY PqT9poFA6senhOPklvj4XHCfC0+FUqd9yO443NNcuT1wkJnJnqR3ugHRKurTMdqJM+3N WjyA== 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=7anRaO+Eqv06r65KB4N8Vvx/GYbSISgFs7ddrz16dHE=; b=XkgKcDjm9q6nJ1m/1uwEzp00578hoOrK8k3EZ5lSkPXsojwz82RcV5/WIdbu4PAWZ2 7l2GdqXhzzNbltLmSEUthjT/4XcGEOeANLIIlTZPPA3hZ+izQf5OoB8novYPxJwzhCjX F2RIIprHEbTKQVXSBBwEY1bfzOse2UsWMKJA6kRUH9x1uelLzMVixQkbrxBD07k7TAuc hW6ievlxSAz4J/Nv/rc7+6wBoNboWsVfTqEt+ZPb3UzLO+uQ+xJFjpV/Wq+BkDlHckFK ivwRWXU+ISAEY/34qDrY6BtIHYEKo8gl7VvB78sTAZRo7XXs7Yw9qamGsf8cfSD79TkK Gmow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YRKe1QWg; 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 m21si1210517ejq.199.2020.09.17.19.10.48; Thu, 17 Sep 2020 19:11:11 -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=default header.b=YRKe1QWg; 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 S1727800AbgIRCGj (ORCPT + 99 others); Thu, 17 Sep 2020 22:06:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:56052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbgIRCGh (ORCPT ); Thu, 17 Sep 2020 22:06:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 38FC123772; Fri, 18 Sep 2020 02:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394797; bh=qsmbx+LWYhW40jxyy4d6lzF0hG3ZSYrZoizFkJdgukA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRKe1QWg/HpzTVo0CJdpwxKW62a4m34YjklMxkXF811TpKdw4AoeKMpA+n0mqzC3t A1+j1+9QbOgiWYS3/rIDPdPrBBUMhDBwWcHo2JlmbdFLGvgKkj02kUm6yrTw229xO4 E3vMu5zFGG8y0RupoRoOm937lR9NPuGCOLKnlUog= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Bakker , Krzysztof Kozlowski , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 266/330] tty: serial: samsung: Correct clock selection logic Date: Thu, 17 Sep 2020 22:00:06 -0400 Message-Id: <20200918020110.2063155-266-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-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: Jonathan Bakker [ Upstream commit 7d31676a8d91dd18e08853efd1cb26961a38c6a6 ] Some variants of the samsung tty driver can pick which clock to use for their baud rate generation. In the DT conversion, a default clock was selected to be used if a specific one wasn't assigned and then a comparison of which clock rate worked better was done. Unfortunately, the comparison was implemented in such a way that only the default clock was ever actually compared. Fix this by iterating through all possible clocks, except when a specific clock has already been picked via clk_sel (which is only possible via board files). Signed-off-by: Jonathan Bakker Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/BN6PR04MB06604E63833EA41837EBF77BA3A30@BN6PR04MB0660.namprd04.prod.outlook.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/samsung.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 71f99e9217592..c7683beb3412a 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1187,14 +1187,14 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, struct s3c24xx_uart_info *info = ourport->info; struct clk *clk; unsigned long rate; - unsigned int cnt, baud, quot, clk_sel, best_quot = 0; + unsigned int cnt, baud, quot, best_quot = 0; char clkname[MAX_CLK_NAME_LENGTH]; int calc_deviation, deviation = (1 << 30) - 1; - clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : - ourport->info->def_clk_sel; for (cnt = 0; cnt < info->num_clks; cnt++) { - if (!(clk_sel & (1 << cnt))) + /* Keep selected clock if provided */ + if (ourport->cfg->clk_sel && + !(ourport->cfg->clk_sel & (1 << cnt))) continue; sprintf(clkname, "clk_uart_baud%d", cnt); -- 2.25.1