diff options
author | Joe Perches <joe@perches.com> | 2010-12-09 22:29:03 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-12-10 09:10:38 -0500 |
commit | 4291ee305e9bb0699504a66f0e2b7aefcf0512a5 (patch) | |
tree | 3996b77eb64d4f3b76a0799f30a5b2ba6cbc9ddb /drivers/hid/usbhid/hid-pidff.c | |
parent | 5bea7660bba973dc5e8e9d92b11fb1dd5b524ebf (diff) |
HID: Add and use hid_<level>: dev_<level> equivalents
Neaten current uses of dev_<level> by adding and using
hid specific hid_<level> macros.
Convert existing uses of dev_<level> uses to hid_<level>.
Convert hid-pidff printk uses to hid_<level>.
Remove err_hid and use hid_err instead.
Add missing newlines to logging messages where necessary.
Coalesce format strings.
Add and use pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Other miscellaneous changes:
Add const struct hid_device * argument to hid-core functions
extract() and implement() so hid_<level> can be used by them.
Fix bad indentation in hid-core hid_input_field function
that calls extract() function above.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid/hid-pidff.c')
-rw-r--r-- | drivers/hid/usbhid/hid-pidff.c | 164 |
1 files changed, 77 insertions, 87 deletions
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index ef381d79cfa8..f91c136821f7 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | /* #define DEBUG */ | 23 | /* #define DEBUG */ |
24 | 24 | ||
25 | #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) | 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
26 | 26 | ||
27 | #include <linux/input.h> | 27 | #include <linux/input.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -220,7 +220,7 @@ static int pidff_rescale_signed(int i, struct hid_field *field) | |||
220 | static void pidff_set(struct pidff_usage *usage, u16 value) | 220 | static void pidff_set(struct pidff_usage *usage, u16 value) |
221 | { | 221 | { |
222 | usage->value[0] = pidff_rescale(value, 0xffff, usage->field); | 222 | usage->value[0] = pidff_rescale(value, 0xffff, usage->field); |
223 | debug("calculated from %d to %d", value, usage->value[0]); | 223 | pr_debug("calculated from %d to %d\n", value, usage->value[0]); |
224 | } | 224 | } |
225 | 225 | ||
226 | static void pidff_set_signed(struct pidff_usage *usage, s16 value) | 226 | static void pidff_set_signed(struct pidff_usage *usage, s16 value) |
@@ -235,7 +235,7 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value) | |||
235 | usage->value[0] = | 235 | usage->value[0] = |
236 | pidff_rescale(value, 0x7fff, usage->field); | 236 | pidff_rescale(value, 0x7fff, usage->field); |
237 | } | 237 | } |
238 | debug("calculated from %d to %d", value, usage->value[0]); | 238 | pr_debug("calculated from %d to %d\n", value, usage->value[0]); |
239 | } | 239 | } |
240 | 240 | ||
241 | /* | 241 | /* |
@@ -259,8 +259,9 @@ static void pidff_set_envelope_report(struct pidff_device *pidff, | |||
259 | pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length; | 259 | pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length; |
260 | pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length; | 260 | pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length; |
261 | 261 | ||
262 | debug("attack %u => %d", envelope->attack_level, | 262 | hid_dbg(pidff->hid, "attack %u => %d\n", |
263 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); | 263 | envelope->attack_level, |
264 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); | ||
264 | 265 | ||
265 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], | 266 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], |
266 | USB_DIR_OUT); | 267 | USB_DIR_OUT); |
@@ -466,33 +467,33 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum) | |||
466 | pidff->create_new_effect_type->value[0] = efnum; | 467 | pidff->create_new_effect_type->value[0] = efnum; |
467 | usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], | 468 | usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], |
468 | USB_DIR_OUT); | 469 | USB_DIR_OUT); |
469 | debug("create_new_effect sent, type: %d", efnum); | 470 | hid_dbg(pidff->hid, "create_new_effect sent, type: %d\n", efnum); |
470 | 471 | ||
471 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; | 472 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; |
472 | pidff->block_load_status->value[0] = 0; | 473 | pidff->block_load_status->value[0] = 0; |
473 | usbhid_wait_io(pidff->hid); | 474 | usbhid_wait_io(pidff->hid); |
474 | 475 | ||
475 | for (j = 0; j < 60; j++) { | 476 | for (j = 0; j < 60; j++) { |
476 | debug("pid_block_load requested"); | 477 | hid_dbg(pidff->hid, "pid_block_load requested\n"); |
477 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], | 478 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], |
478 | USB_DIR_IN); | 479 | USB_DIR_IN); |
479 | usbhid_wait_io(pidff->hid); | 480 | usbhid_wait_io(pidff->hid); |
480 | if (pidff->block_load_status->value[0] == | 481 | if (pidff->block_load_status->value[0] == |
481 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { | 482 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { |
482 | debug("device reported free memory: %d bytes", | 483 | hid_dbg(pidff->hid, "device reported free memory: %d bytes\n", |
483 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? | 484 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? |
484 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); | 485 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); |
485 | return 0; | 486 | return 0; |
486 | } | 487 | } |
487 | if (pidff->block_load_status->value[0] == | 488 | if (pidff->block_load_status->value[0] == |
488 | pidff->status_id[PID_BLOCK_LOAD_FULL]) { | 489 | pidff->status_id[PID_BLOCK_LOAD_FULL]) { |
489 | debug("not enough memory free: %d bytes", | 490 | hid_dbg(pidff->hid, "not enough memory free: %d bytes\n", |
490 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? | 491 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? |
491 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); | 492 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); |
492 | return -ENOSPC; | 493 | return -ENOSPC; |
493 | } | 494 | } |
494 | } | 495 | } |
495 | printk(KERN_ERR "hid-pidff: pid_block_load failed 60 times\n"); | 496 | hid_err(pidff->hid, "pid_block_load failed 60 times\n"); |
496 | return -EIO; | 497 | return -EIO; |
497 | } | 498 | } |
498 | 499 | ||
@@ -546,7 +547,8 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id) | |||
546 | struct pidff_device *pidff = dev->ff->private; | 547 | struct pidff_device *pidff = dev->ff->private; |
547 | int pid_id = pidff->pid_id[effect_id]; | 548 | int pid_id = pidff->pid_id[effect_id]; |
548 | 549 | ||
549 | debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]); | 550 | hid_dbg(pidff->hid, "starting to erase %d/%d\n", |
551 | effect_id, pidff->pid_id[effect_id]); | ||
550 | /* Wait for the queue to clear. We do not want a full fifo to | 552 | /* Wait for the queue to clear. We do not want a full fifo to |
551 | prevent the effect removal. */ | 553 | prevent the effect removal. */ |
552 | usbhid_wait_io(pidff->hid); | 554 | usbhid_wait_io(pidff->hid); |
@@ -604,8 +606,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
604 | type_id = PID_SAW_DOWN; | 606 | type_id = PID_SAW_DOWN; |
605 | break; | 607 | break; |
606 | default: | 608 | default: |
607 | printk(KERN_ERR | 609 | hid_err(pidff->hid, "invalid waveform\n"); |
608 | "hid-pidff: invalid waveform\n"); | ||
609 | return -EINVAL; | 610 | return -EINVAL; |
610 | } | 611 | } |
611 | 612 | ||
@@ -696,7 +697,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
696 | break; | 697 | break; |
697 | 698 | ||
698 | default: | 699 | default: |
699 | printk(KERN_ERR "hid-pidff: invalid type\n"); | 700 | hid_err(pidff->hid, "invalid type\n"); |
700 | return -EINVAL; | 701 | return -EINVAL; |
701 | } | 702 | } |
702 | 703 | ||
@@ -704,7 +705,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
704 | pidff->pid_id[effect->id] = | 705 | pidff->pid_id[effect->id] = |
705 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; | 706 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; |
706 | 707 | ||
707 | debug("uploaded"); | 708 | hid_dbg(pidff->hid, "uploaded\n"); |
708 | 709 | ||
709 | return 0; | 710 | return 0; |
710 | } | 711 | } |
@@ -770,14 +771,14 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, | |||
770 | for (i = 0; i < report->maxfield; i++) { | 771 | for (i = 0; i < report->maxfield; i++) { |
771 | if (report->field[i]->maxusage != | 772 | if (report->field[i]->maxusage != |
772 | report->field[i]->report_count) { | 773 | report->field[i]->report_count) { |
773 | debug("maxusage and report_count do not match, " | 774 | pr_debug("maxusage and report_count do not match, skipping\n"); |
774 | "skipping"); | ||
775 | continue; | 775 | continue; |
776 | } | 776 | } |
777 | for (j = 0; j < report->field[i]->maxusage; j++) { | 777 | for (j = 0; j < report->field[i]->maxusage; j++) { |
778 | if (report->field[i]->usage[j].hid == | 778 | if (report->field[i]->usage[j].hid == |
779 | (HID_UP_PID | table[k])) { | 779 | (HID_UP_PID | table[k])) { |
780 | debug("found %d at %d->%d", k, i, j); | 780 | pr_debug("found %d at %d->%d\n", |
781 | k, i, j); | ||
781 | usage[k].field = report->field[i]; | 782 | usage[k].field = report->field[i]; |
782 | usage[k].value = | 783 | usage[k].value = |
783 | &report->field[i]->value[j]; | 784 | &report->field[i]->value[j]; |
@@ -789,7 +790,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, | |||
789 | break; | 790 | break; |
790 | } | 791 | } |
791 | if (!found && strict) { | 792 | if (!found && strict) { |
792 | debug("failed to locate %d", k); | 793 | pr_debug("failed to locate %d\n", k); |
793 | return -1; | 794 | return -1; |
794 | } | 795 | } |
795 | } | 796 | } |
@@ -826,8 +827,8 @@ static void pidff_find_reports(struct hid_device *hid, int report_type, | |||
826 | continue; | 827 | continue; |
827 | ret = pidff_check_usage(report->field[0]->logical); | 828 | ret = pidff_check_usage(report->field[0]->logical); |
828 | if (ret != -1) { | 829 | if (ret != -1) { |
829 | debug("found usage 0x%02x from field->logical", | 830 | hid_dbg(hid, "found usage 0x%02x from field->logical\n", |
830 | pidff_reports[ret]); | 831 | pidff_reports[ret]); |
831 | pidff->reports[ret] = report; | 832 | pidff->reports[ret] = report; |
832 | continue; | 833 | continue; |
833 | } | 834 | } |
@@ -845,8 +846,9 @@ static void pidff_find_reports(struct hid_device *hid, int report_type, | |||
845 | continue; | 846 | continue; |
846 | ret = pidff_check_usage(hid->collection[i - 1].usage); | 847 | ret = pidff_check_usage(hid->collection[i - 1].usage); |
847 | if (ret != -1 && !pidff->reports[ret]) { | 848 | if (ret != -1 && !pidff->reports[ret]) { |
848 | debug("found usage 0x%02x from collection array", | 849 | hid_dbg(hid, |
849 | pidff_reports[ret]); | 850 | "found usage 0x%02x from collection array\n", |
851 | pidff_reports[ret]); | ||
850 | pidff->reports[ret] = report; | 852 | pidff->reports[ret] = report; |
851 | } | 853 | } |
852 | } | 854 | } |
@@ -861,7 +863,7 @@ static int pidff_reports_ok(struct pidff_device *pidff) | |||
861 | 863 | ||
862 | for (i = 0; i <= PID_REQUIRED_REPORTS; i++) { | 864 | for (i = 0; i <= PID_REQUIRED_REPORTS; i++) { |
863 | if (!pidff->reports[i]) { | 865 | if (!pidff->reports[i]) { |
864 | debug("%d missing", i); | 866 | hid_dbg(pidff->hid, "%d missing\n", i); |
865 | return 0; | 867 | return 0; |
866 | } | 868 | } |
867 | } | 869 | } |
@@ -884,8 +886,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report, | |||
884 | report->field[i]->logical_minimum == 1) | 886 | report->field[i]->logical_minimum == 1) |
885 | return report->field[i]; | 887 | return report->field[i]; |
886 | else { | 888 | else { |
887 | printk(KERN_ERR "hid-pidff: logical_minimum " | 889 | pr_err("logical_minimum is not 1 as it should be\n"); |
888 | "is not 1 as it should be\n"); | ||
889 | return NULL; | 890 | return NULL; |
890 | } | 891 | } |
891 | } | 892 | } |
@@ -924,7 +925,7 @@ static int pidff_find_special_keys(int *keys, struct hid_field *fld, | |||
924 | */ | 925 | */ |
925 | static int pidff_find_special_fields(struct pidff_device *pidff) | 926 | static int pidff_find_special_fields(struct pidff_device *pidff) |
926 | { | 927 | { |
927 | debug("finding special fields"); | 928 | hid_dbg(pidff->hid, "finding special fields\n"); |
928 | 929 | ||
929 | pidff->create_new_effect_type = | 930 | pidff->create_new_effect_type = |
930 | pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT], | 931 | pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT], |
@@ -945,32 +946,30 @@ static int pidff_find_special_fields(struct pidff_device *pidff) | |||
945 | pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION], | 946 | pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION], |
946 | 0x78, 1); | 947 | 0x78, 1); |
947 | 948 | ||
948 | debug("search done"); | 949 | hid_dbg(pidff->hid, "search done\n"); |
949 | 950 | ||
950 | if (!pidff->create_new_effect_type || !pidff->set_effect_type) { | 951 | if (!pidff->create_new_effect_type || !pidff->set_effect_type) { |
951 | printk(KERN_ERR "hid-pidff: effect lists not found\n"); | 952 | hid_err(pidff->hid, "effect lists not found\n"); |
952 | return -1; | 953 | return -1; |
953 | } | 954 | } |
954 | 955 | ||
955 | if (!pidff->effect_direction) { | 956 | if (!pidff->effect_direction) { |
956 | printk(KERN_ERR "hid-pidff: direction field not found\n"); | 957 | hid_err(pidff->hid, "direction field not found\n"); |
957 | return -1; | 958 | return -1; |
958 | } | 959 | } |
959 | 960 | ||
960 | if (!pidff->device_control) { | 961 | if (!pidff->device_control) { |
961 | printk(KERN_ERR "hid-pidff: device control field not found\n"); | 962 | hid_err(pidff->hid, "device control field not found\n"); |
962 | return -1; | 963 | return -1; |
963 | } | 964 | } |
964 | 965 | ||
965 | if (!pidff->block_load_status) { | 966 | if (!pidff->block_load_status) { |
966 | printk(KERN_ERR | 967 | hid_err(pidff->hid, "block load status field not found\n"); |
967 | "hid-pidff: block load status field not found\n"); | ||
968 | return -1; | 968 | return -1; |
969 | } | 969 | } |
970 | 970 | ||
971 | if (!pidff->effect_operation_status) { | 971 | if (!pidff->effect_operation_status) { |
972 | printk(KERN_ERR | 972 | hid_err(pidff->hid, "effect operation field not found\n"); |
973 | "hid-pidff: effect operation field not found\n"); | ||
974 | return -1; | 973 | return -1; |
975 | } | 974 | } |
976 | 975 | ||
@@ -982,23 +981,22 @@ static int pidff_find_special_fields(struct pidff_device *pidff) | |||
982 | 981 | ||
983 | if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type, | 982 | if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type, |
984 | effect_types)) { | 983 | effect_types)) { |
985 | printk(KERN_ERR "hid-pidff: no effect types found\n"); | 984 | hid_err(pidff->hid, "no effect types found\n"); |
986 | return -1; | 985 | return -1; |
987 | } | 986 | } |
988 | 987 | ||
989 | if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status, | 988 | if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status, |
990 | block_load_status) != | 989 | block_load_status) != |
991 | sizeof(pidff_block_load_status)) { | 990 | sizeof(pidff_block_load_status)) { |
992 | printk(KERN_ERR | 991 | hid_err(pidff->hid, |
993 | "hidpidff: block load status identifiers not found\n"); | 992 | "block load status identifiers not found\n"); |
994 | return -1; | 993 | return -1; |
995 | } | 994 | } |
996 | 995 | ||
997 | if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status, | 996 | if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status, |
998 | effect_operation_status) != | 997 | effect_operation_status) != |
999 | sizeof(pidff_effect_operation_status)) { | 998 | sizeof(pidff_effect_operation_status)) { |
1000 | printk(KERN_ERR | 999 | hid_err(pidff->hid, "effect operation identifiers not found\n"); |
1001 | "hidpidff: effect operation identifiers not found\n"); | ||
1002 | return -1; | 1000 | return -1; |
1003 | } | 1001 | } |
1004 | 1002 | ||
@@ -1017,8 +1015,8 @@ static int pidff_find_effects(struct pidff_device *pidff, | |||
1017 | int pidff_type = pidff->type_id[i]; | 1015 | int pidff_type = pidff->type_id[i]; |
1018 | if (pidff->set_effect_type->usage[pidff_type].hid != | 1016 | if (pidff->set_effect_type->usage[pidff_type].hid != |
1019 | pidff->create_new_effect_type->usage[pidff_type].hid) { | 1017 | pidff->create_new_effect_type->usage[pidff_type].hid) { |
1020 | printk(KERN_ERR "hid-pidff: " | 1018 | hid_err(pidff->hid, |
1021 | "effect type number %d is invalid\n", i); | 1019 | "effect type number %d is invalid\n", i); |
1022 | return -1; | 1020 | return -1; |
1023 | } | 1021 | } |
1024 | } | 1022 | } |
@@ -1073,27 +1071,23 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1073 | int envelope_ok = 0; | 1071 | int envelope_ok = 0; |
1074 | 1072 | ||
1075 | if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) { | 1073 | if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) { |
1076 | printk(KERN_ERR | 1074 | hid_err(pidff->hid, "unknown set_effect report layout\n"); |
1077 | "hid-pidff: unknown set_effect report layout\n"); | ||
1078 | return -ENODEV; | 1075 | return -ENODEV; |
1079 | } | 1076 | } |
1080 | 1077 | ||
1081 | PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0); | 1078 | PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0); |
1082 | if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) { | 1079 | if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) { |
1083 | printk(KERN_ERR | 1080 | hid_err(pidff->hid, "unknown pid_block_load report layout\n"); |
1084 | "hid-pidff: unknown pid_block_load report layout\n"); | ||
1085 | return -ENODEV; | 1081 | return -ENODEV; |
1086 | } | 1082 | } |
1087 | 1083 | ||
1088 | if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) { | 1084 | if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) { |
1089 | printk(KERN_ERR | 1085 | hid_err(pidff->hid, "unknown effect_operation report layout\n"); |
1090 | "hid-pidff: unknown effect_operation report layout\n"); | ||
1091 | return -ENODEV; | 1086 | return -ENODEV; |
1092 | } | 1087 | } |
1093 | 1088 | ||
1094 | if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) { | 1089 | if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) { |
1095 | printk(KERN_ERR | 1090 | hid_err(pidff->hid, "unknown pid_block_free report layout\n"); |
1096 | "hid-pidff: unknown pid_block_free report layout\n"); | ||
1097 | return -ENODEV; | 1091 | return -ENODEV; |
1098 | } | 1092 | } |
1099 | 1093 | ||
@@ -1105,27 +1099,26 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1105 | 1099 | ||
1106 | if (!envelope_ok) { | 1100 | if (!envelope_ok) { |
1107 | if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) | 1101 | if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) |
1108 | printk(KERN_WARNING "hid-pidff: " | 1102 | hid_warn(pidff->hid, |
1109 | "has constant effect but no envelope\n"); | 1103 | "has constant effect but no envelope\n"); |
1110 | if (test_and_clear_bit(FF_RAMP, dev->ffbit)) | 1104 | if (test_and_clear_bit(FF_RAMP, dev->ffbit)) |
1111 | printk(KERN_WARNING "hid-pidff: " | 1105 | hid_warn(pidff->hid, |
1112 | "has ramp effect but no envelope\n"); | 1106 | "has ramp effect but no envelope\n"); |
1113 | 1107 | ||
1114 | if (test_and_clear_bit(FF_PERIODIC, dev->ffbit)) | 1108 | if (test_and_clear_bit(FF_PERIODIC, dev->ffbit)) |
1115 | printk(KERN_WARNING "hid-pidff: " | 1109 | hid_warn(pidff->hid, |
1116 | "has periodic effect but no envelope\n"); | 1110 | "has periodic effect but no envelope\n"); |
1117 | } | 1111 | } |
1118 | 1112 | ||
1119 | if (test_bit(FF_CONSTANT, dev->ffbit) && | 1113 | if (test_bit(FF_CONSTANT, dev->ffbit) && |
1120 | PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) { | 1114 | PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) { |
1121 | printk(KERN_WARNING | 1115 | hid_warn(pidff->hid, "unknown constant effect layout\n"); |
1122 | "hid-pidff: unknown constant effect layout\n"); | ||
1123 | clear_bit(FF_CONSTANT, dev->ffbit); | 1116 | clear_bit(FF_CONSTANT, dev->ffbit); |
1124 | } | 1117 | } |
1125 | 1118 | ||
1126 | if (test_bit(FF_RAMP, dev->ffbit) && | 1119 | if (test_bit(FF_RAMP, dev->ffbit) && |
1127 | PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) { | 1120 | PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) { |
1128 | printk(KERN_WARNING "hid-pidff: unknown ramp effect layout\n"); | 1121 | hid_warn(pidff->hid, "unknown ramp effect layout\n"); |
1129 | clear_bit(FF_RAMP, dev->ffbit); | 1122 | clear_bit(FF_RAMP, dev->ffbit); |
1130 | } | 1123 | } |
1131 | 1124 | ||
@@ -1134,8 +1127,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1134 | test_bit(FF_FRICTION, dev->ffbit) || | 1127 | test_bit(FF_FRICTION, dev->ffbit) || |
1135 | test_bit(FF_INERTIA, dev->ffbit)) && | 1128 | test_bit(FF_INERTIA, dev->ffbit)) && |
1136 | PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { | 1129 | PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { |
1137 | printk(KERN_WARNING | 1130 | hid_warn(pidff->hid, "unknown condition effect layout\n"); |
1138 | "hid-pidff: unknown condition effect layout\n"); | ||
1139 | clear_bit(FF_SPRING, dev->ffbit); | 1131 | clear_bit(FF_SPRING, dev->ffbit); |
1140 | clear_bit(FF_DAMPER, dev->ffbit); | 1132 | clear_bit(FF_DAMPER, dev->ffbit); |
1141 | clear_bit(FF_FRICTION, dev->ffbit); | 1133 | clear_bit(FF_FRICTION, dev->ffbit); |
@@ -1144,8 +1136,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1144 | 1136 | ||
1145 | if (test_bit(FF_PERIODIC, dev->ffbit) && | 1137 | if (test_bit(FF_PERIODIC, dev->ffbit) && |
1146 | PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) { | 1138 | PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) { |
1147 | printk(KERN_WARNING | 1139 | hid_warn(pidff->hid, "unknown periodic effect layout\n"); |
1148 | "hid-pidff: unknown periodic effect layout\n"); | ||
1149 | clear_bit(FF_PERIODIC, dev->ffbit); | 1140 | clear_bit(FF_PERIODIC, dev->ffbit); |
1150 | } | 1141 | } |
1151 | 1142 | ||
@@ -1184,12 +1175,12 @@ static void pidff_reset(struct pidff_device *pidff) | |||
1184 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { | 1175 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { |
1185 | while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { | 1176 | while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { |
1186 | if (i++ > 20) { | 1177 | if (i++ > 20) { |
1187 | printk(KERN_WARNING "hid-pidff: device reports " | 1178 | hid_warn(pidff->hid, |
1188 | "%d simultaneous effects\n", | 1179 | "device reports %d simultaneous effects\n", |
1189 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); | 1180 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); |
1190 | break; | 1181 | break; |
1191 | } | 1182 | } |
1192 | debug("pid_pool requested again"); | 1183 | hid_dbg(pidff->hid, "pid_pool requested again\n"); |
1193 | usbhid_submit_report(hid, pidff->reports[PID_POOL], | 1184 | usbhid_submit_report(hid, pidff->reports[PID_POOL], |
1194 | USB_DIR_IN); | 1185 | USB_DIR_IN); |
1195 | usbhid_wait_io(hid); | 1186 | usbhid_wait_io(hid); |
@@ -1215,7 +1206,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff, | |||
1215 | 1206 | ||
1216 | error = pidff_request_effect_upload(pidff, 1); | 1207 | error = pidff_request_effect_upload(pidff, 1); |
1217 | if (error) { | 1208 | if (error) { |
1218 | printk(KERN_ERR "hid-pidff: upload request failed\n"); | 1209 | hid_err(pidff->hid, "upload request failed\n"); |
1219 | return error; | 1210 | return error; |
1220 | } | 1211 | } |
1221 | 1212 | ||
@@ -1224,8 +1215,8 @@ static int pidff_check_autocenter(struct pidff_device *pidff, | |||
1224 | pidff_autocenter(pidff, 0xffff); | 1215 | pidff_autocenter(pidff, 0xffff); |
1225 | set_bit(FF_AUTOCENTER, dev->ffbit); | 1216 | set_bit(FF_AUTOCENTER, dev->ffbit); |
1226 | } else { | 1217 | } else { |
1227 | printk(KERN_NOTICE "hid-pidff: " | 1218 | hid_notice(pidff->hid, |
1228 | "device has unknown autocenter control method\n"); | 1219 | "device has unknown autocenter control method\n"); |
1229 | } | 1220 | } |
1230 | 1221 | ||
1231 | pidff_erase_pid(pidff, | 1222 | pidff_erase_pid(pidff, |
@@ -1248,10 +1239,10 @@ int hid_pidff_init(struct hid_device *hid) | |||
1248 | int max_effects; | 1239 | int max_effects; |
1249 | int error; | 1240 | int error; |
1250 | 1241 | ||
1251 | debug("starting pid init"); | 1242 | hid_dbg(hid, "starting pid init\n"); |
1252 | 1243 | ||
1253 | if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) { | 1244 | if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) { |
1254 | debug("not a PID device, no output report"); | 1245 | hid_dbg(hid, "not a PID device, no output report\n"); |
1255 | return -ENODEV; | 1246 | return -ENODEV; |
1256 | } | 1247 | } |
1257 | 1248 | ||
@@ -1265,7 +1256,7 @@ int hid_pidff_init(struct hid_device *hid) | |||
1265 | pidff_find_reports(hid, HID_FEATURE_REPORT, pidff); | 1256 | pidff_find_reports(hid, HID_FEATURE_REPORT, pidff); |
1266 | 1257 | ||
1267 | if (!pidff_reports_ok(pidff)) { | 1258 | if (!pidff_reports_ok(pidff)) { |
1268 | debug("reports not ok, aborting"); | 1259 | hid_dbg(hid, "reports not ok, aborting\n"); |
1269 | error = -ENODEV; | 1260 | error = -ENODEV; |
1270 | goto fail; | 1261 | goto fail; |
1271 | } | 1262 | } |
@@ -1278,8 +1269,8 @@ int hid_pidff_init(struct hid_device *hid) | |||
1278 | 1269 | ||
1279 | if (test_bit(FF_GAIN, dev->ffbit)) { | 1270 | if (test_bit(FF_GAIN, dev->ffbit)) { |
1280 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); | 1271 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); |
1281 | usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], | 1272 | usbhid_submit_report(hid, pidff->reports[PID_DEVICE_GAIN], |
1282 | USB_DIR_OUT); | 1273 | USB_DIR_OUT); |
1283 | } | 1274 | } |
1284 | 1275 | ||
1285 | error = pidff_check_autocenter(pidff, dev); | 1276 | error = pidff_check_autocenter(pidff, dev); |
@@ -1290,23 +1281,23 @@ int hid_pidff_init(struct hid_device *hid) | |||
1290 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum - | 1281 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum - |
1291 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum + | 1282 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum + |
1292 | 1; | 1283 | 1; |
1293 | debug("max effects is %d", max_effects); | 1284 | hid_dbg(hid, "max effects is %d\n", max_effects); |
1294 | 1285 | ||
1295 | if (max_effects > PID_EFFECTS_MAX) | 1286 | if (max_effects > PID_EFFECTS_MAX) |
1296 | max_effects = PID_EFFECTS_MAX; | 1287 | max_effects = PID_EFFECTS_MAX; |
1297 | 1288 | ||
1298 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) | 1289 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) |
1299 | debug("max simultaneous effects is %d", | 1290 | hid_dbg(hid, "max simultaneous effects is %d\n", |
1300 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); | 1291 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); |
1301 | 1292 | ||
1302 | if (pidff->pool[PID_RAM_POOL_SIZE].value) | 1293 | if (pidff->pool[PID_RAM_POOL_SIZE].value) |
1303 | debug("device memory size is %d bytes", | 1294 | hid_dbg(hid, "device memory size is %d bytes\n", |
1304 | pidff->pool[PID_RAM_POOL_SIZE].value[0]); | 1295 | pidff->pool[PID_RAM_POOL_SIZE].value[0]); |
1305 | 1296 | ||
1306 | if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && | 1297 | if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && |
1307 | pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { | 1298 | pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { |
1308 | printk(KERN_NOTICE "hid-pidff: " | 1299 | hid_notice(hid, |
1309 | "device does not support device managed pool\n"); | 1300 | "device does not support device managed pool\n"); |
1310 | goto fail; | 1301 | goto fail; |
1311 | } | 1302 | } |
1312 | 1303 | ||
@@ -1322,8 +1313,7 @@ int hid_pidff_init(struct hid_device *hid) | |||
1322 | ff->set_autocenter = pidff_set_autocenter; | 1313 | ff->set_autocenter = pidff_set_autocenter; |
1323 | ff->playback = pidff_playback; | 1314 | ff->playback = pidff_playback; |
1324 | 1315 | ||
1325 | printk(KERN_INFO "Force feedback for USB HID PID devices by " | 1316 | hid_info(dev, "Force feedback for USB HID PID devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); |
1326 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
1327 | 1317 | ||
1328 | return 0; | 1318 | return 0; |
1329 | 1319 | ||