aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/hid-roccat-kone.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index 7847a5bb88fb..c931d00c70b9 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -37,6 +37,12 @@
37 37
38static uint profile_numbers[5] = {0, 1, 2, 3, 4}; 38static uint profile_numbers[5] = {0, 1, 2, 3, 4};
39 39
40static void kone_profile_activated(struct kone_device *kone, uint new_profile)
41{
42 kone->actual_profile = new_profile;
43 kone->actual_dpi = kone->profiles[new_profile - 1].startup_dpi;
44}
45
40static int kone_receive(struct usb_device *usb_dev, uint usb_command, 46static int kone_receive(struct usb_device *usb_dev, uint usb_command,
41 void *data, uint size) 47 void *data, uint size)
42{ 48{
@@ -294,21 +300,16 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
294 if (difference) { 300 if (difference) {
295 retval = kone_set_settings(usb_dev, 301 retval = kone_set_settings(usb_dev,
296 (struct kone_settings const *)buf); 302 (struct kone_settings const *)buf);
297 if (!retval) 303 if (retval) {
298 memcpy(&kone->settings, buf, 304 mutex_unlock(&kone->kone_lock);
299 sizeof(struct kone_settings)); 305 return retval;
300 } 306 }
301 mutex_unlock(&kone->kone_lock);
302 307
303 if (retval) 308 memcpy(&kone->settings, buf, sizeof(struct kone_settings));
304 return retval;
305 309
306 /* 310 kone_profile_activated(kone, kone->settings.startup_profile);
307 * If we get here, treat settings as okay and update actual values 311 }
308 * according to startup_profile 312 mutex_unlock(&kone->kone_lock);
309 */
310 kone->actual_profile = kone->settings.startup_profile;
311 kone->actual_dpi = kone->profiles[kone->actual_profile - 1].startup_dpi;
312 313
313 return sizeof(struct kone_settings); 314 return sizeof(struct kone_settings);
314} 315}
@@ -501,6 +502,8 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev,
501 goto exit_no_settings; 502 goto exit_no_settings;
502 goto exit_unlock; 503 goto exit_unlock;
503 } 504 }
505 /* calibration resets profile */
506 kone_profile_activated(kone, kone->settings.startup_profile);
504 } 507 }
505 508
506 retval = size; 509 retval = size;
@@ -544,16 +547,15 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
544 kone_set_settings_checksum(&kone->settings); 547 kone_set_settings_checksum(&kone->settings);
545 548
546 retval = kone_set_settings(usb_dev, &kone->settings); 549 retval = kone_set_settings(usb_dev, &kone->settings);
547 550 if (retval) {
548 mutex_unlock(&kone->kone_lock); 551 mutex_unlock(&kone->kone_lock);
549
550 if (retval)
551 return retval; 552 return retval;
553 }
552 554
553 /* changing the startup profile immediately activates this profile */ 555 /* changing the startup profile immediately activates this profile */
554 kone->actual_profile = new_startup_profile; 556 kone_profile_activated(kone, new_startup_profile);
555 kone->actual_dpi = kone->profiles[kone->actual_profile - 1].startup_dpi;
556 557
558 mutex_unlock(&kone->kone_lock);
557 return size; 559 return size;
558} 560}
559 561
@@ -665,8 +667,7 @@ static int kone_init_kone_device_struct(struct usb_device *usb_dev,
665 if (retval) 667 if (retval)
666 return retval; 668 return retval;
667 669
668 kone->actual_profile = kone->settings.startup_profile; 670 kone_profile_activated(kone, kone->settings.startup_profile);
669 kone->actual_dpi = kone->profiles[kone->actual_profile].startup_dpi;
670 671
671 return 0; 672 return 0;
672} 673}