All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: poke users of legacy drivers with a warning
@ 2019-03-12  9:42 Uwe Kleine-König
  2019-03-12 11:39 ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2019-03-12  9:42 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, kernel

As it is hard to convert a given driver from the legacy functions
(.enable, .disable, .config) to the atomic stuff (.apply) without
testing make users aware that there is something to do with a warning to
eventually get rid of the legacy drivers.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/core.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index e547c3217fca..1a871cf8f7ee 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -236,16 +236,20 @@ void *pwm_get_chip_data(struct pwm_device *pwm)
 }
 EXPORT_SYMBOL_GPL(pwm_get_chip_data);
 
-static bool pwm_ops_check(const struct pwm_ops *ops)
+static bool pwm_ops_check(const struct pwm_chip *chip)
 {
-	/* driver supports legacy, non-atomic operation */
-	if (ops->config && ops->enable && ops->disable)
-		return true;
+	const struct pwm_ops *ops = chip->ops;
 
 	/* driver supports atomic operation */
 	if (ops->apply)
 		return true;
 
+	/* driver supports legacy, non-atomic operation */
+	if (ops->config && ops->enable && ops->disable) {
+		dev_warn(chip->dev, "registering PWM driver with legacy API, driver needs updating");
+		return true;
+	}
+
 	return false;
 }
 
@@ -270,7 +274,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
 	if (!chip || !chip->dev || !chip->ops || !chip->npwm)
 		return -EINVAL;
 
-	if (!pwm_ops_check(chip->ops))
+	if (!pwm_ops_check(chip))
 		return -EINVAL;
 
 	mutex_lock(&pwm_lock);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-12 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-12  9:42 [PATCH] pwm: poke users of legacy drivers with a warning Uwe Kleine-König
2019-03-12 11:39 ` Thierry Reding
2019-03-12 12:03   ` Uwe Kleine-König
2019-03-12 12:28     ` Thierry Reding
2019-03-12 13:48       ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.