linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: core: cleanup pointer tests
@ 2015-08-07 14:49 Olliver Schinagl
  2015-08-07 18:18 ` Olliver Schinagl
  0 siblings, 1 reply; 2+ messages in thread
From: Olliver Schinagl @ 2015-08-07 14:49 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Olliver Schinagl, linux-pwm, linux-kernel

From: Olliver Schinagl <oliver@schinagl.nl>

pwm_set_polarity() checks if there's ops and polarity function pointers.
Most of these pointers are actually checked when a chip is added via
pwm_add, except for set_polarity.

This patch adds set_polarity to the list of functions to test on
pwmchip_add_with_polarity(); and removes these checks from
pwm_set_polarity.

The pwm should be valid, as it was checked during
pwmchip_add_with_polarity().

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
 drivers/pwm/core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 3a7769f..66fd5fd 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -239,7 +239,8 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
 	int ret;
 
 	if (!chip || !chip->dev || !chip->ops || !chip->ops->config ||
-	    !chip->ops->enable || !chip->ops->disable || !chip->npwm)
+	    !chip->ops->set_polarity || !chip->ops->enable ||
+	    !chip->ops->disable || !chip->npwm)
 		return -EINVAL;
 
 	mutex_lock(&pwm_lock);
@@ -449,12 +450,9 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
 {
 	int err;
 
-	if (!pwm || !pwm->chip->ops)
+	if (!pwm)
 		return -EINVAL;
 
-	if (!pwm->chip->ops->set_polarity)
-		return -ENOSYS;
-
 	if (test_bit(PWMF_ENABLED, &pwm->flags))
 		return -EBUSY;
 
-- 
2.1.4


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

* Re: [PATCH] pwm: core: cleanup pointer tests
  2015-08-07 14:49 [PATCH] pwm: core: cleanup pointer tests Olliver Schinagl
@ 2015-08-07 18:18 ` Olliver Schinagl
  0 siblings, 0 replies; 2+ messages in thread
From: Olliver Schinagl @ 2015-08-07 18:18 UTC (permalink / raw)
  To: Olliver Schinagl, Thierry Reding; +Cc: linux-pwm, linux-kernel

Hey list,

After working on a new pwm-driver I noticed that not everybody actually 
has the set_polarity op and thus its an optional property. For a moment 
I figured I could add a 'software' polarity function by inverting the 
calculation of the on/off time, but I don't even have the hardware to 
test it so ...

Sorry for the noise, this patch can be ignored.

Olliver

On 07-08-15 16:49, Olliver Schinagl wrote:
> From: Olliver Schinagl <oliver@schinagl.nl>
>
> pwm_set_polarity() checks if there's ops and polarity function pointers.
> Most of these pointers are actually checked when a chip is added via
> pwm_add, except for set_polarity.
>
> This patch adds set_polarity to the list of functions to test on
> pwmchip_add_with_polarity(); and removes these checks from
> pwm_set_polarity.
>
> The pwm should be valid, as it was checked during
> pwmchip_add_with_polarity().
>
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> ---
>   drivers/pwm/core.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 3a7769f..66fd5fd 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -239,7 +239,8 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
>   	int ret;
>   
>   	if (!chip || !chip->dev || !chip->ops || !chip->ops->config ||
> -	    !chip->ops->enable || !chip->ops->disable || !chip->npwm)
> +	    !chip->ops->set_polarity || !chip->ops->enable ||
> +	    !chip->ops->disable || !chip->npwm)
>   		return -EINVAL;
>   
>   	mutex_lock(&pwm_lock);
> @@ -449,12 +450,9 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
>   {
>   	int err;
>   
> -	if (!pwm || !pwm->chip->ops)
> +	if (!pwm)
>   		return -EINVAL;
>   
> -	if (!pwm->chip->ops->set_polarity)
> -		return -ENOSYS;
> -
>   	if (test_bit(PWMF_ENABLED, &pwm->flags))
>   		return -EBUSY;
>   


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

end of thread, other threads:[~2015-08-07 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-07 14:49 [PATCH] pwm: core: cleanup pointer tests Olliver Schinagl
2015-08-07 18:18 ` Olliver Schinagl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).