mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-16 09:50:26 +00:00
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@gmail.com> Link: https://github.com/openwrt/openwrt/pull/16869 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
e2b80013ed
commit
980fe90711
@ -116,17 +116,16 @@ static int gca230718_set_brightness(struct led_classdev *led_cdev,
|
|||||||
|
|
||||||
static int gca230718_probe(struct i2c_client *client)
|
static int gca230718_probe(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
int status = 0;
|
|
||||||
struct gca230718_private *gca230718_privateData;
|
struct gca230718_private *gca230718_privateData;
|
||||||
|
|
||||||
pr_info("Enter gca230718_probe for device address %u\n", client->addr);
|
pr_info("Enter gca230718_probe for device address %u\n", client->addr);
|
||||||
gca230718_privateData = devm_kzalloc(
|
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");
|
pr_info("Error during allocating memory for private data\n");
|
||||||
status = -ENOMEM;
|
return -ENOMEM;
|
||||||
} else {
|
}
|
||||||
struct device_node *ledNode;
|
struct device_node *ledNode;
|
||||||
mutex_init(&gca230718_privateData->lock);
|
mutex_init(&gca230718_privateData->lock);
|
||||||
gca230718_init_private_led_data(gca230718_privateData);
|
gca230718_init_private_led_data(gca230718_privateData);
|
||||||
@ -134,21 +133,19 @@ static int gca230718_probe(struct i2c_client *client)
|
|||||||
|
|
||||||
for_each_child_of_node(client->dev.of_node, ledNode) {
|
for_each_child_of_node(client->dev.of_node, ledNode) {
|
||||||
u32 regValue = 0;
|
u32 regValue = 0;
|
||||||
if (of_property_read_u32(ledNode, "reg", ®Value) !=
|
if (of_property_read_u32(ledNode, "reg", ®Value))
|
||||||
0) {
|
|
||||||
pr_info("Missing entry \"reg\" in node %s\n",
|
pr_info("Missing entry \"reg\" in node %s\n",
|
||||||
ledNode->name);
|
ledNode->name);
|
||||||
} else if (regValue >= GCA230718_MAX_LEDS) {
|
else if (regValue >= GCA230718_MAX_LEDS)
|
||||||
pr_info("Invalid entry \"reg\" in node %s (%u)\n",
|
pr_info("Invalid entry \"reg\" in node %s (%u)\n",
|
||||||
ledNode->name, regValue);
|
ledNode->name, regValue);
|
||||||
} else {
|
else {
|
||||||
struct led_classdev *ledClassDev =
|
struct led_classdev *ledClassDev =
|
||||||
&(gca230718_privateData->leds[regValue]
|
&(gca230718_privateData->leds[regValue]
|
||||||
.ledClassDev);
|
.ledClassDev);
|
||||||
struct led_init_data init_data = {};
|
struct led_init_data init_data = {};
|
||||||
|
|
||||||
gca230718_privateData->leds[regValue].client =
|
gca230718_privateData->leds[regValue].client = client;
|
||||||
client;
|
|
||||||
init_data.fwnode = of_fwnode_handle(ledNode);
|
init_data.fwnode = of_fwnode_handle(ledNode);
|
||||||
|
|
||||||
pr_info("Creating LED for node %s: reg=%u\n",
|
pr_info("Creating LED for node %s: reg=%u\n",
|
||||||
@ -156,9 +153,8 @@ static int gca230718_probe(struct i2c_client *client)
|
|||||||
|
|
||||||
ledClassDev->name =
|
ledClassDev->name =
|
||||||
of_get_property(ledNode, "label", NULL);
|
of_get_property(ledNode, "label", NULL);
|
||||||
if (ledClassDev->name == NULL) {
|
if (!ledClassDev->name)
|
||||||
ledClassDev->name = ledNode->name;
|
ledClassDev->name = ledNode->name;
|
||||||
}
|
|
||||||
|
|
||||||
ledClassDev->brightness = LED_OFF;
|
ledClassDev->brightness = LED_OFF;
|
||||||
ledClassDev->max_brightness = LED_FULL;
|
ledClassDev->max_brightness = LED_FULL;
|
||||||
@ -166,15 +162,11 @@ static int gca230718_probe(struct i2c_client *client)
|
|||||||
gca230718_set_brightness;
|
gca230718_set_brightness;
|
||||||
|
|
||||||
if (devm_led_classdev_register_ext(
|
if (devm_led_classdev_register_ext(
|
||||||
&(client->dev), ledClassDev,
|
&client->dev, ledClassDev, &init_data))
|
||||||
&init_data) != 0) {
|
|
||||||
pr_info("Error during call of devm_led_classdev_register_ext");
|
pr_info("Error during call of devm_led_classdev_register_ext");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == 0) {
|
|
||||||
/*
|
/*
|
||||||
Send full initialization sequence.
|
Send full initialization sequence.
|
||||||
Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values.
|
Afterwards only GCA230718_2ND_SEQUENCE_BYTE_1 must be send to upddate the brightness values.
|
||||||
@ -185,9 +177,8 @@ static int gca230718_probe(struct i2c_client *client)
|
|||||||
gca230718_privateData);
|
gca230718_privateData);
|
||||||
gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1,
|
gca230718_send_sequence(client, GCA230718_3RD_SEQUENCE_BYTE_1,
|
||||||
gca230718_privateData);
|
gca230718_privateData);
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gca230718_remove(struct i2c_client *client)
|
static void gca230718_remove(struct i2c_client *client)
|
||||||
|
Loading…
Reference in New Issue
Block a user