mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 18:14:07 +08:00
platform/x86: fujitsu-laptop: Simplify error paths
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ń <kernel@kempniu.pl> Reviewed-by: Jonathan Woithe <jwoithe@just42.net> Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
This commit is contained in:
parent
a7a1ccbee3
commit
7f83d41044
@ -410,11 +410,7 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = fujitsu_backlight_register(device);
|
return fujitsu_backlight_register(device);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Brightness notify */
|
/* Brightness notify */
|
||||||
@ -790,10 +786,8 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
|
|||||||
spin_lock_init(&priv->fifo_lock);
|
spin_lock_init(&priv->fifo_lock);
|
||||||
ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
|
ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (ret) {
|
if (ret)
|
||||||
pr_err("kfifo_alloc failed\n");
|
return ret;
|
||||||
goto err_stop;
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("ACPI: %s [%s]\n",
|
pr_info("ACPI: %s [%s]\n",
|
||||||
acpi_device_name(device), acpi_device_bid(device));
|
acpi_device_name(device), acpi_device_bid(device));
|
||||||
@ -845,7 +839,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
|
|||||||
|
|
||||||
err_free_fifo:
|
err_free_fifo:
|
||||||
kfifo_free(&priv->fifo);
|
kfifo_free(&priv->fifo);
|
||||||
err_stop:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user