Skip to content

Commit 0af4d70

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: Delete deprecated functions pwm_request() and pwm_free()
Since commit 5a7fbe4 ("backlight: pwm_bl: Drop support for legacy PWM probing") the last user of pwm_request() and pwm_free() is gone. So remove these functions that were deprecated over 10 years ago in commit 8138d2d ("pwm: Add table-based lookup for static mappings"). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [thierry.reding@gmail.com: clean up a bit after removal] Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
1 parent 9e4fa80 commit 0af4d70

3 files changed

Lines changed: 7 additions & 77 deletions

File tree

Documentation/driver-api/pwm.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ consumers to providers, as given in the following example::
3535
Using PWMs
3636
----------
3737

38-
Legacy users can request a PWM device using pwm_request() and free it
39-
after usage with pwm_free().
40-
41-
New users should use the pwm_get() function and pass to it the consumer
42-
device or a consumer name. pwm_put() is used to free the PWM device. Managed
43-
variants of the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
38+
Consumers use the pwm_get() function and pass to it the consumer device or a
39+
consumer name. pwm_put() is used to free the PWM device. Managed variants of
40+
the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
4441

4542
After being requested, a PWM has to be configured using::
4643

@@ -165,8 +162,8 @@ consumers should implement it as described in the "Using PWMs" section.
165162
Locking
166163
-------
167164

168-
The PWM core list manipulations are protected by a mutex, so pwm_request()
169-
and pwm_free() may not be called from an atomic context. Currently the
165+
The PWM core list manipulations are protected by a mutex, so pwm_get()
166+
and pwm_put() may not be called from an atomic context. Currently the
170167
PWM core does not enforce any locking to pwm_enable(), pwm_disable() and
171168
pwm_config(), so the calling context is currently driver specific. This
172169
is an issue derived from the former barebone API and should be fixed soon.

drivers/pwm/core.c

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ static LIST_HEAD(pwm_chips);
3535
static DECLARE_BITMAP(allocated_pwms, MAX_PWMS);
3636
static RADIX_TREE(pwm_tree, GFP_KERNEL);
3737

38-
static struct pwm_device *pwm_to_device(unsigned int pwm)
39-
{
40-
return radix_tree_lookup(&pwm_tree, pwm);
41-
}
42-
4338
/* Called with pwm_lock held */
4439
static int alloc_pwms(unsigned int count)
4540
{
@@ -369,43 +364,6 @@ int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
369364
}
370365
EXPORT_SYMBOL_GPL(devm_pwmchip_add);
371366

372-
/**
373-
* pwm_request() - request a PWM device
374-
* @pwm: global PWM device index
375-
* @label: PWM device label
376-
*
377-
* This function is deprecated, use pwm_get() instead.
378-
*
379-
* Returns: A pointer to a PWM device or an ERR_PTR()-encoded error code on
380-
* failure.
381-
*/
382-
struct pwm_device *pwm_request(int pwm, const char *label)
383-
{
384-
struct pwm_device *dev;
385-
int err;
386-
387-
if (pwm < 0 || pwm >= MAX_PWMS)
388-
return ERR_PTR(-EINVAL);
389-
390-
mutex_lock(&pwm_lock);
391-
392-
dev = pwm_to_device(pwm);
393-
if (!dev) {
394-
dev = ERR_PTR(-EPROBE_DEFER);
395-
goto out;
396-
}
397-
398-
err = pwm_device_request(dev, label);
399-
if (err < 0)
400-
dev = ERR_PTR(err);
401-
402-
out:
403-
mutex_unlock(&pwm_lock);
404-
405-
return dev;
406-
}
407-
EXPORT_SYMBOL_GPL(pwm_request);
408-
409367
/**
410368
* pwm_request_from_chip() - request a PWM device relative to a PWM chip
411369
* @chip: PWM chip
@@ -438,18 +396,6 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
438396
}
439397
EXPORT_SYMBOL_GPL(pwm_request_from_chip);
440398

441-
/**
442-
* pwm_free() - free a PWM device
443-
* @pwm: PWM device
444-
*
445-
* This function is deprecated, use pwm_put() instead.
446-
*/
447-
void pwm_free(struct pwm_device *pwm)
448-
{
449-
pwm_put(pwm);
450-
}
451-
EXPORT_SYMBOL_GPL(pwm_free);
452-
453399
static void pwm_apply_state_debug(struct pwm_device *pwm,
454400
const struct pwm_state *state)
455401
{
@@ -790,7 +736,7 @@ static struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
790736
dl = pwm_device_link_add(dev, pwm);
791737
if (IS_ERR(dl)) {
792738
/* of_xlate ended up calling pwm_request_from_chip() */
793-
pwm_free(pwm);
739+
pwm_put(pwm);
794740
pwm = ERR_CAST(dl);
795741
goto put;
796742
}
@@ -1014,7 +960,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
1014960

1015961
dl = pwm_device_link_add(dev, pwm);
1016962
if (IS_ERR(dl)) {
1017-
pwm_free(pwm);
963+
pwm_put(pwm);
1018964
return ERR_CAST(dl);
1019965
}
1020966

include/linux/pwm.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ struct pwm_chip {
309309

310310
#if IS_ENABLED(CONFIG_PWM)
311311
/* PWM user APIs */
312-
struct pwm_device *pwm_request(int pwm_id, const char *label);
313-
void pwm_free(struct pwm_device *pwm);
314312
int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
315313
int pwm_adjust_config(struct pwm_device *pwm);
316314

@@ -410,17 +408,6 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
410408
struct fwnode_handle *fwnode,
411409
const char *con_id);
412410
#else
413-
static inline struct pwm_device *pwm_request(int pwm_id, const char *label)
414-
{
415-
might_sleep();
416-
return ERR_PTR(-ENODEV);
417-
}
418-
419-
static inline void pwm_free(struct pwm_device *pwm)
420-
{
421-
might_sleep();
422-
}
423-
424411
static inline int pwm_apply_state(struct pwm_device *pwm,
425412
const struct pwm_state *state)
426413
{

0 commit comments

Comments
 (0)