Skip to contentSkip to conversation

pwm: remove set but not set variable 'pwm'

PATCH Superseded yu kuai 2 participants 4 messages Jan 19, 2020 – Jan 20, 2020 PWM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

yu kuai

author
#0 lore raw

PATCH 1/1 pwm: remove set but not set variable 'pwm'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/pwm/pwm-pca9685.c: In function ‘pca9685_pwm_gpio_free’:
drivers/pwm/pwm-pca9685.c:162:21: warning: variable ‘pwm’ set but not used [-Wunused-but-set-variable]

It is never used, and so can be removed.

---
 drivers/pwm/pwm-pca9685.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/pwm/pwm-pca9685.c +0 -4
index 168684b02ebc..b07bdca3d510 100644
@@ -159,13 +159,9 @@ static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
 static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
 {
 	struct pca9685 *pca = gpiochip_get_data(gpio);
-	struct pwm_device *pwm;
 
 	pca9685_pwm_gpio_set(gpio, offset, 0);
 	pm_runtime_put(pca->chip.dev);
-	mutex_lock(&pca->lock);
-	pwm = &pca->chip.pwms[offset];
-	mutex_unlock(&pca->lock);
 }
 
 static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
Signature · 1 line
2.17.2
#1 lore raw

Hello,

$Subject ~= s/not set/not used/

Quoted 9 lines · yu kuai

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/pwm/pwm-pca9685.c: In function ‘pca9685_pwm_gpio_free’:
drivers/pwm/pwm-pca9685.c:162:21: warning: variable ‘pwm’ set but not used [-Wunused-but-set-variable]

It is never used, and so can be removed.

Fixes e926b12c611c ("pwm: Clear chip_data in pwm_put()")
Quoted 9 lines
---
 drivers/pwm/pwm-pca9685.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/pwm/pwm-pca9685.c +0 -0
index 168684b02ebc..b07bdca3d510 100644

drivers/pwm/pwm-pca9685.c static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset, · line 168

Quoted 10 lines
drivers/pwm/pwm-pca9685.c +0 -4
@@ -159,13 +159,9 @@ static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
 static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
 {
 	struct pca9685 *pca = gpiochip_get_data(gpio);
-	struct pwm_device *pwm;
 
 	pca9685_pwm_gpio_set(gpio, offset, 0);
 	pm_runtime_put(pca->chip.dev);
-	mutex_lock(&pca->lock);
-	pwm = &pca->chip.pwms[offset];
-	mutex_unlock(&pca->lock);

Did you check that dropping the locking is save? (I didn't)

I'd assume that no harm is introduced, but mentioning that in the commit log would be good.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
author
#2 lore raw
Quoted 1 line · Uwe Kleine-König
Fixes e926b12c611c ("pwm: Clear chip_data in pwm_put()")

Thank you for your advise! I'll add 'Fixes' in a V2 patch.

Quoted 4 lines

Did you check that dropping the locking is save? (I didn't)

I'd assume that no harm is introduced, but mentioning that in the commit log would be good.

I think dropping the lock is safe since there is nothing to be done inside the lock. However, I didn't run a full test. By the way, I'll mentioning it in a V2 patch.

Thanks!
Yu Kuai

#3 lore raw
Quoted 5 lines · yukuai (C)
Quoted 1 line · Uwe Kleine-König
Fixes e926b12c611c ("pwm: Clear chip_data in pwm_put()")

Thank you for your advise! I'll add 'Fixes' in a V2 patch.

Quoted 8 lines
Quoted 4 lines

Did you check that dropping the locking is save? (I didn't)

I'd assume that no harm is introduced, but mentioning that in the commit log would be good.

I think dropping the lock is safe since there is nothing to be done inside the lock. However, I didn't run a full test. By the way, I'll mentioning it in a V2 patch.

There are (rare) situations where taking and dropping a lock might make sense. For example if you have a another context and want to make sure that a shared resource isn't about to be used.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |