pwm: core: Refactor pwmchip_add() to avoid extra checks
PATCH v2 1/2 pwm: core: Refactor pwmchip_add() to avoid extra checks
When we already know that everything is fine there is no need to use ret variable. Refactor code accordingly.
---
v2: rebased with dropped wrong patch (LKP)
drivers/pwm/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pwm/core.c +5 -5
@@ -296,16 +296,16 @@ int pwmchip_add(struct pwm_chip *chip)INIT_LIST_HEAD (&chip->list);list_add (&chip->list, &pwm_chips); - ret =0 ; -if (IS_ENABLED (CONFIG_OF ))of_pwmchip_add (chip); -out:mutex_unlock (&pwm_lock); -if (!ret) -pwmchip_sysfs_export (chip); +pwmchip_sysfs_export (chip); + +return 0 ; +out: +mutex_unlock (&pwm_lock);return ret; }
Signature · 1 line
2.35.1
PATCH v2 2/2 pwm: core: Remove S_IFREG from debugfs_create_file()
The debugfs_create_file() already has a check and adds S_IFREG automatically. Remove unneeded flag.
---
v2: rebased with dropped wrong patch (LKP)
drivers/pwm/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pwm/core.c +1 -2
@@ -1179,8 +1179,7 @@ DEFINE_SEQ_ATTRIBUTE(pwm_debugfs);static int __init pwm_debugfs_init (void ) { -debugfs_create_file ("pwm" ,S_IFREG |0444 ,NULL ,NULL , - &pwm_debugfs_fops); +debugfs_create_file ("pwm" ,0444 ,NULL ,NULL , &pwm_debugfs_fops);return 0 ; }
Signature · 1 line
2.35.1
Hello,
Quoted 4 lines · Andy Shevchenko
When we already know that everything is fine there is no need to use ret variable. Refactor code accordingly.
Signed-off-by Andy Shevchenko <[email protected]>
The patch is correct (i.e. doesn't change the semantic of the function).
But I think there is some more potential to clean up than it used here. I will send out a series that I like better than this patch.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 10 lines · Uwe Kleine-König
Quoted 4 lines · Andy Shevchenko
When we already know that everything is fine there is no need to use ret variable. Refactor code accordingly.
Signed-off-by Andy Shevchenko <[email protected]>The patch is correct (i.e. doesn't change the semantic of the function).
But I think there is some more potential to clean up than it used here. I will send out a series that I like better than this patch.
Fine, can you attach the second patch of this series to yours v2, please?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Uwe Kleine-König
Quoted 3 lines · Andy Shevchenko
When we already know that everything is fine there is no need to use ret variable. Refactor code accordingly.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>The patch is correct (i.e. doesn't change the semantic of the function).
But I think there is some more potential to clean up than it used here. I will send out a series that I like better than this patch.
Fine, can you attach the second patch of this series to yours v2, please?
These are independant cleanups. I suggest that Thierry just picks up the other patch in this series (assuming of course he is OK with it).
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |