All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks
@ 2022-11-14 17:00 Andy Shevchenko
  2022-11-14 17:00 ` [PATCH v2 2/2] pwm: core: Remove S_IFREG from debugfs_create_file() Andy Shevchenko
  2022-11-15 20:24 ` [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Uwe Kleine-König
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-14 17:00 UTC (permalink / raw)
  To: Uwe Kleine-König, linux-pwm, linux-kernel
  Cc: Thierry Reding, 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 <andriy.shevchenko@linux.intel.com>
---
v2: rebased with dropped wrong patch (LKP)
 drivers/pwm/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] pwm: core: Remove S_IFREG from debugfs_create_file()
  2022-11-14 17:00 [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Andy Shevchenko
@ 2022-11-14 17:00 ` Andy Shevchenko
  2022-11-15 20:24 ` [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Uwe Kleine-König
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-14 17:00 UTC (permalink / raw)
  To: Uwe Kleine-König, linux-pwm, linux-kernel
  Cc: Thierry Reding, Andy Shevchenko

The debugfs_create_file() already has a check and adds S_IFREG
automatically. Remove unneeded flag.

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

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks
  2022-11-14 17:00 [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Andy Shevchenko
  2022-11-14 17:00 ` [PATCH v2 2/2] pwm: core: Remove S_IFREG from debugfs_create_file() Andy Shevchenko
@ 2022-11-15 20:24 ` Uwe Kleine-König
  2022-11-16  8:22   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2022-11-15 20:24 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pwm, linux-kernel, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks
  2022-11-15 20:24 ` [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Uwe Kleine-König
@ 2022-11-16  8:22   ` Andy Shevchenko
  2022-11-17 13:54     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-11-16  8:22 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-pwm, linux-kernel, Thierry Reding

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?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks
  2022-11-16  8:22   ` Andy Shevchenko
@ 2022-11-17 13:54     ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2022-11-17 13:54 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pwm, linux-kernel, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-17 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 17:00 [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Andy Shevchenko
2022-11-14 17:00 ` [PATCH v2 2/2] pwm: core: Remove S_IFREG from debugfs_create_file() Andy Shevchenko
2022-11-15 20:24 ` [PATCH v2 1/2] pwm: core: Refactor pwmchip_add() to avoid extra checks Uwe Kleine-König
2022-11-16  8:22   ` Andy Shevchenko
2022-11-17 13:54     ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.