Skip to content

Commit

Permalink
platform/x86: fujitsu-laptop: Simplify error paths
Browse files Browse the repository at this point in the history
Replace the last few lines of acpi_fujitsu_bl_add() with a simple return
in order to improve code readability without changing the logic.

As acpi_fujitsu_laptop_add() uses a managed memory allocation for
device-specific data, it is fine to just return immediately upon kfifo
allocation failure.  Do that instead of jumping to the end of the
function to improve code readability.  Running out of memory while
allocating the kfifo does not seem probable enough to warrant logging an
error message, so do not do it.

Signed-off-by: Michał Kępień <[email protected]>
Reviewed-by: Jonathan Woithe <[email protected]>
Signed-off-by: Darren Hart (VMware) <[email protected]>
  • Loading branch information
kempniu authored and dvhart committed Feb 24, 2018
1 parent a7a1ccb commit 7f83d41
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/platform/x86/fujitsu-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,7 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device)
if (ret)
return ret;

ret = fujitsu_backlight_register(device);
if (ret)
return ret;

return 0;
return fujitsu_backlight_register(device);
}

/* Brightness notify */
Expand Down Expand Up @@ -790,10 +786,8 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
spin_lock_init(&priv->fifo_lock);
ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
GFP_KERNEL);
if (ret) {
pr_err("kfifo_alloc failed\n");
goto err_stop;
}
if (ret)
return ret;

pr_info("ACPI: %s [%s]\n",
acpi_device_name(device), acpi_device_bid(device));
Expand Down Expand Up @@ -845,7 +839,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)

err_free_fifo:
kfifo_free(&priv->fifo);
err_stop:

return ret;
}

Expand Down

0 comments on commit 7f83d41

Please sign in to comment.