hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/input/misc/ims-pcu.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for IMS Passenger Control Unit Devices
34 *
45 * Copyright (C) 2013 The IMS Company
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2
8
- * as published by the Free Software Foundation.
96 */
107
118 #include <linux/completion.h>
....@@ -39,8 +36,6 @@
3936
4037 struct ims_pcu_backlight {
4138 struct led_classdev cdev;
42
- struct work_struct work;
43
- enum led_brightness desired_brightness;
4439 char name[32];
4540 };
4641
....@@ -340,7 +335,7 @@
340335 err_free_mem:
341336 input_free_device(input);
342337 kfree(gamepad);
343
- return -ENOMEM;
338
+ return error;
344339 }
345340
346341 static void ims_pcu_destroy_gamepad(struct ims_pcu *pcu)
....@@ -949,14 +944,14 @@
949944
950945 #define IMS_PCU_MAX_BRIGHTNESS 31998
951946
952
-static void ims_pcu_backlight_work(struct work_struct *work)
947
+static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev,
948
+ enum led_brightness value)
953949 {
954950 struct ims_pcu_backlight *backlight =
955
- container_of(work, struct ims_pcu_backlight, work);
951
+ container_of(cdev, struct ims_pcu_backlight, cdev);
956952 struct ims_pcu *pcu =
957953 container_of(backlight, struct ims_pcu, backlight);
958
- int desired_brightness = backlight->desired_brightness;
959
- __le16 br_val = cpu_to_le16(desired_brightness);
954
+ __le16 br_val = cpu_to_le16(value);
960955 int error;
961956
962957 mutex_lock(&pcu->cmd_mutex);
....@@ -966,19 +961,11 @@
966961 if (error && error != -ENODEV)
967962 dev_warn(pcu->dev,
968963 "Failed to set desired brightness %u, error: %d\n",
969
- desired_brightness, error);
964
+ value, error);
970965
971966 mutex_unlock(&pcu->cmd_mutex);
972
-}
973967
974
-static void ims_pcu_backlight_set_brightness(struct led_classdev *cdev,
975
- enum led_brightness value)
976
-{
977
- struct ims_pcu_backlight *backlight =
978
- container_of(cdev, struct ims_pcu_backlight, cdev);
979
-
980
- backlight->desired_brightness = value;
981
- schedule_work(&backlight->work);
968
+ return error;
982969 }
983970
984971 static enum led_brightness
....@@ -1015,14 +1002,14 @@
10151002 struct ims_pcu_backlight *backlight = &pcu->backlight;
10161003 int error;
10171004
1018
- INIT_WORK(&backlight->work, ims_pcu_backlight_work);
10191005 snprintf(backlight->name, sizeof(backlight->name),
10201006 "pcu%d::kbd_backlight", pcu->device_no);
10211007
10221008 backlight->cdev.name = backlight->name;
10231009 backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS;
10241010 backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness;
1025
- backlight->cdev.brightness_set = ims_pcu_backlight_set_brightness;
1011
+ backlight->cdev.brightness_set_blocking =
1012
+ ims_pcu_backlight_set_brightness;
10261013
10271014 error = led_classdev_register(pcu->dev, &backlight->cdev);
10281015 if (error) {
....@@ -1040,7 +1027,6 @@
10401027 struct ims_pcu_backlight *backlight = &pcu->backlight;
10411028
10421029 led_classdev_unregister(&backlight->cdev);
1043
- cancel_work_sync(&backlight->work);
10441030 }
10451031
10461032