get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2223548/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2223548,
    "url": "http://patchwork.ozlabs.org/api/patches/2223548/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/patch/c5e7767cee821b5f6e00f95bd14a5e13015646fb.1776264104.git.u.kleine-koenig@baylibre.com/",
    "project": {
        "id": 38,
        "url": "http://patchwork.ozlabs.org/api/projects/38/?format=api",
        "name": "Linux PWM development",
        "link_name": "linux-pwm",
        "list_id": "linux-pwm.vger.kernel.org",
        "list_email": "linux-pwm@vger.kernel.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<c5e7767cee821b5f6e00f95bd14a5e13015646fb.1776264104.git.u.kleine-koenig@baylibre.com>",
    "list_archive_url": null,
    "date": "2026-04-15T14:50:12",
    "name": "[v1,1/2] pwm: stm32: Fix rounding issue for requests with inverted polarity",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0cfb4f4d0fbe12f750d9bad839fd91039648649b",
    "submitter": {
        "id": 88686,
        "url": "http://patchwork.ozlabs.org/api/people/88686/?format=api",
        "name": "Uwe Kleine-König",
        "email": "u.kleine-koenig@baylibre.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-pwm/patch/c5e7767cee821b5f6e00f95bd14a5e13015646fb.1776264104.git.u.kleine-koenig@baylibre.com/mbox/",
    "series": [
        {
            "id": 500001,
            "url": "http://patchwork.ozlabs.org/api/series/500001/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/list/?series=500001",
            "date": "2026-04-15T14:50:11",
            "name": "pwm: stm32: A rounding fix and a cleanup",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/500001/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2223548/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2223548/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-pwm+bounces-8590-incoming=patchwork.ozlabs.org@vger.kernel.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linux-pwm@vger.kernel.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20251104.gappssmtp.com\n header.i=@baylibre-com.20251104.gappssmtp.com header.a=rsa-sha256\n header.s=20251104 header.b=GxxFKP00;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8590-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)",
            "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com\n header.i=@baylibre-com.20251104.gappssmtp.com header.b=\"GxxFKP00\"",
            "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.128.43",
            "smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=baylibre.com",
            "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=baylibre.com"
        ],
        "Received": [
            "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwkkw07Y3z1yHc\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 00:57:12 +1000 (AEST)",
            "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id CC2CC307263E\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 14:50:34 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 9CE5F175A6D;\n\tWed, 15 Apr 2026 14:50:34 +0000 (UTC)",
            "from mail-wm1-f43.google.com (mail-wm1-f43.google.com\n [209.85.128.43])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 221E8344DAC\n\tfor <linux-pwm@vger.kernel.org>; Wed, 15 Apr 2026 14:50:32 +0000 (UTC)",
            "by mail-wm1-f43.google.com with SMTP id\n 5b1f17b1804b1-488b00ed86fso70744145e9.3\n        for <linux-pwm@vger.kernel.org>; Wed, 15 Apr 2026 07:50:32 -0700 (PDT)",
            "from localhost\n (p200300f65f20eb084c777289617ec110.dip0.t-ipconnect.de.\n [2003:f6:5f20:eb08:4c77:7289:617e:c110])\n        by smtp.gmail.com with UTF8SMTPSA id\n 5b1f17b1804b1-488f08b960esm37537185e9.0.2026.04.15.07.50.30\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 15 Apr 2026 07:50:31 -0700 (PDT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776264634; cv=none;\n b=a3tytfEMj8NUPmZR2uQmXq0SQQ0oow2UYi7O3ra2Q+5A3u1/QIQWAdWxRL+whixVaQOvibNWBHAU53GmdmkoPLat3yNejAaL2MVWqdu+oS/0mrt7kb4QZPtWZhpsGz3YXSOyJoMcnbsEgA8tRikWjU+URqs4R95jrl8sve8O+Sc=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776264634; c=relaxed/simple;\n\tbh=ajSHpn1BNzonBrH5M8RMYAzp3h9B89S9cIWnNvrv9aY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=GDhssLJUhMNxp02UmZfpkRgYKpKtGtxEuBPJmZvMLwDookI4OQxIL+X8IfRPLH7v/jrNkqggrP2RbXjcF8uubEluX12flWURUXmB88nlIhDeeupRUg1jSKFK0wOGqGbZXPqGZsHALi6xYz9UomPe8wCmSwnrJ8gM/7DTKHHtmBs=",
        "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=baylibre.com;\n spf=pass smtp.mailfrom=baylibre.com;\n dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com\n header.i=@baylibre-com.20251104.gappssmtp.com header.b=GxxFKP00;\n arc=none smtp.client-ip=209.85.128.43",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1776264631;\n x=1776869431; darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=jExw1zXy4YyTl+OWBiTmhuXsc+HcqG56ZjMjUPEOfbw=;\n        b=GxxFKP00ftaHiuuPWc2g/d65OjriVzs6jx18QoGAxHVDPn3KcWnYRqlu9UXxGzdm9H\n         tp5UaOw6naKQ+CQcPwLHJWMs23edA8rmhDH2DkVOBZPWryVSR9lLxPGO+vsoXr8ER8et\n         Rc7fBe+ln50pfNxWxv/a6OH03qROysMBSPUSm5y/DuEW9rAwnrg1yLvhtiBe5YkvoSbg\n         vOVZxlCZ066CUlVp4AbUEAEpV6ze8v1mllCpadFBO+TtrUlSu5GNnck9MJu3FEdKUjQg\n         O+qXeY/+z2WzDwImvk4MhQpbLas3rEWMNJEgQEA8EDDvQ4dRu2Y2c/r/pmKL4nAakzEt\n         ySkg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776264631; x=1776869431;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=jExw1zXy4YyTl+OWBiTmhuXsc+HcqG56ZjMjUPEOfbw=;\n        b=ofAK2jl+2/UmHacC9kOCYh0aZhuH5P0SXB344U4I1bBot6WLsWzQjg7Hmb6PJgWK2U\n         BlHhIL3hRsSai9l+JE/iewyrocIedwl+6NPLD7spu1Sk4f6iKtXkJ7rHYdONXupZUbRG\n         y1uSq4YGbLBV5vHbS77ajD/D7yYwqVSHy3sPaZxI8qibIvUU0q68qequMegdITe7GI7j\n         nskFOpnKX14EiGsEHaYvQw59kyIqgmZOB/sJDHjPpe00mPVzFGXXTjVyleMVwO5bDUeE\n         Fl7QyPH4krgTvH2je96/pjur0a8qjuW+dmibcvjmrMae+nYuihGtxKKjC63YzqVhu0uM\n         dDSQ==",
        "X-Forwarded-Encrypted": "i=1;\n AFNElJ/W4k5FbXtqNZwzgCfTsLEMFfWwWAHXfA6/MPxj1ce/wG0LA3in9e2cn0cGjej9HmNyqq1xo+IeM+c=@vger.kernel.org",
        "X-Gm-Message-State": "AOJu0Yzkt6l8U6jfFEmz8526TAZb8kX+fHl1nnbKaMOpr3cKv+jeh6e9\n\tCUzVpc4JqhN1SnHTIK3aXcCXhRR18BPHxUmY4FhvfUIkiFc/xq5RMjul/P1JmmD1MS4=",
        "X-Gm-Gg": "AeBDiet+cc4gBfcv/y9mveWJdEtbR3846V/3WjLIitfOWInfzz0siQRRxvTcXS35qPL\n\tbNCzQ2C92kNHPFISlOQ1PqC8o2IqxH0+7DiZ8ExvKBwgFD5xeZNqBWQpecMsLzU0PN0wJXczoT+\n\tVOh1BcgRgdwSmjBV7w/BGPzKu+KWQq0MiGUFLSvzpai90ynptg0zmLCECcVam2JYiAamMhLlrFA\n\tkCouvNLwTWNOVG6dFmv0rRibySAvhAOc11AWJT10WbH+P/etfdo2EaTmB+g+IALArrlSAvWzQki\n\tA/lVn2o8g2Yq43ZTUdgO6sv4+PBoERM+fPdSYvj1H1eBLbhC8L1oiw7YJuMbsXwQracEFdizuzS\n\tsu27jTDTpL+bi6+F1jToS/mhWkU9FmmvG2IyBYyp1ReljGU/hiey5MdCBVZz+meGhzjHQ+9G1vl\n\tuHPRQ+kHZ1t983/cfctXlyy25hVG5BLAWb8PVmgAFMDNee8pVCPZ1olvjTI05Ihh4dK1Cr1dezu\n\tLghf2ub4sF+wY4=",
        "X-Received": "by 2002:a05:600c:45cd:b0:488:9ed3:1492 with SMTP id\n 5b1f17b1804b1-488d67f0bb7mr285886345e9.10.1776264631425;\n        Wed, 15 Apr 2026 07:50:31 -0700 (PDT)",
        "From": "=?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@baylibre.com>",
        "To": "Fabrice Gasnier <fabrice.gasnier@foss.st.com>,\n\tMaxime Coquelin <mcoquelin.stm32@gmail.com>,\n\tAlexandre Torgue <alexandre.torgue@foss.st.com>",
        "Cc": "Andrea della Porta <andrea.porta@suse.com>,\n\tlinux-pwm@vger.kernel.org,\n\tlinux-stm32@st-md-mailman.stormreply.com",
        "Subject": "[PATCH v1 1/2] pwm: stm32: Fix rounding issue for requests with\n inverted polarity",
        "Date": "Wed, 15 Apr 2026 16:50:12 +0200",
        "Message-ID": "\n <c5e7767cee821b5f6e00f95bd14a5e13015646fb.1776264104.git.u.kleine-koenig@baylibre.com>",
        "X-Mailer": "git-send-email 2.47.3",
        "In-Reply-To": "<cover.1776264104.git.u.kleine-koenig@baylibre.com>",
        "References": "<cover.1776264104.git.u.kleine-koenig@baylibre.com>",
        "Precedence": "bulk",
        "X-Mailing-List": "linux-pwm@vger.kernel.org",
        "List-Id": "<linux-pwm.vger.kernel.org>",
        "List-Subscribe": "<mailto:linux-pwm+subscribe@vger.kernel.org>",
        "List-Unsubscribe": "<mailto:linux-pwm+unsubscribe@vger.kernel.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "X-Developer-Signature": "v=1; a=openpgp-sha256; l=3091;\n i=u.kleine-koenig@baylibre.com; h=from:subject:message-id;\n bh=ajSHpn1BNzonBrH5M8RMYAzp3h9B89S9cIWnNvrv9aY=;\n b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBp36Wn3t8V0cwMk6wJp4ND3V1gfyMohb6DSJJWf\n 9cMInW5qk+JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCad+lpwAKCRCPgPtYfRL+\n TnNvB/9+W/2Jab6L+30hO6T7u6hyyxLqJfIMDaAjeCbtPY+hhJtBlwYwdwTN0y48ovKKOB6MOpO\n O5U0WpFLZgrfzUQSxFT0Qzabf2FhdR1jacnbk8+dq2kQau/7hplscF/Uzw18UVDVfOXrUEgAkW2\n hax6KpmE81l0DGtEue+aODWW7iyUixYNQJMikXfZvc8tJ+XPotiIuPYqs5nR6+mRq5lbqZBNuPb\n t2SfQNVVfJ0DysXaNEjCOqyWzkHWboL/gJlRnCpiVJOHG0VuCFdLOAjSVSKJi6SS/LRncLflxVP\n nq+Whuh9IrMXT/HlXuDLLjB7as8f+w3U0wuqbHkiTaDI+ymi",
        "X-Developer-Key": "i=u.kleine-koenig@baylibre.com; a=openpgp;\n fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6",
        "Content-Transfer-Encoding": "8bit"
    },
    "content": "The calculation of the number of pwm clk ticks from a time length in\nnanoseconds involves a division and thus some rounding. That might\nresult in\n\n\tduty_ticks + offset_ticks < period_ticks\n\ndespite\n\n\tduty_length_ns + duty_offset_ns >= period_length_ns\n\n. The stm32 PWM cannot configure offset_ticks freely, it can only select\n0 or period_length_ns - duty_length_ns---that is the classic normal and\ninverted polarity. The decision to select the hardware polarity must be\ndone using the ticks values and not the nanoseconds times to adhere to\nthe rounding rules by the pwm core.\n\nWith the pwm clk running at 208900 kHz on my test machine\n(stm32mp135f-dk), a test case that was handled wrong is:\n\n\t# pwmround -P 9999962 -O 24970 -D 9974992\n\tperiod_length = 9999962\n\tduty_length = 9974840\n\tduty_offset = 25123\n\nWith this change applied the rounding is done correctly:\n\n\t# pwmround -P 9999962 -O 24970 -D 9974992\n\tperiod_length = 9999962\n\tduty_length = 9974840\n\tduty_offset = 0\n\nFixes: deaba9cff809 (\"pwm: stm32: Implementation of the waveform callbacks\")\nSigned-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>\n---\n drivers/pwm/pwm-stm32.c | 22 ++++++++++++----------\n 1 file changed, 12 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c\nindex 2594fb771b04..935257a890b0 100644\n--- a/drivers/pwm/pwm-stm32.c\n+++ b/drivers/pwm/pwm-stm32.c\n@@ -68,7 +68,7 @@ static int stm32_pwm_round_waveform_tohw(struct pwm_chip *chip,\n \tstruct stm32_pwm *priv = to_stm32_pwm_dev(chip);\n \tunsigned int ch = pwm->hwpwm;\n \tunsigned long rate;\n-\tu64 ccr, duty;\n+\tu64 duty_ticks, offset_ticks;\n \tint ret;\n \n \tif (wf->period_length_ns == 0) {\n@@ -164,23 +164,25 @@ static int stm32_pwm_round_waveform_tohw(struct pwm_chip *chip,\n \t\twfhw->arr = min_t(u64, arr, priv->max_arr) - 1;\n \t}\n \n-\tduty = mul_u64_u64_div_u64(wf->duty_length_ns, rate,\n-\t\t\t\t   (u64)NSEC_PER_SEC * (wfhw->psc + 1));\n-\tduty = min_t(u64, duty, wfhw->arr + 1);\n+\tduty_ticks = mul_u64_u64_div_u64(wf->duty_length_ns, rate,\n+\t\t\t\t\t (u64)NSEC_PER_SEC * (wfhw->psc + 1));\n+\tduty_ticks = min_t(u64, duty_ticks, wfhw->arr + 1);\n \n-\tif (wf->duty_length_ns && wf->duty_offset_ns &&\n-\t    wf->duty_length_ns + wf->duty_offset_ns >= wf->period_length_ns) {\n+\toffset_ticks = mul_u64_u64_div_u64(wf->duty_offset_ns, rate,\n+\t\t\t\t\t   (u64)NSEC_PER_SEC * (wfhw->psc + 1));\n+\toffset_ticks = min_t(u64, offset_ticks, wfhw->arr + 1);\n+\n+\tif (duty_ticks && offset_ticks &&\n+\t    duty_ticks + offset_ticks >= wfhw->arr + 1) {\n \t\twfhw->ccer |= TIM_CCER_CCxP(ch + 1);\n \t\tif (priv->have_complementary_output)\n \t\t\twfhw->ccer |= TIM_CCER_CCxNP(ch + 1);\n \n-\t\tccr = wfhw->arr + 1 - duty;\n+\t\twfhw->ccr = wfhw->arr + 1 - duty_ticks;\n \t} else {\n-\t\tccr = duty;\n+\t\twfhw->ccr = duty_ticks;\n \t}\n \n-\twfhw->ccr = min_t(u64, ccr, wfhw->arr + 1);\n-\n out:\n \tdev_dbg(&chip->dev, \"pwm#%u: %lld/%lld [+%lld] @%lu -> CCER: %08x, PSC: %08x, ARR: %08x, CCR: %08x\\n\",\n \t\tpwm->hwpwm, wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns,\n",
    "prefixes": [
        "v1",
        "1/2"
    ]
}