From patchwork Tue Dec 19 16:30:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2061121dyi; Tue, 19 Dec 2023 08:32:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHGOzsUHyT8nQZn1uVYV9G9hnCx2gkfr4sEXkMfiRQH79dB0Otmum0e95gCoStPsPQlNhi X-Received: by 2002:a05:6358:3a1a:b0:172:caa6:52d2 with SMTP id g26-20020a0563583a1a00b00172caa652d2mr4095170rwe.29.1703003541992; Tue, 19 Dec 2023 08:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003541; cv=none; d=google.com; s=arc-20160816; b=FUsv/5WYlWVUVaaIojKMJjpGQiVM0mXPNhjbdI2CD0N3p/elysfCSfQPYN8daJeVAc 07z7G48zsiIlEILqL+NRq84LCB8Xg8anaHQPQoH8v11H+oLFRtqBtBFmGgD/Hv56Vsuc zy/PncGlfP2Yg4Wl7E3oQ2fwJOYRGMBKKsmH1TJXZyZYKWBFrqLhI1vIisQN3/lKg+Fm T1iVDI9V3M4nmKKp4fAlBeYJ791k+Z2KAYqXDspDFDnvk53U80wTk1kMtbMEE4lnmjwB YpiugMqauxqIzWZbJtmAiNq6svFX2403hCmMEK66Xd2nCheNh13Njkt0G0hymUcXXalz bN7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=85lBUXS+wHrV6cq9m2QX0yJ8oRLgOcJr6IAwOji89JM=; fh=LXVDIsQAHYcuAbSneegrOY6aljpJ62fO3JnfAjaSssY=; b=wfdQ80xT6TGFmHo/nYzwFR9OLnovjJSpaRMzNhZEfqOx+scRksT8pTK5v+VLycfO2R 7OVCvkNsDJ4EKABiH+qbbLDq46UiGkE09vd8ovoyGuHBr9BVLJtkgffZMSjMBKW3Lgn6 QEWFjpVtPvbcbpYO0HXxHzo1vD0CnvaqakVfwxORZgsxDcfEcXnMBQKrDqM25upZiIG8 zyHRYp7HA+YQ/cYu0EZ7BrmNRRvKoRGIOrxUK3QHGSyrhYPVkEWfKguy7rpUxh2hKR8j UFdPDVMnp8R7ca2jzbM630C7t3qI9Tii+PUBEHRW46Kq2pC8owTEBiUBu6XK2KHHCIpS 51Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Pgm5PlTR; dkim=pass header.i=@mess.org header.s=2020 header.b=hLqXDR5w; spf=pass (google.com: domain of linux-kernel+bounces-5563-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5563-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n127-20020a632785000000b005cd7fc2c658si6143661pgn.260.2023.12.19.08.32.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5563-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=Pgm5PlTR; dkim=pass header.i=@mess.org header.s=2020 header.b=hLqXDR5w; spf=pass (google.com: domain of linux-kernel+bounces-5563-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5563-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A7EE9285CA8 for ; Tue, 19 Dec 2023 16:32:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3AD731A63; Tue, 19 Dec 2023 16:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="Pgm5PlTR"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="hLqXDR5w" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 6BE8F1D552; Tue, 19 Dec 2023 16:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003464; bh=H02m+7ZCWR76SzdKN2YGwZ97zwCUhVUPpmdrKW2ye6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pgm5PlTRHvsnlXEs+hhpoqTy4jReetnTv/wHs3I/lcJ4sbBZTHIIEbqYh2SBuwesj 2TWhAnlFS8D8GA/iE/TuU4GpGVvMPcw8I5dmI66SICvF67XYQpfmZJoXNTdJLkefiz hDxItRB6U7aS/C6qEEl3IwOZ76dVixlaUE+T4JDS25gNkdnt9pef4efRwxV4zrt6WC 6fzNtWNEV8IELAITzziGyGr8Pb+9K4eywvkqCaaSrcop7LNKaFIduKX2fBi8uRz927 Vz2AEFF9VT//wzV0HQPz9BnrnPUbZC/fTobngWqHgAAxW8QwW1fyXJIQ8cBFfOsRy/ oaXFaclnZs7dQ== Received: by gofer.mess.org (Postfix, from userid 501) id E2B04100A04; Tue, 19 Dec 2023 16:31:04 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003448; bh=H02m+7ZCWR76SzdKN2YGwZ97zwCUhVUPpmdrKW2ye6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLqXDR5wLkhGKdUH4nPeb3a3sADAIa6yD3UUec3iyyrQF2e3s82OiVCPHf9TrLkXK 1pBcqTyK3Z9DpoMZixdA4nNaSRrTLCGZ6QuJ3Vd1zzFi/bB7KY7Au/l/gcpRaY0KvD DcKIUhI0Tk1V/nLBfiOL96ZzYi+4vCdYqqcKKcxUtozBcbkZi2gBxxkLf4OCNWUJ+v d0yiHpdcyMdD/cCM8ENwJWEGaySnEvRYDoUVNtSdJeVoDKG7tM0K9V+t8Qm0fZCzGO qKbrXJW6FxfwwcKNQt01I/4+fpD/p2DYDbvjpnays+ZyxkrFUEf+VKHaf9qtmtrRsL T6559FeQ5WwNg== Received: from localhost.localdomain (bigcore.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 5E3971000FD; Tue, 19 Dec 2023 16:30:48 +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 v10 1/6] pwm: Rename pwm_apply_state() to pwm_apply_might_sleep() Date: Tue, 19 Dec 2023 16:30:24 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728642000341632 X-GMAIL-MSGID: 1785728642000341632 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: Uwe Kleine-König Acked-by: Guenter Roeck Acked-by: Mark Brown Acked-by: Dmitry Torokhov # for input Acked-by: Hans de Goede Acked-by: Jani Nikula Acked-by: Lee Jones Signed-off-by: Sean Young --- 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 bb264490a87a..f1d8197c8c43 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 97f51d5ec1cf..c58480595220 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 2e8f17c04522..ff9b9918b0a1 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 e0174f82e353..cce043a4a1dc 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 6e4516c2ab89..b67bc9e833c0 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 ce82548916bb..c1fa75c0f970 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 1e731d8397c6..5b9aedf4362f 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 acac79c488aa..3e5ed685ed8f 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 2b3bf1353b70..4e3936a39d0e 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 46cd062b8b24..e1a81e0109e8 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 c5f37c03af9c..cf51e2760975 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 b8d0239192cb..fd62bf746ebd 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 f60b715abe62..c2d78136625d 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 8a870d0db3c6..c670ccb81653 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 bdea60389487..7bfeacee05d0 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 4edb994fa2e1..1698609d91c8 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 2aff6db748e2..698c420e0869 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 8fcb62be597b..a3412c936ca2 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 da1f124db69c..7075bfab59c4 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 289bd9ce4d36..35c716e9043c 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 5ae48e36fccb..1a4f90ea7d5a 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 f87655c06c82..b64b8a82415c 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 19 16:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2060755dyi; Tue, 19 Dec 2023 08:31:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOrFKFwAUj9PRhvFvQxOrLbinluLqvx+mYYM4CH2cUxCyWW8VLmvgYNZJO6mWg4O+O4gfV X-Received: by 2002:a17:902:d4c2:b0:1d3:675a:cbec with SMTP id o2-20020a170902d4c200b001d3675acbecmr5837018plg.24.1703003514033; Tue, 19 Dec 2023 08:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003514; cv=none; d=google.com; s=arc-20160816; b=Z2LMuN3NmjbVsXzXnTKGmMM6Uotym/KehvYDtVZ5mcokZwBkGENhhc0sETMMcn8PrI tdrpt3b5MSSPD4Nr4z/EMVX9qG4vIYq4/+Z5HGUVb3pTXZviGHlmaEBzCQaM+ojzMBAZ ADtZxHZUz4UiXc1+VIrdr9grV0kcnCjHQTXv+FyWp7cxcqvVA250p21tZE8E4TLklYpa oAuo9TE8O8gmMtb42+nbD6Krc4QYR6yBIUZ/+DdvKqoSa8eGmqlCkaJlnH+XKAhM7jSZ zM+uw0t9j3dMuooysE+MIgiycRHb11zC74nfdUWAMkbOEV4BzSpzyBXR98IU7sIdjiMh N/Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=mENA2QPZgoF9kco20FTQ0GpcO1pFdykWFx3kRUDKAP0=; fh=G36Ufr6lzVczrOndx/ne0QnYCnZHT0W+s6wWJgcb5Qs=; b=a4K7xUu6g6E9yDokA+7BMYuM3CZcfuf2kTtUQ8EAnmuRo4rri9DM23QiqxttKycSi0 FEioE6xXwUXIZIWZ7icEDlRqktsSgGltmnQ1PjahxOq5ctsPWbsBHBnKkrMdIkBJWqAO ISLZ7KwoySFZRhC3Zbxh4Mo5dE6rJokh4tAyaNTHrOQnY2Q0PLOfB71WJ/JyObLdAd3d e7QFDSQL4+z2SURHCf+OC5D/plgZ8dQ/xFrtHL2/+auc6vDJOEEf6kLk7N037zpzrP2d 52qio7OCbwZgFIEEJW1yeXNpAXGk4OlS4XgrwqmAIqW1Pu0n9/udh4jx5egw1biUj8lO PW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=bE1UADNe; dkim=pass header.i=@mess.org header.s=2020 header.b=V7XnzUo5; spf=pass (google.com: domain of linux-kernel+bounces-5561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5561-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c15-20020a634e0f000000b005c65d99188esi19514746pgb.34.2023.12.19.08.31.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=bE1UADNe; dkim=pass header.i=@mess.org header.s=2020 header.b=V7XnzUo5; spf=pass (google.com: domain of linux-kernel+bounces-5561-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5561-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 13343B213B4 for ; Tue, 19 Dec 2023 16:31:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 332F421118; Tue, 19 Dec 2023 16:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="bE1UADNe"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="V7XnzUo5" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 417801D54D; Tue, 19 Dec 2023 16:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003463; bh=M9WlBbQS+py4vER3IqEGVhXVemW9VnxieqHLqtwQ3LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bE1UADNeB2uspHMYO3fCWbYA2MtHZ1o6vQMX7OMEAWNWK04X2PNGmfHb215SMxQxF aVTUi56JUtqcQZsLaz+d8QiQ/edH37rBaUsa754r5Jhbmb65DmIn+9GbDx5g7MMGWW cY0sQW3gmOSn0TQLrYCv/GA4sVyxKOY9BIXB2Ns7cDUOQ5egfO3FYDO4B4GLxWvmHW 07dvld+veB3/EhCgjVUHZVRrryXhZNJ2ay0uva29oAbkrz0+qyrCUCas0ta8bi3oQZ TYC7siMKU3sI6hfbjqCaCEncklEGdCpulOZOwbFlezPqrX0MetIN8XfXeGL3k65hkp PWM90dkxrTnQQ== Received: by gofer.mess.org (Postfix, from userid 501) id 91B1D100A03; Tue, 19 Dec 2023 16:31:03 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003448; bh=M9WlBbQS+py4vER3IqEGVhXVemW9VnxieqHLqtwQ3LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7XnzUo5dtNydJL1osYe+LHZrYzldF0f0Pklco8NJlaQDeRO5p+9Em3YRowZIWJui G8uS0cpyjiI//V/DYUBXOPhdlyV45rF6Rt7JYopQNXkEGscmYTXP3jopTyleeL7X10 wb5LcWt1O39zsUWteKERN6vnpjFiUzBWp6QupRHyI5BU/35Y/lsrWf870vYJQ4FZt9 iHW7xQlVgOCIvUoAOlZ+IGC1hagKPFSfj3RG9B7xVVv1yXBk6bw0+K4S5/xjFQHKwg 7qLFhAAIOQgcOMiNj+lb1T1nuN+WNm1okZj8I1O19ae1g2uV8G065uz7g0h8zkcVEp 89WzAqwfgFQtQ== Received: from localhost.localdomain (bigcore.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 970D11002A3; Tue, 19 Dec 2023 16:30:48 +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 v10 2/6] pwm: Replace ENOTSUPP with EOPNOTSUPP Date: Tue, 19 Dec 2023 16:30:25 +0000 Message-ID: <7d6c10b52bbb29925fff9d2f16788a65c138921e.1703003288.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728613010909463 X-GMAIL-MSGID: 1785728613010909463 According to Documentation/dev-tools/checkpatch.rst ENOTSUPP is not recommended and EOPNOTSUPP should be used instead. Signed-off-by: Sean Young Acked-by: Uwe Kleine-König --- 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 b64b8a82415c..c9cb87b59ac8 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 19 16:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2060954dyi; Tue, 19 Dec 2023 08:32:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGj5fnC1VC1owCkR+COW2d1WELj9ZZ8qRQAMysa14yEd3pDHz1GHpIuNcgcr6NG8m5mnDOs X-Received: by 2002:a05:6a00:99c:b0:6d9:36c3:647c with SMTP id u28-20020a056a00099c00b006d936c3647cmr1318607pfg.6.1703003529487; Tue, 19 Dec 2023 08:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003529; cv=none; d=google.com; s=arc-20160816; b=OLvdRri77bLvsrEOXSSw/K+rJBZA3hJL3mvNC4CpvgOSrpRsM+cObsDSeOpPJ8zNxt VhmJNFCBRvZKZwVDJ/SKHgcqTznz0J2t5MR8Ecxp4BizCbPui/j2fPoAaoVIu4iXDSZh zATfZwqqX1XNlpPxY6P7R8iYMRXBfk5tZaVYiut5JtIulQeWDmipF/nkiXEDHbeKtC2m 6Vp9eFufYId1/vJYunFVpAAKT1/cl/jeFMH7yfdPwSrRD6oUXJb/SoScwTIbyUOslnCc 7dCWEugF9DgoCY8fVXq6cYmYa2jMjh8a1J2Q2Bg03ekvrjPv4He2AOLtyotvf5lGh0+4 03gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ov1quIJGezYF9wodyL29R7dTtFmka5Zj5hISxYRY4uQ=; fh=G36Ufr6lzVczrOndx/ne0QnYCnZHT0W+s6wWJgcb5Qs=; b=gNmMBhEMkfrFaP32xcVMYlhLJcFXpN21VVicBU77pgG1kVP7IWOUtEfIQ2zQMKO2NG UNBcYm1BTwXba/4L9AkFPsVnAl06/WBoRL7KkWfISju0zzXafA7ZqUSY77LeN/Jc7cZS npsmwKVF5eVLahA7QPKv06ofvaX7hTpSgG3nqQobzZw2gJ8x6WT55mbFZFOt9BAp+6HD 6i8rR3eEB+5qNJ4/YXuxFyzPEcXC4SJdIA5hcwMud8Rm0OpaUSTeluwZbxxeOOXnPZQZ 9mVwzTclLK4Dz7RVA0N8tbrdr8CpGus3QbxAb5BtANNAJvmGv10HdklI+cUcYYuH64xs GhdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=rybegmk2; dkim=pass header.i=@mess.org header.s=2020 header.b=neTMlc54; spf=pass (google.com: domain of linux-kernel+bounces-5562-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5562-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g5-20020a056a0023c500b006d0d83a11bcsi4177498pfc.102.2023.12.19.08.32.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:32:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5562-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=rybegmk2; dkim=pass header.i=@mess.org header.s=2020 header.b=neTMlc54; spf=pass (google.com: domain of linux-kernel+bounces-5562-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5562-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 43961285CDB for ; Tue, 19 Dec 2023 16:32:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 251CE26296; Tue, 19 Dec 2023 16:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="rybegmk2"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="neTMlc54" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 0D8961D54A; Tue, 19 Dec 2023 16:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003465; bh=4Uv9T6s4wh/LXg7ZHtJ7w1pHCYlvw7d96NQ/caKWDUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rybegmk2K2ZQ80aClNkJqaX4WobeLc1uhZ59Hd5Tt2pvEuY8f9HtbrUEeiVfPS6SH 5lv10dohxVDqSY5i+bs7k6I29kLrJSVKQsTLKNBTFnN0BVHM0TwfVSq4gnyOg4vgUq aH83fRaxbtiFKD5+9dQJ7z5xJ1vieroN3wVTrUzxCre1Mee0PcEnq78zZ3K98fC+8u IgGPn/0M0ESF8tHGIH6+a+G0TVd0/ZInrZGdw91OajP0U8a2L85rjEnYAajlUhINfR u4fqP2Hmtad7ZGzcLvyHtBoAf9wYm3GZ+5Lx9/w0d0HNaY32OTPOQexp61pCQ5lode 84/aesFtEA1ag== Received: by gofer.mess.org (Postfix, from userid 501) id 4271A100A09; Tue, 19 Dec 2023 16:31:05 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003448; bh=4Uv9T6s4wh/LXg7ZHtJ7w1pHCYlvw7d96NQ/caKWDUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=neTMlc54I0LBHj5Fn1Lz/nCDT4Tryb2AuIsu883fcLTKXbapZkwKK2zRoWD39vlyp 2DIdh0CWqvprloHwErCYArkB1bw5EzpMjHhMYSCoUTLUI4HXYYP04CkEK9EcUc7Ho5 diWvEQkgG4dCljbLPjlrgU8TnZordJKcGzqLA3gBui6pbpFgXM7wofVat6I0A+w6nr cSp9i5R+1g++1CCoKZ+QF9fFSeqYQ5ZYCF62M5TW69ZTBaQvKxV32BnvvhSZl4fLYj bmuON7OOHC8OsFpXXokxrI4/V09MmegC47U/P9MAdsY11aRZEwl1nLQqIjAicxQAiV P8ZjuK/laKeSg== Received: from localhost.localdomain (bigcore.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 CC10E1000CC; Tue, 19 Dec 2023 16:30:48 +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 v10 3/6] pwm: renesas: Remove unused include Date: Tue, 19 Dec 2023 16:30:26 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728628814486569 X-GMAIL-MSGID: 1785728628814486569 No mutex is used in this driver. Reviewed-by: Uwe Kleine-König Signed-off-by: Sean Young --- 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 ce92db1f8511..28265fdfc92a 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 19 16:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2061372dyi; Tue, 19 Dec 2023 08:32:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNu6g3NL+sDwr5G+jD4n7rG+X82+60VUU5AkX72s0i4zERw4qiomaWOBudQLsMlO2663ZI X-Received: by 2002:a17:906:470f:b0:a23:339a:1fd3 with SMTP id y15-20020a170906470f00b00a23339a1fd3mr2345196ejq.138.1703003563052; Tue, 19 Dec 2023 08:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003563; cv=none; d=google.com; s=arc-20160816; b=gcvLpENWDfGINF5LTKhVsZoqwkNEVc4tmBDvQd+qNYAnfo8BUKTZ/VtVMYItNWRT+t +Btc0hVsGeAwZmd3JAELZB0n4F28BhXsm+Ncj5z3KGeAq5rmhiI5e8ID4f4qASVL8BGv rTwEQQLa5LoX3282Pc2k3hZhkoZYCZ1CHhTgIHJfW6bwqXnuRpdTsDGDwXprYQgoSY1j XsuHUY1TYEpMmBsnPGdSSS4/lyLeZatwNVlW4PxSqvI6akvUAHXts8+kVxOhJsm3ZtU/ A29pR3iQIz2hHIyrYo+7MwqyR5oMRwQAFeWAg4QArfXof8wEYj6Cyk21MJcNMTF7xXPK bSPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=EHiMwZ5DYxpmZpIn8UE+vcuaEAW1PzP3H8D08ZdjVo4=; fh=xi/MSaxLTzLfOvSuzBMM1/60ApIuTUoD+htsskhpbNk=; b=n3aJCUfWlzLMLyCG7FePknb88WDTFGUaIWk1kcPR7BBHZXwwfODFuneokbm7XL6qPp Q3RhKES9GBsirRstcJl1rYsqbdSKQ9f9b8uZEoMNwCSnq9wrq+8gUojFZRyIfTfGX+WN 3o1QKrlJdjf71bnH0DstRUSrpvXV7ByjAW795aSDKIv44l0NHSHSAK+7pkCT5FLbfQ2b h8o4d8hAE/EDIrPErErTMCQormY74L6xbphJ4kja69eQ3eEt0uufOVpJh/OVQIq+UjHI TSqKRPHNYl9Tqgzmimx906By+qdOtQwpoMlGUegeojjuRzjJSjeSSDIiVDyrH9qA1eHn RHkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="Zl/dXOqj"; dkim=pass header.i=@mess.org header.s=2020 header.b=BAqhNSs6; spf=pass (google.com: domain of linux-kernel+bounces-5564-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5564-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i6-20020a170906114600b00a1c78edbe7csi10723478eja.141.2023.12.19.08.32.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:32:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5564-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b="Zl/dXOqj"; dkim=pass header.i=@mess.org header.s=2020 header.b=BAqhNSs6; spf=pass (google.com: domain of linux-kernel+bounces-5564-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5564-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6EF7D1F25943 for ; Tue, 19 Dec 2023 16:32:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C35EC34557; Tue, 19 Dec 2023 16:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="Zl/dXOqj"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="BAqhNSs6" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 53D231DA5B; Tue, 19 Dec 2023 16:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003466; bh=nq08shY4F84JWnlQ3SSHlueQDTZg9R3tBoXVvnOsM60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zl/dXOqjlWBevcnZn0nqnndnRGSF5X7wQMrIkHEO6oUxJeNCCxiEZpQ+S8ZSmBDlA zGclrXyCwRekplZG7v1VdzxmMJPgwtqu44tPFlxbiAkGd0zklrvFJjBn7SuI04zkkb Ny9waj98vuvrl0Lq0IYBnG+/ylX3QGba2REqwvJsuTnwQsVpcS4tKLJOtDfrdh2Zbk kggyeLyyuT4Plk9r0TipvaFAbFUYedqA2F+6A2ba+GxkDYpfuFjqjmiOWo8I74d8hm WcaoH2YFty2jhqMTbkPz/Ea4T+Dku2b5k+RsmALtvk5kVrNOVRvGaPDgNhdQUYG0ed wwedHtjj7Rdww== Received: by gofer.mess.org (Postfix, from userid 501) id ADBDF1000CC; Tue, 19 Dec 2023 16:31:06 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003449; bh=nq08shY4F84JWnlQ3SSHlueQDTZg9R3tBoXVvnOsM60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BAqhNSs6jtKNYeIk3LaRPpkifxs5s6Jikoy9ZqXaxNfq1/7/MunMCP4unUufX38pA gI2jnM3oNfYUtQIqEIpr5E9a9lq871dQ7bvM3z3Z/cu7QaXzYW8x4jvcWO7TD+uJPe XD13sRdFJx1wvr+JXp7bS9WsteAXNB8T0mA3zgFWx1QmFGJQQtdC3Hr/V8Ox/P/BIj fx1/5/ldL5gfwunC0w0X+7xELQmib/Hlvb9H61uroXjczdXxhnJOKDKFUitYWDABiS IrueiLouR6D/onkwhoXd5+VA6WxWObWUo2S51u3BvaPrhqeWyJw5PgXws867Vf/7ug DTpaLhcTfEmhw== Received: from localhost.localdomain (bigcore.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 4768B10029E; Tue, 19 Dec 2023 16:30:49 +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 v10 4/6] pwm: Make it possible to apply PWM changes in atomic context Date: Tue, 19 Dec 2023 16:30:27 +0000 Message-ID: <2a08b7876059f30c5c081d02978876022fa8d3ea.1703003288.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728664432148991 X-GMAIL-MSGID: 1785728664432148991 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 Reviewed-by: Uwe Kleine-König --- Documentation/driver-api/pwm.rst | 9 +++++ MAINTAINERS | 2 +- drivers/pwm/core.c | 62 ++++++++++++++++++++++++++------ include/linux/pwm.h | 25 +++++++++++++ 4 files changed, 86 insertions(+), 12 deletions(-) diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst index f1d8197c8c43..3c28ccc4b611 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 c58480595220..5342cf32d73f 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 c2d78136625d..39bfc8b52294 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() - 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(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; @@ -479,8 +470,57 @@ int pwm_apply_might_sleep(struct pwm_device *pwm, const struct 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(pwm, state); + non_block_end(); + } else { + err = __pwm_apply(pwm, state); + } + + 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(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 c9cb87b59ac8..495af3627939 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 19 16:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2061495dyi; Tue, 19 Dec 2023 08:32:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW9fRia5Xj3+MyeGaSiz1u0KvG16Dakht5J+UGl2u8omL8/FDZtDQFE8bxQE2iuSAPqR3c X-Received: by 2002:a05:6a20:9718:b0:18f:b99d:df9d with SMTP id hr24-20020a056a20971800b0018fb99ddf9dmr7573625pzc.120.1703003578032; Tue, 19 Dec 2023 08:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003578; cv=none; d=google.com; s=arc-20160816; b=eC+fLTqkqIn9P12z4TH4e+GQTrP8pYd61y2D/G7cFUeX/i0dsiYfffpVzaDu1ViLHL X9sRZW5Bnm4YY6w0fHpOqfddbwncDyBe1Hr/mXbPy8UWpQGuZy/mIZSw4HIhXpk2CVIw qrsWX4n5ZKhf1LBNdGwpxYYkpKxp1m4Gu3aPPs9o49iT0lFweJCkj7bpYYLCl06jGtaQ /TTtyv/10PwyWC/p9qDhyJqMYSm367+ddCnSvoQMdcQKtSDWHd9QqYpAocgcCMTDVByi s2yQcTaz1f+SRnFBGY01O+6dyJ7G6HM8nkfwZ/gqy8+x0U0GdPx7fKth3DdOOHTblypJ TqfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=rGVlRxGMyUSZQ4WV29rpiq4lYAVw01Pro2byQCY9dWc=; fh=/7Crfx1M7QQY+j06MLDjROh1SB3OvesMG8XebREHJaQ=; b=bCicfYtfG3oHIMZyrLcogeEqDELu4spHjz0pJ2TuYmT8eGGcuar7ur4gdwwc3wXtxX sWbWCve+AqcAjOIBL9r+qsKsMttumt92xFI2IT3EqAaa1Ll6Ff1IUQEw/OHjOy9sKrZs 9iZAmXhJQhOKILPtGCoiC94vpevSbjE7PEg/bT4tVif4Q70YiPbKj6LnUMcdaHFMzJO/ 7e4LwxYJA0tW+rUvdIIq3zmgZLwDi6j/BXsrUHG9z2dAJroSJWUA6ez9ohMh0DHTdDcY ExT+Er5h6LQ5U6m6XWP9q8sYSuESIWvj4NgWVDoBzBP7wvBam3aJOjbAq1HdGfcg0+lO RPMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=tUvnul4Y; dkim=pass header.i=@mess.org header.s=2020 header.b=dNJnBW58; spf=pass (google.com: domain of linux-kernel+bounces-5565-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5565-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u1-20020a6540c1000000b005ac8d44bad4si19209550pgp.592.2023.12.19.08.32.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5565-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=tUvnul4Y; dkim=pass header.i=@mess.org header.s=2020 header.b=dNJnBW58; spf=pass (google.com: domain of linux-kernel+bounces-5565-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5565-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CA114287B9C for ; Tue, 19 Dec 2023 16:32:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 782EB358AF; Tue, 19 Dec 2023 16:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="tUvnul4Y"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="dNJnBW58" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 16B5A210EC; Tue, 19 Dec 2023 16:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003468; bh=uUf3zxmOYbpHbQdPmRJIHAbIUbLSVg5+6TD2Zc3o9Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUvnul4YU3uRyaHPOY+Hd5w5TnG2MszE5+Vvm7WCc/Oy4eTRnvFGzObEhPDinpcSv IaCOvBvmj5jJpq3b6EQYfU5ARUU6rT93bMVpz+syxIPqYIFNZ/PacQq9RlCCOpfRnx IO5upqGyQYVrvG63iutpU9sZiHv0fMiw9JWEEPJGuXQGfEpkXgvdfarIscc+pokUD6 CB07HGp3EqgTYj2MiIXGH7xaKKc4btoOrnIRteb/LBklA/ob4XiwLxIK9lcuIPKby2 4FarnA7+TeeRhJqtEU+/eLmAVrwF+sZpZr7FwmzmzQ9qkKqIPTO5hpz7TjYca7wWbM Xu5BCJzw9DZIA== Received: by gofer.mess.org (Postfix, from userid 501) id 7A96F100A03; Tue, 19 Dec 2023 16:31:08 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003449; bh=uUf3zxmOYbpHbQdPmRJIHAbIUbLSVg5+6TD2Zc3o9Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNJnBW582nDvd33QqAoyQHVEL3FUPnDHJ2VkfvM33QXCUHAC2w1qKFXrntsGF/CCV SMBbb2eBbKPIpj5EE+2HeHZkrV3p8GNVnNNbWE8oyCkJCqf+c9MQ3T78wbHn+3XiQ/ bryAdBHzinfQNaMk6/BLA6M3IHBCYzJMrklc/yA4vgCRkfqi9jM/XyimvqqasDRuxC pH16vlRs8S03L5J4xW5/uasoeLtPpCPzixLWBCCE1QWNKKkglzpVmKmCkMnUcjrJfB 6hoSgVVfImSqlO8kOF6EO4PeWCeuhR/eaIGovsM1zVsi0fMWJ4D9PIu2CtmqDF8n7k XhPy15NsK/pXw== Received: from localhost.localdomain (bigcore.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 7E1191009FD; Tue, 19 Dec 2023 16:30:49 +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 , Ray Jui , Scott Branden , Broadcom internal kernel review list Cc: Sean Young , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context Date: Tue, 19 Dec 2023 16:30:28 +0000 Message-ID: <6c5852c902e6603571e4fde5955d1aeb537059ba.1703003288.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728679677013327 X-GMAIL-MSGID: 1785728679677013327 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 --- drivers/pwm/pwm-bcm2835.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index ab30667f4f95..d9ac50a5b04e 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 */ @@ -131,6 +126,13 @@ static const struct pwm_ops bcm2835_pwm_ops = { .apply = bcm2835_pwm_apply, }; +static void devm_clk_rate_exclusive_put(void *data) +{ + struct clk *clk = data; + + clk_rate_exclusive_put(clk); +} + static int bcm2835_pwm_probe(struct platform_device *pdev) { struct bcm2835_pwm *pc; @@ -151,8 +153,22 @@ 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"); + + devm_add_action_or_reset(&pdev->dev, devm_clk_rate_exclusive_put, + pc->clk); + + pc->rate = clk_get_rate(pc->clk); + if (!pc->rate) + 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); From patchwork Tue Dec 19 16:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 181084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2061521dyi; Tue, 19 Dec 2023 08:33:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEa7ghD1b6L5kfLLnkc+opnQcd/0JnN9TDgJy5hfJI4kH6P5IYsHwSBrRLbKRVaH/2ntTpi X-Received: by 2002:a50:a459:0:b0:553:2dc2:4b9b with SMTP id v25-20020a50a459000000b005532dc24b9bmr2384851edb.14.1703003581189; Tue, 19 Dec 2023 08:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003581; cv=none; d=google.com; s=arc-20160816; b=pFkWtJbzXyUIFpsslwC1D2YwiUPa4wWuGH24g6P3jHRUlyBX26hXCXpquX8hlqqOqh DucoHagc82cOE49I/odHAWwsQ1XQMkDvvqKukFlOJ6P0Z2RX2m/MipsNY2exuyq6whBH oBTLJIKucItX7taCLBNiN8x7pv1l5OevpX5khb5SFiY/2rBhNY3XaHoOhvOhic76gDNT a4YXRxhVCIPEvuLSwZGRbKnIm84OjWBcN117F+pPNlsljvFZhgWWBbvZhoZJ6Y9EHKMb n4qzPnkGwyelpkpOke2F99OVIUlA0CjcxyoDYObUB75p91f65raYw4hkdJ/M2YiqICjx oRpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=QRZm4mUaf52sFo3XS/ZMq7LXrR6TeHsJVIwLttHc5EM=; fh=783w7aDAZyP4p7OqZukZFTwWfu+r3305h4buZFldemk=; b=kGJFxfr6WAZHtBVcHseeaTbAvKRlr/MhleptoV2Ne3I8fgjGUOg2apOPkFal2tIbWl tr+gCtLfiHb7qI7aksUHdTH6t0Cj2jpf/KJ5haeIzZ5RAWQWdBuZ2V/Kalyt+8wE5HnK e825QJwRyvMAveg9eotIx38Soq1wx8v/H+VIfgxVLCvzj5E4Q6Wc/dt8a7Sg7zBNBKSn 7XSCDujFsPePLYQHIzhRYURZQLEi28x4lTdtbikZm+1KJS1SwEllaPVuVKogMHB2GgrU TTz7i2b08x54ASfH+o6MZXy7EVExO50gie+SskS8SRI/BrjsW0FnBOAQKE1OkyYrAntj 88Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=NYfu6jWK; dkim=pass header.i=@mess.org header.s=2020 header.b=blkhsLd0; spf=pass (google.com: domain of linux-kernel+bounces-5566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5566-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b11-20020a056402084b00b0054c878f57ecsi10950989edz.621.2023.12.19.08.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=NYfu6jWK; dkim=pass header.i=@mess.org header.s=2020 header.b=blkhsLd0; spf=pass (google.com: domain of linux-kernel+bounces-5566-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5566-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A15941F258F2 for ; Tue, 19 Dec 2023 16:33:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B15AE364C9; Tue, 19 Dec 2023 16:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="NYfu6jWK"; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="blkhsLd0" X-Original-To: linux-kernel@vger.kernel.org Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 48E3622331; Tue, 19 Dec 2023 16:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003468; bh=hUUyx2Ra/j0PfiviV+OXUA5B+Rr5c5IfU2vtPHgn40o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NYfu6jWKFgj9mC3ee/nZq7ODltMtE9iQU5keKKmA+PGIHhF1oFMXX08UunGXfJU60 +YEdnVlG/tKBb7HpXA7iq68T83Hs17eygkJcyBeDOtMHvG9FAxQZzqgH7wlIv772PX oeTrxH6APT5WkRi71pL7t0eqcjInM1v+HoGN+YhZiVOwZSUPm+ooOUvyjS58j4quNt sTUXD6t/z29XaNqGRIzQW1Wb1Dr3VeUmucCSZGdtVj+qxPPGedGFsFiS2vGuAyWJga gaqpCKMyIxL+o2QVFsw0OzqmidSRhiEiCWff4TJ7DuiR0fnn/cGzdO+cQHjizKvyL5 csiqF/k8KFg+g== Received: by gofer.mess.org (Postfix, from userid 501) id C019010029E; Tue, 19 Dec 2023 16:31:08 +0000 (GMT) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703003449; bh=hUUyx2Ra/j0PfiviV+OXUA5B+Rr5c5IfU2vtPHgn40o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blkhsLd0GFn35E4dfO2DkD3V2fcGTIjuMIvfsWsX/UuDFkNgoaHlERe4GJE1v/b8r yT3XrpVFzaHEUhrmfzj9fBRmTBO4944oiniOix5V+6Y7vmYpZ5fyCKKS1PR+tD/rVL dDx+GS+JdhPR+9zcTFviaaUCOHnQZJoUqLtLxbKcm7iDE6ttXpxDyjanX5DGJWZ6J5 bjw6fvYW3wYn5O3szjShT6yul4oYeAYvrmEV1SxhjrxbP8RkysqwwN9A97bX5sQvSF cxzzLAPrVPcITAEJZmiFxivO+SFoHVX5yZYMYmJ4r6psC0nuc0ktR/YUNzkKJDU0ju mHX7oGDUUpP2A== Received: from localhost.localdomain (bigcore.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 C18ED1009FF; Tue, 19 Dec 2023 16:30:49 +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 v10 6/6] media: pwm-ir-tx: Trigger edges from hrtimer interrupt context Date: Tue, 19 Dec 2023 16:30:29 +0000 Message-ID: <1a5750d4eb3e4f777a123b094fdd66d3b16d2b9d.1703003288.git.sean@mess.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728683264255811 X-GMAIL-MSGID: 1785728683264255811 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 cf51e2760975..fe368aebbc13 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;