Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1499419/?format=api
{ "id": 1499419, "url": "http://patchwork.ozlabs.org/api/patches/1499419/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20210701072927.328254-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": "<20210701072927.328254-2-u.kleine-koenig@pengutronix.de>", "list_archive_url": null, "date": "2021-07-01T07:29:25", "name": "[1/3] pwm: Move legacy driver handling into a dedicated function", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5f691d9ea07cf9574ad4fc9ed7308e427a8a7557", "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/20210701072927.328254-2-u.kleine-koenig@pengutronix.de/mbox/", "series": [ { "id": 251456, "url": "http://patchwork.ozlabs.org/api/series/251456/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/list/?series=251456", "date": "2021-07-01T07:29:25", "name": "pwm: Some improvements for legacy drivers", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/251456/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1499419/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1499419/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 ozlabs.org (Postfix) with ESMTP id 4GFqbg6j6Sz9sVb\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 1 Jul 2021 17:29:35 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n id S234829AbhGAHcE (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n Thu, 1 Jul 2021 03:32:04 -0400", "from lindbergh.monkeyblade.net ([23.128.96.19]:52742 \"EHLO\n lindbergh.monkeyblade.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n with ESMTP id S229906AbhGAHcE (ORCPT\n <rfc822;linux-pwm@vger.kernel.org>); Thu, 1 Jul 2021 03:32:04 -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 EF892C061756\n for <linux-pwm@vger.kernel.org>; Thu, 1 Jul 2021 00:29:32 -0700 (PDT)", "from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0])\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 1lyr8c-00038y-Ou; Thu, 01 Jul 2021 09:29:30 +0200", "from ukl by ptx.hi.pengutronix.de with local (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1lyr8b-0006y1-OU; Thu, 01 Jul 2021 09:29:29 +0200" ], "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-pwm@vger.kernel.org, kernel@pengutronix.de,\n Geert Uytterhoeven <geert@linux-m68k.org>", "Subject": "[PATCH 1/3] pwm: Move legacy driver handling into a dedicated\n function", "Date": "Thu, 1 Jul 2021 09:29:25 +0200", "Message-Id": "<20210701072927.328254-2-u.kleine-koenig@pengutronix.de>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210701072927.328254-1-u.kleine-koenig@pengutronix.de>", "References": "<20210701072927.328254-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=VLywSRiHGKnQZ+sS60XRoAG+wlQ7ZanrKLCkgOrOEtI=;\n m=QQPqrse405A0JmOj99AyliymNJHPDcGyWK2Z6TGu7H8=;\n p=UfM8u/A5kO1ZoEeAdooxrxFd7zYtC0Qf5wAU/XvdwmU=;\n g=66d12b77bcf010abc5b380ec6f11cccdd7875858", "X-Patch-Sig": "m=pgp; i=uwe@kleine-koenig.org;\n s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6;\n b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmDdbsoACgkQwfwUeK3K7AnDUwf9Gd/\n R/7bk0u93wRx4bEYcaWnLy+qtDgUX816nORB4cJZtdclCrw4a5zQmXgMXLskoUmJ8j2OPnJ8AM1n8\n 2wnDX8J7Rs8ZFq7Og9+1BmB5CRBb4wmi9GAf9AJJmbk4xE8pmKFENVcLEYyiAk1KWX3VCsXAnk+/P\n eKnR69iqUO8ND1TDEOrBOvZ73TnlyKYxWH2Cz7aMtpqBFs2cLdmlBIhyFZhJyy0tmC9IVuuYG1Voj\n O6i2HfDUuRCJ7n0qzVqaoTTv4JVPX0dxDP1a/ZMMTNoLk7zwKp6pshezy5dyYwapb1ZfSNcyvkjIU\n AQmJ18qWJHwevSgyU2EbgS4aiWwD27g==", "Content-Transfer-Encoding": "8bit", "X-SA-Exim-Connect-IP": "2001:67c:670:100:1d::c0", "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": "There is no change in behaviour, only some code is moved from\npwm_apply_state to a separate function.\n\nSigned-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>\n---\n drivers/pwm/core.c | 130 ++++++++++++++++++++++++---------------------\n 1 file changed, 70 insertions(+), 60 deletions(-)", "diff": "diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c\nindex c4d5c0667137..3c72f8963073 100644\n--- a/drivers/pwm/core.c\n+++ b/drivers/pwm/core.c\n@@ -535,6 +535,64 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,\n \t}\n }\n \n+static int pwm_apply_legacy(struct pwm_chip *chip, struct pwm_device *pwm,\n+\t\t\t const struct pwm_state *state)\n+{\n+\tint err;\n+\n+\t/*\n+\t * FIXME: restore the initial state in case of error.\n+\t */\n+\tif (state->polarity != pwm->state.polarity) {\n+\t\tif (!chip->ops->set_polarity)\n+\t\t\treturn -EINVAL;\n+\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 (pwm->state.enabled) {\n+\t\t\tchip->ops->disable(chip, pwm);\n+\n+\t\t\t/*\n+\t\t\t * Update pwm->state already here in case\n+\t\t\t * .set_polarity() or another callback depend on that.\n+\t\t\t */\n+\t\t\tpwm->state.enabled = false;\n+\t\t}\n+\n+\t\terr = chip->ops->set_polarity(chip, pwm, state->polarity);\n+\t\tif (err)\n+\t\t\treturn err;\n+\n+\t\tpwm->state.polarity = state->polarity;\n+\t}\n+\n+\tif (state->period != pwm->state.period ||\n+\t state->duty_cycle != pwm->state.duty_cycle) {\n+\t\terr = chip->ops->config(pwm->chip, pwm,\n+\t\t\t\t\tstate->duty_cycle,\n+\t\t\t\t\tstate->period);\n+\t\tif (err)\n+\t\t\treturn err;\n+\n+\t\tpwm->state.period = state->period;\n+\t\tpwm->state.duty_cycle = state->duty_cycle;\n+\t}\n+\n+\tif (state->enabled != pwm->state.enabled) {\n+\t\tif (!pwm->state.enabled) {\n+\t\t\terr = chip->ops->enable(chip, pwm);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t} else {\n+\t\t\tchip->ops->disable(chip, pwm);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n * pwm_apply_state() - atomically apply a new state to a PWM device\n * @pwm: PWM device\n@@ -557,70 +615,22 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)\n \t state->enabled == pwm->state.enabled)\n \t\treturn 0;\n \n-\tif (chip->ops->apply) {\n+\tif (chip->ops->apply)\n \t\terr = chip->ops->apply(chip, pwm, state);\n-\t\tif (err)\n-\t\t\treturn err;\n-\n-\t\ttrace_pwm_apply(pwm, state);\n-\n-\t\tpwm->state = *state;\n-\n-\t\t/*\n-\t\t * only do this after pwm->state was applied as some\n-\t\t * implementations of .get_state depend on this\n-\t\t */\n-\t\tpwm_apply_state_debug(pwm, state);\n-\t} else {\n-\t\t/*\n-\t\t * FIXME: restore the initial state in case of error.\n-\t\t */\n-\t\tif (state->polarity != pwm->state.polarity) {\n-\t\t\tif (!chip->ops->set_polarity)\n-\t\t\t\treturn -EINVAL;\n-\n-\t\t\t/*\n-\t\t\t * Changing the polarity of a running PWM is\n-\t\t\t * only allowed when the PWM driver implements\n-\t\t\t * ->apply().\n-\t\t\t */\n-\t\t\tif (pwm->state.enabled) {\n-\t\t\t\tchip->ops->disable(chip, pwm);\n-\t\t\t\tpwm->state.enabled = false;\n-\t\t\t}\n-\n-\t\t\terr = chip->ops->set_polarity(chip, pwm,\n-\t\t\t\t\t\t state->polarity);\n-\t\t\tif (err)\n-\t\t\t\treturn err;\n-\n-\t\t\tpwm->state.polarity = state->polarity;\n-\t\t}\n-\n-\t\tif (state->period != pwm->state.period ||\n-\t\t state->duty_cycle != pwm->state.duty_cycle) {\n-\t\t\terr = chip->ops->config(pwm->chip, pwm,\n-\t\t\t\t\t\tstate->duty_cycle,\n-\t\t\t\t\t\tstate->period);\n-\t\t\tif (err)\n-\t\t\t\treturn err;\n+\telse\n+\t\terr = pwm_apply_legacy(chip, pwm, state);\n+\tif (err)\n+\t\treturn err;\n \n-\t\t\tpwm->state.duty_cycle = state->duty_cycle;\n-\t\t\tpwm->state.period = state->period;\n-\t\t}\n+\ttrace_pwm_apply(pwm, state);\n \n-\t\tif (state->enabled != pwm->state.enabled) {\n-\t\t\tif (state->enabled) {\n-\t\t\t\terr = chip->ops->enable(chip, pwm);\n-\t\t\t\tif (err)\n-\t\t\t\t\treturn err;\n-\t\t\t} else {\n-\t\t\t\tchip->ops->disable(chip, pwm);\n-\t\t\t}\n+\tpwm->state = *state;\n \n-\t\t\tpwm->state.enabled = state->enabled;\n-\t\t}\n-\t}\n+\t/*\n+\t * only do this after pwm->state was applied as some\n+\t * implementations of .get_state depend on this\n+\t */\n+\tpwm_apply_state_debug(pwm, state);\n \n \treturn 0;\n }\n", "prefixes": [ "1/3" ] }