Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1549531/?format=api
{ "id": 1549531, "url": "http://patchwork.ozlabs.org/api/patches/1549531/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20211102092804.296089-2-u.kleine-koenig@pengutronix.de/", "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": "<20211102092804.296089-2-u.kleine-koenig@pengutronix.de>", "list_archive_url": null, "date": "2021-11-02T09:28:03", "name": "[1/2] pwm: vt8500: Implement .apply() callback", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "22498c0585faa3fb24de0688ba1bb470e20e94b7", "submitter": { "id": 1476, "url": "http://patchwork.ozlabs.org/api/people/1476/?format=api", "name": "Uwe Kleine-König", "email": "u.kleine-koenig@pengutronix.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20211102092804.296089-2-u.kleine-koenig@pengutronix.de/mbox/", "series": [ { "id": 269946, "url": "http://patchwork.ozlabs.org/api/series/269946/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/list/?series=269946", "date": "2021-11-02T09:28:02", "name": "pwm: vt8500: Implement .apply() callback", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/269946/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1549531/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1549531/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-pwm-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=23.128.96.18; helo=vger.kernel.org;\n envelope-from=linux-pwm-owner@vger.kernel.org; receiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [23.128.96.18])\n\tby bilbo.ozlabs.org (Postfix) with ESMTP id 4Hk4MN2q1kz9sf8\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 2 Nov 2021 20:28:16 +1100 (AEDT)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n id S229770AbhKBJat (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n Tue, 2 Nov 2021 05:30:49 -0400", "from lindbergh.monkeyblade.net ([23.128.96.19]:58022 \"EHLO\n lindbergh.monkeyblade.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n with ESMTP id S229577AbhKBJas (ORCPT\n <rfc822;linux-pwm@vger.kernel.org>); Tue, 2 Nov 2021 05:30:48 -0400", "from metis.ext.pengutronix.de (metis.ext.pengutronix.de\n [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33])\n by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907BBC061766\n for <linux-pwm@vger.kernel.org>; Tue, 2 Nov 2021 02:28:13 -0700 (PDT)", "from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2])\n by metis.ext.pengutronix.de with esmtps\n (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1mhq5T-000350-GW; Tue, 02 Nov 2021 10:28:11 +0100", "from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de)\n by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1mhq5O-0008TL-CJ; Tue, 02 Nov 2021 10:28:06 +0100", "from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1mhq5O-0005Ha-BS; Tue, 02 Nov 2021 10:28:06 +0100" ], "From": "=?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>", "To": "Thierry Reding <thierry.reding@gmail.com>,\n Lee Jones <lee.jones@linaro.org>", "Cc": "linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org,\n Tony Prisk <linux@prisktech.co.nz>", "Subject": "[PATCH 1/2] pwm: vt8500: Implement .apply() callback", "Date": "Tue, 2 Nov 2021 10:28:03 +0100", "Message-Id": "<20211102092804.296089-2-u.kleine-koenig@pengutronix.de>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20211102092804.296089-1-u.kleine-koenig@pengutronix.de>", "References": "<20211102092804.296089-1-u.kleine-koenig@pengutronix.de>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "X-Patch-Hashes": "v=1; h=sha256; i=kUCY9L4JrDsDg/j7euSIYXyRiptGkOKO1yVlNu2XPRQ=;\n m=TzWDfn0QgyP4Qo0s0ELgUgvslQMmfgqYACV4fnO2KFo=;\n p=a2ymg8Cb6SrZGy75FqCYhS2mhx3DqAFdFafzg6kjHzE=;\n g=c83172edeea4810182ce0815168b009d2649768d", "X-Patch-Sig": "m=pgp; i=u.kleine-koenig@pengutronix.de;\n s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6;\n b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmGBBJwACgkQwfwUeK3K7Am5ogf9EaJ\n PRsxbCaIWMVHMXqBdJWQQ6MaVYCjr3tpfBTwJrz86k6N/uWbT6RsWzJalBqtdDEB+/YDxotWZYvSL\n ufZZTtDUNA+oj0ohlELTGLfHsI7ONrkNdoUpeVZeuNlddYfjzLP26Tjfhn6io321xodWnYmvHRsHy\n 1+DxN7hWT408omMinkizfpUwQzj4RkuLJb4pQfxDPnK5n5CZvF/88awVoEzr9dc3ZMMNqYJZ1sTdE\n w2K1Rau0RsE/914umoltZjen+/sPo+jBLqfkiUkKJYrujG8kOQbKM+4Ojnm57YhbhevKaom48JVQ+\n a4YISbz0zF9WTPr4vpnB/lOXAihi+CQ==", "Content-Transfer-Encoding": "8bit", "X-SA-Exim-Connect-IP": "2a0a:edc0:0:c01:1d::a2", "X-SA-Exim-Mail-From": "ukl@pengutronix.de", "X-SA-Exim-Scanned": "No (on metis.ext.pengutronix.de);\n SAEximRunCond expanded to false", "X-PTX-Original-Recipient": "linux-pwm@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-pwm.vger.kernel.org>", "X-Mailing-List": "linux-pwm@vger.kernel.org" }, "content": "To eventually get rid of all legacy drivers convert this driver to the\nmodern world implementing .apply(). This just pushes down a slightly\noptimized variant of how legacy drivers are handled in the core.\n\nSigned-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>\n---\n drivers/pwm/pwm-vt8500.c | 57 +++++++++++++++++++++++++++++++++++-----\n 1 file changed, 50 insertions(+), 7 deletions(-)", "diff": "diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c\nindex ea2aa151080a..3203ec1b0d24 100644\n--- a/drivers/pwm/pwm-vt8500.c\n+++ b/drivers/pwm/pwm-vt8500.c\n@@ -70,7 +70,7 @@ static inline void pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 bitmask)\n }\n \n static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,\n-\t\tint duty_ns, int period_ns)\n+\t\tu64 duty_ns, u64 period_ns)\n {\n \tstruct vt8500_chip *vt8500 = to_vt8500_chip(chip);\n \tunsigned long long c;\n@@ -102,8 +102,8 @@ static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,\n \t}\n \n \tc = (unsigned long long)pv * duty_ns;\n-\tdo_div(c, period_ns);\n-\tdc = c;\n+\n+\tdc = div64_u64(c, period_ns);\n \n \twritel(prescale, vt8500->base + REG_SCALAR(pwm->hwpwm));\n \tpwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE);\n@@ -176,11 +176,54 @@ static int vt8500_pwm_set_polarity(struct pwm_chip *chip,\n \treturn 0;\n }\n \n+static int vt8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,\n+\t\t\t const struct pwm_state *state)\n+{\n+\tint err;\n+\tbool enabled = pwm->state.enabled;\n+\n+\tif (state->polarity != pwm->state.polarity) {\n+\t\t/*\n+\t\t * Changing the polarity of a running PWM is only allowed when\n+\t\t * the PWM driver implements ->apply().\n+\t\t */\n+\t\tif (enabled) {\n+\t\t\tvt8500_pwm_disable(chip, pwm);\n+\n+\t\t\tenabled = false;\n+\t\t}\n+\n+\t\terr = vt8500_pwm_set_polarity(chip, pwm, state->polarity);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n+\tif (!state->enabled) {\n+\t\tif (enabled)\n+\t\t\tvt8500_pwm_disable(chip, pwm);\n+\n+\t\treturn 0;\n+\t}\n+\n+\t/*\n+\t * We cannot skip calling ->config even if state->period ==\n+\t * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle\n+\t * because we might have exited early in the last call to\n+\t * pwm_apply_state because of !state->enabled and so the two values in\n+\t * pwm->state might not be configured in hardware.\n+\t */\n+\terr = vt8500_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);\n+\tif (err)\n+\t\treturn err;\n+\n+\tif (!enabled)\n+\t\terr = vt8500_pwm_enable(chip, pwm);\n+\n+\treturn err;\n+}\n+\n static const struct pwm_ops vt8500_pwm_ops = {\n-\t.enable = vt8500_pwm_enable,\n-\t.disable = vt8500_pwm_disable,\n-\t.config = vt8500_pwm_config,\n-\t.set_polarity = vt8500_pwm_set_polarity,\n+\t.apply = vt8500_pwm_apply,\n \t.owner = THIS_MODULE,\n };\n \n", "prefixes": [ "1/2" ] }