.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for IMS Passenger Control Unit Devices |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/completion.h> |
---|
.. | .. |
---|
39 | 36 | |
---|
40 | 37 | struct ims_pcu_backlight { |
---|
41 | 38 | struct led_classdev cdev; |
---|
42 | | - struct work_struct work; |
---|
43 | | - enum led_brightness desired_brightness; |
---|
44 | 39 | char name[32]; |
---|
45 | 40 | }; |
---|
46 | 41 | |
---|
.. | .. |
---|
340 | 335 | err_free_mem: |
---|
341 | 336 | input_free_device(input); |
---|
342 | 337 | kfree(gamepad); |
---|
343 | | - return -ENOMEM; |
---|
| 338 | + return error; |
---|
344 | 339 | } |
---|
345 | 340 | |
---|
346 | 341 | static void ims_pcu_destroy_gamepad(struct ims_pcu *pcu) |
---|
.. | .. |
---|
949 | 944 | |
---|
950 | 945 | #define IMS_PCU_MAX_BRIGHTNESS 31998 |
---|
951 | 946 | |
---|
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) |
---|
953 | 949 | { |
---|
954 | 950 | struct ims_pcu_backlight *backlight = |
---|
955 | | - container_of(work, struct ims_pcu_backlight, work); |
---|
| 951 | + container_of(cdev, struct ims_pcu_backlight, cdev); |
---|
956 | 952 | struct ims_pcu *pcu = |
---|
957 | 953 | 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); |
---|
960 | 955 | int error; |
---|
961 | 956 | |
---|
962 | 957 | mutex_lock(&pcu->cmd_mutex); |
---|
.. | .. |
---|
966 | 961 | if (error && error != -ENODEV) |
---|
967 | 962 | dev_warn(pcu->dev, |
---|
968 | 963 | "Failed to set desired brightness %u, error: %d\n", |
---|
969 | | - desired_brightness, error); |
---|
| 964 | + value, error); |
---|
970 | 965 | |
---|
971 | 966 | mutex_unlock(&pcu->cmd_mutex); |
---|
972 | | -} |
---|
973 | 967 | |
---|
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; |
---|
982 | 969 | } |
---|
983 | 970 | |
---|
984 | 971 | static enum led_brightness |
---|
.. | .. |
---|
1015 | 1002 | struct ims_pcu_backlight *backlight = &pcu->backlight; |
---|
1016 | 1003 | int error; |
---|
1017 | 1004 | |
---|
1018 | | - INIT_WORK(&backlight->work, ims_pcu_backlight_work); |
---|
1019 | 1005 | snprintf(backlight->name, sizeof(backlight->name), |
---|
1020 | 1006 | "pcu%d::kbd_backlight", pcu->device_no); |
---|
1021 | 1007 | |
---|
1022 | 1008 | backlight->cdev.name = backlight->name; |
---|
1023 | 1009 | backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; |
---|
1024 | 1010 | 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; |
---|
1026 | 1013 | |
---|
1027 | 1014 | error = led_classdev_register(pcu->dev, &backlight->cdev); |
---|
1028 | 1015 | if (error) { |
---|
.. | .. |
---|
1040 | 1027 | struct ims_pcu_backlight *backlight = &pcu->backlight; |
---|
1041 | 1028 | |
---|
1042 | 1029 | led_classdev_unregister(&backlight->cdev); |
---|
1043 | | - cancel_work_sync(&backlight->work); |
---|
1044 | 1030 | } |
---|
1045 | 1031 | |
---|
1046 | 1032 | |
---|