From nobody Fri Dec 19 20:13:14 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9530A158D75; Wed, 13 Mar 2024 16:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348443; cv=none; b=CWdDJkHwqdUlb+P+/576OX7ithJA7w96lepquigPLzeO3Gp/Se+yCWa6+hSYZBZs4vhmIee7eNOhEoI+ALYXUWe3FitWMaDP+FxtU4SoN7DUv0FLcWgT1xpvJT6jVm1hcnar/TgTxopx0xfolmw4zzLAbGM+rrELm7zoEs/Y7tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348443; c=relaxed/simple; bh=EwYFc6u/vRmEQVBhKndW0cFn92ioVA9ZTpiDm23xcUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AOeXlBgnHaeoXDZ0CedvioxXRu1cDBVKzweTXrmwbUui3ZwjpQN7am+WeTDJJKkun1ueQx5fLKRS+NnQfJTaeKKu1Mn3bqvf6chfklAAHBjpL5CluutaO9Bv4IATzVlr1kvq0LDw3fbO8Y4a8fitUKGSzPz3OqM+IljNw8Qq1dI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P4ahr/5C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P4ahr/5C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7251BC433C7; Wed, 13 Mar 2024 16:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348443; bh=EwYFc6u/vRmEQVBhKndW0cFn92ioVA9ZTpiDm23xcUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4ahr/5CoXYxhBzevLiigzC95ArZnJEWrxE960QIfn1E8oulRCDfdat1oga0AiOcB o7APPzCkmgaggf8aSpA0HrwDMnO23UbeppxY82MSz2CjcMQWA9HZqXFCNdHGd3SM80 nAgedQ7Sq8fOt/N3ps6xpyRLMeXLYWiqtD8gEZ2ujaxEdGIGQBbw+MCCy1zzFPuma9 Wiov/YAZB+dauO6irkKditKOMfMNaauEaKFewqc0YQP0ZDfn3wGUGgENHRJXK3voea ybJygIxZy10jKgfwgydeAimDWXT6gBetMfUTu0Hw0TneA/41I7YrABYq26dhmU14US R2azWwxZhyFWA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.10 37/73] serial: max310x: Use devm_clk_get_optional() to get the input clock Date: Wed, 13 Mar 2024 12:46:04 -0400 Message-ID: <20240313164640.616049-38-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164640.616049-1-sashal@kernel.org> References: <20240313164640.616049-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.213-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.213-rc1 X-KernelTest-Deadline: 2024-03-15T16:46+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko [ Upstream commit 974e454d6f96da0c0ab1b4115b92587dd9406f6a ] Simplify the code which fetches the input clock by using devm_clk_get_optional(). If no input clock is present devm_clk_get_optional() will return NULL instead of an error which matches the behavior of the old code. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20201007084635.594991-2-andy.shevchenko@gma= il.com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 8afa6c6decea ("serial: max310x: fail probe if clock crystal = is unstable") Signed-off-by: Sasha Levin --- drivers/tty/serial/max310x.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 14537878f9855..8bf3c5ab59431 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1265,7 +1265,6 @@ static int max310x_probe(struct device *dev, struct m= ax310x_devtype *devtype, struct regmap *regmap, int irq) { int i, ret, fmin, fmax, freq, uartclk; - struct clk *clk_osc, *clk_xtal; struct max310x_port *s; bool xtal =3D false; =20 @@ -1279,23 +1278,24 @@ static int max310x_probe(struct device *dev, struct= max310x_devtype *devtype, return -ENOMEM; } =20 - clk_osc =3D devm_clk_get(dev, "osc"); - clk_xtal =3D devm_clk_get(dev, "xtal"); - if (!IS_ERR(clk_osc)) { - s->clk =3D clk_osc; + s->clk =3D devm_clk_get_optional(dev, "osc"); + if (IS_ERR(s->clk)) + return PTR_ERR(s->clk); + if (s->clk) { fmin =3D 500000; fmax =3D 35000000; - } else if (!IS_ERR(clk_xtal)) { - s->clk =3D clk_xtal; - fmin =3D 1000000; - fmax =3D 4000000; - xtal =3D true; - } else if (PTR_ERR(clk_osc) =3D=3D -EPROBE_DEFER || - PTR_ERR(clk_xtal) =3D=3D -EPROBE_DEFER) { - return -EPROBE_DEFER; } else { - dev_err(dev, "Cannot get clock\n"); - return -EINVAL; + s->clk =3D devm_clk_get_optional(dev, "xtal"); + if (IS_ERR(s->clk)) + return PTR_ERR(s->clk); + if (s->clk) { + fmin =3D 1000000; + fmax =3D 4000000; + xtal =3D true; + } else { + dev_err(dev, "Cannot get clock\n"); + return -EINVAL; + } } =20 ret =3D clk_prepare_enable(s->clk); --=20 2.43.0