From mboxrd@z Thu Jan 1 00:00:00 1970 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 9562430AAD8; Tue, 26 Aug 2025 14:43:13 +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=1756219393; cv=none; b=NsikhYPcmEQwj4Odf+9TG0BGvJpjvKVFqW0Xf/WV9ZpGUrtMYtMxd5wwlGNweW7Qeq3BxbX6jXY8OSa2PySAj2gyeBkXnT1jNyH/ITVw2HgvClz5vkSlkvChx2Rw/sBxkUPCQgSFM7FMNRTNtq0qa09HLSMnHnVUw3gjJKhDXxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219393; c=relaxed/simple; bh=1pa9I2bMXkc4x44w6jsLWMTySUpJSIQ73yq4kARxMXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aFNvY9n0p734HNt3gBxUPOofK5EnNdyQkuSQJ/iEv34C2LZ+D4r5lBYACUV6bV7A146Jm0YznTAnj1Gjs6nzOV5iIML5CHrjC3XyObMjklX8DURtYomXdd0/5ElCI4Maogri7zrr4Xs+8odC/8p9h8SPDJHk1THWyB+fhyD2zO8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gWENf4jz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gWENf4jz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26413C4CEF1; Tue, 26 Aug 2025 14:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756219393; bh=1pa9I2bMXkc4x44w6jsLWMTySUpJSIQ73yq4kARxMXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWENf4jzbol1i0jUlJKqEOV5BLZdK03KVoGy0/7prTfX1+/C1E6cgU1EnO9q6cld7 u/eRuf74Ukb9oTi4Kq/I1SZdnJCHehLbETybzZtrqRgcf+HrOVpzSax2ctaUO/2zON NySnM8SIaK+41yhHkske1T/eDGl3kJm2MlODNgSk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , AngeloGioacchino Del Regno , Thierry Reding , Sasha Levin Subject: [PATCH 5.4 365/403] pwm: mediatek: Implement .apply() callback Date: Tue, 26 Aug 2025 13:11:31 +0200 Message-ID: <20250826110917.086193387@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110905.607690791@linuxfoundation.org> References: <20250826110905.607690791@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Uwe Kleine-König [ Upstream commit 758de66f4bd2cac2b1d71db917c65c3d611d4e74 ] To eventually get rid of all legacy drivers convert this driver to the modern world implementing .apply(). This just pushed a variant of pwm_apply_legacy() into the driver that was slightly simplified because the driver doesn't provide a .set_polarity() callback. Signed-off-by: Uwe Kleine-König Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Thierry Reding Stable-dep-of: f21d136caf81 ("pwm: mediatek: Fix duty and period setting") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pwm/pwm-mediatek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -210,10 +210,33 @@ static void pwm_mediatek_disable(struct pwm_mediatek_clk_disable(chip, pwm); } +static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + int err; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + if (!state->enabled) { + if (pwm->state.enabled) + pwm_mediatek_disable(chip, pwm); + + return 0; + } + + err = pwm_mediatek_config(pwm->chip, pwm, state->duty_cycle, state->period); + if (err) + return err; + + if (!pwm->state.enabled) + err = pwm_mediatek_enable(chip, pwm); + + return err; +} + static const struct pwm_ops pwm_mediatek_ops = { - .config = pwm_mediatek_config, - .enable = pwm_mediatek_enable, - .disable = pwm_mediatek_disable, + .apply = pwm_mediatek_apply, .owner = THIS_MODULE, };