Message ID | c523cc0fa14dd16785c85f4b204ba6d5e02a77a3.1718788826.git.u.kleine-koenig@baylibre.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93C0EC2BA1A for <linux-arm-kernel@archiver.kernel.org>; Wed, 19 Jun 2024 09:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DR7DaLA90oi7Sx2UQfP1lchaT92bhvbec7yBR4cuGW8=; b=ljttUYABYObeOksOe4Q5KbF4A8 Zz1MSpvZ+x41Qqu0zLPGVUz83AkXjmvr8APup2rzRkIqBxSTzcxHI7632O2pK/s3e6w/13xJr9Kru wFo6P1OMxOxrEwt0OHXHEd7ZnkpPyGtBdsMfoDATJFgvlo+FnB62NeAgxHwVbBDD78y9yfphXU2LI eNLW0IINo5oxa0ETQryGmXK+cncAfuahfgy/G2wUwP8UrUWm2KfYu3r0t54mYnI2FVwqutyGGGqBy 0GcFBFgKjke/5HPRtinyTVzhcjC6ss1TdSUit5ATsC0xBdfSVHSqdknerzX+xC3sC2EL9wVS7mw8G fQY/lc3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJrad-00000000aTG-46or; Wed, 19 Jun 2024 09:26:52 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJraZ-00000000aRR-2CJg for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 09:26:49 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-424720e73e1so12382465e9.1 for <linux-arm-kernel@lists.infradead.org>; Wed, 19 Jun 2024 02:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718789205; x=1719394005; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DR7DaLA90oi7Sx2UQfP1lchaT92bhvbec7yBR4cuGW8=; b=j5qyrX9j3KN/B3ncZrw0IS57+WQ14jO2x+Sr5vGEOJRjCOrN7sGgVr+oDuMrH36R6G VaJ7Q7VG3yp05MFVfrTBKutdsEYri0tqvlAIiIcWqTRnmgocHRojkfcXmkmYCbmzuUbk XJePKlVK2npvx1wbZRkfJo3X4s4FgDOjLp5mE7FJHiIkrJ7TrmfWWxBumYrM/TAanrIg XfI5xA9FDr1b56TP6cO0VlJx0iH0879b4tU45EK8XiquusxH8LTB35LpYIW0C1dJ/mH3 UZ1cNzg064w/X8pahXxtHvzT5DcH2+AzAxpyrc/78vmeLjDz0T3t+zJX0lPvvZ5iNgoT tGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718789205; x=1719394005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DR7DaLA90oi7Sx2UQfP1lchaT92bhvbec7yBR4cuGW8=; b=LpTKiuFWpkKSX5u9B38Tanj3IAB18gqHPJj+e6DrTOAuRjQWeR2Vgcl0xSwdbMBnnY 7aQIw+ixguVKDraul2lmvfAuZz7YJKBA2G9YVmIOkaxw0fXwrfFBvQ/ANMm9omFaHHEW VwVdi4kZtQ5Yl/urTCV9+N2CfTcbWeDAwakli4uh1NfwEjIF7mNFaXVX27r0+IiXvq2p dYytSBV/leo8iUcjRqMAeaQZXhbc1aRHTE45M3ANZdtgXfmHnfT3yR/AdkT6C3IazCvk /Fvr0kG+XWKtNjGWFppA4xLANdtQ8iTp0uuhDQrJO9XIrYJAJzhPf1mJZhu4yjY9GPs6 AQkg== X-Forwarded-Encrypted: i=1; AJvYcCVIEZgzq1Ico1XJF6KoahTjOfhCYLB/dvMb4cKKgQud5s+cOgH9h42xSzz/LTY6SPkBkvhbNMLJhayZ3NjNT/wISHKd7qO8h4QJXgdm66BWm3qWzbY= X-Gm-Message-State: AOJu0Yzgd1IidsPUui1kRlYPO7IXCAOL7jsXY0XJmgKfWmijobr12e0e dUbmpGiMa2u/XpZHSL79rMM3gPnbGj8fQqx5030NtsPcM7xpi5iqZMvUyTpH6D4= X-Google-Smtp-Source: AGHT+IECQtiC0VKWzrySd3phzgKGLPkfzADfJEpWsC3603JzVYfretGLD12PgHyZjjXmDS4xZ154rg== X-Received: by 2002:a7b:cd07:0:b0:422:370a:ca57 with SMTP id 5b1f17b1804b1-4247529bd22mr12959225e9.36.1718789204826; Wed, 19 Jun 2024 02:26:44 -0700 (PDT) Received: from localhost (p509153eb.dip0.t-ipconnect.de. [80.145.83.235]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-422870e9590sm257894845e9.23.2024.06.19.02.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 02:26:44 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@baylibre.com> To: Fabrice Gasnier <fabrice.gasnier@foss.st.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Lee Jones <lee@kernel.org>, Thierry Reding <treding@nvidia.com> Cc: linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH 1/2] pwm: stm32: Refuse too small period requests Date: Wed, 19 Jun 2024 11:26:24 +0200 Message-ID: <c523cc0fa14dd16785c85f4b204ba6d5e02a77a3.1718788826.git.u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1718788826.git.u.kleine-koenig@baylibre.com> References: <cover.1718788826.git.u.kleine-koenig@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=916; i=u.kleine-koenig@baylibre.com; h=from:subject:message-id; bh=t/egHWd+wmcQlgsPv+ZLw8ZljE6PdVD/61DykbjcgzU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmcqREO8R0IRhIv2cdHZmB13NIe9ta4LYlDZM/y NzbWbt7RF2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZnKkRAAKCRCPgPtYfRL+ TiHoB/0RVZ9pnx+IyNBO+qORuAclGa8F4EDvd1uHdrU9quZ5Vo2GZqZGHKe+jsPAwrnq5cDTuVL uRzTEYQN15LjnjI3DVpjzCXMdmxlSX8AR3oENWmvoURE8AvQjDS/aEEmkIC2M5qjg5JqtRSO475 b90u24VQc9RElRsZ+/44CaINWsndASrwah18oJ9ymattO4Zreaz2tyKDe08sImU50zAekOAbtAj /l7p8ln/vSiXb4xAuR9aSaknu6FuWBlgumoeguo47sJFpL7zbrOg1yTPdBW2JELuJ6JMbMSI9uS SuECLulflPslzng2EkpawVELbT7Kaeg/FdHL4xsR7rKXmJL7 X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_022647_584977_4262921B X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
pwm: stm32: Two fixes
|
expand
|
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index a2f231d13a9f..3e7b2a8e34e7 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -337,6 +337,8 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch, prd = mul_u64_u64_div_u64(period_ns, clk_get_rate(priv->clk), (u64)NSEC_PER_SEC * (prescaler + 1)); + if (!prd) + return -EINVAL; /* * All channels share the same prescaler and counter so when two
If period_ns is small, prd might well become 0. Catch that case because otherwise with regmap_write(priv->regmap, TIM_ARR, prd - 1); a few lines down quite a big period is configured. Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm") Cc: stable@vger.kernel.org Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- drivers/pwm/pwm-stm32.c | 2 ++ 1 file changed, 2 insertions(+)