mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
platform/chrome: cros_kbd_led_backlight: Pass keyboard_led as parameter
Make the code simpler to read by passing the 'struct keyboard_led' as a parameter to the 'init' callbacks instead of relying on the platform device driver data. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20260404-cros_kbd_led-cleanup-v1-2-0dc1100d54e3@weissschuh.net Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
This commit is contained in:
parent
d68c290819
commit
8cf72e3f61
|
|
@ -36,7 +36,7 @@ struct keyboard_led {
|
|||
* See struct led_classdev in include/linux/leds.h for more details.
|
||||
*/
|
||||
struct keyboard_led_drvdata {
|
||||
int (*init)(struct platform_device *pdev);
|
||||
int (*init)(struct platform_device *pdev, struct keyboard_led *keyboard_led);
|
||||
|
||||
enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
|
||||
|
||||
|
|
@ -89,7 +89,8 @@ keyboard_led_get_brightness_acpi(struct led_classdev *cdev)
|
|||
return brightness;
|
||||
}
|
||||
|
||||
static int keyboard_led_init_acpi(struct platform_device *pdev)
|
||||
static int keyboard_led_init_acpi(struct platform_device *pdev,
|
||||
struct keyboard_led *keyboard_led)
|
||||
{
|
||||
acpi_handle handle;
|
||||
acpi_status status;
|
||||
|
|
@ -116,11 +117,11 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
|
|||
#endif /* CONFIG_ACPI */
|
||||
|
||||
#if IS_ENABLED(CONFIG_MFD_CROS_EC_DEV)
|
||||
static int keyboard_led_init_ec_pwm_mfd(struct platform_device *pdev)
|
||||
static int keyboard_led_init_ec_pwm_mfd(struct platform_device *pdev,
|
||||
struct keyboard_led *keyboard_led)
|
||||
{
|
||||
struct cros_ec_dev *ec_dev = dev_get_drvdata(pdev->dev.parent);
|
||||
struct cros_ec_device *cros_ec = ec_dev->ec_dev;
|
||||
struct keyboard_led *keyboard_led = platform_get_drvdata(pdev);
|
||||
|
||||
keyboard_led->ec = cros_ec;
|
||||
|
||||
|
|
@ -198,10 +199,9 @@ static int keyboard_led_probe(struct platform_device *pdev)
|
|||
keyboard_led = devm_kzalloc(&pdev->dev, sizeof(*keyboard_led), GFP_KERNEL);
|
||||
if (!keyboard_led)
|
||||
return -ENOMEM;
|
||||
platform_set_drvdata(pdev, keyboard_led);
|
||||
|
||||
if (drvdata->init) {
|
||||
err = drvdata->init(pdev);
|
||||
err = drvdata->init(pdev, keyboard_led);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user