Skip to content

Commit

Permalink
Clean up source code for 4.18+
Browse files Browse the repository at this point in the history
Remove code specific to kernels older than 4.18.

Signed-off-by: Ping Cheng <[email protected]>
  • Loading branch information
Ping Cheng committed Jul 3, 2024
1 parent 3fdbd53 commit ce3eb87
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 79 deletions.
6 changes: 0 additions & 6 deletions 4.18/wacom.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ struct wacom_remote {
struct input_dev *input;
bool registered;
struct wacom_battery battery;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
ktime_t active_time;
#endif
} remotes[WACOM_MAX_REMOTES];
};

Expand Down Expand Up @@ -258,9 +256,5 @@ struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group,
struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur);
int wacom_equivalent_usage(int usage);
int wacom_initialize_leds(struct wacom *wacom);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
void wacom_idleprox_timeout(struct timer_list *list);
#else
void wacom_idleprox_timeout(unsigned long data);
#endif
#endif
58 changes: 1 addition & 57 deletions 4.18/wacom_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,6 @@
#define wacom_is_using_usb_driver(hdev) hid_is_usb(hdev)
#elif defined WACOM_USING_LL_DRIVER
#define wacom_is_using_usb_driver(hdev) hid_is_using_ll_driver(hdev, &usb_hid_driver)
#else
static int __wacom_is_usb_parent(struct usb_device *usbdev, void *ptr)
{
struct hid_device *hdev = ptr;
struct device *parent = hdev->dev.parent;
struct usb_host_config *config = usbdev->actconfig;
int i;

for (i = 0; config && i < config->desc.bNumInterfaces; i++) {
if (&config->interface[i]->dev == parent)
return 1;
}
return 0;
}

static bool wacom_is_using_usb_driver(struct hid_device *hdev)
{
return hdev->bus == BUS_USB &&
usb_for_each_dev(hdev, __wacom_is_usb_parent);
}
#endif

#ifndef WACOM_DEVM_OR_RESET
static int devm_add_action_or_reset(struct device *dev,
void (*action)(void *), void *data)
{
int ret;

ret = devm_add_action(dev, action, data);
if (ret)
action(data);

return ret;
}
#endif

static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
Expand Down Expand Up @@ -1444,9 +1410,7 @@ static int wacom_led_register_one(struct device *dev, struct wacom *wacom,
led->hlv = wacom->led.hlv;
led->cdev.name = name;
led->cdev.max_brightness = LED_FULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
led->cdev.flags = LED_HW_PLUGGABLE;
#endif
led->cdev.brightness_get = __wacom_led_brightness_get;
if (!read_only) {
led->cdev.brightness_set_blocking = wacom_led_brightness_set;
Expand Down Expand Up @@ -2615,7 +2579,6 @@ static void wacom_wireless_work(struct work_struct *work)
return;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
static void wacom_remote_destroy_battery(struct wacom *wacom, int index)
{
struct wacom_remote *remote = wacom->remote;
Expand All @@ -2627,7 +2590,6 @@ static void wacom_remote_destroy_battery(struct wacom *wacom, int index)
remote->remotes[index].active_time = 0;
}
}
#endif

static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
{
Expand All @@ -2643,23 +2605,15 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
remote->remotes[i].registered = false;
spin_unlock_irqrestore(&remote->remote_lock, flags);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
wacom_remote_destroy_battery(wacom, i);
#else
if (remote->remotes[i].battery.battery)
devres_release_group(&wacom->hdev->dev,
&remote->remotes[i].battery.bat_desc);
#endif

if (remote->remotes[i].group.name)
devres_release_group(&wacom->hdev->dev,
&remote->remotes[i]);

remote->remotes[i].serial = 0;
remote->remotes[i].group.name = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
remote->remotes[i].battery.battery = NULL;
#endif

wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
}
}
Expand Down Expand Up @@ -2744,10 +2698,8 @@ static int wacom_remote_attach_battery(struct wacom *wacom, int index)
if (remote->remotes[index].battery.battery)
return 0;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
if (!remote->remotes[index].active_time)
return 0;
#endif

if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN)
return 0;
Expand All @@ -2764,9 +2716,7 @@ static void wacom_remote_work(struct work_struct *work)
{
struct wacom *wacom = container_of(work, struct wacom, remote_work);
struct wacom_remote *remote = wacom->remote;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
ktime_t kt = ktime_get();
#endif
struct wacom_remote_work_data remote_work_data;
unsigned long flags;
unsigned int count;
Expand Down Expand Up @@ -2794,11 +2744,9 @@ static void wacom_remote_work(struct work_struct *work)
work_serial = remote_work_data.remote[i].serial;
if (work_serial) {

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
if (kt - remote->remotes[i].active_time > WACOM_REMOTE_BATTERY_TIMEOUT
&& remote->remotes[i].active_time != 0)
wacom_remote_destroy_battery(wacom, i);
#endif

if (remote->remotes[i].serial == work_serial) {
wacom_remote_attach_battery(wacom, i);
Expand Down Expand Up @@ -2908,11 +2856,7 @@ static int wacom_probe(struct hid_device *hdev,
INIT_WORK(&wacom->battery_work, wacom_battery_work);
INIT_WORK(&wacom->remote_work, wacom_remote_work);
INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE);
#else
setup_timer(&wacom->idleprox_timer, &wacom_idleprox_timeout, (unsigned long) wacom);
#endif

/* ask for the report descriptor to be loaded by HID */
error = hid_parse(hdev);
Expand Down
18 changes: 2 additions & 16 deletions 4.18/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@ static void wacom_force_proxout(struct wacom_wac *wacom_wac)
input_sync(input);
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
void wacom_idleprox_timeout(struct timer_list *list)
{
struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
#else
void wacom_idleprox_timeout(unsigned long data)
{
struct wacom *wacom = (struct wacom *)data;
#endif
struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
struct wacom_wac *wacom_wac = &wacom->wacom_wac;

if (!wacom_wac->hid_data.sense_state) {
Expand Down Expand Up @@ -1144,9 +1138,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
if (index < 0 || !remote->remotes[index].registered)
goto out;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
remote->remotes[i].active_time = ktime_get();
#endif
input = remote->remotes[index].input;

input_report_key(input, BTN_0, (data[9] & 0x01));
Expand Down Expand Up @@ -1948,14 +1940,8 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
int resolution_code = code;
int resolution = hidinput_calc_abs_res(field, resolution_code);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
if (equivalent_usage == HID_DG_TWIST) {
#else
if (equivalent_usage == HID_DG_TWIST ||
equivalent_usage == WACOM_HID_WD_TOUCHRING) {
#endif
if (equivalent_usage == HID_DG_TWIST)
resolution_code = ABS_RZ;
}

if (equivalent_usage == HID_GD_X) {
fmin += features->offset_left;
Expand Down

0 comments on commit ce3eb87

Please sign in to comment.