2022-06-09 16:51:54

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

The standard conditional pattern is to check for errors first and
bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally
on success.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/leds/led-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 4a97cb745788..96a2817712e5 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);

int led_update_brightness(struct led_classdev *led_cdev)
{
- int ret = 0;
+ int ret;

if (led_cdev->brightness_get) {
ret = led_cdev->brightness_get(led_cdev);
- if (ret >= 0) {
- led_cdev->brightness = ret;
- return 0;
- }
+ if (ret < 0)
+ return ret;
+
+ led_cdev->brightness = ret;
}

- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(led_update_brightness);

--
2.35.1


2022-06-10 05:54:20

by Denis OSTERLAND-HEIM

[permalink] [raw]
Subject: RE: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

LGTM

Acked-by: Denis Osterland-Heim <[email protected]>

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Thursday, June 9, 2022 6:23 PM
To: Denis OSTERLAND-HEIM <[email protected]>; Andy Shevchenko <[email protected]>; [email protected]; [email protected]
Cc: Pavel Machek <[email protected]>
Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

The standard conditional pattern is to check for errors first and bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally on success.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/leds/led-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 4a97cb745788..96a2817712e5 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);

int led_update_brightness(struct led_classdev *led_cdev) {
-int ret = 0;
+int ret;

if (led_cdev->brightness_get) {
ret = led_cdev->brightness_get(led_cdev);
-if (ret >= 0) {
-led_cdev->brightness = ret;
-return 0;
-}
+if (ret < 0)
+return ret;
+
+led_cdev->brightness = ret;
}

-return ret;
+return 0;
}
EXPORT_SYMBOL_GPL(led_update_brightness);

--
2.35.1
Diehl Metering GmbH, Donaustrasse 120, 90451 Nuernberg
Sitz der Gesellschaft: Ansbach, Registergericht: Ansbach HRB 69
Geschaeftsfuehrer: Dr. Christof Bosbach (Sprecher), Dipl.-Dolm. Annette Geuther, Dipl.-Kfm. Reiner Edel

Bitte denken Sie an die Umwelt, bevor Sie diese E-Mail drucken. Diese E-Mail kann vertrauliche Informationen enthalten. Sollten die in dieser E-Mail enthaltenen Informationen nicht für Sie bestimmt sein, informieren Sie bitte unverzueglich den Absender per E-Mail und loeschen Sie diese E-Mail in Ihrem System. Jede unberechtigte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt. Informationen zum Datenschutz finden Sie auf unserer Homepage<https://www.diehl.com/metering/de/impressum-und-rechtliche-hinweise/>.

Before printing, think about environmental responsibility.This message may contain confidential information. If you are not authorized to receive this information please advise the sender immediately by reply e-mail and delete this message without making any copies. Any form of unauthorized use, publication, reproduction, copying or disclosure of the e-mail is not permitted. Information about data protection can be found on our homepage<https://www.diehl.com/metering/en/data-protection/>.

2022-06-10 06:06:20

by Denis OSTERLAND-HEIM

[permalink] [raw]
Subject: RE: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

LGTM

Acked-by: Denis Osterland <[email protected]>

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Thursday, June 9, 2022 6:23 PM
To: Denis OSTERLAND-HEIM <[email protected]>; Andy Shevchenko <[email protected]>; [email protected]; [email protected]
Cc: Pavel Machek <[email protected]>
Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

The standard conditional pattern is to check for errors first and bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally on success.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/leds/led-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 4a97cb745788..96a2817712e5 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);

int led_update_brightness(struct led_classdev *led_cdev) {
-int ret = 0;
+int ret;

if (led_cdev->brightness_get) {
ret = led_cdev->brightness_get(led_cdev);
-if (ret >= 0) {
-led_cdev->brightness = ret;
-return 0;
-}
+if (ret < 0)
+return ret;
+
+led_cdev->brightness = ret;
}

-return ret;
+return 0;
}
EXPORT_SYMBOL_GPL(led_update_brightness);

--
2.35.1
Diehl Metering GmbH, Donaustrasse 120, 90451 Nuernberg
Sitz der Gesellschaft: Ansbach, Registergericht: Ansbach HRB 69
Geschaeftsfuehrer: Dr. Christof Bosbach (Sprecher), Dipl.-Dolm. Annette Geuther, Dipl.-Kfm. Reiner Edel

Bitte denken Sie an die Umwelt, bevor Sie diese E-Mail drucken. Diese E-Mail kann vertrauliche Informationen enthalten. Sollten die in dieser E-Mail enthaltenen Informationen nicht für Sie bestimmt sein, informieren Sie bitte unverzueglich den Absender per E-Mail und loeschen Sie diese E-Mail in Ihrem System. Jede unberechtigte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt. Informationen zum Datenschutz finden Sie auf unserer Homepage<https://www.diehl.com/metering/de/impressum-und-rechtliche-hinweise/>.

Before printing, think about environmental responsibility.This message may contain confidential information. If you are not authorized to receive this information please advise the sender immediately by reply e-mail and delete this message without making any copies. Any form of unauthorized use, publication, reproduction, copying or disclosure of the e-mail is not permitted. Information about data protection can be found on our homepage<https://www.diehl.com/metering/en/data-protection/>.

2022-06-10 06:06:37

by Denis OSTERLAND-HEIM

[permalink] [raw]
Subject: RE: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern

LGTM

Acked-by: Denis Osterland-Heim <[email protected]>

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Thursday, June 9, 2022 6:23 PM
To: Denis OSTERLAND-HEIM <[email protected]>; Andy Shevchenko
<[email protected]>; [email protected];
[email protected]
Cc: Pavel Machek <[email protected]>
Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use
standard pattern

The standard conditional pattern is to check for errors first and
bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally
on success.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/leds/led-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 4a97cb745788..96a2817712e5 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);

int led_update_brightness(struct led_classdev *led_cdev)
{
- int ret = 0;
+ int ret;

if (led_cdev->brightness_get) {
ret = led_cdev->brightness_get(led_cdev);
- if (ret >= 0) {
- led_cdev->brightness = ret;
- return 0;
- }
+ if (ret < 0)
+ return ret;
+
+ led_cdev->brightness = ret;
}

- return ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(led_update_brightness);

--
2.35.1


Attachments:
smime.p7s (3.82 kB)