diff mbox series

[v2,3/3] pwm: Drop function pwmchip_add_with_polarity()

Message ID 20201207134556.25217-4-uwe@kleine-koenig.org
State Accepted
Headers show
Series pwm: get rid of pwmchip_add_with_polarity() | expand

Commit Message

Uwe Kleine-König Dec. 7, 2020, 1:45 p.m. UTC
pwmchip_add() only calls pwmchip_add_with_polarity() and nothing else. All
other users of pwmchip_add_with_polarity() are gone. So drop
pwmchip_add_with_polarity() and move the code instead to pwmchip_add().

The initial assignment to pwm->state.polarity is dropped. In every correct
usage of the PWM API this value is overwritten later anyhow.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 drivers/pwm/core.c  | 25 +++----------------------
 include/linux/pwm.h |  2 --
 2 files changed, 3 insertions(+), 24 deletions(-)

Comments

Thierry Reding March 22, 2021, 11:32 a.m. UTC | #1
On Mon, Dec 07, 2020 at 02:45:56PM +0100, Uwe Kleine-König wrote:
> pwmchip_add() only calls pwmchip_add_with_polarity() and nothing else. All
> other users of pwmchip_add_with_polarity() are gone. So drop
> pwmchip_add_with_polarity() and move the code instead to pwmchip_add().
> 
> The initial assignment to pwm->state.polarity is dropped. In every correct
> usage of the PWM API this value is overwritten later anyhow.
> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
>  drivers/pwm/core.c  | 25 +++----------------------
>  include/linux/pwm.h |  2 --
>  2 files changed, 3 insertions(+), 24 deletions(-)

There was a conflict between this and patch "pwm: Always allocate PWM
chip base ID dynamically", but it was fairly trivial to resolve. Let me
know if you think I didn't resolve it correctly.

Thierry
Uwe Kleine-König March 22, 2021, 3:50 p.m. UTC | #2
Hi Thierry,

On 3/22/21 12:32 PM, Thierry Reding wrote:
> On Mon, Dec 07, 2020 at 02:45:56PM +0100, Uwe Kleine-König wrote:
>> pwmchip_add() only calls pwmchip_add_with_polarity() and nothing else. All
>> other users of pwmchip_add_with_polarity() are gone. So drop
>> pwmchip_add_with_polarity() and move the code instead to pwmchip_add().
>>
>> The initial assignment to pwm->state.polarity is dropped. In every correct
>> usage of the PWM API this value is overwritten later anyhow.
>>
>> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
>> ---
>>   drivers/pwm/core.c  | 25 +++----------------------
>>   include/linux/pwm.h |  2 --
>>   2 files changed, 3 insertions(+), 24 deletions(-)
> 
> There was a conflict between this and patch "pwm: Always allocate PWM
> chip base ID dynamically", but it was fairly trivial to resolve. Let me
> know if you think I didn't resolve it correctly.

You did it in the same way I did it on my next branch. (Actually I had 
the patch order reversed, but the result is the same.)

Best regards
Uwe
diff mbox series

Patch

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 1f16f5365d3c..78611487d887 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -260,18 +260,15 @@  static bool pwm_ops_check(const struct pwm_chip *chip)
 }
 
 /**
- * pwmchip_add_with_polarity() - register a new PWM chip
+ * pwmchip_add() - register a new PWM chip
  * @chip: the PWM chip to add
- * @polarity: initial polarity of PWM channels
  *
  * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
- * will be used. The initial polarity for all channels is specified by the
- * @polarity parameter.
+ * will be used.
  *
  * Returns: 0 on success or a negative error code on failure.
  */
-int pwmchip_add_with_polarity(struct pwm_chip *chip,
-			      enum pwm_polarity polarity)
+int pwmchip_add(struct pwm_chip *chip)
 {
 	struct pwm_device *pwm;
 	unsigned int i;
@@ -303,7 +300,6 @@  int pwmchip_add_with_polarity(struct pwm_chip *chip,
 		pwm->chip = chip;
 		pwm->pwm = chip->base + i;
 		pwm->hwpwm = i;
-		pwm->state.polarity = polarity;
 
 		radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
 	}
@@ -326,21 +322,6 @@  int pwmchip_add_with_polarity(struct pwm_chip *chip,
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(pwmchip_add_with_polarity);
-
-/**
- * pwmchip_add() - register a new PWM chip
- * @chip: the PWM chip to add
- *
- * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
- * will be used. The initial polarity for all channels is normal.
- *
- * Returns: 0 on success or a negative error code on failure.
- */
-int pwmchip_add(struct pwm_chip *chip)
-{
-	return pwmchip_add_with_polarity(chip, PWM_POLARITY_NORMAL);
-}
 EXPORT_SYMBOL_GPL(pwmchip_add);
 
 /**
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index e4d84d4db293..8f4eefd129aa 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -392,8 +392,6 @@  int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
 int pwm_set_chip_data(struct pwm_device *pwm, void *data);
 void *pwm_get_chip_data(struct pwm_device *pwm);
 
-int pwmchip_add_with_polarity(struct pwm_chip *chip,
-			      enum pwm_polarity polarity);
 int pwmchip_add(struct pwm_chip *chip);
 int pwmchip_remove(struct pwm_chip *chip);
 struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,