[v2,1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks

Message ID 20221114170006.61751-1-andriy.shevchenko@linux.intel.com
State New
Headers
Series [v2,1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks |

Commit Message

Andy Shevchenko Nov. 14, 2022, 5 p.m. UTC
  When we already know that everything is fine there is no need
to use ret variable. Refactor code accordingly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: rebased with dropped wrong patch (LKP)
 drivers/pwm/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Uwe Kleine-König Nov. 15, 2022, 8:24 p.m. UTC | #1
Hello,

On Mon, Nov 14, 2022 at 07:00:04PM +0200, Andy Shevchenko wrote:
> When we already know that everything is fine there is no need
> to use ret variable. Refactor code accordingly.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

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
  
Andy Shevchenko Nov. 16, 2022, 8:22 a.m. UTC | #2
On Tue, Nov 15, 2022 at 09:24:12PM +0100, Uwe Kleine-König wrote:
> On Mon, Nov 14, 2022 at 07:00:04PM +0200, Andy Shevchenko wrote:
> > When we already know that everything is fine there is no need
> > to use ret variable. Refactor code accordingly.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> 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?
  
Uwe Kleine-König Nov. 17, 2022, 1:54 p.m. UTC | #3
On Wed, Nov 16, 2022 at 10:22:56AM +0200, Andy Shevchenko wrote:
> On Tue, Nov 15, 2022 at 09:24:12PM +0100, Uwe Kleine-König wrote:
> > On Mon, Nov 14, 2022 at 07:00:04PM +0200, Andy Shevchenko wrote:
> > > When we already know that everything is fine there is no need
> > > to use ret variable. Refactor code accordingly.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > 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
  

Patch

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index d333e7422f4a..855abd0a776f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -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;
 }