mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 14:14:24 +08:00
6061302092
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() is renamed to .remove(). All platform drivers below drivers/leds/ unconditionally return zero in their remove callback and so can be converted trivially to the variant returning void. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230917130947.1122198-1-u.kleine-koenig@pengutronix.de Signed-off-by: Lee Jones <lee@kernel.org>
64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* LEDs driver for the "User LED" on Routerboard532
|
|
*
|
|
* Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org>
|
|
*
|
|
* Based on leds-cobalt-qube.c by Florian Fainelly and
|
|
* rb-diag.c (my own standalone driver for both LED and
|
|
* button of Routerboard532).
|
|
*/
|
|
|
|
#include <linux/leds.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <asm/mach-rc32434/gpio.h>
|
|
#include <asm/mach-rc32434/rb.h>
|
|
|
|
static void rb532_led_set(struct led_classdev *cdev,
|
|
enum led_brightness brightness)
|
|
{
|
|
if (brightness)
|
|
set_latch_u5(LO_ULED, 0);
|
|
else
|
|
set_latch_u5(0, LO_ULED);
|
|
}
|
|
|
|
static enum led_brightness rb532_led_get(struct led_classdev *cdev)
|
|
{
|
|
return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF;
|
|
}
|
|
|
|
static struct led_classdev rb532_uled = {
|
|
.name = "uled",
|
|
.brightness_set = rb532_led_set,
|
|
.brightness_get = rb532_led_get,
|
|
.default_trigger = "nand-disk",
|
|
};
|
|
|
|
static int rb532_led_probe(struct platform_device *pdev)
|
|
{
|
|
return led_classdev_register(&pdev->dev, &rb532_uled);
|
|
}
|
|
|
|
static void rb532_led_remove(struct platform_device *pdev)
|
|
{
|
|
led_classdev_unregister(&rb532_uled);
|
|
}
|
|
|
|
static struct platform_driver rb532_led_driver = {
|
|
.probe = rb532_led_probe,
|
|
.remove_new = rb532_led_remove,
|
|
.driver = {
|
|
.name = "rb532-led",
|
|
},
|
|
};
|
|
|
|
module_platform_driver(rb532_led_driver);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_DESCRIPTION("User LED support for Routerboard532");
|
|
MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");
|
|
MODULE_ALIAS("platform:rb532-led");
|