Skip to contentSkip to conversation

pwm: pca9685: Fix wrong argument to set MODE1_SLEEP bit

PATCH Applied Axel Lin 3 participants 4 messages Jun 19, 2013 – Jun 26, 2013 PWM

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 pwm: pca9685: Fix wrong argument to set MODE1_SLEEP bit

Current code actually does not set MODE1_SLEEP bit because the new value for bitmask (0x1) is wrong. To set MODE1_SLEEP bit, we should pass MODE1_SLEEP as the new value for bitmask.

---
Hi Steffen,
I don't have this hardware, can you test if this patch works? Thanks,
Axel

 drivers/pwm/pwm-pca9685.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pwm/pwm-pca9685.c +3 -2
index c9f9e65..3fb775d 100644
@@ -190,7 +190,7 @@ static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	if (--pca->active_cnt == 0)
 		regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
-				   0x1);
+				   MODE1_SLEEP);
 }
 
 static const struct pwm_ops pca9685_pwm_ops = {
@@ -264,7 +264,8 @@ static int pca9685_pwm_remove(struct i2c_client *client)
 {
 	struct pca9685 *pca = i2c_get_clientdata(client);
 
-	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP, 0x1);
+	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
+			   MODE1_SLEEP);
 
 	return pwmchip_remove(&pca->chip);
 }
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 5 lines · Axel Lin

Current code actually does not set MODE1_SLEEP bit because the new value for bitmask (0x1) is wrong. To set MODE1_SLEEP bit, we should pass MODE1_SLEEP as the new value for bitmask.

Quoted 8 lines

---
Hi Steffen,
I don't have this hardware, can you test if this patch works? Thanks,
Axel

 drivers/pwm/pwm-pca9685.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Steffen,

are you able to test or review this? The patch seems good but I'm not familiar with the hardware nor do I have a board to test it on.

Thierry

Quoted 29 lines
drivers/pwm/pwm-pca9685.c +3 -2
index c9f9e65..3fb775d 100644
@@ -190,7 +190,7 @@ static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	if (--pca->active_cnt == 0)
 		regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
-				   0x1);
+				   MODE1_SLEEP);
 }
 
 static const struct pwm_ops pca9685_pwm_ops = {
@@ -264,7 +264,8 @@ static int pca9685_pwm_remove(struct i2c_client *client)
 {
 	struct pca9685 *pca = i2c_get_clientdata(client);
 
-	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP, 0x1);
+	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
+			   MODE1_SLEEP);
 
 	return pwmchip_remove(&pca->chip);
 }
Signature · 1 line
1.8.1.2
Reviewed-by
#2 lore raw
Quoted 40 lines · Thierry Reding
Quoted 5 lines · Axel Lin

Current code actually does not set MODE1_SLEEP bit because the new value for bitmask (0x1) is wrong. To set MODE1_SLEEP bit, we should pass MODE1_SLEEP as the new value for bitmask.

Quoted 8 lines

---
Hi Steffen,
I don't have this hardware, can you test if this patch works? Thanks,
Axel

 drivers/pwm/pwm-pca9685.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Steffen,

are you able to test or review this? The patch seems good but I'm not familiar with the hardware nor do I have a board to test it on.

Thierry

Quoted 18 lines
drivers/pwm/pwm-pca9685.c +1 -1
index c9f9e65..3fb775d 100644
@@ -190,7 +190,7 @@ static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	if (--pca->active_cnt == 0)
 		regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
-				   0x1);
+				   MODE1_SLEEP);
 }
 
 static const struct pwm_ops pca9685_pwm_ops = {
@@ -264,7 +264,8 @@ static int pca9685_pwm_remove(struct i2c_client *client)
 {
 	struct pca9685 *pca = i2c_get_clientdata(client);
 
Quoted 7 lines

drivers/pwm/pwm-pca9685.c static int pca9685_pwm_remove(struct i2c_client *client) · line 271

Quoted 7 lines
drivers/pwm/pwm-pca9685.c +2 -1
-	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP, 0x1);
+	regmap_update_bits(pca->regmap, PCA9685_MODE1, MODE1_SLEEP,
+			   MODE1_SLEEP);
 
 	return pwmchip_remove(&pca->chip);
 }

Hi!

Looks good. I used regmap_update_bits wrong, obviously. I only provided the value (0x1), but did not apply the correct mask to it, which this version (with MODE1_SLEEP) does.

So, you may add my

Thank you Axel for fixing it,
Steffen

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw
In reply to Axel Lin
Quoted 5 lines · Axel Lin

Current code actually does not set MODE1_SLEEP bit because the new value for bitmask (0x1) is wrong. To set MODE1_SLEEP bit, we should pass MODE1_SLEEP as the new value for bitmask.

Quoted 8 lines

---
Hi Steffen,
I don't have this hardware, can you test if this patch works? Thanks,
Axel

 drivers/pwm/pwm-pca9685.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks.

Thierry