diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-02-05 17:21:45 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-02-17 00:39:42 -0500 |
| commit | 6b65189a2d09e0821c80581455b748c23c9342e9 (patch) | |
| tree | adfe9e3c35a1d547d5d277ab755d4813617b15f4 /drivers/input | |
| parent | e3dd12f0eacc52ddf5cd4e6651e09daebcb25f0e (diff) | |
Input: ims-pcu - switch to using brightness_set_blocking()
Now that LEDs core allows "blocking" flavor of "set brightness" method we
can use it and get rid of private work item.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/misc/ims-pcu.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 3d51175c4d72..74cf3b612f05 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c | |||
| @@ -39,8 +39,6 @@ struct ims_pcu_gamepad { | |||
| 39 | 39 | ||
| 40 | struct ims_pcu_backlight { | 40 | struct ims_pcu_backlight { |
| 41 | struct led_classdev cdev; | 41 | struct led_classdev cdev; |
| 42 | struct work_struct work; | ||
| 43 | enum led_brightness desired_brightness; | ||
| 44 | char name[32]; | 42 | char name[32]; |
| 45 | }; | 43 | }; |
| 46 | 44 | ||
| @@ -949,14 +947,14 @@ out: | |||
| 949 | 947 | ||
| 950 | #define IMS_PCU_MAX_BRIGHTNESS 31998 | 948 | #define IMS_PCU_MAX_BRIGHTNESS 31998 |
| 951 | 949 | ||
| 952 | static void ims_pcu_backlight_work(struct work_struct *work) | 950 | static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev, |
| 951 | enum led_brightness value) | ||
| 953 | { | 952 | { |
| 954 | struct ims_pcu_backlight *backlight = | 953 | struct ims_pcu_backlight *backlight = |
| 955 | container_of(work, struct ims_pcu_backlight, work); | 954 | container_of(cdev, struct ims_pcu_backlight, cdev); |
| 956 | struct ims_pcu *pcu = | 955 | struct ims_pcu *pcu = |
| 957 | container_of(backlight, struct ims_pcu, backlight); | 956 | container_of(backlight, struct ims_pcu, backlight); |
| 958 | int desired_brightness = backlight->desired_brightness; | 957 | __le16 br_val = cpu_to_le16(value); |
| 959 | __le16 br_val = cpu_to_le16(desired_brightness); | ||
| 960 | int error; | 958 | int error; |
| 961 | 959 | ||
| 962 | mutex_lock(&pcu->cmd_mutex); | 960 | mutex_lock(&pcu->cmd_mutex); |
| @@ -966,19 +964,11 @@ static void ims_pcu_backlight_work(struct work_struct *work) | |||
| 966 | if (error && error != -ENODEV) | 964 | if (error && error != -ENODEV) |
| 967 | dev_warn(pcu->dev, | 965 | dev_warn(pcu->dev, |
| 968 | "Failed to set desired brightness %u, error: %d\n", | 966 | "Failed to set desired brightness %u, error: %d\n", |
| 969 | desired_brightness, error); | 967 | value, error); |
| 970 | 968 | ||
| 971 | mutex_unlock(&pcu->cmd_mutex); | 969 | mutex_unlock(&pcu->cmd_mutex); |
| 972 | } | ||
| 973 | 970 | ||
| 974 | static void ims_pcu_backlight_set_brightness(struct led_classdev *cdev, | 971 | return error; |
| 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); | ||
| 982 | } | 972 | } |
| 983 | 973 | ||
| 984 | static enum led_brightness | 974 | static enum led_brightness |
| @@ -1015,14 +1005,14 @@ static int ims_pcu_setup_backlight(struct ims_pcu *pcu) | |||
| 1015 | struct ims_pcu_backlight *backlight = &pcu->backlight; | 1005 | struct ims_pcu_backlight *backlight = &pcu->backlight; |
| 1016 | int error; | 1006 | int error; |
| 1017 | 1007 | ||
| 1018 | INIT_WORK(&backlight->work, ims_pcu_backlight_work); | ||
| 1019 | snprintf(backlight->name, sizeof(backlight->name), | 1008 | snprintf(backlight->name, sizeof(backlight->name), |
| 1020 | "pcu%d::kbd_backlight", pcu->device_no); | 1009 | "pcu%d::kbd_backlight", pcu->device_no); |
| 1021 | 1010 | ||
| 1022 | backlight->cdev.name = backlight->name; | 1011 | backlight->cdev.name = backlight->name; |
| 1023 | backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; | 1012 | backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; |
| 1024 | backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness; | 1013 | backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness; |
| 1025 | backlight->cdev.brightness_set = ims_pcu_backlight_set_brightness; | 1014 | backlight->cdev.brightness_set_blocking = |
| 1015 | ims_pcu_backlight_set_brightness; | ||
| 1026 | 1016 | ||
| 1027 | error = led_classdev_register(pcu->dev, &backlight->cdev); | 1017 | error = led_classdev_register(pcu->dev, &backlight->cdev); |
| 1028 | if (error) { | 1018 | if (error) { |
| @@ -1040,7 +1030,6 @@ static void ims_pcu_destroy_backlight(struct ims_pcu *pcu) | |||
| 1040 | struct ims_pcu_backlight *backlight = &pcu->backlight; | 1030 | struct ims_pcu_backlight *backlight = &pcu->backlight; |
| 1041 | 1031 | ||
| 1042 | led_classdev_unregister(&backlight->cdev); | 1032 | led_classdev_unregister(&backlight->cdev); |
| 1043 | cancel_work_sync(&backlight->work); | ||
| 1044 | } | 1033 | } |
| 1045 | 1034 | ||
| 1046 | 1035 | ||
