[openwrt/openwrt] kernel: leds-gca230718: remove status variable
LEDE Commits
lede-commits at lists.infradead.org
Mon Dec 23 15:25:00 PST 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/980fe907116e4a15737ca3895979b59c10aff791
commit 980fe907116e4a15737ca3895979b59c10aff791
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Sun Oct 6 16:56:25 2024 -0700
kernel: leds-gca230718: remove status variable
I have no idea why this is even here. Simplifies the code with direct
returns.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16869
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
package/kernel/leds-gca230718/src/leds-gca230718.c | 115 ++++++++++-----------
1 file changed, 53 insertions(+), 62 deletions(-)
diff --git a/package/kernel/leds-gca230718/src/leds-gca230718.c b/package/kernel/leds-gca230718/src/leds-gca230718.c
index 9069fc90f7..98cc732c34 100644
--- a/package/kernel/leds-gca230718/src/leds-gca230718.c
+++ b/package/kernel/leds-gca230718/src/leds-gca230718.c
@@ -116,78 +116,69 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev,
static int gca230718_probe(struct i2c_client *client)
{
- int status = 0;
struct gca230718_private *gca230718_privateData;
pr_info("Enter gca230718_probe for device address %u\n", client->addr);
gca230718_privateData = devm_kzalloc(
- &(client->dev), sizeof(struct gca230718_private), GFP_KERNEL);
+ &client->dev, sizeof(struct gca230718_private), GFP_KERNEL);
- if (gca230718_privateData == NULL) {
+ if (!gca230718_privateData) {
pr_info("Error during allocating memory for private data\n");
- status = -ENOMEM;
- } else {
- struct device_node *ledNode;
- mutex_init(&gca230718_privateData->lock);
- gca230718_init_private_led_data(gca230718_privateData);
- i2c_set_clientdata(client, gca230718_privateData);
-
- for_each_child_of_node(client->dev.of_node, ledNode) {
- u32 regValue = 0;
- if (of_property_read_u32(ledNode, "reg", ®Value) !=
- 0) {
- pr_info("Missing entry \"reg\" in node %s\n",
- ledNode->name);
- } else if (regValue >= GCA230718_MAX_LEDS) {
- pr_info("Invalid entry \"reg\" in node %s (%u)\n",
- ledNode->name, regValue);
- } else {
- struct led_classdev *ledClassDev =
- &(gca230718_privateData->leds[regValue]
- .ledClassDev);
- struct led_init_data init_data = {};
-
- gca230718_privateData->leds[regValue].client =
- client;
- init_data.fwnode = of_fwnode_handle(ledNode);
-
- pr_info("Creating LED for node %s: reg=%u\n",
- ledNode->name, regValue);
-
- ledClassDev->name =
- of_get_property(ledNode, "label", NULL);
- if (ledClassDev->name == NULL) {
- ledClassDev->name = ledNode->name;
- }
-
- ledClassDev->brightness = LED_OFF;
- ledClassDev->max_brightness = LED_FULL;
- ledClassDev->brightness_set_blocking =
- gca230718_set_brightness;
-
- if (devm_led_classdev_register_ext(
- &(client->dev), ledClassDev,
- &init_data) != 0) {
- pr_info("Error during call of devm_led_classdev_register_ext");
- }
- }
+ return -ENOMEM;
+ }
+ struct device_node *ledNode;
+ mutex_init(&gca230718_privateData->lock);
+ gca230718_init_private_led_data(gca230718_privateData);
+ i2c_set_clientdata(client, gca230718_privateData);
+
+ for_each_child_of_node(client->dev.of_node, ledNode) {
+ u32 regValue = 0;
+ if (of_property_read_u32(ledNode, "reg", ®Value))
+ pr_info("Missing entry \"reg\" in node %s\n",
+ ledNode->name);
+ else if (regValue >= GCA230718_MAX_LEDS)
+ pr_info("Invalid entry \"reg\" in node %s (%u)\n",
+ ledNode->name, regValue);
+ else {
+ struct led_classdev *ledClassDev =
+ &(gca230718_privateData->leds[regValue]
+ .ledClassDev);
+ struct led_init_data init_data = {};
+
+ gca230718_privateData->leds[regValue].client = client;
+ init_data.fwnode = of_fwnode_handle(ledNode);
+
+ pr_info("Creating LED for node %s: reg=%u\n",
+ ledNode->name, regValue);
+
+ ledClassDev->name =
+ of_get_property(ledNode, "label", NULL);
+ if (!ledClassDev->name)
+ ledClassDev->name = ledNode->name;
+
+ ledClassDev->brightness = LED_OFF;
+ ledClassDev->max_brightness = LED_FULL;
+ ledClassDev->brightness_set_blocking =
+ gca230718_set_brightness;
+
+ if (devm_led_classdev_register_ext(
+ &client->dev, ledClassDev, &init_data))
+ pr_info("Error during call of devm_led_classdev_register_ext");
}
}
- if (status == 0) {
- /*
- Send full initialization sequence.
- Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values.
- */
- gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1,
- gca230718_privateData);
- gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1,
- gca230718_privateData);
- gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1,
- gca230718_privateData);
- }
+ /*
+ Send full initialization sequence.
+ Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values.
+ */
+ gca230718_send_sequence(client, GCA230718_1ST_SEQUENCE_BYTE_1,
+ gca230718_privateData);
+ gca230718_send_sequence(client, GCA230718_2ND_SEQUENCE_BYTE_1,
+ gca230718_privateData);
+ gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1,
+ gca230718_privateData);
- return status;
+ return 0;
}
static void gca230718_remove(struct i2c_client *client)
More information about the lede-commits
mailing list