From patchwork Tue Dec 12 08:34:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585635vqy; Tue, 12 Dec 2023 00:34:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVZEO7F3BFjtmOuEUrmMyLn/oEwkuYZ/pbLwSoPqowvKuv2V15fPFu8bOyCg9i1FImxW2X X-Received: by 2002:a17:902:ce85:b0:1d0:910e:5036 with SMTP id f5-20020a170902ce8500b001d0910e5036mr6944821plg.7.1702370096108; Tue, 12 Dec 2023 00:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370096; cv=none; d=google.com; s=arc-20160816; b=WG5xzq/HcAUYtEb8eg07ckNNJQDqxQy9Djkj+6Lu+QmOVwDN+O9GfhfcdkND4/ZEQr OHWRBZFXDG6TwrxvCHtMKYs+aFug1+wEC/bUO0uQwtOrPz5JQIa77s5HAblVJ1FWQyEt sefZ6jEorWiD1hlHPVA6WBqbBMC332eZs7UziUIw4rc2zt1myA47lOQkTzz99JJ6LUDB wceqkd+Es+eNTnbw7I6z5gD9eG7uljnYaxgjTChGKXFB5O5H9TPGURkdrPE0/zZkcA2d 3q3gsbiELzxXoZC458bvIdxqRyp5vBWENjVoh1paitz+rXBo68RXisAuihVZB7b5Kk1j fNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=IW6Df7i2pBpFyqFI6nD+fzzcpJR54OcfsZa6gBRH4qo=; fh=LXVDIsQAHYcuAbSneegrOY6aljpJ62fO3JnfAjaSssY=; b=xsXKGE9eOaO8XRdc+30RuSgVrFAzAh6RmRWbAgRRtnGs+7c+LmJuJXUUDzJ0II8qZn zh3gP+9JJco5hLsunpZCCTa2m1XTyuC14WbyqphDJqwIyuhFQ8r/1EWSNDyfLEMInW18 cZxWLvc2sNEGCNPIQh9CJZJbJ4CXDWgQgJTss1vcUmevK/DAAI2qFAWJtPjqfiRhSnBw 8xpQSMcyfKG4MQbuSMWN19F6+821N3aOQHdVGKonbdm5F/kfW5CtFd2VbES7WxVEUcmi 0CQI/wgqbykZbYO32a7cNPzcE1qnM2pwbQQyQQqG39v+6zKjh+IoAhPTT7dcwAjv1WlZ 2hrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=VE2N7yVa; dkim=pass header.i=@mess.org header.s=2020 header.b=gZTHV81b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z3-20020a1709028f8300b001d0b2230dbfsi7276649plo.266.2023.12.12.00.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=VE2N7yVa; dkim=pass header.i=@mess.org header.s=2020 header.b=gZTHV81b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D1BA3804DDA2; Tue, 12 Dec 2023 00:34:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235020AbjLLIem (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344749AbjLLIee (ORCPT ); Tue, 12 Dec 2023 03:34:34 -0500 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A016CFD; Tue, 12 Dec 2023 00:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370077; bh=g2jdy8jYeO+QLh0PNjfO3EUwri5hqnCpRDJI39cDyzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VE2N7yVaOKPnqHrODVhrpm8e/FnjgRmwx4rrP2rSAdtXZ92bp9HKiraEubei18jNi kVx3w6GrN6Gtmq9MUT1g3V2ccLPTLvzo2UCNJC8+zb8QiobeJwGkVf6ehgjgvSVdUD c5hjytOOD1rRKVDDf4eHxDn90dz7KcYNeEP6hAuDliBF0w4jsCn3aqY9LzJ9afrcFT dlt+iKxhafU+AKgJaduCDnd274dBXd6ETD9vti+tRsOW5GMpfM5Dm4PCi+thYy8+n9 3zLzpnu2XRBVWwaqCht71GvITfGaj2So6kc4C3wvPW18J/QKdJCxKIr7QZcGtNpG4p q3eaoG1kUGu4Q== Received: by gofer.mess.org (Postfix, from userid 501) id 0515D10008F; Tue, 12 Dec 2023 08:34:36 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370061; bh=g2jdy8jYeO+QLh0PNjfO3EUwri5hqnCpRDJI39cDyzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZTHV81ba9dgFBI1YZoOgjP61y3P9H4AC7GM4vtuvOkPQIJMYJNqccE/iDVinKHwt YmPbHeYYe72dwMC0306SwvE01/PjnA3R4WPKWYSX7Las5pOM47qEZ4yCvAxtNxKJJJ bW+XkUfffC0wZnX7MQHACsGJHPfZ+tX6u7qLsa9GRlbP9S0du+10afvLWm30BqZYXf 0Lmlli/Sb7tc8PeZ+HpNI2tpc3CYwtrkX/IuWD3zLG1pwi2j9Yg2jQqstwG3J6FJih 4wV4s+ExnstQJcRVJsad4QJtzenaXsglTlZgl9c0xf+2RlTRiNb2uK68HQggF07+41 qw3dTf2GpH5CQ== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id AA4B810008F; Tue, 12 Dec 2023 08:34:21 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jonathan Corbet , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jean Delvare , Guenter Roeck , Support Opensource , Dmitry Torokhov , Pavel Machek , Lee Jones , Sean Young , Mauro Carvalho Chehab , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Gross , Liam Girdwood , Mark Brown , Daniel Thompson , Jingoo Han , Helge Deller Cc: Jani Nikula , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-hwmon@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fbdev@vger.kernel.org Subject: [PATCH v8 1/6] pwm: Rename pwm_apply_state() to pwm_apply_might_sleep() Date: Tue, 12 Dec 2023 08:34:00 +0000 Message-ID: <9af7ba748fd2eb7e04208b6b183185f1daf78016.1702369869.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:34:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064425872577805 X-GMAIL-MSGID: 1785064425872577805 In order to introduce a pwm api which can be used from atomic context, we will need two functions for applying pwm changes: int pwm_apply_might_sleep(struct pwm *, struct pwm_state *); int pwm_apply_atomic(struct pwm *, struct pwm_state *); This commit just deals with renaming pwm_apply_state(), a following commit will introduce the pwm_apply_atomic() function. Acked-by: Dmitry Torokhov # for input Acked-by: Hans de Goede Acked-by: Jani Nikula Acked-by: Lee Jones Signed-off-by: Sean Young Acked-by: Uwe Kleine-König Acked-by: Guenter Roeck Acked-by: Mark Brown --- Documentation/driver-api/pwm.rst | 8 +++--- MAINTAINERS | 2 +- .../gpu/drm/i915/display/intel_backlight.c | 6 ++-- drivers/gpu/drm/solomon/ssd130x.c | 2 +- drivers/hwmon/pwm-fan.c | 8 +++--- drivers/input/misc/da7280.c | 4 +-- drivers/input/misc/pwm-beeper.c | 4 +-- drivers/input/misc/pwm-vibra.c | 8 +++--- drivers/leds/leds-pwm.c | 2 +- drivers/leds/rgb/leds-pwm-multicolor.c | 4 +-- drivers/media/rc/pwm-ir-tx.c | 4 +-- drivers/platform/x86/lenovo-yogabook.c | 2 +- drivers/pwm/core.c | 18 ++++++------ drivers/pwm/pwm-twl-led.c | 2 +- drivers/pwm/pwm-vt8500.c | 2 +- drivers/pwm/sysfs.c | 10 +++---- drivers/regulator/pwm-regulator.c | 4 +-- drivers/video/backlight/lm3630a_bl.c | 2 +- drivers/video/backlight/lp855x_bl.c | 2 +- drivers/video/backlight/pwm_bl.c | 12 ++++---- drivers/video/fbdev/ssd1307fb.c | 2 +- include/linux/pwm.h | 28 +++++++++---------- 22 files changed, 68 insertions(+), 68 deletions(-) diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst index bb264490a87a1..f1d8197c8c430 100644 --- a/Documentation/driver-api/pwm.rst +++ b/Documentation/driver-api/pwm.rst @@ -41,7 +41,7 @@ the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist. After being requested, a PWM has to be configured using:: - int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state); + int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state); This API controls both the PWM period/duty_cycle config and the enable/disable state. @@ -57,13 +57,13 @@ If supported by the driver, the signal can be optimized, for example to improve EMI by phase shifting the individual channels of a chip. The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers -around pwm_apply_state() and should not be used if the user wants to change +around pwm_apply_might_sleep() and should not be used if the user wants to change several parameter at once. For example, if you see pwm_config() and pwm_{enable,disable}() calls in the same function, this probably means you -should switch to pwm_apply_state(). +should switch to pwm_apply_might_sleep(). The PWM user API also allows one to query the PWM state that was passed to the -last invocation of pwm_apply_state() using pwm_get_state(). Note this is +last invocation of pwm_apply_might_sleep() using pwm_get_state(). Note this is different to what the driver has actually implemented if the request cannot be satisfied exactly with the hardware in use. There is currently no way for consumers to get the actually implemented settings. diff --git a/MAINTAINERS b/MAINTAINERS index 97f51d5ec1cfd..c584805952209 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17576,7 +17576,7 @@ F: drivers/video/backlight/pwm_bl.c F: include/dt-bindings/pwm/ F: include/linux/pwm.h F: include/linux/pwm_backlight.h -K: pwm_(config|apply_state|ops) +K: pwm_(config|apply_might_sleep|ops) PXA GPIO DRIVER M: Robert Jarzmik diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c index 2e8f17c045222..ff9b9918b0a13 100644 --- a/drivers/gpu/drm/i915/display/intel_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_backlight.c @@ -274,7 +274,7 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state, struct intel_panel *panel = &to_intel_connector(conn_state->connector)->panel; pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); - pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); + pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); } static void @@ -427,7 +427,7 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn intel_backlight_set_pwm_level(old_conn_state, level); panel->backlight.pwm_state.enabled = false; - pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); + pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); } void intel_backlight_disable(const struct drm_connector_state *old_conn_state) @@ -749,7 +749,7 @@ static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state, pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); panel->backlight.pwm_state.enabled = true; - pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state); + pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); } static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state, diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index e0174f82e3537..cce043a4a1dcd 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -319,7 +319,7 @@ static int ssd130x_pwm_enable(struct ssd130x_device *ssd130x) pwm_init_state(ssd130x->pwm, &pwmstate); pwm_set_relative_duty_cycle(&pwmstate, 50, 100); - pwm_apply_state(ssd130x->pwm, &pwmstate); + pwm_apply_might_sleep(ssd130x->pwm, &pwmstate); /* Enable the PWM */ pwm_enable(ssd130x->pwm); diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 6e4516c2ab894..b67bc9e833c01 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -151,7 +151,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx) } state->enabled = true; - ret = pwm_apply_state(ctx->pwm, state); + ret = pwm_apply_might_sleep(ctx->pwm, state); if (ret) { dev_err(ctx->dev, "failed to enable PWM\n"); goto disable_regulator; @@ -181,7 +181,7 @@ static int pwm_fan_power_off(struct pwm_fan_ctx *ctx) state->enabled = false; state->duty_cycle = 0; - ret = pwm_apply_state(ctx->pwm, state); + ret = pwm_apply_might_sleep(ctx->pwm, state); if (ret) { dev_err(ctx->dev, "failed to disable PWM\n"); return ret; @@ -207,7 +207,7 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm) period = state->period; state->duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM); - ret = pwm_apply_state(ctx->pwm, state); + ret = pwm_apply_might_sleep(ctx->pwm, state); if (ret) return ret; ret = pwm_fan_power_on(ctx); @@ -278,7 +278,7 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val) state, &enable_regulator); - pwm_apply_state(ctx->pwm, state); + pwm_apply_might_sleep(ctx->pwm, state); pwm_fan_switch_power(ctx, enable_regulator); pwm_fan_update_state(ctx, 0); } diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index ce82548916bbc..c1fa75c0f970a 100644 --- a/drivers/input/misc/da7280.c +++ b/drivers/input/misc/da7280.c @@ -352,7 +352,7 @@ static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool enabled) state.duty_cycle = period_mag_multi; } - error = pwm_apply_state(haptics->pwm_dev, &state); + error = pwm_apply_might_sleep(haptics->pwm_dev, &state); if (error) dev_err(haptics->dev, "Failed to apply pwm state: %d\n", error); @@ -1175,7 +1175,7 @@ static int da7280_probe(struct i2c_client *client) /* Sync up PWM state and ensure it is off. */ pwm_init_state(haptics->pwm_dev, &state); state.enabled = false; - error = pwm_apply_state(haptics->pwm_dev, &state); + error = pwm_apply_might_sleep(haptics->pwm_dev, &state); if (error) { dev_err(dev, "Failed to apply PWM state: %d\n", error); return error; diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 1e731d8397c6f..5b9aedf4362f4 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -39,7 +39,7 @@ static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) state.period = period; pwm_set_relative_duty_cycle(&state, 50, 100); - error = pwm_apply_state(beeper->pwm, &state); + error = pwm_apply_might_sleep(beeper->pwm, &state); if (error) return error; @@ -138,7 +138,7 @@ static int pwm_beeper_probe(struct platform_device *pdev) /* Sync up PWM state and ensure it is off. */ pwm_init_state(beeper->pwm, &state); state.enabled = false; - error = pwm_apply_state(beeper->pwm, &state); + error = pwm_apply_might_sleep(beeper->pwm, &state); if (error) { dev_err(dev, "failed to apply initial PWM state: %d\n", error); diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index acac79c488aa1..3e5ed685ed8f5 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c @@ -56,7 +56,7 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff); state.enabled = true; - err = pwm_apply_state(vibrator->pwm, &state); + err = pwm_apply_might_sleep(vibrator->pwm, &state); if (err) { dev_err(pdev, "failed to apply pwm state: %d\n", err); return err; @@ -67,7 +67,7 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) state.duty_cycle = vibrator->direction_duty_cycle; state.enabled = true; - err = pwm_apply_state(vibrator->pwm_dir, &state); + err = pwm_apply_might_sleep(vibrator->pwm_dir, &state); if (err) { dev_err(pdev, "failed to apply dir-pwm state: %d\n", err); pwm_disable(vibrator->pwm); @@ -160,7 +160,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev) /* Sync up PWM state and ensure it is off. */ pwm_init_state(vibrator->pwm, &state); state.enabled = false; - err = pwm_apply_state(vibrator->pwm, &state); + err = pwm_apply_might_sleep(vibrator->pwm, &state); if (err) { dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", err); @@ -174,7 +174,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev) /* Sync up PWM state and ensure it is off. */ pwm_init_state(vibrator->pwm_dir, &state); state.enabled = false; - err = pwm_apply_state(vibrator->pwm_dir, &state); + err = pwm_apply_might_sleep(vibrator->pwm_dir, &state); if (err) { dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", err); diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 2b3bf1353b707..4e3936a39d0ed 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -54,7 +54,7 @@ static int led_pwm_set(struct led_classdev *led_cdev, led_dat->pwmstate.duty_cycle = duty; led_dat->pwmstate.enabled = true; - return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate); + return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate); } __attribute__((nonnull)) diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds-pwm-multicolor.c index 46cd062b8b24c..e1a81e0109e8a 100644 --- a/drivers/leds/rgb/leds-pwm-multicolor.c +++ b/drivers/leds/rgb/leds-pwm-multicolor.c @@ -51,8 +51,8 @@ static int led_pwm_mc_set(struct led_classdev *cdev, priv->leds[i].state.duty_cycle = duty; priv->leds[i].state.enabled = duty > 0; - ret = pwm_apply_state(priv->leds[i].pwm, - &priv->leds[i].state); + ret = pwm_apply_might_sleep(priv->leds[i].pwm, + &priv->leds[i].state); if (ret) break; } diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c index c5f37c03af9c9..cf51e27609759 100644 --- a/drivers/media/rc/pwm-ir-tx.c +++ b/drivers/media/rc/pwm-ir-tx.c @@ -68,7 +68,7 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, for (i = 0; i < count; i++) { state.enabled = !(i % 2); - pwm_apply_state(pwm, &state); + pwm_apply_might_sleep(pwm, &state); edge = ktime_add_us(edge, txbuf[i]); delta = ktime_us_delta(edge, ktime_get()); @@ -77,7 +77,7 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, } state.enabled = false; - pwm_apply_state(pwm, &state); + pwm_apply_might_sleep(pwm, &state); return count; } diff --git a/drivers/platform/x86/lenovo-yogabook.c b/drivers/platform/x86/lenovo-yogabook.c index b8d0239192cbf..fd62bf746ebde 100644 --- a/drivers/platform/x86/lenovo-yogabook.c +++ b/drivers/platform/x86/lenovo-yogabook.c @@ -435,7 +435,7 @@ static int yogabook_pdev_set_kbd_backlight(struct yogabook_data *data, u8 level) .enabled = level, }; - pwm_apply_state(data->kbd_bl_pwm, &state); + pwm_apply_might_sleep(data->kbd_bl_pwm, &state); gpiod_set_value(data->kbd_bl_led_enable, level ? 1 : 0); return 0; } diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index f60b715abe62b..c2d78136625d5 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -326,8 +326,8 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, } EXPORT_SYMBOL_GPL(pwm_request_from_chip); -static void pwm_apply_state_debug(struct pwm_device *pwm, - const struct pwm_state *state) +static void pwm_apply_debug(struct pwm_device *pwm, + const struct pwm_state *state) { struct pwm_state *last = &pwm->last; struct pwm_chip *chip = pwm->chip; @@ -433,11 +433,11 @@ static void pwm_apply_state_debug(struct pwm_device *pwm, } /** - * pwm_apply_state() - atomically apply a new state to a PWM device + * pwm_apply_might_sleep() - atomically apply a new state to a PWM device * @pwm: PWM device * @state: new state to apply */ -int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) +int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) { struct pwm_chip *chip; int err; @@ -445,7 +445,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) /* * Some lowlevel driver's implementations of .apply() make use of * mutexes, also with some drivers only returning when the new - * configuration is active calling pwm_apply_state() from atomic context + * configuration is active calling pwm_apply_might_sleep() from atomic context * is a bad idea. So make it explicit that calling this function might * sleep. */ @@ -475,11 +475,11 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) * only do this after pwm->state was applied as some * implementations of .get_state depend on this */ - pwm_apply_state_debug(pwm, state); + pwm_apply_debug(pwm, state); return 0; } -EXPORT_SYMBOL_GPL(pwm_apply_state); +EXPORT_SYMBOL_GPL(pwm_apply_might_sleep); /** * pwm_capture() - capture and report a PWM signal @@ -537,7 +537,7 @@ int pwm_adjust_config(struct pwm_device *pwm) state.period = pargs.period; state.polarity = pargs.polarity; - return pwm_apply_state(pwm, &state); + return pwm_apply_might_sleep(pwm, &state); } /* @@ -560,7 +560,7 @@ int pwm_adjust_config(struct pwm_device *pwm) state.duty_cycle = state.period - state.duty_cycle; } - return pwm_apply_state(pwm, &state); + return pwm_apply_might_sleep(pwm, &state); } EXPORT_SYMBOL_GPL(pwm_adjust_config); diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c index 8a870d0db3c69..c670ccb816536 100644 --- a/drivers/pwm/pwm-twl-led.c +++ b/drivers/pwm/pwm-twl-led.c @@ -172,7 +172,7 @@ static int twl4030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm, * We cannot skip calling ->config even if state->period == * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle * because we might have exited early in the last call to - * pwm_apply_state because of !state->enabled and so the two values in + * pwm_apply_might_sleep because of !state->enabled and so the two values in * pwm->state might not be configured in hardware. */ ret = twl4030_pwmled_config(chip, pwm, diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c index bdea60389487e..7bfeacee05d0f 100644 --- a/drivers/pwm/pwm-vt8500.c +++ b/drivers/pwm/pwm-vt8500.c @@ -206,7 +206,7 @@ static int vt8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, * We cannot skip calling ->config even if state->period == * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle * because we might have exited early in the last call to - * pwm_apply_state because of !state->enabled and so the two values in + * pwm_apply_might_sleep because of !state->enabled and so the two values in * pwm->state might not be configured in hardware. */ err = vt8500_pwm_config(chip, pwm, state->duty_cycle, state->period); diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 4edb994fa2e12..1698609d91c8a 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -62,7 +62,7 @@ static ssize_t period_store(struct device *child, mutex_lock(&export->lock); pwm_get_state(pwm, &state); state.period = val; - ret = pwm_apply_state(pwm, &state); + ret = pwm_apply_might_sleep(pwm, &state); mutex_unlock(&export->lock); return ret ? : size; @@ -97,7 +97,7 @@ static ssize_t duty_cycle_store(struct device *child, mutex_lock(&export->lock); pwm_get_state(pwm, &state); state.duty_cycle = val; - ret = pwm_apply_state(pwm, &state); + ret = pwm_apply_might_sleep(pwm, &state); mutex_unlock(&export->lock); return ret ? : size; @@ -144,7 +144,7 @@ static ssize_t enable_store(struct device *child, goto unlock; } - ret = pwm_apply_state(pwm, &state); + ret = pwm_apply_might_sleep(pwm, &state); unlock: mutex_unlock(&export->lock); @@ -194,7 +194,7 @@ static ssize_t polarity_store(struct device *child, mutex_lock(&export->lock); pwm_get_state(pwm, &state); state.polarity = polarity; - ret = pwm_apply_state(pwm, &state); + ret = pwm_apply_might_sleep(pwm, &state); mutex_unlock(&export->lock); return ret ? : size; @@ -401,7 +401,7 @@ static int pwm_class_apply_state(struct pwm_export *export, struct pwm_device *pwm, struct pwm_state *state) { - int ret = pwm_apply_state(pwm, state); + int ret = pwm_apply_might_sleep(pwm, state); /* release lock taken in pwm_class_get_state */ mutex_unlock(&export->lock); diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 2aff6db748e2c..698c420e0869b 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -90,7 +90,7 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev, pwm_set_relative_duty_cycle(&pstate, drvdata->duty_cycle_table[selector].dutycycle, 100); - ret = pwm_apply_state(drvdata->pwm, &pstate); + ret = pwm_apply_might_sleep(drvdata->pwm, &pstate); if (ret) { dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret); return ret; @@ -216,7 +216,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, pwm_set_relative_duty_cycle(&pstate, dutycycle, duty_unit); - ret = pwm_apply_state(drvdata->pwm, &pstate); + ret = pwm_apply_might_sleep(drvdata->pwm, &pstate); if (ret) { dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret); return ret; diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 8fcb62be597b8..a3412c936ca28 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -180,7 +180,7 @@ static int lm3630a_pwm_ctrl(struct lm3630a_chip *pchip, int br, int br_max) pchip->pwmd_state.enabled = pchip->pwmd_state.duty_cycle ? true : false; - return pwm_apply_state(pchip->pwmd, &pchip->pwmd_state); + return pwm_apply_might_sleep(pchip->pwmd, &pchip->pwmd_state); } /* update and get brightness */ diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index da1f124db69c0..7075bfab59c4d 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -234,7 +234,7 @@ static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) state.duty_cycle = div_u64(br * state.period, max_br); state.enabled = state.duty_cycle; - return pwm_apply_state(lp->pwm, &state); + return pwm_apply_might_sleep(lp->pwm, &state); } static int lp855x_bl_update_status(struct backlight_device *bl) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 289bd9ce4d36d..35c716e9043c3 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -103,7 +103,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl) pwm_get_state(pb->pwm, &state); state.duty_cycle = compute_duty_cycle(pb, brightness, &state); state.enabled = true; - pwm_apply_state(pb->pwm, &state); + pwm_apply_might_sleep(pb->pwm, &state); pwm_backlight_power_on(pb); } else { @@ -120,7 +120,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl) * inactive output. */ state.enabled = !pb->power_supply && !pb->enable_gpio; - pwm_apply_state(pb->pwm, &state); + pwm_apply_might_sleep(pb->pwm, &state); } if (pb->notify_after) @@ -528,7 +528,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) if (!state.period && (data->pwm_period_ns > 0)) state.period = data->pwm_period_ns; - ret = pwm_apply_state(pb->pwm, &state); + ret = pwm_apply_might_sleep(pb->pwm, &state); if (ret) { dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", ret); @@ -633,7 +633,7 @@ static void pwm_backlight_remove(struct platform_device *pdev) pwm_get_state(pb->pwm, &state); state.duty_cycle = 0; state.enabled = false; - pwm_apply_state(pb->pwm, &state); + pwm_apply_might_sleep(pb->pwm, &state); if (pb->exit) pb->exit(&pdev->dev); @@ -649,7 +649,7 @@ static void pwm_backlight_shutdown(struct platform_device *pdev) pwm_get_state(pb->pwm, &state); state.duty_cycle = 0; state.enabled = false; - pwm_apply_state(pb->pwm, &state); + pwm_apply_might_sleep(pb->pwm, &state); } #ifdef CONFIG_PM_SLEEP @@ -673,7 +673,7 @@ static int pwm_backlight_suspend(struct device *dev) pwm_get_state(pb->pwm, &state); state.duty_cycle = 0; state.enabled = false; - pwm_apply_state(pb->pwm, &state); + pwm_apply_might_sleep(pb->pwm, &state); if (pb->notify_after) pb->notify_after(pb->dev, 0); diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 5ae48e36fccb4..1a4f90ea7d5a8 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -347,7 +347,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) pwm_init_state(par->pwm, &pwmstate); pwm_set_relative_duty_cycle(&pwmstate, 50, 100); - pwm_apply_state(par->pwm, &pwmstate); + pwm_apply_might_sleep(par->pwm, &pwmstate); /* Enable the PWM */ pwm_enable(par->pwm); diff --git a/include/linux/pwm.h b/include/linux/pwm.h index f87655c06c825..b64b8a82415c4 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -92,8 +92,8 @@ struct pwm_device { * @state: state to fill with the current PWM state * * The returned PWM state represents the state that was applied by a previous call to - * pwm_apply_state(). Drivers may have to slightly tweak that state before programming it to - * hardware. If pwm_apply_state() was never called, this returns either the current hardware + * pwm_apply_might_sleep(). Drivers may have to slightly tweak that state before programming it to + * hardware. If pwm_apply_might_sleep() was never called, this returns either the current hardware * state (if supported) or the default settings. */ static inline void pwm_get_state(const struct pwm_device *pwm, @@ -157,20 +157,20 @@ static inline void pwm_get_args(const struct pwm_device *pwm, } /** - * pwm_init_state() - prepare a new state to be applied with pwm_apply_state() + * pwm_init_state() - prepare a new state to be applied with pwm_apply_might_sleep() * @pwm: PWM device * @state: state to fill with the prepared PWM state * * This functions prepares a state that can later be tweaked and applied - * to the PWM device with pwm_apply_state(). This is a convenient function + * to the PWM device with pwm_apply_might_sleep(). This is a convenient function * that first retrieves the current PWM state and the replaces the period * and polarity fields with the reference values defined in pwm->args. * Once the function returns, you can adjust the ->enabled and ->duty_cycle - * fields according to your needs before calling pwm_apply_state(). + * fields according to your needs before calling pwm_apply_might_sleep(). * * ->duty_cycle is initially set to zero to avoid cases where the current * ->duty_cycle value exceed the pwm_args->period one, which would trigger - * an error if the user calls pwm_apply_state() without adjusting ->duty_cycle + * an error if the user calls pwm_apply_might_sleep() without adjusting ->duty_cycle * first. */ static inline void pwm_init_state(const struct pwm_device *pwm, @@ -226,7 +226,7 @@ pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale) * * pwm_init_state(pwm, &state); * pwm_set_relative_duty_cycle(&state, 50, 100); - * pwm_apply_state(pwm, &state); + * pwm_apply_might_sleep(pwm, &state); * * This functions returns -EINVAL if @duty_cycle and/or @scale are * inconsistent (@scale == 0 or @duty_cycle > @scale). @@ -304,7 +304,7 @@ struct pwm_chip { #if IS_ENABLED(CONFIG_PWM) /* PWM user APIs */ -int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state); +int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state); int pwm_adjust_config(struct pwm_device *pwm); /** @@ -332,7 +332,7 @@ static inline int pwm_config(struct pwm_device *pwm, int duty_ns, state.duty_cycle = duty_ns; state.period = period_ns; - return pwm_apply_state(pwm, &state); + return pwm_apply_might_sleep(pwm, &state); } /** @@ -353,7 +353,7 @@ static inline int pwm_enable(struct pwm_device *pwm) return 0; state.enabled = true; - return pwm_apply_state(pwm, &state); + return pwm_apply_might_sleep(pwm, &state); } /** @@ -372,7 +372,7 @@ static inline void pwm_disable(struct pwm_device *pwm) return; state.enabled = false; - pwm_apply_state(pwm, &state); + pwm_apply_might_sleep(pwm, &state); } /* PWM provider APIs */ @@ -403,8 +403,8 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode, const char *con_id); #else -static inline int pwm_apply_state(struct pwm_device *pwm, - const struct pwm_state *state) +static inline int pwm_apply_might_sleep(struct pwm_device *pwm, + const struct pwm_state *state) { might_sleep(); return -ENOTSUPP; @@ -521,7 +521,7 @@ static inline void pwm_apply_args(struct pwm_device *pwm) state.period = pwm->args.period; state.usage_power = false; - pwm_apply_state(pwm, &state); + pwm_apply_might_sleep(pwm, &state); } struct pwm_lookup { From patchwork Tue Dec 12 08:34:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585565vqy; Tue, 12 Dec 2023 00:34:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFUAV07TLGYyZ32IhS4PGWRZ3urxcnc7wxgPEiGF7LFgraW/iVSaokchdyeCSe8A2aDh0i X-Received: by 2002:a17:90a:8812:b0:28a:cdbc:a5d with SMTP id s18-20020a17090a881200b0028acdbc0a5dmr9469pjn.95.1702370083980; Tue, 12 Dec 2023 00:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370083; cv=none; d=google.com; s=arc-20160816; b=TxJuWqy8uaJ3QfqwlfCR9EQjfrfkdCGGpPrq0SFC3svuwQ0Zog0lvbZBniPop1XPJ3 Nn2BYBkJFS/P8WvworbgNlAMclsvC8oEtj7nAWAOMfcEJt8839Wueir0KCmltEcBNR4L 7bip4Bgo/JLpxAUFkIGyyhHDXqs9iTN98IwTSOEYHeMtXss3G1nPEZCAIrCfsRjbtHs/ P9eSSI3tz+QU03Lv6orzIZnUyfe8PepmZEGZ9hIS2aopfx0swP7zs7q5LOim+rz+Gid3 mk8fL/sOcfyzWILPPzAwlNcsWhRPGsoS9+gybOzna/Da6edLRC5o1MK4IqILxfMkgaiy W4ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=fM44Zn5u6MCt9p/c94+xGZM6H6tjUzx4kUmLWPIZZVE=; fh=G36Ufr6lzVczrOndx/ne0QnYCnZHT0W+s6wWJgcb5Qs=; b=mT/MCfGB9XbOiK/FxVNKOmobvsWcTB5jrow+u2JTEMkO0+YUDLZGP61XP4bcut+OoS ExQ/x+D/XC/mG3yP+kM4oZVRWBt6cJVmG4U2br1gzIWdJVwuZ84TKPMFnh8OAJFSEA37 HCmo91MRgPm5+si/HkhEF5a2sXRITZ4v5awpSD3MX4TMCrkRxYS36kby4mZIdK3J0npW PpyHARYR9ZswiPl/NCKtWzqiwboCyYnGbwd6DjDUnNfGvBnL8ZaNT1zaYSgljt4fPR8j 0iXR94/HOMwR47p0fyg61OaBNg8MQQbl/ywRZz6INJhbDVMILtGFKu1wTjw32ojejP/o RD9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=QHRl9oXF; dkim=pass header.i=@mess.org header.s=2020 header.b="V6n+/2VG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id co7-20020a17090afe8700b0028ab57a7191si1166402pjb.65.2023.12.12.00.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=QHRl9oXF; dkim=pass header.i=@mess.org header.s=2020 header.b="V6n+/2VG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 42FA5809F3BE; Tue, 12 Dec 2023 00:34:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjLLIeb (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjLLIea (ORCPT ); Tue, 12 Dec 2023 03:34:30 -0500 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C7D3D5; Tue, 12 Dec 2023 00:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370075; bh=ZJmg/D8rsDFVuY4KX2dLUs2GuRoQzlNEMePV81ScWU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHRl9oXFwz+oATGHYO7Wt2O7MVCDV7AS1PIAwv+DEGG+wGUP4JdJRtv/1vAzQ+pia jOw6b/QuFJK8B3WfYtDLBfjBmXxTny/xUk6PrA7GUoqoIj7gJbnDexazRAbXKcRlHa 8Ipg9/0kRfWyu+XSQeSk9t5NBMubd3itDviCQjbWv+q4qsPvquPNI2uX4J4Wj6SXhj Dl/Gi0Tl/QjIMPHzZPMdXynAPogHaNsJRqePfpiwjuQJoiKo+Z/WUTDPANYdcJJrj8 xs5WwJfiN+82te8A0I++qXH5YJlzR+ngCCv/qmYGF3sUpbDeUr2fHCiqiFhO9ZOzmN nIOxbbHE13A3g== Received: by gofer.mess.org (Postfix, from userid 501) id 88115100A05; Tue, 12 Dec 2023 08:34:35 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370061; bh=ZJmg/D8rsDFVuY4KX2dLUs2GuRoQzlNEMePV81ScWU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V6n+/2VGWhYLAjdpbbPUxOdcp9ocm7vur5ZTEBEnYtOeuzEa50TfwgN7QCEf+nNQS 2JczxWc9pfIdw6V03tu6XNWKeCvWSS+mhOif4e3HF/fhqRnxLIMMpOkhpWDv+l4gBJ rv0PJn198Q3JdEPfVm7U2vBLcVDg4PpZhC+0RrEHHmn63ZIr68pn4Pz78bvcBaqKuz clvKRtJZdutLfr0BY7hHRfCZMYDvacvOpkN8LBHbFUwLwoU7QPdOb+DaxP62yM7DYn 3fVrQxS2/fZC5ZfaaZDXqE1h23FG63I7NjYYnzb5EJsTyvMk0OX4ZyIzExparbA/ha UWDxHESeRxSkw== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id E58521002A3; Tue, 12 Dec 2023 08:34:21 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Sean Young , linux-kernel@vger.kernel.org Subject: [PATCH v8 2/6] pwm: Replace ENOTSUPP with EOPNOTSUPP Date: Tue, 12 Dec 2023 08:34:01 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:34:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064413545335416 X-GMAIL-MSGID: 1785064413545335416 ENOTSUPP is not a standard error code and should be avoided. Signed-off-by: Sean Young --- include/linux/pwm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/pwm.h b/include/linux/pwm.h index b64b8a82415c4..c9cb87b59ac80 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -407,12 +407,12 @@ static inline int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) { might_sleep(); - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int pwm_adjust_config(struct pwm_device *pwm) { - return -ENOTSUPP; + return -EOPNOTSUPP; } static inline int pwm_config(struct pwm_device *pwm, int duty_ns, From patchwork Tue Dec 12 08:34:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585705vqy; Tue, 12 Dec 2023 00:35:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO92teiGbdG/33Sjncg1a6eZYQ7D5T1aYOigyi5A82knJgVi7Kc7JC1IBuO4noeQCAl1HG X-Received: by 2002:a05:6e02:1a0a:b0:35d:5db6:cf9 with SMTP id s10-20020a056e021a0a00b0035d5db60cf9mr6500277ild.30.1702370106848; Tue, 12 Dec 2023 00:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370106; cv=none; d=google.com; s=arc-20160816; b=1LHMW9Atg1Lh5UCnDFMY4NBu+or+2kGj5jKWr5JlWRJU+ZoooymuAptQa2bYTHtFxO CqG6Rked4Fd/zHJG4iQqAAkoNvbtD1LynV4GxHD+3+O8aVUhC3m3djoQ974N0f0IP8fK 0Po/Wb2PVf/jhtW5JncG976eJMyRVC/XBwNV3DwzLiGOZpDSZqI6ouGBGGzy7pGC0lI5 r+biQglSfnitmFjC57ACpexy1xqQFyqzIpqNkOGtTTKU/heC+1V26uclk1Y/7jvcxABm kHLq3AcSMBDoBAdY+DJGe2hwYSWKZX2bEsEmsT2WbbydBIMrXMQhosopBy5pdP2TjBUP EB9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=pxbDpfXFxGPQYRfqvLuDznuiG7ZEXglAN5UKcwMp6do=; fh=G36Ufr6lzVczrOndx/ne0QnYCnZHT0W+s6wWJgcb5Qs=; b=AXuCGS3Qm92rkBh6EO2fwe2iDoistvPv3Ocejr6uMfIJBVM6Wi9ImzF9fBb1Ixh3a3 Jq3r/KyB5niyh5CV9UZerEs3tC/fHdSqJhI5VqSg45Ns9gUKE5FTCTp428dsD1xWC61Q +Wc9LM85pV1kI3CZtkTyqrl1Om0r2EKFdpCxZ7mnZHWAel7ZIpSrecc1lYeyVB0Sc2ee HYLb/OfNVqR9oX4ptdJt6BRbh1Cz6tW58PMCNTPaoVvX9NrZCuFkGXcuo3XnGjTPK9eh JyNpEBsoaV+dBDr+MEWFYluTyoczZrYQq77z/RrjmVlm6dRnTt+uDkyNfG0EncNZh1B4 FuGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="kyqBLI/O"; dkim=pass header.i=@mess.org header.s=2020 header.b=V7HBSbPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id by32-20020a056a0205a000b005be1ee5bea2si7699273pgb.374.2023.12.12.00.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:35:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="kyqBLI/O"; dkim=pass header.i=@mess.org header.s=2020 header.b=V7HBSbPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 8E8998067A87; Tue, 12 Dec 2023 00:35:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbjLLIed (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjLLIeb (ORCPT ); Tue, 12 Dec 2023 03:34:31 -0500 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B8DF4; Tue, 12 Dec 2023 00:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370077; bh=zLSyEthe/4DdR0aMOzSw83eC3jPiBmnxF3nl//8MZOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyqBLI/OkkMdG6cucpZJFmVXKgh5VPYfOk21KK0u9B6fUAKfQXegJsAUdTmf4gqlj yOQhi7iFqqaYdbrJtYDXgxTjaD8C8mLR9s77oorZPMGa+P5qE81veVyuxIyedTyKDB wuEFj3q/M0XjC+fHizVAIUYIE749XV7ce5SxOdPbINMj64QoC+JDtBLSBnVLuK4l0I ZXz55vYWH1CYLDGyK2CbGuSyDX5NRWPiiGMP8HWb0DVJ7hNxQn+Hs55py7jFZoMzow 2r3qWklXrDK05o1RfMlBCTww2P0ObxTz1X3Rd2TvUKpSqupCsk4wy9/aaCds2hJr6o hyJ6hlfIV4u7w== Received: by gofer.mess.org (Postfix, from userid 501) id 14317100A0A; Tue, 12 Dec 2023 08:34:37 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370062; bh=zLSyEthe/4DdR0aMOzSw83eC3jPiBmnxF3nl//8MZOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7HBSbPRNlgNEn/WY/PFOS1JEExoS8AETzZ7hNtdRp7LLT/w9/xlkdK4y7NLWJQ2k Zsv36ias08FSMct0CpsubAIfFg/n3XzW3vczfBAgiBjoMGp2KzL0uJXYo3tSQtHYaE +jbzf4Gd9LhXr9jgidPeciI90Q+q206fS5DgmZu9S2F7Lp1NvrDIWfXJj6yPmdF/Ji v61xT4EfXvLrRKYHJiT7BFxwyuOHlHrmp7uZRYznA28V7sv3AE64VO5JjogzBf7mVq riHgJKENAUunnS9GUvnM/avtFghNxAsVRNiOyMyKCjgtGyZafJobM7miIIo82BXB+S /ATUaiKvk8E6w== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id 332A610006D; Tue, 12 Dec 2023 08:34:22 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Sean Young , linux-kernel@vger.kernel.org Subject: [PATCH v8 3/6] pwm: renesas: Remove unused include Date: Tue, 12 Dec 2023 08:34:02 +0000 Message-ID: <4c135f9cd23592b1646a4151e86ef4ea0321d4ef.1702369869.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:35:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064437170040617 X-GMAIL-MSGID: 1785064437170040617 No mutex is used in this driver. Signed-off-by: Sean Young Reviewed-by: Uwe Kleine-König --- drivers/pwm/pwm-renesas-tpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c index ce92db1f85113..28265fdfc92a9 100644 --- a/drivers/pwm/pwm-renesas-tpu.c +++ b/drivers/pwm/pwm-renesas-tpu.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include From patchwork Tue Dec 12 08:34:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585609vqy; Tue, 12 Dec 2023 00:34:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZBTSlycUgePQJhprPO0noLsiN5mXxBEcGq8TWfkahkb8ebOmybse0SRDTTn85U3W5RP2E X-Received: by 2002:a05:6a20:5d2:b0:190:8d36:550c with SMTP id r18-20020a056a2005d200b001908d36550cmr4484615pzr.53.1702370093669; Tue, 12 Dec 2023 00:34:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370093; cv=none; d=google.com; s=arc-20160816; b=ievpr6JdAAn3PyrQ+jq3pLMaJ0/TLL+yLEgcuSTTtTobeUJgvQzZ3Lg+xZvKcyYn9E lvrjaMhGCvH6dFBZX9Da89OrAWRiTnl2K8RIR28Oni6mfgKPwgzle7yCLisKcjJqQZD9 oy4RcAYLnFEMi1WcNLUzMEEGZ06XEy/w2Wukupt6j3FQWiYKfreJQaUBeqPtdT4YAEQ/ mPVnGzGk1/FnXajIFDE8lDT6yg39ldqUvZBm3ZOlNR6WE3mn3+vWVZEYLriXuG5F84PV mX9po9/Vvek6CBdMGzLjSNdRu/JGPgJpKP9qhK1Ae0uIZ6QYgRfKbI5glfjl4H71eIEk 7Jhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=BvqVV3yamIgHsoxjX0UcKC2yM1X/uz/0DHcI2xAIapU=; fh=xi/MSaxLTzLfOvSuzBMM1/60ApIuTUoD+htsskhpbNk=; b=plvpKI2KA7bZCoPJetJJDbdShr3M/Z9S88haeWpATQ2FcQDOxrXZiMF1wmqDUPr6vr OWq0RAfmpH8erXwQKEa2qzYwVl1od5Pkw3VYTsaMcxbfhyS6EoDHzu3Qy9j8jf/g9QA4 uxZF7UxAcN352bvS4C5y1QIpd/wc1AJAvIwh3Ev/LDVcWZg81kCISKXreyZtEJ0lmPFd NiS12ZkyGNIHRV/NDZp460y9EmwzPgZR6aPEyy3gqYeJ9WLpHBdPzzCeGeRTz6Vab96+ Mq5fdsxgOvEbEtI3Ueepa4+8A2zKQupMTspD7aWNB7ZS8/ziSfTCUORgXfIhW6XFobrS citQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=QPnsgTfo; dkim=pass header.i=@mess.org header.s=2020 header.b=HT4lKnG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n3-20020a632703000000b005b99bfe3301si7592455pgn.462.2023.12.12.00.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:34:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=QPnsgTfo; dkim=pass header.i=@mess.org header.s=2020 header.b=HT4lKnG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 736E1806AFC2; Tue, 12 Dec 2023 00:34:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346007AbjLLIej (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbjLLIed (ORCPT ); Tue, 12 Dec 2023 03:34:33 -0500 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2BC10B; Tue, 12 Dec 2023 00:34:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370078; bh=2Pw20VBRXdfmL7SgSifOivpj0hhLB50AYu53xedYzp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPnsgTfoV8z5MFBYObjmfuemhy4aTCLgCEMCdIEtFyDoYi8H78j7BTr42Ma/paCCt MyBGgYsCW8KXuD/nPelBP0M2Iq6NBGy0JirzvtlWiRmMIGgcdKCner2LIXrY2kLbYh fBEiy5vM0l8oFtnuGroUAEDmHFwIFuDZNrsQVmurvBzunmZznfHrvr7liPaipulbN4 cexoDXH8FStEcVzcqw6BiexGlUjfU4V/EEIry8QcI1qyuCW5U/PzFLKySiPFQREalG SpRA0xCweZA+Z33PmAw0zmPNh7L5aRNg38z9yCF2tqLrEFe3UrfjKADyTK+Tv/x9eX bfgukpw5JV5ug== Received: by gofer.mess.org (Postfix, from userid 501) id 62E12100A03; Tue, 12 Dec 2023 08:34:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370062; bh=2Pw20VBRXdfmL7SgSifOivpj0hhLB50AYu53xedYzp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HT4lKnG42tiemYgOwTflbY2RrCzyFwlFqQsInBmJW8jRfRtPiz2mlY2ezOeQMnG4k XabBGFiVSKlWMBThdv4sF6MmLjtLSOWNskCcCF/Ew5v7CB0izzS7WsE/2m7bufX15N tR1H0cdbthcyOs5+Ph57h0CfWIOh/oiWqwdn/4ZM3VUC9FJ0wOayNb5KgCilL3HLrq 2Y7uA97oV38Wa3WnIfGcWGfQ2ESbj8D+A7pq4gooSrBbxPL6CuYwNj9QyvyzLLfuIu AFWMMPztzywuV+UfEh5Qw6mUUNymjJ/RCmGvDDeBd1pc1n1LVVPPnAhYTATTxDmIaX CwqsYp3RZEnww== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id A7C671009FC; Tue, 12 Dec 2023 08:34:22 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jonathan Corbet Cc: Sean Young , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 4/6] pwm: Make it possible to apply PWM changes in atomic context Date: Tue, 12 Dec 2023 08:34:03 +0000 Message-ID: <57f48330eb606356e86be17f85253f0e3d6ab104.1702369869.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:34:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064423630978444 X-GMAIL-MSGID: 1785064423630978444 Some PWM devices require sleeping, for example if the pwm device is connected over I2C. However, many PWM devices could be used from atomic context, e.g. memory mapped PWM. This is useful for, for example, the pwm-ir-tx driver which requires precise timing. Sleeping causes havoc with the generated IR signal. Since not all PWM devices can support atomic context, we also add a pwm_might_sleep() function to check if is not supported. Signed-off-by: Sean Young --- Documentation/driver-api/pwm.rst | 9 +++++ MAINTAINERS | 2 +- drivers/pwm/core.c | 67 +++++++++++++++++++++++++------- include/linux/pwm.h | 25 ++++++++++++ 4 files changed, 89 insertions(+), 14 deletions(-) diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst index f1d8197c8c430..3c28ccc4b6113 100644 --- a/Documentation/driver-api/pwm.rst +++ b/Documentation/driver-api/pwm.rst @@ -46,6 +46,15 @@ After being requested, a PWM has to be configured using:: This API controls both the PWM period/duty_cycle config and the enable/disable state. +PWM devices can be used from atomic context, if the PWM does not sleep. You +can check if this the case with:: + + bool pwm_might_sleep(struct pwm_device *pwm); + +If false, the PWM can also be configured from atomic context with:: + + int pwm_apply_atomic(struct pwm_device *pwm, struct pwm_state *state); + As a consumer, don't rely on the output's state for a disabled PWM. If it's easily possible, drivers are supposed to emit the inactive state, but some drivers cannot. If you rely on getting the inactive state, use .duty_cycle=0, diff --git a/MAINTAINERS b/MAINTAINERS index c584805952209..5342cf32d73ff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17576,7 +17576,7 @@ F: drivers/video/backlight/pwm_bl.c F: include/dt-bindings/pwm/ F: include/linux/pwm.h F: include/linux/pwm_backlight.h -K: pwm_(config|apply_might_sleep|ops) +K: pwm_(config|apply_might_sleep|apply_atomic|ops) PXA GPIO DRIVER M: Robert Jarzmik diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index c2d78136625d5..30c0623dbd5ba 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -433,24 +433,15 @@ static void pwm_apply_debug(struct pwm_device *pwm, } /** - * pwm_apply_might_sleep() - atomically apply a new state to a PWM device + * pwm_apply_unchecked() - atomically apply a new state to a PWM device * @pwm: PWM device * @state: new state to apply */ -int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) +static int pwm_apply_unchecked(struct pwm_device *pwm, const struct pwm_state *state) { struct pwm_chip *chip; int err; - /* - * Some lowlevel driver's implementations of .apply() make use of - * mutexes, also with some drivers only returning when the new - * configuration is active calling pwm_apply_might_sleep() from atomic context - * is a bad idea. So make it explicit that calling this function might - * sleep. - */ - might_sleep(); - if (!pwm || !state || !state->period || state->duty_cycle > state->period) return -EINVAL; @@ -471,16 +462,66 @@ int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) pwm->state = *state; + return 0; +} + +/** + * pwm_apply_might_sleep() - atomically apply a new state to a PWM device + * Cannot be used in atomic context. + * @pwm: PWM device + * @state: new state to apply + */ +int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) +{ + int err; + + /* + * Some lowlevel driver's implementations of .apply() make use of + * mutexes, also with some drivers only returning when the new + * configuration is active calling pwm_apply_might_sleep() from atomic context + * is a bad idea. So make it explicit that calling this function might + * sleep. + */ + might_sleep(); + + if (IS_ENABLED(CONFIG_PWM_DEBUG) && pwm->chip->atomic) { + /* + * Catch any drivers that have been marked as atomic but + * that will sleep anyway. + */ + non_block_start(); + err = pwm_apply_unchecked(pwm, state); + non_block_end(); + } else { + err = pwm_apply_unchecked(pwm, state); + } + /* * only do this after pwm->state was applied as some * implementations of .get_state depend on this */ - pwm_apply_debug(pwm, state); + if (!err) + pwm_apply_debug(pwm, state); - return 0; + return err; } EXPORT_SYMBOL_GPL(pwm_apply_might_sleep); +/** + * pwm_apply_atomic() - apply a new state to a PWM device from atomic context + * Not all PWM devices support this function, check with pwm_might_sleep(). + * @pwm: PWM device + * @state: new state to apply + */ +int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state) +{ + WARN_ONCE(!pwm->chip->atomic, + "sleeping PWM driver used in atomic context\n"); + + return pwm_apply_unchecked(pwm, state); +} +EXPORT_SYMBOL_GPL(pwm_apply_atomic); + /** * pwm_capture() - capture and report a PWM signal * @pwm: PWM device diff --git a/include/linux/pwm.h b/include/linux/pwm.h index c9cb87b59ac80..495af3627939c 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -285,6 +285,7 @@ struct pwm_ops { * @npwm: number of PWMs controlled by this chip * @of_xlate: request a PWM device given a device tree PWM specifier * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier + * @atomic: can the driver's ->apply() be called in atomic context * @pwms: array of PWM devices allocated by the framework */ struct pwm_chip { @@ -297,6 +298,7 @@ struct pwm_chip { struct pwm_device * (*of_xlate)(struct pwm_chip *chip, const struct of_phandle_args *args); unsigned int of_pwm_n_cells; + bool atomic; /* only used internally by the PWM framework */ struct pwm_device *pwms; @@ -305,6 +307,7 @@ struct pwm_chip { #if IS_ENABLED(CONFIG_PWM) /* PWM user APIs */ int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state); +int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state); int pwm_adjust_config(struct pwm_device *pwm); /** @@ -375,6 +378,17 @@ static inline void pwm_disable(struct pwm_device *pwm) pwm_apply_might_sleep(pwm, &state); } +/** + * pwm_might_sleep() - is pwm_apply_atomic() supported? + * @pwm: PWM device + * + * Returns: false if pwm_apply_atomic() can be called from atomic context. + */ +static inline bool pwm_might_sleep(struct pwm_device *pwm) +{ + return !pwm->chip->atomic; +} + /* PWM provider APIs */ int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result, unsigned long timeout); @@ -403,6 +417,11 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode, const char *con_id); #else +static inline bool pwm_might_sleep(struct pwm_device *pwm) +{ + return true; +} + static inline int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) { @@ -410,6 +429,12 @@ static inline int pwm_apply_might_sleep(struct pwm_device *pwm, return -EOPNOTSUPP; } +static inline int pwm_apply_atomic(struct pwm_device *pwm, + const struct pwm_state *state) +{ + return -EOPNOTSUPP; +} + static inline int pwm_adjust_config(struct pwm_device *pwm) { return -EOPNOTSUPP; From patchwork Tue Dec 12 08:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585918vqy; Tue, 12 Dec 2023 00:35:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsynQB1NlyNyOKtTI+QPvxGqdEav7yvPHkJw7UXRmFntDrthm6qK7PaFKDvT3nkiyjFQPA X-Received: by 2002:a17:902:7809:b0:1cf:bf7b:adf2 with SMTP id p9-20020a170902780900b001cfbf7badf2mr4524089pll.32.1702370142402; Tue, 12 Dec 2023 00:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370142; cv=none; d=google.com; s=arc-20160816; b=YEEMbLvp4l8jquHRdPKhsoqHn6WbCEmWjOmD3Ij7h+Jtd3nDXT9ZOtr0FVakIjjzUo u9JKdkBkarcvayyAj7w9uXr+w6wuseGsC3Q4BKHNOzvsrWGjvb6POJLrAN7+EvOTkwn7 E1PodRCmKLqKs4ozwaLXbglp5WlmHe8ZwVsizVukSQqzkDVdfE3TmZt2Mw1cQfdfC9Be kFI26o8H3svQxbt7em1yIkMoRvcRO93l0vgtqJVr6Otn8x+gUvHbUAUqcuIbZknWgmBK WE8mW5QS3DwezjpcUWHn8Sp/J+H0Sq3K1U4QtjPVV730PTMz86mP29jbayAmzYXpWQib dErw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=k6CahLzxd9gfK06yDIJqYxNYdWbJjN5d/Ro6XfVzsB8=; fh=qM8A1c4zxWggFvkRT+btn+KkCChDzIcE2Z4gmA3RbqY=; b=zxWB33SPPdCXms5jbKqm4V9vlks6fvvkoH3+0V8NWPafm+ThTKAFQPqvGjUd0ofK06 5B4DSMi7FYLL32jYDPg9VPbXdoYwDiAitdwGsHKkm3kPFfiWElCQ1twTeIpsT3GVT62w 51Iqcs2aBB46FpkPDq2bePj/9CHwHFgMfrQcvvpoIq0qmSuC1QkGsikLR0QqnxvgCaYg Iqhv/c9xOA+hUKRYYgKcq75ITMqiyOF2zbKLSwCcUXaXGU0lS6w9VGfp4UYhTUYlaKmv Av5yUp23Uu1+mr11qzErHL/0L2I8eKHJ8RfQM2dgeS9Q/KFYKJzrrk1lof3UwBGv0aKg iJOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=PdDHjwkZ; dkim=pass header.i=@mess.org header.s=2020 header.b="pxTwT/yu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b17-20020a170902d89100b001d2eca39503si530859plz.489.2023.12.12.00.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:35:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=PdDHjwkZ; dkim=pass header.i=@mess.org header.s=2020 header.b="pxTwT/yu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 313D68076E7B; Tue, 12 Dec 2023 00:35:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbjLLIeq (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345813AbjLLIef (ORCPT ); Tue, 12 Dec 2023 03:34:35 -0500 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63549F4; Tue, 12 Dec 2023 00:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370080; bh=gTEti/8B23Lhh743tVWTymBVRCEpQHU5KFyCDk5okO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PdDHjwkZrYIpKreAFvesoE6terpFGKIBaIpiJymKWFojQgagbOR7wt/H9h3zHDB4x HDXSUnbRhdpTkk2ugLr09zocrWcHJWIgxWb+wZpEWgiVyW+qNY/ywFziMPHLsBRpTb HQ57NtBJmsOJYA/w3DqxF2DfeWn8gkyFbq+r1D/6RbV4fuGLWAu8Q1/o/4XS0fj/z3 kY8o6KqnV9rhRbD8ZGfyCOuZDGovctXBKZquOFFP81ybVD9qeU5VjTTYf1Zc/GgcQQ moNLrbxsreLm/rJIPjMdmPpiWWz803eI9q0LJ0hpok+EKeSw6+bBoPAC6tQ8q3qq1U fV92GYeNxpNbA== Received: by gofer.mess.org (Postfix, from userid 501) id 37EAB100A00; Tue, 12 Dec 2023 08:34:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370062; bh=gTEti/8B23Lhh743tVWTymBVRCEpQHU5KFyCDk5okO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxTwT/yu6GbqALKFR6VoMRiIFXgE8GntD/iXPUVaPjQfJF49/FqkAtQtcpqxIqV3o ZwIMYifyK/VqRJ8JJx7/w1+8wXYCfmh3uj/uOEGMURFEM5ZtwNsschKbRYti5WuRuS 8DoHG+Ltz0a245V2kiAOds0OHKmz8Nw/4PHv/JDWhuKIkG9TofUYGeq5MzQabz9xWf KBW32GBSlXHVVSrAy9lBSNOnXoovEB4VQ/M1gkK0bs4uSOALyuMuyFI65YqBkVGD0J nRbpeqEI05LIVcGyqtQhokCAyMxV3hX5Eb24TBppmawjv2X8ZTOWEKKFM/iykl0LuW y/a7gJlj2/Z/g== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id E672310029E; Tue, 12 Dec 2023 08:34:22 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden Cc: Sean Young , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context Date: Tue, 12 Dec 2023 08:34:04 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:35:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064474539622989 X-GMAIL-MSGID: 1785064474539622989 clk_get_rate() may do a mutex lock. Fetch the clock rate once, and prevent rate changes using clk_rate_exclusive_get(). Signed-off-by: Sean Young Reviewed-by: Florian Fainelli Reviewed-by: Uwe Kleine-König --- drivers/pwm/pwm-bcm2835.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index ab30667f4f951..309d52ec43bbe 100644 --- a/drivers/pwm/pwm-bcm2835.c +++ b/drivers/pwm/pwm-bcm2835.c @@ -28,6 +28,7 @@ struct bcm2835_pwm { struct device *dev; void __iomem *base; struct clk *clk; + unsigned long rate; }; static inline struct bcm2835_pwm *to_bcm2835_pwm(struct pwm_chip *chip) @@ -63,17 +64,11 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, { struct bcm2835_pwm *pc = to_bcm2835_pwm(chip); - unsigned long rate = clk_get_rate(pc->clk); unsigned long long period_cycles; u64 max_period; u32 val; - if (!rate) { - dev_err(pc->dev, "failed to get clock rate\n"); - return -EINVAL; - } - /* * period_cycles must be a 32 bit value, so period * rate / NSEC_PER_SEC * must be <= U32_MAX. As U32_MAX * NSEC_PER_SEC < U64_MAX the @@ -88,13 +83,13 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, * <=> period < ((U32_MAX * NSEC_PER_SEC + NSEC_PER_SEC/2) / rate * <=> period <= ceil((U32_MAX * NSEC_PER_SEC + NSEC_PER_SEC/2) / rate) - 1 */ - max_period = DIV_ROUND_UP_ULL((u64)U32_MAX * NSEC_PER_SEC + NSEC_PER_SEC / 2, rate) - 1; + max_period = DIV_ROUND_UP_ULL((u64)U32_MAX * NSEC_PER_SEC + NSEC_PER_SEC / 2, pc->rate) - 1; if (state->period > max_period) return -EINVAL; /* set period */ - period_cycles = DIV_ROUND_CLOSEST_ULL(state->period * rate, NSEC_PER_SEC); + period_cycles = DIV_ROUND_CLOSEST_ULL(state->period * pc->rate, NSEC_PER_SEC); /* don't accept a period that is too small */ if (period_cycles < PERIOD_MIN) @@ -103,7 +98,7 @@ static int bcm2835_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, writel(period_cycles, pc->base + PERIOD(pwm->hwpwm)); /* set duty cycle */ - val = DIV_ROUND_CLOSEST_ULL(state->duty_cycle * rate, NSEC_PER_SEC); + val = DIV_ROUND_CLOSEST_ULL(state->duty_cycle * pc->rate, NSEC_PER_SEC); writel(val, pc->base + DUTY(pwm->hwpwm)); /* set polarity */ @@ -151,16 +146,31 @@ static int bcm2835_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk), "clock not found\n"); + ret = clk_rate_exclusive_get(pc->clk); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "fail to get exclusive rate\n"); + + pc->rate = clk_get_rate(pc->clk); + if (!pc->rate) { + clk_rate_exclusive_put(pc->clk); + return dev_err_probe(&pdev->dev, -EINVAL, + "failed to get clock rate\n"); + } + pc->chip.dev = &pdev->dev; pc->chip.ops = &bcm2835_pwm_ops; + pc->chip.atomic = true; pc->chip.npwm = 2; platform_set_drvdata(pdev, pc); ret = devm_pwmchip_add(&pdev->dev, &pc->chip); - if (ret < 0) + if (ret < 0) { + clk_rate_exclusive_put(pc->clk); return dev_err_probe(&pdev->dev, ret, "failed to add pwmchip\n"); + } return 0; } @@ -169,6 +179,7 @@ static int bcm2835_pwm_suspend(struct device *dev) { struct bcm2835_pwm *pc = dev_get_drvdata(dev); + clk_rate_exclusive_put(pc->clk); clk_disable_unprepare(pc->clk); return 0; From patchwork Tue Dec 12 08:34:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 177180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7585911vqy; Tue, 12 Dec 2023 00:35:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaT7kOmaVlLfS2ObXowCKW98RDq81ZJ4aOFBTYljEygELeOQGz/qzHCeY4mzmsVkkweORq X-Received: by 2002:a05:6359:489e:b0:170:17eb:2054 with SMTP id ok30-20020a056359489e00b0017017eb2054mr4734779rwb.61.1702370141730; Tue, 12 Dec 2023 00:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370141; cv=none; d=google.com; s=arc-20160816; b=lR0FOcjsqtM2h4590mbilOdRO+LlNQCQavhU0oRmRkicLljQXjxVxSo0rqxJzQwG/F GrQskFpkEr76fnrCBa8FFe5T7NB+PEg6HCdk6p3a0NMz3ibct+/EMIBUhvKWY8kaCBo3 VcwhbzclvKHC60vvWZ4yP2fhWIaYwF1E3WdEIEskFWd9VROwnuQ7pUWzhJmau+oPlf1W bYBvHj61/cM/AYb0IWAHA+XdW1tMjqtO5Qw4KV5IvUlKAaXMRdCSFc+h6BC7IptB3uUM YPnHFfiJ5kXb1cOpWHc3N1mCpa1QMVHPnYSdJWHo4hATpO9MP0CKVOOVnPywyMQn66Jv y3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=n7SNZ6++T24/33Jnrzi/f2LmtA7pEN6xN3h6eMLLRvQ=; fh=783w7aDAZyP4p7OqZukZFTwWfu+r3305h4buZFldemk=; b=qcnma4J15EJFZ/ScZ6G1bcDqHCtjROwgKNwu0hfKAZr3J1lAVNKe+wmaKdpryW0DeS mge6KBsM8Ed0t15Bi53m8Kp1usKt+8E9bZB/hASG1j/AttCOmwT2Sr5ENSTZOhW7+3AX 8T+nwTmFyVtpbOVzE1h9WY8LqpdzdAlzqCOCbnOVmMRwksuJQISohFIo/mBXcsusjT8W 5XxkvT/ksrPYmuNgXQdcJNsMCiBFS+mj+EbziUe6sLN6bOWCHbULsldFHVhOOsc5lGVe 63VFgU4oEcbxVtzixecKUNKjAXihoYgsuT5CFtSEcaN0HuVX9YqQUph2pBHx1abtZN2z SETA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Vnfp6YoO; dkim=pass header.i=@mess.org header.s=2020 header.b=emtTqSer; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f11-20020a056a00228b00b006ce9acdf9efsi7304747pfe.79.2023.12.12.00.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Vnfp6YoO; dkim=pass header.i=@mess.org header.s=2020 header.b=emtTqSer; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 509058076E6B; Tue, 12 Dec 2023 00:35:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbjLLIez (ORCPT + 99 others); Tue, 12 Dec 2023 03:34:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjLLIef (ORCPT ); Tue, 12 Dec 2023 03:34:35 -0500 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6EEA10F; Tue, 12 Dec 2023 00:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370080; bh=VG5ODc7Qao4WW/nSZE6mHR4bHC822oumil/Bqxfu/yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vnfp6YoO7jtQab8iFoGW0hu488sNLYVDDT0hzj2zgpA2rNDlbLyrTEbxKVpGLeUHD OrKBM66Gu9RWQY3/GNESwATskeMU+xDYMjZqWDlvakjD37Xbq7XoONKk/344lUeDAE opZxpMJdQeQYUbsGRwc8Mzw5XBVmuRehVwmYfnZrB+FjO/pTFoNE+ZpFNhuSft59Z+ AVPgqHoAZBu/L5L29xxjMXeEcXhC883WjfyO9+cQ5NBqgHku1tqmu630ehI4iiwmAN orf1RAfqAIHoM+Z9m8MCEOJsMgwYlH/HlqvKvEFai8UCnkwscgks3wiFz8ti1szcCV fZa1PfPcZLmZg== Received: by gofer.mess.org (Postfix, from userid 501) id 92E071009FC; Tue, 12 Dec 2023 08:34:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702370063; bh=VG5ODc7Qao4WW/nSZE6mHR4bHC822oumil/Bqxfu/yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=emtTqSerEUlYl32NAURBtyHU9Z9sq+JDT0rHFJM3r+S+bGmhDAYBFhSdpiBnMNgCe UMzBGGX5ZURggUJz+hPxyhLj3t0D4Lb6AE9cDNjaqurMkrlTsLWmzJ0vEvLV+xTPus nG0Wga8YcutIInMslBN3+nAgl2zowTNZBhXPnoZ0tYDyXLIGaqQLdFB7TpQmSY/sze Jsm9afwxkdvhNrEPcLOS/J/NRqBUAsEgVRMgYiadBHtw19LNVVfrFqT4gi9cJNeHj+ hdL2/Gl9lGmpF2c9glf6t8BpaAb0DlLo6d5Cyduh70GVkobvWKMMbt/66f/WHWmRvn RhLC/M3qo6OFA== Received: from localhost.localdomain (bigcore-58.local [IPv6:2a02:8011:d000:212:ca7f:54ff:fe51:14d6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gofer.mess.org (Postfix) with ESMTPSA id 3A0E71009FF; Tue, 12 Dec 2023 08:34:23 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Sean Young , Mauro Carvalho Chehab Cc: linux-kernel@vger.kernel.org Subject: [PATCH v8 6/6] media: pwm-ir-tx: Trigger edges from hrtimer interrupt context Date: Tue, 12 Dec 2023 08:34:05 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:35:07 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785064473601008846 X-GMAIL-MSGID: 1785064473601008846 This makes the generated IR much more precise. Before this change, the driver is unreliable and many users opted to use gpio-ir-tx instead. Signed-off-by: Sean Young --- drivers/media/rc/pwm-ir-tx.c | 83 +++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c index cf51e27609759..fe368aebbc139 100644 --- a/drivers/media/rc/pwm-ir-tx.c +++ b/drivers/media/rc/pwm-ir-tx.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #define DRIVER_NAME "pwm-ir-tx" @@ -17,8 +19,14 @@ struct pwm_ir { struct pwm_device *pwm; - unsigned int carrier; - unsigned int duty_cycle; + struct hrtimer timer; + struct completion tx_done; + struct pwm_state *state; + u32 carrier; + u32 duty_cycle; + const unsigned int *txbuf; + unsigned int txbuf_len; + unsigned int txbuf_index; }; static const struct of_device_id pwm_ir_of_match[] = { @@ -49,8 +57,8 @@ static int pwm_ir_set_carrier(struct rc_dev *dev, u32 carrier) return 0; } -static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, - unsigned int count) +static int pwm_ir_tx_sleep(struct rc_dev *dev, unsigned int *txbuf, + unsigned int count) { struct pwm_ir *pwm_ir = dev->priv; struct pwm_device *pwm = pwm_ir->pwm; @@ -82,6 +90,62 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, return count; } +static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf, + unsigned int count) +{ + struct pwm_ir *pwm_ir = dev->priv; + struct pwm_device *pwm = pwm_ir->pwm; + struct pwm_state state; + + pwm_init_state(pwm, &state); + + state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); + pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100); + + pwm_ir->txbuf = txbuf; + pwm_ir->txbuf_len = count; + pwm_ir->txbuf_index = 0; + pwm_ir->state = &state; + + hrtimer_start(&pwm_ir->timer, 0, HRTIMER_MODE_REL); + + wait_for_completion(&pwm_ir->tx_done); + + return count; +} + +static enum hrtimer_restart pwm_ir_timer(struct hrtimer *timer) +{ + struct pwm_ir *pwm_ir = container_of(timer, struct pwm_ir, timer); + ktime_t now; + + /* + * If we happen to hit an odd latency spike, loop through the + * pulses until we catch up. + */ + do { + u64 ns; + + pwm_ir->state->enabled = !(pwm_ir->txbuf_index % 2); + pwm_apply_atomic(pwm_ir->pwm, pwm_ir->state); + + if (pwm_ir->txbuf_index >= pwm_ir->txbuf_len) { + complete(&pwm_ir->tx_done); + + return HRTIMER_NORESTART; + } + + ns = US_TO_NS(pwm_ir->txbuf[pwm_ir->txbuf_index]); + hrtimer_add_expires_ns(timer, ns); + + pwm_ir->txbuf_index++; + + now = timer->base->get_time(); + } while (hrtimer_get_expires_tv64(timer) < now); + + return HRTIMER_RESTART; +} + static int pwm_ir_probe(struct platform_device *pdev) { struct pwm_ir *pwm_ir; @@ -103,10 +167,19 @@ static int pwm_ir_probe(struct platform_device *pdev) if (!rcdev) return -ENOMEM; + if (pwm_might_sleep(pwm_ir->pwm)) { + dev_info(&pdev->dev, "TX will not be accurate as PWM device might sleep\n"); + rcdev->tx_ir = pwm_ir_tx_sleep; + } else { + init_completion(&pwm_ir->tx_done); + hrtimer_init(&pwm_ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + pwm_ir->timer.function = pwm_ir_timer; + rcdev->tx_ir = pwm_ir_tx_atomic; + } + rcdev->priv = pwm_ir; rcdev->driver_name = DRIVER_NAME; rcdev->device_name = DEVICE_NAME; - rcdev->tx_ir = pwm_ir_tx; rcdev->s_tx_duty_cycle = pwm_ir_set_duty_cycle; rcdev->s_tx_carrier = pwm_ir_set_carrier;