Message ID | 20200119122202.14502-1-yukuai3@huawei.com |
---|---|
State | Changes Requested |
Headers | show |
Series | pwm: remove set but not set variable 'pwm' | expand |
Hello, $Subject ~= s/not set/not used/ On Sun, Jan 19, 2020 at 08:22:02PM +0800, yu kuai wrote: > 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. > > Signed-off-by: yu kuai <yukuai3@huawei.com> Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") > --- > drivers/pwm/pwm-pca9685.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c > index 168684b02ebc..b07bdca3d510 100644 > --- a/drivers/pwm/pwm-pca9685.c > +++ b/drivers/pwm/pwm-pca9685.c > @@ -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
On 2020/1/20 15:34, Uwe Kleine-König wrote: > Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") Thank you for your advise! I'll add 'Fixes' in a V2 patch. > 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
On Mon, Jan 20, 2020 at 07:40:37PM +0800, yukuai (C) wrote: > On 2020/1/20 15:34, Uwe Kleine-König wrote: > > Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") > > Thank you for your advise! I'll add 'Fixes' in a V2 patch. > > > 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
diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index 168684b02ebc..b07bdca3d510 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c @@ -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,
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. Signed-off-by: yu kuai <yukuai3@huawei.com> --- drivers/pwm/pwm-pca9685.c | 4 ---- 1 file changed, 4 deletions(-)