diff options
Diffstat (limited to 'drivers')
184 files changed, 4263 insertions, 1650 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 34948362f41d..0cc2fd31e376 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -826,6 +826,11 @@ static int acpi_processor_add(struct acpi_device *device) | |||
826 | if (!pr) | 826 | if (!pr) |
827 | return -ENOMEM; | 827 | return -ENOMEM; |
828 | 828 | ||
829 | if (!alloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
830 | kfree(pr); | ||
831 | return -ENOMEM; | ||
832 | } | ||
833 | |||
829 | pr->handle = device->handle; | 834 | pr->handle = device->handle; |
830 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | 835 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); |
831 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | 836 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); |
@@ -845,10 +850,8 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
845 | 850 | ||
846 | pr = acpi_driver_data(device); | 851 | pr = acpi_driver_data(device); |
847 | 852 | ||
848 | if (pr->id >= nr_cpu_ids) { | 853 | if (pr->id >= nr_cpu_ids) |
849 | kfree(pr); | 854 | goto free; |
850 | return 0; | ||
851 | } | ||
852 | 855 | ||
853 | if (type == ACPI_BUS_REMOVAL_EJECT) { | 856 | if (type == ACPI_BUS_REMOVAL_EJECT) { |
854 | if (acpi_processor_handle_eject(pr)) | 857 | if (acpi_processor_handle_eject(pr)) |
@@ -873,6 +876,9 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
873 | 876 | ||
874 | per_cpu(processors, pr->id) = NULL; | 877 | per_cpu(processors, pr->id) = NULL; |
875 | per_cpu(processor_device_array, pr->id) = NULL; | 878 | per_cpu(processor_device_array, pr->id) = NULL; |
879 | |||
880 | free: | ||
881 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
876 | kfree(pr); | 882 | kfree(pr); |
877 | 883 | ||
878 | return 0; | 884 | return 0; |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 0d7b772bef50..846e227592d4 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -588,12 +588,15 @@ int acpi_processor_preregister_performance( | |||
588 | int count, count_target; | 588 | int count, count_target; |
589 | int retval = 0; | 589 | int retval = 0; |
590 | unsigned int i, j; | 590 | unsigned int i, j; |
591 | cpumask_t covered_cpus; | 591 | cpumask_var_t covered_cpus; |
592 | struct acpi_processor *pr; | 592 | struct acpi_processor *pr; |
593 | struct acpi_psd_package *pdomain; | 593 | struct acpi_psd_package *pdomain; |
594 | struct acpi_processor *match_pr; | 594 | struct acpi_processor *match_pr; |
595 | struct acpi_psd_package *match_pdomain; | 595 | struct acpi_psd_package *match_pdomain; |
596 | 596 | ||
597 | if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL)) | ||
598 | return -ENOMEM; | ||
599 | |||
597 | mutex_lock(&performance_mutex); | 600 | mutex_lock(&performance_mutex); |
598 | 601 | ||
599 | retval = 0; | 602 | retval = 0; |
@@ -617,7 +620,7 @@ int acpi_processor_preregister_performance( | |||
617 | } | 620 | } |
618 | 621 | ||
619 | pr->performance = percpu_ptr(performance, i); | 622 | pr->performance = percpu_ptr(performance, i); |
620 | cpu_set(i, pr->performance->shared_cpu_map); | 623 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
621 | if (acpi_processor_get_psd(pr)) { | 624 | if (acpi_processor_get_psd(pr)) { |
622 | retval = -EINVAL; | 625 | retval = -EINVAL; |
623 | continue; | 626 | continue; |
@@ -650,18 +653,18 @@ int acpi_processor_preregister_performance( | |||
650 | } | 653 | } |
651 | } | 654 | } |
652 | 655 | ||
653 | cpus_clear(covered_cpus); | 656 | cpumask_clear(covered_cpus); |
654 | for_each_possible_cpu(i) { | 657 | for_each_possible_cpu(i) { |
655 | pr = per_cpu(processors, i); | 658 | pr = per_cpu(processors, i); |
656 | if (!pr) | 659 | if (!pr) |
657 | continue; | 660 | continue; |
658 | 661 | ||
659 | if (cpu_isset(i, covered_cpus)) | 662 | if (cpumask_test_cpu(i, covered_cpus)) |
660 | continue; | 663 | continue; |
661 | 664 | ||
662 | pdomain = &(pr->performance->domain_info); | 665 | pdomain = &(pr->performance->domain_info); |
663 | cpu_set(i, pr->performance->shared_cpu_map); | 666 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
664 | cpu_set(i, covered_cpus); | 667 | cpumask_set_cpu(i, covered_cpus); |
665 | if (pdomain->num_processors <= 1) | 668 | if (pdomain->num_processors <= 1) |
666 | continue; | 669 | continue; |
667 | 670 | ||
@@ -699,8 +702,8 @@ int acpi_processor_preregister_performance( | |||
699 | goto err_ret; | 702 | goto err_ret; |
700 | } | 703 | } |
701 | 704 | ||
702 | cpu_set(j, covered_cpus); | 705 | cpumask_set_cpu(j, covered_cpus); |
703 | cpu_set(j, pr->performance->shared_cpu_map); | 706 | cpumask_set_cpu(j, pr->performance->shared_cpu_map); |
704 | count++; | 707 | count++; |
705 | } | 708 | } |
706 | 709 | ||
@@ -718,8 +721,8 @@ int acpi_processor_preregister_performance( | |||
718 | 721 | ||
719 | match_pr->performance->shared_type = | 722 | match_pr->performance->shared_type = |
720 | pr->performance->shared_type; | 723 | pr->performance->shared_type; |
721 | match_pr->performance->shared_cpu_map = | 724 | cpumask_copy(match_pr->performance->shared_cpu_map, |
722 | pr->performance->shared_cpu_map; | 725 | pr->performance->shared_cpu_map); |
723 | } | 726 | } |
724 | } | 727 | } |
725 | 728 | ||
@@ -731,14 +734,15 @@ err_ret: | |||
731 | 734 | ||
732 | /* Assume no coordination on any error parsing domain info */ | 735 | /* Assume no coordination on any error parsing domain info */ |
733 | if (retval) { | 736 | if (retval) { |
734 | cpus_clear(pr->performance->shared_cpu_map); | 737 | cpumask_clear(pr->performance->shared_cpu_map); |
735 | cpu_set(i, pr->performance->shared_cpu_map); | 738 | cpumask_set_cpu(i, pr->performance->shared_cpu_map); |
736 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; | 739 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; |
737 | } | 740 | } |
738 | pr->performance = NULL; /* Will be set for real in register */ | 741 | pr->performance = NULL; /* Will be set for real in register */ |
739 | } | 742 | } |
740 | 743 | ||
741 | mutex_unlock(&performance_mutex); | 744 | mutex_unlock(&performance_mutex); |
745 | free_cpumask_var(covered_cpus); | ||
742 | return retval; | 746 | return retval; |
743 | } | 747 | } |
744 | EXPORT_SYMBOL(acpi_processor_preregister_performance); | 748 | EXPORT_SYMBOL(acpi_processor_preregister_performance); |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index a0c38c94a8a0..d27838171f4a 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -61,11 +61,14 @@ static int acpi_processor_update_tsd_coord(void) | |||
61 | int count, count_target; | 61 | int count, count_target; |
62 | int retval = 0; | 62 | int retval = 0; |
63 | unsigned int i, j; | 63 | unsigned int i, j; |
64 | cpumask_t covered_cpus; | 64 | cpumask_var_t covered_cpus; |
65 | struct acpi_processor *pr, *match_pr; | 65 | struct acpi_processor *pr, *match_pr; |
66 | struct acpi_tsd_package *pdomain, *match_pdomain; | 66 | struct acpi_tsd_package *pdomain, *match_pdomain; |
67 | struct acpi_processor_throttling *pthrottling, *match_pthrottling; | 67 | struct acpi_processor_throttling *pthrottling, *match_pthrottling; |
68 | 68 | ||
69 | if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL)) | ||
70 | return -ENOMEM; | ||
71 | |||
69 | /* | 72 | /* |
70 | * Now that we have _TSD data from all CPUs, lets setup T-state | 73 | * Now that we have _TSD data from all CPUs, lets setup T-state |
71 | * coordination between all CPUs. | 74 | * coordination between all CPUs. |
@@ -91,19 +94,19 @@ static int acpi_processor_update_tsd_coord(void) | |||
91 | if (retval) | 94 | if (retval) |
92 | goto err_ret; | 95 | goto err_ret; |
93 | 96 | ||
94 | cpus_clear(covered_cpus); | 97 | cpumask_clear(covered_cpus); |
95 | for_each_possible_cpu(i) { | 98 | for_each_possible_cpu(i) { |
96 | pr = per_cpu(processors, i); | 99 | pr = per_cpu(processors, i); |
97 | if (!pr) | 100 | if (!pr) |
98 | continue; | 101 | continue; |
99 | 102 | ||
100 | if (cpu_isset(i, covered_cpus)) | 103 | if (cpumask_test_cpu(i, covered_cpus)) |
101 | continue; | 104 | continue; |
102 | pthrottling = &pr->throttling; | 105 | pthrottling = &pr->throttling; |
103 | 106 | ||
104 | pdomain = &(pthrottling->domain_info); | 107 | pdomain = &(pthrottling->domain_info); |
105 | cpu_set(i, pthrottling->shared_cpu_map); | 108 | cpumask_set_cpu(i, pthrottling->shared_cpu_map); |
106 | cpu_set(i, covered_cpus); | 109 | cpumask_set_cpu(i, covered_cpus); |
107 | /* | 110 | /* |
108 | * If the number of processor in the TSD domain is 1, it is | 111 | * If the number of processor in the TSD domain is 1, it is |
109 | * unnecessary to parse the coordination for this CPU. | 112 | * unnecessary to parse the coordination for this CPU. |
@@ -144,8 +147,8 @@ static int acpi_processor_update_tsd_coord(void) | |||
144 | goto err_ret; | 147 | goto err_ret; |
145 | } | 148 | } |
146 | 149 | ||
147 | cpu_set(j, covered_cpus); | 150 | cpumask_set_cpu(j, covered_cpus); |
148 | cpu_set(j, pthrottling->shared_cpu_map); | 151 | cpumask_set_cpu(j, pthrottling->shared_cpu_map); |
149 | count++; | 152 | count++; |
150 | } | 153 | } |
151 | for_each_possible_cpu(j) { | 154 | for_each_possible_cpu(j) { |
@@ -165,12 +168,14 @@ static int acpi_processor_update_tsd_coord(void) | |||
165 | * If some CPUS have the same domain, they | 168 | * If some CPUS have the same domain, they |
166 | * will have the same shared_cpu_map. | 169 | * will have the same shared_cpu_map. |
167 | */ | 170 | */ |
168 | match_pthrottling->shared_cpu_map = | 171 | cpumask_copy(match_pthrottling->shared_cpu_map, |
169 | pthrottling->shared_cpu_map; | 172 | pthrottling->shared_cpu_map); |
170 | } | 173 | } |
171 | } | 174 | } |
172 | 175 | ||
173 | err_ret: | 176 | err_ret: |
177 | free_cpumask_var(covered_cpus); | ||
178 | |||
174 | for_each_possible_cpu(i) { | 179 | for_each_possible_cpu(i) { |
175 | pr = per_cpu(processors, i); | 180 | pr = per_cpu(processors, i); |
176 | if (!pr) | 181 | if (!pr) |
@@ -182,8 +187,8 @@ err_ret: | |||
182 | */ | 187 | */ |
183 | if (retval) { | 188 | if (retval) { |
184 | pthrottling = &(pr->throttling); | 189 | pthrottling = &(pr->throttling); |
185 | cpus_clear(pthrottling->shared_cpu_map); | 190 | cpumask_clear(pthrottling->shared_cpu_map); |
186 | cpu_set(i, pthrottling->shared_cpu_map); | 191 | cpumask_set_cpu(i, pthrottling->shared_cpu_map); |
187 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; | 192 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; |
188 | } | 193 | } |
189 | } | 194 | } |
@@ -567,7 +572,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) | |||
567 | pthrottling = &pr->throttling; | 572 | pthrottling = &pr->throttling; |
568 | pthrottling->tsd_valid_flag = 1; | 573 | pthrottling->tsd_valid_flag = 1; |
569 | pthrottling->shared_type = pdomain->coord_type; | 574 | pthrottling->shared_type = pdomain->coord_type; |
570 | cpu_set(pr->id, pthrottling->shared_cpu_map); | 575 | cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map); |
571 | /* | 576 | /* |
572 | * If the coordination type is not defined in ACPI spec, | 577 | * If the coordination type is not defined in ACPI spec, |
573 | * the tsd_valid_flag will be clear and coordination type | 578 | * the tsd_valid_flag will be clear and coordination type |
@@ -826,7 +831,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
826 | 831 | ||
827 | static int acpi_processor_get_throttling(struct acpi_processor *pr) | 832 | static int acpi_processor_get_throttling(struct acpi_processor *pr) |
828 | { | 833 | { |
829 | cpumask_t saved_mask; | 834 | cpumask_var_t saved_mask; |
830 | int ret; | 835 | int ret; |
831 | 836 | ||
832 | if (!pr) | 837 | if (!pr) |
@@ -834,14 +839,20 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) | |||
834 | 839 | ||
835 | if (!pr->flags.throttling) | 840 | if (!pr->flags.throttling) |
836 | return -ENODEV; | 841 | return -ENODEV; |
842 | |||
843 | if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL)) | ||
844 | return -ENOMEM; | ||
845 | |||
837 | /* | 846 | /* |
838 | * Migrate task to the cpu pointed by pr. | 847 | * Migrate task to the cpu pointed by pr. |
839 | */ | 848 | */ |
840 | saved_mask = current->cpus_allowed; | 849 | cpumask_copy(saved_mask, ¤t->cpus_allowed); |
841 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 850 | /* FIXME: use work_on_cpu() */ |
851 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); | ||
842 | ret = pr->throttling.acpi_processor_get_throttling(pr); | 852 | ret = pr->throttling.acpi_processor_get_throttling(pr); |
843 | /* restore the previous state */ | 853 | /* restore the previous state */ |
844 | set_cpus_allowed_ptr(current, &saved_mask); | 854 | set_cpus_allowed_ptr(current, saved_mask); |
855 | free_cpumask_var(saved_mask); | ||
845 | 856 | ||
846 | return ret; | 857 | return ret; |
847 | } | 858 | } |
@@ -986,13 +997,13 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
986 | 997 | ||
987 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | 998 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) |
988 | { | 999 | { |
989 | cpumask_t saved_mask; | 1000 | cpumask_var_t saved_mask; |
990 | int ret = 0; | 1001 | int ret = 0; |
991 | unsigned int i; | 1002 | unsigned int i; |
992 | struct acpi_processor *match_pr; | 1003 | struct acpi_processor *match_pr; |
993 | struct acpi_processor_throttling *p_throttling; | 1004 | struct acpi_processor_throttling *p_throttling; |
994 | struct throttling_tstate t_state; | 1005 | struct throttling_tstate t_state; |
995 | cpumask_t online_throttling_cpus; | 1006 | cpumask_var_t online_throttling_cpus; |
996 | 1007 | ||
997 | if (!pr) | 1008 | if (!pr) |
998 | return -EINVAL; | 1009 | return -EINVAL; |
@@ -1003,17 +1014,25 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1003 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) | 1014 | if ((state < 0) || (state > (pr->throttling.state_count - 1))) |
1004 | return -EINVAL; | 1015 | return -EINVAL; |
1005 | 1016 | ||
1006 | saved_mask = current->cpus_allowed; | 1017 | if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL)) |
1018 | return -ENOMEM; | ||
1019 | |||
1020 | if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) { | ||
1021 | free_cpumask_var(saved_mask); | ||
1022 | return -ENOMEM; | ||
1023 | } | ||
1024 | |||
1025 | cpumask_copy(saved_mask, ¤t->cpus_allowed); | ||
1007 | t_state.target_state = state; | 1026 | t_state.target_state = state; |
1008 | p_throttling = &(pr->throttling); | 1027 | p_throttling = &(pr->throttling); |
1009 | cpus_and(online_throttling_cpus, cpu_online_map, | 1028 | cpumask_and(online_throttling_cpus, cpu_online_mask, |
1010 | p_throttling->shared_cpu_map); | 1029 | p_throttling->shared_cpu_map); |
1011 | /* | 1030 | /* |
1012 | * The throttling notifier will be called for every | 1031 | * The throttling notifier will be called for every |
1013 | * affected cpu in order to get one proper T-state. | 1032 | * affected cpu in order to get one proper T-state. |
1014 | * The notifier event is THROTTLING_PRECHANGE. | 1033 | * The notifier event is THROTTLING_PRECHANGE. |
1015 | */ | 1034 | */ |
1016 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1035 | for_each_cpu(i, online_throttling_cpus) { |
1017 | t_state.cpu = i; | 1036 | t_state.cpu = i; |
1018 | acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, | 1037 | acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, |
1019 | &t_state); | 1038 | &t_state); |
@@ -1025,7 +1044,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1025 | * it can be called only for the cpu pointed by pr. | 1044 | * it can be called only for the cpu pointed by pr. |
1026 | */ | 1045 | */ |
1027 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { | 1046 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { |
1028 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 1047 | /* FIXME: use work_on_cpu() */ |
1048 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); | ||
1029 | ret = p_throttling->acpi_processor_set_throttling(pr, | 1049 | ret = p_throttling->acpi_processor_set_throttling(pr, |
1030 | t_state.target_state); | 1050 | t_state.target_state); |
1031 | } else { | 1051 | } else { |
@@ -1034,7 +1054,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1034 | * it is necessary to set T-state for every affected | 1054 | * it is necessary to set T-state for every affected |
1035 | * cpus. | 1055 | * cpus. |
1036 | */ | 1056 | */ |
1037 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1057 | for_each_cpu(i, online_throttling_cpus) { |
1038 | match_pr = per_cpu(processors, i); | 1058 | match_pr = per_cpu(processors, i); |
1039 | /* | 1059 | /* |
1040 | * If the pointer is invalid, we will report the | 1060 | * If the pointer is invalid, we will report the |
@@ -1056,7 +1076,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1056 | continue; | 1076 | continue; |
1057 | } | 1077 | } |
1058 | t_state.cpu = i; | 1078 | t_state.cpu = i; |
1059 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); | 1079 | /* FIXME: use work_on_cpu() */ |
1080 | set_cpus_allowed_ptr(current, cpumask_of(i)); | ||
1060 | ret = match_pr->throttling. | 1081 | ret = match_pr->throttling. |
1061 | acpi_processor_set_throttling( | 1082 | acpi_processor_set_throttling( |
1062 | match_pr, t_state.target_state); | 1083 | match_pr, t_state.target_state); |
@@ -1068,13 +1089,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1068 | * affected cpu to update the T-states. | 1089 | * affected cpu to update the T-states. |
1069 | * The notifier event is THROTTLING_POSTCHANGE | 1090 | * The notifier event is THROTTLING_POSTCHANGE |
1070 | */ | 1091 | */ |
1071 | for_each_cpu_mask_nr(i, online_throttling_cpus) { | 1092 | for_each_cpu(i, online_throttling_cpus) { |
1072 | t_state.cpu = i; | 1093 | t_state.cpu = i; |
1073 | acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, | 1094 | acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, |
1074 | &t_state); | 1095 | &t_state); |
1075 | } | 1096 | } |
1076 | /* restore the previous state */ | 1097 | /* restore the previous state */ |
1077 | set_cpus_allowed_ptr(current, &saved_mask); | 1098 | /* FIXME: use work_on_cpu() */ |
1099 | set_cpus_allowed_ptr(current, saved_mask); | ||
1100 | free_cpumask_var(online_throttling_cpus); | ||
1101 | free_cpumask_var(saved_mask); | ||
1078 | return ret; | 1102 | return ret; |
1079 | } | 1103 | } |
1080 | 1104 | ||
@@ -1120,7 +1144,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
1120 | if (acpi_processor_get_tsd(pr)) { | 1144 | if (acpi_processor_get_tsd(pr)) { |
1121 | pthrottling = &pr->throttling; | 1145 | pthrottling = &pr->throttling; |
1122 | pthrottling->tsd_valid_flag = 0; | 1146 | pthrottling->tsd_valid_flag = 0; |
1123 | cpu_set(pr->id, pthrottling->shared_cpu_map); | 1147 | cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map); |
1124 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; | 1148 | pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; |
1125 | } | 1149 | } |
1126 | 1150 | ||
diff --git a/drivers/base/Makefile b/drivers/base/Makefile index c66637392bbc..b5b8ba512b28 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile | |||
@@ -11,6 +11,7 @@ obj-$(CONFIG_FW_LOADER) += firmware_class.o | |||
11 | obj-$(CONFIG_NUMA) += node.o | 11 | obj-$(CONFIG_NUMA) += node.o |
12 | obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o | 12 | obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o |
13 | obj-$(CONFIG_SMP) += topology.o | 13 | obj-$(CONFIG_SMP) += topology.o |
14 | obj-$(CONFIG_IOMMU_API) += iommu.o | ||
14 | ifeq ($(CONFIG_SYSFS),y) | 15 | ifeq ($(CONFIG_SYSFS),y) |
15 | obj-$(CONFIG_MODULES) += module.o | 16 | obj-$(CONFIG_MODULES) += module.o |
16 | endif | 17 | endif |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4259072f5bd0..719ee5c1c8d9 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -128,10 +128,54 @@ print_cpus_func(online); | |||
128 | print_cpus_func(possible); | 128 | print_cpus_func(possible); |
129 | print_cpus_func(present); | 129 | print_cpus_func(present); |
130 | 130 | ||
131 | /* | ||
132 | * Print values for NR_CPUS and offlined cpus | ||
133 | */ | ||
134 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf) | ||
135 | { | ||
136 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); | ||
137 | return n; | ||
138 | } | ||
139 | static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); | ||
140 | |||
141 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ | ||
142 | unsigned int total_cpus; | ||
143 | |||
144 | static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf) | ||
145 | { | ||
146 | int n = 0, len = PAGE_SIZE-2; | ||
147 | cpumask_var_t offline; | ||
148 | |||
149 | /* display offline cpus < nr_cpu_ids */ | ||
150 | if (!alloc_cpumask_var(&offline, GFP_KERNEL)) | ||
151 | return -ENOMEM; | ||
152 | cpumask_complement(offline, cpu_online_mask); | ||
153 | n = cpulist_scnprintf(buf, len, offline); | ||
154 | free_cpumask_var(offline); | ||
155 | |||
156 | /* display offline cpus >= nr_cpu_ids */ | ||
157 | if (total_cpus && nr_cpu_ids < total_cpus) { | ||
158 | if (n && n < len) | ||
159 | buf[n++] = ','; | ||
160 | |||
161 | if (nr_cpu_ids == total_cpus-1) | ||
162 | n += snprintf(&buf[n], len - n, "%d", nr_cpu_ids); | ||
163 | else | ||
164 | n += snprintf(&buf[n], len - n, "%d-%d", | ||
165 | nr_cpu_ids, total_cpus-1); | ||
166 | } | ||
167 | |||
168 | n += snprintf(&buf[n], len - n, "\n"); | ||
169 | return n; | ||
170 | } | ||
171 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); | ||
172 | |||
131 | static struct sysdev_class_attribute *cpu_state_attr[] = { | 173 | static struct sysdev_class_attribute *cpu_state_attr[] = { |
132 | &attr_online_map, | 174 | &attr_online_map, |
133 | &attr_possible_map, | 175 | &attr_possible_map, |
134 | &attr_present_map, | 176 | &attr_present_map, |
177 | &attr_kernel_max, | ||
178 | &attr_offline, | ||
135 | }; | 179 | }; |
136 | 180 | ||
137 | static int cpu_states_init(void) | 181 | static int cpu_states_init(void) |
diff --git a/drivers/base/iommu.c b/drivers/base/iommu.c new file mode 100644 index 000000000000..5e039d4f877c --- /dev/null +++ b/drivers/base/iommu.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Advanced Micro Devices, Inc. | ||
3 | * Author: Joerg Roedel <joerg.roedel@amd.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License version 2 as published | ||
7 | * by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | ||
18 | |||
19 | #include <linux/bug.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/iommu.h> | ||
23 | |||
24 | static struct iommu_ops *iommu_ops; | ||
25 | |||
26 | void register_iommu(struct iommu_ops *ops) | ||
27 | { | ||
28 | if (iommu_ops) | ||
29 | BUG(); | ||
30 | |||
31 | iommu_ops = ops; | ||
32 | } | ||
33 | |||
34 | bool iommu_found() | ||
35 | { | ||
36 | return iommu_ops != NULL; | ||
37 | } | ||
38 | EXPORT_SYMBOL_GPL(iommu_found); | ||
39 | |||
40 | struct iommu_domain *iommu_domain_alloc(void) | ||
41 | { | ||
42 | struct iommu_domain *domain; | ||
43 | int ret; | ||
44 | |||
45 | domain = kmalloc(sizeof(*domain), GFP_KERNEL); | ||
46 | if (!domain) | ||
47 | return NULL; | ||
48 | |||
49 | ret = iommu_ops->domain_init(domain); | ||
50 | if (ret) | ||
51 | goto out_free; | ||
52 | |||
53 | return domain; | ||
54 | |||
55 | out_free: | ||
56 | kfree(domain); | ||
57 | |||
58 | return NULL; | ||
59 | } | ||
60 | EXPORT_SYMBOL_GPL(iommu_domain_alloc); | ||
61 | |||
62 | void iommu_domain_free(struct iommu_domain *domain) | ||
63 | { | ||
64 | iommu_ops->domain_destroy(domain); | ||
65 | kfree(domain); | ||
66 | } | ||
67 | EXPORT_SYMBOL_GPL(iommu_domain_free); | ||
68 | |||
69 | int iommu_attach_device(struct iommu_domain *domain, struct device *dev) | ||
70 | { | ||
71 | return iommu_ops->attach_dev(domain, dev); | ||
72 | } | ||
73 | EXPORT_SYMBOL_GPL(iommu_attach_device); | ||
74 | |||
75 | void iommu_detach_device(struct iommu_domain *domain, struct device *dev) | ||
76 | { | ||
77 | iommu_ops->detach_dev(domain, dev); | ||
78 | } | ||
79 | EXPORT_SYMBOL_GPL(iommu_detach_device); | ||
80 | |||
81 | int iommu_map_range(struct iommu_domain *domain, unsigned long iova, | ||
82 | phys_addr_t paddr, size_t size, int prot) | ||
83 | { | ||
84 | return iommu_ops->map(domain, iova, paddr, size, prot); | ||
85 | } | ||
86 | EXPORT_SYMBOL_GPL(iommu_map_range); | ||
87 | |||
88 | void iommu_unmap_range(struct iommu_domain *domain, unsigned long iova, | ||
89 | size_t size) | ||
90 | { | ||
91 | iommu_ops->unmap(domain, iova, size); | ||
92 | } | ||
93 | EXPORT_SYMBOL_GPL(iommu_unmap_range); | ||
94 | |||
95 | phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, | ||
96 | unsigned long iova) | ||
97 | { | ||
98 | return iommu_ops->iova_to_phys(domain, iova); | ||
99 | } | ||
100 | EXPORT_SYMBOL_GPL(iommu_iova_to_phys); | ||
diff --git a/drivers/char/random.c b/drivers/char/random.c index d26891bfcd41..c7afc068c28d 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -559,7 +559,40 @@ struct timer_rand_state { | |||
559 | }; | 559 | }; |
560 | 560 | ||
561 | #ifndef CONFIG_SPARSE_IRQ | 561 | #ifndef CONFIG_SPARSE_IRQ |
562 | struct timer_rand_state *irq_timer_state[NR_IRQS]; | 562 | |
563 | static struct timer_rand_state *irq_timer_state[NR_IRQS]; | ||
564 | |||
565 | static struct timer_rand_state *get_timer_rand_state(unsigned int irq) | ||
566 | { | ||
567 | return irq_timer_state[irq]; | ||
568 | } | ||
569 | |||
570 | static void set_timer_rand_state(unsigned int irq, | ||
571 | struct timer_rand_state *state) | ||
572 | { | ||
573 | irq_timer_state[irq] = state; | ||
574 | } | ||
575 | |||
576 | #else | ||
577 | |||
578 | static struct timer_rand_state *get_timer_rand_state(unsigned int irq) | ||
579 | { | ||
580 | struct irq_desc *desc; | ||
581 | |||
582 | desc = irq_to_desc(irq); | ||
583 | |||
584 | return desc->timer_rand_state; | ||
585 | } | ||
586 | |||
587 | static void set_timer_rand_state(unsigned int irq, | ||
588 | struct timer_rand_state *state) | ||
589 | { | ||
590 | struct irq_desc *desc; | ||
591 | |||
592 | desc = irq_to_desc(irq); | ||
593 | |||
594 | desc->timer_rand_state = state; | ||
595 | } | ||
563 | #endif | 596 | #endif |
564 | 597 | ||
565 | static struct timer_rand_state input_timer_state; | 598 | static struct timer_rand_state input_timer_state; |
@@ -919,11 +952,6 @@ void rand_initialize_irq(int irq) | |||
919 | { | 952 | { |
920 | struct timer_rand_state *state; | 953 | struct timer_rand_state *state; |
921 | 954 | ||
922 | #ifndef CONFIG_SPARSE_IRQ | ||
923 | if (irq >= nr_irqs) | ||
924 | return; | ||
925 | #endif | ||
926 | |||
927 | state = get_timer_rand_state(irq); | 955 | state = get_timer_rand_state(irq); |
928 | 956 | ||
929 | if (state) | 957 | if (state) |
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index 757035ea246f..3128a5090dbd 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c | |||
@@ -659,12 +659,12 @@ static inline int find_next_online_cpu(struct ehca_comp_pool *pool) | |||
659 | 659 | ||
660 | WARN_ON_ONCE(!in_interrupt()); | 660 | WARN_ON_ONCE(!in_interrupt()); |
661 | if (ehca_debug_level >= 3) | 661 | if (ehca_debug_level >= 3) |
662 | ehca_dmp(&cpu_online_map, sizeof(cpumask_t), ""); | 662 | ehca_dmp(cpu_online_mask, cpumask_size(), ""); |
663 | 663 | ||
664 | spin_lock_irqsave(&pool->last_cpu_lock, flags); | 664 | spin_lock_irqsave(&pool->last_cpu_lock, flags); |
665 | cpu = next_cpu_nr(pool->last_cpu, cpu_online_map); | 665 | cpu = cpumask_next(pool->last_cpu, cpu_online_mask); |
666 | if (cpu >= nr_cpu_ids) | 666 | if (cpu >= nr_cpu_ids) |
667 | cpu = first_cpu(cpu_online_map); | 667 | cpu = cpumask_first(cpu_online_mask); |
668 | pool->last_cpu = cpu; | 668 | pool->last_cpu = cpu; |
669 | spin_unlock_irqrestore(&pool->last_cpu_lock, flags); | 669 | spin_unlock_irqrestore(&pool->last_cpu_lock, flags); |
670 | 670 | ||
@@ -855,7 +855,7 @@ static int __cpuinit comp_pool_callback(struct notifier_block *nfb, | |||
855 | case CPU_UP_CANCELED_FROZEN: | 855 | case CPU_UP_CANCELED_FROZEN: |
856 | ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); | 856 | ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); |
857 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); | 857 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); |
858 | kthread_bind(cct->task, any_online_cpu(cpu_online_map)); | 858 | kthread_bind(cct->task, cpumask_any(cpu_online_mask)); |
859 | destroy_comp_task(pool, cpu); | 859 | destroy_comp_task(pool, cpu); |
860 | break; | 860 | break; |
861 | case CPU_ONLINE: | 861 | case CPU_ONLINE: |
@@ -902,7 +902,7 @@ int ehca_create_comp_pool(void) | |||
902 | return -ENOMEM; | 902 | return -ENOMEM; |
903 | 903 | ||
904 | spin_lock_init(&pool->last_cpu_lock); | 904 | spin_lock_init(&pool->last_cpu_lock); |
905 | pool->last_cpu = any_online_cpu(cpu_online_map); | 905 | pool->last_cpu = cpumask_any(cpu_online_mask); |
906 | 906 | ||
907 | pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task); | 907 | pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task); |
908 | if (pool->cpu_comp_tasks == NULL) { | 908 | if (pool->cpu_comp_tasks == NULL) { |
@@ -934,10 +934,9 @@ void ehca_destroy_comp_pool(void) | |||
934 | 934 | ||
935 | unregister_hotcpu_notifier(&comp_pool_callback_nb); | 935 | unregister_hotcpu_notifier(&comp_pool_callback_nb); |
936 | 936 | ||
937 | for (i = 0; i < NR_CPUS; i++) { | 937 | for_each_online_cpu(i) |
938 | if (cpu_online(i)) | 938 | destroy_comp_task(pool, i); |
939 | destroy_comp_task(pool, i); | 939 | |
940 | } | ||
941 | free_percpu(pool->cpu_comp_tasks); | 940 | free_percpu(pool->cpu_comp_tasks); |
942 | kfree(pool); | 941 | kfree(pool); |
943 | } | 942 | } |
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 239d4e8068ac..23173982b32c 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -1679,7 +1679,7 @@ static int find_best_unit(struct file *fp, | |||
1679 | * InfiniPath chip to that processor (we assume reasonable connectivity, | 1679 | * InfiniPath chip to that processor (we assume reasonable connectivity, |
1680 | * for now). This code assumes that if affinity has been set | 1680 | * for now). This code assumes that if affinity has been set |
1681 | * before this point, that at most one cpu is set; for now this | 1681 | * before this point, that at most one cpu is set; for now this |
1682 | * is reasonable. I check for both cpus_empty() and cpus_full(), | 1682 | * is reasonable. I check for both cpumask_empty() and cpumask_full(), |
1683 | * in case some kernel variant sets none of the bits when no | 1683 | * in case some kernel variant sets none of the bits when no |
1684 | * affinity is set. 2.6.11 and 12 kernels have all present | 1684 | * affinity is set. 2.6.11 and 12 kernels have all present |
1685 | * cpus set. Some day we'll have to fix it up further to handle | 1685 | * cpus set. Some day we'll have to fix it up further to handle |
@@ -1688,11 +1688,11 @@ static int find_best_unit(struct file *fp, | |||
1688 | * information. There may be some issues with dual core numbering | 1688 | * information. There may be some issues with dual core numbering |
1689 | * as well. This needs more work prior to release. | 1689 | * as well. This needs more work prior to release. |
1690 | */ | 1690 | */ |
1691 | if (!cpus_empty(current->cpus_allowed) && | 1691 | if (!cpumask_empty(¤t->cpus_allowed) && |
1692 | !cpus_full(current->cpus_allowed)) { | 1692 | !cpumask_full(¤t->cpus_allowed)) { |
1693 | int ncpus = num_online_cpus(), curcpu = -1, nset = 0; | 1693 | int ncpus = num_online_cpus(), curcpu = -1, nset = 0; |
1694 | for (i = 0; i < ncpus; i++) | 1694 | for (i = 0; i < ncpus; i++) |
1695 | if (cpu_isset(i, current->cpus_allowed)) { | 1695 | if (cpumask_test_cpu(i, ¤t->cpus_allowed)) { |
1696 | ipath_cdbg(PROC, "%s[%u] affinity set for " | 1696 | ipath_cdbg(PROC, "%s[%u] affinity set for " |
1697 | "cpu %d/%d\n", current->comm, | 1697 | "cpu %d/%d\n", current->comm, |
1698 | current->pid, i, ncpus); | 1698 | current->pid, i, ncpus); |
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index 7d844af88384..cf06f4d10ad4 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -192,9 +192,9 @@ void saa7146_buffer_timeout(unsigned long data) | |||
192 | /********************************************************************************/ | 192 | /********************************************************************************/ |
193 | /* file operations */ | 193 | /* file operations */ |
194 | 194 | ||
195 | static int fops_open(struct inode *inode, struct file *file) | 195 | static int fops_open(struct file *file) |
196 | { | 196 | { |
197 | unsigned int minor = iminor(inode); | 197 | unsigned int minor = video_devdata(file)->minor; |
198 | struct saa7146_dev *h = NULL, *dev = NULL; | 198 | struct saa7146_dev *h = NULL, *dev = NULL; |
199 | struct list_head *list; | 199 | struct list_head *list; |
200 | struct saa7146_fh *fh = NULL; | 200 | struct saa7146_fh *fh = NULL; |
@@ -202,7 +202,7 @@ static int fops_open(struct inode *inode, struct file *file) | |||
202 | 202 | ||
203 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 203 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
204 | 204 | ||
205 | DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor)); | 205 | DEB_EE(("file:%p, minor:%d\n", file, minor)); |
206 | 206 | ||
207 | if (mutex_lock_interruptible(&saa7146_devices_lock)) | 207 | if (mutex_lock_interruptible(&saa7146_devices_lock)) |
208 | return -ERESTARTSYS; | 208 | return -ERESTARTSYS; |
@@ -255,7 +255,7 @@ static int fops_open(struct inode *inode, struct file *file) | |||
255 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) | 255 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
256 | result = saa7146_vbi_uops.open(dev,file); | 256 | result = saa7146_vbi_uops.open(dev,file); |
257 | if (dev->ext_vv_data->vbi_fops.open) | 257 | if (dev->ext_vv_data->vbi_fops.open) |
258 | dev->ext_vv_data->vbi_fops.open(inode, file); | 258 | dev->ext_vv_data->vbi_fops.open(file); |
259 | } else { | 259 | } else { |
260 | DEB_S(("initializing video...\n")); | 260 | DEB_S(("initializing video...\n")); |
261 | result = saa7146_video_uops.open(dev,file); | 261 | result = saa7146_video_uops.open(dev,file); |
@@ -280,12 +280,12 @@ out: | |||
280 | return result; | 280 | return result; |
281 | } | 281 | } |
282 | 282 | ||
283 | static int fops_release(struct inode *inode, struct file *file) | 283 | static int fops_release(struct file *file) |
284 | { | 284 | { |
285 | struct saa7146_fh *fh = file->private_data; | 285 | struct saa7146_fh *fh = file->private_data; |
286 | struct saa7146_dev *dev = fh->dev; | 286 | struct saa7146_dev *dev = fh->dev; |
287 | 287 | ||
288 | DEB_EE(("inode:%p, file:%p\n",inode,file)); | 288 | DEB_EE(("file:%p\n", file)); |
289 | 289 | ||
290 | if (mutex_lock_interruptible(&saa7146_devices_lock)) | 290 | if (mutex_lock_interruptible(&saa7146_devices_lock)) |
291 | return -ERESTARTSYS; | 291 | return -ERESTARTSYS; |
@@ -294,7 +294,7 @@ static int fops_release(struct inode *inode, struct file *file) | |||
294 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) | 294 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
295 | saa7146_vbi_uops.release(dev,file); | 295 | saa7146_vbi_uops.release(dev,file); |
296 | if (dev->ext_vv_data->vbi_fops.release) | 296 | if (dev->ext_vv_data->vbi_fops.release) |
297 | dev->ext_vv_data->vbi_fops.release(inode, file); | 297 | dev->ext_vv_data->vbi_fops.release(file); |
298 | } else { | 298 | } else { |
299 | saa7146_video_uops.release(dev,file); | 299 | saa7146_video_uops.release(dev,file); |
300 | } | 300 | } |
@@ -308,10 +308,10 @@ static int fops_release(struct inode *inode, struct file *file) | |||
308 | return 0; | 308 | return 0; |
309 | } | 309 | } |
310 | 310 | ||
311 | static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 311 | static long fops_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
312 | { | 312 | { |
313 | /* | 313 | /* |
314 | DEB_EE(("inode:%p, file:%p, cmd:%d, arg:%li\n",inode, file, cmd, arg)); | 314 | DEB_EE(("file:%p, cmd:%d, arg:%li\n", file, cmd, arg)); |
315 | */ | 315 | */ |
316 | return video_usercopy(file, cmd, arg, saa7146_video_do_ioctl); | 316 | return video_usercopy(file, cmd, arg, saa7146_video_do_ioctl); |
317 | } | 317 | } |
@@ -416,7 +416,7 @@ static ssize_t fops_write(struct file *file, const char __user *data, size_t cou | |||
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | static const struct file_operations video_fops = | 419 | static const struct v4l2_file_operations video_fops = |
420 | { | 420 | { |
421 | .owner = THIS_MODULE, | 421 | .owner = THIS_MODULE, |
422 | .open = fops_open, | 422 | .open = fops_open, |
@@ -426,7 +426,6 @@ static const struct file_operations video_fops = | |||
426 | .poll = fops_poll, | 426 | .poll = fops_poll, |
427 | .mmap = fops_mmap, | 427 | .mmap = fops_mmap, |
428 | .ioctl = fops_ioctl, | 428 | .ioctl = fops_ioctl, |
429 | .llseek = no_llseek, | ||
430 | }; | 429 | }; |
431 | 430 | ||
432 | static void vv_callback(struct saa7146_dev *dev, unsigned long status) | 431 | static void vv_callback(struct saa7146_dev *dev, unsigned long status) |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index 101b01dbb8ea..6098b626811f 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
@@ -834,13 +834,14 @@ static int video_end(struct saa7146_fh *fh, struct file *file) | |||
834 | * copying is done already, arg is a kernel pointer. | 834 | * copying is done already, arg is a kernel pointer. |
835 | */ | 835 | */ |
836 | 836 | ||
837 | int saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 837 | long saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
838 | { | 838 | { |
839 | struct saa7146_fh *fh = file->private_data; | 839 | struct saa7146_fh *fh = file->private_data; |
840 | struct saa7146_dev *dev = fh->dev; | 840 | struct saa7146_dev *dev = fh->dev; |
841 | struct saa7146_vv *vv = dev->vv_data; | 841 | struct saa7146_vv *vv = dev->vv_data; |
842 | 842 | ||
843 | int err = 0, result = 0, ee = 0; | 843 | long err = 0; |
844 | int result = 0, ee = 0; | ||
844 | 845 | ||
845 | struct saa7146_use_ops *ops; | 846 | struct saa7146_use_ops *ops; |
846 | struct videobuf_queue *q; | 847 | struct videobuf_queue *q; |
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index fb3f3b3adaba..de7adaf5fa5b 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -820,6 +820,15 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
820 | int ret; | 820 | int ret; |
821 | unsigned frequency = params->frequency / 62500; | 821 | unsigned frequency = params->frequency / 62500; |
822 | 822 | ||
823 | if (!tun->stepsize) { | ||
824 | /* tuner-core was loaded before the digital tuner was | ||
825 | * configured and somehow picked the wrong tuner type */ | ||
826 | tuner_err("attempt to treat tuner %d (%s) as digital tuner " | ||
827 | "without stepsize defined.\n", | ||
828 | priv->type, priv->tun->name); | ||
829 | return 0; /* failure */ | ||
830 | } | ||
831 | |||
823 | t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); | 832 | t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); |
824 | ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); | 833 | ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); |
825 | if (ret < 0) | 834 | if (ret < 0) |
@@ -1059,7 +1068,12 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, | |||
1059 | memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, | 1068 | memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, |
1060 | sizeof(struct dvb_tuner_ops)); | 1069 | sizeof(struct dvb_tuner_ops)); |
1061 | 1070 | ||
1062 | tuner_info("type set to %d (%s)\n", type, priv->tun->name); | 1071 | if (type != priv->type) |
1072 | tuner_warn("couldn't set type to %d. Using %d (%s) instead\n", | ||
1073 | type, priv->type, priv->tun->name); | ||
1074 | else | ||
1075 | tuner_info("type set to %d (%s)\n", | ||
1076 | priv->type, priv->tun->name); | ||
1063 | 1077 | ||
1064 | if ((debug) || ((atv_input[priv->nr] > 0) || | 1078 | if ((debug) || ((atv_input[priv->nr] > 0) || |
1065 | (dtv_input[priv->nr] > 0))) { | 1079 | (dtv_input[priv->nr] > 0))) { |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 6c571d9f011c..65d69665f1fc 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
@@ -436,8 +436,9 @@ static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
436 | { | 436 | { |
437 | struct dvb_device *dvbdev = dev_get_drvdata(dev); | 437 | struct dvb_device *dvbdev = dev_get_drvdata(dev); |
438 | 438 | ||
439 | add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id); | ||
440 | add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num); | 439 | add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num); |
440 | add_uevent_var(env, "DVB_DEVICE_TYPE=%s", dnames[dvbdev->type]); | ||
441 | add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id); | ||
441 | return 0; | 442 | return 0; |
442 | } | 443 | } |
443 | 444 | ||
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c index c1da962cc886..3dd6843864ed 100644 --- a/drivers/media/dvb/dvb-usb/gp8psk.c +++ b/drivers/media/dvb/dvb-usb/gp8psk.c | |||
@@ -187,7 +187,7 @@ int gp8psk_bcm4500_reload(struct dvb_usb_device *d) | |||
187 | /* load BCM4500 firmware */ | 187 | /* load BCM4500 firmware */ |
188 | if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) | 188 | if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) |
189 | if (gp8psk_load_bcm4500fw(d)) | 189 | if (gp8psk_load_bcm4500fw(d)) |
190 | return EINVAL; | 190 | return -EINVAL; |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c index 9b6c89e93f16..4f514d39b98f 100644 --- a/drivers/media/dvb/frontends/cx24116.c +++ b/drivers/media/dvb/frontends/cx24116.c | |||
@@ -1463,6 +1463,7 @@ static struct dvb_frontend_ops cx24116_ops = { | |||
1463 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | 1463 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
1464 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | | 1464 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | |
1465 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | 1465 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | |
1466 | FE_CAN_2G_MODULATION | | ||
1466 | FE_CAN_QPSK | FE_CAN_RECOVER | 1467 | FE_CAN_QPSK | FE_CAN_RECOVER |
1467 | }, | 1468 | }, |
1468 | 1469 | ||
diff --git a/drivers/media/dvb/frontends/cx24116.h b/drivers/media/dvb/frontends/cx24116.h index 4cb3ddd6c626..b1b76b47a14c 100644 --- a/drivers/media/dvb/frontends/cx24116.h +++ b/drivers/media/dvb/frontends/cx24116.h | |||
@@ -37,7 +37,8 @@ struct cx24116_config { | |||
37 | u8 mpg_clk_pos_pol:0x02; | 37 | u8 mpg_clk_pos_pol:0x02; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) | 40 | #if defined(CONFIG_DVB_CX24116) || \ |
41 | (defined(CONFIG_DVB_CX24116_MODULE) && defined(MODULE)) | ||
41 | extern struct dvb_frontend *cx24116_attach( | 42 | extern struct dvb_frontend *cx24116_attach( |
42 | const struct cx24116_config *config, | 43 | const struct cx24116_config *config, |
43 | struct i2c_adapter *i2c); | 44 | struct i2c_adapter *i2c); |
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 528820170228..bee28f77b93f 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c | |||
@@ -1618,6 +1618,7 @@ static struct dvb_frontend_ops stb0899_ops = { | |||
1618 | 1618 | ||
1619 | .caps = FE_CAN_INVERSION_AUTO | | 1619 | .caps = FE_CAN_INVERSION_AUTO | |
1620 | FE_CAN_FEC_AUTO | | 1620 | FE_CAN_FEC_AUTO | |
1621 | FE_CAN_2G_MODULATION | | ||
1621 | FE_CAN_QPSK | 1622 | FE_CAN_QPSK |
1622 | }, | 1623 | }, |
1623 | 1624 | ||
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 5506f80e180e..170720b02815 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c | |||
@@ -587,8 +587,15 @@ static int zl10353_init(struct dvb_frontend *fe) | |||
587 | 587 | ||
588 | static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | 588 | static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) |
589 | { | 589 | { |
590 | struct zl10353_state *state = fe->demodulator_priv; | ||
590 | u8 val = 0x0a; | 591 | u8 val = 0x0a; |
591 | 592 | ||
593 | if (state->config.no_tuner) { | ||
594 | /* No tuner attached to the internal I2C bus */ | ||
595 | /* If set enable I2C bridge, the main I2C bus stopped hardly */ | ||
596 | return 0; | ||
597 | } | ||
598 | |||
592 | if (enable) | 599 | if (enable) |
593 | val |= 0x10; | 600 | val |= 0x10; |
594 | 601 | ||
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c index fd62e0b85621..4307e4e8aa34 100644 --- a/drivers/media/dvb/siano/sms-cards.c +++ b/drivers/media/dvb/siano/sms-cards.c | |||
@@ -120,7 +120,7 @@ static struct sms_board sms_boards[] = { | |||
120 | .name = "Hauppauge WinTV MiniCard", | 120 | .name = "Hauppauge WinTV MiniCard", |
121 | .type = SMS_NOVA_B0, | 121 | .type = SMS_NOVA_B0, |
122 | .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw", | 122 | .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw", |
123 | .lna_ctrl = 1, | 123 | .lna_ctrl = -1, |
124 | }, | 124 | }, |
125 | }; | 125 | }; |
126 | 126 | ||
@@ -131,9 +131,10 @@ struct sms_board *sms_get_board(int id) | |||
131 | return &sms_boards[id]; | 131 | return &sms_boards[id]; |
132 | } | 132 | } |
133 | 133 | ||
134 | static int sms_set_gpio(struct smscore_device_t *coredev, u32 pin, int enable) | 134 | static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable) |
135 | { | 135 | { |
136 | int ret; | 136 | int lvl, ret; |
137 | u32 gpio; | ||
137 | struct smscore_gpio_config gpioconfig = { | 138 | struct smscore_gpio_config gpioconfig = { |
138 | .direction = SMS_GPIO_DIRECTION_OUTPUT, | 139 | .direction = SMS_GPIO_DIRECTION_OUTPUT, |
139 | .pullupdown = SMS_GPIO_PULLUPDOWN_NONE, | 140 | .pullupdown = SMS_GPIO_PULLUPDOWN_NONE, |
@@ -145,12 +146,20 @@ static int sms_set_gpio(struct smscore_device_t *coredev, u32 pin, int enable) | |||
145 | if (pin == 0) | 146 | if (pin == 0) |
146 | return -EINVAL; | 147 | return -EINVAL; |
147 | 148 | ||
148 | ret = smscore_configure_gpio(coredev, pin, &gpioconfig); | 149 | if (pin < 0) { |
150 | /* inverted gpio */ | ||
151 | gpio = pin * -1; | ||
152 | lvl = enable ? 0 : 1; | ||
153 | } else { | ||
154 | gpio = pin; | ||
155 | lvl = enable ? 1 : 0; | ||
156 | } | ||
149 | 157 | ||
158 | ret = smscore_configure_gpio(coredev, gpio, &gpioconfig); | ||
150 | if (ret < 0) | 159 | if (ret < 0) |
151 | return ret; | 160 | return ret; |
152 | 161 | ||
153 | return smscore_set_gpio(coredev, pin, enable); | 162 | return smscore_set_gpio(coredev, gpio, lvl); |
154 | } | 163 | } |
155 | 164 | ||
156 | int sms_board_setup(struct smscore_device_t *coredev) | 165 | int sms_board_setup(struct smscore_device_t *coredev) |
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index b4a0cc5dc935..c5b9c70563dc 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c | |||
@@ -316,7 +316,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) | |||
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | 318 | ||
319 | static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | 319 | static long av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) |
320 | { | 320 | { |
321 | struct saa7146_dev *dev = fh->dev; | 321 | struct saa7146_dev *dev = fh->dev; |
322 | struct av7110 *av7110 = (struct av7110*) dev->ext_priv; | 322 | struct av7110 *av7110 = (struct av7110*) dev->ext_priv; |
@@ -567,7 +567,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
567 | return 0; | 567 | return 0; |
568 | } | 568 | } |
569 | 569 | ||
570 | static int av7110_vbi_reset(struct inode *inode, struct file *file) | 570 | static int av7110_vbi_reset(struct file *file) |
571 | { | 571 | { |
572 | struct saa7146_fh *fh = file->private_data; | 572 | struct saa7146_fh *fh = file->private_data; |
573 | struct saa7146_dev *dev = fh->dev; | 573 | struct saa7146_dev *dev = fh->dev; |
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index f996cef79ec1..4182121d7e5d 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -1493,7 +1493,7 @@ static struct saa7146_extension_ioctls ioctls[] = { | |||
1493 | {0, 0} | 1493 | {0, 0} |
1494 | }; | 1494 | }; |
1495 | 1495 | ||
1496 | static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | 1496 | static long av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) |
1497 | { | 1497 | { |
1498 | struct saa7146_dev *dev = fh->dev; | 1498 | struct saa7146_dev *dev = fh->dev; |
1499 | struct budget_av *budget_av = (struct budget_av *) dev->ext_priv; | 1499 | struct budget_av *budget_av = (struct budget_av *) dev->ext_priv; |
diff --git a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig index f546bccdb997..2663ae39b886 100644 --- a/drivers/media/dvb/ttusb-budget/Kconfig +++ b/drivers/media/dvb/ttusb-budget/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_TTUSB_BUDGET | 1 | config DVB_TTUSB_BUDGET |
2 | tristate "Technotrend/Hauppauge Nova-USB devices" | 2 | tristate "Technotrend/Hauppauge Nova-USB devices" |
3 | depends on DVB_CORE && USB && I2C | 3 | depends on DVB_CORE && USB && I2C && PCI |
4 | select DVB_CX22700 if !DVB_FE_CUSTOMISE | 4 | select DVB_CX22700 if !DVB_FE_CUSTOMISE |
5 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE | 5 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE |
6 | select DVB_VES1820 if !DVB_FE_CUSTOMISE | 6 | select DVB_VES1820 if !DVB_FE_CUSTOMISE |
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig index d5f48a3102bd..290254ab06db 100644 --- a/drivers/media/dvb/ttusb-dec/Kconfig +++ b/drivers/media/dvb/ttusb-dec/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_TTUSB_DEC | 1 | config DVB_TTUSB_DEC |
2 | tristate "Technotrend/Hauppauge USB DEC devices" | 2 | tristate "Technotrend/Hauppauge USB DEC devices" |
3 | depends on DVB_CORE && USB && INPUT | 3 | depends on DVB_CORE && USB && INPUT && PCI |
4 | select CRC32 | 4 | select CRC32 |
5 | help | 5 | help |
6 | Support for external USB adapters designed by Technotrend and | 6 | Support for external USB adapters designed by Technotrend and |
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 5189c4eb439f..3315cac875e5 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -387,4 +387,23 @@ config USB_MR800 | |||
387 | To compile this driver as a module, choose M here: the | 387 | To compile this driver as a module, choose M here: the |
388 | module will be called radio-mr800. | 388 | module will be called radio-mr800. |
389 | 389 | ||
390 | config RADIO_TEA5764 | ||
391 | tristate "TEA5764 I2C FM radio support" | ||
392 | depends on I2C && VIDEO_V4L2 | ||
393 | ---help--- | ||
394 | Say Y here if you want to use the TEA5764 FM chip found in | ||
395 | EZX phones. This FM chip is present in EZX phones from Motorola, | ||
396 | connected to internal pxa I2C bus. | ||
397 | |||
398 | To compile this driver as a module, choose M here: the | ||
399 | module will be called radio-tea5764. | ||
400 | |||
401 | config RADIO_TEA5764_XTAL | ||
402 | bool "TEA5764 crystal reference" | ||
403 | depends on RADIO_TEA5764=y | ||
404 | default y | ||
405 | help | ||
406 | Say Y here if TEA5764 have a 32768 Hz crystal in circuit, say N | ||
407 | here if TEA5764 reference frequency is connected in FREQIN. | ||
408 | |||
390 | endif # RADIO_ADAPTERS | 409 | endif # RADIO_ADAPTERS |
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 240ec63cdafc..0f2b35b3e560 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile | |||
@@ -19,5 +19,6 @@ obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o | |||
19 | obj-$(CONFIG_USB_DSBR) += dsbr100.o | 19 | obj-$(CONFIG_USB_DSBR) += dsbr100.o |
20 | obj-$(CONFIG_USB_SI470X) += radio-si470x.o | 20 | obj-$(CONFIG_USB_SI470X) += radio-si470x.o |
21 | obj-$(CONFIG_USB_MR800) += radio-mr800.o | 21 | obj-$(CONFIG_USB_MR800) += radio-mr800.o |
22 | obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o | ||
22 | 23 | ||
23 | EXTRA_CFLAGS += -Isound | 24 | EXTRA_CFLAGS += -Isound |
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 5474a22c1b22..2014ebc4e984 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -154,8 +154,8 @@ devices, that would be 76 and 91. */ | |||
154 | static int usb_dsbr100_probe(struct usb_interface *intf, | 154 | static int usb_dsbr100_probe(struct usb_interface *intf, |
155 | const struct usb_device_id *id); | 155 | const struct usb_device_id *id); |
156 | static void usb_dsbr100_disconnect(struct usb_interface *intf); | 156 | static void usb_dsbr100_disconnect(struct usb_interface *intf); |
157 | static int usb_dsbr100_open(struct inode *inode, struct file *file); | 157 | static int usb_dsbr100_open(struct file *file); |
158 | static int usb_dsbr100_close(struct inode *inode, struct file *file); | 158 | static int usb_dsbr100_close(struct file *file); |
159 | static int usb_dsbr100_suspend(struct usb_interface *intf, | 159 | static int usb_dsbr100_suspend(struct usb_interface *intf, |
160 | pm_message_t message); | 160 | pm_message_t message); |
161 | static int usb_dsbr100_resume(struct usb_interface *intf); | 161 | static int usb_dsbr100_resume(struct usb_interface *intf); |
@@ -566,7 +566,7 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
566 | return 0; | 566 | return 0; |
567 | } | 567 | } |
568 | 568 | ||
569 | static int usb_dsbr100_open(struct inode *inode, struct file *file) | 569 | static int usb_dsbr100_open(struct file *file) |
570 | { | 570 | { |
571 | struct dsbr100_device *radio = video_drvdata(file); | 571 | struct dsbr100_device *radio = video_drvdata(file); |
572 | int retval; | 572 | int retval; |
@@ -593,7 +593,7 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file) | |||
593 | return 0; | 593 | return 0; |
594 | } | 594 | } |
595 | 595 | ||
596 | static int usb_dsbr100_close(struct inode *inode, struct file *file) | 596 | static int usb_dsbr100_close(struct file *file) |
597 | { | 597 | { |
598 | struct dsbr100_device *radio = video_drvdata(file); | 598 | struct dsbr100_device *radio = video_drvdata(file); |
599 | int retval; | 599 | int retval; |
@@ -653,15 +653,11 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev) | |||
653 | } | 653 | } |
654 | 654 | ||
655 | /* File system interface */ | 655 | /* File system interface */ |
656 | static const struct file_operations usb_dsbr100_fops = { | 656 | static const struct v4l2_file_operations usb_dsbr100_fops = { |
657 | .owner = THIS_MODULE, | 657 | .owner = THIS_MODULE, |
658 | .open = usb_dsbr100_open, | 658 | .open = usb_dsbr100_open, |
659 | .release = usb_dsbr100_close, | 659 | .release = usb_dsbr100_close, |
660 | .ioctl = video_ioctl2, | 660 | .ioctl = video_ioctl2, |
661 | #ifdef CONFIG_COMPAT | ||
662 | .compat_ioctl = v4l_compat_ioctl32, | ||
663 | #endif | ||
664 | .llseek = no_llseek, | ||
665 | }; | 661 | }; |
666 | 662 | ||
667 | static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { | 663 | static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index dd6d3dfcd7d2..bfa13b8b3043 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
@@ -374,26 +374,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
374 | 374 | ||
375 | static struct rt_device rtrack_unit; | 375 | static struct rt_device rtrack_unit; |
376 | 376 | ||
377 | static int rtrack_exclusive_open(struct inode *inode, struct file *file) | 377 | static int rtrack_exclusive_open(struct file *file) |
378 | { | 378 | { |
379 | return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0; | 379 | return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0; |
380 | } | 380 | } |
381 | 381 | ||
382 | static int rtrack_exclusive_release(struct inode *inode, struct file *file) | 382 | static int rtrack_exclusive_release(struct file *file) |
383 | { | 383 | { |
384 | clear_bit(0, &rtrack_unit.in_use); | 384 | clear_bit(0, &rtrack_unit.in_use); |
385 | return 0; | 385 | return 0; |
386 | } | 386 | } |
387 | 387 | ||
388 | static const struct file_operations rtrack_fops = { | 388 | static const struct v4l2_file_operations rtrack_fops = { |
389 | .owner = THIS_MODULE, | 389 | .owner = THIS_MODULE, |
390 | .open = rtrack_exclusive_open, | 390 | .open = rtrack_exclusive_open, |
391 | .release = rtrack_exclusive_release, | 391 | .release = rtrack_exclusive_release, |
392 | .ioctl = video_ioctl2, | 392 | .ioctl = video_ioctl2, |
393 | #ifdef CONFIG_COMPAT | ||
394 | .compat_ioctl = v4l_compat_ioctl32, | ||
395 | #endif | ||
396 | .llseek = no_llseek, | ||
397 | }; | 393 | }; |
398 | 394 | ||
399 | static const struct v4l2_ioctl_ops rtrack_ioctl_ops = { | 395 | static const struct v4l2_ioctl_ops rtrack_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index d78489573230..5604e881e96c 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c | |||
@@ -338,26 +338,22 @@ static int vidioc_s_ctrl (struct file *file, void *priv, | |||
338 | 338 | ||
339 | static struct az_device aztech_unit; | 339 | static struct az_device aztech_unit; |
340 | 340 | ||
341 | static int aztech_exclusive_open(struct inode *inode, struct file *file) | 341 | static int aztech_exclusive_open(struct file *file) |
342 | { | 342 | { |
343 | return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0; | 343 | return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0; |
344 | } | 344 | } |
345 | 345 | ||
346 | static int aztech_exclusive_release(struct inode *inode, struct file *file) | 346 | static int aztech_exclusive_release(struct file *file) |
347 | { | 347 | { |
348 | clear_bit(0, &aztech_unit.in_use); | 348 | clear_bit(0, &aztech_unit.in_use); |
349 | return 0; | 349 | return 0; |
350 | } | 350 | } |
351 | 351 | ||
352 | static const struct file_operations aztech_fops = { | 352 | static const struct v4l2_file_operations aztech_fops = { |
353 | .owner = THIS_MODULE, | 353 | .owner = THIS_MODULE, |
354 | .open = aztech_exclusive_open, | 354 | .open = aztech_exclusive_open, |
355 | .release = aztech_exclusive_release, | 355 | .release = aztech_exclusive_release, |
356 | .ioctl = video_ioctl2, | 356 | .ioctl = video_ioctl2, |
357 | #ifdef CONFIG_COMPAT | ||
358 | .compat_ioctl = v4l_compat_ioctl32, | ||
359 | #endif | ||
360 | .llseek = no_llseek, | ||
361 | }; | 357 | }; |
362 | 358 | ||
363 | static const struct v4l2_ioctl_ops aztech_ioctl_ops = { | 359 | static const struct v4l2_ioctl_ops aztech_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index bfd37f38b9ab..cb3075ac104c 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c | |||
@@ -529,7 +529,7 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
529 | } | 529 | } |
530 | 530 | ||
531 | static int | 531 | static int |
532 | cadet_open(struct inode *inode, struct file *file) | 532 | cadet_open(struct file *file) |
533 | { | 533 | { |
534 | users++; | 534 | users++; |
535 | if (1 == users) init_waitqueue_head(&read_queue); | 535 | if (1 == users) init_waitqueue_head(&read_queue); |
@@ -537,7 +537,7 @@ cadet_open(struct inode *inode, struct file *file) | |||
537 | } | 537 | } |
538 | 538 | ||
539 | static int | 539 | static int |
540 | cadet_release(struct inode *inode, struct file *file) | 540 | cadet_release(struct file *file) |
541 | { | 541 | { |
542 | users--; | 542 | users--; |
543 | if (0 == users){ | 543 | if (0 == users){ |
@@ -557,17 +557,13 @@ cadet_poll(struct file *file, struct poll_table_struct *wait) | |||
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | static const struct file_operations cadet_fops = { | 560 | static const struct v4l2_file_operations cadet_fops = { |
561 | .owner = THIS_MODULE, | 561 | .owner = THIS_MODULE, |
562 | .open = cadet_open, | 562 | .open = cadet_open, |
563 | .release = cadet_release, | 563 | .release = cadet_release, |
564 | .read = cadet_read, | 564 | .read = cadet_read, |
565 | .ioctl = video_ioctl2, | 565 | .ioctl = video_ioctl2, |
566 | .poll = cadet_poll, | 566 | .poll = cadet_poll, |
567 | #ifdef CONFIG_COMPAT | ||
568 | .compat_ioctl = v4l_compat_ioctl32, | ||
569 | #endif | ||
570 | .llseek = no_llseek, | ||
571 | }; | 567 | }; |
572 | 568 | ||
573 | static const struct v4l2_ioctl_ops cadet_ioctl_ops = { | 569 | static const struct v4l2_ioctl_ops cadet_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index e15bee6d7cfc..0c96bf8525b0 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c | |||
@@ -358,26 +358,22 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id ); | |||
358 | 358 | ||
359 | static int mx = 1; | 359 | static int mx = 1; |
360 | 360 | ||
361 | static int gemtek_pci_exclusive_open(struct inode *inode, struct file *file) | 361 | static int gemtek_pci_exclusive_open(struct file *file) |
362 | { | 362 | { |
363 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | 363 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; |
364 | } | 364 | } |
365 | 365 | ||
366 | static int gemtek_pci_exclusive_release(struct inode *inode, struct file *file) | 366 | static int gemtek_pci_exclusive_release(struct file *file) |
367 | { | 367 | { |
368 | clear_bit(0, &in_use); | 368 | clear_bit(0, &in_use); |
369 | return 0; | 369 | return 0; |
370 | } | 370 | } |
371 | 371 | ||
372 | static const struct file_operations gemtek_pci_fops = { | 372 | static const struct v4l2_file_operations gemtek_pci_fops = { |
373 | .owner = THIS_MODULE, | 373 | .owner = THIS_MODULE, |
374 | .open = gemtek_pci_exclusive_open, | 374 | .open = gemtek_pci_exclusive_open, |
375 | .release = gemtek_pci_exclusive_release, | 375 | .release = gemtek_pci_exclusive_release, |
376 | .ioctl = video_ioctl2, | 376 | .ioctl = video_ioctl2, |
377 | #ifdef CONFIG_COMPAT | ||
378 | .compat_ioctl = v4l_compat_ioctl32, | ||
379 | #endif | ||
380 | .llseek = no_llseek, | ||
381 | }; | 377 | }; |
382 | 378 | ||
383 | static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { | 379 | static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index e13118da307b..2b68be773f13 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c | |||
@@ -394,26 +394,22 @@ static struct v4l2_queryctrl radio_qctrl[] = { | |||
394 | } | 394 | } |
395 | }; | 395 | }; |
396 | 396 | ||
397 | static int gemtek_exclusive_open(struct inode *inode, struct file *file) | 397 | static int gemtek_exclusive_open(struct file *file) |
398 | { | 398 | { |
399 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | 399 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; |
400 | } | 400 | } |
401 | 401 | ||
402 | static int gemtek_exclusive_release(struct inode *inode, struct file *file) | 402 | static int gemtek_exclusive_release(struct file *file) |
403 | { | 403 | { |
404 | clear_bit(0, &in_use); | 404 | clear_bit(0, &in_use); |
405 | return 0; | 405 | return 0; |
406 | } | 406 | } |
407 | 407 | ||
408 | static const struct file_operations gemtek_fops = { | 408 | static const struct v4l2_file_operations gemtek_fops = { |
409 | .owner = THIS_MODULE, | 409 | .owner = THIS_MODULE, |
410 | .open = gemtek_exclusive_open, | 410 | .open = gemtek_exclusive_open, |
411 | .release = gemtek_exclusive_release, | 411 | .release = gemtek_exclusive_release, |
412 | .ioctl = video_ioctl2, | 412 | .ioctl = video_ioctl2, |
413 | #ifdef CONFIG_COMPAT | ||
414 | .compat_ioctl = v4l_compat_ioctl32, | ||
415 | #endif | ||
416 | .llseek = no_llseek | ||
417 | }; | 413 | }; |
418 | 414 | ||
419 | static int vidioc_querycap(struct file *file, void *priv, | 415 | static int vidioc_querycap(struct file *file, void *priv, |
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 4bf4d007bcfa..ba3a13a90013 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -79,12 +79,12 @@ static unsigned long in_use; | |||
79 | 79 | ||
80 | static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); | 80 | static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); |
81 | 81 | ||
82 | static int maestro_exclusive_open(struct inode *inode, struct file *file) | 82 | static int maestro_exclusive_open(struct file *file) |
83 | { | 83 | { |
84 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | 84 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int maestro_exclusive_release(struct inode *inode, struct file *file) | 87 | static int maestro_exclusive_release(struct file *file) |
88 | { | 88 | { |
89 | clear_bit(0, &in_use); | 89 | clear_bit(0, &in_use); |
90 | return 0; | 90 | return 0; |
@@ -110,15 +110,11 @@ static struct pci_driver maestro_r_driver = { | |||
110 | .remove = __devexit_p(maestro_remove), | 110 | .remove = __devexit_p(maestro_remove), |
111 | }; | 111 | }; |
112 | 112 | ||
113 | static const struct file_operations maestro_fops = { | 113 | static const struct v4l2_file_operations maestro_fops = { |
114 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
115 | .open = maestro_exclusive_open, | 115 | .open = maestro_exclusive_open, |
116 | .release = maestro_exclusive_release, | 116 | .release = maestro_exclusive_release, |
117 | .ioctl = video_ioctl2, | 117 | .ioctl = video_ioctl2, |
118 | #ifdef CONFIG_COMPAT | ||
119 | .compat_ioctl = v4l_compat_ioctl32, | ||
120 | #endif | ||
121 | .llseek = no_llseek, | ||
122 | }; | 118 | }; |
123 | 119 | ||
124 | struct radio_device { | 120 | struct radio_device { |
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index c777a17b00bc..c5dc00aa9c9f 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -100,26 +100,22 @@ static unsigned long in_use; | |||
100 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) | 100 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) |
101 | 101 | ||
102 | 102 | ||
103 | static int maxiradio_exclusive_open(struct inode *inode, struct file *file) | 103 | static int maxiradio_exclusive_open(struct file *file) |
104 | { | 104 | { |
105 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | 105 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | static int maxiradio_exclusive_release(struct inode *inode, struct file *file) | 108 | static int maxiradio_exclusive_release(struct file *file) |
109 | { | 109 | { |
110 | clear_bit(0, &in_use); | 110 | clear_bit(0, &in_use); |
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | static const struct file_operations maxiradio_fops = { | 114 | static const struct v4l2_file_operations maxiradio_fops = { |
115 | .owner = THIS_MODULE, | 115 | .owner = THIS_MODULE, |
116 | .open = maxiradio_exclusive_open, | 116 | .open = maxiradio_exclusive_open, |
117 | .release = maxiradio_exclusive_release, | 117 | .release = maxiradio_exclusive_release, |
118 | .ioctl = video_ioctl2, | 118 | .ioctl = video_ioctl2, |
119 | #ifdef CONFIG_COMPAT | ||
120 | .compat_ioctl = v4l_compat_ioctl32, | ||
121 | #endif | ||
122 | .llseek = no_llseek, | ||
123 | }; | 119 | }; |
124 | 120 | ||
125 | static struct radio_device | 121 | static struct radio_device |
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index e730eddb2bb5..0747dc8862b0 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c | |||
@@ -127,8 +127,8 @@ static struct v4l2_queryctrl radio_qctrl[] = { | |||
127 | static int usb_amradio_probe(struct usb_interface *intf, | 127 | static int usb_amradio_probe(struct usb_interface *intf, |
128 | const struct usb_device_id *id); | 128 | const struct usb_device_id *id); |
129 | static void usb_amradio_disconnect(struct usb_interface *intf); | 129 | static void usb_amradio_disconnect(struct usb_interface *intf); |
130 | static int usb_amradio_open(struct inode *inode, struct file *file); | 130 | static int usb_amradio_open(struct file *file); |
131 | static int usb_amradio_close(struct inode *inode, struct file *file); | 131 | static int usb_amradio_close(struct file *file); |
132 | static int usb_amradio_suspend(struct usb_interface *intf, | 132 | static int usb_amradio_suspend(struct usb_interface *intf, |
133 | pm_message_t message); | 133 | pm_message_t message); |
134 | static int usb_amradio_resume(struct usb_interface *intf); | 134 | static int usb_amradio_resume(struct usb_interface *intf); |
@@ -500,7 +500,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | |||
500 | } | 500 | } |
501 | 501 | ||
502 | /* open device - amradio_start() and amradio_setfreq() */ | 502 | /* open device - amradio_start() and amradio_setfreq() */ |
503 | static int usb_amradio_open(struct inode *inode, struct file *file) | 503 | static int usb_amradio_open(struct file *file) |
504 | { | 504 | { |
505 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 505 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); |
506 | 506 | ||
@@ -525,7 +525,7 @@ static int usb_amradio_open(struct inode *inode, struct file *file) | |||
525 | } | 525 | } |
526 | 526 | ||
527 | /*close device */ | 527 | /*close device */ |
528 | static int usb_amradio_close(struct inode *inode, struct file *file) | 528 | static int usb_amradio_close(struct file *file) |
529 | { | 529 | { |
530 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 530 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); |
531 | int retval; | 531 | int retval; |
@@ -572,15 +572,11 @@ static int usb_amradio_resume(struct usb_interface *intf) | |||
572 | } | 572 | } |
573 | 573 | ||
574 | /* File system interface */ | 574 | /* File system interface */ |
575 | static const struct file_operations usb_amradio_fops = { | 575 | static const struct v4l2_file_operations usb_amradio_fops = { |
576 | .owner = THIS_MODULE, | 576 | .owner = THIS_MODULE, |
577 | .open = usb_amradio_open, | 577 | .open = usb_amradio_open, |
578 | .release = usb_amradio_close, | 578 | .release = usb_amradio_close, |
579 | .ioctl = video_ioctl2, | 579 | .ioctl = video_ioctl2, |
580 | #ifdef CONFIG_COMPAT | ||
581 | .compat_ioctl = v4l_compat_ioctl32, | ||
582 | #endif | ||
583 | .llseek = no_llseek, | ||
584 | }; | 580 | }; |
585 | 581 | ||
586 | static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { | 582 | static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index 7704f243b6f0..2587227214bf 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c | |||
@@ -280,26 +280,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
280 | 280 | ||
281 | static struct rt_device rtrack2_unit; | 281 | static struct rt_device rtrack2_unit; |
282 | 282 | ||
283 | static int rtrack2_exclusive_open(struct inode *inode, struct file *file) | 283 | static int rtrack2_exclusive_open(struct file *file) |
284 | { | 284 | { |
285 | return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0; | 285 | return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static int rtrack2_exclusive_release(struct inode *inode, struct file *file) | 288 | static int rtrack2_exclusive_release(struct file *file) |
289 | { | 289 | { |
290 | clear_bit(0, &rtrack2_unit.in_use); | 290 | clear_bit(0, &rtrack2_unit.in_use); |
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | static const struct file_operations rtrack2_fops = { | 294 | static const struct v4l2_file_operations rtrack2_fops = { |
295 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
296 | .open = rtrack2_exclusive_open, | 296 | .open = rtrack2_exclusive_open, |
297 | .release = rtrack2_exclusive_release, | 297 | .release = rtrack2_exclusive_release, |
298 | .ioctl = video_ioctl2, | 298 | .ioctl = video_ioctl2, |
299 | #ifdef CONFIG_COMPAT | ||
300 | .compat_ioctl = v4l_compat_ioctl32, | ||
301 | #endif | ||
302 | .llseek = no_llseek, | ||
303 | }; | 299 | }; |
304 | 300 | ||
305 | static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = { | 301 | static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 834d43651c70..d358e48c2422 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -280,26 +280,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
280 | 280 | ||
281 | static struct fmi_device fmi_unit; | 281 | static struct fmi_device fmi_unit; |
282 | 282 | ||
283 | static int fmi_exclusive_open(struct inode *inode, struct file *file) | 283 | static int fmi_exclusive_open(struct file *file) |
284 | { | 284 | { |
285 | return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0; | 285 | return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static int fmi_exclusive_release(struct inode *inode, struct file *file) | 288 | static int fmi_exclusive_release(struct file *file) |
289 | { | 289 | { |
290 | clear_bit(0, &fmi_unit.in_use); | 290 | clear_bit(0, &fmi_unit.in_use); |
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | static const struct file_operations fmi_fops = { | 294 | static const struct v4l2_file_operations fmi_fops = { |
295 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
296 | .open = fmi_exclusive_open, | 296 | .open = fmi_exclusive_open, |
297 | .release = fmi_exclusive_release, | 297 | .release = fmi_exclusive_release, |
298 | .ioctl = video_ioctl2, | 298 | .ioctl = video_ioctl2, |
299 | #ifdef CONFIG_COMPAT | ||
300 | .compat_ioctl = v4l_compat_ioctl32, | ||
301 | #endif | ||
302 | .llseek = no_llseek, | ||
303 | }; | 299 | }; |
304 | 300 | ||
305 | static const struct v4l2_ioctl_ops fmi_ioctl_ops = { | 301 | static const struct v4l2_ioctl_ops fmi_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index b1f47c322e02..92f17a347fa7 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c | |||
@@ -396,26 +396,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
396 | 396 | ||
397 | static struct fmr2_device fmr2_unit; | 397 | static struct fmr2_device fmr2_unit; |
398 | 398 | ||
399 | static int fmr2_exclusive_open(struct inode *inode, struct file *file) | 399 | static int fmr2_exclusive_open(struct file *file) |
400 | { | 400 | { |
401 | return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0; | 401 | return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0; |
402 | } | 402 | } |
403 | 403 | ||
404 | static int fmr2_exclusive_release(struct inode *inode, struct file *file) | 404 | static int fmr2_exclusive_release(struct file *file) |
405 | { | 405 | { |
406 | clear_bit(0, &fmr2_unit.in_use); | 406 | clear_bit(0, &fmr2_unit.in_use); |
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | static const struct file_operations fmr2_fops = { | 410 | static const struct v4l2_file_operations fmr2_fops = { |
411 | .owner = THIS_MODULE, | 411 | .owner = THIS_MODULE, |
412 | .open = fmr2_exclusive_open, | 412 | .open = fmr2_exclusive_open, |
413 | .release = fmr2_exclusive_release, | 413 | .release = fmr2_exclusive_release, |
414 | .ioctl = video_ioctl2, | 414 | .ioctl = video_ioctl2, |
415 | #ifdef CONFIG_COMPAT | ||
416 | .compat_ioctl = v4l_compat_ioctl32, | ||
417 | #endif | ||
418 | .llseek = no_llseek, | ||
419 | }; | 415 | }; |
420 | 416 | ||
421 | static const struct v4l2_ioctl_ops fmr2_ioctl_ops = { | 417 | static const struct v4l2_ioctl_ops fmr2_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 3e1830293de5..67cbce82cb91 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -96,6 +96,8 @@ | |||
96 | * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com> | 96 | * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com> |
97 | * - add support for KWorld USB FM Radio FM700 | 97 | * - add support for KWorld USB FM Radio FM700 |
98 | * - blacklisted KWorld radio in hid-core.c and hid-ids.h | 98 | * - blacklisted KWorld radio in hid-core.c and hid-ids.h |
99 | * 2008-12-03 Mark Lord <mlord@pobox.com> | ||
100 | * - add support for DealExtreme USB Radio | ||
99 | * | 101 | * |
100 | * ToDo: | 102 | * ToDo: |
101 | * - add firmware download/update support | 103 | * - add firmware download/update support |
@@ -138,6 +140,8 @@ static struct usb_device_id si470x_usb_driver_id_table[] = { | |||
138 | { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, | 140 | { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, |
139 | /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */ | 141 | /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */ |
140 | { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) }, | 142 | { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) }, |
143 | /* DealExtreme USB Radio */ | ||
144 | { USB_DEVICE_AND_INTERFACE_INFO(0x10c5, 0x819a, USB_CLASS_HID, 0, 0) }, | ||
141 | /* Terminating entry */ | 145 | /* Terminating entry */ |
142 | { } | 146 | { } |
143 | }; | 147 | }; |
@@ -1075,7 +1079,7 @@ static unsigned int si470x_fops_poll(struct file *file, | |||
1075 | /* | 1079 | /* |
1076 | * si470x_fops_open - file open | 1080 | * si470x_fops_open - file open |
1077 | */ | 1081 | */ |
1078 | static int si470x_fops_open(struct inode *inode, struct file *file) | 1082 | static int si470x_fops_open(struct file *file) |
1079 | { | 1083 | { |
1080 | struct si470x_device *radio = video_drvdata(file); | 1084 | struct si470x_device *radio = video_drvdata(file); |
1081 | int retval; | 1085 | int retval; |
@@ -1105,7 +1109,7 @@ done: | |||
1105 | /* | 1109 | /* |
1106 | * si470x_fops_release - file release | 1110 | * si470x_fops_release - file release |
1107 | */ | 1111 | */ |
1108 | static int si470x_fops_release(struct inode *inode, struct file *file) | 1112 | static int si470x_fops_release(struct file *file) |
1109 | { | 1113 | { |
1110 | struct si470x_device *radio = video_drvdata(file); | 1114 | struct si470x_device *radio = video_drvdata(file); |
1111 | int retval = 0; | 1115 | int retval = 0; |
@@ -1147,15 +1151,11 @@ done: | |||
1147 | /* | 1151 | /* |
1148 | * si470x_fops - file operations interface | 1152 | * si470x_fops - file operations interface |
1149 | */ | 1153 | */ |
1150 | static const struct file_operations si470x_fops = { | 1154 | static const struct v4l2_file_operations si470x_fops = { |
1151 | .owner = THIS_MODULE, | 1155 | .owner = THIS_MODULE, |
1152 | .llseek = no_llseek, | ||
1153 | .read = si470x_fops_read, | 1156 | .read = si470x_fops_read, |
1154 | .poll = si470x_fops_poll, | 1157 | .poll = si470x_fops_poll, |
1155 | .ioctl = video_ioctl2, | 1158 | .ioctl = video_ioctl2, |
1156 | #ifdef CONFIG_COMPAT | ||
1157 | .compat_ioctl = v4l_compat_ioctl32, | ||
1158 | #endif | ||
1159 | .open = si470x_fops_open, | 1159 | .open = si470x_fops_open, |
1160 | .release = si470x_fops_release, | 1160 | .release = si470x_fops_release, |
1161 | }; | 1161 | }; |
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c new file mode 100644 index 000000000000..4d35308fc1ff --- /dev/null +++ b/drivers/media/radio/radio-tea5764.c | |||
@@ -0,0 +1,634 @@ | |||
1 | /* | ||
2 | * driver/media/radio/radio-tea5764.c | ||
3 | * | ||
4 | * Driver for TEA5764 radio chip for linux 2.6. | ||
5 | * This driver is for TEA5764 chip from NXP, used in EZX phones from Motorola. | ||
6 | * The I2C protocol is used for communicate with chip. | ||
7 | * | ||
8 | * Based in radio-tea5761.c Copyright (C) 2005 Nokia Corporation | ||
9 | * | ||
10 | * Copyright (c) 2008 Fabio Belavenuto <belavenuto@gmail.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | * History: | ||
27 | * 2008-12-06 Fabio Belavenuto <belavenuto@gmail.com> | ||
28 | * initial code | ||
29 | * | ||
30 | * TODO: | ||
31 | * add platform_data support for IRQs platform dependencies | ||
32 | * add RDS support | ||
33 | */ | ||
34 | #include <linux/kernel.h> | ||
35 | #include <linux/module.h> | ||
36 | #include <linux/init.h> /* Initdata */ | ||
37 | #include <linux/videodev2.h> /* kernel radio structs */ | ||
38 | #include <linux/i2c.h> /* I2C */ | ||
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-ioctl.h> | ||
41 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
42 | |||
43 | #define DRIVER_VERSION "v0.01" | ||
44 | #define RADIO_VERSION KERNEL_VERSION(0, 0, 1) | ||
45 | |||
46 | #define DRIVER_AUTHOR "Fabio Belavenuto <belavenuto@gmail.com>" | ||
47 | #define DRIVER_DESC "A driver for the TEA5764 radio chip for EZX Phones." | ||
48 | |||
49 | #define PINFO(format, ...)\ | ||
50 | printk(KERN_INFO KBUILD_MODNAME ": "\ | ||
51 | DRIVER_VERSION ": " format "\n", ## __VA_ARGS__) | ||
52 | #define PWARN(format, ...)\ | ||
53 | printk(KERN_WARNING KBUILD_MODNAME ": "\ | ||
54 | DRIVER_VERSION ": " format "\n", ## __VA_ARGS__) | ||
55 | # define PDEBUG(format, ...)\ | ||
56 | printk(KERN_DEBUG KBUILD_MODNAME ": "\ | ||
57 | DRIVER_VERSION ": " format "\n", ## __VA_ARGS__) | ||
58 | |||
59 | /* Frequency limits in MHz -- these are European values. For Japanese | ||
60 | devices, that would be 76000 and 91000. */ | ||
61 | #define FREQ_MIN 87500 | ||
62 | #define FREQ_MAX 108000 | ||
63 | #define FREQ_MUL 16 | ||
64 | |||
65 | /* TEA5764 registers */ | ||
66 | #define TEA5764_MANID 0x002b | ||
67 | #define TEA5764_CHIPID 0x5764 | ||
68 | |||
69 | #define TEA5764_INTREG_BLMSK 0x0001 | ||
70 | #define TEA5764_INTREG_FRRMSK 0x0002 | ||
71 | #define TEA5764_INTREG_LEVMSK 0x0008 | ||
72 | #define TEA5764_INTREG_IFMSK 0x0010 | ||
73 | #define TEA5764_INTREG_BLMFLAG 0x0100 | ||
74 | #define TEA5764_INTREG_FRRFLAG 0x0200 | ||
75 | #define TEA5764_INTREG_LEVFLAG 0x0800 | ||
76 | #define TEA5764_INTREG_IFFLAG 0x1000 | ||
77 | |||
78 | #define TEA5764_FRQSET_SUD 0x8000 | ||
79 | #define TEA5764_FRQSET_SM 0x4000 | ||
80 | |||
81 | #define TEA5764_TNCTRL_PUPD1 0x8000 | ||
82 | #define TEA5764_TNCTRL_PUPD0 0x4000 | ||
83 | #define TEA5764_TNCTRL_BLIM 0x2000 | ||
84 | #define TEA5764_TNCTRL_SWPM 0x1000 | ||
85 | #define TEA5764_TNCTRL_IFCTC 0x0800 | ||
86 | #define TEA5764_TNCTRL_AFM 0x0400 | ||
87 | #define TEA5764_TNCTRL_SMUTE 0x0200 | ||
88 | #define TEA5764_TNCTRL_SNC 0x0100 | ||
89 | #define TEA5764_TNCTRL_MU 0x0080 | ||
90 | #define TEA5764_TNCTRL_SSL1 0x0040 | ||
91 | #define TEA5764_TNCTRL_SSL0 0x0020 | ||
92 | #define TEA5764_TNCTRL_HLSI 0x0010 | ||
93 | #define TEA5764_TNCTRL_MST 0x0008 | ||
94 | #define TEA5764_TNCTRL_SWP 0x0004 | ||
95 | #define TEA5764_TNCTRL_DTC 0x0002 | ||
96 | #define TEA5764_TNCTRL_AHLSI 0x0001 | ||
97 | |||
98 | #define TEA5764_TUNCHK_LEVEL(x) (((x) & 0x00F0) >> 4) | ||
99 | #define TEA5764_TUNCHK_IFCNT(x) (((x) & 0xFE00) >> 9) | ||
100 | #define TEA5764_TUNCHK_TUNTO 0x0100 | ||
101 | #define TEA5764_TUNCHK_LD 0x0008 | ||
102 | #define TEA5764_TUNCHK_STEREO 0x0004 | ||
103 | |||
104 | #define TEA5764_TESTREG_TRIGFR 0x0800 | ||
105 | |||
106 | struct tea5764_regs { | ||
107 | u16 intreg; /* INTFLAG & INTMSK */ | ||
108 | u16 frqset; /* FRQSETMSB & FRQSETLSB */ | ||
109 | u16 tnctrl; /* TNCTRL1 & TNCTRL2 */ | ||
110 | u16 frqchk; /* FRQCHKMSB & FRQCHKLSB */ | ||
111 | u16 tunchk; /* IFCHK & LEVCHK */ | ||
112 | u16 testreg; /* TESTBITS & TESTMODE */ | ||
113 | u16 rdsstat; /* RDSSTAT1 & RDSSTAT2 */ | ||
114 | u16 rdslb; /* RDSLBMSB & RDSLBLSB */ | ||
115 | u16 rdspb; /* RDSPBMSB & RDSPBLSB */ | ||
116 | u16 rdsbc; /* RDSBBC & RDSGBC */ | ||
117 | u16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */ | ||
118 | u16 rdsbbl; /* PAUSEDET & RDSBBL */ | ||
119 | u16 manid; /* MANID1 & MANID2 */ | ||
120 | u16 chipid; /* CHIPID1 & CHIPID2 */ | ||
121 | } __attribute__ ((packed)); | ||
122 | |||
123 | struct tea5764_write_regs { | ||
124 | u8 intreg; /* INTMSK */ | ||
125 | u16 frqset; /* FRQSETMSB & FRQSETLSB */ | ||
126 | u16 tnctrl; /* TNCTRL1 & TNCTRL2 */ | ||
127 | u16 testreg; /* TESTBITS & TESTMODE */ | ||
128 | u16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */ | ||
129 | u16 rdsbbl; /* PAUSEDET & RDSBBL */ | ||
130 | } __attribute__ ((packed)); | ||
131 | |||
132 | #ifndef RADIO_TEA5764_XTAL | ||
133 | #define RADIO_TEA5764_XTAL 1 | ||
134 | #endif | ||
135 | |||
136 | static int radio_nr = -1; | ||
137 | static int use_xtal = RADIO_TEA5764_XTAL; | ||
138 | |||
139 | struct tea5764_device { | ||
140 | struct i2c_client *i2c_client; | ||
141 | struct video_device *videodev; | ||
142 | struct tea5764_regs regs; | ||
143 | struct mutex mutex; | ||
144 | int users; | ||
145 | }; | ||
146 | |||
147 | /* I2C code related */ | ||
148 | int tea5764_i2c_read(struct tea5764_device *radio) | ||
149 | { | ||
150 | int i; | ||
151 | u16 *p = (u16 *) &radio->regs; | ||
152 | |||
153 | struct i2c_msg msgs[1] = { | ||
154 | { radio->i2c_client->addr, I2C_M_RD, sizeof(radio->regs), | ||
155 | (void *)&radio->regs }, | ||
156 | }; | ||
157 | if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1) | ||
158 | return -EIO; | ||
159 | for (i = 0; i < sizeof(struct tea5764_regs) / sizeof(u16); i++) | ||
160 | p[i] = __be16_to_cpu(p[i]); | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | int tea5764_i2c_write(struct tea5764_device *radio) | ||
166 | { | ||
167 | struct tea5764_write_regs wr; | ||
168 | struct tea5764_regs *r = &radio->regs; | ||
169 | struct i2c_msg msgs[1] = { | ||
170 | { radio->i2c_client->addr, 0, sizeof(wr), (void *) &wr }, | ||
171 | }; | ||
172 | wr.intreg = r->intreg & 0xff; | ||
173 | wr.frqset = __cpu_to_be16(r->frqset); | ||
174 | wr.tnctrl = __cpu_to_be16(r->tnctrl); | ||
175 | wr.testreg = __cpu_to_be16(r->testreg); | ||
176 | wr.rdsctrl = __cpu_to_be16(r->rdsctrl); | ||
177 | wr.rdsbbl = __cpu_to_be16(r->rdsbbl); | ||
178 | if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1) | ||
179 | return -EIO; | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | /* V4L2 code related */ | ||
184 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
185 | { | ||
186 | .id = V4L2_CID_AUDIO_MUTE, | ||
187 | .name = "Mute", | ||
188 | .minimum = 0, | ||
189 | .maximum = 1, | ||
190 | .default_value = 1, | ||
191 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
192 | } | ||
193 | }; | ||
194 | |||
195 | static void tea5764_power_up(struct tea5764_device *radio) | ||
196 | { | ||
197 | struct tea5764_regs *r = &radio->regs; | ||
198 | |||
199 | if (!(r->tnctrl & TEA5764_TNCTRL_PUPD0)) { | ||
200 | r->tnctrl &= ~(TEA5764_TNCTRL_AFM | TEA5764_TNCTRL_MU | | ||
201 | TEA5764_TNCTRL_HLSI); | ||
202 | if (!use_xtal) | ||
203 | r->testreg |= TEA5764_TESTREG_TRIGFR; | ||
204 | else | ||
205 | r->testreg &= ~TEA5764_TESTREG_TRIGFR; | ||
206 | |||
207 | r->tnctrl |= TEA5764_TNCTRL_PUPD0; | ||
208 | tea5764_i2c_write(radio); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | static void tea5764_power_down(struct tea5764_device *radio) | ||
213 | { | ||
214 | struct tea5764_regs *r = &radio->regs; | ||
215 | |||
216 | if (r->tnctrl & TEA5764_TNCTRL_PUPD0) { | ||
217 | r->tnctrl &= ~TEA5764_TNCTRL_PUPD0; | ||
218 | tea5764_i2c_write(radio); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | static void tea5764_set_freq(struct tea5764_device *radio, int freq) | ||
223 | { | ||
224 | struct tea5764_regs *r = &radio->regs; | ||
225 | |||
226 | /* formula: (freq [+ or -] 225000) / 8192 */ | ||
227 | if (r->tnctrl & TEA5764_TNCTRL_HLSI) | ||
228 | r->frqset = (freq + 225000) / 8192; | ||
229 | else | ||
230 | r->frqset = (freq - 225000) / 8192; | ||
231 | } | ||
232 | |||
233 | static int tea5764_get_freq(struct tea5764_device *radio) | ||
234 | { | ||
235 | struct tea5764_regs *r = &radio->regs; | ||
236 | |||
237 | if (r->tnctrl & TEA5764_TNCTRL_HLSI) | ||
238 | return (r->frqchk * 8192) - 225000; | ||
239 | else | ||
240 | return (r->frqchk * 8192) + 225000; | ||
241 | } | ||
242 | |||
243 | /* tune an frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ | ||
244 | static void tea5764_tune(struct tea5764_device *radio, int freq) | ||
245 | { | ||
246 | tea5764_set_freq(radio, freq); | ||
247 | if (tea5764_i2c_write(radio)) | ||
248 | PWARN("Could not set frequency!"); | ||
249 | } | ||
250 | |||
251 | static void tea5764_set_audout_mode(struct tea5764_device *radio, int audmode) | ||
252 | { | ||
253 | struct tea5764_regs *r = &radio->regs; | ||
254 | int tnctrl = r->tnctrl; | ||
255 | |||
256 | if (audmode == V4L2_TUNER_MODE_MONO) | ||
257 | r->tnctrl |= TEA5764_TNCTRL_MST; | ||
258 | else | ||
259 | r->tnctrl &= ~TEA5764_TNCTRL_MST; | ||
260 | if (tnctrl != r->tnctrl) | ||
261 | tea5764_i2c_write(radio); | ||
262 | } | ||
263 | |||
264 | static int tea5764_get_audout_mode(struct tea5764_device *radio) | ||
265 | { | ||
266 | struct tea5764_regs *r = &radio->regs; | ||
267 | |||
268 | if (r->tnctrl & TEA5764_TNCTRL_MST) | ||
269 | return V4L2_TUNER_MODE_MONO; | ||
270 | else | ||
271 | return V4L2_TUNER_MODE_STEREO; | ||
272 | } | ||
273 | |||
274 | static void tea5764_mute(struct tea5764_device *radio, int on) | ||
275 | { | ||
276 | struct tea5764_regs *r = &radio->regs; | ||
277 | int tnctrl = r->tnctrl; | ||
278 | |||
279 | if (on) | ||
280 | r->tnctrl |= TEA5764_TNCTRL_MU; | ||
281 | else | ||
282 | r->tnctrl &= ~TEA5764_TNCTRL_MU; | ||
283 | if (tnctrl != r->tnctrl) | ||
284 | tea5764_i2c_write(radio); | ||
285 | } | ||
286 | |||
287 | static int tea5764_is_muted(struct tea5764_device *radio) | ||
288 | { | ||
289 | return radio->regs.tnctrl & TEA5764_TNCTRL_MU; | ||
290 | } | ||
291 | |||
292 | /* V4L2 vidioc */ | ||
293 | static int vidioc_querycap(struct file *file, void *priv, | ||
294 | struct v4l2_capability *v) | ||
295 | { | ||
296 | struct tea5764_device *radio = video_drvdata(file); | ||
297 | struct video_device *dev = radio->videodev; | ||
298 | |||
299 | strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); | ||
300 | strlcpy(v->card, dev->name, sizeof(v->card)); | ||
301 | snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev->dev.bus_id); | ||
302 | v->version = RADIO_VERSION; | ||
303 | v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int vidioc_g_tuner(struct file *file, void *priv, | ||
308 | struct v4l2_tuner *v) | ||
309 | { | ||
310 | struct tea5764_device *radio = video_drvdata(file); | ||
311 | struct tea5764_regs *r = &radio->regs; | ||
312 | |||
313 | if (v->index > 0) | ||
314 | return -EINVAL; | ||
315 | |||
316 | memset(v, 0, sizeof(v)); | ||
317 | strcpy(v->name, "FM"); | ||
318 | v->type = V4L2_TUNER_RADIO; | ||
319 | tea5764_i2c_read(radio); | ||
320 | v->rangelow = FREQ_MIN * FREQ_MUL; | ||
321 | v->rangehigh = FREQ_MAX * FREQ_MUL; | ||
322 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | ||
323 | if (r->tunchk & TEA5764_TUNCHK_STEREO) | ||
324 | v->rxsubchans = V4L2_TUNER_SUB_STEREO; | ||
325 | v->audmode = tea5764_get_audout_mode(radio); | ||
326 | v->signal = TEA5764_TUNCHK_LEVEL(r->tunchk) * 0xffff / 0xf; | ||
327 | v->afc = TEA5764_TUNCHK_IFCNT(r->tunchk); | ||
328 | |||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | static int vidioc_s_tuner(struct file *file, void *priv, | ||
333 | struct v4l2_tuner *v) | ||
334 | { | ||
335 | struct tea5764_device *radio = video_drvdata(file); | ||
336 | |||
337 | if (v->index > 0) | ||
338 | return -EINVAL; | ||
339 | |||
340 | tea5764_set_audout_mode(radio, v->audmode); | ||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | static int vidioc_s_frequency(struct file *file, void *priv, | ||
345 | struct v4l2_frequency *f) | ||
346 | { | ||
347 | struct tea5764_device *radio = video_drvdata(file); | ||
348 | |||
349 | if (f->tuner != 0) | ||
350 | return -EINVAL; | ||
351 | if (f->frequency == 0) { | ||
352 | /* We special case this as a power down control. */ | ||
353 | tea5764_power_down(radio); | ||
354 | } | ||
355 | if (f->frequency < (FREQ_MIN * FREQ_MUL)) | ||
356 | return -EINVAL; | ||
357 | if (f->frequency > (FREQ_MAX * FREQ_MUL)) | ||
358 | return -EINVAL; | ||
359 | tea5764_power_up(radio); | ||
360 | tea5764_tune(radio, (f->frequency * 125) / 2); | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static int vidioc_g_frequency(struct file *file, void *priv, | ||
365 | struct v4l2_frequency *f) | ||
366 | { | ||
367 | struct tea5764_device *radio = video_drvdata(file); | ||
368 | struct tea5764_regs *r = &radio->regs; | ||
369 | |||
370 | tea5764_i2c_read(radio); | ||
371 | memset(f, 0, sizeof(f)); | ||
372 | f->type = V4L2_TUNER_RADIO; | ||
373 | if (r->tnctrl & TEA5764_TNCTRL_PUPD0) | ||
374 | f->frequency = (tea5764_get_freq(radio) * 2) / 125; | ||
375 | else | ||
376 | f->frequency = 0; | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
382 | struct v4l2_queryctrl *qc) | ||
383 | { | ||
384 | int i; | ||
385 | |||
386 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
387 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
388 | memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); | ||
389 | return 0; | ||
390 | } | ||
391 | } | ||
392 | return -EINVAL; | ||
393 | } | ||
394 | |||
395 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
396 | struct v4l2_control *ctrl) | ||
397 | { | ||
398 | struct tea5764_device *radio = video_drvdata(file); | ||
399 | |||
400 | switch (ctrl->id) { | ||
401 | case V4L2_CID_AUDIO_MUTE: | ||
402 | tea5764_i2c_read(radio); | ||
403 | ctrl->value = tea5764_is_muted(radio) ? 1 : 0; | ||
404 | return 0; | ||
405 | } | ||
406 | return -EINVAL; | ||
407 | } | ||
408 | |||
409 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
410 | struct v4l2_control *ctrl) | ||
411 | { | ||
412 | struct tea5764_device *radio = video_drvdata(file); | ||
413 | |||
414 | switch (ctrl->id) { | ||
415 | case V4L2_CID_AUDIO_MUTE: | ||
416 | tea5764_mute(radio, ctrl->value); | ||
417 | return 0; | ||
418 | } | ||
419 | return -EINVAL; | ||
420 | } | ||
421 | |||
422 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
423 | { | ||
424 | *i = 0; | ||
425 | return 0; | ||
426 | } | ||
427 | |||
428 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
429 | { | ||
430 | if (i != 0) | ||
431 | return -EINVAL; | ||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | static int vidioc_g_audio(struct file *file, void *priv, | ||
436 | struct v4l2_audio *a) | ||
437 | { | ||
438 | if (a->index > 1) | ||
439 | return -EINVAL; | ||
440 | |||
441 | strcpy(a->name, "Radio"); | ||
442 | a->capability = V4L2_AUDCAP_STEREO; | ||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | static int vidioc_s_audio(struct file *file, void *priv, | ||
447 | struct v4l2_audio *a) | ||
448 | { | ||
449 | if (a->index != 0) | ||
450 | return -EINVAL; | ||
451 | |||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int tea5764_open(struct file *file) | ||
456 | { | ||
457 | /* Currently we support only one device */ | ||
458 | int minor = video_devdata(file)->minor; | ||
459 | struct tea5764_device *radio = video_drvdata(file); | ||
460 | |||
461 | if (radio->videodev->minor != minor) | ||
462 | return -ENODEV; | ||
463 | |||
464 | mutex_lock(&radio->mutex); | ||
465 | /* Only exclusive access */ | ||
466 | if (radio->users) { | ||
467 | mutex_unlock(&radio->mutex); | ||
468 | return -EBUSY; | ||
469 | } | ||
470 | radio->users++; | ||
471 | mutex_unlock(&radio->mutex); | ||
472 | file->private_data = radio; | ||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static int tea5764_close(struct file *file) | ||
477 | { | ||
478 | struct tea5764_device *radio = video_drvdata(file); | ||
479 | |||
480 | if (!radio) | ||
481 | return -ENODEV; | ||
482 | mutex_lock(&radio->mutex); | ||
483 | radio->users--; | ||
484 | mutex_unlock(&radio->mutex); | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | /* File system interface */ | ||
489 | static const struct v4l2_file_operations tea5764_fops = { | ||
490 | .owner = THIS_MODULE, | ||
491 | .open = tea5764_open, | ||
492 | .release = tea5764_close, | ||
493 | .ioctl = video_ioctl2, | ||
494 | }; | ||
495 | |||
496 | static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { | ||
497 | .vidioc_querycap = vidioc_querycap, | ||
498 | .vidioc_g_tuner = vidioc_g_tuner, | ||
499 | .vidioc_s_tuner = vidioc_s_tuner, | ||
500 | .vidioc_g_audio = vidioc_g_audio, | ||
501 | .vidioc_s_audio = vidioc_s_audio, | ||
502 | .vidioc_g_input = vidioc_g_input, | ||
503 | .vidioc_s_input = vidioc_s_input, | ||
504 | .vidioc_g_frequency = vidioc_g_frequency, | ||
505 | .vidioc_s_frequency = vidioc_s_frequency, | ||
506 | .vidioc_queryctrl = vidioc_queryctrl, | ||
507 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
508 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
509 | }; | ||
510 | |||
511 | /* V4L2 interface */ | ||
512 | static struct video_device tea5764_radio_template = { | ||
513 | .name = "TEA5764 FM-Radio", | ||
514 | .fops = &tea5764_fops, | ||
515 | .ioctl_ops = &tea5764_ioctl_ops, | ||
516 | .release = video_device_release, | ||
517 | }; | ||
518 | |||
519 | /* I2C probe: check if the device exists and register with v4l if it is */ | ||
520 | static int __devinit tea5764_i2c_probe(struct i2c_client *client, | ||
521 | const struct i2c_device_id *id) | ||
522 | { | ||
523 | struct tea5764_device *radio; | ||
524 | struct tea5764_regs *r; | ||
525 | int ret; | ||
526 | |||
527 | PDEBUG("probe"); | ||
528 | radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL); | ||
529 | if (!radio) | ||
530 | return -ENOMEM; | ||
531 | |||
532 | mutex_init(&radio->mutex); | ||
533 | radio->i2c_client = client; | ||
534 | ret = tea5764_i2c_read(radio); | ||
535 | if (ret) | ||
536 | goto errfr; | ||
537 | r = &radio->regs; | ||
538 | PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid); | ||
539 | if (r->chipid != TEA5764_CHIPID || | ||
540 | (r->manid & 0x0fff) != TEA5764_MANID) { | ||
541 | PWARN("This chip is not a TEA5764!"); | ||
542 | ret = -EINVAL; | ||
543 | goto errfr; | ||
544 | } | ||
545 | |||
546 | radio->videodev = video_device_alloc(); | ||
547 | if (!(radio->videodev)) { | ||
548 | ret = -ENOMEM; | ||
549 | goto errfr; | ||
550 | } | ||
551 | memcpy(radio->videodev, &tea5764_radio_template, | ||
552 | sizeof(tea5764_radio_template)); | ||
553 | |||
554 | i2c_set_clientdata(client, radio); | ||
555 | video_set_drvdata(radio->videodev, radio); | ||
556 | |||
557 | ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); | ||
558 | if (ret < 0) { | ||
559 | PWARN("Could not register video device!"); | ||
560 | goto errrel; | ||
561 | } | ||
562 | |||
563 | /* initialize and power off the chip */ | ||
564 | tea5764_i2c_read(radio); | ||
565 | tea5764_set_audout_mode(radio, V4L2_TUNER_MODE_STEREO); | ||
566 | tea5764_mute(radio, 1); | ||
567 | tea5764_power_down(radio); | ||
568 | |||
569 | PINFO("registered."); | ||
570 | return 0; | ||
571 | errrel: | ||
572 | video_device_release(radio->videodev); | ||
573 | errfr: | ||
574 | kfree(radio); | ||
575 | return ret; | ||
576 | } | ||
577 | |||
578 | static int __devexit tea5764_i2c_remove(struct i2c_client *client) | ||
579 | { | ||
580 | struct tea5764_device *radio = i2c_get_clientdata(client); | ||
581 | |||
582 | PDEBUG("remove"); | ||
583 | if (radio) { | ||
584 | tea5764_power_down(radio); | ||
585 | video_unregister_device(radio->videodev); | ||
586 | kfree(radio); | ||
587 | } | ||
588 | return 0; | ||
589 | } | ||
590 | |||
591 | /* I2C subsystem interface */ | ||
592 | static const struct i2c_device_id tea5764_id[] = { | ||
593 | { "radio-tea5764", 0 }, | ||
594 | { } /* Terminating entry */ | ||
595 | }; | ||
596 | MODULE_DEVICE_TABLE(i2c, tea5764_id); | ||
597 | |||
598 | static struct i2c_driver tea5764_i2c_driver = { | ||
599 | .driver = { | ||
600 | .name = "radio-tea5764", | ||
601 | .owner = THIS_MODULE, | ||
602 | }, | ||
603 | .probe = tea5764_i2c_probe, | ||
604 | .remove = __devexit_p(tea5764_i2c_remove), | ||
605 | .id_table = tea5764_id, | ||
606 | }; | ||
607 | |||
608 | /* init the driver */ | ||
609 | static int __init tea5764_init(void) | ||
610 | { | ||
611 | int ret = i2c_add_driver(&tea5764_i2c_driver); | ||
612 | |||
613 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ": " | ||
614 | DRIVER_DESC "\n"); | ||
615 | return ret; | ||
616 | } | ||
617 | |||
618 | /* cleanup the driver */ | ||
619 | static void __exit tea5764_exit(void) | ||
620 | { | ||
621 | i2c_del_driver(&tea5764_i2c_driver); | ||
622 | } | ||
623 | |||
624 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
625 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
626 | MODULE_LICENSE("GPL"); | ||
627 | |||
628 | module_param(use_xtal, int, 1); | ||
629 | MODULE_PARM_DESC(use_xtal, "Chip have a xtal connected in board"); | ||
630 | module_param(radio_nr, int, 0); | ||
631 | MODULE_PARM_DESC(radio_nr, "video4linux device number to use"); | ||
632 | |||
633 | module_init(tea5764_init); | ||
634 | module_exit(tea5764_exit); | ||
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index 0abb186a9473..0798d71abd00 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c | |||
@@ -352,26 +352,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
352 | 352 | ||
353 | static struct tt_device terratec_unit; | 353 | static struct tt_device terratec_unit; |
354 | 354 | ||
355 | static int terratec_exclusive_open(struct inode *inode, struct file *file) | 355 | static int terratec_exclusive_open(struct file *file) |
356 | { | 356 | { |
357 | return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0; | 357 | return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | static int terratec_exclusive_release(struct inode *inode, struct file *file) | 360 | static int terratec_exclusive_release(struct file *file) |
361 | { | 361 | { |
362 | clear_bit(0, &terratec_unit.in_use); | 362 | clear_bit(0, &terratec_unit.in_use); |
363 | return 0; | 363 | return 0; |
364 | } | 364 | } |
365 | 365 | ||
366 | static const struct file_operations terratec_fops = { | 366 | static const struct v4l2_file_operations terratec_fops = { |
367 | .owner = THIS_MODULE, | 367 | .owner = THIS_MODULE, |
368 | .open = terratec_exclusive_open, | 368 | .open = terratec_exclusive_open, |
369 | .release = terratec_exclusive_release, | 369 | .release = terratec_exclusive_release, |
370 | .ioctl = video_ioctl2, | 370 | .ioctl = video_ioctl2, |
371 | #ifdef CONFIG_COMPAT | ||
372 | .compat_ioctl = v4l_compat_ioctl32, | ||
373 | #endif | ||
374 | .llseek = no_llseek, | ||
375 | }; | 371 | }; |
376 | 372 | ||
377 | static const struct v4l2_ioctl_ops terratec_ioctl_ops = { | 373 | static const struct v4l2_ioctl_ops terratec_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c index e7b111fcd105..bdf9cb6a75f4 100644 --- a/drivers/media/radio/radio-trust.c +++ b/drivers/media/radio/radio-trust.c | |||
@@ -337,26 +337,22 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
337 | return 0; | 337 | return 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | static int trust_exclusive_open(struct inode *inode, struct file *file) | 340 | static int trust_exclusive_open(struct file *file) |
341 | { | 341 | { |
342 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | 342 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; |
343 | } | 343 | } |
344 | 344 | ||
345 | static int trust_exclusive_release(struct inode *inode, struct file *file) | 345 | static int trust_exclusive_release(struct file *file) |
346 | { | 346 | { |
347 | clear_bit(0, &in_use); | 347 | clear_bit(0, &in_use); |
348 | return 0; | 348 | return 0; |
349 | } | 349 | } |
350 | 350 | ||
351 | static const struct file_operations trust_fops = { | 351 | static const struct v4l2_file_operations trust_fops = { |
352 | .owner = THIS_MODULE, | 352 | .owner = THIS_MODULE, |
353 | .open = trust_exclusive_open, | 353 | .open = trust_exclusive_open, |
354 | .release = trust_exclusive_release, | 354 | .release = trust_exclusive_release, |
355 | .ioctl = video_ioctl2, | 355 | .ioctl = video_ioctl2, |
356 | #ifdef CONFIG_COMPAT | ||
357 | .compat_ioctl = v4l_compat_ioctl32, | ||
358 | #endif | ||
359 | .llseek = no_llseek, | ||
360 | }; | 356 | }; |
361 | 357 | ||
362 | static const struct v4l2_ioctl_ops trust_ioctl_ops = { | 358 | static const struct v4l2_ioctl_ops trust_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c index 952ec35a8415..5c3b319dab37 100644 --- a/drivers/media/radio/radio-typhoon.c +++ b/drivers/media/radio/radio-typhoon.c | |||
@@ -330,26 +330,22 @@ static struct typhoon_device typhoon_unit = | |||
330 | .mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ, | 330 | .mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ, |
331 | }; | 331 | }; |
332 | 332 | ||
333 | static int typhoon_exclusive_open(struct inode *inode, struct file *file) | 333 | static int typhoon_exclusive_open(struct file *file) |
334 | { | 334 | { |
335 | return test_and_set_bit(0, &typhoon_unit.in_use) ? -EBUSY : 0; | 335 | return test_and_set_bit(0, &typhoon_unit.in_use) ? -EBUSY : 0; |
336 | } | 336 | } |
337 | 337 | ||
338 | static int typhoon_exclusive_release(struct inode *inode, struct file *file) | 338 | static int typhoon_exclusive_release(struct file *file) |
339 | { | 339 | { |
340 | clear_bit(0, &typhoon_unit.in_use); | 340 | clear_bit(0, &typhoon_unit.in_use); |
341 | return 0; | 341 | return 0; |
342 | } | 342 | } |
343 | 343 | ||
344 | static const struct file_operations typhoon_fops = { | 344 | static const struct v4l2_file_operations typhoon_fops = { |
345 | .owner = THIS_MODULE, | 345 | .owner = THIS_MODULE, |
346 | .open = typhoon_exclusive_open, | 346 | .open = typhoon_exclusive_open, |
347 | .release = typhoon_exclusive_release, | 347 | .release = typhoon_exclusive_release, |
348 | .ioctl = video_ioctl2, | 348 | .ioctl = video_ioctl2, |
349 | #ifdef CONFIG_COMPAT | ||
350 | .compat_ioctl = v4l_compat_ioctl32, | ||
351 | #endif | ||
352 | .llseek = no_llseek, | ||
353 | }; | 349 | }; |
354 | 350 | ||
355 | static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { | 351 | static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { |
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 15b10bad6796..d2ac17eeec5f 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -401,27 +401,23 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
401 | 401 | ||
402 | static struct zol_device zoltrix_unit; | 402 | static struct zol_device zoltrix_unit; |
403 | 403 | ||
404 | static int zoltrix_exclusive_open(struct inode *inode, struct file *file) | 404 | static int zoltrix_exclusive_open(struct file *file) |
405 | { | 405 | { |
406 | return test_and_set_bit(0, &zoltrix_unit.in_use) ? -EBUSY : 0; | 406 | return test_and_set_bit(0, &zoltrix_unit.in_use) ? -EBUSY : 0; |
407 | } | 407 | } |
408 | 408 | ||
409 | static int zoltrix_exclusive_release(struct inode *inode, struct file *file) | 409 | static int zoltrix_exclusive_release(struct file *file) |
410 | { | 410 | { |
411 | clear_bit(0, &zoltrix_unit.in_use); | 411 | clear_bit(0, &zoltrix_unit.in_use); |
412 | return 0; | 412 | return 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | static const struct file_operations zoltrix_fops = | 415 | static const struct v4l2_file_operations zoltrix_fops = |
416 | { | 416 | { |
417 | .owner = THIS_MODULE, | 417 | .owner = THIS_MODULE, |
418 | .open = zoltrix_exclusive_open, | 418 | .open = zoltrix_exclusive_open, |
419 | .release = zoltrix_exclusive_release, | 419 | .release = zoltrix_exclusive_release, |
420 | .ioctl = video_ioctl2, | 420 | .ioctl = video_ioctl2, |
421 | #ifdef CONFIG_COMPAT | ||
422 | .compat_ioctl = v4l_compat_ioctl32, | ||
423 | #endif | ||
424 | .llseek = no_llseek, | ||
425 | }; | 421 | }; |
426 | 422 | ||
427 | static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = { | 423 | static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = { |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 1611c33b1aee..72f6d03d2d8f 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -12,7 +12,10 @@ omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o | |||
12 | 12 | ||
13 | videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o | 13 | videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o |
14 | 14 | ||
15 | obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-compat-ioctl32.o v4l2-int-device.o | 15 | obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o |
16 | ifeq ($(CONFIG_COMPAT),y) | ||
17 | obj-$(CONFIG_VIDEO_DEV) += v4l2-compat-ioctl32.o | ||
18 | endif | ||
16 | 19 | ||
17 | obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o | 20 | obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o |
18 | 21 | ||
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 2ba6abd92b6f..d137bac84511 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c | |||
@@ -396,7 +396,7 @@ out_up: | |||
396 | return ret; | 396 | return ret; |
397 | } | 397 | } |
398 | 398 | ||
399 | static int ar_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 399 | static long ar_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
400 | { | 400 | { |
401 | struct video_device *dev = video_devdata(file); | 401 | struct video_device *dev = video_devdata(file); |
402 | struct ar_device *ar = video_get_drvdata(dev); | 402 | struct ar_device *ar = video_get_drvdata(dev); |
@@ -539,7 +539,7 @@ static int ar_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
539 | return 0; | 539 | return 0; |
540 | } | 540 | } |
541 | 541 | ||
542 | static int ar_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 542 | static long ar_ioctl(struct file *file, unsigned int cmd, |
543 | unsigned long arg) | 543 | unsigned long arg) |
544 | { | 544 | { |
545 | return video_usercopy(file, cmd, arg, ar_do_ioctl); | 545 | return video_usercopy(file, cmd, arg, ar_do_ioctl); |
@@ -744,27 +744,23 @@ void ar_release(struct video_device *vfd) | |||
744 | ****************************************************************************/ | 744 | ****************************************************************************/ |
745 | static struct ar_device ardev; | 745 | static struct ar_device ardev; |
746 | 746 | ||
747 | static int ar_exclusive_open(struct inode *inode, struct file *file) | 747 | static int ar_exclusive_open(struct file *file) |
748 | { | 748 | { |
749 | return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0; | 749 | return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0; |
750 | } | 750 | } |
751 | 751 | ||
752 | static int ar_exclusive_release(struct inode *inode, struct file *file) | 752 | static int ar_exclusive_release(struct file *file) |
753 | { | 753 | { |
754 | clear_bit(0, &ardev.in_use); | 754 | clear_bit(0, &ardev.in_use); |
755 | return 0; | 755 | return 0; |
756 | } | 756 | } |
757 | 757 | ||
758 | static const struct file_operations ar_fops = { | 758 | static const struct v4l2_file_operations ar_fops = { |
759 | .owner = THIS_MODULE, | 759 | .owner = THIS_MODULE, |
760 | .open = ar_exclusive_open, | 760 | .open = ar_exclusive_open, |
761 | .release = ar_exclusive_release, | 761 | .release = ar_exclusive_release, |
762 | .read = ar_read, | 762 | .read = ar_read, |
763 | .ioctl = ar_ioctl, | 763 | .ioctl = ar_ioctl, |
764 | #ifdef CONFIG_COMPAT | ||
765 | .compat_ioctl = v4l_compat_ioctl32, | ||
766 | #endif | ||
767 | .llseek = no_llseek, | ||
768 | }; | 764 | }; |
769 | 765 | ||
770 | static struct video_device ar_template = { | 766 | static struct video_device ar_template = { |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 9ec4cec2e52d..c71f394fc0ea 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -2039,7 +2039,7 @@ static int bttv_log_status(struct file *file, void *f) | |||
2039 | 2039 | ||
2040 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 2040 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2041 | static int bttv_g_register(struct file *file, void *f, | 2041 | static int bttv_g_register(struct file *file, void *f, |
2042 | struct v4l2_register *reg) | 2042 | struct v4l2_dbg_register *reg) |
2043 | { | 2043 | { |
2044 | struct bttv_fh *fh = f; | 2044 | struct bttv_fh *fh = f; |
2045 | struct bttv *btv = fh->btv; | 2045 | struct bttv *btv = fh->btv; |
@@ -2047,18 +2047,19 @@ static int bttv_g_register(struct file *file, void *f, | |||
2047 | if (!capable(CAP_SYS_ADMIN)) | 2047 | if (!capable(CAP_SYS_ADMIN)) |
2048 | return -EPERM; | 2048 | return -EPERM; |
2049 | 2049 | ||
2050 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 2050 | if (!v4l2_chip_match_host(®->match)) |
2051 | return -EINVAL; | 2051 | return -EINVAL; |
2052 | 2052 | ||
2053 | /* bt848 has a 12-bit register space */ | 2053 | /* bt848 has a 12-bit register space */ |
2054 | reg->reg &= 0xfff; | 2054 | reg->reg &= 0xfff; |
2055 | reg->val = btread(reg->reg); | 2055 | reg->val = btread(reg->reg); |
2056 | reg->size = 1; | ||
2056 | 2057 | ||
2057 | return 0; | 2058 | return 0; |
2058 | } | 2059 | } |
2059 | 2060 | ||
2060 | static int bttv_s_register(struct file *file, void *f, | 2061 | static int bttv_s_register(struct file *file, void *f, |
2061 | struct v4l2_register *reg) | 2062 | struct v4l2_dbg_register *reg) |
2062 | { | 2063 | { |
2063 | struct bttv_fh *fh = f; | 2064 | struct bttv_fh *fh = f; |
2064 | struct bttv *btv = fh->btv; | 2065 | struct bttv *btv = fh->btv; |
@@ -2066,7 +2067,7 @@ static int bttv_s_register(struct file *file, void *f, | |||
2066 | if (!capable(CAP_SYS_ADMIN)) | 2067 | if (!capable(CAP_SYS_ADMIN)) |
2067 | return -EPERM; | 2068 | return -EPERM; |
2068 | 2069 | ||
2069 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 2070 | if (!v4l2_chip_match_host(®->match)) |
2070 | return -EINVAL; | 2071 | return -EINVAL; |
2071 | 2072 | ||
2072 | /* bt848 has a 12-bit register space */ | 2073 | /* bt848 has a 12-bit register space */ |
@@ -3208,9 +3209,9 @@ err: | |||
3208 | return POLLERR; | 3209 | return POLLERR; |
3209 | } | 3210 | } |
3210 | 3211 | ||
3211 | static int bttv_open(struct inode *inode, struct file *file) | 3212 | static int bttv_open(struct file *file) |
3212 | { | 3213 | { |
3213 | int minor = iminor(inode); | 3214 | int minor = video_devdata(file)->minor; |
3214 | struct bttv *btv = NULL; | 3215 | struct bttv *btv = NULL; |
3215 | struct bttv_fh *fh; | 3216 | struct bttv_fh *fh; |
3216 | enum v4l2_buf_type type = 0; | 3217 | enum v4l2_buf_type type = 0; |
@@ -3291,7 +3292,7 @@ static int bttv_open(struct inode *inode, struct file *file) | |||
3291 | return 0; | 3292 | return 0; |
3292 | } | 3293 | } |
3293 | 3294 | ||
3294 | static int bttv_release(struct inode *inode, struct file *file) | 3295 | static int bttv_release(struct file *file) |
3295 | { | 3296 | { |
3296 | struct bttv_fh *fh = file->private_data; | 3297 | struct bttv_fh *fh = file->private_data; |
3297 | struct bttv *btv = fh->btv; | 3298 | struct bttv *btv = fh->btv; |
@@ -3346,14 +3347,12 @@ bttv_mmap(struct file *file, struct vm_area_struct *vma) | |||
3346 | return videobuf_mmap_mapper(bttv_queue(fh),vma); | 3347 | return videobuf_mmap_mapper(bttv_queue(fh),vma); |
3347 | } | 3348 | } |
3348 | 3349 | ||
3349 | static const struct file_operations bttv_fops = | 3350 | static const struct v4l2_file_operations bttv_fops = |
3350 | { | 3351 | { |
3351 | .owner = THIS_MODULE, | 3352 | .owner = THIS_MODULE, |
3352 | .open = bttv_open, | 3353 | .open = bttv_open, |
3353 | .release = bttv_release, | 3354 | .release = bttv_release, |
3354 | .ioctl = video_ioctl2, | 3355 | .ioctl = video_ioctl2, |
3355 | .compat_ioctl = v4l_compat_ioctl32, | ||
3356 | .llseek = no_llseek, | ||
3357 | .read = bttv_read, | 3356 | .read = bttv_read, |
3358 | .mmap = bttv_mmap, | 3357 | .mmap = bttv_mmap, |
3359 | .poll = bttv_poll, | 3358 | .poll = bttv_poll, |
@@ -3422,9 +3421,9 @@ static struct video_device bttv_video_template = { | |||
3422 | /* ----------------------------------------------------------------------- */ | 3421 | /* ----------------------------------------------------------------------- */ |
3423 | /* radio interface */ | 3422 | /* radio interface */ |
3424 | 3423 | ||
3425 | static int radio_open(struct inode *inode, struct file *file) | 3424 | static int radio_open(struct file *file) |
3426 | { | 3425 | { |
3427 | int minor = iminor(inode); | 3426 | int minor = video_devdata(file)->minor; |
3428 | struct bttv *btv = NULL; | 3427 | struct bttv *btv = NULL; |
3429 | struct bttv_fh *fh; | 3428 | struct bttv_fh *fh; |
3430 | unsigned int i; | 3429 | unsigned int i; |
@@ -3467,12 +3466,13 @@ static int radio_open(struct inode *inode, struct file *file) | |||
3467 | return 0; | 3466 | return 0; |
3468 | } | 3467 | } |
3469 | 3468 | ||
3470 | static int radio_release(struct inode *inode, struct file *file) | 3469 | static int radio_release(struct file *file) |
3471 | { | 3470 | { |
3472 | struct bttv_fh *fh = file->private_data; | 3471 | struct bttv_fh *fh = file->private_data; |
3473 | struct bttv *btv = fh->btv; | 3472 | struct bttv *btv = fh->btv; |
3474 | struct rds_command cmd; | 3473 | struct rds_command cmd; |
3475 | 3474 | ||
3475 | v4l2_prio_close(&btv->prio,&fh->prio); | ||
3476 | file->private_data = NULL; | 3476 | file->private_data = NULL; |
3477 | kfree(fh); | 3477 | kfree(fh); |
3478 | 3478 | ||
@@ -3633,15 +3633,13 @@ static unsigned int radio_poll(struct file *file, poll_table *wait) | |||
3633 | return cmd.result; | 3633 | return cmd.result; |
3634 | } | 3634 | } |
3635 | 3635 | ||
3636 | static const struct file_operations radio_fops = | 3636 | static const struct v4l2_file_operations radio_fops = |
3637 | { | 3637 | { |
3638 | .owner = THIS_MODULE, | 3638 | .owner = THIS_MODULE, |
3639 | .open = radio_open, | 3639 | .open = radio_open, |
3640 | .read = radio_read, | 3640 | .read = radio_read, |
3641 | .release = radio_release, | 3641 | .release = radio_release, |
3642 | .compat_ioctl = v4l_compat_ioctl32, | ||
3643 | .ioctl = video_ioctl2, | 3642 | .ioctl = video_ioctl2, |
3644 | .llseek = no_llseek, | ||
3645 | .poll = radio_poll, | 3643 | .poll = radio_poll, |
3646 | }; | 3644 | }; |
3647 | 3645 | ||
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index 17f80d03f38e..10dbd4a11b30 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
@@ -706,7 +706,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l | |||
706 | * Video4linux interfacing | 706 | * Video4linux interfacing |
707 | */ | 707 | */ |
708 | 708 | ||
709 | static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 709 | static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
710 | { | 710 | { |
711 | struct video_device *dev = video_devdata(file); | 711 | struct video_device *dev = video_devdata(file); |
712 | struct qcam_device *qcam=(struct qcam_device *)dev; | 712 | struct qcam_device *qcam=(struct qcam_device *)dev; |
@@ -863,7 +863,7 @@ static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | 865 | ||
866 | static int qcam_ioctl(struct inode *inode, struct file *file, | 866 | static long qcam_ioctl(struct file *file, |
867 | unsigned int cmd, unsigned long arg) | 867 | unsigned int cmd, unsigned long arg) |
868 | { | 868 | { |
869 | return video_usercopy(file, cmd, arg, qcam_do_ioctl); | 869 | return video_usercopy(file, cmd, arg, qcam_do_ioctl); |
@@ -893,7 +893,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
893 | return len; | 893 | return len; |
894 | } | 894 | } |
895 | 895 | ||
896 | static int qcam_exclusive_open(struct inode *inode, struct file *file) | 896 | static int qcam_exclusive_open(struct file *file) |
897 | { | 897 | { |
898 | struct video_device *dev = video_devdata(file); | 898 | struct video_device *dev = video_devdata(file); |
899 | struct qcam_device *qcam = (struct qcam_device *)dev; | 899 | struct qcam_device *qcam = (struct qcam_device *)dev; |
@@ -901,7 +901,7 @@ static int qcam_exclusive_open(struct inode *inode, struct file *file) | |||
901 | return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; | 901 | return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; |
902 | } | 902 | } |
903 | 903 | ||
904 | static int qcam_exclusive_release(struct inode *inode, struct file *file) | 904 | static int qcam_exclusive_release(struct file *file) |
905 | { | 905 | { |
906 | struct video_device *dev = video_devdata(file); | 906 | struct video_device *dev = video_devdata(file); |
907 | struct qcam_device *qcam = (struct qcam_device *)dev; | 907 | struct qcam_device *qcam = (struct qcam_device *)dev; |
@@ -910,16 +910,12 @@ static int qcam_exclusive_release(struct inode *inode, struct file *file) | |||
910 | return 0; | 910 | return 0; |
911 | } | 911 | } |
912 | 912 | ||
913 | static const struct file_operations qcam_fops = { | 913 | static const struct v4l2_file_operations qcam_fops = { |
914 | .owner = THIS_MODULE, | 914 | .owner = THIS_MODULE, |
915 | .open = qcam_exclusive_open, | 915 | .open = qcam_exclusive_open, |
916 | .release = qcam_exclusive_release, | 916 | .release = qcam_exclusive_release, |
917 | .ioctl = qcam_ioctl, | 917 | .ioctl = qcam_ioctl, |
918 | #ifdef CONFIG_COMPAT | ||
919 | .compat_ioctl = v4l_compat_ioctl32, | ||
920 | #endif | ||
921 | .read = qcam_read, | 918 | .read = qcam_read, |
922 | .llseek = no_llseek, | ||
923 | }; | 919 | }; |
924 | static struct video_device qcam_template= | 920 | static struct video_device qcam_template= |
925 | { | 921 | { |
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c index 21c71eb085db..85cf1778827a 100644 --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c | |||
@@ -500,7 +500,7 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le | |||
500 | * Video4linux interfacing | 500 | * Video4linux interfacing |
501 | */ | 501 | */ |
502 | 502 | ||
503 | static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 503 | static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
504 | { | 504 | { |
505 | struct video_device *dev = video_devdata(file); | 505 | struct video_device *dev = video_devdata(file); |
506 | struct qcam_device *qcam=(struct qcam_device *)dev; | 506 | struct qcam_device *qcam=(struct qcam_device *)dev; |
@@ -665,7 +665,7 @@ static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
665 | return 0; | 665 | return 0; |
666 | } | 666 | } |
667 | 667 | ||
668 | static int qcam_ioctl(struct inode *inode, struct file *file, | 668 | static long qcam_ioctl(struct file *file, |
669 | unsigned int cmd, unsigned long arg) | 669 | unsigned int cmd, unsigned long arg) |
670 | { | 670 | { |
671 | return video_usercopy(file, cmd, arg, qcam_do_ioctl); | 671 | return video_usercopy(file, cmd, arg, qcam_do_ioctl); |
@@ -687,7 +687,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
687 | return len; | 687 | return len; |
688 | } | 688 | } |
689 | 689 | ||
690 | static int qcam_exclusive_open(struct inode *inode, struct file *file) | 690 | static int qcam_exclusive_open(struct file *file) |
691 | { | 691 | { |
692 | struct video_device *dev = video_devdata(file); | 692 | struct video_device *dev = video_devdata(file); |
693 | struct qcam_device *qcam = (struct qcam_device *)dev; | 693 | struct qcam_device *qcam = (struct qcam_device *)dev; |
@@ -695,7 +695,7 @@ static int qcam_exclusive_open(struct inode *inode, struct file *file) | |||
695 | return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; | 695 | return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; |
696 | } | 696 | } |
697 | 697 | ||
698 | static int qcam_exclusive_release(struct inode *inode, struct file *file) | 698 | static int qcam_exclusive_release(struct file *file) |
699 | { | 699 | { |
700 | struct video_device *dev = video_devdata(file); | 700 | struct video_device *dev = video_devdata(file); |
701 | struct qcam_device *qcam = (struct qcam_device *)dev; | 701 | struct qcam_device *qcam = (struct qcam_device *)dev; |
@@ -705,16 +705,12 @@ static int qcam_exclusive_release(struct inode *inode, struct file *file) | |||
705 | } | 705 | } |
706 | 706 | ||
707 | /* video device template */ | 707 | /* video device template */ |
708 | static const struct file_operations qcam_fops = { | 708 | static const struct v4l2_file_operations qcam_fops = { |
709 | .owner = THIS_MODULE, | 709 | .owner = THIS_MODULE, |
710 | .open = qcam_exclusive_open, | 710 | .open = qcam_exclusive_open, |
711 | .release = qcam_exclusive_release, | 711 | .release = qcam_exclusive_release, |
712 | .ioctl = qcam_ioctl, | 712 | .ioctl = qcam_ioctl, |
713 | #ifdef CONFIG_COMPAT | ||
714 | .compat_ioctl = v4l_compat_ioctl32, | ||
715 | #endif | ||
716 | .read = qcam_read, | 713 | .read = qcam_read, |
717 | .llseek = no_llseek, | ||
718 | }; | 714 | }; |
719 | 715 | ||
720 | static struct video_device qcam_template= | 716 | static struct video_device qcam_template= |
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index 1740b9ebdcef..34a39d2e4703 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c | |||
@@ -859,7 +859,7 @@ static int __cafe_cam_reset(struct cafe_camera *cam) | |||
859 | */ | 859 | */ |
860 | static int cafe_cam_init(struct cafe_camera *cam) | 860 | static int cafe_cam_init(struct cafe_camera *cam) |
861 | { | 861 | { |
862 | struct v4l2_chip_ident chip = { V4L2_CHIP_MATCH_I2C_ADDR, 0, 0, 0 }; | 862 | struct v4l2_dbg_chip_ident chip; |
863 | int ret; | 863 | int ret; |
864 | 864 | ||
865 | mutex_lock(&cam->s_mutex); | 865 | mutex_lock(&cam->s_mutex); |
@@ -869,8 +869,9 @@ static int cafe_cam_init(struct cafe_camera *cam) | |||
869 | ret = __cafe_cam_reset(cam); | 869 | ret = __cafe_cam_reset(cam); |
870 | if (ret) | 870 | if (ret) |
871 | goto out; | 871 | goto out; |
872 | chip.match_chip = cam->sensor->addr; | 872 | chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR; |
873 | ret = __cafe_cam_cmd(cam, VIDIOC_G_CHIP_IDENT, &chip); | 873 | chip.match.addr = cam->sensor->addr; |
874 | ret = __cafe_cam_cmd(cam, VIDIOC_DBG_G_CHIP_IDENT, &chip); | ||
874 | if (ret) | 875 | if (ret) |
875 | goto out; | 876 | goto out; |
876 | cam->sensor_type = chip.ident; | 877 | cam->sensor_type = chip.ident; |
@@ -1472,11 +1473,11 @@ static int cafe_v4l_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1472 | 1473 | ||
1473 | 1474 | ||
1474 | 1475 | ||
1475 | static int cafe_v4l_open(struct inode *inode, struct file *filp) | 1476 | static int cafe_v4l_open(struct file *filp) |
1476 | { | 1477 | { |
1477 | struct cafe_camera *cam; | 1478 | struct cafe_camera *cam; |
1478 | 1479 | ||
1479 | cam = cafe_find_dev(iminor(inode)); | 1480 | cam = cafe_find_dev(video_devdata(filp)->minor); |
1480 | if (cam == NULL) | 1481 | if (cam == NULL) |
1481 | return -ENODEV; | 1482 | return -ENODEV; |
1482 | filp->private_data = cam; | 1483 | filp->private_data = cam; |
@@ -1494,7 +1495,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp) | |||
1494 | } | 1495 | } |
1495 | 1496 | ||
1496 | 1497 | ||
1497 | static int cafe_v4l_release(struct inode *inode, struct file *filp) | 1498 | static int cafe_v4l_release(struct file *filp) |
1498 | { | 1499 | { |
1499 | struct cafe_camera *cam = filp->private_data; | 1500 | struct cafe_camera *cam = filp->private_data; |
1500 | 1501 | ||
@@ -1759,7 +1760,7 @@ static void cafe_v4l_dev_release(struct video_device *vd) | |||
1759 | * clone it for specific real devices. | 1760 | * clone it for specific real devices. |
1760 | */ | 1761 | */ |
1761 | 1762 | ||
1762 | static const struct file_operations cafe_v4l_fops = { | 1763 | static const struct v4l2_file_operations cafe_v4l_fops = { |
1763 | .owner = THIS_MODULE, | 1764 | .owner = THIS_MODULE, |
1764 | .open = cafe_v4l_open, | 1765 | .open = cafe_v4l_open, |
1765 | .release = cafe_v4l_release, | 1766 | .release = cafe_v4l_release, |
@@ -1767,7 +1768,6 @@ static const struct file_operations cafe_v4l_fops = { | |||
1767 | .poll = cafe_v4l_poll, | 1768 | .poll = cafe_v4l_poll, |
1768 | .mmap = cafe_v4l_mmap, | 1769 | .mmap = cafe_v4l_mmap, |
1769 | .ioctl = video_ioctl2, | 1770 | .ioctl = video_ioctl2, |
1770 | .llseek = no_llseek, | ||
1771 | }; | 1771 | }; |
1772 | 1772 | ||
1773 | static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = { | 1773 | static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = { |
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 028a400d2453..c3b0c8c63c76 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -3148,7 +3148,7 @@ static void put_cam(struct cpia_camera_ops* ops) | |||
3148 | } | 3148 | } |
3149 | 3149 | ||
3150 | /* ------------------------- V4L interface --------------------- */ | 3150 | /* ------------------------- V4L interface --------------------- */ |
3151 | static int cpia_open(struct inode *inode, struct file *file) | 3151 | static int cpia_open(struct file *file) |
3152 | { | 3152 | { |
3153 | struct video_device *dev = video_devdata(file); | 3153 | struct video_device *dev = video_devdata(file); |
3154 | struct cam_data *cam = video_get_drvdata(dev); | 3154 | struct cam_data *cam = video_get_drvdata(dev); |
@@ -3225,7 +3225,7 @@ static int cpia_open(struct inode *inode, struct file *file) | |||
3225 | return err; | 3225 | return err; |
3226 | } | 3226 | } |
3227 | 3227 | ||
3228 | static int cpia_close(struct inode *inode, struct file *file) | 3228 | static int cpia_close(struct file *file) |
3229 | { | 3229 | { |
3230 | struct video_device *dev = file->private_data; | 3230 | struct video_device *dev = file->private_data; |
3231 | struct cam_data *cam = video_get_drvdata(dev); | 3231 | struct cam_data *cam = video_get_drvdata(dev); |
@@ -3333,7 +3333,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf, | |||
3333 | return cam->decompressed_frame.count; | 3333 | return cam->decompressed_frame.count; |
3334 | } | 3334 | } |
3335 | 3335 | ||
3336 | static int cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 3336 | static long cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
3337 | { | 3337 | { |
3338 | struct video_device *dev = file->private_data; | 3338 | struct video_device *dev = file->private_data; |
3339 | struct cam_data *cam = video_get_drvdata(dev); | 3339 | struct cam_data *cam = video_get_drvdata(dev); |
@@ -3720,7 +3720,7 @@ static int cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
3720 | return retval; | 3720 | return retval; |
3721 | } | 3721 | } |
3722 | 3722 | ||
3723 | static int cpia_ioctl(struct inode *inode, struct file *file, | 3723 | static long cpia_ioctl(struct file *file, |
3724 | unsigned int cmd, unsigned long arg) | 3724 | unsigned int cmd, unsigned long arg) |
3725 | { | 3725 | { |
3726 | return video_usercopy(file, cmd, arg, cpia_do_ioctl); | 3726 | return video_usercopy(file, cmd, arg, cpia_do_ioctl); |
@@ -3780,17 +3780,13 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma) | |||
3780 | return 0; | 3780 | return 0; |
3781 | } | 3781 | } |
3782 | 3782 | ||
3783 | static const struct file_operations cpia_fops = { | 3783 | static const struct v4l2_file_operations cpia_fops = { |
3784 | .owner = THIS_MODULE, | 3784 | .owner = THIS_MODULE, |
3785 | .open = cpia_open, | 3785 | .open = cpia_open, |
3786 | .release = cpia_close, | 3786 | .release = cpia_close, |
3787 | .read = cpia_read, | 3787 | .read = cpia_read, |
3788 | .mmap = cpia_mmap, | 3788 | .mmap = cpia_mmap, |
3789 | .ioctl = cpia_ioctl, | 3789 | .ioctl = cpia_ioctl, |
3790 | #ifdef CONFIG_COMPAT | ||
3791 | .compat_ioctl = v4l_compat_ioctl32, | ||
3792 | #endif | ||
3793 | .llseek = no_llseek, | ||
3794 | }; | 3790 | }; |
3795 | 3791 | ||
3796 | static struct video_device cpia_template = { | 3792 | static struct video_device cpia_template = { |
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 3c2d7eac1197..9c25894fdd8e 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
@@ -239,7 +239,7 @@ static struct v4l2_queryctrl controls[] = { | |||
239 | * cpia2_open | 239 | * cpia2_open |
240 | * | 240 | * |
241 | *****************************************************************************/ | 241 | *****************************************************************************/ |
242 | static int cpia2_open(struct inode *inode, struct file *file) | 242 | static int cpia2_open(struct file *file) |
243 | { | 243 | { |
244 | struct camera_data *cam = video_drvdata(file); | 244 | struct camera_data *cam = video_drvdata(file); |
245 | int retval = 0; | 245 | int retval = 0; |
@@ -302,7 +302,7 @@ err_return: | |||
302 | * cpia2_close | 302 | * cpia2_close |
303 | * | 303 | * |
304 | *****************************************************************************/ | 304 | *****************************************************************************/ |
305 | static int cpia2_close(struct inode *inode, struct file *file) | 305 | static int cpia2_close(struct file *file) |
306 | { | 306 | { |
307 | struct video_device *dev = video_devdata(file); | 307 | struct video_device *dev = video_devdata(file); |
308 | struct camera_data *cam = video_get_drvdata(dev); | 308 | struct camera_data *cam = video_get_drvdata(dev); |
@@ -1572,10 +1572,10 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file) | |||
1572 | * cpia2_ioctl | 1572 | * cpia2_ioctl |
1573 | * | 1573 | * |
1574 | *****************************************************************************/ | 1574 | *****************************************************************************/ |
1575 | static int cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 1575 | static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
1576 | { | 1576 | { |
1577 | struct camera_data *cam = video_drvdata(file); | 1577 | struct camera_data *cam = video_drvdata(file); |
1578 | int retval = 0; | 1578 | long retval = 0; |
1579 | 1579 | ||
1580 | if (!cam) | 1580 | if (!cam) |
1581 | return -ENOTTY; | 1581 | return -ENOTTY; |
@@ -1841,7 +1841,7 @@ static int cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
1841 | return retval; | 1841 | return retval; |
1842 | } | 1842 | } |
1843 | 1843 | ||
1844 | static int cpia2_ioctl(struct inode *inode, struct file *file, | 1844 | static long cpia2_ioctl(struct file *file, |
1845 | unsigned int cmd, unsigned long arg) | 1845 | unsigned int cmd, unsigned long arg) |
1846 | { | 1846 | { |
1847 | return video_usercopy(file, cmd, arg, cpia2_do_ioctl); | 1847 | return video_usercopy(file, cmd, arg, cpia2_do_ioctl); |
@@ -1912,17 +1912,13 @@ static void reset_camera_struct_v4l(struct camera_data *cam) | |||
1912 | /*** | 1912 | /*** |
1913 | * The v4l video device structure initialized for this device | 1913 | * The v4l video device structure initialized for this device |
1914 | ***/ | 1914 | ***/ |
1915 | static const struct file_operations fops_template = { | 1915 | static const struct v4l2_file_operations fops_template = { |
1916 | .owner = THIS_MODULE, | 1916 | .owner = THIS_MODULE, |
1917 | .open = cpia2_open, | 1917 | .open = cpia2_open, |
1918 | .release = cpia2_close, | 1918 | .release = cpia2_close, |
1919 | .read = cpia2_v4l_read, | 1919 | .read = cpia2_v4l_read, |
1920 | .poll = cpia2_v4l_poll, | 1920 | .poll = cpia2_v4l_poll, |
1921 | .ioctl = cpia2_ioctl, | 1921 | .ioctl = cpia2_ioctl, |
1922 | .llseek = no_llseek, | ||
1923 | #ifdef CONFIG_COMPAT | ||
1924 | .compat_ioctl = v4l_compat_ioctl32, | ||
1925 | #endif | ||
1926 | .mmap = cpia2_mmap, | 1922 | .mmap = cpia2_mmap, |
1927 | }; | 1923 | }; |
1928 | 1924 | ||
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c index 70fcd0d5de13..14bebf8a116f 100644 --- a/drivers/media/video/cs5345.c +++ b/drivers/media/video/cs5345.c | |||
@@ -95,25 +95,24 @@ static int cs5345_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 97 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
98 | static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 98 | static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
99 | { | 99 | { |
100 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 100 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
101 | 101 | ||
102 | if (!v4l2_chip_match_i2c_client(client, | 102 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
103 | reg->match_type, reg->match_chip)) | ||
104 | return -EINVAL; | 103 | return -EINVAL; |
105 | if (!capable(CAP_SYS_ADMIN)) | 104 | if (!capable(CAP_SYS_ADMIN)) |
106 | return -EPERM; | 105 | return -EPERM; |
106 | reg->size = 1; | ||
107 | reg->val = cs5345_read(sd, reg->reg & 0x1f); | 107 | reg->val = cs5345_read(sd, reg->reg & 0x1f); |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 111 | static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
112 | { | 112 | { |
113 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 113 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
114 | 114 | ||
115 | if (!v4l2_chip_match_i2c_client(client, | 115 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
116 | reg->match_type, reg->match_chip)) | ||
117 | return -EINVAL; | 116 | return -EINVAL; |
118 | if (!capable(CAP_SYS_ADMIN)) | 117 | if (!capable(CAP_SYS_ADMIN)) |
119 | return -EPERM; | 118 | return -EPERM; |
@@ -122,7 +121,7 @@ static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | |||
122 | } | 121 | } |
123 | #endif | 122 | #endif |
124 | 123 | ||
125 | static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 124 | static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
126 | { | 125 | { |
127 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 126 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
128 | 127 | ||
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index cb65d519cf78..7292a6316e63 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c | |||
@@ -102,7 +102,7 @@ static int cs53l32a_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 105 | static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
106 | { | 106 | { |
107 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 107 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
108 | 108 | ||
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 425271a29517..055f6e004b2d 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
@@ -552,7 +552,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end) | |||
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | int cx18_v4l2_close(struct inode *inode, struct file *filp) | 555 | int cx18_v4l2_close(struct file *filp) |
556 | { | 556 | { |
557 | struct cx18_open_id *id = filp->private_data; | 557 | struct cx18_open_id *id = filp->private_data; |
558 | struct cx18 *cx = id->cx; | 558 | struct cx18 *cx = id->cx; |
@@ -650,12 +650,12 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) | |||
650 | return 0; | 650 | return 0; |
651 | } | 651 | } |
652 | 652 | ||
653 | int cx18_v4l2_open(struct inode *inode, struct file *filp) | 653 | int cx18_v4l2_open(struct file *filp) |
654 | { | 654 | { |
655 | int res, x, y = 0; | 655 | int res, x, y = 0; |
656 | struct cx18 *cx = NULL; | 656 | struct cx18 *cx = NULL; |
657 | struct cx18_stream *s = NULL; | 657 | struct cx18_stream *s = NULL; |
658 | int minor = iminor(inode); | 658 | int minor = video_devdata(filp)->minor; |
659 | 659 | ||
660 | /* Find which card this open was on */ | 660 | /* Find which card this open was on */ |
661 | spin_lock(&cx18_cards_lock); | 661 | spin_lock(&cx18_cards_lock); |
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h index 46da0282fc7d..92e2d5dab936 100644 --- a/drivers/media/video/cx18/cx18-fileops.h +++ b/drivers/media/video/cx18/cx18-fileops.h | |||
@@ -22,12 +22,12 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* Testing/Debugging */ | 24 | /* Testing/Debugging */ |
25 | int cx18_v4l2_open(struct inode *inode, struct file *filp); | 25 | int cx18_v4l2_open(struct file *filp); |
26 | ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, | 26 | ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, |
27 | loff_t *pos); | 27 | loff_t *pos); |
28 | ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count, | 28 | ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count, |
29 | loff_t *pos); | 29 | loff_t *pos); |
30 | int cx18_v4l2_close(struct inode *inode, struct file *filp); | 30 | int cx18_v4l2_close(struct file *filp); |
31 | unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait); | 31 | unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait); |
32 | int cx18_start_capture(struct cx18_open_id *id); | 32 | int cx18_start_capture(struct cx18_open_id *id); |
33 | void cx18_stop_capture(struct cx18_open_id *id, int gop_end); | 33 | void cx18_stop_capture(struct cx18_open_id *id, int gop_end); |
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index 8941f58bed7f..83e1c6333126 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -242,7 +242,7 @@ int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg) | |||
242 | return retval; | 242 | return retval; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | if (cmd != VIDIOC_G_CHIP_IDENT) | 245 | if (cmd != VIDIOC_DBG_G_CHIP_IDENT) |
246 | CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n", | 246 | CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n", |
247 | addr, cmd); | 247 | addr, cmd); |
248 | return -ENODEV; | 248 | return -ENODEV; |
@@ -268,17 +268,6 @@ static int cx18_i2c_id_addr(struct cx18 *cx, u32 id) | |||
268 | return retval; | 268 | return retval; |
269 | } | 269 | } |
270 | 270 | ||
271 | /* Find the i2c device name matching the DRIVERID */ | ||
272 | static const char *cx18_i2c_id_name(u32 id) | ||
273 | { | ||
274 | int i; | ||
275 | |||
276 | for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) | ||
277 | if (hw_driverids[i] == id) | ||
278 | return hw_devicenames[i]; | ||
279 | return "unknown device"; | ||
280 | } | ||
281 | |||
282 | /* Find the i2c device name matching the CX18_HW_ flag */ | 271 | /* Find the i2c device name matching the CX18_HW_ flag */ |
283 | static const char *cx18_i2c_hw_name(u32 hw) | 272 | static const char *cx18_i2c_hw_name(u32 hw) |
284 | { | 273 | { |
@@ -326,21 +315,6 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg) | |||
326 | return cx18_call_i2c_client(cx, addr, cmd, arg); | 315 | return cx18_call_i2c_client(cx, addr, cmd, arg); |
327 | } | 316 | } |
328 | 317 | ||
329 | /* Calls i2c device based on I2C driver ID. */ | ||
330 | int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg) | ||
331 | { | ||
332 | int addr; | ||
333 | |||
334 | addr = cx18_i2c_id_addr(cx, id); | ||
335 | if (addr < 0) { | ||
336 | if (cmd != VIDIOC_G_CHIP_IDENT) | ||
337 | CX18_ERR("i2c ID 0x%08x (%s) not found for cmd 0x%x!\n", | ||
338 | id, cx18_i2c_id_name(id), cmd); | ||
339 | return addr; | ||
340 | } | ||
341 | return cx18_call_i2c_client(cx, addr, cmd, arg); | ||
342 | } | ||
343 | |||
344 | /* broadcast cmd for all I2C clients and for the gpio subsystem */ | 318 | /* broadcast cmd for all I2C clients and for the gpio subsystem */ |
345 | void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) | 319 | void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) |
346 | { | 320 | { |
diff --git a/drivers/media/video/cx18/cx18-i2c.h b/drivers/media/video/cx18/cx18-i2c.h index 113c3f9a2cc0..4869739013bd 100644 --- a/drivers/media/video/cx18/cx18-i2c.h +++ b/drivers/media/video/cx18/cx18-i2c.h | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw); | 24 | int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw); |
25 | int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg); | 25 | int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg); |
26 | int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg); | ||
27 | int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg); | 26 | int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg); |
28 | void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg); | 27 | void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg); |
29 | int cx18_i2c_register(struct cx18 *cx, unsigned idx); | 28 | int cx18_i2c_register(struct cx18 *cx, unsigned idx); |
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index e6087486f889..7086aaba77d6 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c | |||
@@ -254,30 +254,24 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, | |||
254 | } | 254 | } |
255 | 255 | ||
256 | static int cx18_g_chip_ident(struct file *file, void *fh, | 256 | static int cx18_g_chip_ident(struct file *file, void *fh, |
257 | struct v4l2_chip_ident *chip) | 257 | struct v4l2_dbg_chip_ident *chip) |
258 | { | 258 | { |
259 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | 259 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
260 | 260 | ||
261 | chip->ident = V4L2_IDENT_NONE; | 261 | chip->ident = V4L2_IDENT_NONE; |
262 | chip->revision = 0; | 262 | chip->revision = 0; |
263 | if (chip->match_type == V4L2_CHIP_MATCH_HOST) { | 263 | if (v4l2_chip_match_host(&chip->match)) { |
264 | if (v4l2_chip_match_host(chip->match_type, chip->match_chip)) | 264 | chip->ident = V4L2_IDENT_CX23418; |
265 | chip->ident = V4L2_IDENT_CX23418; | ||
266 | return 0; | 265 | return 0; |
267 | } | 266 | } |
268 | if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) | 267 | cx18_call_i2c_clients(cx, VIDIOC_DBG_G_CHIP_IDENT, chip); |
269 | return cx18_i2c_id(cx, chip->match_chip, VIDIOC_G_CHIP_IDENT, | 268 | return 0; |
270 | chip); | ||
271 | if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR) | ||
272 | return cx18_call_i2c_client(cx, chip->match_chip, | ||
273 | VIDIOC_G_CHIP_IDENT, chip); | ||
274 | return -EINVAL; | ||
275 | } | 269 | } |
276 | 270 | ||
277 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 271 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
278 | static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) | 272 | static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) |
279 | { | 273 | { |
280 | struct v4l2_register *regs = arg; | 274 | struct v4l2_dbg_register *regs = arg; |
281 | unsigned long flags; | 275 | unsigned long flags; |
282 | 276 | ||
283 | if (!capable(CAP_SYS_ADMIN)) | 277 | if (!capable(CAP_SYS_ADMIN)) |
@@ -286,6 +280,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) | |||
286 | return -EINVAL; | 280 | return -EINVAL; |
287 | 281 | ||
288 | spin_lock_irqsave(&cx18_cards_lock, flags); | 282 | spin_lock_irqsave(&cx18_cards_lock, flags); |
283 | regs->size = 4; | ||
289 | if (cmd == VIDIOC_DBG_G_REGISTER) | 284 | if (cmd == VIDIOC_DBG_G_REGISTER) |
290 | regs->val = cx18_read_enc(cx, regs->reg); | 285 | regs->val = cx18_read_enc(cx, regs->reg); |
291 | else | 286 | else |
@@ -295,31 +290,25 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) | |||
295 | } | 290 | } |
296 | 291 | ||
297 | static int cx18_g_register(struct file *file, void *fh, | 292 | static int cx18_g_register(struct file *file, void *fh, |
298 | struct v4l2_register *reg) | 293 | struct v4l2_dbg_register *reg) |
299 | { | 294 | { |
300 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | 295 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
301 | 296 | ||
302 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 297 | if (v4l2_chip_match_host(®->match)) |
303 | return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg); | 298 | return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg); |
304 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) | 299 | cx18_call_i2c_clients(cx, VIDIOC_DBG_G_REGISTER, reg); |
305 | return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER, | 300 | return 0; |
306 | reg); | ||
307 | return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER, | ||
308 | reg); | ||
309 | } | 301 | } |
310 | 302 | ||
311 | static int cx18_s_register(struct file *file, void *fh, | 303 | static int cx18_s_register(struct file *file, void *fh, |
312 | struct v4l2_register *reg) | 304 | struct v4l2_dbg_register *reg) |
313 | { | 305 | { |
314 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | 306 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
315 | 307 | ||
316 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 308 | if (v4l2_chip_match_host(®->match)) |
317 | return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg); | 309 | return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg); |
318 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) | 310 | cx18_call_i2c_clients(cx, VIDIOC_DBG_S_REGISTER, reg); |
319 | return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER, | 311 | return 0; |
320 | reg); | ||
321 | return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER, | ||
322 | reg); | ||
323 | } | 312 | } |
324 | #endif | 313 | #endif |
325 | 314 | ||
@@ -755,7 +744,7 @@ static int cx18_log_status(struct file *file, void *fh) | |||
755 | return 0; | 744 | return 0; |
756 | } | 745 | } |
757 | 746 | ||
758 | static int cx18_default(struct file *file, void *fh, int cmd, void *arg) | 747 | static long cx18_default(struct file *file, void *fh, int cmd, void *arg) |
759 | { | 748 | { |
760 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | 749 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
761 | 750 | ||
@@ -783,19 +772,19 @@ static int cx18_default(struct file *file, void *fh, int cmd, void *arg) | |||
783 | return 0; | 772 | return 0; |
784 | } | 773 | } |
785 | 774 | ||
786 | int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 775 | long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, |
787 | unsigned long arg) | 776 | unsigned long arg) |
788 | { | 777 | { |
789 | struct video_device *vfd = video_devdata(filp); | 778 | struct video_device *vfd = video_devdata(filp); |
790 | struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; | 779 | struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; |
791 | struct cx18 *cx = id->cx; | 780 | struct cx18 *cx = id->cx; |
792 | int res; | 781 | long res; |
793 | 782 | ||
794 | mutex_lock(&cx->serialize_lock); | 783 | mutex_lock(&cx->serialize_lock); |
795 | 784 | ||
796 | if (cx18_debug & CX18_DBGFLG_IOCTL) | 785 | if (cx18_debug & CX18_DBGFLG_IOCTL) |
797 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; | 786 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; |
798 | res = video_ioctl2(inode, filp, cmd, arg); | 787 | res = video_ioctl2(filp, cmd, arg); |
799 | vfd->debug = 0; | 788 | vfd->debug = 0; |
800 | mutex_unlock(&cx->serialize_lock); | 789 | mutex_unlock(&cx->serialize_lock); |
801 | return res; | 790 | return res; |
diff --git a/drivers/media/video/cx18/cx18-ioctl.h b/drivers/media/video/cx18/cx18-ioctl.h index 08fe24e9510e..e2ca0d152116 100644 --- a/drivers/media/video/cx18/cx18-ioctl.h +++ b/drivers/media/video/cx18/cx18-ioctl.h | |||
@@ -29,5 +29,5 @@ void cx18_set_funcs(struct video_device *vdev); | |||
29 | int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); | 29 | int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); |
30 | int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); | 30 | int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); |
31 | int cx18_s_input(struct file *file, void *fh, unsigned int inp); | 31 | int cx18_s_input(struct file *file, void *fh, unsigned int inp); |
32 | int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 32 | long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, |
33 | unsigned long arg); | 33 | unsigned long arg); |
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 63c336c95ff5..89c1ec94f335 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -37,13 +37,12 @@ | |||
37 | 37 | ||
38 | #define CX18_DSP0_INTERRUPT_MASK 0xd0004C | 38 | #define CX18_DSP0_INTERRUPT_MASK 0xd0004C |
39 | 39 | ||
40 | static struct file_operations cx18_v4l2_enc_fops = { | 40 | static struct v4l2_file_operations cx18_v4l2_enc_fops = { |
41 | .owner = THIS_MODULE, | 41 | .owner = THIS_MODULE, |
42 | .read = cx18_v4l2_read, | 42 | .read = cx18_v4l2_read, |
43 | .open = cx18_v4l2_open, | 43 | .open = cx18_v4l2_open, |
44 | /* FIXME change to video_ioctl2 if serialization lock can be removed */ | 44 | /* FIXME change to video_ioctl2 if serialization lock can be removed */ |
45 | .ioctl = cx18_v4l2_ioctl, | 45 | .ioctl = cx18_v4l2_ioctl, |
46 | .compat_ioctl = v4l_compat_ioctl32, | ||
47 | .release = cx18_v4l2_close, | 46 | .release = cx18_v4l2_close, |
48 | .poll = cx18_v4l2_enc_poll, | 47 | .poll = cx18_v4l2_enc_poll, |
49 | }; | 48 | }; |
@@ -61,49 +60,41 @@ static struct { | |||
61 | int num_offset; | 60 | int num_offset; |
62 | int dma; | 61 | int dma; |
63 | enum v4l2_buf_type buf_type; | 62 | enum v4l2_buf_type buf_type; |
64 | struct file_operations *fops; | ||
65 | } cx18_stream_info[] = { | 63 | } cx18_stream_info[] = { |
66 | { /* CX18_ENC_STREAM_TYPE_MPG */ | 64 | { /* CX18_ENC_STREAM_TYPE_MPG */ |
67 | "encoder MPEG", | 65 | "encoder MPEG", |
68 | VFL_TYPE_GRABBER, 0, | 66 | VFL_TYPE_GRABBER, 0, |
69 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, | 67 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
70 | &cx18_v4l2_enc_fops | ||
71 | }, | 68 | }, |
72 | { /* CX18_ENC_STREAM_TYPE_TS */ | 69 | { /* CX18_ENC_STREAM_TYPE_TS */ |
73 | "TS", | 70 | "TS", |
74 | VFL_TYPE_GRABBER, -1, | 71 | VFL_TYPE_GRABBER, -1, |
75 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, | 72 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
76 | &cx18_v4l2_enc_fops | ||
77 | }, | 73 | }, |
78 | { /* CX18_ENC_STREAM_TYPE_YUV */ | 74 | { /* CX18_ENC_STREAM_TYPE_YUV */ |
79 | "encoder YUV", | 75 | "encoder YUV", |
80 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, | 76 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, |
81 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, | 77 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
82 | &cx18_v4l2_enc_fops | ||
83 | }, | 78 | }, |
84 | { /* CX18_ENC_STREAM_TYPE_VBI */ | 79 | { /* CX18_ENC_STREAM_TYPE_VBI */ |
85 | "encoder VBI", | 80 | "encoder VBI", |
86 | VFL_TYPE_VBI, 0, | 81 | VFL_TYPE_VBI, 0, |
87 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE, | 82 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE, |
88 | &cx18_v4l2_enc_fops | ||
89 | }, | 83 | }, |
90 | { /* CX18_ENC_STREAM_TYPE_PCM */ | 84 | { /* CX18_ENC_STREAM_TYPE_PCM */ |
91 | "encoder PCM audio", | 85 | "encoder PCM audio", |
92 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET, | 86 | VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET, |
93 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE, | 87 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE, |
94 | &cx18_v4l2_enc_fops | ||
95 | }, | 88 | }, |
96 | { /* CX18_ENC_STREAM_TYPE_IDX */ | 89 | { /* CX18_ENC_STREAM_TYPE_IDX */ |
97 | "encoder IDX", | 90 | "encoder IDX", |
98 | VFL_TYPE_GRABBER, -1, | 91 | VFL_TYPE_GRABBER, -1, |
99 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, | 92 | PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
100 | &cx18_v4l2_enc_fops | ||
101 | }, | 93 | }, |
102 | { /* CX18_ENC_STREAM_TYPE_RAD */ | 94 | { /* CX18_ENC_STREAM_TYPE_RAD */ |
103 | "encoder radio", | 95 | "encoder radio", |
104 | VFL_TYPE_RADIO, 0, | 96 | VFL_TYPE_RADIO, 0, |
105 | PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE, | 97 | PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE, |
106 | &cx18_v4l2_enc_fops | ||
107 | }, | 98 | }, |
108 | }; | 99 | }; |
109 | 100 | ||
@@ -184,7 +175,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type) | |||
184 | 175 | ||
185 | s->v4l2dev->num = num; | 176 | s->v4l2dev->num = num; |
186 | s->v4l2dev->parent = &cx->dev->dev; | 177 | s->v4l2dev->parent = &cx->dev->dev; |
187 | s->v4l2dev->fops = cx18_stream_info[type].fops; | 178 | s->v4l2dev->fops = &cx18_v4l2_enc_fops; |
188 | s->v4l2dev->release = video_device_release; | 179 | s->v4l2dev->release = video_device_release; |
189 | s->v4l2dev->tvnorms = V4L2_STD_ALL; | 180 | s->v4l2dev->tvnorms = V4L2_STD_ALL; |
190 | cx18_set_funcs(s->v4l2dev); | 181 | cx18_set_funcs(s->v4l2dev); |
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c index 798d24024353..8f1db57bd1dd 100644 --- a/drivers/media/video/cx23885/cx23885-417.c +++ b/drivers/media/video/cx23885/cx23885-417.c | |||
@@ -1027,12 +1027,13 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev) | |||
1027 | printk(KERN_ERR "%s() f/w load failed\n", __func__); | 1027 | printk(KERN_ERR "%s() f/w load failed\n", __func__); |
1028 | return retval; | 1028 | return retval; |
1029 | } | 1029 | } |
1030 | dev->cx23417_mailbox = cx23885_find_mailbox(dev); | 1030 | retval = cx23885_find_mailbox(dev); |
1031 | if (dev->cx23417_mailbox < 0) { | 1031 | if (retval < 0) { |
1032 | printk(KERN_ERR "%s() mailbox < 0, error\n", | 1032 | printk(KERN_ERR "%s() mailbox < 0, error\n", |
1033 | __func__); | 1033 | __func__); |
1034 | return -1; | 1034 | return -1; |
1035 | } | 1035 | } |
1036 | dev->cx23417_mailbox = retval; | ||
1036 | retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); | 1037 | retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); |
1037 | if (retval < 0) { | 1038 | if (retval < 0) { |
1038 | printk(KERN_ERR | 1039 | printk(KERN_ERR |
@@ -1573,9 +1574,9 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
1573 | return cx23885_queryctrl(dev, c); | 1574 | return cx23885_queryctrl(dev, c); |
1574 | } | 1575 | } |
1575 | 1576 | ||
1576 | static int mpeg_open(struct inode *inode, struct file *file) | 1577 | static int mpeg_open(struct file *file) |
1577 | { | 1578 | { |
1578 | int minor = iminor(inode); | 1579 | int minor = video_devdata(file)->minor; |
1579 | struct cx23885_dev *h, *dev = NULL; | 1580 | struct cx23885_dev *h, *dev = NULL; |
1580 | struct list_head *list; | 1581 | struct list_head *list; |
1581 | struct cx23885_fh *fh; | 1582 | struct cx23885_fh *fh; |
@@ -1617,7 +1618,7 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
1617 | return 0; | 1618 | return 0; |
1618 | } | 1619 | } |
1619 | 1620 | ||
1620 | static int mpeg_release(struct inode *inode, struct file *file) | 1621 | static int mpeg_release(struct file *file) |
1621 | { | 1622 | { |
1622 | struct cx23885_fh *fh = file->private_data; | 1623 | struct cx23885_fh *fh = file->private_data; |
1623 | struct cx23885_dev *dev = fh->dev; | 1624 | struct cx23885_dev *dev = fh->dev; |
@@ -1694,15 +1695,13 @@ static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) | |||
1694 | return videobuf_mmap_mapper(&fh->mpegq, vma); | 1695 | return videobuf_mmap_mapper(&fh->mpegq, vma); |
1695 | } | 1696 | } |
1696 | 1697 | ||
1697 | static struct file_operations mpeg_fops = { | 1698 | static struct v4l2_file_operations mpeg_fops = { |
1698 | .owner = THIS_MODULE, | 1699 | .owner = THIS_MODULE, |
1699 | .open = mpeg_open, | 1700 | .open = mpeg_open, |
1700 | .release = mpeg_release, | 1701 | .release = mpeg_release, |
1701 | .read = mpeg_read, | 1702 | .read = mpeg_read, |
1702 | .poll = mpeg_poll, | 1703 | .poll = mpeg_poll, |
1703 | .mmap = mpeg_mmap, | 1704 | .mmap = mpeg_mmap, |
1704 | .ioctl = video_ioctl2, | ||
1705 | .llseek = no_llseek, | ||
1706 | }; | 1705 | }; |
1707 | 1706 | ||
1708 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | 1707 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index c742a10be5cb..2d81c4d04340 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -718,9 +718,9 @@ static int get_resource(struct cx23885_fh *fh) | |||
718 | } | 718 | } |
719 | } | 719 | } |
720 | 720 | ||
721 | static int video_open(struct inode *inode, struct file *file) | 721 | static int video_open(struct file *file) |
722 | { | 722 | { |
723 | int minor = iminor(inode); | 723 | int minor = video_devdata(file)->minor; |
724 | struct cx23885_dev *h, *dev = NULL; | 724 | struct cx23885_dev *h, *dev = NULL; |
725 | struct cx23885_fh *fh; | 725 | struct cx23885_fh *fh; |
726 | struct list_head *list; | 726 | struct list_head *list; |
@@ -834,7 +834,7 @@ static unsigned int video_poll(struct file *file, | |||
834 | return 0; | 834 | return 0; |
835 | } | 835 | } |
836 | 836 | ||
837 | static int video_release(struct inode *inode, struct file *file) | 837 | static int video_release(struct file *file) |
838 | { | 838 | { |
839 | struct cx23885_fh *fh = file->private_data; | 839 | struct cx23885_fh *fh = file->private_data; |
840 | struct cx23885_dev *dev = fh->dev; | 840 | struct cx23885_dev *dev = fh->dev; |
@@ -1326,11 +1326,11 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1326 | 1326 | ||
1327 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1327 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1328 | static int vidioc_g_register(struct file *file, void *fh, | 1328 | static int vidioc_g_register(struct file *file, void *fh, |
1329 | struct v4l2_register *reg) | 1329 | struct v4l2_dbg_register *reg) |
1330 | { | 1330 | { |
1331 | struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; | 1331 | struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; |
1332 | 1332 | ||
1333 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1333 | if (!v4l2_chip_match_host(®->match)) |
1334 | return -EINVAL; | 1334 | return -EINVAL; |
1335 | 1335 | ||
1336 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg); | 1336 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg); |
@@ -1339,11 +1339,11 @@ static int vidioc_g_register(struct file *file, void *fh, | |||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | static int vidioc_s_register(struct file *file, void *fh, | 1341 | static int vidioc_s_register(struct file *file, void *fh, |
1342 | struct v4l2_register *reg) | 1342 | struct v4l2_dbg_register *reg) |
1343 | { | 1343 | { |
1344 | struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; | 1344 | struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; |
1345 | 1345 | ||
1346 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1346 | if (!v4l2_chip_match_host(®->match)) |
1347 | return -EINVAL; | 1347 | return -EINVAL; |
1348 | 1348 | ||
1349 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg); | 1349 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg); |
@@ -1422,7 +1422,7 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status) | |||
1422 | /* ----------------------------------------------------------- */ | 1422 | /* ----------------------------------------------------------- */ |
1423 | /* exported stuff */ | 1423 | /* exported stuff */ |
1424 | 1424 | ||
1425 | static const struct file_operations video_fops = { | 1425 | static const struct v4l2_file_operations video_fops = { |
1426 | .owner = THIS_MODULE, | 1426 | .owner = THIS_MODULE, |
1427 | .open = video_open, | 1427 | .open = video_open, |
1428 | .release = video_release, | 1428 | .release = video_release, |
@@ -1430,8 +1430,6 @@ static const struct file_operations video_fops = { | |||
1430 | .poll = video_poll, | 1430 | .poll = video_poll, |
1431 | .mmap = video_mmap, | 1431 | .mmap = video_mmap, |
1432 | .ioctl = video_ioctl2, | 1432 | .ioctl = video_ioctl2, |
1433 | .compat_ioctl = v4l_compat_ioctl32, | ||
1434 | .llseek = no_llseek, | ||
1435 | }; | 1433 | }; |
1436 | 1434 | ||
1437 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 1435 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -1479,13 +1477,11 @@ static struct video_device cx23885_video_template = { | |||
1479 | .current_norm = V4L2_STD_NTSC_M, | 1477 | .current_norm = V4L2_STD_NTSC_M, |
1480 | }; | 1478 | }; |
1481 | 1479 | ||
1482 | static const struct file_operations radio_fops = { | 1480 | static const struct v4l2_file_operations radio_fops = { |
1483 | .owner = THIS_MODULE, | 1481 | .owner = THIS_MODULE, |
1484 | .open = video_open, | 1482 | .open = video_open, |
1485 | .release = video_release, | 1483 | .release = video_release, |
1486 | .ioctl = video_ioctl2, | 1484 | .ioctl = video_ioctl2, |
1487 | .compat_ioctl = v4l_compat_ioctl32, | ||
1488 | .llseek = no_llseek, | ||
1489 | }; | 1485 | }; |
1490 | 1486 | ||
1491 | 1487 | ||
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 2ad277189da8..88f2fd32bfe3 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -1120,25 +1120,24 @@ static int cx25840_init(struct v4l2_subdev *sd, u32 val) | |||
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1122 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1123 | static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1123 | static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1124 | { | 1124 | { |
1125 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1125 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1126 | 1126 | ||
1127 | if (!v4l2_chip_match_i2c_client(client, | 1127 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1128 | reg->match_type, reg->match_chip)) | ||
1129 | return -EINVAL; | 1128 | return -EINVAL; |
1130 | if (!capable(CAP_SYS_ADMIN)) | 1129 | if (!capable(CAP_SYS_ADMIN)) |
1131 | return -EPERM; | 1130 | return -EPERM; |
1131 | reg->size = 1; | ||
1132 | reg->val = cx25840_read(client, reg->reg & 0x0fff); | 1132 | reg->val = cx25840_read(client, reg->reg & 0x0fff); |
1133 | return 0; | 1133 | return 0; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1136 | static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1137 | { | 1137 | { |
1138 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1138 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1139 | 1139 | ||
1140 | if (!v4l2_chip_match_i2c_client(client, | 1140 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1141 | reg->match_type, reg->match_chip)) | ||
1142 | return -EINVAL; | 1141 | return -EINVAL; |
1143 | if (!capable(CAP_SYS_ADMIN)) | 1142 | if (!capable(CAP_SYS_ADMIN)) |
1144 | return -EPERM; | 1143 | return -EPERM; |
@@ -1362,7 +1361,7 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val) | |||
1362 | return 0; | 1361 | return 0; |
1363 | } | 1362 | } |
1364 | 1363 | ||
1365 | static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 1364 | static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
1366 | { | 1365 | { |
1367 | struct cx25840_state *state = to_state(sd); | 1366 | struct cx25840_state *state = to_state(sd); |
1368 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1367 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index e162a70748c5..7f5b8bfd08ac 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -1049,16 +1049,16 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
1049 | 1049 | ||
1050 | /* FIXME: cx88_ioctl_hook not implemented */ | 1050 | /* FIXME: cx88_ioctl_hook not implemented */ |
1051 | 1051 | ||
1052 | static int mpeg_open(struct inode *inode, struct file *file) | 1052 | static int mpeg_open(struct file *file) |
1053 | { | 1053 | { |
1054 | int minor = iminor(inode); | 1054 | int minor = video_devdata(file)->minor; |
1055 | struct cx8802_dev *dev = NULL; | 1055 | struct cx8802_dev *dev = NULL; |
1056 | struct cx8802_fh *fh; | 1056 | struct cx8802_fh *fh; |
1057 | struct cx8802_driver *drv = NULL; | 1057 | struct cx8802_driver *drv = NULL; |
1058 | int err; | 1058 | int err; |
1059 | 1059 | ||
1060 | lock_kernel(); | 1060 | lock_kernel(); |
1061 | dev = cx8802_get_device(inode); | 1061 | dev = cx8802_get_device(minor); |
1062 | 1062 | ||
1063 | dprintk( 1, "%s\n", __func__); | 1063 | dprintk( 1, "%s\n", __func__); |
1064 | 1064 | ||
@@ -1114,7 +1114,7 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
1114 | return 0; | 1114 | return 0; |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | static int mpeg_release(struct inode *inode, struct file *file) | 1117 | static int mpeg_release(struct file *file) |
1118 | { | 1118 | { |
1119 | struct cx8802_fh *fh = file->private_data; | 1119 | struct cx8802_fh *fh = file->private_data; |
1120 | struct cx8802_dev *dev = fh->dev; | 1120 | struct cx8802_dev *dev = fh->dev; |
@@ -1132,7 +1132,7 @@ static int mpeg_release(struct inode *inode, struct file *file) | |||
1132 | kfree(fh); | 1132 | kfree(fh); |
1133 | 1133 | ||
1134 | /* Make sure we release the hardware */ | 1134 | /* Make sure we release the hardware */ |
1135 | dev = cx8802_get_device(inode); | 1135 | dev = cx8802_get_device(video_devdata(file)->minor); |
1136 | if (dev == NULL) | 1136 | if (dev == NULL) |
1137 | return -ENODEV; | 1137 | return -ENODEV; |
1138 | 1138 | ||
@@ -1178,7 +1178,7 @@ mpeg_mmap(struct file *file, struct vm_area_struct * vma) | |||
1178 | return videobuf_mmap_mapper(&fh->mpegq, vma); | 1178 | return videobuf_mmap_mapper(&fh->mpegq, vma); |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | static const struct file_operations mpeg_fops = | 1181 | static const struct v4l2_file_operations mpeg_fops = |
1182 | { | 1182 | { |
1183 | .owner = THIS_MODULE, | 1183 | .owner = THIS_MODULE, |
1184 | .open = mpeg_open, | 1184 | .open = mpeg_open, |
@@ -1187,7 +1187,6 @@ static const struct file_operations mpeg_fops = | |||
1187 | .poll = mpeg_poll, | 1187 | .poll = mpeg_poll, |
1188 | .mmap = mpeg_mmap, | 1188 | .mmap = mpeg_mmap, |
1189 | .ioctl = video_ioctl2, | 1189 | .ioctl = video_ioctl2, |
1190 | .llseek = no_llseek, | ||
1191 | }; | 1190 | }; |
1192 | 1191 | ||
1193 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | 1192 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index a04fee235db6..59164fc94f5f 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -578,9 +578,8 @@ static int cx8802_resume_common(struct pci_dev *pci_dev) | |||
578 | 578 | ||
579 | #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ | 579 | #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ |
580 | defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) | 580 | defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) |
581 | struct cx8802_dev * cx8802_get_device(struct inode *inode) | 581 | struct cx8802_dev *cx8802_get_device(int minor) |
582 | { | 582 | { |
583 | int minor = iminor(inode); | ||
584 | struct cx8802_dev *dev; | 583 | struct cx8802_dev *dev; |
585 | 584 | ||
586 | list_for_each_entry(dev, &cx8802_devlist, devlist) | 585 | list_for_each_entry(dev, &cx8802_devlist, devlist) |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index b96ce991d968..791e69d804f9 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -757,9 +757,9 @@ static int get_ressource(struct cx8800_fh *fh) | |||
757 | } | 757 | } |
758 | } | 758 | } |
759 | 759 | ||
760 | static int video_open(struct inode *inode, struct file *file) | 760 | static int video_open(struct file *file) |
761 | { | 761 | { |
762 | int minor = iminor(inode); | 762 | int minor = video_devdata(file)->minor; |
763 | struct cx8800_dev *h,*dev = NULL; | 763 | struct cx8800_dev *h,*dev = NULL; |
764 | struct cx88_core *core; | 764 | struct cx88_core *core; |
765 | struct cx8800_fh *fh; | 765 | struct cx8800_fh *fh; |
@@ -904,7 +904,7 @@ video_poll(struct file *file, struct poll_table_struct *wait) | |||
904 | return 0; | 904 | return 0; |
905 | } | 905 | } |
906 | 906 | ||
907 | static int video_release(struct inode *inode, struct file *file) | 907 | static int video_release(struct file *file) |
908 | { | 908 | { |
909 | struct cx8800_fh *fh = file->private_data; | 909 | struct cx8800_fh *fh = file->private_data; |
910 | struct cx8800_dev *dev = fh->dev; | 910 | struct cx8800_dev *dev = fh->dev; |
@@ -1447,25 +1447,26 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
1447 | 1447 | ||
1448 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1448 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1449 | static int vidioc_g_register (struct file *file, void *fh, | 1449 | static int vidioc_g_register (struct file *file, void *fh, |
1450 | struct v4l2_register *reg) | 1450 | struct v4l2_dbg_register *reg) |
1451 | { | 1451 | { |
1452 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; | 1452 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; |
1453 | 1453 | ||
1454 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1454 | if (!v4l2_chip_match_host(®->match)) |
1455 | return -EINVAL; | 1455 | return -EINVAL; |
1456 | /* cx2388x has a 24-bit register space */ | 1456 | /* cx2388x has a 24-bit register space */ |
1457 | reg->val = cx_read(reg->reg&0xffffff); | 1457 | reg->val = cx_read(reg->reg & 0xffffff); |
1458 | reg->size = 4; | ||
1458 | return 0; | 1459 | return 0; |
1459 | } | 1460 | } |
1460 | 1461 | ||
1461 | static int vidioc_s_register (struct file *file, void *fh, | 1462 | static int vidioc_s_register (struct file *file, void *fh, |
1462 | struct v4l2_register *reg) | 1463 | struct v4l2_dbg_register *reg) |
1463 | { | 1464 | { |
1464 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; | 1465 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; |
1465 | 1466 | ||
1466 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1467 | if (!v4l2_chip_match_host(®->match)) |
1467 | return -EINVAL; | 1468 | return -EINVAL; |
1468 | cx_write(reg->reg&0xffffff, reg->val); | 1469 | cx_write(reg->reg & 0xffffff, reg->val); |
1469 | return 0; | 1470 | return 0; |
1470 | } | 1471 | } |
1471 | #endif | 1472 | #endif |
@@ -1693,7 +1694,7 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id) | |||
1693 | /* ----------------------------------------------------------- */ | 1694 | /* ----------------------------------------------------------- */ |
1694 | /* exported stuff */ | 1695 | /* exported stuff */ |
1695 | 1696 | ||
1696 | static const struct file_operations video_fops = | 1697 | static const struct v4l2_file_operations video_fops = |
1697 | { | 1698 | { |
1698 | .owner = THIS_MODULE, | 1699 | .owner = THIS_MODULE, |
1699 | .open = video_open, | 1700 | .open = video_open, |
@@ -1702,8 +1703,6 @@ static const struct file_operations video_fops = | |||
1702 | .poll = video_poll, | 1703 | .poll = video_poll, |
1703 | .mmap = video_mmap, | 1704 | .mmap = video_mmap, |
1704 | .ioctl = video_ioctl2, | 1705 | .ioctl = video_ioctl2, |
1705 | .compat_ioctl = v4l_compat_ioctl32, | ||
1706 | .llseek = no_llseek, | ||
1707 | }; | 1706 | }; |
1708 | 1707 | ||
1709 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 1708 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -1752,14 +1751,12 @@ static struct video_device cx8800_video_template = { | |||
1752 | .current_norm = V4L2_STD_NTSC_M, | 1751 | .current_norm = V4L2_STD_NTSC_M, |
1753 | }; | 1752 | }; |
1754 | 1753 | ||
1755 | static const struct file_operations radio_fops = | 1754 | static const struct v4l2_file_operations radio_fops = |
1756 | { | 1755 | { |
1757 | .owner = THIS_MODULE, | 1756 | .owner = THIS_MODULE, |
1758 | .open = video_open, | 1757 | .open = video_open, |
1759 | .release = video_release, | 1758 | .release = video_release, |
1760 | .ioctl = video_ioctl2, | 1759 | .ioctl = video_ioctl2, |
1761 | .compat_ioctl = v4l_compat_ioctl32, | ||
1762 | .llseek = no_llseek, | ||
1763 | }; | 1760 | }; |
1764 | 1761 | ||
1765 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 1762 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 20649b25f7ba..eb9ce30dc5e6 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -643,7 +643,7 @@ int cx88_audio_thread(void *data); | |||
643 | 643 | ||
644 | int cx8802_register_driver(struct cx8802_driver *drv); | 644 | int cx8802_register_driver(struct cx8802_driver *drv); |
645 | int cx8802_unregister_driver(struct cx8802_driver *drv); | 645 | int cx8802_unregister_driver(struct cx8802_driver *drv); |
646 | struct cx8802_dev * cx8802_get_device(struct inode *inode); | 646 | struct cx8802_dev *cx8802_get_device(int minor); |
647 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); | 647 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); |
648 | 648 | ||
649 | /* ----------------------------------------------------------- */ | 649 | /* ----------------------------------------------------------- */ |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 15c03f0e69ad..94378ccb7505 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -62,9 +62,9 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) | |||
62 | 62 | ||
63 | dprintk("Stopping isoc\n"); | 63 | dprintk("Stopping isoc\n"); |
64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { | 64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
65 | usb_unlink_urb(dev->adev->urb[i]); | 65 | usb_unlink_urb(dev->adev.urb[i]); |
66 | usb_free_urb(dev->adev->urb[i]); | 66 | usb_free_urb(dev->adev.urb[i]); |
67 | dev->adev->urb[i] = NULL; | 67 | dev->adev.urb[i] = NULL; |
68 | } | 68 | } |
69 | 69 | ||
70 | return 0; | 70 | return 0; |
@@ -81,8 +81,8 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
81 | unsigned int stride; | 81 | unsigned int stride; |
82 | struct snd_pcm_substream *substream; | 82 | struct snd_pcm_substream *substream; |
83 | struct snd_pcm_runtime *runtime; | 83 | struct snd_pcm_runtime *runtime; |
84 | if (dev->adev->capture_pcm_substream) { | 84 | if (dev->adev.capture_pcm_substream) { |
85 | substream = dev->adev->capture_pcm_substream; | 85 | substream = dev->adev.capture_pcm_substream; |
86 | runtime = substream->runtime; | 86 | runtime = substream->runtime; |
87 | stride = runtime->frame_bits >> 3; | 87 | stride = runtime->frame_bits >> 3; |
88 | 88 | ||
@@ -95,7 +95,7 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
95 | if (!length) | 95 | if (!length) |
96 | continue; | 96 | continue; |
97 | 97 | ||
98 | oldptr = dev->adev->hwptr_done_capture; | 98 | oldptr = dev->adev.hwptr_done_capture; |
99 | if (oldptr + length >= runtime->buffer_size) { | 99 | if (oldptr + length >= runtime->buffer_size) { |
100 | unsigned int cnt = | 100 | unsigned int cnt = |
101 | runtime->buffer_size - oldptr; | 101 | runtime->buffer_size - oldptr; |
@@ -110,16 +110,16 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
110 | 110 | ||
111 | snd_pcm_stream_lock(substream); | 111 | snd_pcm_stream_lock(substream); |
112 | 112 | ||
113 | dev->adev->hwptr_done_capture += length; | 113 | dev->adev.hwptr_done_capture += length; |
114 | if (dev->adev->hwptr_done_capture >= | 114 | if (dev->adev.hwptr_done_capture >= |
115 | runtime->buffer_size) | 115 | runtime->buffer_size) |
116 | dev->adev->hwptr_done_capture -= | 116 | dev->adev.hwptr_done_capture -= |
117 | runtime->buffer_size; | 117 | runtime->buffer_size; |
118 | 118 | ||
119 | dev->adev->capture_transfer_done += length; | 119 | dev->adev.capture_transfer_done += length; |
120 | if (dev->adev->capture_transfer_done >= | 120 | if (dev->adev.capture_transfer_done >= |
121 | runtime->period_size) { | 121 | runtime->period_size) { |
122 | dev->adev->capture_transfer_done -= | 122 | dev->adev.capture_transfer_done -= |
123 | runtime->period_size; | 123 | runtime->period_size; |
124 | period_elapsed = 1; | 124 | period_elapsed = 1; |
125 | } | 125 | } |
@@ -131,7 +131,7 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
131 | } | 131 | } |
132 | urb->status = 0; | 132 | urb->status = 0; |
133 | 133 | ||
134 | if (dev->adev->shutdown) | 134 | if (dev->adev.shutdown) |
135 | return; | 135 | return; |
136 | 136 | ||
137 | status = usb_submit_urb(urb, GFP_ATOMIC); | 137 | status = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -154,17 +154,17 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
154 | struct urb *urb; | 154 | struct urb *urb; |
155 | int j, k; | 155 | int j, k; |
156 | 156 | ||
157 | dev->adev->transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); | 157 | dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); |
158 | if (!dev->adev->transfer_buffer[i]) | 158 | if (!dev->adev.transfer_buffer[i]) |
159 | return -ENOMEM; | 159 | return -ENOMEM; |
160 | 160 | ||
161 | memset(dev->adev->transfer_buffer[i], 0x80, sb_size); | 161 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); |
162 | urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); | 162 | urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); |
163 | if (!urb) { | 163 | if (!urb) { |
164 | em28xx_errdev("usb_alloc_urb failed!\n"); | 164 | em28xx_errdev("usb_alloc_urb failed!\n"); |
165 | for (j = 0; j < i; j++) { | 165 | for (j = 0; j < i; j++) { |
166 | usb_free_urb(dev->adev->urb[j]); | 166 | usb_free_urb(dev->adev.urb[j]); |
167 | kfree(dev->adev->transfer_buffer[j]); | 167 | kfree(dev->adev.transfer_buffer[j]); |
168 | } | 168 | } |
169 | return -ENOMEM; | 169 | return -ENOMEM; |
170 | } | 170 | } |
@@ -173,7 +173,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
173 | urb->context = dev; | 173 | urb->context = dev; |
174 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x83); | 174 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x83); |
175 | urb->transfer_flags = URB_ISO_ASAP; | 175 | urb->transfer_flags = URB_ISO_ASAP; |
176 | urb->transfer_buffer = dev->adev->transfer_buffer[i]; | 176 | urb->transfer_buffer = dev->adev.transfer_buffer[i]; |
177 | urb->interval = 1; | 177 | urb->interval = 1; |
178 | urb->complete = em28xx_audio_isocirq; | 178 | urb->complete = em28xx_audio_isocirq; |
179 | urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; | 179 | urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; |
@@ -185,11 +185,11 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
185 | urb->iso_frame_desc[j].length = | 185 | urb->iso_frame_desc[j].length = |
186 | EM28XX_AUDIO_MAX_PACKET_SIZE; | 186 | EM28XX_AUDIO_MAX_PACKET_SIZE; |
187 | } | 187 | } |
188 | dev->adev->urb[i] = urb; | 188 | dev->adev.urb[i] = urb; |
189 | } | 189 | } |
190 | 190 | ||
191 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { | 191 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
192 | errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC); | 192 | errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); |
193 | if (errCode) { | 193 | if (errCode) { |
194 | em28xx_isoc_audio_deinit(dev); | 194 | em28xx_isoc_audio_deinit(dev); |
195 | 195 | ||
@@ -202,16 +202,16 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) | |||
202 | 202 | ||
203 | static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) | 203 | static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) |
204 | { | 204 | { |
205 | dprintk("%s transfer\n", (dev->adev->capture_stream == STREAM_ON)? | 205 | dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON) ? |
206 | "stop" : "start"); | 206 | "stop" : "start"); |
207 | 207 | ||
208 | switch (cmd) { | 208 | switch (cmd) { |
209 | case EM28XX_CAPTURE_STREAM_EN: | 209 | case EM28XX_CAPTURE_STREAM_EN: |
210 | if (dev->adev->capture_stream == STREAM_OFF && arg == 1) { | 210 | if (dev->adev.capture_stream == STREAM_OFF && arg == 1) { |
211 | dev->adev->capture_stream = STREAM_ON; | 211 | dev->adev.capture_stream = STREAM_ON; |
212 | em28xx_init_audio_isoc(dev); | 212 | em28xx_init_audio_isoc(dev); |
213 | } else if (dev->adev->capture_stream == STREAM_ON && arg == 0) { | 213 | } else if (dev->adev.capture_stream == STREAM_ON && arg == 0) { |
214 | dev->adev->capture_stream = STREAM_OFF; | 214 | dev->adev.capture_stream = STREAM_OFF; |
215 | em28xx_isoc_audio_deinit(dev); | 215 | em28xx_isoc_audio_deinit(dev); |
216 | } else { | 216 | } else { |
217 | printk(KERN_ERR "An underrun very likely occurred. " | 217 | printk(KERN_ERR "An underrun very likely occurred. " |
@@ -289,17 +289,17 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) | |||
289 | goto err; | 289 | goto err; |
290 | 290 | ||
291 | runtime->hw = snd_em28xx_hw_capture; | 291 | runtime->hw = snd_em28xx_hw_capture; |
292 | if (dev->alt == 0 && dev->adev->users == 0) { | 292 | if (dev->alt == 0 && dev->adev.users == 0) { |
293 | int errCode; | 293 | int errCode; |
294 | dev->alt = 7; | 294 | dev->alt = 7; |
295 | errCode = usb_set_interface(dev->udev, 0, 7); | 295 | errCode = usb_set_interface(dev->udev, 0, 7); |
296 | dprintk("changing alternate number to 7\n"); | 296 | dprintk("changing alternate number to 7\n"); |
297 | } | 297 | } |
298 | 298 | ||
299 | dev->adev->users++; | 299 | dev->adev.users++; |
300 | 300 | ||
301 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | 301 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); |
302 | dev->adev->capture_pcm_substream = substream; | 302 | dev->adev.capture_pcm_substream = substream; |
303 | runtime->private_data = dev; | 303 | runtime->private_data = dev; |
304 | 304 | ||
305 | return 0; | 305 | return 0; |
@@ -311,7 +311,7 @@ err: | |||
311 | static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) | 311 | static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) |
312 | { | 312 | { |
313 | struct em28xx *dev = snd_pcm_substream_chip(substream); | 313 | struct em28xx *dev = snd_pcm_substream_chip(substream); |
314 | dev->adev->users--; | 314 | dev->adev.users--; |
315 | 315 | ||
316 | dprintk("closing device\n"); | 316 | dprintk("closing device\n"); |
317 | 317 | ||
@@ -320,10 +320,10 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) | |||
320 | em28xx_audio_analog_set(dev); | 320 | em28xx_audio_analog_set(dev); |
321 | mutex_unlock(&dev->lock); | 321 | mutex_unlock(&dev->lock); |
322 | 322 | ||
323 | if (dev->adev->users == 0 && dev->adev->shutdown == 1) { | 323 | if (dev->adev.users == 0 && dev->adev.shutdown == 1) { |
324 | dprintk("audio users: %d\n", dev->adev->users); | 324 | dprintk("audio users: %d\n", dev->adev.users); |
325 | dprintk("disabling audio stream!\n"); | 325 | dprintk("disabling audio stream!\n"); |
326 | dev->adev->shutdown = 0; | 326 | dev->adev.shutdown = 0; |
327 | dprintk("released lock\n"); | 327 | dprintk("released lock\n"); |
328 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); | 328 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); |
329 | } | 329 | } |
@@ -356,7 +356,7 @@ static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream) | |||
356 | 356 | ||
357 | dprintk("Stop capture, if needed\n"); | 357 | dprintk("Stop capture, if needed\n"); |
358 | 358 | ||
359 | if (dev->adev->capture_stream == STREAM_ON) | 359 | if (dev->adev.capture_stream == STREAM_ON) |
360 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); | 360 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); |
361 | 361 | ||
362 | return 0; | 362 | return 0; |
@@ -379,7 +379,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, | |||
379 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); | 379 | em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); |
380 | return 0; | 380 | return 0; |
381 | case SNDRV_PCM_TRIGGER_STOP: | 381 | case SNDRV_PCM_TRIGGER_STOP: |
382 | dev->adev->shutdown = 1; | 382 | dev->adev.shutdown = 1; |
383 | return 0; | 383 | return 0; |
384 | default: | 384 | default: |
385 | return -EINVAL; | 385 | return -EINVAL; |
@@ -393,7 +393,7 @@ static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream | |||
393 | 393 | ||
394 | snd_pcm_uframes_t hwptr_done; | 394 | snd_pcm_uframes_t hwptr_done; |
395 | dev = snd_pcm_substream_chip(substream); | 395 | dev = snd_pcm_substream_chip(substream); |
396 | hwptr_done = dev->adev->hwptr_done_capture; | 396 | hwptr_done = dev->adev.hwptr_done_capture; |
397 | 397 | ||
398 | return hwptr_done; | 398 | return hwptr_done; |
399 | } | 399 | } |
@@ -420,7 +420,7 @@ static struct snd_pcm_ops snd_em28xx_pcm_capture = { | |||
420 | 420 | ||
421 | static int em28xx_audio_init(struct em28xx *dev) | 421 | static int em28xx_audio_init(struct em28xx *dev) |
422 | { | 422 | { |
423 | struct em28xx_audio *adev; | 423 | struct em28xx_audio *adev = &dev->adev; |
424 | struct snd_pcm *pcm; | 424 | struct snd_pcm *pcm; |
425 | struct snd_card *card; | 425 | struct snd_card *card; |
426 | static int devnr; | 426 | static int devnr; |
@@ -438,16 +438,9 @@ static int em28xx_audio_init(struct em28xx *dev) | |||
438 | printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " | 438 | printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " |
439 | "Rechberger\n"); | 439 | "Rechberger\n"); |
440 | 440 | ||
441 | adev = kzalloc(sizeof(*adev), GFP_KERNEL); | ||
442 | if (!adev) { | ||
443 | printk(KERN_ERR "em28xx-audio.c: out of memory\n"); | ||
444 | return -1; | ||
445 | } | ||
446 | card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); | 441 | card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); |
447 | if (card == NULL) { | 442 | if (card == NULL) |
448 | kfree(adev); | ||
449 | return -ENOMEM; | 443 | return -ENOMEM; |
450 | } | ||
451 | 444 | ||
452 | spin_lock_init(&adev->slock); | 445 | spin_lock_init(&adev->slock); |
453 | err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); | 446 | err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); |
@@ -471,7 +464,6 @@ static int em28xx_audio_init(struct em28xx *dev) | |||
471 | } | 464 | } |
472 | adev->sndcard = card; | 465 | adev->sndcard = card; |
473 | adev->udev = dev->udev; | 466 | adev->udev = dev->udev; |
474 | dev->adev = adev; | ||
475 | 467 | ||
476 | return 0; | 468 | return 0; |
477 | } | 469 | } |
@@ -488,10 +480,9 @@ static int em28xx_audio_fini(struct em28xx *dev) | |||
488 | return 0; | 480 | return 0; |
489 | } | 481 | } |
490 | 482 | ||
491 | if (dev->adev) { | 483 | if (dev->adev.sndcard) { |
492 | snd_card_free(dev->adev->sndcard); | 484 | snd_card_free(dev->adev.sndcard); |
493 | kfree(dev->adev); | 485 | dev->adev.sndcard = NULL; |
494 | dev->adev = NULL; | ||
495 | } | 486 | } |
496 | 487 | ||
497 | return 0; | 488 | return 0; |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index f8504518586a..819cceaa6ef4 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -1000,12 +1000,11 @@ void em28xx_wake_i2c(struct em28xx *dev) | |||
1000 | static LIST_HEAD(em28xx_devlist); | 1000 | static LIST_HEAD(em28xx_devlist); |
1001 | static DEFINE_MUTEX(em28xx_devlist_mutex); | 1001 | static DEFINE_MUTEX(em28xx_devlist_mutex); |
1002 | 1002 | ||
1003 | struct em28xx *em28xx_get_device(struct inode *inode, | 1003 | struct em28xx *em28xx_get_device(int minor, |
1004 | enum v4l2_buf_type *fh_type, | 1004 | enum v4l2_buf_type *fh_type, |
1005 | int *has_radio) | 1005 | int *has_radio) |
1006 | { | 1006 | { |
1007 | struct em28xx *h, *dev = NULL; | 1007 | struct em28xx *h, *dev = NULL; |
1008 | int minor = iminor(inode); | ||
1009 | 1008 | ||
1010 | *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1009 | *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1011 | *has_radio = 0; | 1010 | *has_radio = 0; |
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h index 65dcb91bdcc2..24e39c56811e 100644 --- a/drivers/media/video/em28xx/em28xx-reg.h +++ b/drivers/media/video/em28xx/em28xx-reg.h | |||
@@ -160,7 +160,7 @@ | |||
160 | 160 | ||
161 | /* FIXME: Need to be populated with the other chip ID's */ | 161 | /* FIXME: Need to be populated with the other chip ID's */ |
162 | enum em28xx_chip_id { | 162 | enum em28xx_chip_id { |
163 | CHIP_ID_EM2820 = 18, | 163 | CHIP_ID_EM2820 = 18, /* Also used by em2710 */ |
164 | CHIP_ID_EM2840 = 20, | 164 | CHIP_ID_EM2840 = 20, |
165 | CHIP_ID_EM2750 = 33, | 165 | CHIP_ID_EM2750 = 33, |
166 | CHIP_ID_EM2860 = 34, | 166 | CHIP_ID_EM2860 = 34, |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 53527536481e..416b691c33c1 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1154,7 +1154,7 @@ static int em28xx_reg_len(int reg) | |||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | static int vidioc_g_chip_ident(struct file *file, void *priv, | 1156 | static int vidioc_g_chip_ident(struct file *file, void *priv, |
1157 | struct v4l2_chip_ident *chip) | 1157 | struct v4l2_dbg_chip_ident *chip) |
1158 | { | 1158 | { |
1159 | struct em28xx_fh *fh = priv; | 1159 | struct em28xx_fh *fh = priv; |
1160 | struct em28xx *dev = fh->dev; | 1160 | struct em28xx *dev = fh->dev; |
@@ -1162,20 +1162,20 @@ static int vidioc_g_chip_ident(struct file *file, void *priv, | |||
1162 | chip->ident = V4L2_IDENT_NONE; | 1162 | chip->ident = V4L2_IDENT_NONE; |
1163 | chip->revision = 0; | 1163 | chip->revision = 0; |
1164 | 1164 | ||
1165 | em28xx_i2c_call_clients(dev, VIDIOC_G_CHIP_IDENT, chip); | 1165 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); |
1166 | 1166 | ||
1167 | return 0; | 1167 | return 0; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | 1170 | ||
1171 | static int vidioc_g_register(struct file *file, void *priv, | 1171 | static int vidioc_g_register(struct file *file, void *priv, |
1172 | struct v4l2_register *reg) | 1172 | struct v4l2_dbg_register *reg) |
1173 | { | 1173 | { |
1174 | struct em28xx_fh *fh = priv; | 1174 | struct em28xx_fh *fh = priv; |
1175 | struct em28xx *dev = fh->dev; | 1175 | struct em28xx *dev = fh->dev; |
1176 | int ret; | 1176 | int ret; |
1177 | 1177 | ||
1178 | switch (reg->match_type) { | 1178 | switch (reg->match.type) { |
1179 | case V4L2_CHIP_MATCH_AC97: | 1179 | case V4L2_CHIP_MATCH_AC97: |
1180 | mutex_lock(&dev->lock); | 1180 | mutex_lock(&dev->lock); |
1181 | ret = em28xx_read_ac97(dev, reg->reg); | 1181 | ret = em28xx_read_ac97(dev, reg->reg); |
@@ -1184,6 +1184,7 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1184 | return ret; | 1184 | return ret; |
1185 | 1185 | ||
1186 | reg->val = ret; | 1186 | reg->val = ret; |
1187 | reg->size = 1; | ||
1187 | return 0; | 1188 | return 0; |
1188 | case V4L2_CHIP_MATCH_I2C_DRIVER: | 1189 | case V4L2_CHIP_MATCH_I2C_DRIVER: |
1189 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg); | 1190 | em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg); |
@@ -1192,12 +1193,13 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1192 | /* Not supported yet */ | 1193 | /* Not supported yet */ |
1193 | return -EINVAL; | 1194 | return -EINVAL; |
1194 | default: | 1195 | default: |
1195 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1196 | if (!v4l2_chip_match_host(®->match)) |
1196 | return -EINVAL; | 1197 | return -EINVAL; |
1197 | } | 1198 | } |
1198 | 1199 | ||
1199 | /* Match host */ | 1200 | /* Match host */ |
1200 | if (em28xx_reg_len(reg->reg) == 1) { | 1201 | reg->size = em28xx_reg_len(reg->reg); |
1202 | if (reg->size == 1) { | ||
1201 | mutex_lock(&dev->lock); | 1203 | mutex_lock(&dev->lock); |
1202 | ret = em28xx_read_reg(dev, reg->reg); | 1204 | ret = em28xx_read_reg(dev, reg->reg); |
1203 | mutex_unlock(&dev->lock); | 1205 | mutex_unlock(&dev->lock); |
@@ -1207,7 +1209,7 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1207 | 1209 | ||
1208 | reg->val = ret; | 1210 | reg->val = ret; |
1209 | } else { | 1211 | } else { |
1210 | __le64 val = 0; | 1212 | __le16 val = 0; |
1211 | mutex_lock(&dev->lock); | 1213 | mutex_lock(&dev->lock); |
1212 | ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, | 1214 | ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, |
1213 | reg->reg, (char *)&val, 2); | 1215 | reg->reg, (char *)&val, 2); |
@@ -1215,21 +1217,21 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1215 | if (ret < 0) | 1217 | if (ret < 0) |
1216 | return ret; | 1218 | return ret; |
1217 | 1219 | ||
1218 | reg->val = le64_to_cpu(val); | 1220 | reg->val = le16_to_cpu(val); |
1219 | } | 1221 | } |
1220 | 1222 | ||
1221 | return 0; | 1223 | return 0; |
1222 | } | 1224 | } |
1223 | 1225 | ||
1224 | static int vidioc_s_register(struct file *file, void *priv, | 1226 | static int vidioc_s_register(struct file *file, void *priv, |
1225 | struct v4l2_register *reg) | 1227 | struct v4l2_dbg_register *reg) |
1226 | { | 1228 | { |
1227 | struct em28xx_fh *fh = priv; | 1229 | struct em28xx_fh *fh = priv; |
1228 | struct em28xx *dev = fh->dev; | 1230 | struct em28xx *dev = fh->dev; |
1229 | __le64 buf; | 1231 | __le16 buf; |
1230 | int rc; | 1232 | int rc; |
1231 | 1233 | ||
1232 | switch (reg->match_type) { | 1234 | switch (reg->match.type) { |
1233 | case V4L2_CHIP_MATCH_AC97: | 1235 | case V4L2_CHIP_MATCH_AC97: |
1234 | mutex_lock(&dev->lock); | 1236 | mutex_lock(&dev->lock); |
1235 | rc = em28xx_write_ac97(dev, reg->reg, reg->val); | 1237 | rc = em28xx_write_ac97(dev, reg->reg, reg->val); |
@@ -1243,12 +1245,12 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1243 | /* Not supported yet */ | 1245 | /* Not supported yet */ |
1244 | return -EINVAL; | 1246 | return -EINVAL; |
1245 | default: | 1247 | default: |
1246 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1248 | if (!v4l2_chip_match_host(®->match)) |
1247 | return -EINVAL; | 1249 | return -EINVAL; |
1248 | } | 1250 | } |
1249 | 1251 | ||
1250 | /* Match host */ | 1252 | /* Match host */ |
1251 | buf = cpu_to_le64(reg->val); | 1253 | buf = cpu_to_le16(reg->val); |
1252 | 1254 | ||
1253 | mutex_lock(&dev->lock); | 1255 | mutex_lock(&dev->lock); |
1254 | rc = em28xx_write_regs(dev, reg->reg, (char *)&buf, | 1256 | rc = em28xx_write_regs(dev, reg->reg, (char *)&buf, |
@@ -1582,15 +1584,15 @@ static int radio_queryctrl(struct file *file, void *priv, | |||
1582 | * em28xx_v4l2_open() | 1584 | * em28xx_v4l2_open() |
1583 | * inits the device and starts isoc transfer | 1585 | * inits the device and starts isoc transfer |
1584 | */ | 1586 | */ |
1585 | static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | 1587 | static int em28xx_v4l2_open(struct file *filp) |
1586 | { | 1588 | { |
1587 | int minor = iminor(inode); | 1589 | int minor = video_devdata(filp)->minor; |
1588 | int errCode = 0, radio; | 1590 | int errCode = 0, radio; |
1589 | struct em28xx *dev; | 1591 | struct em28xx *dev; |
1590 | enum v4l2_buf_type fh_type; | 1592 | enum v4l2_buf_type fh_type; |
1591 | struct em28xx_fh *fh; | 1593 | struct em28xx_fh *fh; |
1592 | 1594 | ||
1593 | dev = em28xx_get_device(inode, &fh_type, &radio); | 1595 | dev = em28xx_get_device(minor, &fh_type, &radio); |
1594 | 1596 | ||
1595 | if (NULL == dev) | 1597 | if (NULL == dev) |
1596 | return -ENODEV; | 1598 | return -ENODEV; |
@@ -1686,7 +1688,7 @@ void em28xx_release_analog_resources(struct em28xx *dev) | |||
1686 | * stops streaming and deallocates all resources allocated by the v4l2 | 1688 | * stops streaming and deallocates all resources allocated by the v4l2 |
1687 | * calls and ioctls | 1689 | * calls and ioctls |
1688 | */ | 1690 | */ |
1689 | static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | 1691 | static int em28xx_v4l2_close(struct file *filp) |
1690 | { | 1692 | { |
1691 | struct em28xx_fh *fh = filp->private_data; | 1693 | struct em28xx_fh *fh = filp->private_data; |
1692 | struct em28xx *dev = fh->dev; | 1694 | struct em28xx *dev = fh->dev; |
@@ -1826,7 +1828,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1826 | return rc; | 1828 | return rc; |
1827 | } | 1829 | } |
1828 | 1830 | ||
1829 | static const struct file_operations em28xx_v4l_fops = { | 1831 | static const struct v4l2_file_operations em28xx_v4l_fops = { |
1830 | .owner = THIS_MODULE, | 1832 | .owner = THIS_MODULE, |
1831 | .open = em28xx_v4l2_open, | 1833 | .open = em28xx_v4l2_open, |
1832 | .release = em28xx_v4l2_close, | 1834 | .release = em28xx_v4l2_close, |
@@ -1834,8 +1836,6 @@ static const struct file_operations em28xx_v4l_fops = { | |||
1834 | .poll = em28xx_v4l2_poll, | 1836 | .poll = em28xx_v4l2_poll, |
1835 | .mmap = em28xx_v4l2_mmap, | 1837 | .mmap = em28xx_v4l2_mmap, |
1836 | .ioctl = video_ioctl2, | 1838 | .ioctl = video_ioctl2, |
1837 | .llseek = no_llseek, | ||
1838 | .compat_ioctl = v4l_compat_ioctl32, | ||
1839 | }; | 1839 | }; |
1840 | 1840 | ||
1841 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 1841 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -1890,13 +1890,11 @@ static const struct video_device em28xx_video_template = { | |||
1890 | .current_norm = V4L2_STD_PAL, | 1890 | .current_norm = V4L2_STD_PAL, |
1891 | }; | 1891 | }; |
1892 | 1892 | ||
1893 | static const struct file_operations radio_fops = { | 1893 | static const struct v4l2_file_operations radio_fops = { |
1894 | .owner = THIS_MODULE, | 1894 | .owner = THIS_MODULE, |
1895 | .open = em28xx_v4l2_open, | 1895 | .open = em28xx_v4l2_open, |
1896 | .release = em28xx_v4l2_close, | 1896 | .release = em28xx_v4l2_close, |
1897 | .ioctl = video_ioctl2, | 1897 | .ioctl = video_ioctl2, |
1898 | .compat_ioctl = v4l_compat_ioctl32, | ||
1899 | .llseek = no_llseek, | ||
1900 | }; | 1898 | }; |
1901 | 1899 | ||
1902 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 1900 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index b5eddc26388e..6c6b94aa05b2 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -473,7 +473,7 @@ struct em28xx { | |||
473 | unsigned long i2c_hash; /* i2c devicelist hash - | 473 | unsigned long i2c_hash; /* i2c devicelist hash - |
474 | for boards with generic ID */ | 474 | for boards with generic ID */ |
475 | 475 | ||
476 | struct em28xx_audio *adev; | 476 | struct em28xx_audio adev; |
477 | 477 | ||
478 | /* states */ | 478 | /* states */ |
479 | enum em28xx_dev_state state; | 479 | enum em28xx_dev_state state; |
@@ -583,7 +583,7 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); | |||
583 | void em28xx_wake_i2c(struct em28xx *dev); | 583 | void em28xx_wake_i2c(struct em28xx *dev); |
584 | void em28xx_remove_from_devlist(struct em28xx *dev); | 584 | void em28xx_remove_from_devlist(struct em28xx *dev); |
585 | void em28xx_add_into_devlist(struct em28xx *dev); | 585 | void em28xx_add_into_devlist(struct em28xx *dev); |
586 | struct em28xx *em28xx_get_device(struct inode *inode, | 586 | struct em28xx *em28xx_get_device(int minor, |
587 | enum v4l2_buf_type *fh_type, | 587 | enum v4l2_buf_type *fh_type, |
588 | int *has_radio); | 588 | int *has_radio); |
589 | int em28xx_register_extension(struct em28xx_ops *dev); | 589 | int em28xx_register_extension(struct em28xx_ops *dev); |
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index 83c07112c59d..d1c1e457f0b9 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c | |||
@@ -1206,7 +1206,7 @@ static void et61x251_release_resources(struct kref *kref) | |||
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | 1208 | ||
1209 | static int et61x251_open(struct inode* inode, struct file* filp) | 1209 | static int et61x251_open(struct file *filp) |
1210 | { | 1210 | { |
1211 | struct et61x251_device* cam; | 1211 | struct et61x251_device* cam; |
1212 | int err = 0; | 1212 | int err = 0; |
@@ -1291,7 +1291,7 @@ out: | |||
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | static int et61x251_release(struct inode* inode, struct file* filp) | 1294 | static int et61x251_release(struct file *filp) |
1295 | { | 1295 | { |
1296 | struct et61x251_device* cam; | 1296 | struct et61x251_device* cam; |
1297 | 1297 | ||
@@ -2392,8 +2392,8 @@ et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg) | |||
2392 | } | 2392 | } |
2393 | 2393 | ||
2394 | 2394 | ||
2395 | static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, | 2395 | static long et61x251_ioctl_v4l2(struct file *filp, |
2396 | unsigned int cmd, void __user * arg) | 2396 | unsigned int cmd, void __user *arg) |
2397 | { | 2397 | { |
2398 | struct et61x251_device *cam = video_drvdata(filp); | 2398 | struct et61x251_device *cam = video_drvdata(filp); |
2399 | 2399 | ||
@@ -2487,11 +2487,11 @@ static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, | |||
2487 | } | 2487 | } |
2488 | 2488 | ||
2489 | 2489 | ||
2490 | static int et61x251_ioctl(struct inode* inode, struct file* filp, | 2490 | static long et61x251_ioctl(struct file *filp, |
2491 | unsigned int cmd, unsigned long arg) | 2491 | unsigned int cmd, unsigned long arg) |
2492 | { | 2492 | { |
2493 | struct et61x251_device *cam = video_drvdata(filp); | 2493 | struct et61x251_device *cam = video_drvdata(filp); |
2494 | int err = 0; | 2494 | long err = 0; |
2495 | 2495 | ||
2496 | if (mutex_lock_interruptible(&cam->fileop_mutex)) | 2496 | if (mutex_lock_interruptible(&cam->fileop_mutex)) |
2497 | return -ERESTARTSYS; | 2497 | return -ERESTARTSYS; |
@@ -2511,7 +2511,7 @@ static int et61x251_ioctl(struct inode* inode, struct file* filp, | |||
2511 | 2511 | ||
2512 | V4LDBG(3, "et61x251", cmd); | 2512 | V4LDBG(3, "et61x251", cmd); |
2513 | 2513 | ||
2514 | err = et61x251_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); | 2514 | err = et61x251_ioctl_v4l2(filp, cmd, (void __user *)arg); |
2515 | 2515 | ||
2516 | mutex_unlock(&cam->fileop_mutex); | 2516 | mutex_unlock(&cam->fileop_mutex); |
2517 | 2517 | ||
@@ -2519,18 +2519,14 @@ static int et61x251_ioctl(struct inode* inode, struct file* filp, | |||
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | 2521 | ||
2522 | static const struct file_operations et61x251_fops = { | 2522 | static const struct v4l2_file_operations et61x251_fops = { |
2523 | .owner = THIS_MODULE, | 2523 | .owner = THIS_MODULE, |
2524 | .open = et61x251_open, | 2524 | .open = et61x251_open, |
2525 | .release = et61x251_release, | 2525 | .release = et61x251_release, |
2526 | .ioctl = et61x251_ioctl, | 2526 | .ioctl = et61x251_ioctl, |
2527 | #ifdef CONFIG_COMPAT | ||
2528 | .compat_ioctl = v4l_compat_ioctl32, | ||
2529 | #endif | ||
2530 | .read = et61x251_read, | 2527 | .read = et61x251_read, |
2531 | .poll = et61x251_poll, | 2528 | .poll = et61x251_poll, |
2532 | .mmap = et61x251_mmap, | 2529 | .mmap = et61x251_mmap, |
2533 | .llseek = no_llseek, | ||
2534 | }; | 2530 | }; |
2535 | 2531 | ||
2536 | /*****************************************************************************/ | 2532 | /*****************************************************************************/ |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 8b9f3bde5740..5e36b9a4ae3e 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -875,7 +875,7 @@ static void gspca_release(struct video_device *vfd) | |||
875 | kfree(gspca_dev); | 875 | kfree(gspca_dev); |
876 | } | 876 | } |
877 | 877 | ||
878 | static int dev_open(struct inode *inode, struct file *file) | 878 | static int dev_open(struct file *file) |
879 | { | 879 | { |
880 | struct gspca_dev *gspca_dev; | 880 | struct gspca_dev *gspca_dev; |
881 | int ret; | 881 | int ret; |
@@ -922,7 +922,7 @@ out: | |||
922 | return ret; | 922 | return ret; |
923 | } | 923 | } |
924 | 924 | ||
925 | static int dev_close(struct inode *inode, struct file *file) | 925 | static int dev_close(struct file *file) |
926 | { | 926 | { |
927 | struct gspca_dev *gspca_dev = file->private_data; | 927 | struct gspca_dev *gspca_dev = file->private_data; |
928 | 928 | ||
@@ -1802,17 +1802,13 @@ out: | |||
1802 | return ret; | 1802 | return ret; |
1803 | } | 1803 | } |
1804 | 1804 | ||
1805 | static struct file_operations dev_fops = { | 1805 | static struct v4l2_file_operations dev_fops = { |
1806 | .owner = THIS_MODULE, | 1806 | .owner = THIS_MODULE, |
1807 | .open = dev_open, | 1807 | .open = dev_open, |
1808 | .release = dev_close, | 1808 | .release = dev_close, |
1809 | .read = dev_read, | 1809 | .read = dev_read, |
1810 | .mmap = dev_mmap, | 1810 | .mmap = dev_mmap, |
1811 | .unlocked_ioctl = __video_ioctl2, | 1811 | .unlocked_ioctl = video_ioctl2, |
1812 | #ifdef CONFIG_COMPAT | ||
1813 | .compat_ioctl = v4l_compat_ioctl32, | ||
1814 | #endif | ||
1815 | .llseek = no_llseek, | ||
1816 | .poll = dev_poll, | 1812 | .poll = dev_poll, |
1817 | }; | 1813 | }; |
1818 | 1814 | ||
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c index 352f84d440fb..79393d1772e4 100644 --- a/drivers/media/video/hexium_gemini.c +++ b/drivers/media/video/hexium_gemini.c | |||
@@ -306,7 +306,7 @@ static int hexium_detach(struct saa7146_dev *dev) | |||
306 | return 0; | 306 | return 0; |
307 | } | 307 | } |
308 | 308 | ||
309 | static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | 309 | static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) |
310 | { | 310 | { |
311 | struct saa7146_dev *dev = fh->dev; | 311 | struct saa7146_dev *dev = fh->dev; |
312 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | 312 | struct hexium *hexium = (struct hexium *) dev->ext_priv; |
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c index 8d3c1482e7ea..074bec711fe0 100644 --- a/drivers/media/video/hexium_orion.c +++ b/drivers/media/video/hexium_orion.c | |||
@@ -370,7 +370,7 @@ static int hexium_detach(struct saa7146_dev *dev) | |||
370 | return 0; | 370 | return 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | 373 | static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) |
374 | { | 374 | { |
375 | struct saa7146_dev *dev = fh->dev; | 375 | struct saa7146_dev *dev = fh->dev; |
376 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | 376 | struct hexium *hexium = (struct hexium *) dev->ext_priv; |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 08b762951759..e8e5921cdc34 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -902,18 +902,19 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
902 | } | 902 | } |
903 | 903 | ||
904 | if (hw & IVTV_HW_SAA711X) { | 904 | if (hw & IVTV_HW_SAA711X) { |
905 | struct v4l2_chip_ident v = { V4L2_CHIP_MATCH_I2C_DRIVER, I2C_DRIVERID_SAA711X }; | 905 | struct v4l2_dbg_chip_ident v; |
906 | 906 | ||
907 | /* determine the exact saa711x model */ | 907 | /* determine the exact saa711x model */ |
908 | itv->hw_flags &= ~IVTV_HW_SAA711X; | 908 | itv->hw_flags &= ~IVTV_HW_SAA711X; |
909 | 909 | ||
910 | v.match.type = V4L2_CHIP_MATCH_I2C_DRIVER; | ||
911 | strlcpy(v.match.name, "saa7115", sizeof(v.match.name)); | ||
910 | ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v); | 912 | ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v); |
911 | if (v.ident == V4L2_IDENT_SAA7114) { | 913 | if (v.ident == V4L2_IDENT_SAA7114) { |
912 | itv->hw_flags |= IVTV_HW_SAA7114; | 914 | itv->hw_flags |= IVTV_HW_SAA7114; |
913 | /* VBI is not yet supported by the saa7114 driver. */ | 915 | /* VBI is not yet supported by the saa7114 driver. */ |
914 | itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); | 916 | itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); |
915 | } | 917 | } else { |
916 | else { | ||
917 | itv->hw_flags |= IVTV_HW_SAA7115; | 918 | itv->hw_flags |= IVTV_HW_SAA7115; |
918 | } | 919 | } |
919 | itv->vbi.raw_decoder_line_size = 1443; | 920 | itv->vbi.raw_decoder_line_size = 1443; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 5eb587592e9d..d594bc29f07f 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -831,7 +831,7 @@ static void ivtv_stop_decoding(struct ivtv_open_id *id, int flags, u64 pts) | |||
831 | ivtv_release_stream(s); | 831 | ivtv_release_stream(s); |
832 | } | 832 | } |
833 | 833 | ||
834 | int ivtv_v4l2_close(struct inode *inode, struct file *filp) | 834 | int ivtv_v4l2_close(struct file *filp) |
835 | { | 835 | { |
836 | struct ivtv_open_id *id = filp->private_data; | 836 | struct ivtv_open_id *id = filp->private_data; |
837 | struct ivtv *itv = id->itv; | 837 | struct ivtv *itv = id->itv; |
@@ -978,7 +978,7 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp) | |||
978 | return 0; | 978 | return 0; |
979 | } | 979 | } |
980 | 980 | ||
981 | int ivtv_v4l2_open(struct inode *inode, struct file *filp) | 981 | int ivtv_v4l2_open(struct file *filp) |
982 | { | 982 | { |
983 | int res; | 983 | int res; |
984 | struct ivtv *itv = NULL; | 984 | struct ivtv *itv = NULL; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.h b/drivers/media/video/ivtv/ivtv-fileops.h index df81e790147f..049a2923965d 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.h +++ b/drivers/media/video/ivtv/ivtv-fileops.h | |||
@@ -22,12 +22,12 @@ | |||
22 | #define IVTV_FILEOPS_H | 22 | #define IVTV_FILEOPS_H |
23 | 23 | ||
24 | /* Testing/Debugging */ | 24 | /* Testing/Debugging */ |
25 | int ivtv_v4l2_open(struct inode *inode, struct file *filp); | 25 | int ivtv_v4l2_open(struct file *filp); |
26 | ssize_t ivtv_v4l2_read(struct file *filp, char __user *buf, size_t count, | 26 | ssize_t ivtv_v4l2_read(struct file *filp, char __user *buf, size_t count, |
27 | loff_t * pos); | 27 | loff_t * pos); |
28 | ssize_t ivtv_v4l2_write(struct file *filp, const char __user *buf, size_t count, | 28 | ssize_t ivtv_v4l2_write(struct file *filp, const char __user *buf, size_t count, |
29 | loff_t * pos); | 29 | loff_t * pos); |
30 | int ivtv_v4l2_close(struct inode *inode, struct file *filp); | 30 | int ivtv_v4l2_close(struct file *filp); |
31 | unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait); | 31 | unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait); |
32 | unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table * wait); | 32 | unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table * wait); |
33 | int ivtv_start_capture(struct ivtv_open_id *id); | 33 | int ivtv_start_capture(struct ivtv_open_id *id); |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index cd990a4b81a9..f6b3ef6e691b 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -674,19 +674,19 @@ static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_f | |||
674 | return ret; | 674 | return ret; |
675 | } | 675 | } |
676 | 676 | ||
677 | static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident *chip) | 677 | static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip) |
678 | { | 678 | { |
679 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 679 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
680 | 680 | ||
681 | chip->ident = V4L2_IDENT_NONE; | 681 | chip->ident = V4L2_IDENT_NONE; |
682 | chip->revision = 0; | 682 | chip->revision = 0; |
683 | if (chip->match_type == V4L2_CHIP_MATCH_HOST) { | 683 | if (chip->match.type == V4L2_CHIP_MATCH_HOST) { |
684 | if (v4l2_chip_match_host(chip->match_type, chip->match_chip)) | 684 | if (v4l2_chip_match_host(&chip->match)) |
685 | chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; | 685 | chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; |
686 | return 0; | 686 | return 0; |
687 | } | 687 | } |
688 | if (chip->match_type != V4L2_CHIP_MATCH_I2C_DRIVER && | 688 | if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && |
689 | chip->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | 689 | chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
690 | return -EINVAL; | 690 | return -EINVAL; |
691 | /* TODO: is this correct? */ | 691 | /* TODO: is this correct? */ |
692 | return ivtv_call_all_err(itv, core, g_chip_ident, chip); | 692 | return ivtv_call_all_err(itv, core, g_chip_ident, chip); |
@@ -695,7 +695,7 @@ static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident | |||
695 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 695 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
696 | static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) | 696 | static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) |
697 | { | 697 | { |
698 | struct v4l2_register *regs = arg; | 698 | struct v4l2_dbg_register *regs = arg; |
699 | volatile u8 __iomem *reg_start; | 699 | volatile u8 __iomem *reg_start; |
700 | 700 | ||
701 | if (!capable(CAP_SYS_ADMIN)) | 701 | if (!capable(CAP_SYS_ADMIN)) |
@@ -710,6 +710,7 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) | |||
710 | else | 710 | else |
711 | return -EINVAL; | 711 | return -EINVAL; |
712 | 712 | ||
713 | regs->size = 4; | ||
713 | if (cmd == VIDIOC_DBG_G_REGISTER) | 714 | if (cmd == VIDIOC_DBG_G_REGISTER) |
714 | regs->val = readl(regs->reg + reg_start); | 715 | regs->val = readl(regs->reg + reg_start); |
715 | else | 716 | else |
@@ -717,11 +718,11 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) | |||
717 | return 0; | 718 | return 0; |
718 | } | 719 | } |
719 | 720 | ||
720 | static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *reg) | 721 | static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) |
721 | { | 722 | { |
722 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 723 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
723 | 724 | ||
724 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 725 | if (v4l2_chip_match_host(®->match)) |
725 | return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg); | 726 | return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg); |
726 | /* TODO: subdev errors should not be ignored, this should become a | 727 | /* TODO: subdev errors should not be ignored, this should become a |
727 | subdev helper function. */ | 728 | subdev helper function. */ |
@@ -729,11 +730,11 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *re | |||
729 | return 0; | 730 | return 0; |
730 | } | 731 | } |
731 | 732 | ||
732 | static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *reg) | 733 | static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) |
733 | { | 734 | { |
734 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 735 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
735 | 736 | ||
736 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 737 | if (v4l2_chip_match_host(®->match)) |
737 | return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg); | 738 | return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg); |
738 | /* TODO: subdev errors should not be ignored, this should become a | 739 | /* TODO: subdev errors should not be ignored, this should become a |
739 | subdev helper function. */ | 740 | subdev helper function. */ |
@@ -1725,7 +1726,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
1725 | return 0; | 1726 | return 0; |
1726 | } | 1727 | } |
1727 | 1728 | ||
1728 | static int ivtv_default(struct file *file, void *fh, int cmd, void *arg) | 1729 | static long ivtv_default(struct file *file, void *fh, int cmd, void *arg) |
1729 | { | 1730 | { |
1730 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 1731 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
1731 | 1732 | ||
@@ -1827,7 +1828,7 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp, | |||
1827 | 1828 | ||
1828 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) | 1829 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) |
1829 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; | 1830 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; |
1830 | ret = __video_ioctl2(filp, cmd, arg); | 1831 | ret = video_ioctl2(filp, cmd, arg); |
1831 | vfd->debug = 0; | 1832 | vfd->debug = 0; |
1832 | return ret; | 1833 | return ret; |
1833 | } | 1834 | } |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index f77d764707b2..854a950af78c 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -43,24 +43,22 @@ | |||
43 | #include "ivtv-cards.h" | 43 | #include "ivtv-cards.h" |
44 | #include "ivtv-streams.h" | 44 | #include "ivtv-streams.h" |
45 | 45 | ||
46 | static const struct file_operations ivtv_v4l2_enc_fops = { | 46 | static const struct v4l2_file_operations ivtv_v4l2_enc_fops = { |
47 | .owner = THIS_MODULE, | 47 | .owner = THIS_MODULE, |
48 | .read = ivtv_v4l2_read, | 48 | .read = ivtv_v4l2_read, |
49 | .write = ivtv_v4l2_write, | 49 | .write = ivtv_v4l2_write, |
50 | .open = ivtv_v4l2_open, | 50 | .open = ivtv_v4l2_open, |
51 | .unlocked_ioctl = ivtv_v4l2_ioctl, | 51 | .unlocked_ioctl = ivtv_v4l2_ioctl, |
52 | .compat_ioctl = v4l_compat_ioctl32, | ||
53 | .release = ivtv_v4l2_close, | 52 | .release = ivtv_v4l2_close, |
54 | .poll = ivtv_v4l2_enc_poll, | 53 | .poll = ivtv_v4l2_enc_poll, |
55 | }; | 54 | }; |
56 | 55 | ||
57 | static const struct file_operations ivtv_v4l2_dec_fops = { | 56 | static const struct v4l2_file_operations ivtv_v4l2_dec_fops = { |
58 | .owner = THIS_MODULE, | 57 | .owner = THIS_MODULE, |
59 | .read = ivtv_v4l2_read, | 58 | .read = ivtv_v4l2_read, |
60 | .write = ivtv_v4l2_write, | 59 | .write = ivtv_v4l2_write, |
61 | .open = ivtv_v4l2_open, | 60 | .open = ivtv_v4l2_open, |
62 | .unlocked_ioctl = ivtv_v4l2_ioctl, | 61 | .unlocked_ioctl = ivtv_v4l2_ioctl, |
63 | .compat_ioctl = v4l_compat_ioctl32, | ||
64 | .release = ivtv_v4l2_close, | 62 | .release = ivtv_v4l2_close, |
65 | .poll = ivtv_v4l2_dec_poll, | 63 | .poll = ivtv_v4l2_dec_poll, |
66 | }; | 64 | }; |
@@ -78,7 +76,7 @@ static struct { | |||
78 | int num_offset; | 76 | int num_offset; |
79 | int dma, pio; | 77 | int dma, pio; |
80 | enum v4l2_buf_type buf_type; | 78 | enum v4l2_buf_type buf_type; |
81 | const struct file_operations *fops; | 79 | const struct v4l2_file_operations *fops; |
82 | } ivtv_stream_info[] = { | 80 | } ivtv_stream_info[] = { |
83 | { /* IVTV_ENC_STREAM_TYPE_MPG */ | 81 | { /* IVTV_ENC_STREAM_TYPE_MPG */ |
84 | "encoder MPG", | 82 | "encoder MPG", |
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c index 07be14a9fe7b..de397ef57b44 100644 --- a/drivers/media/video/m52790.c +++ b/drivers/media/video/m52790.c | |||
@@ -80,29 +80,28 @@ static int m52790_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r | |||
80 | } | 80 | } |
81 | 81 | ||
82 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 82 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
83 | static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 83 | static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
84 | { | 84 | { |
85 | struct m52790_state *state = to_state(sd); | 85 | struct m52790_state *state = to_state(sd); |
86 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 86 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
87 | 87 | ||
88 | if (!v4l2_chip_match_i2c_client(client, | 88 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
89 | reg->match_type, reg->match_chip)) | ||
90 | return -EINVAL; | 89 | return -EINVAL; |
91 | if (!capable(CAP_SYS_ADMIN)) | 90 | if (!capable(CAP_SYS_ADMIN)) |
92 | return -EPERM; | 91 | return -EPERM; |
93 | if (reg->reg != 0) | 92 | if (reg->reg != 0) |
94 | return -EINVAL; | 93 | return -EINVAL; |
94 | reg->size = 1; | ||
95 | reg->val = state->input | state->output; | 95 | reg->val = state->input | state->output; |
96 | return 0; | 96 | return 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 99 | static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
100 | { | 100 | { |
101 | struct m52790_state *state = to_state(sd); | 101 | struct m52790_state *state = to_state(sd); |
102 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 102 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
103 | 103 | ||
104 | if (!v4l2_chip_match_i2c_client(client, | 104 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
105 | reg->match_type, reg->match_chip)) | ||
106 | return -EINVAL; | 105 | return -EINVAL; |
107 | if (!capable(CAP_SYS_ADMIN)) | 106 | if (!capable(CAP_SYS_ADMIN)) |
108 | return -EPERM; | 107 | return -EPERM; |
@@ -115,7 +114,7 @@ static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | |||
115 | } | 114 | } |
116 | #endif | 115 | #endif |
117 | 116 | ||
118 | static int m52790_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 117 | static int m52790_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
119 | { | 118 | { |
120 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 119 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
121 | 120 | ||
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 6418f4a78f2a..b76e33d5c867 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
@@ -841,7 +841,7 @@ again: | |||
841 | /* video4linux integration */ | 841 | /* video4linux integration */ |
842 | /****************************************************************************/ | 842 | /****************************************************************************/ |
843 | 843 | ||
844 | static int meye_open(struct inode *inode, struct file *file) | 844 | static int meye_open(struct file *file) |
845 | { | 845 | { |
846 | int i; | 846 | int i; |
847 | 847 | ||
@@ -863,7 +863,7 @@ static int meye_open(struct inode *inode, struct file *file) | |||
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | 865 | ||
866 | static int meye_release(struct inode *inode, struct file *file) | 866 | static int meye_release(struct file *file) |
867 | { | 867 | { |
868 | mchip_hic_stop(); | 868 | mchip_hic_stop(); |
869 | mchip_dma_free(); | 869 | mchip_dma_free(); |
@@ -1577,7 +1577,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i) | |||
1577 | return 0; | 1577 | return 0; |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | static int vidioc_default(struct file *file, void *fh, int cmd, void *arg) | 1580 | static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) |
1581 | { | 1581 | { |
1582 | switch (cmd) { | 1582 | switch (cmd) { |
1583 | case MEYEIOC_G_PARAMS: | 1583 | case MEYEIOC_G_PARAMS: |
@@ -1684,17 +1684,13 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) | |||
1684 | return 0; | 1684 | return 0; |
1685 | } | 1685 | } |
1686 | 1686 | ||
1687 | static const struct file_operations meye_fops = { | 1687 | static const struct v4l2_file_operations meye_fops = { |
1688 | .owner = THIS_MODULE, | 1688 | .owner = THIS_MODULE, |
1689 | .open = meye_open, | 1689 | .open = meye_open, |
1690 | .release = meye_release, | 1690 | .release = meye_release, |
1691 | .mmap = meye_mmap, | 1691 | .mmap = meye_mmap, |
1692 | .ioctl = video_ioctl2, | 1692 | .ioctl = video_ioctl2, |
1693 | #ifdef CONFIG_COMPAT | ||
1694 | .compat_ioctl = v4l_compat_ioctl32, | ||
1695 | #endif | ||
1696 | .poll = meye_poll, | 1693 | .poll = meye_poll, |
1697 | .llseek = no_llseek, | ||
1698 | }; | 1694 | }; |
1699 | 1695 | ||
1700 | static const struct v4l2_ioctl_ops meye_ioctl_ops = { | 1696 | static const struct v4l2_ioctl_ops meye_ioctl_ops = { |
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c index a622dbb72ed8..4d7a91852117 100644 --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c | |||
@@ -483,7 +483,7 @@ static int msp_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
483 | } | 483 | } |
484 | 484 | ||
485 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 | 485 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 |
486 | static int msp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) | 486 | static long msp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
487 | { | 487 | { |
488 | struct msp_state *state = to_state(sd); | 488 | struct msp_state *state = to_state(sd); |
489 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 489 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
@@ -733,7 +733,7 @@ static int msp_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
733 | return 0; | 733 | return 0; |
734 | } | 734 | } |
735 | 735 | ||
736 | static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 736 | static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
737 | { | 737 | { |
738 | struct msp_state *state = to_state(sd); | 738 | struct msp_state *state = to_state(sd); |
739 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 739 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 1a1a12453672..c1bf75ef2741 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -343,14 +343,14 @@ static int mt9m001_try_fmt(struct soc_camera_device *icd, | |||
343 | } | 343 | } |
344 | 344 | ||
345 | static int mt9m001_get_chip_id(struct soc_camera_device *icd, | 345 | static int mt9m001_get_chip_id(struct soc_camera_device *icd, |
346 | struct v4l2_chip_ident *id) | 346 | struct v4l2_dbg_chip_ident *id) |
347 | { | 347 | { |
348 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 348 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
349 | 349 | ||
350 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | 350 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
351 | return -EINVAL; | 351 | return -EINVAL; |
352 | 352 | ||
353 | if (id->match_chip != mt9m001->client->addr) | 353 | if (id->match.addr != mt9m001->client->addr) |
354 | return -ENODEV; | 354 | return -ENODEV; |
355 | 355 | ||
356 | id->ident = mt9m001->model; | 356 | id->ident = mt9m001->model; |
@@ -361,16 +361,17 @@ static int mt9m001_get_chip_id(struct soc_camera_device *icd, | |||
361 | 361 | ||
362 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 362 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
363 | static int mt9m001_get_register(struct soc_camera_device *icd, | 363 | static int mt9m001_get_register(struct soc_camera_device *icd, |
364 | struct v4l2_register *reg) | 364 | struct v4l2_dbg_register *reg) |
365 | { | 365 | { |
366 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 366 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
367 | 367 | ||
368 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 368 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
369 | return -EINVAL; | 369 | return -EINVAL; |
370 | 370 | ||
371 | if (reg->match_chip != mt9m001->client->addr) | 371 | if (reg->match.addr != mt9m001->client->addr) |
372 | return -ENODEV; | 372 | return -ENODEV; |
373 | 373 | ||
374 | reg->size = 2; | ||
374 | reg->val = reg_read(icd, reg->reg); | 375 | reg->val = reg_read(icd, reg->reg); |
375 | 376 | ||
376 | if (reg->val > 0xffff) | 377 | if (reg->val > 0xffff) |
@@ -380,14 +381,14 @@ static int mt9m001_get_register(struct soc_camera_device *icd, | |||
380 | } | 381 | } |
381 | 382 | ||
382 | static int mt9m001_set_register(struct soc_camera_device *icd, | 383 | static int mt9m001_set_register(struct soc_camera_device *icd, |
383 | struct v4l2_register *reg) | 384 | struct v4l2_dbg_register *reg) |
384 | { | 385 | { |
385 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 386 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
386 | 387 | ||
387 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 388 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
388 | return -EINVAL; | 389 | return -EINVAL; |
389 | 390 | ||
390 | if (reg->match_chip != mt9m001->client->addr) | 391 | if (reg->match.addr != mt9m001->client->addr) |
391 | return -ENODEV; | 392 | return -ENODEV; |
392 | 393 | ||
393 | if (reg_write(icd, reg->reg, reg->val) < 0) | 394 | if (reg_write(icd, reg->reg, reg->val) < 0) |
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index c89ea41fe259..5b8e20979cce 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -514,14 +514,14 @@ static int mt9m111_try_fmt(struct soc_camera_device *icd, | |||
514 | } | 514 | } |
515 | 515 | ||
516 | static int mt9m111_get_chip_id(struct soc_camera_device *icd, | 516 | static int mt9m111_get_chip_id(struct soc_camera_device *icd, |
517 | struct v4l2_chip_ident *id) | 517 | struct v4l2_dbg_chip_ident *id) |
518 | { | 518 | { |
519 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 519 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
520 | 520 | ||
521 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | 521 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
522 | return -EINVAL; | 522 | return -EINVAL; |
523 | 523 | ||
524 | if (id->match_chip != mt9m111->client->addr) | 524 | if (id->match.addr != mt9m111->client->addr) |
525 | return -ENODEV; | 525 | return -ENODEV; |
526 | 526 | ||
527 | id->ident = mt9m111->model; | 527 | id->ident = mt9m111->model; |
@@ -532,18 +532,19 @@ static int mt9m111_get_chip_id(struct soc_camera_device *icd, | |||
532 | 532 | ||
533 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 533 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
534 | static int mt9m111_get_register(struct soc_camera_device *icd, | 534 | static int mt9m111_get_register(struct soc_camera_device *icd, |
535 | struct v4l2_register *reg) | 535 | struct v4l2_dbg_register *reg) |
536 | { | 536 | { |
537 | int val; | 537 | int val; |
538 | 538 | ||
539 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 539 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
540 | 540 | ||
541 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) | 541 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) |
542 | return -EINVAL; | 542 | return -EINVAL; |
543 | if (reg->match_chip != mt9m111->client->addr) | 543 | if (reg->match.addr != mt9m111->client->addr) |
544 | return -ENODEV; | 544 | return -ENODEV; |
545 | 545 | ||
546 | val = mt9m111_reg_read(icd, reg->reg); | 546 | val = mt9m111_reg_read(icd, reg->reg); |
547 | reg->size = 2; | ||
547 | reg->val = (u64)val; | 548 | reg->val = (u64)val; |
548 | 549 | ||
549 | if (reg->val > 0xffff) | 550 | if (reg->val > 0xffff) |
@@ -553,14 +554,14 @@ static int mt9m111_get_register(struct soc_camera_device *icd, | |||
553 | } | 554 | } |
554 | 555 | ||
555 | static int mt9m111_set_register(struct soc_camera_device *icd, | 556 | static int mt9m111_set_register(struct soc_camera_device *icd, |
556 | struct v4l2_register *reg) | 557 | struct v4l2_dbg_register *reg) |
557 | { | 558 | { |
558 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 559 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
559 | 560 | ||
560 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) | 561 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) |
561 | return -EINVAL; | 562 | return -EINVAL; |
562 | 563 | ||
563 | if (reg->match_chip != mt9m111->client->addr) | 564 | if (reg->match.addr != mt9m111->client->addr) |
564 | return -ENODEV; | 565 | return -ENODEV; |
565 | 566 | ||
566 | if (mt9m111_reg_write(icd, reg->reg, reg->val) < 0) | 567 | if (mt9m111_reg_write(icd, reg->reg, reg->val) < 0) |
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index 1a9d53966d06..349d8e365530 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
@@ -326,14 +326,14 @@ static int mt9t031_try_fmt(struct soc_camera_device *icd, | |||
326 | } | 326 | } |
327 | 327 | ||
328 | static int mt9t031_get_chip_id(struct soc_camera_device *icd, | 328 | static int mt9t031_get_chip_id(struct soc_camera_device *icd, |
329 | struct v4l2_chip_ident *id) | 329 | struct v4l2_dbg_chip_ident *id) |
330 | { | 330 | { |
331 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); | 331 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); |
332 | 332 | ||
333 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | 333 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
334 | return -EINVAL; | 334 | return -EINVAL; |
335 | 335 | ||
336 | if (id->match_chip != mt9t031->client->addr) | 336 | if (id->match.addr != mt9t031->client->addr) |
337 | return -ENODEV; | 337 | return -ENODEV; |
338 | 338 | ||
339 | id->ident = mt9t031->model; | 339 | id->ident = mt9t031->model; |
@@ -344,14 +344,14 @@ static int mt9t031_get_chip_id(struct soc_camera_device *icd, | |||
344 | 344 | ||
345 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 345 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
346 | static int mt9t031_get_register(struct soc_camera_device *icd, | 346 | static int mt9t031_get_register(struct soc_camera_device *icd, |
347 | struct v4l2_register *reg) | 347 | struct v4l2_dbg_register *reg) |
348 | { | 348 | { |
349 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); | 349 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); |
350 | 350 | ||
351 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 351 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
352 | return -EINVAL; | 352 | return -EINVAL; |
353 | 353 | ||
354 | if (reg->match_chip != mt9t031->client->addr) | 354 | if (reg->match.addr != mt9t031->client->addr) |
355 | return -ENODEV; | 355 | return -ENODEV; |
356 | 356 | ||
357 | reg->val = reg_read(icd, reg->reg); | 357 | reg->val = reg_read(icd, reg->reg); |
@@ -363,14 +363,14 @@ static int mt9t031_get_register(struct soc_camera_device *icd, | |||
363 | } | 363 | } |
364 | 364 | ||
365 | static int mt9t031_set_register(struct soc_camera_device *icd, | 365 | static int mt9t031_set_register(struct soc_camera_device *icd, |
366 | struct v4l2_register *reg) | 366 | struct v4l2_dbg_register *reg) |
367 | { | 367 | { |
368 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); | 368 | struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); |
369 | 369 | ||
370 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 370 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
371 | return -EINVAL; | 371 | return -EINVAL; |
372 | 372 | ||
373 | if (reg->match_chip != mt9t031->client->addr) | 373 | if (reg->match.addr != mt9t031->client->addr) |
374 | return -ENODEV; | 374 | return -ENODEV; |
375 | 375 | ||
376 | if (reg_write(icd, reg->reg, reg->val) < 0) | 376 | if (reg_write(icd, reg->reg, reg->val) < 0) |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index 14a5f9c21ffa..b04c8cb1644d 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -422,14 +422,14 @@ static int mt9v022_try_fmt(struct soc_camera_device *icd, | |||
422 | } | 422 | } |
423 | 423 | ||
424 | static int mt9v022_get_chip_id(struct soc_camera_device *icd, | 424 | static int mt9v022_get_chip_id(struct soc_camera_device *icd, |
425 | struct v4l2_chip_ident *id) | 425 | struct v4l2_dbg_chip_ident *id) |
426 | { | 426 | { |
427 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | 427 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); |
428 | 428 | ||
429 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | 429 | if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) |
430 | return -EINVAL; | 430 | return -EINVAL; |
431 | 431 | ||
432 | if (id->match_chip != mt9v022->client->addr) | 432 | if (id->match.addr != mt9v022->client->addr) |
433 | return -ENODEV; | 433 | return -ENODEV; |
434 | 434 | ||
435 | id->ident = mt9v022->model; | 435 | id->ident = mt9v022->model; |
@@ -440,16 +440,17 @@ static int mt9v022_get_chip_id(struct soc_camera_device *icd, | |||
440 | 440 | ||
441 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 441 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
442 | static int mt9v022_get_register(struct soc_camera_device *icd, | 442 | static int mt9v022_get_register(struct soc_camera_device *icd, |
443 | struct v4l2_register *reg) | 443 | struct v4l2_dbg_register *reg) |
444 | { | 444 | { |
445 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | 445 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); |
446 | 446 | ||
447 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 447 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
448 | return -EINVAL; | 448 | return -EINVAL; |
449 | 449 | ||
450 | if (reg->match_chip != mt9v022->client->addr) | 450 | if (reg->match.addr != mt9v022->client->addr) |
451 | return -ENODEV; | 451 | return -ENODEV; |
452 | 452 | ||
453 | reg->size = 2; | ||
453 | reg->val = reg_read(icd, reg->reg); | 454 | reg->val = reg_read(icd, reg->reg); |
454 | 455 | ||
455 | if (reg->val > 0xffff) | 456 | if (reg->val > 0xffff) |
@@ -459,14 +460,14 @@ static int mt9v022_get_register(struct soc_camera_device *icd, | |||
459 | } | 460 | } |
460 | 461 | ||
461 | static int mt9v022_set_register(struct soc_camera_device *icd, | 462 | static int mt9v022_set_register(struct soc_camera_device *icd, |
462 | struct v4l2_register *reg) | 463 | struct v4l2_dbg_register *reg) |
463 | { | 464 | { |
464 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | 465 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); |
465 | 466 | ||
466 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | 467 | if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) |
467 | return -EINVAL; | 468 | return -EINVAL; |
468 | 469 | ||
469 | if (reg->match_chip != mt9v022->client->addr) | 470 | if (reg->match.addr != mt9v022->client->addr) |
470 | return -ENODEV; | 471 | return -ENODEV; |
471 | 472 | ||
472 | if (reg_write(icd, reg->reg, reg->val) < 0) | 473 | if (reg_write(icd, reg->reg, reg->val) < 0) |
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index 7f130284b5c7..e3cbe14c349a 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
@@ -489,7 +489,7 @@ static int mxb_detach(struct saa7146_dev *dev) | |||
489 | return 0; | 489 | return 0; |
490 | } | 490 | } |
491 | 491 | ||
492 | static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | 492 | static long mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) |
493 | { | 493 | { |
494 | struct saa7146_dev *dev = fh->dev; | 494 | struct saa7146_dev *dev = fh->dev; |
495 | struct mxb *mxb = (struct mxb *)dev->ext_priv; | 495 | struct mxb *mxb = (struct mxb *)dev->ext_priv; |
diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c index 85c3c7c92af1..73eb656acfe3 100644 --- a/drivers/media/video/omap24xxcam.c +++ b/drivers/media/video/omap24xxcam.c | |||
@@ -1454,9 +1454,9 @@ static int omap24xxcam_mmap(struct file *file, struct vm_area_struct *vma) | |||
1454 | return rval; | 1454 | return rval; |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | static int omap24xxcam_open(struct inode *inode, struct file *file) | 1457 | static int omap24xxcam_open(struct file *file) |
1458 | { | 1458 | { |
1459 | int minor = iminor(inode); | 1459 | int minor = video_devdata(file)->minor; |
1460 | struct omap24xxcam_device *cam = omap24xxcam.priv; | 1460 | struct omap24xxcam_device *cam = omap24xxcam.priv; |
1461 | struct omap24xxcam_fh *fh; | 1461 | struct omap24xxcam_fh *fh; |
1462 | struct v4l2_format format; | 1462 | struct v4l2_format format; |
@@ -1511,7 +1511,7 @@ out_try_module_get: | |||
1511 | return -ENODEV; | 1511 | return -ENODEV; |
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | static int omap24xxcam_release(struct inode *inode, struct file *file) | 1514 | static int omap24xxcam_release(struct file *file) |
1515 | { | 1515 | { |
1516 | struct omap24xxcam_fh *fh = file->private_data; | 1516 | struct omap24xxcam_fh *fh = file->private_data; |
1517 | struct omap24xxcam_device *cam = fh->cam; | 1517 | struct omap24xxcam_device *cam = fh->cam; |
@@ -1559,8 +1559,7 @@ static int omap24xxcam_release(struct inode *inode, struct file *file) | |||
1559 | return 0; | 1559 | return 0; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | static struct file_operations omap24xxcam_fops = { | 1562 | static struct v4l2_file_operations omap24xxcam_fops = { |
1563 | .llseek = no_llseek, | ||
1564 | .ioctl = video_ioctl2, | 1563 | .ioctl = video_ioctl2, |
1565 | .poll = omap24xxcam_poll, | 1564 | .poll = omap24xxcam_poll, |
1566 | .mmap = omap24xxcam_mmap, | 1565 | .mmap = omap24xxcam_mmap, |
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 6ee9b69cc4a9..9af5532db142 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
@@ -3915,7 +3915,7 @@ ov51x_dealloc(struct usb_ov511 *ov) | |||
3915 | ***************************************************************************/ | 3915 | ***************************************************************************/ |
3916 | 3916 | ||
3917 | static int | 3917 | static int |
3918 | ov51x_v4l1_open(struct inode *inode, struct file *file) | 3918 | ov51x_v4l1_open(struct file *file) |
3919 | { | 3919 | { |
3920 | struct video_device *vdev = video_devdata(file); | 3920 | struct video_device *vdev = video_devdata(file); |
3921 | struct usb_ov511 *ov = video_get_drvdata(vdev); | 3921 | struct usb_ov511 *ov = video_get_drvdata(vdev); |
@@ -3972,7 +3972,7 @@ out: | |||
3972 | } | 3972 | } |
3973 | 3973 | ||
3974 | static int | 3974 | static int |
3975 | ov51x_v4l1_close(struct inode *inode, struct file *file) | 3975 | ov51x_v4l1_close(struct file *file) |
3976 | { | 3976 | { |
3977 | struct video_device *vdev = file->private_data; | 3977 | struct video_device *vdev = file->private_data; |
3978 | struct usb_ov511 *ov = video_get_drvdata(vdev); | 3978 | struct usb_ov511 *ov = video_get_drvdata(vdev); |
@@ -4010,7 +4010,7 @@ ov51x_v4l1_close(struct inode *inode, struct file *file) | |||
4010 | } | 4010 | } |
4011 | 4011 | ||
4012 | /* Do not call this function directly! */ | 4012 | /* Do not call this function directly! */ |
4013 | static int | 4013 | static long |
4014 | ov51x_v4l1_ioctl_internal(struct file *file, unsigned int cmd, void *arg) | 4014 | ov51x_v4l1_ioctl_internal(struct file *file, unsigned int cmd, void *arg) |
4015 | { | 4015 | { |
4016 | struct video_device *vdev = file->private_data; | 4016 | struct video_device *vdev = file->private_data; |
@@ -4449,8 +4449,8 @@ redo: | |||
4449 | return 0; | 4449 | return 0; |
4450 | } | 4450 | } |
4451 | 4451 | ||
4452 | static int | 4452 | static long |
4453 | ov51x_v4l1_ioctl(struct inode *inode, struct file *file, | 4453 | ov51x_v4l1_ioctl(struct file *file, |
4454 | unsigned int cmd, unsigned long arg) | 4454 | unsigned int cmd, unsigned long arg) |
4455 | { | 4455 | { |
4456 | struct video_device *vdev = file->private_data; | 4456 | struct video_device *vdev = file->private_data; |
@@ -4661,17 +4661,13 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma) | |||
4661 | return 0; | 4661 | return 0; |
4662 | } | 4662 | } |
4663 | 4663 | ||
4664 | static const struct file_operations ov511_fops = { | 4664 | static const struct v4l2_file_operations ov511_fops = { |
4665 | .owner = THIS_MODULE, | 4665 | .owner = THIS_MODULE, |
4666 | .open = ov51x_v4l1_open, | 4666 | .open = ov51x_v4l1_open, |
4667 | .release = ov51x_v4l1_close, | 4667 | .release = ov51x_v4l1_close, |
4668 | .read = ov51x_v4l1_read, | 4668 | .read = ov51x_v4l1_read, |
4669 | .mmap = ov51x_v4l1_mmap, | 4669 | .mmap = ov51x_v4l1_mmap, |
4670 | .ioctl = ov51x_v4l1_ioctl, | 4670 | .ioctl = ov51x_v4l1_ioctl, |
4671 | #ifdef CONFIG_COMPAT | ||
4672 | .compat_ioctl = v4l_compat_ioctl32, | ||
4673 | #endif | ||
4674 | .llseek = no_llseek, | ||
4675 | }; | 4671 | }; |
4676 | 4672 | ||
4677 | static struct video_device vdev_template = { | 4673 | static struct video_device vdev_template = { |
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index ea032f5f2f41..ca26b0c50cf2 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c | |||
@@ -1310,7 +1310,7 @@ static int ov7670_command(struct i2c_client *client, unsigned int cmd, | |||
1310 | void *arg) | 1310 | void *arg) |
1311 | { | 1311 | { |
1312 | switch (cmd) { | 1312 | switch (cmd) { |
1313 | case VIDIOC_G_CHIP_IDENT: | 1313 | case VIDIOC_DBG_G_CHIP_IDENT: |
1314 | return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0); | 1314 | return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0); |
1315 | 1315 | ||
1316 | case VIDIOC_INT_RESET: | 1316 | case VIDIOC_INT_RESET: |
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c index 54b736fcc07a..3c9e0ba974e9 100644 --- a/drivers/media/video/ov772x.c +++ b/drivers/media/video/ov772x.c | |||
@@ -724,7 +724,7 @@ static unsigned long ov772x_query_bus_param(struct soc_camera_device *icd) | |||
724 | } | 724 | } |
725 | 725 | ||
726 | static int ov772x_get_chip_id(struct soc_camera_device *icd, | 726 | static int ov772x_get_chip_id(struct soc_camera_device *icd, |
727 | struct v4l2_chip_ident *id) | 727 | struct v4l2_dbg_chip_ident *id) |
728 | { | 728 | { |
729 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | 729 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); |
730 | 730 | ||
@@ -736,11 +736,12 @@ static int ov772x_get_chip_id(struct soc_camera_device *icd, | |||
736 | 736 | ||
737 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 737 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
738 | static int ov772x_get_register(struct soc_camera_device *icd, | 738 | static int ov772x_get_register(struct soc_camera_device *icd, |
739 | struct v4l2_register *reg) | 739 | struct v4l2_dbg_register *reg) |
740 | { | 740 | { |
741 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | 741 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); |
742 | int ret; | 742 | int ret; |
743 | 743 | ||
744 | reg->size = 1; | ||
744 | if (reg->reg > 0xff) | 745 | if (reg->reg > 0xff) |
745 | return -EINVAL; | 746 | return -EINVAL; |
746 | 747 | ||
@@ -754,7 +755,7 @@ static int ov772x_get_register(struct soc_camera_device *icd, | |||
754 | } | 755 | } |
755 | 756 | ||
756 | static int ov772x_set_register(struct soc_camera_device *icd, | 757 | static int ov772x_set_register(struct soc_camera_device *icd, |
757 | struct v4l2_register *reg) | 758 | struct v4l2_dbg_register *reg) |
758 | { | 759 | { |
759 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | 760 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); |
760 | 761 | ||
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index 45730fac1570..a1ad38fc49c1 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
@@ -680,7 +680,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int | |||
680 | * Video4linux interfacing | 680 | * Video4linux interfacing |
681 | */ | 681 | */ |
682 | 682 | ||
683 | static int pms_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 683 | static long pms_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
684 | { | 684 | { |
685 | struct video_device *dev = video_devdata(file); | 685 | struct video_device *dev = video_devdata(file); |
686 | struct pms_device *pd=(struct pms_device *)dev; | 686 | struct pms_device *pd=(struct pms_device *)dev; |
@@ -862,7 +862,7 @@ static int pms_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
862 | return 0; | 862 | return 0; |
863 | } | 863 | } |
864 | 864 | ||
865 | static int pms_ioctl(struct inode *inode, struct file *file, | 865 | static long pms_ioctl(struct file *file, |
866 | unsigned int cmd, unsigned long arg) | 866 | unsigned int cmd, unsigned long arg) |
867 | { | 867 | { |
868 | return video_usercopy(file, cmd, arg, pms_do_ioctl); | 868 | return video_usercopy(file, cmd, arg, pms_do_ioctl); |
@@ -881,7 +881,7 @@ static ssize_t pms_read(struct file *file, char __user *buf, | |||
881 | return len; | 881 | return len; |
882 | } | 882 | } |
883 | 883 | ||
884 | static int pms_exclusive_open(struct inode *inode, struct file *file) | 884 | static int pms_exclusive_open(struct file *file) |
885 | { | 885 | { |
886 | struct video_device *v = video_devdata(file); | 886 | struct video_device *v = video_devdata(file); |
887 | struct pms_device *pd = (struct pms_device *)v; | 887 | struct pms_device *pd = (struct pms_device *)v; |
@@ -889,7 +889,7 @@ static int pms_exclusive_open(struct inode *inode, struct file *file) | |||
889 | return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0; | 889 | return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0; |
890 | } | 890 | } |
891 | 891 | ||
892 | static int pms_exclusive_release(struct inode *inode, struct file *file) | 892 | static int pms_exclusive_release(struct file *file) |
893 | { | 893 | { |
894 | struct video_device *v = video_devdata(file); | 894 | struct video_device *v = video_devdata(file); |
895 | struct pms_device *pd = (struct pms_device *)v; | 895 | struct pms_device *pd = (struct pms_device *)v; |
@@ -898,16 +898,12 @@ static int pms_exclusive_release(struct inode *inode, struct file *file) | |||
898 | return 0; | 898 | return 0; |
899 | } | 899 | } |
900 | 900 | ||
901 | static const struct file_operations pms_fops = { | 901 | static const struct v4l2_file_operations pms_fops = { |
902 | .owner = THIS_MODULE, | 902 | .owner = THIS_MODULE, |
903 | .open = pms_exclusive_open, | 903 | .open = pms_exclusive_open, |
904 | .release = pms_exclusive_release, | 904 | .release = pms_exclusive_release, |
905 | .ioctl = pms_ioctl, | 905 | .ioctl = pms_ioctl, |
906 | #ifdef CONFIG_COMPAT | ||
907 | .compat_ioctl = v4l_compat_ioctl32, | ||
908 | #endif | ||
909 | .read = pms_read, | 906 | .read = pms_read, |
910 | .llseek = no_llseek, | ||
911 | }; | 907 | }; |
912 | 908 | ||
913 | static struct video_device pms_template= | 909 | static struct video_device pms_template= |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 4358079f1966..8fb92ac78c7b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -4732,26 +4732,25 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) | |||
4732 | 4732 | ||
4733 | 4733 | ||
4734 | int pvr2_hdw_register_access(struct pvr2_hdw *hdw, | 4734 | int pvr2_hdw_register_access(struct pvr2_hdw *hdw, |
4735 | u32 match_type, u32 match_chip, u64 reg_id, | 4735 | struct v4l2_dbg_match *match, u64 reg_id, |
4736 | int setFl,u64 *val_ptr) | 4736 | int setFl, u64 *val_ptr) |
4737 | { | 4737 | { |
4738 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 4738 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
4739 | struct pvr2_i2c_client *cp; | 4739 | struct pvr2_i2c_client *cp; |
4740 | struct v4l2_register req; | 4740 | struct v4l2_dbg_register req; |
4741 | int stat = 0; | 4741 | int stat = 0; |
4742 | int okFl = 0; | 4742 | int okFl = 0; |
4743 | 4743 | ||
4744 | if (!capable(CAP_SYS_ADMIN)) return -EPERM; | 4744 | if (!capable(CAP_SYS_ADMIN)) return -EPERM; |
4745 | 4745 | ||
4746 | req.match_type = match_type; | 4746 | req.match = *match; |
4747 | req.match_chip = match_chip; | ||
4748 | req.reg = reg_id; | 4747 | req.reg = reg_id; |
4749 | if (setFl) req.val = *val_ptr; | 4748 | if (setFl) req.val = *val_ptr; |
4750 | mutex_lock(&hdw->i2c_list_lock); do { | 4749 | mutex_lock(&hdw->i2c_list_lock); do { |
4751 | list_for_each_entry(cp, &hdw->i2c_clients, list) { | 4750 | list_for_each_entry(cp, &hdw->i2c_clients, list) { |
4752 | if (!v4l2_chip_match_i2c_client( | 4751 | if (!v4l2_chip_match_i2c_client( |
4753 | cp->client, | 4752 | cp->client, |
4754 | req.match_type, req.match_chip)) { | 4753 | &req.match)) { |
4755 | continue; | 4754 | continue; |
4756 | } | 4755 | } |
4757 | stat = pvr2_i2c_client_cmd( | 4756 | stat = pvr2_i2c_client_cmd( |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h index 49482d1f2b28..1b4fec337c6b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h | |||
@@ -242,8 +242,8 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *, | |||
242 | setFl - true to set the register, false to read it | 242 | setFl - true to set the register, false to read it |
243 | val_ptr - storage location for source / result. */ | 243 | val_ptr - storage location for source / result. */ |
244 | int pvr2_hdw_register_access(struct pvr2_hdw *, | 244 | int pvr2_hdw_register_access(struct pvr2_hdw *, |
245 | u32 match_type, u32 match_chip,u64 reg_id, | 245 | struct v4l2_dbg_match *match, u64 reg_id, |
246 | int setFl,u64 *val_ptr); | 246 | int setFl, u64 *val_ptr); |
247 | 247 | ||
248 | /* The following entry points are all lower level things you normally don't | 248 | /* The following entry points are all lower level things you normally don't |
249 | want to worry about. */ | 249 | want to worry about. */ |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 52af1c435965..878fd52a73b3 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
@@ -168,13 +168,13 @@ static const char *get_v4l_name(int v4l_type) | |||
168 | * This is part of Video 4 Linux API. The procedure handles ioctl() calls. | 168 | * This is part of Video 4 Linux API. The procedure handles ioctl() calls. |
169 | * | 169 | * |
170 | */ | 170 | */ |
171 | static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 171 | static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
172 | { | 172 | { |
173 | struct pvr2_v4l2_fh *fh = file->private_data; | 173 | struct pvr2_v4l2_fh *fh = file->private_data; |
174 | struct pvr2_v4l2 *vp = fh->vhead; | 174 | struct pvr2_v4l2 *vp = fh->vhead; |
175 | struct pvr2_v4l2_dev *dev_info = fh->dev_info; | 175 | struct pvr2_v4l2_dev *dev_info = fh->dev_info; |
176 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; | 176 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
177 | int ret = -EINVAL; | 177 | long ret = -EINVAL; |
178 | 178 | ||
179 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { | 179 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { |
180 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd); | 180 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd); |
@@ -851,11 +851,11 @@ static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
851 | case VIDIOC_DBG_G_REGISTER: | 851 | case VIDIOC_DBG_G_REGISTER: |
852 | { | 852 | { |
853 | u64 val; | 853 | u64 val; |
854 | struct v4l2_register *req = (struct v4l2_register *)arg; | 854 | struct v4l2_dbg_register *req = (struct v4l2_dbg_register *)arg; |
855 | if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val; | 855 | if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val; |
856 | ret = pvr2_hdw_register_access( | 856 | ret = pvr2_hdw_register_access( |
857 | hdw,req->match_type,req->match_chip,req->reg, | 857 | hdw, &req->match, req->reg, |
858 | cmd == VIDIOC_DBG_S_REGISTER,&val); | 858 | cmd == VIDIOC_DBG_S_REGISTER, &val); |
859 | if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val; | 859 | if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val; |
860 | break; | 860 | break; |
861 | } | 861 | } |
@@ -871,20 +871,20 @@ static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
871 | if (ret < 0) { | 871 | if (ret < 0) { |
872 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { | 872 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { |
873 | pvr2_trace(PVR2_TRACE_V4LIOCTL, | 873 | pvr2_trace(PVR2_TRACE_V4LIOCTL, |
874 | "pvr2_v4l2_do_ioctl failure, ret=%d",ret); | 874 | "pvr2_v4l2_do_ioctl failure, ret=%ld", ret); |
875 | } else { | 875 | } else { |
876 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { | 876 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { |
877 | pvr2_trace(PVR2_TRACE_V4LIOCTL, | 877 | pvr2_trace(PVR2_TRACE_V4LIOCTL, |
878 | "pvr2_v4l2_do_ioctl failure, ret=%d" | 878 | "pvr2_v4l2_do_ioctl failure, ret=%ld" |
879 | " command was:",ret); | 879 | " command was:", ret); |
880 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), | 880 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), |
881 | cmd); | 881 | cmd); |
882 | } | 882 | } |
883 | } | 883 | } |
884 | } else { | 884 | } else { |
885 | pvr2_trace(PVR2_TRACE_V4LIOCTL, | 885 | pvr2_trace(PVR2_TRACE_V4LIOCTL, |
886 | "pvr2_v4l2_do_ioctl complete, ret=%d (0x%x)", | 886 | "pvr2_v4l2_do_ioctl complete, ret=%ld (0x%lx)", |
887 | ret,ret); | 887 | ret, ret); |
888 | } | 888 | } |
889 | return ret; | 889 | return ret; |
890 | } | 890 | } |
@@ -948,7 +948,7 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp) | |||
948 | } | 948 | } |
949 | 949 | ||
950 | 950 | ||
951 | static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file, | 951 | static long pvr2_v4l2_ioctl(struct file *file, |
952 | unsigned int cmd, unsigned long arg) | 952 | unsigned int cmd, unsigned long arg) |
953 | { | 953 | { |
954 | 954 | ||
@@ -960,7 +960,7 @@ static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file, | |||
960 | } | 960 | } |
961 | 961 | ||
962 | 962 | ||
963 | static int pvr2_v4l2_release(struct inode *inode, struct file *file) | 963 | static int pvr2_v4l2_release(struct file *file) |
964 | { | 964 | { |
965 | struct pvr2_v4l2_fh *fhp = file->private_data; | 965 | struct pvr2_v4l2_fh *fhp = file->private_data; |
966 | struct pvr2_v4l2 *vp = fhp->vhead; | 966 | struct pvr2_v4l2 *vp = fhp->vhead; |
@@ -1008,7 +1008,7 @@ static int pvr2_v4l2_release(struct inode *inode, struct file *file) | |||
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | 1010 | ||
1011 | static int pvr2_v4l2_open(struct inode *inode, struct file *file) | 1011 | static int pvr2_v4l2_open(struct file *file) |
1012 | { | 1012 | { |
1013 | struct pvr2_v4l2_dev *dip; /* Our own context pointer */ | 1013 | struct pvr2_v4l2_dev *dip; /* Our own context pointer */ |
1014 | struct pvr2_v4l2_fh *fhp; | 1014 | struct pvr2_v4l2_fh *fhp; |
@@ -1235,13 +1235,12 @@ static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait) | |||
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | 1237 | ||
1238 | static const struct file_operations vdev_fops = { | 1238 | static const struct v4l2_file_operations vdev_fops = { |
1239 | .owner = THIS_MODULE, | 1239 | .owner = THIS_MODULE, |
1240 | .open = pvr2_v4l2_open, | 1240 | .open = pvr2_v4l2_open, |
1241 | .release = pvr2_v4l2_release, | 1241 | .release = pvr2_v4l2_release, |
1242 | .read = pvr2_v4l2_read, | 1242 | .read = pvr2_v4l2_read, |
1243 | .ioctl = pvr2_v4l2_ioctl, | 1243 | .ioctl = pvr2_v4l2_ioctl, |
1244 | .llseek = no_llseek, | ||
1245 | .poll = pvr2_v4l2_poll, | 1244 | .poll = pvr2_v4l2_poll, |
1246 | }; | 1245 | }; |
1247 | 1246 | ||
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c index c66530210192..f9fbe02e0f69 100644 --- a/drivers/media/video/pwc/pwc-ctrl.c +++ b/drivers/media/video/pwc/pwc-ctrl.c | |||
@@ -1266,9 +1266,9 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor) | |||
1266 | /* copy local variable to arg */ | 1266 | /* copy local variable to arg */ |
1267 | #define ARG_OUT(ARG_name) /* nothing */ | 1267 | #define ARG_OUT(ARG_name) /* nothing */ |
1268 | 1268 | ||
1269 | int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) | 1269 | long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) |
1270 | { | 1270 | { |
1271 | int ret = 0; | 1271 | long ret = 0; |
1272 | 1272 | ||
1273 | switch(cmd) { | 1273 | switch(cmd) { |
1274 | case VIDIOCPWCRUSER: | 1274 | case VIDIOCPWCRUSER: |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 1ce9da167b7e..39fbc970f43d 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -142,16 +142,16 @@ static struct { | |||
142 | 142 | ||
143 | /***/ | 143 | /***/ |
144 | 144 | ||
145 | static int pwc_video_open(struct inode *inode, struct file *file); | 145 | static int pwc_video_open(struct file *file); |
146 | static int pwc_video_close(struct inode *inode, struct file *file); | 146 | static int pwc_video_close(struct file *file); |
147 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | 147 | static ssize_t pwc_video_read(struct file *file, char __user *buf, |
148 | size_t count, loff_t *ppos); | 148 | size_t count, loff_t *ppos); |
149 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); | 149 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); |
150 | static int pwc_video_ioctl(struct inode *inode, struct file *file, | 150 | static long pwc_video_ioctl(struct file *file, |
151 | unsigned int ioctlnr, unsigned long arg); | 151 | unsigned int ioctlnr, unsigned long arg); |
152 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); | 152 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); |
153 | 153 | ||
154 | static const struct file_operations pwc_fops = { | 154 | static const struct v4l2_file_operations pwc_fops = { |
155 | .owner = THIS_MODULE, | 155 | .owner = THIS_MODULE, |
156 | .open = pwc_video_open, | 156 | .open = pwc_video_open, |
157 | .release = pwc_video_close, | 157 | .release = pwc_video_close, |
@@ -159,10 +159,6 @@ static const struct file_operations pwc_fops = { | |||
159 | .poll = pwc_video_poll, | 159 | .poll = pwc_video_poll, |
160 | .mmap = pwc_video_mmap, | 160 | .mmap = pwc_video_mmap, |
161 | .ioctl = pwc_video_ioctl, | 161 | .ioctl = pwc_video_ioctl, |
162 | #ifdef CONFIG_COMPAT | ||
163 | .compat_ioctl = v4l_compat_ioctl32, | ||
164 | #endif | ||
165 | .llseek = no_llseek, | ||
166 | }; | 162 | }; |
167 | static struct video_device pwc_template = { | 163 | static struct video_device pwc_template = { |
168 | .name = "Philips Webcam", /* Filled in later */ | 164 | .name = "Philips Webcam", /* Filled in later */ |
@@ -1104,7 +1100,7 @@ static const char *pwc_sensor_type_to_string(unsigned int sensor_type) | |||
1104 | /***************************************************************************/ | 1100 | /***************************************************************************/ |
1105 | /* Video4Linux functions */ | 1101 | /* Video4Linux functions */ |
1106 | 1102 | ||
1107 | static int pwc_video_open(struct inode *inode, struct file *file) | 1103 | static int pwc_video_open(struct file *file) |
1108 | { | 1104 | { |
1109 | int i, ret; | 1105 | int i, ret; |
1110 | struct video_device *vdev = video_devdata(file); | 1106 | struct video_device *vdev = video_devdata(file); |
@@ -1224,7 +1220,7 @@ static void pwc_cleanup(struct pwc_device *pdev) | |||
1224 | } | 1220 | } |
1225 | 1221 | ||
1226 | /* Note that all cleanup is done in the reverse order as in _open */ | 1222 | /* Note that all cleanup is done in the reverse order as in _open */ |
1227 | static int pwc_video_close(struct inode *inode, struct file *file) | 1223 | static int pwc_video_close(struct file *file) |
1228 | { | 1224 | { |
1229 | struct video_device *vdev = file->private_data; | 1225 | struct video_device *vdev = file->private_data; |
1230 | struct pwc_device *pdev; | 1226 | struct pwc_device *pdev; |
@@ -1399,12 +1395,12 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | |||
1399 | return 0; | 1395 | return 0; |
1400 | } | 1396 | } |
1401 | 1397 | ||
1402 | static int pwc_video_ioctl(struct inode *inode, struct file *file, | 1398 | static long pwc_video_ioctl(struct file *file, |
1403 | unsigned int cmd, unsigned long arg) | 1399 | unsigned int cmd, unsigned long arg) |
1404 | { | 1400 | { |
1405 | struct video_device *vdev = file->private_data; | 1401 | struct video_device *vdev = file->private_data; |
1406 | struct pwc_device *pdev; | 1402 | struct pwc_device *pdev; |
1407 | int r = -ENODEV; | 1403 | long r = -ENODEV; |
1408 | 1404 | ||
1409 | if (!vdev) | 1405 | if (!vdev) |
1410 | goto out; | 1406 | goto out; |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index d7c147328e35..bc0a464295c5 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -337,7 +337,7 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f) | |||
337 | 337 | ||
338 | } | 338 | } |
339 | 339 | ||
340 | int pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 340 | long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
341 | { | 341 | { |
342 | struct video_device *vdev = video_devdata(file); | 342 | struct video_device *vdev = video_devdata(file); |
343 | struct pwc_device *pdev; | 343 | struct pwc_device *pdev; |
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index c046a2535668..01411fb2337a 100644 --- a/drivers/media/video/pwc/pwc.h +++ b/drivers/media/video/pwc/pwc.h | |||
@@ -337,10 +337,10 @@ extern int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise); | |||
337 | extern int pwc_camera_power(struct pwc_device *pdev, int power); | 337 | extern int pwc_camera_power(struct pwc_device *pdev, int power); |
338 | 338 | ||
339 | /* Private ioctl()s; see pwc-ioctl.h */ | 339 | /* Private ioctl()s; see pwc-ioctl.h */ |
340 | extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg); | 340 | extern long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg); |
341 | 341 | ||
342 | /** Functions in pwc-v4l.c */ | 342 | /** Functions in pwc-v4l.c */ |
343 | extern int pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg); | 343 | extern long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg); |
344 | 344 | ||
345 | /** pwc-uncompress.c */ | 345 | /** pwc-uncompress.c */ |
346 | /* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */ | 346 | /* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */ |
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 3c3f8cf73108..13f85ad363cd 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -1502,9 +1502,9 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv, | |||
1502 | dprintk(2, "setting jpeg quality %d\n", jc->quality); | 1502 | dprintk(2, "setting jpeg quality %d\n", jc->quality); |
1503 | return 0; | 1503 | return 0; |
1504 | } | 1504 | } |
1505 | static int s2255_open(struct inode *inode, struct file *file) | 1505 | static int s2255_open(struct file *file) |
1506 | { | 1506 | { |
1507 | int minor = iminor(inode); | 1507 | int minor = video_devdata(file)->minor; |
1508 | struct s2255_dev *h, *dev = NULL; | 1508 | struct s2255_dev *h, *dev = NULL; |
1509 | struct s2255_fh *fh; | 1509 | struct s2255_fh *fh; |
1510 | struct list_head *list; | 1510 | struct list_head *list; |
@@ -1711,11 +1711,11 @@ static void s2255_destroy(struct kref *kref) | |||
1711 | mutex_unlock(&dev->open_lock); | 1711 | mutex_unlock(&dev->open_lock); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | static int s2255_close(struct inode *inode, struct file *file) | 1714 | static int s2255_close(struct file *file) |
1715 | { | 1715 | { |
1716 | struct s2255_fh *fh = file->private_data; | 1716 | struct s2255_fh *fh = file->private_data; |
1717 | struct s2255_dev *dev = fh->dev; | 1717 | struct s2255_dev *dev = fh->dev; |
1718 | int minor = iminor(inode); | 1718 | int minor = video_devdata(file)->minor; |
1719 | if (!dev) | 1719 | if (!dev) |
1720 | return -ENODEV; | 1720 | return -ENODEV; |
1721 | 1721 | ||
@@ -1759,15 +1759,13 @@ static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma) | |||
1759 | return ret; | 1759 | return ret; |
1760 | } | 1760 | } |
1761 | 1761 | ||
1762 | static const struct file_operations s2255_fops_v4l = { | 1762 | static const struct v4l2_file_operations s2255_fops_v4l = { |
1763 | .owner = THIS_MODULE, | 1763 | .owner = THIS_MODULE, |
1764 | .open = s2255_open, | 1764 | .open = s2255_open, |
1765 | .release = s2255_close, | 1765 | .release = s2255_close, |
1766 | .poll = s2255_poll, | 1766 | .poll = s2255_poll, |
1767 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ | 1767 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ |
1768 | .compat_ioctl = v4l_compat_ioctl32, | ||
1769 | .mmap = s2255_mmap_v4l, | 1768 | .mmap = s2255_mmap_v4l, |
1770 | .llseek = no_llseek, | ||
1771 | }; | 1769 | }; |
1772 | 1770 | ||
1773 | static const struct v4l2_ioctl_ops s2255_ioctl_ops = { | 1771 | static const struct v4l2_ioctl_ops s2255_ioctl_ops = { |
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index f159441e9375..e637e440b6d5 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c | |||
@@ -804,7 +804,7 @@ static inline int saa5246a_stop_dau(struct saa5246a_device *t, | |||
804 | * | 804 | * |
805 | * Returns 0 if successful | 805 | * Returns 0 if successful |
806 | */ | 806 | */ |
807 | static int do_saa5246a_ioctl(struct file *file, unsigned int cmd, void *arg) | 807 | static long do_saa5246a_ioctl(struct file *file, unsigned int cmd, void *arg) |
808 | { | 808 | { |
809 | struct saa5246a_device *t = video_drvdata(file); | 809 | struct saa5246a_device *t = video_drvdata(file); |
810 | 810 | ||
@@ -944,11 +944,11 @@ static inline unsigned int vtx_fix_command(unsigned int cmd) | |||
944 | /* | 944 | /* |
945 | * Handle the locking | 945 | * Handle the locking |
946 | */ | 946 | */ |
947 | static int saa5246a_ioctl(struct inode *inode, struct file *file, | 947 | static long saa5246a_ioctl(struct file *file, |
948 | unsigned int cmd, unsigned long arg) | 948 | unsigned int cmd, unsigned long arg) |
949 | { | 949 | { |
950 | struct saa5246a_device *t = video_drvdata(file); | 950 | struct saa5246a_device *t = video_drvdata(file); |
951 | int err; | 951 | long err; |
952 | 952 | ||
953 | cmd = vtx_fix_command(cmd); | 953 | cmd = vtx_fix_command(cmd); |
954 | mutex_lock(&t->lock); | 954 | mutex_lock(&t->lock); |
@@ -957,7 +957,7 @@ static int saa5246a_ioctl(struct inode *inode, struct file *file, | |||
957 | return err; | 957 | return err; |
958 | } | 958 | } |
959 | 959 | ||
960 | static int saa5246a_open(struct inode *inode, struct file *file) | 960 | static int saa5246a_open(struct file *file) |
961 | { | 961 | { |
962 | struct saa5246a_device *t = video_drvdata(file); | 962 | struct saa5246a_device *t = video_drvdata(file); |
963 | 963 | ||
@@ -999,7 +999,7 @@ static int saa5246a_open(struct inode *inode, struct file *file) | |||
999 | return 0; | 999 | return 0; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static int saa5246a_release(struct inode *inode, struct file *file) | 1002 | static int saa5246a_release(struct file *file) |
1003 | { | 1003 | { |
1004 | struct saa5246a_device *t = video_drvdata(file); | 1004 | struct saa5246a_device *t = video_drvdata(file); |
1005 | 1005 | ||
@@ -1018,12 +1018,11 @@ static int saa5246a_release(struct inode *inode, struct file *file) | |||
1018 | return 0; | 1018 | return 0; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | static const struct file_operations saa_fops = { | 1021 | static const struct v4l2_file_operations saa_fops = { |
1022 | .owner = THIS_MODULE, | 1022 | .owner = THIS_MODULE, |
1023 | .open = saa5246a_open, | 1023 | .open = saa5246a_open, |
1024 | .release = saa5246a_release, | 1024 | .release = saa5246a_release, |
1025 | .ioctl = saa5246a_ioctl, | 1025 | .ioctl = saa5246a_ioctl, |
1026 | .llseek = no_llseek, | ||
1027 | }; | 1026 | }; |
1028 | 1027 | ||
1029 | static struct video_device saa_template = | 1028 | static struct video_device saa_template = |
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 6ef3affb97f1..e29765192469 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c | |||
@@ -190,7 +190,7 @@ static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf) | |||
190 | * Standard character-device-driver functions | 190 | * Standard character-device-driver functions |
191 | */ | 191 | */ |
192 | 192 | ||
193 | static int do_saa5249_ioctl(struct file *file, unsigned int cmd, void *arg) | 193 | static long do_saa5249_ioctl(struct file *file, unsigned int cmd, void *arg) |
194 | { | 194 | { |
195 | static int virtual_mode = false; | 195 | static int virtual_mode = false; |
196 | struct saa5249_device *t = video_drvdata(file); | 196 | struct saa5249_device *t = video_drvdata(file); |
@@ -479,11 +479,11 @@ static inline unsigned int vtx_fix_command(unsigned int cmd) | |||
479 | * Handle the locking | 479 | * Handle the locking |
480 | */ | 480 | */ |
481 | 481 | ||
482 | static int saa5249_ioctl(struct inode *inode, struct file *file, | 482 | static long saa5249_ioctl(struct file *file, |
483 | unsigned int cmd, unsigned long arg) | 483 | unsigned int cmd, unsigned long arg) |
484 | { | 484 | { |
485 | struct saa5249_device *t = video_drvdata(file); | 485 | struct saa5249_device *t = video_drvdata(file); |
486 | int err; | 486 | long err; |
487 | 487 | ||
488 | cmd = vtx_fix_command(cmd); | 488 | cmd = vtx_fix_command(cmd); |
489 | mutex_lock(&t->lock); | 489 | mutex_lock(&t->lock); |
@@ -492,7 +492,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file, | |||
492 | return err; | 492 | return err; |
493 | } | 493 | } |
494 | 494 | ||
495 | static int saa5249_open(struct inode *inode, struct file *file) | 495 | static int saa5249_open(struct file *file) |
496 | { | 496 | { |
497 | struct saa5249_device *t = video_drvdata(file); | 497 | struct saa5249_device *t = video_drvdata(file); |
498 | int pgbuf; | 498 | int pgbuf; |
@@ -529,7 +529,7 @@ static int saa5249_open(struct inode *inode, struct file *file) | |||
529 | 529 | ||
530 | 530 | ||
531 | 531 | ||
532 | static int saa5249_release(struct inode *inode, struct file *file) | 532 | static int saa5249_release(struct file *file) |
533 | { | 533 | { |
534 | struct saa5249_device *t = video_drvdata(file); | 534 | struct saa5249_device *t = video_drvdata(file); |
535 | 535 | ||
@@ -539,15 +539,11 @@ static int saa5249_release(struct inode *inode, struct file *file) | |||
539 | return 0; | 539 | return 0; |
540 | } | 540 | } |
541 | 541 | ||
542 | static const struct file_operations saa_fops = { | 542 | static const struct v4l2_file_operations saa_fops = { |
543 | .owner = THIS_MODULE, | 543 | .owner = THIS_MODULE, |
544 | .open = saa5249_open, | 544 | .open = saa5249_open, |
545 | .release = saa5249_release, | 545 | .release = saa5249_release, |
546 | .ioctl = saa5249_ioctl, | 546 | .ioctl = saa5249_ioctl, |
547 | #ifdef CONFIG_COMPAT | ||
548 | .compat_ioctl = v4l_compat_ioctl32, | ||
549 | #endif | ||
550 | .llseek = no_llseek, | ||
551 | }; | 547 | }; |
552 | 548 | ||
553 | static struct video_device saa_template = | 549 | static struct video_device saa_template = |
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index 22708ecdf1bb..46c796c3fec8 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
@@ -1371,25 +1371,24 @@ static int saa711x_g_vbi_data(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_dat | |||
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1373 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1374 | static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1374 | static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1375 | { | 1375 | { |
1376 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1376 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1377 | 1377 | ||
1378 | if (!v4l2_chip_match_i2c_client(client, | 1378 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1379 | reg->match_type, reg->match_chip)) | ||
1380 | return -EINVAL; | 1379 | return -EINVAL; |
1381 | if (!capable(CAP_SYS_ADMIN)) | 1380 | if (!capable(CAP_SYS_ADMIN)) |
1382 | return -EPERM; | 1381 | return -EPERM; |
1383 | reg->val = saa711x_read(sd, reg->reg & 0xff); | 1382 | reg->val = saa711x_read(sd, reg->reg & 0xff); |
1383 | reg->size = 1; | ||
1384 | return 0; | 1384 | return 0; |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1387 | static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1388 | { | 1388 | { |
1389 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1389 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1390 | 1390 | ||
1391 | if (!v4l2_chip_match_i2c_client(client, | 1391 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1392 | reg->match_type, reg->match_chip)) | ||
1393 | return -EINVAL; | 1392 | return -EINVAL; |
1394 | if (!capable(CAP_SYS_ADMIN)) | 1393 | if (!capable(CAP_SYS_ADMIN)) |
1395 | return -EPERM; | 1394 | return -EPERM; |
@@ -1398,7 +1397,7 @@ static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | |||
1398 | } | 1397 | } |
1399 | #endif | 1398 | #endif |
1400 | 1399 | ||
1401 | static int saa711x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 1400 | static int saa711x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
1402 | { | 1401 | { |
1403 | struct saa711x_state *state = to_state(sd); | 1402 | struct saa711x_state *state = to_state(sd); |
1404 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1403 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index bfc85654795e..d6848f7a503b 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c | |||
@@ -623,25 +623,24 @@ static int saa7127_s_vbi_data(struct v4l2_subdev *sd, const struct v4l2_sliced_v | |||
623 | } | 623 | } |
624 | 624 | ||
625 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 625 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
626 | static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 626 | static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
627 | { | 627 | { |
628 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 628 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
629 | 629 | ||
630 | if (!v4l2_chip_match_i2c_client(client, | 630 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
631 | reg->match_type, reg->match_chip)) | ||
632 | return -EINVAL; | 631 | return -EINVAL; |
633 | if (!capable(CAP_SYS_ADMIN)) | 632 | if (!capable(CAP_SYS_ADMIN)) |
634 | return -EPERM; | 633 | return -EPERM; |
635 | reg->val = saa7127_read(sd, reg->reg & 0xff); | 634 | reg->val = saa7127_read(sd, reg->reg & 0xff); |
635 | reg->size = 1; | ||
636 | return 0; | 636 | return 0; |
637 | } | 637 | } |
638 | 638 | ||
639 | static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 639 | static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
640 | { | 640 | { |
641 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 641 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
642 | 642 | ||
643 | if (!v4l2_chip_match_i2c_client(client, | 643 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
644 | reg->match_type, reg->match_chip)) | ||
645 | return -EINVAL; | 644 | return -EINVAL; |
646 | if (!capable(CAP_SYS_ADMIN)) | 645 | if (!capable(CAP_SYS_ADMIN)) |
647 | return -EPERM; | 646 | return -EPERM; |
@@ -650,7 +649,7 @@ static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | |||
650 | } | 649 | } |
651 | #endif | 650 | #endif |
652 | 651 | ||
653 | static int saa7127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 652 | static int saa7127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
654 | { | 653 | { |
655 | struct saa7127_state *state = to_state(sd); | 654 | struct saa7127_state *state = to_state(sd); |
656 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 655 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 1fb6eccdade3..1fee6e84a512 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -838,7 +838,7 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
838 | h->standard = *((v4l2_std_id *) arg); | 838 | h->standard = *((v4l2_std_id *) arg); |
839 | break; | 839 | break; |
840 | 840 | ||
841 | case VIDIOC_G_CHIP_IDENT: | 841 | case VIDIOC_DBG_G_CHIP_IDENT: |
842 | return v4l2_chip_ident_i2c_client(client, | 842 | return v4l2_chip_ident_i2c_client(client, |
843 | arg, h->chip, h->revision); | 843 | arg, h->chip, h->revision); |
844 | 844 | ||
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index a2e3f6729c5b..e2febcd6e529 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4462,6 +4462,7 @@ struct saa7134_board saa7134_boards[] = { | |||
4462 | .tuner_addr = ADDR_UNSET, | 4462 | .tuner_addr = ADDR_UNSET, |
4463 | .radio_addr = ADDR_UNSET, | 4463 | .radio_addr = ADDR_UNSET, |
4464 | .tda9887_conf = TDA9887_PRESENT, | 4464 | .tda9887_conf = TDA9887_PRESENT, |
4465 | .mpeg = SAA7134_MPEG_DVB, | ||
4465 | .inputs = {{ | 4466 | .inputs = {{ |
4466 | .name = name_tv, | 4467 | .name = name_tv, |
4467 | .vmux = 3, | 4468 | .vmux = 3, |
@@ -4480,8 +4481,6 @@ struct saa7134_board saa7134_boards[] = { | |||
4480 | .name = name_radio, | 4481 | .name = name_radio, |
4481 | .amux = LINE2, | 4482 | .amux = LINE2, |
4482 | }, | 4483 | }, |
4483 | /* no DVB support for now */ | ||
4484 | /* .mpeg = SAA7134_MPEG_DVB, */ | ||
4485 | }, | 4484 | }, |
4486 | [SAA7134_BOARD_ASUSTeK_TIGER_3IN1] = { | 4485 | [SAA7134_BOARD_ASUSTeK_TIGER_3IN1] = { |
4487 | .name = "Asus Tiger 3in1", | 4486 | .name = "Asus Tiger 3in1", |
@@ -4643,6 +4642,38 @@ struct saa7134_board saa7134_boards[] = { | |||
4643 | .amux = 2, | 4642 | .amux = 2, |
4644 | }, | 4643 | }, |
4645 | }, | 4644 | }, |
4645 | [SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS] = { | ||
4646 | .name = "Avermedia AVerTV GO 007 FM Plus", | ||
4647 | .audio_clock = 0x00187de7, | ||
4648 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
4649 | .radio_type = UNSET, | ||
4650 | .tuner_addr = ADDR_UNSET, | ||
4651 | .radio_addr = ADDR_UNSET, | ||
4652 | .gpiomask = 0x00300003, | ||
4653 | /* .gpiomask = 0x8c240003, */ | ||
4654 | .inputs = { { | ||
4655 | .name = name_tv, | ||
4656 | .vmux = 1, | ||
4657 | .amux = TV, | ||
4658 | .tv = 1, | ||
4659 | .gpio = 0x01, | ||
4660 | }, { | ||
4661 | .name = name_svideo, | ||
4662 | .vmux = 6, | ||
4663 | .amux = LINE1, | ||
4664 | .gpio = 0x02, | ||
4665 | } }, | ||
4666 | .radio = { | ||
4667 | .name = name_radio, | ||
4668 | .amux = TV, | ||
4669 | .gpio = 0x00300001, | ||
4670 | }, | ||
4671 | .mute = { | ||
4672 | .name = name_mute, | ||
4673 | .amux = TV, | ||
4674 | .gpio = 0x01, | ||
4675 | }, | ||
4676 | }, | ||
4646 | }; | 4677 | }; |
4647 | 4678 | ||
4648 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); | 4679 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); |
@@ -5702,6 +5733,13 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
5702 | .subdevice = 0x7128, | 5733 | .subdevice = 0x7128, |
5703 | .driver_data = SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG, | 5734 | .driver_data = SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG, |
5704 | }, { | 5735 | }, { |
5736 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
5737 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
5738 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
5739 | .subdevice = 0xf31d, | ||
5740 | .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS, | ||
5741 | |||
5742 | }, { | ||
5705 | /* --- boards without eeprom + subsystem ID --- */ | 5743 | /* --- boards without eeprom + subsystem ID --- */ |
5706 | .vendor = PCI_VENDOR_ID_PHILIPS, | 5744 | .vendor = PCI_VENDOR_ID_PHILIPS, |
5707 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | 5745 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, |
@@ -5930,6 +5968,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
5930 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: | 5968 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: |
5931 | case SAA7134_BOARD_REAL_ANGEL_220: | 5969 | case SAA7134_BOARD_REAL_ANGEL_220: |
5932 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: | 5970 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: |
5971 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: | ||
5933 | dev->has_remote = SAA7134_REMOTE_GPIO; | 5972 | dev->has_remote = SAA7134_REMOTE_GPIO; |
5934 | break; | 5973 | break; |
5935 | case SAA7134_BOARD_FLYDVBS_LR300: | 5974 | case SAA7134_BOARD_FLYDVBS_LR300: |
@@ -6025,6 +6064,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
6025 | case SAA7134_BOARD_BEHOLD_M6: | 6064 | case SAA7134_BOARD_BEHOLD_M6: |
6026 | case SAA7134_BOARD_BEHOLD_M63: | 6065 | case SAA7134_BOARD_BEHOLD_M63: |
6027 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: | 6066 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: |
6067 | case SAA7134_BOARD_BEHOLD_H6: | ||
6028 | dev->has_remote = SAA7134_REMOTE_I2C; | 6068 | dev->has_remote = SAA7134_REMOTE_I2C; |
6029 | break; | 6069 | break; |
6030 | case SAA7134_BOARD_AVERMEDIA_A169_B: | 6070 | case SAA7134_BOARD_AVERMEDIA_A169_B: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index d9a5652595b5..0776ecf56d27 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -49,6 +49,8 @@ | |||
49 | #include "lnbp21.h" | 49 | #include "lnbp21.h" |
50 | #include "tuner-simple.h" | 50 | #include "tuner-simple.h" |
51 | 51 | ||
52 | #include "zl10353.h" | ||
53 | |||
52 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 54 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
53 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
54 | 56 | ||
@@ -854,6 +856,12 @@ static struct tda1004x_config ads_tech_duo_config = { | |||
854 | .request_firmware = philips_tda1004x_request_firmware | 856 | .request_firmware = philips_tda1004x_request_firmware |
855 | }; | 857 | }; |
856 | 858 | ||
859 | static struct zl10353_config behold_h6_config = { | ||
860 | .demod_address = 0x1e>>1, | ||
861 | .no_tuner = 1, | ||
862 | .parallel_ts = 1, | ||
863 | }; | ||
864 | |||
857 | /* ================================================================== | 865 | /* ================================================================== |
858 | * tda10086 based DVB-S cards, helper functions | 866 | * tda10086 based DVB-S cards, helper functions |
859 | */ | 867 | */ |
@@ -1357,6 +1365,16 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1357 | &tda827x_cfg_0) < 0) | 1365 | &tda827x_cfg_0) < 0) |
1358 | goto dettach_frontend; | 1366 | goto dettach_frontend; |
1359 | break; | 1367 | break; |
1368 | case SAA7134_BOARD_BEHOLD_H6: | ||
1369 | fe0->dvb.frontend = dvb_attach(zl10353_attach, | ||
1370 | &behold_h6_config, | ||
1371 | &dev->i2c_adap); | ||
1372 | if (fe0->dvb.frontend) { | ||
1373 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, | ||
1374 | &dev->i2c_adap, 0x61, | ||
1375 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
1376 | } | ||
1377 | break; | ||
1360 | default: | 1378 | default: |
1361 | wprintk("Huh? unknown DVB card?\n"); | 1379 | wprintk("Huh? unknown DVB card?\n"); |
1362 | break; | 1380 | break; |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 7f40511bcc04..c9d8beb87a60 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -83,9 +83,9 @@ static int ts_init_encoder(struct saa7134_dev* dev) | |||
83 | 83 | ||
84 | /* ------------------------------------------------------------------ */ | 84 | /* ------------------------------------------------------------------ */ |
85 | 85 | ||
86 | static int ts_open(struct inode *inode, struct file *file) | 86 | static int ts_open(struct file *file) |
87 | { | 87 | { |
88 | int minor = iminor(inode); | 88 | int minor = video_devdata(file)->minor; |
89 | struct saa7134_dev *dev; | 89 | struct saa7134_dev *dev; |
90 | int err; | 90 | int err; |
91 | 91 | ||
@@ -119,7 +119,7 @@ done: | |||
119 | return err; | 119 | return err; |
120 | } | 120 | } |
121 | 121 | ||
122 | static int ts_release(struct inode *inode, struct file *file) | 122 | static int ts_release(struct file *file) |
123 | { | 123 | { |
124 | struct saa7134_dev *dev = file->private_data; | 124 | struct saa7134_dev *dev = file->private_data; |
125 | 125 | ||
@@ -405,7 +405,7 @@ static int empress_querymenu(struct file *file, void *priv, | |||
405 | } | 405 | } |
406 | 406 | ||
407 | static int empress_g_chip_ident(struct file *file, void *fh, | 407 | static int empress_g_chip_ident(struct file *file, void *fh, |
408 | struct v4l2_chip_ident *chip) | 408 | struct v4l2_dbg_chip_ident *chip) |
409 | { | 409 | { |
410 | struct saa7134_dev *dev = file->private_data; | 410 | struct saa7134_dev *dev = file->private_data; |
411 | 411 | ||
@@ -413,12 +413,12 @@ static int empress_g_chip_ident(struct file *file, void *fh, | |||
413 | chip->revision = 0; | 413 | chip->revision = 0; |
414 | if (dev->mpeg_i2c_client == NULL) | 414 | if (dev->mpeg_i2c_client == NULL) |
415 | return -EINVAL; | 415 | return -EINVAL; |
416 | if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER && | 416 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER && |
417 | chip->match_chip == I2C_DRIVERID_SAA6752HS) | 417 | !strcmp(chip->match.name, "saa6752hs")) |
418 | return saa7134_i2c_call_saa6752(dev, VIDIOC_G_CHIP_IDENT, chip); | 418 | return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); |
419 | if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR && | 419 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR && |
420 | chip->match_chip == dev->mpeg_i2c_client->addr) | 420 | chip->match.addr == dev->mpeg_i2c_client->addr) |
421 | return saa7134_i2c_call_saa6752(dev, VIDIOC_G_CHIP_IDENT, chip); | 421 | return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); |
422 | return -EINVAL; | 422 | return -EINVAL; |
423 | } | 423 | } |
424 | 424 | ||
@@ -437,7 +437,7 @@ static int empress_g_std(struct file *file, void *priv, v4l2_std_id *id) | |||
437 | return 0; | 437 | return 0; |
438 | } | 438 | } |
439 | 439 | ||
440 | static const struct file_operations ts_fops = | 440 | static const struct v4l2_file_operations ts_fops = |
441 | { | 441 | { |
442 | .owner = THIS_MODULE, | 442 | .owner = THIS_MODULE, |
443 | .open = ts_open, | 443 | .open = ts_open, |
@@ -446,7 +446,6 @@ static const struct file_operations ts_fops = | |||
446 | .poll = ts_poll, | 446 | .poll = ts_poll, |
447 | .mmap = ts_mmap, | 447 | .mmap = ts_mmap, |
448 | .ioctl = video_ioctl2, | 448 | .ioctl = video_ioctl2, |
449 | .llseek = no_llseek, | ||
450 | }; | 449 | }; |
451 | 450 | ||
452 | static const struct v4l2_ioctl_ops ts_ioctl_ops = { | 451 | static const struct v4l2_ioctl_ops ts_ioctl_ops = { |
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index d2124f64e4e2..8a106d36e723 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -449,6 +449,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
449 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507: | 449 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507: |
450 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: | 450 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: |
451 | case SAA7134_BOARD_AVERMEDIA_M102: | 451 | case SAA7134_BOARD_AVERMEDIA_M102: |
452 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: | ||
452 | ir_codes = ir_codes_avermedia; | 453 | ir_codes = ir_codes_avermedia; |
453 | mask_keycode = 0x0007C8; | 454 | mask_keycode = 0x0007C8; |
454 | mask_keydown = 0x000010; | 455 | mask_keydown = 0x000010; |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 02bb6747a39c..a1f7e351f572 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -1326,9 +1326,9 @@ static int saa7134_resource(struct saa7134_fh *fh) | |||
1326 | return 0; | 1326 | return 0; |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | static int video_open(struct inode *inode, struct file *file) | 1329 | static int video_open(struct file *file) |
1330 | { | 1330 | { |
1331 | int minor = iminor(inode); | 1331 | int minor = video_devdata(file)->minor; |
1332 | struct saa7134_dev *dev; | 1332 | struct saa7134_dev *dev; |
1333 | struct saa7134_fh *fh; | 1333 | struct saa7134_fh *fh; |
1334 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1334 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
@@ -1462,7 +1462,7 @@ err: | |||
1462 | return POLLERR; | 1462 | return POLLERR; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | static int video_release(struct inode *inode, struct file *file) | 1465 | static int video_release(struct file *file) |
1466 | { | 1466 | { |
1467 | struct saa7134_fh *fh = file->private_data; | 1467 | struct saa7134_fh *fh = file->private_data; |
1468 | struct saa7134_dev *dev = fh->dev; | 1468 | struct saa7134_dev *dev = fh->dev; |
@@ -2247,24 +2247,25 @@ static int saa7134_g_parm(struct file *file, void *fh, | |||
2247 | 2247 | ||
2248 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 2248 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2249 | static int vidioc_g_register (struct file *file, void *priv, | 2249 | static int vidioc_g_register (struct file *file, void *priv, |
2250 | struct v4l2_register *reg) | 2250 | struct v4l2_dbg_register *reg) |
2251 | { | 2251 | { |
2252 | struct saa7134_fh *fh = priv; | 2252 | struct saa7134_fh *fh = priv; |
2253 | struct saa7134_dev *dev = fh->dev; | 2253 | struct saa7134_dev *dev = fh->dev; |
2254 | 2254 | ||
2255 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 2255 | if (!v4l2_chip_match_host(®->match)) |
2256 | return -EINVAL; | 2256 | return -EINVAL; |
2257 | reg->val = saa_readb(reg->reg); | 2257 | reg->val = saa_readb(reg->reg); |
2258 | reg->size = 1; | ||
2258 | return 0; | 2259 | return 0; |
2259 | } | 2260 | } |
2260 | 2261 | ||
2261 | static int vidioc_s_register (struct file *file, void *priv, | 2262 | static int vidioc_s_register (struct file *file, void *priv, |
2262 | struct v4l2_register *reg) | 2263 | struct v4l2_dbg_register *reg) |
2263 | { | 2264 | { |
2264 | struct saa7134_fh *fh = priv; | 2265 | struct saa7134_fh *fh = priv; |
2265 | struct saa7134_dev *dev = fh->dev; | 2266 | struct saa7134_dev *dev = fh->dev; |
2266 | 2267 | ||
2267 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 2268 | if (!v4l2_chip_match_host(®->match)) |
2268 | return -EINVAL; | 2269 | return -EINVAL; |
2269 | saa_writeb(reg->reg&0xffffff, reg->val); | 2270 | saa_writeb(reg->reg&0xffffff, reg->val); |
2270 | return 0; | 2271 | return 0; |
@@ -2377,7 +2378,7 @@ static int radio_queryctrl(struct file *file, void *priv, | |||
2377 | return 0; | 2378 | return 0; |
2378 | } | 2379 | } |
2379 | 2380 | ||
2380 | static const struct file_operations video_fops = | 2381 | static const struct v4l2_file_operations video_fops = |
2381 | { | 2382 | { |
2382 | .owner = THIS_MODULE, | 2383 | .owner = THIS_MODULE, |
2383 | .open = video_open, | 2384 | .open = video_open, |
@@ -2386,8 +2387,6 @@ static const struct file_operations video_fops = | |||
2386 | .poll = video_poll, | 2387 | .poll = video_poll, |
2387 | .mmap = video_mmap, | 2388 | .mmap = video_mmap, |
2388 | .ioctl = video_ioctl2, | 2389 | .ioctl = video_ioctl2, |
2389 | .compat_ioctl = v4l_compat_ioctl32, | ||
2390 | .llseek = no_llseek, | ||
2391 | }; | 2390 | }; |
2392 | 2391 | ||
2393 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | 2392 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
@@ -2441,13 +2440,11 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2441 | #endif | 2440 | #endif |
2442 | }; | 2441 | }; |
2443 | 2442 | ||
2444 | static const struct file_operations radio_fops = { | 2443 | static const struct v4l2_file_operations radio_fops = { |
2445 | .owner = THIS_MODULE, | 2444 | .owner = THIS_MODULE, |
2446 | .open = video_open, | 2445 | .open = video_open, |
2447 | .release = video_release, | 2446 | .release = video_release, |
2448 | .ioctl = video_ioctl2, | 2447 | .ioctl = video_ioctl2, |
2449 | .compat_ioctl = v4l_compat_ioctl32, | ||
2450 | .llseek = no_llseek, | ||
2451 | }; | 2448 | }; |
2452 | 2449 | ||
2453 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 2450 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index f6c1fcc72070..14ee265f3374 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -276,6 +276,7 @@ struct saa7134_format { | |||
276 | #define SAA7134_BOARD_ADS_INSTANT_HDTV_PCI 151 | 276 | #define SAA7134_BOARD_ADS_INSTANT_HDTV_PCI 151 |
277 | #define SAA7134_BOARD_ASUSTeK_TIGER 152 | 277 | #define SAA7134_BOARD_ASUSTeK_TIGER 152 |
278 | #define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153 | 278 | #define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153 |
279 | #define SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS 154 | ||
279 | 280 | ||
280 | #define SAA7134_MAXBOARDS 32 | 281 | #define SAA7134_MAXBOARDS 32 |
281 | #define SAA7134_INPUT_MAX 8 | 282 | #define SAA7134_INPUT_MAX 8 |
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c index 9befca65905e..454ad1dd7507 100644 --- a/drivers/media/video/saa717x.c +++ b/drivers/media/video/saa717x.c | |||
@@ -1171,25 +1171,26 @@ static int saa717x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1173 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1174 | static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1174 | static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1175 | { | 1175 | { |
1176 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1176 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1177 | 1177 | ||
1178 | if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) | 1178 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1179 | return -EINVAL; | 1179 | return -EINVAL; |
1180 | if (!capable(CAP_SYS_ADMIN)) | 1180 | if (!capable(CAP_SYS_ADMIN)) |
1181 | return -EPERM; | 1181 | return -EPERM; |
1182 | reg->val = saa717x_read(sd, reg->reg); | 1182 | reg->val = saa717x_read(sd, reg->reg); |
1183 | reg->size = 1; | ||
1183 | return 0; | 1184 | return 0; |
1184 | } | 1185 | } |
1185 | 1186 | ||
1186 | static int saa717x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 1187 | static int saa717x_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1187 | { | 1188 | { |
1188 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1189 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1189 | u16 addr = reg->reg & 0xffff; | 1190 | u16 addr = reg->reg & 0xffff; |
1190 | u8 val = reg->val & 0xff; | 1191 | u8 val = reg->val & 0xff; |
1191 | 1192 | ||
1192 | if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) | 1193 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1193 | return -EINVAL; | 1194 | return -EINVAL; |
1194 | if (!capable(CAP_SYS_ADMIN)) | 1195 | if (!capable(CAP_SYS_ADMIN)) |
1195 | return -EPERM; | 1196 | return -EPERM; |
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c index d652f25eef0e..5990ab38a124 100644 --- a/drivers/media/video/se401.c +++ b/drivers/media/video/se401.c | |||
@@ -932,7 +932,7 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401) | |||
932 | ***************************************************************************/ | 932 | ***************************************************************************/ |
933 | 933 | ||
934 | 934 | ||
935 | static int se401_open(struct inode *inode, struct file *file) | 935 | static int se401_open(struct file *file) |
936 | { | 936 | { |
937 | struct video_device *dev = video_devdata(file); | 937 | struct video_device *dev = video_devdata(file); |
938 | struct usb_se401 *se401 = (struct usb_se401 *)dev; | 938 | struct usb_se401 *se401 = (struct usb_se401 *)dev; |
@@ -954,7 +954,7 @@ static int se401_open(struct inode *inode, struct file *file) | |||
954 | return err; | 954 | return err; |
955 | } | 955 | } |
956 | 956 | ||
957 | static int se401_close(struct inode *inode, struct file *file) | 957 | static int se401_close(struct file *file) |
958 | { | 958 | { |
959 | struct video_device *dev = file->private_data; | 959 | struct video_device *dev = file->private_data; |
960 | struct usb_se401 *se401 = (struct usb_se401 *)dev; | 960 | struct usb_se401 *se401 = (struct usb_se401 *)dev; |
@@ -975,7 +975,7 @@ static int se401_close(struct inode *inode, struct file *file) | |||
975 | return 0; | 975 | return 0; |
976 | } | 976 | } |
977 | 977 | ||
978 | static int se401_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 978 | static long se401_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
979 | { | 979 | { |
980 | struct video_device *vdev = file->private_data; | 980 | struct video_device *vdev = file->private_data; |
981 | struct usb_se401 *se401 = (struct usb_se401 *)vdev; | 981 | struct usb_se401 *se401 = (struct usb_se401 *)vdev; |
@@ -1138,7 +1138,7 @@ static int se401_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
1138 | return 0; | 1138 | return 0; |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | static int se401_ioctl(struct inode *inode, struct file *file, | 1141 | static long se401_ioctl(struct file *file, |
1142 | unsigned int cmd, unsigned long arg) | 1142 | unsigned int cmd, unsigned long arg) |
1143 | { | 1143 | { |
1144 | return video_usercopy(file, cmd, arg, se401_do_ioctl); | 1144 | return video_usercopy(file, cmd, arg, se401_do_ioctl); |
@@ -1222,17 +1222,13 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma) | |||
1222 | return 0; | 1222 | return 0; |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | static const struct file_operations se401_fops = { | 1225 | static const struct v4l2_file_operations se401_fops = { |
1226 | .owner = THIS_MODULE, | 1226 | .owner = THIS_MODULE, |
1227 | .open = se401_open, | 1227 | .open = se401_open, |
1228 | .release = se401_close, | 1228 | .release = se401_close, |
1229 | .read = se401_read, | 1229 | .read = se401_read, |
1230 | .mmap = se401_mmap, | 1230 | .mmap = se401_mmap, |
1231 | .ioctl = se401_ioctl, | 1231 | .ioctl = se401_ioctl, |
1232 | #ifdef CONFIG_COMPAT | ||
1233 | .compat_ioctl = v4l_compat_ioctl32, | ||
1234 | #endif | ||
1235 | .llseek = no_llseek, | ||
1236 | }; | 1232 | }; |
1237 | static struct video_device se401_template = { | 1233 | static struct video_device se401_template = { |
1238 | .name = "se401 USB camera", | 1234 | .name = "se401 USB camera", |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 01a8efb8deb1..23edfdc4d4bc 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
@@ -1746,7 +1746,7 @@ static void sn9c102_release_resources(struct kref *kref) | |||
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | 1748 | ||
1749 | static int sn9c102_open(struct inode* inode, struct file* filp) | 1749 | static int sn9c102_open(struct file *filp) |
1750 | { | 1750 | { |
1751 | struct sn9c102_device* cam; | 1751 | struct sn9c102_device* cam; |
1752 | int err = 0; | 1752 | int err = 0; |
@@ -1857,7 +1857,7 @@ out: | |||
1857 | } | 1857 | } |
1858 | 1858 | ||
1859 | 1859 | ||
1860 | static int sn9c102_release(struct inode* inode, struct file* filp) | 1860 | static int sn9c102_release(struct file *filp) |
1861 | { | 1861 | { |
1862 | struct sn9c102_device* cam; | 1862 | struct sn9c102_device* cam; |
1863 | 1863 | ||
@@ -3092,8 +3092,8 @@ sn9c102_vidioc_s_audio(struct sn9c102_device* cam, void __user * arg) | |||
3092 | } | 3092 | } |
3093 | 3093 | ||
3094 | 3094 | ||
3095 | static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, | 3095 | static long sn9c102_ioctl_v4l2(struct file *filp, |
3096 | unsigned int cmd, void __user * arg) | 3096 | unsigned int cmd, void __user *arg) |
3097 | { | 3097 | { |
3098 | struct sn9c102_device *cam = video_drvdata(filp); | 3098 | struct sn9c102_device *cam = video_drvdata(filp); |
3099 | 3099 | ||
@@ -3196,7 +3196,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, | |||
3196 | } | 3196 | } |
3197 | 3197 | ||
3198 | 3198 | ||
3199 | static int sn9c102_ioctl(struct inode* inode, struct file* filp, | 3199 | static long sn9c102_ioctl(struct file *filp, |
3200 | unsigned int cmd, unsigned long arg) | 3200 | unsigned int cmd, unsigned long arg) |
3201 | { | 3201 | { |
3202 | struct sn9c102_device *cam = video_drvdata(filp); | 3202 | struct sn9c102_device *cam = video_drvdata(filp); |
@@ -3220,7 +3220,7 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
3220 | 3220 | ||
3221 | V4LDBG(3, "sn9c102", cmd); | 3221 | V4LDBG(3, "sn9c102", cmd); |
3222 | 3222 | ||
3223 | err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); | 3223 | err = sn9c102_ioctl_v4l2(filp, cmd, (void __user *)arg); |
3224 | 3224 | ||
3225 | mutex_unlock(&cam->fileop_mutex); | 3225 | mutex_unlock(&cam->fileop_mutex); |
3226 | 3226 | ||
@@ -3229,18 +3229,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
3229 | 3229 | ||
3230 | /*****************************************************************************/ | 3230 | /*****************************************************************************/ |
3231 | 3231 | ||
3232 | static const struct file_operations sn9c102_fops = { | 3232 | static const struct v4l2_file_operations sn9c102_fops = { |
3233 | .owner = THIS_MODULE, | 3233 | .owner = THIS_MODULE, |
3234 | .open = sn9c102_open, | 3234 | .open = sn9c102_open, |
3235 | .release = sn9c102_release, | 3235 | .release = sn9c102_release, |
3236 | .ioctl = sn9c102_ioctl, | 3236 | .ioctl = sn9c102_ioctl, |
3237 | #ifdef CONFIG_COMPAT | ||
3238 | .compat_ioctl = v4l_compat_ioctl32, | ||
3239 | #endif | ||
3240 | .read = sn9c102_read, | 3237 | .read = sn9c102_read, |
3241 | .poll = sn9c102_poll, | 3238 | .poll = sn9c102_poll, |
3242 | .mmap = sn9c102_mmap, | 3239 | .mmap = sn9c102_mmap, |
3243 | .llseek = no_llseek, | ||
3244 | }; | 3240 | }; |
3245 | 3241 | ||
3246 | /*****************************************************************************/ | 3242 | /*****************************************************************************/ |
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 90077cb4fe66..fcb05f06de8f 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -256,7 +256,7 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd) | |||
256 | vfree(icd->user_formats); | 256 | vfree(icd->user_formats); |
257 | } | 257 | } |
258 | 258 | ||
259 | static int soc_camera_open(struct inode *inode, struct file *file) | 259 | static int soc_camera_open(struct file *file) |
260 | { | 260 | { |
261 | struct video_device *vdev; | 261 | struct video_device *vdev; |
262 | struct soc_camera_device *icd; | 262 | struct soc_camera_device *icd; |
@@ -330,7 +330,7 @@ emgd: | |||
330 | return ret; | 330 | return ret; |
331 | } | 331 | } |
332 | 332 | ||
333 | static int soc_camera_close(struct inode *inode, struct file *file) | 333 | static int soc_camera_close(struct file *file) |
334 | { | 334 | { |
335 | struct soc_camera_file *icf = file->private_data; | 335 | struct soc_camera_file *icf = file->private_data; |
336 | struct soc_camera_device *icd = icf->icd; | 336 | struct soc_camera_device *icd = icf->icd; |
@@ -400,7 +400,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt) | |||
400 | return ici->ops->poll(file, pt); | 400 | return ici->ops->poll(file, pt); |
401 | } | 401 | } |
402 | 402 | ||
403 | static struct file_operations soc_camera_fops = { | 403 | static struct v4l2_file_operations soc_camera_fops = { |
404 | .owner = THIS_MODULE, | 404 | .owner = THIS_MODULE, |
405 | .open = soc_camera_open, | 405 | .open = soc_camera_open, |
406 | .release = soc_camera_close, | 406 | .release = soc_camera_close, |
@@ -408,7 +408,6 @@ static struct file_operations soc_camera_fops = { | |||
408 | .read = soc_camera_read, | 408 | .read = soc_camera_read, |
409 | .mmap = soc_camera_mmap, | 409 | .mmap = soc_camera_mmap, |
410 | .poll = soc_camera_poll, | 410 | .poll = soc_camera_poll, |
411 | .llseek = no_llseek, | ||
412 | }; | 411 | }; |
413 | 412 | ||
414 | static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, | 413 | static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, |
@@ -700,7 +699,7 @@ static int soc_camera_s_crop(struct file *file, void *fh, | |||
700 | } | 699 | } |
701 | 700 | ||
702 | static int soc_camera_g_chip_ident(struct file *file, void *fh, | 701 | static int soc_camera_g_chip_ident(struct file *file, void *fh, |
703 | struct v4l2_chip_ident *id) | 702 | struct v4l2_dbg_chip_ident *id) |
704 | { | 703 | { |
705 | struct soc_camera_file *icf = file->private_data; | 704 | struct soc_camera_file *icf = file->private_data; |
706 | struct soc_camera_device *icd = icf->icd; | 705 | struct soc_camera_device *icd = icf->icd; |
@@ -713,7 +712,7 @@ static int soc_camera_g_chip_ident(struct file *file, void *fh, | |||
713 | 712 | ||
714 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 713 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
715 | static int soc_camera_g_register(struct file *file, void *fh, | 714 | static int soc_camera_g_register(struct file *file, void *fh, |
716 | struct v4l2_register *reg) | 715 | struct v4l2_dbg_register *reg) |
717 | { | 716 | { |
718 | struct soc_camera_file *icf = file->private_data; | 717 | struct soc_camera_file *icf = file->private_data; |
719 | struct soc_camera_device *icd = icf->icd; | 718 | struct soc_camera_device *icd = icf->icd; |
@@ -725,7 +724,7 @@ static int soc_camera_g_register(struct file *file, void *fh, | |||
725 | } | 724 | } |
726 | 725 | ||
727 | static int soc_camera_s_register(struct file *file, void *fh, | 726 | static int soc_camera_s_register(struct file *file, void *fh, |
728 | struct v4l2_register *reg) | 727 | struct v4l2_dbg_register *reg) |
729 | { | 728 | { |
730 | struct soc_camera_file *icf = file->private_data; | 729 | struct soc_camera_file *icf = file->private_data; |
731 | struct soc_camera_device *icd = icf->icd; | 730 | struct soc_camera_device *icd = icf->icd; |
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index f9516d0f3c11..26378cf390fc 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
@@ -664,7 +664,7 @@ static void stk_free_buffers(struct stk_camera *dev) | |||
664 | 664 | ||
665 | /* v4l file operations */ | 665 | /* v4l file operations */ |
666 | 666 | ||
667 | static int v4l_stk_open(struct inode *inode, struct file *fp) | 667 | static int v4l_stk_open(struct file *fp) |
668 | { | 668 | { |
669 | struct stk_camera *dev; | 669 | struct stk_camera *dev; |
670 | struct video_device *vdev; | 670 | struct video_device *vdev; |
@@ -684,7 +684,7 @@ static int v4l_stk_open(struct inode *inode, struct file *fp) | |||
684 | return 0; | 684 | return 0; |
685 | } | 685 | } |
686 | 686 | ||
687 | static int v4l_stk_release(struct inode *inode, struct file *fp) | 687 | static int v4l_stk_release(struct file *fp) |
688 | { | 688 | { |
689 | struct stk_camera *dev = fp->private_data; | 689 | struct stk_camera *dev = fp->private_data; |
690 | 690 | ||
@@ -1281,7 +1281,7 @@ static int stk_vidioc_enum_framesizes(struct file *filp, | |||
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | static struct file_operations v4l_stk_fops = { | 1284 | static struct v4l2_file_operations v4l_stk_fops = { |
1285 | .owner = THIS_MODULE, | 1285 | .owner = THIS_MODULE, |
1286 | .open = v4l_stk_open, | 1286 | .open = v4l_stk_open, |
1287 | .release = v4l_stk_release, | 1287 | .release = v4l_stk_release, |
@@ -1289,10 +1289,6 @@ static struct file_operations v4l_stk_fops = { | |||
1289 | .poll = v4l_stk_poll, | 1289 | .poll = v4l_stk_poll, |
1290 | .mmap = v4l_stk_mmap, | 1290 | .mmap = v4l_stk_mmap, |
1291 | .ioctl = video_ioctl2, | 1291 | .ioctl = video_ioctl2, |
1292 | #ifdef CONFIG_COMPAT | ||
1293 | .compat_ioctl = v4l_compat_ioctl32, | ||
1294 | #endif | ||
1295 | .llseek = no_llseek | ||
1296 | }; | 1292 | }; |
1297 | 1293 | ||
1298 | static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = { | 1294 | static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = { |
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c index bbad54f85c83..0eb313082c97 100644 --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c | |||
@@ -1275,7 +1275,7 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr) | |||
1275 | clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y); | 1275 | clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y); |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | static int saa_ioctl(struct inode *inode, struct file *file, | 1278 | static long saa_ioctl(struct file *file, |
1279 | unsigned int cmd, unsigned long argl) | 1279 | unsigned int cmd, unsigned long argl) |
1280 | { | 1280 | { |
1281 | struct saa7146 *saa = file->private_data; | 1281 | struct saa7146 *saa = file->private_data; |
@@ -1877,7 +1877,7 @@ static ssize_t saa_write(struct file *file, const char __user * buf, | |||
1877 | return count; | 1877 | return count; |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | static int saa_open(struct inode *inode, struct file *file) | 1880 | static int saa_open(struct file *file) |
1881 | { | 1881 | { |
1882 | struct video_device *vdev = video_devdata(file); | 1882 | struct video_device *vdev = video_devdata(file); |
1883 | struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev); | 1883 | struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev); |
@@ -1895,7 +1895,7 @@ static int saa_open(struct inode *inode, struct file *file) | |||
1895 | return 0; | 1895 | return 0; |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | static int saa_release(struct inode *inode, struct file *file) | 1898 | static int saa_release(struct file *file) |
1899 | { | 1899 | { |
1900 | struct saa7146 *saa = file->private_data; | 1900 | struct saa7146 *saa = file->private_data; |
1901 | saa->user--; | 1901 | saa->user--; |
@@ -1906,16 +1906,12 @@ static int saa_release(struct inode *inode, struct file *file) | |||
1906 | return 0; | 1906 | return 0; |
1907 | } | 1907 | } |
1908 | 1908 | ||
1909 | static const struct file_operations saa_fops = { | 1909 | static const struct v4l2_file_operations saa_fops = { |
1910 | .owner = THIS_MODULE, | 1910 | .owner = THIS_MODULE, |
1911 | .open = saa_open, | 1911 | .open = saa_open, |
1912 | .release = saa_release, | 1912 | .release = saa_release, |
1913 | .ioctl = saa_ioctl, | 1913 | .ioctl = saa_ioctl, |
1914 | #ifdef CONFIG_COMPAT | ||
1915 | .compat_ioctl = v4l_compat_ioctl32, | ||
1916 | #endif | ||
1917 | .read = saa_read, | 1914 | .read = saa_read, |
1918 | .llseek = no_llseek, | ||
1919 | .write = saa_write, | 1915 | .write = saa_write, |
1920 | .mmap = saa_mmap, | 1916 | .mmap = saa_mmap, |
1921 | }; | 1917 | }; |
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c index 42acc92c182d..75f286f7a2e9 100644 --- a/drivers/media/video/stv680.c +++ b/drivers/media/video/stv680.c | |||
@@ -1080,7 +1080,7 @@ static int stv680_newframe (struct usb_stv *stv680, int framenr) | |||
1080 | * Video4Linux | 1080 | * Video4Linux |
1081 | *********************************************************************/ | 1081 | *********************************************************************/ |
1082 | 1082 | ||
1083 | static int stv_open (struct inode *inode, struct file *file) | 1083 | static int stv_open(struct file *file) |
1084 | { | 1084 | { |
1085 | struct video_device *dev = video_devdata(file); | 1085 | struct video_device *dev = video_devdata(file); |
1086 | struct usb_stv *stv680 = video_get_drvdata(dev); | 1086 | struct usb_stv *stv680 = video_get_drvdata(dev); |
@@ -1106,7 +1106,7 @@ static int stv_open (struct inode *inode, struct file *file) | |||
1106 | return err; | 1106 | return err; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | static int stv_close (struct inode *inode, struct file *file) | 1109 | static int stv_close(struct file *file) |
1110 | { | 1110 | { |
1111 | struct video_device *dev = file->private_data; | 1111 | struct video_device *dev = file->private_data; |
1112 | struct usb_stv *stv680 = video_get_drvdata(dev); | 1112 | struct usb_stv *stv680 = video_get_drvdata(dev); |
@@ -1132,7 +1132,7 @@ static int stv_close (struct inode *inode, struct file *file) | |||
1132 | return 0; | 1132 | return 0; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | static int stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 1135 | static long stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
1136 | { | 1136 | { |
1137 | struct video_device *vdev = file->private_data; | 1137 | struct video_device *vdev = file->private_data; |
1138 | struct usb_stv *stv680 = video_get_drvdata(vdev); | 1138 | struct usb_stv *stv680 = video_get_drvdata(vdev); |
@@ -1299,7 +1299,7 @@ static int stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
1299 | return 0; | 1299 | return 0; |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | static int stv680_ioctl(struct inode *inode, struct file *file, | 1302 | static long stv680_ioctl(struct file *file, |
1303 | unsigned int cmd, unsigned long arg) | 1303 | unsigned int cmd, unsigned long arg) |
1304 | { | 1304 | { |
1305 | return video_usercopy(file, cmd, arg, stv680_do_ioctl); | 1305 | return video_usercopy(file, cmd, arg, stv680_do_ioctl); |
@@ -1391,17 +1391,13 @@ static ssize_t stv680_read (struct file *file, char __user *buf, | |||
1391 | return realcount; | 1391 | return realcount; |
1392 | } /* stv680_read */ | 1392 | } /* stv680_read */ |
1393 | 1393 | ||
1394 | static const struct file_operations stv680_fops = { | 1394 | static const struct v4l2_file_operations stv680_fops = { |
1395 | .owner = THIS_MODULE, | 1395 | .owner = THIS_MODULE, |
1396 | .open = stv_open, | 1396 | .open = stv_open, |
1397 | .release = stv_close, | 1397 | .release = stv_close, |
1398 | .read = stv680_read, | 1398 | .read = stv680_read, |
1399 | .mmap = stv680_mmap, | 1399 | .mmap = stv680_mmap, |
1400 | .ioctl = stv680_ioctl, | 1400 | .ioctl = stv680_ioctl, |
1401 | #ifdef CONFIG_COMPAT | ||
1402 | .compat_ioctl = v4l_compat_ioctl32, | ||
1403 | #endif | ||
1404 | .llseek = no_llseek, | ||
1405 | }; | 1401 | }; |
1406 | static struct video_device stv680_template = { | 1402 | static struct video_device stv680_template = { |
1407 | .name = "STV0680 USB camera", | 1403 | .name = "STV0680 USB camera", |
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index 2644e0dc9251..6afb7059502d 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -137,7 +137,7 @@ static int tda9840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *t) | |||
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int tda9840_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) | 140 | static long tda9840_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) |
141 | { | 141 | { |
142 | int byte; | 142 | int byte; |
143 | 143 | ||
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 31dde86f2df4..7519fd1f57ef 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -122,7 +122,7 @@ static int switch_matrix(struct i2c_client *client, int i, int o) | |||
122 | return ret; | 122 | return ret; |
123 | } | 123 | } |
124 | 124 | ||
125 | static int tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) | 125 | static long tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) |
126 | { | 126 | { |
127 | if (cmd == TEA6415C_SWITCH) { | 127 | if (cmd == TEA6415C_SWITCH) { |
128 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 128 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 38e519f04bde..081e74fa3b2e 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
@@ -90,7 +90,7 @@ static int tea6420_switch(struct i2c_client *client, int i, int o, int g) | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static int tea6420_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) | 93 | static long tea6420_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) |
94 | { | 94 | { |
95 | if (cmd == TEA6420_SWITCH) { | 95 | if (cmd == TEA6420_SWITCH) { |
96 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 96 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 97d7509d212f..30640fbfd0f9 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -800,7 +800,7 @@ static int tuner_s_standby(struct v4l2_subdev *sd, u32 standby) | |||
800 | } | 800 | } |
801 | 801 | ||
802 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 | 802 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 |
803 | static int tuner_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) | 803 | static long tuner_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
804 | { | 804 | { |
805 | struct tuner *t = to_tuner(sd); | 805 | struct tuner *t = to_tuner(sd); |
806 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 806 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index d0c794da735b..5aeccb301cea 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -1762,7 +1762,7 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr | |||
1762 | return 0; | 1762 | return 0; |
1763 | } | 1763 | } |
1764 | 1764 | ||
1765 | static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 1765 | static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
1766 | { | 1766 | { |
1767 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1767 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1768 | 1768 | ||
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index a388a9f0cb18..2cd64ef27b95 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c | |||
@@ -963,7 +963,7 @@ static int tvp5150_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) | |||
963 | 963 | ||
964 | 964 | ||
965 | static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, | 965 | static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, |
966 | struct v4l2_chip_ident *chip) | 966 | struct v4l2_dbg_chip_ident *chip) |
967 | { | 967 | { |
968 | int rev; | 968 | int rev; |
969 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 969 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
@@ -977,25 +977,24 @@ static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, | |||
977 | 977 | ||
978 | 978 | ||
979 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 979 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
980 | static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 980 | static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
981 | { | 981 | { |
982 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 982 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
983 | 983 | ||
984 | if (!v4l2_chip_match_i2c_client(client, | 984 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
985 | reg->match_type, reg->match_chip)) | ||
986 | return -EINVAL; | 985 | return -EINVAL; |
987 | if (!capable(CAP_SYS_ADMIN)) | 986 | if (!capable(CAP_SYS_ADMIN)) |
988 | return -EPERM; | 987 | return -EPERM; |
989 | reg->val = tvp5150_read(sd, reg->reg & 0xff); | 988 | reg->val = tvp5150_read(sd, reg->reg & 0xff); |
989 | reg->size = 1; | ||
990 | return 0; | 990 | return 0; |
991 | } | 991 | } |
992 | 992 | ||
993 | static int tvp5150_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 993 | static int tvp5150_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
994 | { | 994 | { |
995 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 995 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
996 | 996 | ||
997 | if (!v4l2_chip_match_i2c_client(client, | 997 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
998 | reg->match_type, reg->match_chip)) | ||
999 | return -EINVAL; | 998 | return -EINVAL; |
1000 | if (!capable(CAP_SYS_ADMIN)) | 999 | if (!capable(CAP_SYS_ADMIN)) |
1001 | return -EPERM; | 1000 | return -EPERM; |
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c index d5cdc4be1a35..52c0357faa5d 100644 --- a/drivers/media/video/tw9910.c +++ b/drivers/media/video/tw9910.c | |||
@@ -575,7 +575,7 @@ static unsigned long tw9910_query_bus_param(struct soc_camera_device *icd) | |||
575 | } | 575 | } |
576 | 576 | ||
577 | static int tw9910_get_chip_id(struct soc_camera_device *icd, | 577 | static int tw9910_get_chip_id(struct soc_camera_device *icd, |
578 | struct v4l2_chip_ident *id) | 578 | struct v4l2_dbg_chip_ident *id) |
579 | { | 579 | { |
580 | id->ident = V4L2_IDENT_TW9910; | 580 | id->ident = V4L2_IDENT_TW9910; |
581 | id->revision = 0; | 581 | id->revision = 0; |
@@ -606,7 +606,7 @@ static int tw9910_enum_input(struct soc_camera_device *icd, | |||
606 | 606 | ||
607 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 607 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
608 | static int tw9910_get_register(struct soc_camera_device *icd, | 608 | static int tw9910_get_register(struct soc_camera_device *icd, |
609 | struct v4l2_register *reg) | 609 | struct v4l2_dbg_register *reg) |
610 | { | 610 | { |
611 | struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); | 611 | struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); |
612 | int ret; | 612 | int ret; |
@@ -627,7 +627,7 @@ static int tw9910_get_register(struct soc_camera_device *icd, | |||
627 | } | 627 | } |
628 | 628 | ||
629 | static int tw9910_set_register(struct soc_camera_device *icd, | 629 | static int tw9910_set_register(struct soc_camera_device *icd, |
630 | struct v4l2_register *reg) | 630 | struct v4l2_dbg_register *reg) |
631 | { | 631 | { |
632 | struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); | 632 | struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); |
633 | 633 | ||
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c index 7a609a3a6dbe..4f16effb530f 100644 --- a/drivers/media/video/upd64031a.c +++ b/drivers/media/video/upd64031a.c | |||
@@ -147,7 +147,7 @@ static int upd64031a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing | |||
147 | return upd64031a_s_frequency(sd, NULL); | 147 | return upd64031a_s_frequency(sd, NULL); |
148 | } | 148 | } |
149 | 149 | ||
150 | static int upd64031a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 150 | static int upd64031a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
151 | { | 151 | { |
152 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 152 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
153 | 153 | ||
@@ -162,25 +162,24 @@ static int upd64031a_log_status(struct v4l2_subdev *sd) | |||
162 | } | 162 | } |
163 | 163 | ||
164 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 164 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
165 | static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 165 | static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
166 | { | 166 | { |
167 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 167 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
168 | 168 | ||
169 | if (!v4l2_chip_match_i2c_client(client, | 169 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
170 | reg->match_type, reg->match_chip)) | ||
171 | return -EINVAL; | 170 | return -EINVAL; |
172 | if (!capable(CAP_SYS_ADMIN)) | 171 | if (!capable(CAP_SYS_ADMIN)) |
173 | return -EPERM; | 172 | return -EPERM; |
174 | reg->val = upd64031a_read(sd, reg->reg & 0xff); | 173 | reg->val = upd64031a_read(sd, reg->reg & 0xff); |
174 | reg->size = 1; | ||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | static int upd64031a_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 178 | static int upd64031a_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
179 | { | 179 | { |
180 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 180 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
181 | 181 | ||
182 | if (!v4l2_chip_match_i2c_client(client, | 182 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
183 | reg->match_type, reg->match_chip)) | ||
184 | return -EINVAL; | 183 | return -EINVAL; |
185 | if (!capable(CAP_SYS_ADMIN)) | 184 | if (!capable(CAP_SYS_ADMIN)) |
186 | return -EPERM; | 185 | return -EPERM; |
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c index 58412cb9c01a..4b712f69d1b7 100644 --- a/drivers/media/video/upd64083.c +++ b/drivers/media/video/upd64083.c | |||
@@ -120,25 +120,24 @@ static int upd64083_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing | |||
120 | } | 120 | } |
121 | 121 | ||
122 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 122 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
123 | static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 123 | static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
124 | { | 124 | { |
125 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 125 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
126 | 126 | ||
127 | if (!v4l2_chip_match_i2c_client(client, | 127 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
128 | reg->match_type, reg->match_chip)) | ||
129 | return -EINVAL; | 128 | return -EINVAL; |
130 | if (!capable(CAP_SYS_ADMIN)) | 129 | if (!capable(CAP_SYS_ADMIN)) |
131 | return -EPERM; | 130 | return -EPERM; |
132 | reg->val = upd64083_read(sd, reg->reg & 0xff); | 131 | reg->val = upd64083_read(sd, reg->reg & 0xff); |
132 | reg->size = 1; | ||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) | 136 | static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
137 | { | 137 | { |
138 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 138 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
139 | 139 | ||
140 | if (!v4l2_chip_match_i2c_client(client, | 140 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
141 | reg->match_type, reg->match_chip)) | ||
142 | return -EINVAL; | 141 | return -EINVAL; |
143 | if (!capable(CAP_SYS_ADMIN)) | 142 | if (!capable(CAP_SYS_ADMIN)) |
144 | return -EPERM; | 143 | return -EPERM; |
@@ -147,7 +146,7 @@ static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg | |||
147 | } | 146 | } |
148 | #endif | 147 | #endif |
149 | 148 | ||
150 | static int upd64083_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 149 | static int upd64083_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
151 | { | 150 | { |
152 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 151 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
153 | 152 | ||
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c index 148a1f98c70f..dea8b321fb4a 100644 --- a/drivers/media/video/usbvideo/usbvideo.c +++ b/drivers/media/video/usbvideo/usbvideo.c | |||
@@ -41,13 +41,13 @@ module_param(video_nr, int, 0); | |||
41 | static void usbvideo_Disconnect(struct usb_interface *intf); | 41 | static void usbvideo_Disconnect(struct usb_interface *intf); |
42 | static void usbvideo_CameraRelease(struct uvd *uvd); | 42 | static void usbvideo_CameraRelease(struct uvd *uvd); |
43 | 43 | ||
44 | static int usbvideo_v4l_ioctl(struct inode *inode, struct file *file, | 44 | static long usbvideo_v4l_ioctl(struct file *file, |
45 | unsigned int cmd, unsigned long arg); | 45 | unsigned int cmd, unsigned long arg); |
46 | static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma); | 46 | static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma); |
47 | static int usbvideo_v4l_open(struct inode *inode, struct file *file); | 47 | static int usbvideo_v4l_open(struct file *file); |
48 | static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | 48 | static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, |
49 | size_t count, loff_t *ppos); | 49 | size_t count, loff_t *ppos); |
50 | static int usbvideo_v4l_close(struct inode *inode, struct file *file); | 50 | static int usbvideo_v4l_close(struct file *file); |
51 | 51 | ||
52 | static int usbvideo_StartDataPump(struct uvd *uvd); | 52 | static int usbvideo_StartDataPump(struct uvd *uvd); |
53 | static void usbvideo_StopDataPump(struct uvd *uvd); | 53 | static void usbvideo_StopDataPump(struct uvd *uvd); |
@@ -942,17 +942,13 @@ static int usbvideo_find_struct(struct usbvideo *cams) | |||
942 | return rv; | 942 | return rv; |
943 | } | 943 | } |
944 | 944 | ||
945 | static const struct file_operations usbvideo_fops = { | 945 | static const struct v4l2_file_operations usbvideo_fops = { |
946 | .owner = THIS_MODULE, | 946 | .owner = THIS_MODULE, |
947 | .open = usbvideo_v4l_open, | 947 | .open = usbvideo_v4l_open, |
948 | .release =usbvideo_v4l_close, | 948 | .release =usbvideo_v4l_close, |
949 | .read = usbvideo_v4l_read, | 949 | .read = usbvideo_v4l_read, |
950 | .mmap = usbvideo_v4l_mmap, | 950 | .mmap = usbvideo_v4l_mmap, |
951 | .ioctl = usbvideo_v4l_ioctl, | 951 | .ioctl = usbvideo_v4l_ioctl, |
952 | #ifdef CONFIG_COMPAT | ||
953 | .compat_ioctl = v4l_compat_ioctl32, | ||
954 | #endif | ||
955 | .llseek = no_llseek, | ||
956 | }; | 952 | }; |
957 | static const struct video_device usbvideo_template = { | 953 | static const struct video_device usbvideo_template = { |
958 | .fops = &usbvideo_fops, | 954 | .fops = &usbvideo_fops, |
@@ -1113,7 +1109,7 @@ static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma) | |||
1113 | * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. | 1109 | * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. |
1114 | * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT). | 1110 | * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT). |
1115 | */ | 1111 | */ |
1116 | static int usbvideo_v4l_open(struct inode *inode, struct file *file) | 1112 | static int usbvideo_v4l_open(struct file *file) |
1117 | { | 1113 | { |
1118 | struct video_device *dev = video_devdata(file); | 1114 | struct video_device *dev = video_devdata(file); |
1119 | struct uvd *uvd = (struct uvd *) dev; | 1115 | struct uvd *uvd = (struct uvd *) dev; |
@@ -1233,7 +1229,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
1233 | * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. | 1229 | * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. |
1234 | * 24-May-2000 Moved MOD_DEC_USE_COUNT outside of code that can sleep. | 1230 | * 24-May-2000 Moved MOD_DEC_USE_COUNT outside of code that can sleep. |
1235 | */ | 1231 | */ |
1236 | static int usbvideo_v4l_close(struct inode *inode, struct file *file) | 1232 | static int usbvideo_v4l_close(struct file *file) |
1237 | { | 1233 | { |
1238 | struct video_device *dev = file->private_data; | 1234 | struct video_device *dev = file->private_data; |
1239 | struct uvd *uvd = (struct uvd *) dev; | 1235 | struct uvd *uvd = (struct uvd *) dev; |
@@ -1281,7 +1277,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) | |||
1281 | * History: | 1277 | * History: |
1282 | * 22-Jan-2000 Corrected VIDIOCSPICT to reject unsupported settings. | 1278 | * 22-Jan-2000 Corrected VIDIOCSPICT to reject unsupported settings. |
1283 | */ | 1279 | */ |
1284 | static int usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 1280 | static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
1285 | { | 1281 | { |
1286 | struct uvd *uvd = file->private_data; | 1282 | struct uvd *uvd = file->private_data; |
1287 | 1283 | ||
@@ -1501,7 +1497,7 @@ static int usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
1501 | return 0; | 1497 | return 0; |
1502 | } | 1498 | } |
1503 | 1499 | ||
1504 | static int usbvideo_v4l_ioctl(struct inode *inode, struct file *file, | 1500 | static long usbvideo_v4l_ioctl(struct file *file, |
1505 | unsigned int cmd, unsigned long arg) | 1501 | unsigned int cmd, unsigned long arg) |
1506 | { | 1502 | { |
1507 | return video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl); | 1503 | return video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl); |
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index 4602597ed8d1..2f1106338c08 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
@@ -229,12 +229,12 @@ set_camera_power(struct vicam_camera *cam, int state) | |||
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | static int | 232 | static long |
233 | vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsigned long arg) | 233 | vicam_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg) |
234 | { | 234 | { |
235 | void __user *user_arg = (void __user *)arg; | 235 | void __user *user_arg = (void __user *)arg; |
236 | struct vicam_camera *cam = file->private_data; | 236 | struct vicam_camera *cam = file->private_data; |
237 | int retval = 0; | 237 | long retval = 0; |
238 | 238 | ||
239 | if (!cam) | 239 | if (!cam) |
240 | return -ENODEV; | 240 | return -ENODEV; |
@@ -470,7 +470,7 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign | |||
470 | } | 470 | } |
471 | 471 | ||
472 | static int | 472 | static int |
473 | vicam_open(struct inode *inode, struct file *file) | 473 | vicam_open(struct file *file) |
474 | { | 474 | { |
475 | struct vicam_camera *cam = video_drvdata(file); | 475 | struct vicam_camera *cam = video_drvdata(file); |
476 | 476 | ||
@@ -536,7 +536,7 @@ vicam_open(struct inode *inode, struct file *file) | |||
536 | } | 536 | } |
537 | 537 | ||
538 | static int | 538 | static int |
539 | vicam_close(struct inode *inode, struct file *file) | 539 | vicam_close(struct file *file) |
540 | { | 540 | { |
541 | struct vicam_camera *cam = file->private_data; | 541 | struct vicam_camera *cam = file->private_data; |
542 | int open_count; | 542 | int open_count; |
@@ -783,17 +783,13 @@ vicam_mmap(struct file *file, struct vm_area_struct *vma) | |||
783 | return 0; | 783 | return 0; |
784 | } | 784 | } |
785 | 785 | ||
786 | static const struct file_operations vicam_fops = { | 786 | static const struct v4l2_file_operations vicam_fops = { |
787 | .owner = THIS_MODULE, | 787 | .owner = THIS_MODULE, |
788 | .open = vicam_open, | 788 | .open = vicam_open, |
789 | .release = vicam_close, | 789 | .release = vicam_close, |
790 | .read = vicam_read, | 790 | .read = vicam_read, |
791 | .mmap = vicam_mmap, | 791 | .mmap = vicam_mmap, |
792 | .ioctl = vicam_ioctl, | 792 | .ioctl = vicam_ioctl, |
793 | #ifdef CONFIG_COMPAT | ||
794 | .compat_ioctl = v4l_compat_ioctl32, | ||
795 | #endif | ||
796 | .llseek = no_llseek, | ||
797 | }; | 793 | }; |
798 | 794 | ||
799 | static struct video_device vicam_template = { | 795 | static struct video_device vicam_template = { |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 85661b1848fe..2be5e47ed081 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -355,7 +355,7 @@ static void usbvision_remove_sysfs(struct video_device *vdev) | |||
355 | * then allocates buffers needed for video processing. | 355 | * then allocates buffers needed for video processing. |
356 | * | 356 | * |
357 | */ | 357 | */ |
358 | static int usbvision_v4l2_open(struct inode *inode, struct file *file) | 358 | static int usbvision_v4l2_open(struct file *file) |
359 | { | 359 | { |
360 | struct usb_usbvision *usbvision = video_drvdata(file); | 360 | struct usb_usbvision *usbvision = video_drvdata(file); |
361 | int errCode = 0; | 361 | int errCode = 0; |
@@ -432,7 +432,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) | |||
432 | * allocated in usbvision_v4l2_open(). | 432 | * allocated in usbvision_v4l2_open(). |
433 | * | 433 | * |
434 | */ | 434 | */ |
435 | static int usbvision_v4l2_close(struct inode *inode, struct file *file) | 435 | static int usbvision_v4l2_close(struct file *file) |
436 | { | 436 | { |
437 | struct usb_usbvision *usbvision = video_drvdata(file); | 437 | struct usb_usbvision *usbvision = video_drvdata(file); |
438 | 438 | ||
@@ -477,12 +477,12 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) | |||
477 | */ | 477 | */ |
478 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 478 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
479 | static int vidioc_g_register (struct file *file, void *priv, | 479 | static int vidioc_g_register (struct file *file, void *priv, |
480 | struct v4l2_register *reg) | 480 | struct v4l2_dbg_register *reg) |
481 | { | 481 | { |
482 | struct usb_usbvision *usbvision = video_drvdata(file); | 482 | struct usb_usbvision *usbvision = video_drvdata(file); |
483 | int errCode; | 483 | int errCode; |
484 | 484 | ||
485 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 485 | if (!v4l2_chip_match_host(®->match)) |
486 | return -EINVAL; | 486 | return -EINVAL; |
487 | /* NT100x has a 8-bit register space */ | 487 | /* NT100x has a 8-bit register space */ |
488 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); | 488 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); |
@@ -492,16 +492,17 @@ static int vidioc_g_register (struct file *file, void *priv, | |||
492 | return errCode; | 492 | return errCode; |
493 | } | 493 | } |
494 | reg->val = errCode; | 494 | reg->val = errCode; |
495 | reg->size = 1; | ||
495 | return 0; | 496 | return 0; |
496 | } | 497 | } |
497 | 498 | ||
498 | static int vidioc_s_register (struct file *file, void *priv, | 499 | static int vidioc_s_register (struct file *file, void *priv, |
499 | struct v4l2_register *reg) | 500 | struct v4l2_dbg_register *reg) |
500 | { | 501 | { |
501 | struct usb_usbvision *usbvision = video_drvdata(file); | 502 | struct usb_usbvision *usbvision = video_drvdata(file); |
502 | int errCode; | 503 | int errCode; |
503 | 504 | ||
504 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 505 | if (!v4l2_chip_match_host(®->match)) |
505 | return -EINVAL; | 506 | return -EINVAL; |
506 | /* NT100x has a 8-bit register space */ | 507 | /* NT100x has a 8-bit register space */ |
507 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 508 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); |
@@ -1178,7 +1179,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1178 | * Here comes the stuff for radio on usbvision based devices | 1179 | * Here comes the stuff for radio on usbvision based devices |
1179 | * | 1180 | * |
1180 | */ | 1181 | */ |
1181 | static int usbvision_radio_open(struct inode *inode, struct file *file) | 1182 | static int usbvision_radio_open(struct file *file) |
1182 | { | 1183 | { |
1183 | struct usb_usbvision *usbvision = video_drvdata(file); | 1184 | struct usb_usbvision *usbvision = video_drvdata(file); |
1184 | int errCode = 0; | 1185 | int errCode = 0; |
@@ -1228,7 +1229,7 @@ out: | |||
1228 | } | 1229 | } |
1229 | 1230 | ||
1230 | 1231 | ||
1231 | static int usbvision_radio_close(struct inode *inode, struct file *file) | 1232 | static int usbvision_radio_close(struct file *file) |
1232 | { | 1233 | { |
1233 | struct usb_usbvision *usbvision = video_drvdata(file); | 1234 | struct usb_usbvision *usbvision = video_drvdata(file); |
1234 | int errCode = 0; | 1235 | int errCode = 0; |
@@ -1266,26 +1267,26 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) | |||
1266 | * Here comes the stuff for vbi on usbvision based devices | 1267 | * Here comes the stuff for vbi on usbvision based devices |
1267 | * | 1268 | * |
1268 | */ | 1269 | */ |
1269 | static int usbvision_vbi_open(struct inode *inode, struct file *file) | 1270 | static int usbvision_vbi_open(struct file *file) |
1270 | { | 1271 | { |
1271 | /* TODO */ | 1272 | /* TODO */ |
1272 | return -ENODEV; | 1273 | return -ENODEV; |
1273 | } | 1274 | } |
1274 | 1275 | ||
1275 | static int usbvision_vbi_close(struct inode *inode, struct file *file) | 1276 | static int usbvision_vbi_close(struct file *file) |
1276 | { | 1277 | { |
1277 | /* TODO */ | 1278 | /* TODO */ |
1278 | return -ENODEV; | 1279 | return -ENODEV; |
1279 | } | 1280 | } |
1280 | 1281 | ||
1281 | static int usbvision_do_vbi_ioctl(struct file *file, | 1282 | static long usbvision_do_vbi_ioctl(struct file *file, |
1282 | unsigned int cmd, void *arg) | 1283 | unsigned int cmd, void *arg) |
1283 | { | 1284 | { |
1284 | /* TODO */ | 1285 | /* TODO */ |
1285 | return -ENOIOCTLCMD; | 1286 | return -ENOIOCTLCMD; |
1286 | } | 1287 | } |
1287 | 1288 | ||
1288 | static int usbvision_vbi_ioctl(struct inode *inode, struct file *file, | 1289 | static long usbvision_vbi_ioctl(struct file *file, |
1289 | unsigned int cmd, unsigned long arg) | 1290 | unsigned int cmd, unsigned long arg) |
1290 | { | 1291 | { |
1291 | return video_usercopy(file, cmd, arg, usbvision_do_vbi_ioctl); | 1292 | return video_usercopy(file, cmd, arg, usbvision_do_vbi_ioctl); |
@@ -1297,16 +1298,14 @@ static int usbvision_vbi_ioctl(struct inode *inode, struct file *file, | |||
1297 | // | 1298 | // |
1298 | 1299 | ||
1299 | // Video template | 1300 | // Video template |
1300 | static const struct file_operations usbvision_fops = { | 1301 | static const struct v4l2_file_operations usbvision_fops = { |
1301 | .owner = THIS_MODULE, | 1302 | .owner = THIS_MODULE, |
1302 | .open = usbvision_v4l2_open, | 1303 | .open = usbvision_v4l2_open, |
1303 | .release = usbvision_v4l2_close, | 1304 | .release = usbvision_v4l2_close, |
1304 | .read = usbvision_v4l2_read, | 1305 | .read = usbvision_v4l2_read, |
1305 | .mmap = usbvision_v4l2_mmap, | 1306 | .mmap = usbvision_v4l2_mmap, |
1306 | .ioctl = video_ioctl2, | 1307 | .ioctl = video_ioctl2, |
1307 | .llseek = no_llseek, | ||
1308 | /* .poll = video_poll, */ | 1308 | /* .poll = video_poll, */ |
1309 | .compat_ioctl = v4l_compat_ioctl32, | ||
1310 | }; | 1309 | }; |
1311 | 1310 | ||
1312 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | 1311 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { |
@@ -1355,13 +1354,11 @@ static struct video_device usbvision_video_template = { | |||
1355 | 1354 | ||
1356 | 1355 | ||
1357 | // Radio template | 1356 | // Radio template |
1358 | static const struct file_operations usbvision_radio_fops = { | 1357 | static const struct v4l2_file_operations usbvision_radio_fops = { |
1359 | .owner = THIS_MODULE, | 1358 | .owner = THIS_MODULE, |
1360 | .open = usbvision_radio_open, | 1359 | .open = usbvision_radio_open, |
1361 | .release = usbvision_radio_close, | 1360 | .release = usbvision_radio_close, |
1362 | .ioctl = video_ioctl2, | 1361 | .ioctl = video_ioctl2, |
1363 | .llseek = no_llseek, | ||
1364 | .compat_ioctl = v4l_compat_ioctl32, | ||
1365 | }; | 1362 | }; |
1366 | 1363 | ||
1367 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | 1364 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { |
@@ -1392,13 +1389,11 @@ static struct video_device usbvision_radio_template = { | |||
1392 | }; | 1389 | }; |
1393 | 1390 | ||
1394 | // vbi template | 1391 | // vbi template |
1395 | static const struct file_operations usbvision_vbi_fops = { | 1392 | static const struct v4l2_file_operations usbvision_vbi_fops = { |
1396 | .owner = THIS_MODULE, | 1393 | .owner = THIS_MODULE, |
1397 | .open = usbvision_vbi_open, | 1394 | .open = usbvision_vbi_open, |
1398 | .release = usbvision_vbi_close, | 1395 | .release = usbvision_vbi_close, |
1399 | .ioctl = usbvision_vbi_ioctl, | 1396 | .ioctl = usbvision_vbi_ioctl, |
1400 | .llseek = no_llseek, | ||
1401 | .compat_ioctl = v4l_compat_ioctl32, | ||
1402 | }; | 1397 | }; |
1403 | 1398 | ||
1404 | static struct video_device usbvision_vbi_template= | 1399 | static struct video_device usbvision_vbi_template= |
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index afcc6934559e..fa150fff2c10 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c | |||
@@ -406,7 +406,7 @@ static int uvc_has_privileges(struct uvc_fh *handle) | |||
406 | * V4L2 file operations | 406 | * V4L2 file operations |
407 | */ | 407 | */ |
408 | 408 | ||
409 | static int uvc_v4l2_open(struct inode *inode, struct file *file) | 409 | static int uvc_v4l2_open(struct file *file) |
410 | { | 410 | { |
411 | struct uvc_video_device *video; | 411 | struct uvc_video_device *video; |
412 | struct uvc_fh *handle; | 412 | struct uvc_fh *handle; |
@@ -444,7 +444,7 @@ done: | |||
444 | return ret; | 444 | return ret; |
445 | } | 445 | } |
446 | 446 | ||
447 | static int uvc_v4l2_release(struct inode *inode, struct file *file) | 447 | static int uvc_v4l2_release(struct file *file) |
448 | { | 448 | { |
449 | struct uvc_video_device *video = video_drvdata(file); | 449 | struct uvc_video_device *video = video_drvdata(file); |
450 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; | 450 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; |
@@ -472,12 +472,12 @@ static int uvc_v4l2_release(struct inode *inode, struct file *file) | |||
472 | return 0; | 472 | return 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | static int uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 475 | static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
476 | { | 476 | { |
477 | struct video_device *vdev = video_devdata(file); | 477 | struct video_device *vdev = video_devdata(file); |
478 | struct uvc_video_device *video = video_get_drvdata(vdev); | 478 | struct uvc_video_device *video = video_get_drvdata(vdev); |
479 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; | 479 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; |
480 | int ret = 0; | 480 | long ret = 0; |
481 | 481 | ||
482 | switch (cmd) { | 482 | switch (cmd) { |
483 | /* Query capabilities */ | 483 | /* Query capabilities */ |
@@ -996,7 +996,7 @@ static int uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
996 | return ret; | 996 | return ret; |
997 | } | 997 | } |
998 | 998 | ||
999 | static int uvc_v4l2_ioctl(struct inode *inode, struct file *file, | 999 | static long uvc_v4l2_ioctl(struct file *file, |
1000 | unsigned int cmd, unsigned long arg) | 1000 | unsigned int cmd, unsigned long arg) |
1001 | { | 1001 | { |
1002 | if (uvc_trace_param & UVC_TRACE_IOCTL) { | 1002 | if (uvc_trace_param & UVC_TRACE_IOCTL) { |
@@ -1097,13 +1097,11 @@ static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait) | |||
1097 | return uvc_queue_poll(&video->queue, file, wait); | 1097 | return uvc_queue_poll(&video->queue, file, wait); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | struct file_operations uvc_fops = { | 1100 | const struct v4l2_file_operations uvc_fops = { |
1101 | .owner = THIS_MODULE, | 1101 | .owner = THIS_MODULE, |
1102 | .open = uvc_v4l2_open, | 1102 | .open = uvc_v4l2_open, |
1103 | .release = uvc_v4l2_release, | 1103 | .release = uvc_v4l2_release, |
1104 | .ioctl = uvc_v4l2_ioctl, | 1104 | .ioctl = uvc_v4l2_ioctl, |
1105 | .compat_ioctl = v4l_compat_ioctl32, | ||
1106 | .llseek = no_llseek, | ||
1107 | .read = uvc_v4l2_read, | 1105 | .read = uvc_v4l2_read, |
1108 | .mmap = uvc_v4l2_mmap, | 1106 | .mmap = uvc_v4l2_mmap, |
1109 | .poll = uvc_v4l2_poll, | 1107 | .poll = uvc_v4l2_poll, |
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index 896b791ece15..bcf4361dc1bc 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -753,7 +753,7 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue) | |||
753 | } | 753 | } |
754 | 754 | ||
755 | /* V4L2 interface */ | 755 | /* V4L2 interface */ |
756 | extern struct file_operations uvc_fops; | 756 | extern const struct v4l2_file_operations uvc_fops; |
757 | 757 | ||
758 | /* Video */ | 758 | /* Video */ |
759 | extern int uvc_video_init(struct uvc_video_device *video); | 759 | extern int uvc_video_init(struct uvc_video_device *video); |
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index f13c0a9d684f..d450cab20be4 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
@@ -267,12 +267,12 @@ done: | |||
267 | 267 | ||
268 | /* ----------------------------------------------------------------- */ | 268 | /* ----------------------------------------------------------------- */ |
269 | 269 | ||
270 | static noinline int v4l1_compat_get_capabilities( | 270 | static noinline long v4l1_compat_get_capabilities( |
271 | struct video_capability *cap, | 271 | struct video_capability *cap, |
272 | struct file *file, | 272 | struct file *file, |
273 | v4l2_kioctl drv) | 273 | v4l2_kioctl drv) |
274 | { | 274 | { |
275 | int err; | 275 | long err; |
276 | struct v4l2_framebuffer fbuf; | 276 | struct v4l2_framebuffer fbuf; |
277 | struct v4l2_capability *cap2; | 277 | struct v4l2_capability *cap2; |
278 | 278 | ||
@@ -286,13 +286,13 @@ static noinline int v4l1_compat_get_capabilities( | |||
286 | 286 | ||
287 | err = drv(file, VIDIOC_QUERYCAP, cap2); | 287 | err = drv(file, VIDIOC_QUERYCAP, cap2); |
288 | if (err < 0) { | 288 | if (err < 0) { |
289 | dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err); | 289 | dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %ld\n", err); |
290 | goto done; | 290 | goto done; |
291 | } | 291 | } |
292 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { | 292 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { |
293 | err = drv(file, VIDIOC_G_FBUF, &fbuf); | 293 | err = drv(file, VIDIOC_G_FBUF, &fbuf); |
294 | if (err < 0) { | 294 | if (err < 0) { |
295 | dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err); | 295 | dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %ld\n", err); |
296 | memset(&fbuf, 0, sizeof(fbuf)); | 296 | memset(&fbuf, 0, sizeof(fbuf)); |
297 | } | 297 | } |
298 | err = 0; | 298 | err = 0; |
@@ -324,12 +324,12 @@ done: | |||
324 | return err; | 324 | return err; |
325 | } | 325 | } |
326 | 326 | ||
327 | static noinline int v4l1_compat_get_frame_buffer( | 327 | static noinline long v4l1_compat_get_frame_buffer( |
328 | struct video_buffer *buffer, | 328 | struct video_buffer *buffer, |
329 | struct file *file, | 329 | struct file *file, |
330 | v4l2_kioctl drv) | 330 | v4l2_kioctl drv) |
331 | { | 331 | { |
332 | int err; | 332 | long err; |
333 | struct v4l2_framebuffer fbuf; | 333 | struct v4l2_framebuffer fbuf; |
334 | 334 | ||
335 | memset(buffer, 0, sizeof(*buffer)); | 335 | memset(buffer, 0, sizeof(*buffer)); |
@@ -337,7 +337,7 @@ static noinline int v4l1_compat_get_frame_buffer( | |||
337 | 337 | ||
338 | err = drv(file, VIDIOC_G_FBUF, &fbuf); | 338 | err = drv(file, VIDIOC_G_FBUF, &fbuf); |
339 | if (err < 0) { | 339 | if (err < 0) { |
340 | dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); | 340 | dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %ld\n", err); |
341 | goto done; | 341 | goto done; |
342 | } | 342 | } |
343 | buffer->base = fbuf.base; | 343 | buffer->base = fbuf.base; |
@@ -378,12 +378,12 @@ done: | |||
378 | return err; | 378 | return err; |
379 | } | 379 | } |
380 | 380 | ||
381 | static noinline int v4l1_compat_set_frame_buffer( | 381 | static noinline long v4l1_compat_set_frame_buffer( |
382 | struct video_buffer *buffer, | 382 | struct video_buffer *buffer, |
383 | struct file *file, | 383 | struct file *file, |
384 | v4l2_kioctl drv) | 384 | v4l2_kioctl drv) |
385 | { | 385 | { |
386 | int err; | 386 | long err; |
387 | struct v4l2_framebuffer fbuf; | 387 | struct v4l2_framebuffer fbuf; |
388 | 388 | ||
389 | memset(&fbuf, 0, sizeof(fbuf)); | 389 | memset(&fbuf, 0, sizeof(fbuf)); |
@@ -410,16 +410,16 @@ static noinline int v4l1_compat_set_frame_buffer( | |||
410 | fbuf.fmt.bytesperline = buffer->bytesperline; | 410 | fbuf.fmt.bytesperline = buffer->bytesperline; |
411 | err = drv(file, VIDIOC_S_FBUF, &fbuf); | 411 | err = drv(file, VIDIOC_S_FBUF, &fbuf); |
412 | if (err < 0) | 412 | if (err < 0) |
413 | dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err); | 413 | dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %ld\n", err); |
414 | return err; | 414 | return err; |
415 | } | 415 | } |
416 | 416 | ||
417 | static noinline int v4l1_compat_get_win_cap_dimensions( | 417 | static noinline long v4l1_compat_get_win_cap_dimensions( |
418 | struct video_window *win, | 418 | struct video_window *win, |
419 | struct file *file, | 419 | struct file *file, |
420 | v4l2_kioctl drv) | 420 | v4l2_kioctl drv) |
421 | { | 421 | { |
422 | int err; | 422 | long err; |
423 | struct v4l2_format *fmt; | 423 | struct v4l2_format *fmt; |
424 | 424 | ||
425 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); | 425 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
@@ -432,7 +432,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions( | |||
432 | fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; | 432 | fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; |
433 | err = drv(file, VIDIOC_G_FMT, fmt); | 433 | err = drv(file, VIDIOC_G_FMT, fmt); |
434 | if (err < 0) | 434 | if (err < 0) |
435 | dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err); | 435 | dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %ld\n", err); |
436 | if (err == 0) { | 436 | if (err == 0) { |
437 | win->x = fmt->fmt.win.w.left; | 437 | win->x = fmt->fmt.win.w.left; |
438 | win->y = fmt->fmt.win.w.top; | 438 | win->y = fmt->fmt.win.w.top; |
@@ -447,7 +447,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions( | |||
447 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 447 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
448 | err = drv(file, VIDIOC_G_FMT, fmt); | 448 | err = drv(file, VIDIOC_G_FMT, fmt); |
449 | if (err < 0) { | 449 | if (err < 0) { |
450 | dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err); | 450 | dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %ld\n", err); |
451 | goto done; | 451 | goto done; |
452 | } | 452 | } |
453 | win->x = 0; | 453 | win->x = 0; |
@@ -462,12 +462,12 @@ done: | |||
462 | return err; | 462 | return err; |
463 | } | 463 | } |
464 | 464 | ||
465 | static noinline int v4l1_compat_set_win_cap_dimensions( | 465 | static noinline long v4l1_compat_set_win_cap_dimensions( |
466 | struct video_window *win, | 466 | struct video_window *win, |
467 | struct file *file, | 467 | struct file *file, |
468 | v4l2_kioctl drv) | 468 | v4l2_kioctl drv) |
469 | { | 469 | { |
470 | int err, err1, err2; | 470 | long err, err1, err2; |
471 | struct v4l2_format *fmt; | 471 | struct v4l2_format *fmt; |
472 | 472 | ||
473 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); | 473 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
@@ -479,7 +479,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions( | |||
479 | drv(file, VIDIOC_STREAMOFF, &fmt->type); | 479 | drv(file, VIDIOC_STREAMOFF, &fmt->type); |
480 | err1 = drv(file, VIDIOC_G_FMT, fmt); | 480 | err1 = drv(file, VIDIOC_G_FMT, fmt); |
481 | if (err1 < 0) | 481 | if (err1 < 0) |
482 | dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1); | 482 | dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %ld\n", err1); |
483 | if (err1 == 0) { | 483 | if (err1 == 0) { |
484 | fmt->fmt.pix.width = win->width; | 484 | fmt->fmt.pix.width = win->width; |
485 | fmt->fmt.pix.height = win->height; | 485 | fmt->fmt.pix.height = win->height; |
@@ -487,7 +487,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions( | |||
487 | fmt->fmt.pix.bytesperline = 0; | 487 | fmt->fmt.pix.bytesperline = 0; |
488 | err = drv(file, VIDIOC_S_FMT, fmt); | 488 | err = drv(file, VIDIOC_S_FMT, fmt); |
489 | if (err < 0) | 489 | if (err < 0) |
490 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", | 490 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %ld\n", |
491 | err); | 491 | err); |
492 | win->width = fmt->fmt.pix.width; | 492 | win->width = fmt->fmt.pix.width; |
493 | win->height = fmt->fmt.pix.height; | 493 | win->height = fmt->fmt.pix.height; |
@@ -504,7 +504,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions( | |||
504 | fmt->fmt.win.clipcount = win->clipcount; | 504 | fmt->fmt.win.clipcount = win->clipcount; |
505 | err2 = drv(file, VIDIOC_S_FMT, fmt); | 505 | err2 = drv(file, VIDIOC_S_FMT, fmt); |
506 | if (err2 < 0) | 506 | if (err2 < 0) |
507 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2); | 507 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %ld\n", err2); |
508 | 508 | ||
509 | if (err1 != 0 && err2 != 0) | 509 | if (err1 != 0 && err2 != 0) |
510 | err = err1; | 510 | err = err1; |
@@ -514,12 +514,12 @@ static noinline int v4l1_compat_set_win_cap_dimensions( | |||
514 | return err; | 514 | return err; |
515 | } | 515 | } |
516 | 516 | ||
517 | static noinline int v4l1_compat_turn_preview_on_off( | 517 | static noinline long v4l1_compat_turn_preview_on_off( |
518 | int *on, | 518 | int *on, |
519 | struct file *file, | 519 | struct file *file, |
520 | v4l2_kioctl drv) | 520 | v4l2_kioctl drv) |
521 | { | 521 | { |
522 | int err; | 522 | long err; |
523 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 523 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
524 | 524 | ||
525 | if (0 == *on) { | 525 | if (0 == *on) { |
@@ -530,16 +530,16 @@ static noinline int v4l1_compat_turn_preview_on_off( | |||
530 | } | 530 | } |
531 | err = drv(file, VIDIOC_OVERLAY, on); | 531 | err = drv(file, VIDIOC_OVERLAY, on); |
532 | if (err < 0) | 532 | if (err < 0) |
533 | dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err); | 533 | dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %ld\n", err); |
534 | return err; | 534 | return err; |
535 | } | 535 | } |
536 | 536 | ||
537 | static noinline int v4l1_compat_get_input_info( | 537 | static noinline long v4l1_compat_get_input_info( |
538 | struct video_channel *chan, | 538 | struct video_channel *chan, |
539 | struct file *file, | 539 | struct file *file, |
540 | v4l2_kioctl drv) | 540 | v4l2_kioctl drv) |
541 | { | 541 | { |
542 | int err; | 542 | long err; |
543 | struct v4l2_input input2; | 543 | struct v4l2_input input2; |
544 | v4l2_std_id sid; | 544 | v4l2_std_id sid; |
545 | 545 | ||
@@ -548,7 +548,7 @@ static noinline int v4l1_compat_get_input_info( | |||
548 | err = drv(file, VIDIOC_ENUMINPUT, &input2); | 548 | err = drv(file, VIDIOC_ENUMINPUT, &input2); |
549 | if (err < 0) { | 549 | if (err < 0) { |
550 | dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " | 550 | dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " |
551 | "channel=%d err=%d\n", chan->channel, err); | 551 | "channel=%d err=%ld\n", chan->channel, err); |
552 | goto done; | 552 | goto done; |
553 | } | 553 | } |
554 | chan->channel = input2.index; | 554 | chan->channel = input2.index; |
@@ -569,7 +569,7 @@ static noinline int v4l1_compat_get_input_info( | |||
569 | chan->norm = 0; | 569 | chan->norm = 0; |
570 | err = drv(file, VIDIOC_G_STD, &sid); | 570 | err = drv(file, VIDIOC_G_STD, &sid); |
571 | if (err < 0) | 571 | if (err < 0) |
572 | dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n", err); | 572 | dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %ld\n", err); |
573 | if (err == 0) { | 573 | if (err == 0) { |
574 | if (sid & V4L2_STD_PAL) | 574 | if (sid & V4L2_STD_PAL) |
575 | chan->norm = VIDEO_MODE_PAL; | 575 | chan->norm = VIDEO_MODE_PAL; |
@@ -582,17 +582,17 @@ done: | |||
582 | return err; | 582 | return err; |
583 | } | 583 | } |
584 | 584 | ||
585 | static noinline int v4l1_compat_set_input( | 585 | static noinline long v4l1_compat_set_input( |
586 | struct video_channel *chan, | 586 | struct video_channel *chan, |
587 | struct file *file, | 587 | struct file *file, |
588 | v4l2_kioctl drv) | 588 | v4l2_kioctl drv) |
589 | { | 589 | { |
590 | int err; | 590 | long err; |
591 | v4l2_std_id sid = 0; | 591 | v4l2_std_id sid = 0; |
592 | 592 | ||
593 | err = drv(file, VIDIOC_S_INPUT, &chan->channel); | 593 | err = drv(file, VIDIOC_S_INPUT, &chan->channel); |
594 | if (err < 0) | 594 | if (err < 0) |
595 | dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err); | 595 | dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %ld\n", err); |
596 | switch (chan->norm) { | 596 | switch (chan->norm) { |
597 | case VIDEO_MODE_PAL: | 597 | case VIDEO_MODE_PAL: |
598 | sid = V4L2_STD_PAL; | 598 | sid = V4L2_STD_PAL; |
@@ -607,17 +607,17 @@ static noinline int v4l1_compat_set_input( | |||
607 | if (0 != sid) { | 607 | if (0 != sid) { |
608 | err = drv(file, VIDIOC_S_STD, &sid); | 608 | err = drv(file, VIDIOC_S_STD, &sid); |
609 | if (err < 0) | 609 | if (err < 0) |
610 | dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err); | 610 | dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %ld\n", err); |
611 | } | 611 | } |
612 | return err; | 612 | return err; |
613 | } | 613 | } |
614 | 614 | ||
615 | static noinline int v4l1_compat_get_picture( | 615 | static noinline long v4l1_compat_get_picture( |
616 | struct video_picture *pict, | 616 | struct video_picture *pict, |
617 | struct file *file, | 617 | struct file *file, |
618 | v4l2_kioctl drv) | 618 | v4l2_kioctl drv) |
619 | { | 619 | { |
620 | int err; | 620 | long err; |
621 | struct v4l2_format *fmt; | 621 | struct v4l2_format *fmt; |
622 | 622 | ||
623 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); | 623 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
@@ -640,7 +640,7 @@ static noinline int v4l1_compat_get_picture( | |||
640 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 640 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
641 | err = drv(file, VIDIOC_G_FMT, fmt); | 641 | err = drv(file, VIDIOC_G_FMT, fmt); |
642 | if (err < 0) { | 642 | if (err < 0) { |
643 | dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err); | 643 | dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %ld\n", err); |
644 | goto done; | 644 | goto done; |
645 | } | 645 | } |
646 | 646 | ||
@@ -654,12 +654,12 @@ done: | |||
654 | return err; | 654 | return err; |
655 | } | 655 | } |
656 | 656 | ||
657 | static noinline int v4l1_compat_set_picture( | 657 | static noinline long v4l1_compat_set_picture( |
658 | struct video_picture *pict, | 658 | struct video_picture *pict, |
659 | struct file *file, | 659 | struct file *file, |
660 | v4l2_kioctl drv) | 660 | v4l2_kioctl drv) |
661 | { | 661 | { |
662 | int err; | 662 | long err; |
663 | struct v4l2_framebuffer fbuf; | 663 | struct v4l2_framebuffer fbuf; |
664 | int mem_err = 0, ovl_err = 0; | 664 | int mem_err = 0, ovl_err = 0; |
665 | struct v4l2_format *fmt; | 665 | struct v4l2_format *fmt; |
@@ -694,7 +694,7 @@ static noinline int v4l1_compat_set_picture( | |||
694 | support memory capture. Trying to set the memory capture | 694 | support memory capture. Trying to set the memory capture |
695 | parameters would be pointless. */ | 695 | parameters would be pointless. */ |
696 | if (err < 0) { | 696 | if (err < 0) { |
697 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n", err); | 697 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %ld\n", err); |
698 | mem_err = -1000; /* didn't even try */ | 698 | mem_err = -1000; /* didn't even try */ |
699 | } else if (fmt->fmt.pix.pixelformat != | 699 | } else if (fmt->fmt.pix.pixelformat != |
700 | palette_to_pixelformat(pict->palette)) { | 700 | palette_to_pixelformat(pict->palette)) { |
@@ -711,7 +711,7 @@ static noinline int v4l1_compat_set_picture( | |||
711 | support overlay. Trying to set the overlay parameters | 711 | support overlay. Trying to set the overlay parameters |
712 | would be quite pointless. */ | 712 | would be quite pointless. */ |
713 | if (err < 0) { | 713 | if (err < 0) { |
714 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n", err); | 714 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %ld\n", err); |
715 | ovl_err = -1000; /* didn't even try */ | 715 | ovl_err = -1000; /* didn't even try */ |
716 | } else if (fbuf.fmt.pixelformat != | 716 | } else if (fbuf.fmt.pixelformat != |
717 | palette_to_pixelformat(pict->palette)) { | 717 | palette_to_pixelformat(pict->palette)) { |
@@ -736,12 +736,13 @@ static noinline int v4l1_compat_set_picture( | |||
736 | return err; | 736 | return err; |
737 | } | 737 | } |
738 | 738 | ||
739 | static noinline int v4l1_compat_get_tuner( | 739 | static noinline long v4l1_compat_get_tuner( |
740 | struct video_tuner *tun, | 740 | struct video_tuner *tun, |
741 | struct file *file, | 741 | struct file *file, |
742 | v4l2_kioctl drv) | 742 | v4l2_kioctl drv) |
743 | { | 743 | { |
744 | int err, i; | 744 | long err; |
745 | int i; | ||
745 | struct v4l2_tuner tun2; | 746 | struct v4l2_tuner tun2; |
746 | struct v4l2_standard std2; | 747 | struct v4l2_standard std2; |
747 | v4l2_std_id sid; | 748 | v4l2_std_id sid; |
@@ -749,7 +750,7 @@ static noinline int v4l1_compat_get_tuner( | |||
749 | memset(&tun2, 0, sizeof(tun2)); | 750 | memset(&tun2, 0, sizeof(tun2)); |
750 | err = drv(file, VIDIOC_G_TUNER, &tun2); | 751 | err = drv(file, VIDIOC_G_TUNER, &tun2); |
751 | if (err < 0) { | 752 | if (err < 0) { |
752 | dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err); | 753 | dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %ld\n", err); |
753 | goto done; | 754 | goto done; |
754 | } | 755 | } |
755 | memcpy(tun->name, tun2.name, | 756 | memcpy(tun->name, tun2.name, |
@@ -775,7 +776,7 @@ static noinline int v4l1_compat_get_tuner( | |||
775 | 776 | ||
776 | err = drv(file, VIDIOC_G_STD, &sid); | 777 | err = drv(file, VIDIOC_G_STD, &sid); |
777 | if (err < 0) | 778 | if (err < 0) |
778 | dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n", err); | 779 | dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %ld\n", err); |
779 | if (err == 0) { | 780 | if (err == 0) { |
780 | if (sid & V4L2_STD_PAL) | 781 | if (sid & V4L2_STD_PAL) |
781 | tun->mode = VIDEO_MODE_PAL; | 782 | tun->mode = VIDEO_MODE_PAL; |
@@ -794,12 +795,12 @@ done: | |||
794 | return err; | 795 | return err; |
795 | } | 796 | } |
796 | 797 | ||
797 | static noinline int v4l1_compat_select_tuner( | 798 | static noinline long v4l1_compat_select_tuner( |
798 | struct video_tuner *tun, | 799 | struct video_tuner *tun, |
799 | struct file *file, | 800 | struct file *file, |
800 | v4l2_kioctl drv) | 801 | v4l2_kioctl drv) |
801 | { | 802 | { |
802 | int err; | 803 | long err; |
803 | struct v4l2_tuner t;/*84 bytes on x86_64*/ | 804 | struct v4l2_tuner t;/*84 bytes on x86_64*/ |
804 | memset(&t, 0, sizeof(t)); | 805 | memset(&t, 0, sizeof(t)); |
805 | 806 | ||
@@ -807,34 +808,34 @@ static noinline int v4l1_compat_select_tuner( | |||
807 | 808 | ||
808 | err = drv(file, VIDIOC_S_INPUT, &t); | 809 | err = drv(file, VIDIOC_S_INPUT, &t); |
809 | if (err < 0) | 810 | if (err < 0) |
810 | dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err); | 811 | dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %ld\n", err); |
811 | return err; | 812 | return err; |
812 | } | 813 | } |
813 | 814 | ||
814 | static noinline int v4l1_compat_get_frequency( | 815 | static noinline long v4l1_compat_get_frequency( |
815 | unsigned long *freq, | 816 | unsigned long *freq, |
816 | struct file *file, | 817 | struct file *file, |
817 | v4l2_kioctl drv) | 818 | v4l2_kioctl drv) |
818 | { | 819 | { |
819 | int err; | 820 | long err; |
820 | struct v4l2_frequency freq2; | 821 | struct v4l2_frequency freq2; |
821 | memset(&freq2, 0, sizeof(freq2)); | 822 | memset(&freq2, 0, sizeof(freq2)); |
822 | 823 | ||
823 | freq2.tuner = 0; | 824 | freq2.tuner = 0; |
824 | err = drv(file, VIDIOC_G_FREQUENCY, &freq2); | 825 | err = drv(file, VIDIOC_G_FREQUENCY, &freq2); |
825 | if (err < 0) | 826 | if (err < 0) |
826 | dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err); | 827 | dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %ld\n", err); |
827 | if (0 == err) | 828 | if (0 == err) |
828 | *freq = freq2.frequency; | 829 | *freq = freq2.frequency; |
829 | return err; | 830 | return err; |
830 | } | 831 | } |
831 | 832 | ||
832 | static noinline int v4l1_compat_set_frequency( | 833 | static noinline long v4l1_compat_set_frequency( |
833 | unsigned long *freq, | 834 | unsigned long *freq, |
834 | struct file *file, | 835 | struct file *file, |
835 | v4l2_kioctl drv) | 836 | v4l2_kioctl drv) |
836 | { | 837 | { |
837 | int err; | 838 | long err; |
838 | struct v4l2_frequency freq2; | 839 | struct v4l2_frequency freq2; |
839 | memset(&freq2, 0, sizeof(freq2)); | 840 | memset(&freq2, 0, sizeof(freq2)); |
840 | 841 | ||
@@ -842,16 +843,17 @@ static noinline int v4l1_compat_set_frequency( | |||
842 | freq2.frequency = *freq; | 843 | freq2.frequency = *freq; |
843 | err = drv(file, VIDIOC_S_FREQUENCY, &freq2); | 844 | err = drv(file, VIDIOC_S_FREQUENCY, &freq2); |
844 | if (err < 0) | 845 | if (err < 0) |
845 | dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err); | 846 | dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %ld\n", err); |
846 | return err; | 847 | return err; |
847 | } | 848 | } |
848 | 849 | ||
849 | static noinline int v4l1_compat_get_audio( | 850 | static noinline long v4l1_compat_get_audio( |
850 | struct video_audio *aud, | 851 | struct video_audio *aud, |
851 | struct file *file, | 852 | struct file *file, |
852 | v4l2_kioctl drv) | 853 | v4l2_kioctl drv) |
853 | { | 854 | { |
854 | int err, i; | 855 | long err; |
856 | int i; | ||
855 | struct v4l2_queryctrl qctrl2; | 857 | struct v4l2_queryctrl qctrl2; |
856 | struct v4l2_audio aud2; | 858 | struct v4l2_audio aud2; |
857 | struct v4l2_tuner tun2; | 859 | struct v4l2_tuner tun2; |
@@ -859,7 +861,7 @@ static noinline int v4l1_compat_get_audio( | |||
859 | 861 | ||
860 | err = drv(file, VIDIOC_G_AUDIO, &aud2); | 862 | err = drv(file, VIDIOC_G_AUDIO, &aud2); |
861 | if (err < 0) { | 863 | if (err < 0) { |
862 | dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err); | 864 | dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %ld\n", err); |
863 | goto done; | 865 | goto done; |
864 | } | 866 | } |
865 | memcpy(aud->name, aud2.name, | 867 | memcpy(aud->name, aud2.name, |
@@ -903,7 +905,7 @@ static noinline int v4l1_compat_get_audio( | |||
903 | memset(&tun2, 0, sizeof(tun2)); | 905 | memset(&tun2, 0, sizeof(tun2)); |
904 | err = drv(file, VIDIOC_G_TUNER, &tun2); | 906 | err = drv(file, VIDIOC_G_TUNER, &tun2); |
905 | if (err < 0) { | 907 | if (err < 0) { |
906 | dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err); | 908 | dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %ld\n", err); |
907 | err = 0; | 909 | err = 0; |
908 | goto done; | 910 | goto done; |
909 | } | 911 | } |
@@ -918,12 +920,12 @@ done: | |||
918 | return err; | 920 | return err; |
919 | } | 921 | } |
920 | 922 | ||
921 | static noinline int v4l1_compat_set_audio( | 923 | static noinline long v4l1_compat_set_audio( |
922 | struct video_audio *aud, | 924 | struct video_audio *aud, |
923 | struct file *file, | 925 | struct file *file, |
924 | v4l2_kioctl drv) | 926 | v4l2_kioctl drv) |
925 | { | 927 | { |
926 | int err; | 928 | long err; |
927 | struct v4l2_audio aud2; | 929 | struct v4l2_audio aud2; |
928 | struct v4l2_tuner tun2; | 930 | struct v4l2_tuner tun2; |
929 | 931 | ||
@@ -933,7 +935,7 @@ static noinline int v4l1_compat_set_audio( | |||
933 | aud2.index = aud->audio; | 935 | aud2.index = aud->audio; |
934 | err = drv(file, VIDIOC_S_AUDIO, &aud2); | 936 | err = drv(file, VIDIOC_S_AUDIO, &aud2); |
935 | if (err < 0) { | 937 | if (err < 0) { |
936 | dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err); | 938 | dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %ld\n", err); |
937 | goto done; | 939 | goto done; |
938 | } | 940 | } |
939 | 941 | ||
@@ -950,7 +952,7 @@ static noinline int v4l1_compat_set_audio( | |||
950 | 952 | ||
951 | err = drv(file, VIDIOC_G_TUNER, &tun2); | 953 | err = drv(file, VIDIOC_G_TUNER, &tun2); |
952 | if (err < 0) | 954 | if (err < 0) |
953 | dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n", err); | 955 | dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %ld\n", err); |
954 | if (err == 0) { | 956 | if (err == 0) { |
955 | switch (aud->mode) { | 957 | switch (aud->mode) { |
956 | default: | 958 | default: |
@@ -967,19 +969,19 @@ static noinline int v4l1_compat_set_audio( | |||
967 | } | 969 | } |
968 | err = drv(file, VIDIOC_S_TUNER, &tun2); | 970 | err = drv(file, VIDIOC_S_TUNER, &tun2); |
969 | if (err < 0) | 971 | if (err < 0) |
970 | dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err); | 972 | dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %ld\n", err); |
971 | } | 973 | } |
972 | err = 0; | 974 | err = 0; |
973 | done: | 975 | done: |
974 | return err; | 976 | return err; |
975 | } | 977 | } |
976 | 978 | ||
977 | static noinline int v4l1_compat_capture_frame( | 979 | static noinline long v4l1_compat_capture_frame( |
978 | struct video_mmap *mm, | 980 | struct video_mmap *mm, |
979 | struct file *file, | 981 | struct file *file, |
980 | v4l2_kioctl drv) | 982 | v4l2_kioctl drv) |
981 | { | 983 | { |
982 | int err; | 984 | long err; |
983 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 985 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
984 | struct v4l2_buffer buf; | 986 | struct v4l2_buffer buf; |
985 | struct v4l2_format *fmt; | 987 | struct v4l2_format *fmt; |
@@ -994,7 +996,7 @@ static noinline int v4l1_compat_capture_frame( | |||
994 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 996 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
995 | err = drv(file, VIDIOC_G_FMT, fmt); | 997 | err = drv(file, VIDIOC_G_FMT, fmt); |
996 | if (err < 0) { | 998 | if (err < 0) { |
997 | dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err); | 999 | dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %ld\n", err); |
998 | goto done; | 1000 | goto done; |
999 | } | 1001 | } |
1000 | if (mm->width != fmt->fmt.pix.width || | 1002 | if (mm->width != fmt->fmt.pix.width || |
@@ -1010,7 +1012,7 @@ static noinline int v4l1_compat_capture_frame( | |||
1010 | fmt->fmt.pix.bytesperline = 0; | 1012 | fmt->fmt.pix.bytesperline = 0; |
1011 | err = drv(file, VIDIOC_S_FMT, fmt); | 1013 | err = drv(file, VIDIOC_S_FMT, fmt); |
1012 | if (err < 0) { | 1014 | if (err < 0) { |
1013 | dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err); | 1015 | dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %ld\n", err); |
1014 | goto done; | 1016 | goto done; |
1015 | } | 1017 | } |
1016 | } | 1018 | } |
@@ -1018,28 +1020,28 @@ static noinline int v4l1_compat_capture_frame( | |||
1018 | buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1020 | buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1019 | err = drv(file, VIDIOC_QUERYBUF, &buf); | 1021 | err = drv(file, VIDIOC_QUERYBUF, &buf); |
1020 | if (err < 0) { | 1022 | if (err < 0) { |
1021 | dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err); | 1023 | dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %ld\n", err); |
1022 | goto done; | 1024 | goto done; |
1023 | } | 1025 | } |
1024 | err = drv(file, VIDIOC_QBUF, &buf); | 1026 | err = drv(file, VIDIOC_QBUF, &buf); |
1025 | if (err < 0) { | 1027 | if (err < 0) { |
1026 | dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err); | 1028 | dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %ld\n", err); |
1027 | goto done; | 1029 | goto done; |
1028 | } | 1030 | } |
1029 | err = drv(file, VIDIOC_STREAMON, &captype); | 1031 | err = drv(file, VIDIOC_STREAMON, &captype); |
1030 | if (err < 0) | 1032 | if (err < 0) |
1031 | dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err); | 1033 | dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %ld\n", err); |
1032 | done: | 1034 | done: |
1033 | kfree(fmt); | 1035 | kfree(fmt); |
1034 | return err; | 1036 | return err; |
1035 | } | 1037 | } |
1036 | 1038 | ||
1037 | static noinline int v4l1_compat_sync( | 1039 | static noinline long v4l1_compat_sync( |
1038 | int *i, | 1040 | int *i, |
1039 | struct file *file, | 1041 | struct file *file, |
1040 | v4l2_kioctl drv) | 1042 | v4l2_kioctl drv) |
1041 | { | 1043 | { |
1042 | int err; | 1044 | long err; |
1043 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1045 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1044 | struct v4l2_buffer buf; | 1046 | struct v4l2_buffer buf; |
1045 | struct poll_wqueues *pwq; | 1047 | struct poll_wqueues *pwq; |
@@ -1050,7 +1052,7 @@ static noinline int v4l1_compat_sync( | |||
1050 | err = drv(file, VIDIOC_QUERYBUF, &buf); | 1052 | err = drv(file, VIDIOC_QUERYBUF, &buf); |
1051 | if (err < 0) { | 1053 | if (err < 0) { |
1052 | /* No such buffer */ | 1054 | /* No such buffer */ |
1053 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); | 1055 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err); |
1054 | goto done; | 1056 | goto done; |
1055 | } | 1057 | } |
1056 | if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) { | 1058 | if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) { |
@@ -1062,7 +1064,7 @@ static noinline int v4l1_compat_sync( | |||
1062 | /* make sure capture actually runs so we don't block forever */ | 1064 | /* make sure capture actually runs so we don't block forever */ |
1063 | err = drv(file, VIDIOC_STREAMON, &captype); | 1065 | err = drv(file, VIDIOC_STREAMON, &captype); |
1064 | if (err < 0) { | 1066 | if (err < 0) { |
1065 | dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err); | 1067 | dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %ld\n", err); |
1066 | goto done; | 1068 | goto done; |
1067 | } | 1069 | } |
1068 | 1070 | ||
@@ -1076,7 +1078,7 @@ static noinline int v4l1_compat_sync( | |||
1076 | break; | 1078 | break; |
1077 | err = drv(file, VIDIOC_QUERYBUF, &buf); | 1079 | err = drv(file, VIDIOC_QUERYBUF, &buf); |
1078 | if (err < 0) | 1080 | if (err < 0) |
1079 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); | 1081 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err); |
1080 | } | 1082 | } |
1081 | kfree(pwq); | 1083 | kfree(pwq); |
1082 | if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ | 1084 | if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ |
@@ -1084,18 +1086,18 @@ static noinline int v4l1_compat_sync( | |||
1084 | do { | 1086 | do { |
1085 | err = drv(file, VIDIOC_DQBUF, &buf); | 1087 | err = drv(file, VIDIOC_DQBUF, &buf); |
1086 | if (err < 0) | 1088 | if (err < 0) |
1087 | dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err); | 1089 | dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %ld\n", err); |
1088 | } while (err == 0 && buf.index != *i); | 1090 | } while (err == 0 && buf.index != *i); |
1089 | done: | 1091 | done: |
1090 | return err; | 1092 | return err; |
1091 | } | 1093 | } |
1092 | 1094 | ||
1093 | static noinline int v4l1_compat_get_vbi_format( | 1095 | static noinline long v4l1_compat_get_vbi_format( |
1094 | struct vbi_format *fmt, | 1096 | struct vbi_format *fmt, |
1095 | struct file *file, | 1097 | struct file *file, |
1096 | v4l2_kioctl drv) | 1098 | v4l2_kioctl drv) |
1097 | { | 1099 | { |
1098 | int err; | 1100 | long err; |
1099 | struct v4l2_format *fmt2; | 1101 | struct v4l2_format *fmt2; |
1100 | 1102 | ||
1101 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 1103 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); |
@@ -1107,7 +1109,7 @@ static noinline int v4l1_compat_get_vbi_format( | |||
1107 | 1109 | ||
1108 | err = drv(file, VIDIOC_G_FMT, fmt2); | 1110 | err = drv(file, VIDIOC_G_FMT, fmt2); |
1109 | if (err < 0) { | 1111 | if (err < 0) { |
1110 | dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); | 1112 | dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %ld\n", err); |
1111 | goto done; | 1113 | goto done; |
1112 | } | 1114 | } |
1113 | if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { | 1115 | if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { |
@@ -1128,12 +1130,12 @@ done: | |||
1128 | return err; | 1130 | return err; |
1129 | } | 1131 | } |
1130 | 1132 | ||
1131 | static noinline int v4l1_compat_set_vbi_format( | 1133 | static noinline long v4l1_compat_set_vbi_format( |
1132 | struct vbi_format *fmt, | 1134 | struct vbi_format *fmt, |
1133 | struct file *file, | 1135 | struct file *file, |
1134 | v4l2_kioctl drv) | 1136 | v4l2_kioctl drv) |
1135 | { | 1137 | { |
1136 | int err; | 1138 | long err; |
1137 | struct v4l2_format *fmt2 = NULL; | 1139 | struct v4l2_format *fmt2 = NULL; |
1138 | 1140 | ||
1139 | if (VIDEO_PALETTE_RAW != fmt->sample_format) { | 1141 | if (VIDEO_PALETTE_RAW != fmt->sample_format) { |
@@ -1157,7 +1159,7 @@ static noinline int v4l1_compat_set_vbi_format( | |||
1157 | fmt2->fmt.vbi.flags = fmt->flags; | 1159 | fmt2->fmt.vbi.flags = fmt->flags; |
1158 | err = drv(file, VIDIOC_TRY_FMT, fmt2); | 1160 | err = drv(file, VIDIOC_TRY_FMT, fmt2); |
1159 | if (err < 0) { | 1161 | if (err < 0) { |
1160 | dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); | 1162 | dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %ld\n", err); |
1161 | goto done; | 1163 | goto done; |
1162 | } | 1164 | } |
1163 | 1165 | ||
@@ -1174,7 +1176,7 @@ static noinline int v4l1_compat_set_vbi_format( | |||
1174 | } | 1176 | } |
1175 | err = drv(file, VIDIOC_S_FMT, fmt2); | 1177 | err = drv(file, VIDIOC_S_FMT, fmt2); |
1176 | if (err < 0) | 1178 | if (err < 0) |
1177 | dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); | 1179 | dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %ld\n", err); |
1178 | done: | 1180 | done: |
1179 | kfree(fmt2); | 1181 | kfree(fmt2); |
1180 | return err; | 1182 | return err; |
@@ -1183,13 +1185,13 @@ done: | |||
1183 | /* | 1185 | /* |
1184 | * This function is exported. | 1186 | * This function is exported. |
1185 | */ | 1187 | */ |
1186 | int | 1188 | long |
1187 | v4l_compat_translate_ioctl(struct file *file, | 1189 | v4l_compat_translate_ioctl(struct file *file, |
1188 | int cmd, | 1190 | int cmd, |
1189 | void *arg, | 1191 | void *arg, |
1190 | v4l2_kioctl drv) | 1192 | v4l2_kioctl drv) |
1191 | { | 1193 | { |
1192 | int err; | 1194 | long err; |
1193 | 1195 | ||
1194 | switch (cmd) { | 1196 | switch (cmd) { |
1195 | case VIDIOCGCAP: /* capability */ | 1197 | case VIDIOCGCAP: /* capability */ |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index c676b0b0f708..b8f2be8d5c0e 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -797,11 +797,11 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) | |||
797 | } | 797 | } |
798 | EXPORT_SYMBOL(v4l2_ctrl_next); | 798 | EXPORT_SYMBOL(v4l2_ctrl_next); |
799 | 799 | ||
800 | int v4l2_chip_match_host(u32 match_type, u32 match_chip) | 800 | int v4l2_chip_match_host(const struct v4l2_dbg_match *match) |
801 | { | 801 | { |
802 | switch (match_type) { | 802 | switch (match->type) { |
803 | case V4L2_CHIP_MATCH_HOST: | 803 | case V4L2_CHIP_MATCH_HOST: |
804 | return match_chip == 0; | 804 | return match->addr == 0; |
805 | default: | 805 | default: |
806 | return 0; | 806 | return 0; |
807 | } | 807 | } |
@@ -809,23 +809,34 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip) | |||
809 | EXPORT_SYMBOL(v4l2_chip_match_host); | 809 | EXPORT_SYMBOL(v4l2_chip_match_host); |
810 | 810 | ||
811 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | 811 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) |
812 | int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) | 812 | int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match) |
813 | { | 813 | { |
814 | switch (match_type) { | 814 | int len; |
815 | |||
816 | if (c == NULL || match == NULL) | ||
817 | return 0; | ||
818 | |||
819 | switch (match->type) { | ||
815 | case V4L2_CHIP_MATCH_I2C_DRIVER: | 820 | case V4L2_CHIP_MATCH_I2C_DRIVER: |
816 | return (c != NULL && c->driver != NULL && c->driver->id == match_chip); | 821 | if (c->driver == NULL || c->driver->driver.name == NULL) |
822 | return 0; | ||
823 | len = strlen(c->driver->driver.name); | ||
824 | /* legacy drivers have a ' suffix, don't try to match that */ | ||
825 | if (len && c->driver->driver.name[len - 1] == '\'') | ||
826 | len--; | ||
827 | return len && !strncmp(c->driver->driver.name, match->name, len); | ||
817 | case V4L2_CHIP_MATCH_I2C_ADDR: | 828 | case V4L2_CHIP_MATCH_I2C_ADDR: |
818 | return (c != NULL && c->addr == match_chip); | 829 | return c->addr == match->addr; |
819 | default: | 830 | default: |
820 | return 0; | 831 | return 0; |
821 | } | 832 | } |
822 | } | 833 | } |
823 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); | 834 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); |
824 | 835 | ||
825 | int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, | 836 | int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip, |
826 | u32 ident, u32 revision) | 837 | u32 ident, u32 revision) |
827 | { | 838 | { |
828 | if (!v4l2_chip_match_i2c_client(c, chip->match_type, chip->match_chip)) | 839 | if (!v4l2_chip_match_i2c_client(c, &chip->match)) |
829 | return 0; | 840 | return 0; |
830 | if (chip->ident == V4L2_IDENT_NONE) { | 841 | if (chip->ident == V4L2_IDENT_NONE) { |
831 | chip->ident = ident; | 842 | chip->ident = ident; |
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index d0e1bd3ace6a..110376be5d2b 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c | |||
@@ -222,9 +222,9 @@ static int get_microcode32(struct video_code *kp, struct video_code32 __user *up | |||
222 | 222 | ||
223 | #endif | 223 | #endif |
224 | 224 | ||
225 | static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 225 | static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
226 | { | 226 | { |
227 | int ret = -ENOIOCTLCMD; | 227 | long ret = -ENOIOCTLCMD; |
228 | 228 | ||
229 | if (file->f_op->unlocked_ioctl) | 229 | if (file->f_op->unlocked_ioctl) |
230 | ret = file->f_op->unlocked_ioctl(file, cmd, arg); | 230 | ret = file->f_op->unlocked_ioctl(file, cmd, arg); |
@@ -705,7 +705,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext | |||
705 | #define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32) | 705 | #define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32) |
706 | #define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32) | 706 | #define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32) |
707 | 707 | ||
708 | static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 708 | static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
709 | { | 709 | { |
710 | union { | 710 | union { |
711 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 711 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
@@ -726,7 +726,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
726 | } karg; | 726 | } karg; |
727 | void __user *up = compat_ptr(arg); | 727 | void __user *up = compat_ptr(arg); |
728 | int compatible_arg = 1; | 728 | int compatible_arg = 1; |
729 | int err = 0; | 729 | long err = 0; |
730 | 730 | ||
731 | /* First, convert the command. */ | 731 | /* First, convert the command. */ |
732 | switch (cmd) { | 732 | switch (cmd) { |
@@ -937,9 +937,9 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
937 | return err; | 937 | return err; |
938 | } | 938 | } |
939 | 939 | ||
940 | long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | 940 | long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) |
941 | { | 941 | { |
942 | int ret = -ENOIOCTLCMD; | 942 | long ret = -ENOIOCTLCMD; |
943 | 943 | ||
944 | if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl) | 944 | if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl) |
945 | return ret; | 945 | return ret; |
@@ -1046,7 +1046,8 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | |||
1046 | case VIDIOC_TRY_ENCODER_CMD: | 1046 | case VIDIOC_TRY_ENCODER_CMD: |
1047 | case VIDIOC_DBG_S_REGISTER: | 1047 | case VIDIOC_DBG_S_REGISTER: |
1048 | case VIDIOC_DBG_G_REGISTER: | 1048 | case VIDIOC_DBG_G_REGISTER: |
1049 | case VIDIOC_G_CHIP_IDENT: | 1049 | case VIDIOC_DBG_G_CHIP_IDENT: |
1050 | case VIDIOC_G_CHIP_IDENT_OLD: | ||
1050 | case VIDIOC_S_HW_FREQ_SEEK: | 1051 | case VIDIOC_S_HW_FREQ_SEEK: |
1051 | ret = do_video_ioctl(file, cmd, arg); | 1052 | ret = do_video_ioctl(file, cmd, arg); |
1052 | break; | 1053 | break; |
@@ -1065,18 +1066,14 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | |||
1065 | break; | 1066 | break; |
1066 | #endif | 1067 | #endif |
1067 | default: | 1068 | default: |
1068 | v4l_print_ioctl("compat_ioctl32", cmd); | 1069 | printk(KERN_WARNING "compat_ioctl32: " |
1069 | printk(KERN_CONT "\n"); | 1070 | "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n", |
1071 | _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd); | ||
1070 | break; | 1072 | break; |
1071 | } | 1073 | } |
1072 | return ret; | 1074 | return ret; |
1073 | } | 1075 | } |
1074 | #else | 1076 | EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32); |
1075 | long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | ||
1076 | { | ||
1077 | return -ENOIOCTLCMD; | ||
1078 | } | ||
1079 | #endif | 1077 | #endif |
1080 | EXPORT_SYMBOL_GPL(v4l_compat_ioctl32); | ||
1081 | 1078 | ||
1082 | MODULE_LICENSE("GPL"); | 1079 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 7ad6711ee327..13f87c22e78d 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <media/v4l2-common.h> | 32 | #include <media/v4l2-common.h> |
33 | #include <media/v4l2-device.h> | 33 | #include <media/v4l2-device.h> |
34 | #include <media/v4l2-ioctl.h> | ||
34 | 35 | ||
35 | #define VIDEO_NUM_DEVICES 256 | 36 | #define VIDEO_NUM_DEVICES 256 |
36 | #define VIDEO_NAME "video4linux" | 37 | #define VIDEO_NAME "video4linux" |
@@ -182,7 +183,7 @@ static int v4l2_ioctl(struct inode *inode, struct file *filp, | |||
182 | return -ENOTTY; | 183 | return -ENOTTY; |
183 | /* Allow ioctl to continue even if the device was unregistered. | 184 | /* Allow ioctl to continue even if the device was unregistered. |
184 | Things like dequeueing buffers might still be useful. */ | 185 | Things like dequeueing buffers might still be useful. */ |
185 | return vdev->fops->ioctl(inode, filp, cmd, arg); | 186 | return vdev->fops->ioctl(filp, cmd, arg); |
186 | } | 187 | } |
187 | 188 | ||
188 | static long v4l2_unlocked_ioctl(struct file *filp, | 189 | static long v4l2_unlocked_ioctl(struct file *filp, |
@@ -197,20 +198,6 @@ static long v4l2_unlocked_ioctl(struct file *filp, | |||
197 | return vdev->fops->unlocked_ioctl(filp, cmd, arg); | 198 | return vdev->fops->unlocked_ioctl(filp, cmd, arg); |
198 | } | 199 | } |
199 | 200 | ||
200 | #ifdef CONFIG_COMPAT | ||
201 | static long v4l2_compat_ioctl(struct file *filp, | ||
202 | unsigned int cmd, unsigned long arg) | ||
203 | { | ||
204 | struct video_device *vdev = video_devdata(filp); | ||
205 | |||
206 | if (!vdev->fops->compat_ioctl) | ||
207 | return -ENOIOCTLCMD; | ||
208 | /* Allow ioctl to continue even if the device was unregistered. | ||
209 | Things like dequeueing buffers might still be useful. */ | ||
210 | return vdev->fops->compat_ioctl(filp, cmd, arg); | ||
211 | } | ||
212 | #endif | ||
213 | |||
214 | static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) | 201 | static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) |
215 | { | 202 | { |
216 | struct video_device *vdev = video_devdata(filp); | 203 | struct video_device *vdev = video_devdata(filp); |
@@ -239,7 +226,7 @@ static int v4l2_open(struct inode *inode, struct file *filp) | |||
239 | /* and increase the device refcount */ | 226 | /* and increase the device refcount */ |
240 | video_get(vdev); | 227 | video_get(vdev); |
241 | mutex_unlock(&videodev_lock); | 228 | mutex_unlock(&videodev_lock); |
242 | ret = vdev->fops->open(inode, filp); | 229 | ret = vdev->fops->open(filp); |
243 | /* decrease the refcount in case of an error */ | 230 | /* decrease the refcount in case of an error */ |
244 | if (ret) | 231 | if (ret) |
245 | video_put(vdev); | 232 | video_put(vdev); |
@@ -250,7 +237,7 @@ static int v4l2_open(struct inode *inode, struct file *filp) | |||
250 | static int v4l2_release(struct inode *inode, struct file *filp) | 237 | static int v4l2_release(struct inode *inode, struct file *filp) |
251 | { | 238 | { |
252 | struct video_device *vdev = video_devdata(filp); | 239 | struct video_device *vdev = video_devdata(filp); |
253 | int ret = vdev->fops->release(inode, filp); | 240 | int ret = vdev->fops->release(filp); |
254 | 241 | ||
255 | /* decrease the refcount unconditionally since the release() | 242 | /* decrease the refcount unconditionally since the release() |
256 | return value is ignored. */ | 243 | return value is ignored. */ |
@@ -266,7 +253,7 @@ static const struct file_operations v4l2_unlocked_fops = { | |||
266 | .mmap = v4l2_mmap, | 253 | .mmap = v4l2_mmap, |
267 | .unlocked_ioctl = v4l2_unlocked_ioctl, | 254 | .unlocked_ioctl = v4l2_unlocked_ioctl, |
268 | #ifdef CONFIG_COMPAT | 255 | #ifdef CONFIG_COMPAT |
269 | .compat_ioctl = v4l2_compat_ioctl, | 256 | .compat_ioctl = v4l2_compat_ioctl32, |
270 | #endif | 257 | #endif |
271 | .release = v4l2_release, | 258 | .release = v4l2_release, |
272 | .poll = v4l2_poll, | 259 | .poll = v4l2_poll, |
@@ -281,7 +268,7 @@ static const struct file_operations v4l2_fops = { | |||
281 | .mmap = v4l2_mmap, | 268 | .mmap = v4l2_mmap, |
282 | .ioctl = v4l2_ioctl, | 269 | .ioctl = v4l2_ioctl, |
283 | #ifdef CONFIG_COMPAT | 270 | #ifdef CONFIG_COMPAT |
284 | .compat_ioctl = v4l2_compat_ioctl, | 271 | .compat_ioctl = v4l2_compat_ioctl32, |
285 | #endif | 272 | #endif |
286 | .release = v4l2_release, | 273 | .release = v4l2_release, |
287 | .poll = v4l2_poll, | 274 | .poll = v4l2_poll, |
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index b063381f4b3b..52d687b165e0 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -266,7 +266,7 @@ static const char *v4l2_ioctls[] = { | |||
266 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", | 266 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", |
267 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", | 267 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", |
268 | 268 | ||
269 | [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT", | 269 | [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT", |
270 | [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK", | 270 | [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK", |
271 | #endif | 271 | #endif |
272 | }; | 272 | }; |
@@ -392,14 +392,14 @@ video_fix_command(unsigned int cmd) | |||
392 | /* | 392 | /* |
393 | * Obsolete usercopy function - Should be removed soon | 393 | * Obsolete usercopy function - Should be removed soon |
394 | */ | 394 | */ |
395 | int | 395 | long |
396 | video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, | 396 | video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, |
397 | v4l2_kioctl func) | 397 | v4l2_kioctl func) |
398 | { | 398 | { |
399 | char sbuf[128]; | 399 | char sbuf[128]; |
400 | void *mbuf = NULL; | 400 | void *mbuf = NULL; |
401 | void *parg = NULL; | 401 | void *parg = NULL; |
402 | int err = -EINVAL; | 402 | long err = -EINVAL; |
403 | int is_ext_ctrl; | 403 | int is_ext_ctrl; |
404 | size_t ctrls_size = 0; | 404 | size_t ctrls_size = 0; |
405 | void __user *user_ptr = NULL; | 405 | void __user *user_ptr = NULL; |
@@ -623,13 +623,13 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type) | |||
623 | return -EINVAL; | 623 | return -EINVAL; |
624 | } | 624 | } |
625 | 625 | ||
626 | static int __video_do_ioctl(struct file *file, | 626 | static long __video_do_ioctl(struct file *file, |
627 | unsigned int cmd, void *arg) | 627 | unsigned int cmd, void *arg) |
628 | { | 628 | { |
629 | struct video_device *vfd = video_devdata(file); | 629 | struct video_device *vfd = video_devdata(file); |
630 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | 630 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; |
631 | void *fh = file->private_data; | 631 | void *fh = file->private_data; |
632 | int ret = -EINVAL; | 632 | long ret = -EINVAL; |
633 | 633 | ||
634 | if ((vfd->debug & V4L2_DEBUG_IOCTL) && | 634 | if ((vfd->debug & V4L2_DEBUG_IOCTL) && |
635 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { | 635 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { |
@@ -1720,7 +1720,7 @@ static int __video_do_ioctl(struct file *file, | |||
1720 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1720 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1721 | case VIDIOC_DBG_G_REGISTER: | 1721 | case VIDIOC_DBG_G_REGISTER: |
1722 | { | 1722 | { |
1723 | struct v4l2_register *p = arg; | 1723 | struct v4l2_dbg_register *p = arg; |
1724 | 1724 | ||
1725 | if (!capable(CAP_SYS_ADMIN)) | 1725 | if (!capable(CAP_SYS_ADMIN)) |
1726 | ret = -EPERM; | 1726 | ret = -EPERM; |
@@ -1730,7 +1730,7 @@ static int __video_do_ioctl(struct file *file, | |||
1730 | } | 1730 | } |
1731 | case VIDIOC_DBG_S_REGISTER: | 1731 | case VIDIOC_DBG_S_REGISTER: |
1732 | { | 1732 | { |
1733 | struct v4l2_register *p = arg; | 1733 | struct v4l2_dbg_register *p = arg; |
1734 | 1734 | ||
1735 | if (!capable(CAP_SYS_ADMIN)) | 1735 | if (!capable(CAP_SYS_ADMIN)) |
1736 | ret = -EPERM; | 1736 | ret = -EPERM; |
@@ -1739,9 +1739,9 @@ static int __video_do_ioctl(struct file *file, | |||
1739 | break; | 1739 | break; |
1740 | } | 1740 | } |
1741 | #endif | 1741 | #endif |
1742 | case VIDIOC_G_CHIP_IDENT: | 1742 | case VIDIOC_DBG_G_CHIP_IDENT: |
1743 | { | 1743 | { |
1744 | struct v4l2_chip_ident *p = arg; | 1744 | struct v4l2_dbg_chip_ident *p = arg; |
1745 | 1745 | ||
1746 | if (!ops->vidioc_g_chip_ident) | 1746 | if (!ops->vidioc_g_chip_ident) |
1747 | break; | 1747 | break; |
@@ -1750,6 +1750,11 @@ static int __video_do_ioctl(struct file *file, | |||
1750 | dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); | 1750 | dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); |
1751 | break; | 1751 | break; |
1752 | } | 1752 | } |
1753 | case VIDIOC_G_CHIP_IDENT_OLD: | ||
1754 | printk(KERN_ERR "VIDIOC_G_CHIP_IDENT has been deprecated and will disappear in 2.6.30.\n"); | ||
1755 | printk(KERN_ERR "It is a debugging ioctl and must not be used in applications!\n"); | ||
1756 | return -EINVAL; | ||
1757 | |||
1753 | case VIDIOC_S_HW_FREQ_SEEK: | 1758 | case VIDIOC_S_HW_FREQ_SEEK: |
1754 | { | 1759 | { |
1755 | struct v4l2_hw_freq_seek *p = arg; | 1760 | struct v4l2_hw_freq_seek *p = arg; |
@@ -1845,20 +1850,20 @@ static int __video_do_ioctl(struct file *file, | |||
1845 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | 1850 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { |
1846 | if (ret < 0) { | 1851 | if (ret < 0) { |
1847 | v4l_print_ioctl(vfd->name, cmd); | 1852 | v4l_print_ioctl(vfd->name, cmd); |
1848 | printk(KERN_CONT " error %d\n", ret); | 1853 | printk(KERN_CONT " error %ld\n", ret); |
1849 | } | 1854 | } |
1850 | } | 1855 | } |
1851 | 1856 | ||
1852 | return ret; | 1857 | return ret; |
1853 | } | 1858 | } |
1854 | 1859 | ||
1855 | long __video_ioctl2(struct file *file, | 1860 | long video_ioctl2(struct file *file, |
1856 | unsigned int cmd, unsigned long arg) | 1861 | unsigned int cmd, unsigned long arg) |
1857 | { | 1862 | { |
1858 | char sbuf[128]; | 1863 | char sbuf[128]; |
1859 | void *mbuf = NULL; | 1864 | void *mbuf = NULL; |
1860 | void *parg = NULL; | 1865 | void *parg = NULL; |
1861 | int err = -EINVAL; | 1866 | long err = -EINVAL; |
1862 | int is_ext_ctrl; | 1867 | int is_ext_ctrl; |
1863 | size_t ctrls_size = 0; | 1868 | size_t ctrls_size = 0; |
1864 | void __user *user_ptr = NULL; | 1869 | void __user *user_ptr = NULL; |
@@ -1944,11 +1949,4 @@ out: | |||
1944 | kfree(mbuf); | 1949 | kfree(mbuf); |
1945 | return err; | 1950 | return err; |
1946 | } | 1951 | } |
1947 | EXPORT_SYMBOL(__video_ioctl2); | ||
1948 | |||
1949 | int video_ioctl2(struct inode *inode, struct file *file, | ||
1950 | unsigned int cmd, unsigned long arg) | ||
1951 | { | ||
1952 | return __video_ioctl2(file, cmd, arg); | ||
1953 | } | ||
1954 | EXPORT_SYMBOL(video_ioctl2); | 1952 | EXPORT_SYMBOL(video_ioctl2); |
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index e3612f29d0df..fbe9cc0d433a 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c | |||
@@ -37,7 +37,7 @@ int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg) | |||
37 | return v4l2_subdev_call(sd, core, queryctrl, arg); | 37 | return v4l2_subdev_call(sd, core, queryctrl, arg); |
38 | case VIDIOC_LOG_STATUS: | 38 | case VIDIOC_LOG_STATUS: |
39 | return v4l2_subdev_call(sd, core, log_status); | 39 | return v4l2_subdev_call(sd, core, log_status); |
40 | case VIDIOC_G_CHIP_IDENT: | 40 | case VIDIOC_DBG_G_CHIP_IDENT: |
41 | return v4l2_subdev_call(sd, core, g_chip_ident, arg); | 41 | return v4l2_subdev_call(sd, core, g_chip_ident, arg); |
42 | case VIDIOC_INT_S_STANDBY: | 42 | case VIDIOC_INT_S_STANDBY: |
43 | return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0); | 43 | return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0); |
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index a72a361daade..88bf845a3d56 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -4019,7 +4019,7 @@ out: | |||
4019 | 4019 | ||
4020 | /* File operations */ | 4020 | /* File operations */ |
4021 | 4021 | ||
4022 | static int vino_open(struct inode *inode, struct file *file) | 4022 | static int vino_open(struct file *file) |
4023 | { | 4023 | { |
4024 | struct vino_channel_settings *vcs = video_drvdata(file); | 4024 | struct vino_channel_settings *vcs = video_drvdata(file); |
4025 | int ret = 0; | 4025 | int ret = 0; |
@@ -4050,7 +4050,7 @@ static int vino_open(struct inode *inode, struct file *file) | |||
4050 | return ret; | 4050 | return ret; |
4051 | } | 4051 | } |
4052 | 4052 | ||
4053 | static int vino_close(struct inode *inode, struct file *file) | 4053 | static int vino_close(struct file *file) |
4054 | { | 4054 | { |
4055 | struct vino_channel_settings *vcs = video_drvdata(file); | 4055 | struct vino_channel_settings *vcs = video_drvdata(file); |
4056 | dprintk("close():\n"); | 4056 | dprintk("close():\n"); |
@@ -4237,7 +4237,7 @@ error: | |||
4237 | return ret; | 4237 | return ret; |
4238 | } | 4238 | } |
4239 | 4239 | ||
4240 | static int vino_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 4240 | static long vino_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
4241 | { | 4241 | { |
4242 | struct vino_channel_settings *vcs = video_drvdata(file); | 4242 | struct vino_channel_settings *vcs = video_drvdata(file); |
4243 | 4243 | ||
@@ -4343,11 +4343,11 @@ static int vino_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
4343 | return 0; | 4343 | return 0; |
4344 | } | 4344 | } |
4345 | 4345 | ||
4346 | static int vino_ioctl(struct inode *inode, struct file *file, | 4346 | static long vino_ioctl(struct file *file, |
4347 | unsigned int cmd, unsigned long arg) | 4347 | unsigned int cmd, unsigned long arg) |
4348 | { | 4348 | { |
4349 | struct vino_channel_settings *vcs = video_drvdata(file); | 4349 | struct vino_channel_settings *vcs = video_drvdata(file); |
4350 | int ret; | 4350 | long ret; |
4351 | 4351 | ||
4352 | if (mutex_lock_interruptible(&vcs->mutex)) | 4352 | if (mutex_lock_interruptible(&vcs->mutex)) |
4353 | return -EINTR; | 4353 | return -EINTR; |
@@ -4364,14 +4364,13 @@ static int vino_ioctl(struct inode *inode, struct file *file, | |||
4364 | /* __initdata */ | 4364 | /* __initdata */ |
4365 | static int vino_init_stage; | 4365 | static int vino_init_stage; |
4366 | 4366 | ||
4367 | static const struct file_operations vino_fops = { | 4367 | static const struct v4l2_file_operations vino_fops = { |
4368 | .owner = THIS_MODULE, | 4368 | .owner = THIS_MODULE, |
4369 | .open = vino_open, | 4369 | .open = vino_open, |
4370 | .release = vino_close, | 4370 | .release = vino_close, |
4371 | .ioctl = vino_ioctl, | 4371 | .ioctl = vino_ioctl, |
4372 | .mmap = vino_mmap, | 4372 | .mmap = vino_mmap, |
4373 | .poll = vino_poll, | 4373 | .poll = vino_poll, |
4374 | .llseek = no_llseek, | ||
4375 | }; | 4374 | }; |
4376 | 4375 | ||
4377 | static struct video_device v4l_device_template = { | 4376 | static struct video_device v4l_device_template = { |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index e15e48f04be7..81d5aa5cf331 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -1024,9 +1024,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1024 | File operations for the device | 1024 | File operations for the device |
1025 | ------------------------------------------------------------------*/ | 1025 | ------------------------------------------------------------------*/ |
1026 | 1026 | ||
1027 | static int vivi_open(struct inode *inode, struct file *file) | 1027 | static int vivi_open(struct file *file) |
1028 | { | 1028 | { |
1029 | int minor = iminor(inode); | 1029 | int minor = video_devdata(file)->minor; |
1030 | struct vivi_dev *dev; | 1030 | struct vivi_dev *dev; |
1031 | struct vivi_fh *fh = NULL; | 1031 | struct vivi_fh *fh = NULL; |
1032 | int i; | 1032 | int i; |
@@ -1127,13 +1127,13 @@ vivi_poll(struct file *file, struct poll_table_struct *wait) | |||
1127 | return videobuf_poll_stream(file, q, wait); | 1127 | return videobuf_poll_stream(file, q, wait); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | static int vivi_close(struct inode *inode, struct file *file) | 1130 | static int vivi_close(struct file *file) |
1131 | { | 1131 | { |
1132 | struct vivi_fh *fh = file->private_data; | 1132 | struct vivi_fh *fh = file->private_data; |
1133 | struct vivi_dev *dev = fh->dev; | 1133 | struct vivi_dev *dev = fh->dev; |
1134 | struct vivi_dmaqueue *vidq = &dev->vidq; | 1134 | struct vivi_dmaqueue *vidq = &dev->vidq; |
1135 | 1135 | ||
1136 | int minor = iminor(inode); | 1136 | int minor = video_devdata(file)->minor; |
1137 | 1137 | ||
1138 | vivi_stop_thread(vidq); | 1138 | vivi_stop_thread(vidq); |
1139 | videobuf_stop(&fh->vb_vidq); | 1139 | videobuf_stop(&fh->vb_vidq); |
@@ -1195,16 +1195,14 @@ static int vivi_mmap(struct file *file, struct vm_area_struct *vma) | |||
1195 | return ret; | 1195 | return ret; |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | static const struct file_operations vivi_fops = { | 1198 | static const struct v4l2_file_operations vivi_fops = { |
1199 | .owner = THIS_MODULE, | 1199 | .owner = THIS_MODULE, |
1200 | .open = vivi_open, | 1200 | .open = vivi_open, |
1201 | .release = vivi_close, | 1201 | .release = vivi_close, |
1202 | .read = vivi_read, | 1202 | .read = vivi_read, |
1203 | .poll = vivi_poll, | 1203 | .poll = vivi_poll, |
1204 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ | 1204 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ |
1205 | .compat_ioctl = v4l_compat_ioctl32, | ||
1206 | .mmap = vivi_mmap, | 1205 | .mmap = vivi_mmap, |
1207 | .llseek = no_llseek, | ||
1208 | }; | 1206 | }; |
1209 | 1207 | ||
1210 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { | 1208 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { |
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c index f72b859486ad..5d73f66d9f55 100644 --- a/drivers/media/video/vp27smpx.c +++ b/drivers/media/video/vp27smpx.c | |||
@@ -113,7 +113,7 @@ static int vp27smpx_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | static int vp27smpx_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 116 | static int vp27smpx_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
117 | { | 117 | { |
118 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 118 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
119 | 119 | ||
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c index 56c570c267ea..038ff32b01b8 100644 --- a/drivers/media/video/w9966.c +++ b/drivers/media/video/w9966.c | |||
@@ -180,19 +180,19 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data); | |||
180 | static int w9966_i2c_rbyte(struct w9966_dev* cam); | 180 | static int w9966_i2c_rbyte(struct w9966_dev* cam); |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | static int w9966_v4l_ioctl(struct inode *inode, struct file *file, | 183 | static long w9966_v4l_ioctl(struct file *file, |
184 | unsigned int cmd, unsigned long arg); | 184 | unsigned int cmd, unsigned long arg); |
185 | static ssize_t w9966_v4l_read(struct file *file, char __user *buf, | 185 | static ssize_t w9966_v4l_read(struct file *file, char __user *buf, |
186 | size_t count, loff_t *ppos); | 186 | size_t count, loff_t *ppos); |
187 | 187 | ||
188 | static int w9966_exclusive_open(struct inode *inode, struct file *file) | 188 | static int w9966_exclusive_open(struct file *file) |
189 | { | 189 | { |
190 | struct w9966_dev *cam = video_drvdata(file); | 190 | struct w9966_dev *cam = video_drvdata(file); |
191 | 191 | ||
192 | return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0; | 192 | return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | static int w9966_exclusive_release(struct inode *inode, struct file *file) | 195 | static int w9966_exclusive_release(struct file *file) |
196 | { | 196 | { |
197 | struct w9966_dev *cam = video_drvdata(file); | 197 | struct w9966_dev *cam = video_drvdata(file); |
198 | 198 | ||
@@ -200,16 +200,12 @@ static int w9966_exclusive_release(struct inode *inode, struct file *file) | |||
200 | return 0; | 200 | return 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | static const struct file_operations w9966_fops = { | 203 | static const struct v4l2_file_operations w9966_fops = { |
204 | .owner = THIS_MODULE, | 204 | .owner = THIS_MODULE, |
205 | .open = w9966_exclusive_open, | 205 | .open = w9966_exclusive_open, |
206 | .release = w9966_exclusive_release, | 206 | .release = w9966_exclusive_release, |
207 | .ioctl = w9966_v4l_ioctl, | 207 | .ioctl = w9966_v4l_ioctl, |
208 | #ifdef CONFIG_COMPAT | ||
209 | .compat_ioctl = v4l_compat_ioctl32, | ||
210 | #endif | ||
211 | .read = w9966_v4l_read, | 208 | .read = w9966_v4l_read, |
212 | .llseek = no_llseek, | ||
213 | }; | 209 | }; |
214 | static struct video_device w9966_template = { | 210 | static struct video_device w9966_template = { |
215 | .name = W9966_DRIVERNAME, | 211 | .name = W9966_DRIVERNAME, |
@@ -727,7 +723,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data) | |||
727 | * Video4linux interfacing | 723 | * Video4linux interfacing |
728 | */ | 724 | */ |
729 | 725 | ||
730 | static int w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 726 | static long w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
731 | { | 727 | { |
732 | struct w9966_dev *cam = video_drvdata(file); | 728 | struct w9966_dev *cam = video_drvdata(file); |
733 | 729 | ||
@@ -877,7 +873,7 @@ static int w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
877 | return 0; | 873 | return 0; |
878 | } | 874 | } |
879 | 875 | ||
880 | static int w9966_v4l_ioctl(struct inode *inode, struct file *file, | 876 | static long w9966_v4l_ioctl(struct file *file, |
881 | unsigned int cmd, unsigned long arg) | 877 | unsigned int cmd, unsigned long arg) |
882 | { | 878 | { |
883 | return video_usercopy(file, cmd, arg, w9966_v4l_do_ioctl); | 879 | return video_usercopy(file, cmd, arg, w9966_v4l_do_ioctl); |
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 4dfb43bd1846..a3997b7d4366 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
@@ -399,13 +399,13 @@ MODULE_PARM_DESC(specific_debug, | |||
399 | ****************************************************************************/ | 399 | ****************************************************************************/ |
400 | 400 | ||
401 | /* Video4linux interface */ | 401 | /* Video4linux interface */ |
402 | static const struct file_operations w9968cf_fops; | 402 | static const struct v4l2_file_operations w9968cf_fops; |
403 | static int w9968cf_open(struct inode*, struct file*); | 403 | static int w9968cf_open(struct file *); |
404 | static int w9968cf_release(struct inode*, struct file*); | 404 | static int w9968cf_release(struct file *); |
405 | static int w9968cf_mmap(struct file*, struct vm_area_struct*); | 405 | static int w9968cf_mmap(struct file *, struct vm_area_struct *); |
406 | static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long); | 406 | static long w9968cf_ioctl(struct file *, unsigned, unsigned long); |
407 | static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*); | 407 | static ssize_t w9968cf_read(struct file *, char __user *, size_t, loff_t *); |
408 | static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int, | 408 | static long w9968cf_v4l_ioctl(struct file *, unsigned int, |
409 | void __user *); | 409 | void __user *); |
410 | 410 | ||
411 | /* USB-specific */ | 411 | /* USB-specific */ |
@@ -2662,7 +2662,7 @@ static void w9968cf_release_resources(struct w9968cf_device* cam) | |||
2662 | * Video4Linux interface * | 2662 | * Video4Linux interface * |
2663 | ****************************************************************************/ | 2663 | ****************************************************************************/ |
2664 | 2664 | ||
2665 | static int w9968cf_open(struct inode* inode, struct file* filp) | 2665 | static int w9968cf_open(struct file *filp) |
2666 | { | 2666 | { |
2667 | struct w9968cf_device* cam; | 2667 | struct w9968cf_device* cam; |
2668 | int err; | 2668 | int err; |
@@ -2748,7 +2748,7 @@ deallocate_memory: | |||
2748 | } | 2748 | } |
2749 | 2749 | ||
2750 | 2750 | ||
2751 | static int w9968cf_release(struct inode* inode, struct file* filp) | 2751 | static int w9968cf_release(struct file *filp) |
2752 | { | 2752 | { |
2753 | struct w9968cf_device* cam; | 2753 | struct w9968cf_device* cam; |
2754 | 2754 | ||
@@ -2885,12 +2885,12 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma) | |||
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | 2887 | ||
2888 | static int | 2888 | static long |
2889 | w9968cf_ioctl(struct inode* inode, struct file* filp, | 2889 | w9968cf_ioctl(struct file *filp, |
2890 | unsigned int cmd, unsigned long arg) | 2890 | unsigned int cmd, unsigned long arg) |
2891 | { | 2891 | { |
2892 | struct w9968cf_device* cam; | 2892 | struct w9968cf_device* cam; |
2893 | int err; | 2893 | long err; |
2894 | 2894 | ||
2895 | cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); | 2895 | cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); |
2896 | 2896 | ||
@@ -2909,15 +2909,15 @@ w9968cf_ioctl(struct inode* inode, struct file* filp, | |||
2909 | return -EIO; | 2909 | return -EIO; |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | err = w9968cf_v4l_ioctl(inode, filp, cmd, (void __user *)arg); | 2912 | err = w9968cf_v4l_ioctl(filp, cmd, (void __user *)arg); |
2913 | 2913 | ||
2914 | mutex_unlock(&cam->fileop_mutex); | 2914 | mutex_unlock(&cam->fileop_mutex); |
2915 | return err; | 2915 | return err; |
2916 | } | 2916 | } |
2917 | 2917 | ||
2918 | 2918 | ||
2919 | static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, | 2919 | static long w9968cf_v4l_ioctl(struct file *filp, |
2920 | unsigned int cmd, void __user * arg) | 2920 | unsigned int cmd, void __user *arg) |
2921 | { | 2921 | { |
2922 | struct w9968cf_device* cam; | 2922 | struct w9968cf_device* cam; |
2923 | const char* v4l1_ioctls[] = { | 2923 | const char* v4l1_ioctls[] = { |
@@ -3456,17 +3456,13 @@ ioctl_fail: | |||
3456 | } | 3456 | } |
3457 | 3457 | ||
3458 | 3458 | ||
3459 | static const struct file_operations w9968cf_fops = { | 3459 | static const struct v4l2_file_operations w9968cf_fops = { |
3460 | .owner = THIS_MODULE, | 3460 | .owner = THIS_MODULE, |
3461 | .open = w9968cf_open, | 3461 | .open = w9968cf_open, |
3462 | .release = w9968cf_release, | 3462 | .release = w9968cf_release, |
3463 | .read = w9968cf_read, | 3463 | .read = w9968cf_read, |
3464 | .ioctl = w9968cf_ioctl, | 3464 | .ioctl = w9968cf_ioctl, |
3465 | #ifdef CONFIG_COMPAT | ||
3466 | .compat_ioctl = v4l_compat_ioctl32, | ||
3467 | #endif | ||
3468 | .mmap = w9968cf_mmap, | 3465 | .mmap = w9968cf_mmap, |
3469 | .llseek = no_llseek, | ||
3470 | }; | 3466 | }; |
3471 | 3467 | ||
3472 | 3468 | ||
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c index 12a31e7a5f6d..f2864d5cd180 100644 --- a/drivers/media/video/wm8739.c +++ b/drivers/media/video/wm8739.c | |||
@@ -233,7 +233,7 @@ static int wm8739_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 236 | static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
237 | { | 237 | { |
238 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 238 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
239 | 239 | ||
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index d0220b0ec0bc..53fcd42843e0 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c | |||
@@ -130,7 +130,7 @@ static int wm8775_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
132 | 132 | ||
133 | static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) | 133 | static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
134 | { | 134 | { |
135 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 135 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
136 | 136 | ||
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c index 9d00e6056491..96971044fc78 100644 --- a/drivers/media/video/zc0301/zc0301_core.c +++ b/drivers/media/video/zc0301/zc0301_core.c | |||
@@ -649,7 +649,7 @@ static void zc0301_release_resources(struct kref *kref) | |||
649 | } | 649 | } |
650 | 650 | ||
651 | 651 | ||
652 | static int zc0301_open(struct inode* inode, struct file* filp) | 652 | static int zc0301_open(struct file *filp) |
653 | { | 653 | { |
654 | struct zc0301_device* cam; | 654 | struct zc0301_device* cam; |
655 | int err = 0; | 655 | int err = 0; |
@@ -733,7 +733,7 @@ out: | |||
733 | } | 733 | } |
734 | 734 | ||
735 | 735 | ||
736 | static int zc0301_release(struct inode* inode, struct file* filp) | 736 | static int zc0301_release(struct file *filp) |
737 | { | 737 | { |
738 | struct zc0301_device* cam; | 738 | struct zc0301_device* cam; |
739 | 739 | ||
@@ -1793,8 +1793,8 @@ zc0301_vidioc_s_parm(struct zc0301_device* cam, void __user * arg) | |||
1793 | } | 1793 | } |
1794 | 1794 | ||
1795 | 1795 | ||
1796 | static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp, | 1796 | static long zc0301_ioctl_v4l2(struct file *filp, |
1797 | unsigned int cmd, void __user * arg) | 1797 | unsigned int cmd, void __user *arg) |
1798 | { | 1798 | { |
1799 | struct zc0301_device *cam = video_drvdata(filp); | 1799 | struct zc0301_device *cam = video_drvdata(filp); |
1800 | 1800 | ||
@@ -1888,7 +1888,7 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp, | |||
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | 1890 | ||
1891 | static int zc0301_ioctl(struct inode* inode, struct file* filp, | 1891 | static long zc0301_ioctl(struct file *filp, |
1892 | unsigned int cmd, unsigned long arg) | 1892 | unsigned int cmd, unsigned long arg) |
1893 | { | 1893 | { |
1894 | struct zc0301_device *cam = video_drvdata(filp); | 1894 | struct zc0301_device *cam = video_drvdata(filp); |
@@ -1912,7 +1912,7 @@ static int zc0301_ioctl(struct inode* inode, struct file* filp, | |||
1912 | 1912 | ||
1913 | V4LDBG(3, "zc0301", cmd); | 1913 | V4LDBG(3, "zc0301", cmd); |
1914 | 1914 | ||
1915 | err = zc0301_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); | 1915 | err = zc0301_ioctl_v4l2(filp, cmd, (void __user *)arg); |
1916 | 1916 | ||
1917 | mutex_unlock(&cam->fileop_mutex); | 1917 | mutex_unlock(&cam->fileop_mutex); |
1918 | 1918 | ||
@@ -1920,18 +1920,14 @@ static int zc0301_ioctl(struct inode* inode, struct file* filp, | |||
1920 | } | 1920 | } |
1921 | 1921 | ||
1922 | 1922 | ||
1923 | static const struct file_operations zc0301_fops = { | 1923 | static const struct v4l2_file_operations zc0301_fops = { |
1924 | .owner = THIS_MODULE, | 1924 | .owner = THIS_MODULE, |
1925 | .open = zc0301_open, | 1925 | .open = zc0301_open, |
1926 | .release = zc0301_release, | 1926 | .release = zc0301_release, |
1927 | .ioctl = zc0301_ioctl, | 1927 | .ioctl = zc0301_ioctl, |
1928 | #ifdef CONFIG_COMPAT | ||
1929 | .compat_ioctl = v4l_compat_ioctl32, | ||
1930 | #endif | ||
1931 | .read = zc0301_read, | 1928 | .read = zc0301_read, |
1932 | .poll = zc0301_poll, | 1929 | .poll = zc0301_poll, |
1933 | .mmap = zc0301_mmap, | 1930 | .mmap = zc0301_mmap, |
1934 | .llseek = no_llseek, | ||
1935 | }; | 1931 | }; |
1936 | 1932 | ||
1937 | /*****************************************************************************/ | 1933 | /*****************************************************************************/ |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index 00b97d97aeaa..b58b9dda715c 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -1197,10 +1197,9 @@ zoran_close_end_session (struct file *file) | |||
1197 | */ | 1197 | */ |
1198 | 1198 | ||
1199 | static int | 1199 | static int |
1200 | zoran_open (struct inode *inode, | 1200 | zoran_open(struct file *file) |
1201 | struct file *file) | ||
1202 | { | 1201 | { |
1203 | unsigned int minor = iminor(inode); | 1202 | unsigned int minor = video_devdata(file)->minor; |
1204 | struct zoran *zr = NULL; | 1203 | struct zoran *zr = NULL; |
1205 | struct zoran_fh *fh; | 1204 | struct zoran_fh *fh; |
1206 | int i, res, first_open = 0, have_module_locks = 0; | 1205 | int i, res, first_open = 0, have_module_locks = 0; |
@@ -1340,8 +1339,7 @@ open_unlock_and_return: | |||
1340 | } | 1339 | } |
1341 | 1340 | ||
1342 | static int | 1341 | static int |
1343 | zoran_close (struct inode *inode, | 1342 | zoran_close(struct file *file) |
1344 | struct file *file) | ||
1345 | { | 1343 | { |
1346 | struct zoran_fh *fh = file->private_data; | 1344 | struct zoran_fh *fh = file->private_data; |
1347 | struct zoran *zr = fh->zr; | 1345 | struct zoran *zr = fh->zr; |
@@ -1940,7 +1938,7 @@ zoran_set_input (struct zoran *zr, | |||
1940 | * ioctl routine | 1938 | * ioctl routine |
1941 | */ | 1939 | */ |
1942 | 1940 | ||
1943 | static int zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg) | 1941 | static long zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
1944 | { | 1942 | { |
1945 | struct zoran_fh *fh = file->private_data; | 1943 | struct zoran_fh *fh = file->private_data; |
1946 | struct zoran *zr = fh->zr; | 1944 | struct zoran *zr = fh->zr; |
@@ -4191,11 +4189,10 @@ static int zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
4191 | } | 4189 | } |
4192 | 4190 | ||
4193 | 4191 | ||
4194 | static int | 4192 | static long |
4195 | zoran_ioctl (struct inode *inode, | 4193 | zoran_ioctl(struct file *file, |
4196 | struct file *file, | 4194 | unsigned int cmd, |
4197 | unsigned int cmd, | 4195 | unsigned long arg) |
4198 | unsigned long arg) | ||
4199 | { | 4196 | { |
4200 | return video_usercopy(file, cmd, arg, zoran_do_ioctl); | 4197 | return video_usercopy(file, cmd, arg, zoran_do_ioctl); |
4201 | } | 4198 | } |
@@ -4620,15 +4617,11 @@ zoran_mmap (struct file *file, | |||
4620 | return 0; | 4617 | return 0; |
4621 | } | 4618 | } |
4622 | 4619 | ||
4623 | static const struct file_operations zoran_fops = { | 4620 | static const struct v4l2_file_operations zoran_fops = { |
4624 | .owner = THIS_MODULE, | 4621 | .owner = THIS_MODULE, |
4625 | .open = zoran_open, | 4622 | .open = zoran_open, |
4626 | .release = zoran_close, | 4623 | .release = zoran_close, |
4627 | .ioctl = zoran_ioctl, | 4624 | .ioctl = zoran_ioctl, |
4628 | #ifdef CONFIG_COMPAT | ||
4629 | .compat_ioctl = v4l_compat_ioctl32, | ||
4630 | #endif | ||
4631 | .llseek = no_llseek, | ||
4632 | .read = zoran_read, | 4625 | .read = zoran_read, |
4633 | .write = zoran_write, | 4626 | .write = zoran_write, |
4634 | .mmap = zoran_mmap, | 4627 | .mmap = zoran_mmap, |
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index a1d81ed44c7c..93023560f324 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
@@ -634,7 +634,7 @@ static int zr364xx_vidioc_streamoff(struct file *file, void *priv, | |||
634 | 634 | ||
635 | 635 | ||
636 | /* open the camera */ | 636 | /* open the camera */ |
637 | static int zr364xx_open(struct inode *inode, struct file *file) | 637 | static int zr364xx_open(struct file *file) |
638 | { | 638 | { |
639 | struct video_device *vdev = video_devdata(file); | 639 | struct video_device *vdev = video_devdata(file); |
640 | struct zr364xx_camera *cam = video_get_drvdata(vdev); | 640 | struct zr364xx_camera *cam = video_get_drvdata(vdev); |
@@ -688,7 +688,7 @@ out: | |||
688 | 688 | ||
689 | 689 | ||
690 | /* release the camera */ | 690 | /* release the camera */ |
691 | static int zr364xx_release(struct inode *inode, struct file *file) | 691 | static int zr364xx_release(struct file *file) |
692 | { | 692 | { |
693 | struct video_device *vdev = video_devdata(file); | 693 | struct video_device *vdev = video_devdata(file); |
694 | struct zr364xx_camera *cam; | 694 | struct zr364xx_camera *cam; |
@@ -761,14 +761,13 @@ static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma) | |||
761 | } | 761 | } |
762 | 762 | ||
763 | 763 | ||
764 | static const struct file_operations zr364xx_fops = { | 764 | static const struct v4l2_file_operations zr364xx_fops = { |
765 | .owner = THIS_MODULE, | 765 | .owner = THIS_MODULE, |
766 | .open = zr364xx_open, | 766 | .open = zr364xx_open, |
767 | .release = zr364xx_release, | 767 | .release = zr364xx_release, |
768 | .read = zr364xx_read, | 768 | .read = zr364xx_read, |
769 | .mmap = zr364xx_mmap, | 769 | .mmap = zr364xx_mmap, |
770 | .ioctl = video_ioctl2, | 770 | .ioctl = video_ioctl2, |
771 | .llseek = no_llseek, | ||
772 | }; | 771 | }; |
773 | 772 | ||
774 | static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = { | 773 | static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = { |
@@ -894,7 +893,6 @@ static void zr364xx_disconnect(struct usb_interface *intf) | |||
894 | { | 893 | { |
895 | struct zr364xx_camera *cam = usb_get_intfdata(intf); | 894 | struct zr364xx_camera *cam = usb_get_intfdata(intf); |
896 | usb_set_intfdata(intf, NULL); | 895 | usb_set_intfdata(intf, NULL); |
897 | dev_set_drvdata(&intf->dev, NULL); | ||
898 | dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); | 896 | dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); |
899 | if (cam->vdev) | 897 | if (cam->vdev) |
900 | video_unregister_device(cam->vdev); | 898 | video_unregister_device(cam->vdev); |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 3d067c35185d..45b1f430685f 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -145,7 +145,7 @@ struct mmc_blk_request { | |||
145 | static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) | 145 | static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) |
146 | { | 146 | { |
147 | int err; | 147 | int err; |
148 | u32 blocks; | 148 | __be32 blocks; |
149 | 149 | ||
150 | struct mmc_request mrq; | 150 | struct mmc_request mrq; |
151 | struct mmc_command cmd; | 151 | struct mmc_command cmd; |
@@ -204,9 +204,24 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) | |||
204 | if (cmd.error || data.error) | 204 | if (cmd.error || data.error) |
205 | return (u32)-1; | 205 | return (u32)-1; |
206 | 206 | ||
207 | blocks = ntohl(blocks); | 207 | return ntohl(blocks); |
208 | } | ||
209 | |||
210 | static u32 get_card_status(struct mmc_card *card, struct request *req) | ||
211 | { | ||
212 | struct mmc_command cmd; | ||
213 | int err; | ||
208 | 214 | ||
209 | return blocks; | 215 | memset(&cmd, 0, sizeof(struct mmc_command)); |
216 | cmd.opcode = MMC_SEND_STATUS; | ||
217 | if (!mmc_host_is_spi(card->host)) | ||
218 | cmd.arg = card->rca << 16; | ||
219 | cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; | ||
220 | err = mmc_wait_for_cmd(card->host, &cmd, 0); | ||
221 | if (err) | ||
222 | printk(KERN_ERR "%s: error %d sending status comand", | ||
223 | req->rq_disk->disk_name, err); | ||
224 | return cmd.resp[0]; | ||
210 | } | 225 | } |
211 | 226 | ||
212 | static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | 227 | static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) |
@@ -214,13 +229,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
214 | struct mmc_blk_data *md = mq->data; | 229 | struct mmc_blk_data *md = mq->data; |
215 | struct mmc_card *card = md->queue.card; | 230 | struct mmc_card *card = md->queue.card; |
216 | struct mmc_blk_request brq; | 231 | struct mmc_blk_request brq; |
217 | int ret = 1; | 232 | int ret = 1, disable_multi = 0; |
218 | 233 | ||
219 | mmc_claim_host(card->host); | 234 | mmc_claim_host(card->host); |
220 | 235 | ||
221 | do { | 236 | do { |
222 | struct mmc_command cmd; | 237 | struct mmc_command cmd; |
223 | u32 readcmd, writecmd; | 238 | u32 readcmd, writecmd, status = 0; |
224 | 239 | ||
225 | memset(&brq, 0, sizeof(struct mmc_blk_request)); | 240 | memset(&brq, 0, sizeof(struct mmc_blk_request)); |
226 | brq.mrq.cmd = &brq.cmd; | 241 | brq.mrq.cmd = &brq.cmd; |
@@ -236,6 +251,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
236 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; | 251 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; |
237 | brq.data.blocks = req->nr_sectors; | 252 | brq.data.blocks = req->nr_sectors; |
238 | 253 | ||
254 | /* | ||
255 | * After a read error, we redo the request one sector at a time | ||
256 | * in order to accurately determine which sectors can be read | ||
257 | * successfully. | ||
258 | */ | ||
259 | if (disable_multi && brq.data.blocks > 1) | ||
260 | brq.data.blocks = 1; | ||
261 | |||
239 | if (brq.data.blocks > 1) { | 262 | if (brq.data.blocks > 1) { |
240 | /* SPI multiblock writes terminate using a special | 263 | /* SPI multiblock writes terminate using a special |
241 | * token, not a STOP_TRANSMISSION request. | 264 | * token, not a STOP_TRANSMISSION request. |
@@ -264,6 +287,25 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
264 | brq.data.sg = mq->sg; | 287 | brq.data.sg = mq->sg; |
265 | brq.data.sg_len = mmc_queue_map_sg(mq); | 288 | brq.data.sg_len = mmc_queue_map_sg(mq); |
266 | 289 | ||
290 | /* | ||
291 | * Adjust the sg list so it is the same size as the | ||
292 | * request. | ||
293 | */ | ||
294 | if (brq.data.blocks != req->nr_sectors) { | ||
295 | int i, data_size = brq.data.blocks << 9; | ||
296 | struct scatterlist *sg; | ||
297 | |||
298 | for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) { | ||
299 | data_size -= sg->length; | ||
300 | if (data_size <= 0) { | ||
301 | sg->length += data_size; | ||
302 | i++; | ||
303 | break; | ||
304 | } | ||
305 | } | ||
306 | brq.data.sg_len = i; | ||
307 | } | ||
308 | |||
267 | mmc_queue_bounce_pre(mq); | 309 | mmc_queue_bounce_pre(mq); |
268 | 310 | ||
269 | mmc_wait_for_req(card->host, &brq.mrq); | 311 | mmc_wait_for_req(card->host, &brq.mrq); |
@@ -275,19 +317,40 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
275 | * until later as we need to wait for the card to leave | 317 | * until later as we need to wait for the card to leave |
276 | * programming mode even when things go wrong. | 318 | * programming mode even when things go wrong. |
277 | */ | 319 | */ |
320 | if (brq.cmd.error || brq.data.error || brq.stop.error) { | ||
321 | if (brq.data.blocks > 1 && rq_data_dir(req) == READ) { | ||
322 | /* Redo read one sector at a time */ | ||
323 | printk(KERN_WARNING "%s: retrying using single " | ||
324 | "block read\n", req->rq_disk->disk_name); | ||
325 | disable_multi = 1; | ||
326 | continue; | ||
327 | } | ||
328 | status = get_card_status(card, req); | ||
329 | } | ||
330 | |||
278 | if (brq.cmd.error) { | 331 | if (brq.cmd.error) { |
279 | printk(KERN_ERR "%s: error %d sending read/write command\n", | 332 | printk(KERN_ERR "%s: error %d sending read/write " |
280 | req->rq_disk->disk_name, brq.cmd.error); | 333 | "command, response %#x, card status %#x\n", |
334 | req->rq_disk->disk_name, brq.cmd.error, | ||
335 | brq.cmd.resp[0], status); | ||
281 | } | 336 | } |
282 | 337 | ||
283 | if (brq.data.error) { | 338 | if (brq.data.error) { |
284 | printk(KERN_ERR "%s: error %d transferring data\n", | 339 | if (brq.data.error == -ETIMEDOUT && brq.mrq.stop) |
285 | req->rq_disk->disk_name, brq.data.error); | 340 | /* 'Stop' response contains card status */ |
341 | status = brq.mrq.stop->resp[0]; | ||
342 | printk(KERN_ERR "%s: error %d transferring data," | ||
343 | " sector %u, nr %u, card status %#x\n", | ||
344 | req->rq_disk->disk_name, brq.data.error, | ||
345 | (unsigned)req->sector, | ||
346 | (unsigned)req->nr_sectors, status); | ||
286 | } | 347 | } |
287 | 348 | ||
288 | if (brq.stop.error) { | 349 | if (brq.stop.error) { |
289 | printk(KERN_ERR "%s: error %d sending stop command\n", | 350 | printk(KERN_ERR "%s: error %d sending stop command, " |
290 | req->rq_disk->disk_name, brq.stop.error); | 351 | "response %#x, card status %#x\n", |
352 | req->rq_disk->disk_name, brq.stop.error, | ||
353 | brq.stop.resp[0], status); | ||
291 | } | 354 | } |
292 | 355 | ||
293 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { | 356 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { |
@@ -320,8 +383,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
320 | #endif | 383 | #endif |
321 | } | 384 | } |
322 | 385 | ||
323 | if (brq.cmd.error || brq.data.error || brq.stop.error) | 386 | if (brq.cmd.error || brq.stop.error || brq.data.error) { |
387 | if (rq_data_dir(req) == READ) { | ||
388 | /* | ||
389 | * After an error, we redo I/O one sector at a | ||
390 | * time, so we only reach here after trying to | ||
391 | * read a single sector. | ||
392 | */ | ||
393 | spin_lock_irq(&md->lock); | ||
394 | ret = __blk_end_request(req, -EIO, brq.data.blksz); | ||
395 | spin_unlock_irq(&md->lock); | ||
396 | continue; | ||
397 | } | ||
324 | goto cmd_err; | 398 | goto cmd_err; |
399 | } | ||
325 | 400 | ||
326 | /* | 401 | /* |
327 | * A block was successfully transferred. | 402 | * A block was successfully transferred. |
@@ -343,25 +418,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
343 | * If the card is not SD, we can still ok written sectors | 418 | * If the card is not SD, we can still ok written sectors |
344 | * as reported by the controller (which might be less than | 419 | * as reported by the controller (which might be less than |
345 | * the real number of written sectors, but never more). | 420 | * the real number of written sectors, but never more). |
346 | * | ||
347 | * For reads we just fail the entire chunk as that should | ||
348 | * be safe in all cases. | ||
349 | */ | 421 | */ |
350 | if (rq_data_dir(req) != READ) { | 422 | if (mmc_card_sd(card)) { |
351 | if (mmc_card_sd(card)) { | 423 | u32 blocks; |
352 | u32 blocks; | ||
353 | 424 | ||
354 | blocks = mmc_sd_num_wr_blocks(card); | 425 | blocks = mmc_sd_num_wr_blocks(card); |
355 | if (blocks != (u32)-1) { | 426 | if (blocks != (u32)-1) { |
356 | spin_lock_irq(&md->lock); | ||
357 | ret = __blk_end_request(req, 0, blocks << 9); | ||
358 | spin_unlock_irq(&md->lock); | ||
359 | } | ||
360 | } else { | ||
361 | spin_lock_irq(&md->lock); | 427 | spin_lock_irq(&md->lock); |
362 | ret = __blk_end_request(req, 0, brq.data.bytes_xfered); | 428 | ret = __blk_end_request(req, 0, blocks << 9); |
363 | spin_unlock_irq(&md->lock); | 429 | spin_unlock_irq(&md->lock); |
364 | } | 430 | } |
431 | } else { | ||
432 | spin_lock_irq(&md->lock); | ||
433 | ret = __blk_end_request(req, 0, brq.data.bytes_xfered); | ||
434 | spin_unlock_irq(&md->lock); | ||
365 | } | 435 | } |
366 | 436 | ||
367 | mmc_release_host(card->host); | 437 | mmc_release_host(card->host); |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f7284b905eb3..df6ce4a06cf3 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/leds.h> | 21 | #include <linux/leds.h> |
22 | #include <linux/scatterlist.h> | 22 | #include <linux/scatterlist.h> |
23 | #include <linux/log2.h> | ||
23 | 24 | ||
24 | #include <linux/mmc/card.h> | 25 | #include <linux/mmc/card.h> |
25 | #include <linux/mmc/host.h> | 26 | #include <linux/mmc/host.h> |
@@ -448,6 +449,80 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width) | |||
448 | mmc_set_ios(host); | 449 | mmc_set_ios(host); |
449 | } | 450 | } |
450 | 451 | ||
452 | /** | ||
453 | * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number | ||
454 | * @vdd: voltage (mV) | ||
455 | * @low_bits: prefer low bits in boundary cases | ||
456 | * | ||
457 | * This function returns the OCR bit number according to the provided @vdd | ||
458 | * value. If conversion is not possible a negative errno value returned. | ||
459 | * | ||
460 | * Depending on the @low_bits flag the function prefers low or high OCR bits | ||
461 | * on boundary voltages. For example, | ||
462 | * with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33); | ||
463 | * with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34); | ||
464 | * | ||
465 | * Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21). | ||
466 | */ | ||
467 | static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits) | ||
468 | { | ||
469 | const int max_bit = ilog2(MMC_VDD_35_36); | ||
470 | int bit; | ||
471 | |||
472 | if (vdd < 1650 || vdd > 3600) | ||
473 | return -EINVAL; | ||
474 | |||
475 | if (vdd >= 1650 && vdd <= 1950) | ||
476 | return ilog2(MMC_VDD_165_195); | ||
477 | |||
478 | if (low_bits) | ||
479 | vdd -= 1; | ||
480 | |||
481 | /* Base 2000 mV, step 100 mV, bit's base 8. */ | ||
482 | bit = (vdd - 2000) / 100 + 8; | ||
483 | if (bit > max_bit) | ||
484 | return max_bit; | ||
485 | return bit; | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask | ||
490 | * @vdd_min: minimum voltage value (mV) | ||
491 | * @vdd_max: maximum voltage value (mV) | ||
492 | * | ||
493 | * This function returns the OCR mask bits according to the provided @vdd_min | ||
494 | * and @vdd_max values. If conversion is not possible the function returns 0. | ||
495 | * | ||
496 | * Notes wrt boundary cases: | ||
497 | * This function sets the OCR bits for all boundary voltages, for example | ||
498 | * [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | | ||
499 | * MMC_VDD_34_35 mask. | ||
500 | */ | ||
501 | u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max) | ||
502 | { | ||
503 | u32 mask = 0; | ||
504 | |||
505 | if (vdd_max < vdd_min) | ||
506 | return 0; | ||
507 | |||
508 | /* Prefer high bits for the boundary vdd_max values. */ | ||
509 | vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false); | ||
510 | if (vdd_max < 0) | ||
511 | return 0; | ||
512 | |||
513 | /* Prefer low bits for the boundary vdd_min values. */ | ||
514 | vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true); | ||
515 | if (vdd_min < 0) | ||
516 | return 0; | ||
517 | |||
518 | /* Fill the mask, from max bit to min bit. */ | ||
519 | while (vdd_max >= vdd_min) | ||
520 | mask |= 1 << vdd_max--; | ||
521 | |||
522 | return mask; | ||
523 | } | ||
524 | EXPORT_SYMBOL(mmc_vddrange_to_ocrmask); | ||
525 | |||
451 | /* | 526 | /* |
452 | * Mask off any voltages we don't support and select | 527 | * Mask off any voltages we don't support and select |
453 | * the lowest voltage | 528 | * the lowest voltage |
@@ -467,6 +542,8 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
467 | host->ios.vdd = bit; | 542 | host->ios.vdd = bit; |
468 | mmc_set_ios(host); | 543 | mmc_set_ios(host); |
469 | } else { | 544 | } else { |
545 | pr_warning("%s: host doesn't support card's voltages\n", | ||
546 | mmc_hostname(host)); | ||
470 | ocr = 0; | 547 | ocr = 0; |
471 | } | 548 | } |
472 | 549 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index fdd7c760be8c..c232d11a7ed4 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -434,13 +434,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
434 | * Activate wide bus (if supported). | 434 | * Activate wide bus (if supported). |
435 | */ | 435 | */ |
436 | if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) && | 436 | if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) && |
437 | (host->caps & MMC_CAP_4_BIT_DATA)) { | 437 | (host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) { |
438 | unsigned ext_csd_bit, bus_width; | ||
439 | |||
440 | if (host->caps & MMC_CAP_8_BIT_DATA) { | ||
441 | ext_csd_bit = EXT_CSD_BUS_WIDTH_8; | ||
442 | bus_width = MMC_BUS_WIDTH_8; | ||
443 | } else { | ||
444 | ext_csd_bit = EXT_CSD_BUS_WIDTH_4; | ||
445 | bus_width = MMC_BUS_WIDTH_4; | ||
446 | } | ||
447 | |||
438 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 448 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
439 | EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4); | 449 | EXT_CSD_BUS_WIDTH, ext_csd_bit); |
450 | |||
440 | if (err) | 451 | if (err) |
441 | goto free_card; | 452 | goto free_card; |
442 | 453 | ||
443 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); | 454 | mmc_set_bus_width(card->host, bus_width); |
444 | } | 455 | } |
445 | 456 | ||
446 | if (!oldcard) | 457 | if (!oldcard) |
@@ -624,4 +635,3 @@ err: | |||
624 | 635 | ||
625 | return err; | 636 | return err; |
626 | } | 637 | } |
627 | |||
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index c794cc5ce442..f4853288bbb1 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -19,6 +19,9 @@ obj-$(CONFIG_MMC_AT91) += at91_mci.o | |||
19 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o | 19 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o |
20 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o | 20 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o |
21 | obj-$(CONFIG_MMC_SPI) += mmc_spi.o | 21 | obj-$(CONFIG_MMC_SPI) += mmc_spi.o |
22 | ifeq ($(CONFIG_OF),y) | ||
23 | obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o | ||
24 | endif | ||
22 | obj-$(CONFIG_MMC_S3C) += s3cmci.o | 25 | obj-$(CONFIG_MMC_S3C) += s3cmci.o |
23 | obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o | 26 | obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o |
24 | obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o | 27 | obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 1f8b5b36222c..e556d42cc45a 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -1088,6 +1088,8 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1088 | goto fail0; | 1088 | goto fail0; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
1092 | |||
1091 | platform_set_drvdata(pdev, mmc); | 1093 | platform_set_drvdata(pdev, mmc); |
1092 | 1094 | ||
1093 | /* | 1095 | /* |
@@ -1101,8 +1103,6 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1101 | 1103 | ||
1102 | mmc_add_host(mmc); | 1104 | mmc_add_host(mmc); |
1103 | 1105 | ||
1104 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
1105 | |||
1106 | /* | 1106 | /* |
1107 | * monitor card insertion/removal if we can | 1107 | * monitor card insertion/removal if we can |
1108 | */ | 1108 | */ |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index ad00e1632317..87e211df68ac 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1285,7 +1285,7 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1285 | /* Platform data is used to hook up things like card sensing | 1285 | /* Platform data is used to hook up things like card sensing |
1286 | * and power switching gpios. | 1286 | * and power switching gpios. |
1287 | */ | 1287 | */ |
1288 | host->pdata = spi->dev.platform_data; | 1288 | host->pdata = mmc_spi_get_pdata(spi); |
1289 | if (host->pdata) | 1289 | if (host->pdata) |
1290 | mmc->ocr_avail = host->pdata->ocr_mask; | 1290 | mmc->ocr_avail = host->pdata->ocr_mask; |
1291 | if (!mmc->ocr_avail) { | 1291 | if (!mmc->ocr_avail) { |
@@ -1368,6 +1368,7 @@ fail_glue_init: | |||
1368 | 1368 | ||
1369 | fail_nobuf1: | 1369 | fail_nobuf1: |
1370 | mmc_free_host(mmc); | 1370 | mmc_free_host(mmc); |
1371 | mmc_spi_put_pdata(spi); | ||
1371 | dev_set_drvdata(&spi->dev, NULL); | 1372 | dev_set_drvdata(&spi->dev, NULL); |
1372 | 1373 | ||
1373 | nomem: | 1374 | nomem: |
@@ -1402,6 +1403,7 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) | |||
1402 | 1403 | ||
1403 | spi->max_speed_hz = mmc->f_max; | 1404 | spi->max_speed_hz = mmc->f_max; |
1404 | mmc_free_host(mmc); | 1405 | mmc_free_host(mmc); |
1406 | mmc_spi_put_pdata(spi); | ||
1405 | dev_set_drvdata(&spi->dev, NULL); | 1407 | dev_set_drvdata(&spi->dev, NULL); |
1406 | } | 1408 | } |
1407 | return 0; | 1409 | return 0; |
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c new file mode 100644 index 000000000000..fb2921f8099d --- /dev/null +++ b/drivers/mmc/host/of_mmc_spi.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * OpenFirmware bindings for the MMC-over-SPI driver | ||
3 | * | ||
4 | * Copyright (c) MontaVista Software, Inc. 2008. | ||
5 | * | ||
6 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/of.h> | ||
19 | #include <linux/of_gpio.h> | ||
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/spi/mmc_spi.h> | ||
22 | #include <linux/mmc/core.h> | ||
23 | #include <linux/mmc/host.h> | ||
24 | |||
25 | enum { | ||
26 | CD_GPIO = 0, | ||
27 | WP_GPIO, | ||
28 | NUM_GPIOS, | ||
29 | }; | ||
30 | |||
31 | struct of_mmc_spi { | ||
32 | int gpios[NUM_GPIOS]; | ||
33 | bool alow_gpios[NUM_GPIOS]; | ||
34 | struct mmc_spi_platform_data pdata; | ||
35 | }; | ||
36 | |||
37 | static struct of_mmc_spi *to_of_mmc_spi(struct device *dev) | ||
38 | { | ||
39 | return container_of(dev->platform_data, struct of_mmc_spi, pdata); | ||
40 | } | ||
41 | |||
42 | static int of_mmc_spi_read_gpio(struct device *dev, int gpio_num) | ||
43 | { | ||
44 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
45 | bool active_low = oms->alow_gpios[gpio_num]; | ||
46 | bool value = gpio_get_value(oms->gpios[gpio_num]); | ||
47 | |||
48 | return active_low ^ value; | ||
49 | } | ||
50 | |||
51 | static int of_mmc_spi_get_cd(struct device *dev) | ||
52 | { | ||
53 | return of_mmc_spi_read_gpio(dev, CD_GPIO); | ||
54 | } | ||
55 | |||
56 | static int of_mmc_spi_get_ro(struct device *dev) | ||
57 | { | ||
58 | return of_mmc_spi_read_gpio(dev, WP_GPIO); | ||
59 | } | ||
60 | |||
61 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | ||
62 | { | ||
63 | struct device *dev = &spi->dev; | ||
64 | struct device_node *np = dev_archdata_get_node(&dev->archdata); | ||
65 | struct of_mmc_spi *oms; | ||
66 | const u32 *voltage_ranges; | ||
67 | int num_ranges; | ||
68 | int i; | ||
69 | int ret = -EINVAL; | ||
70 | |||
71 | if (dev->platform_data || !np) | ||
72 | return dev->platform_data; | ||
73 | |||
74 | oms = kzalloc(sizeof(*oms), GFP_KERNEL); | ||
75 | if (!oms) | ||
76 | return NULL; | ||
77 | |||
78 | voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); | ||
79 | num_ranges = num_ranges / sizeof(*voltage_ranges) / 2; | ||
80 | if (!voltage_ranges || !num_ranges) { | ||
81 | dev_err(dev, "OF: voltage-ranges unspecified\n"); | ||
82 | goto err_ocr; | ||
83 | } | ||
84 | |||
85 | for (i = 0; i < num_ranges; i++) { | ||
86 | const int j = i * 2; | ||
87 | u32 mask; | ||
88 | |||
89 | mask = mmc_vddrange_to_ocrmask(voltage_ranges[j], | ||
90 | voltage_ranges[j + 1]); | ||
91 | if (!mask) { | ||
92 | ret = -EINVAL; | ||
93 | dev_err(dev, "OF: voltage-range #%d is invalid\n", i); | ||
94 | goto err_ocr; | ||
95 | } | ||
96 | oms->pdata.ocr_mask |= mask; | ||
97 | } | ||
98 | |||
99 | for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { | ||
100 | enum of_gpio_flags gpio_flags; | ||
101 | |||
102 | oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags); | ||
103 | if (!gpio_is_valid(oms->gpios[i])) | ||
104 | continue; | ||
105 | |||
106 | ret = gpio_request(oms->gpios[i], dev->bus_id); | ||
107 | if (ret < 0) { | ||
108 | oms->gpios[i] = -EINVAL; | ||
109 | continue; | ||
110 | } | ||
111 | |||
112 | if (gpio_flags & OF_GPIO_ACTIVE_LOW) | ||
113 | oms->alow_gpios[i] = true; | ||
114 | } | ||
115 | |||
116 | if (gpio_is_valid(oms->gpios[CD_GPIO])) | ||
117 | oms->pdata.get_cd = of_mmc_spi_get_cd; | ||
118 | if (gpio_is_valid(oms->gpios[WP_GPIO])) | ||
119 | oms->pdata.get_ro = of_mmc_spi_get_ro; | ||
120 | |||
121 | /* We don't support interrupts yet, let's poll. */ | ||
122 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | ||
123 | |||
124 | dev->platform_data = &oms->pdata; | ||
125 | return dev->platform_data; | ||
126 | err_ocr: | ||
127 | kfree(oms); | ||
128 | return NULL; | ||
129 | } | ||
130 | EXPORT_SYMBOL(mmc_spi_get_pdata); | ||
131 | |||
132 | void mmc_spi_put_pdata(struct spi_device *spi) | ||
133 | { | ||
134 | struct device *dev = &spi->dev; | ||
135 | struct device_node *np = dev_archdata_get_node(&dev->archdata); | ||
136 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
137 | int i; | ||
138 | |||
139 | if (!dev->platform_data || !np) | ||
140 | return; | ||
141 | |||
142 | for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { | ||
143 | if (gpio_is_valid(oms->gpios[i])) | ||
144 | gpio_free(oms->gpios[i]); | ||
145 | } | ||
146 | kfree(oms); | ||
147 | dev->platform_data = NULL; | ||
148 | } | ||
149 | EXPORT_SYMBOL(mmc_spi_put_pdata); | ||
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index f88cc7406354..3c5483b75da4 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -283,7 +283,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat) | |||
283 | return 0; | 283 | return 0; |
284 | 284 | ||
285 | DCSR(host->dma) = 0; | 285 | DCSR(host->dma) = 0; |
286 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len, | 286 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, |
287 | host->dma_dir); | 287 | host->dma_dir); |
288 | 288 | ||
289 | if (stat & STAT_READ_TIME_OUT) | 289 | if (stat & STAT_READ_TIME_OUT) |
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c index a16d7609e4ee..be9e7b32b34e 100644 --- a/drivers/mmc/host/ricoh_mmc.c +++ b/drivers/mmc/host/ricoh_mmc.c | |||
@@ -11,9 +11,10 @@ | |||
11 | 11 | ||
12 | /* | 12 | /* |
13 | * This is a conceptually ridiculous driver, but it is required by the way | 13 | * This is a conceptually ridiculous driver, but it is required by the way |
14 | * the Ricoh multi-function R5C832 works. This chip implements firewire | 14 | * the Ricoh multi-function chips (R5CXXX) work. These chips implement |
15 | * and four different memory card controllers. Two of those controllers are | 15 | * the four main memory card controllers (SD, MMC, MS, xD) and one or both |
16 | * an SDHCI controller and a proprietary MMC controller. The linux SDHCI | 16 | * of cardbus or firewire. It happens that they implement SD and MMC |
17 | * support as separate controllers (and PCI functions). The linux SDHCI | ||
17 | * driver supports MMC cards but the chip detects MMC cards in hardware | 18 | * driver supports MMC cards but the chip detects MMC cards in hardware |
18 | * and directs them to the MMC controller - so the SDHCI driver never sees | 19 | * and directs them to the MMC controller - so the SDHCI driver never sees |
19 | * them. To get around this, we must disable the useless MMC controller. | 20 | * them. To get around this, we must disable the useless MMC controller. |
@@ -21,8 +22,10 @@ | |||
21 | * a detection event occurs immediately, even if the MMC card is already | 22 | * a detection event occurs immediately, even if the MMC card is already |
22 | * in the reader. | 23 | * in the reader. |
23 | * | 24 | * |
24 | * The relevant registers live on the firewire function, so this is unavoidably | 25 | * It seems to be the case that the relevant PCI registers to deactivate the |
25 | * ugly. Such is life. | 26 | * MMC controller live on PCI function 0, which might be the cardbus controller |
27 | * or the firewire controller, depending on the particular chip in question. As | ||
28 | * such, it makes what this driver has to do unavoidably ugly. Such is life. | ||
26 | */ | 29 | */ |
27 | 30 | ||
28 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
@@ -143,6 +146,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
143 | pci_get_device(PCI_VENDOR_ID_RICOH, | 146 | pci_get_device(PCI_VENDOR_ID_RICOH, |
144 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { | 147 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { |
145 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | 148 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
149 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
146 | pdev->bus == fw_dev->bus) { | 150 | pdev->bus == fw_dev->bus) { |
147 | if (ricoh_mmc_disable(fw_dev) != 0) | 151 | if (ricoh_mmc_disable(fw_dev) != 0) |
148 | return -ENODEV; | 152 | return -ENODEV; |
@@ -160,6 +164,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
160 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, | 164 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, |
161 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { | 165 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { |
162 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | 166 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
167 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
163 | pdev->bus == fw_dev->bus) { | 168 | pdev->bus == fw_dev->bus) { |
164 | if (ricoh_mmc_disable(fw_dev) != 0) | 169 | if (ricoh_mmc_disable(fw_dev) != 0) |
165 | return -ENODEV; | 170 | return -ENODEV; |
@@ -172,7 +177,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
172 | 177 | ||
173 | if (!ctrlfound) { | 178 | if (!ctrlfound) { |
174 | printk(KERN_WARNING DRIVER_NAME | 179 | printk(KERN_WARNING DRIVER_NAME |
175 | ": Main firewire function not found. Cannot disable controller.\n"); | 180 | ": Main Ricoh function not found. Cannot disable controller.\n"); |
176 | return -ENODEV; | 181 | return -ENODEV; |
177 | } | 182 | } |
178 | 183 | ||
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 9bd7026b0021..f07255cb17ee 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -545,7 +545,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
545 | } | 545 | } |
546 | 546 | ||
547 | addr = pci_resource_start(pdev, bar); | 547 | addr = pci_resource_start(pdev, bar); |
548 | host->ioaddr = ioremap_nocache(addr, pci_resource_len(pdev, bar)); | 548 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
549 | if (!host->ioaddr) { | 549 | if (!host->ioaddr) { |
550 | dev_err(&pdev->dev, "failed to remap registers\n"); | 550 | dev_err(&pdev->dev, "failed to remap registers\n"); |
551 | goto release; | 551 | goto release; |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4d010a984bed..6b2d1f99af67 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -30,6 +30,11 @@ | |||
30 | #define DBG(f, x...) \ | 30 | #define DBG(f, x...) \ |
31 | pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) | 31 | pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) |
32 | 32 | ||
33 | #if defined(CONFIG_LEDS_CLASS) || (defined(CONFIG_LEDS_CLASS_MODULE) && \ | ||
34 | defined(CONFIG_MMC_SDHCI_MODULE)) | ||
35 | #define SDHCI_USE_LEDS_CLASS | ||
36 | #endif | ||
37 | |||
33 | static unsigned int debug_quirks = 0; | 38 | static unsigned int debug_quirks = 0; |
34 | 39 | ||
35 | static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *); | 40 | static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *); |
@@ -149,7 +154,7 @@ static void sdhci_deactivate_led(struct sdhci_host *host) | |||
149 | writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); | 154 | writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); |
150 | } | 155 | } |
151 | 156 | ||
152 | #ifdef CONFIG_LEDS_CLASS | 157 | #ifdef SDHCI_USE_LEDS_CLASS |
153 | static void sdhci_led_control(struct led_classdev *led, | 158 | static void sdhci_led_control(struct led_classdev *led, |
154 | enum led_brightness brightness) | 159 | enum led_brightness brightness) |
155 | { | 160 | { |
@@ -994,7 +999,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
994 | 999 | ||
995 | WARN_ON(host->mrq != NULL); | 1000 | WARN_ON(host->mrq != NULL); |
996 | 1001 | ||
997 | #ifndef CONFIG_LEDS_CLASS | 1002 | #ifndef SDHCI_USE_LEDS_CLASS |
998 | sdhci_activate_led(host); | 1003 | sdhci_activate_led(host); |
999 | #endif | 1004 | #endif |
1000 | 1005 | ||
@@ -1201,7 +1206,7 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1201 | host->cmd = NULL; | 1206 | host->cmd = NULL; |
1202 | host->data = NULL; | 1207 | host->data = NULL; |
1203 | 1208 | ||
1204 | #ifndef CONFIG_LEDS_CLASS | 1209 | #ifndef SDHCI_USE_LEDS_CLASS |
1205 | sdhci_deactivate_led(host); | 1210 | sdhci_deactivate_led(host); |
1206 | #endif | 1211 | #endif |
1207 | 1212 | ||
@@ -1717,7 +1722,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1717 | sdhci_dumpregs(host); | 1722 | sdhci_dumpregs(host); |
1718 | #endif | 1723 | #endif |
1719 | 1724 | ||
1720 | #ifdef CONFIG_LEDS_CLASS | 1725 | #ifdef SDHCI_USE_LEDS_CLASS |
1721 | host->led.name = mmc_hostname(mmc); | 1726 | host->led.name = mmc_hostname(mmc); |
1722 | host->led.brightness = LED_OFF; | 1727 | host->led.brightness = LED_OFF; |
1723 | host->led.default_trigger = mmc_hostname(mmc); | 1728 | host->led.default_trigger = mmc_hostname(mmc); |
@@ -1739,7 +1744,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1739 | 1744 | ||
1740 | return 0; | 1745 | return 0; |
1741 | 1746 | ||
1742 | #ifdef CONFIG_LEDS_CLASS | 1747 | #ifdef SDHCI_USE_LEDS_CLASS |
1743 | reset: | 1748 | reset: |
1744 | sdhci_reset(host, SDHCI_RESET_ALL); | 1749 | sdhci_reset(host, SDHCI_RESET_ALL); |
1745 | free_irq(host->irq, host); | 1750 | free_irq(host->irq, host); |
@@ -1775,7 +1780,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) | |||
1775 | 1780 | ||
1776 | mmc_remove_host(host->mmc); | 1781 | mmc_remove_host(host->mmc); |
1777 | 1782 | ||
1778 | #ifdef CONFIG_LEDS_CLASS | 1783 | #ifdef SDHCI_USE_LEDS_CLASS |
1779 | led_classdev_unregister(&host->led); | 1784 | led_classdev_unregister(&host->led); |
1780 | #endif | 1785 | #endif |
1781 | 1786 | ||
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 31f4b1528e76..3efba2363941 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -220,7 +220,7 @@ struct sdhci_host { | |||
220 | struct mmc_host *mmc; /* MMC structure */ | 220 | struct mmc_host *mmc; /* MMC structure */ |
221 | u64 dma_mask; /* custom DMA mask */ | 221 | u64 dma_mask; /* custom DMA mask */ |
222 | 222 | ||
223 | #ifdef CONFIG_LEDS_CLASS | 223 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
224 | struct led_classdev led; /* LED control */ | 224 | struct led_classdev led; /* LED control */ |
225 | #endif | 225 | #endif |
226 | 226 | ||
diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 1df44d966bdb..cb41e9c3ac07 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c | |||
@@ -82,6 +82,8 @@ static struct pcmcia_device_id pcmcia_ids[] = { | |||
82 | /* vendor and device strings followed by their crc32 hashes */ | 82 | /* vendor and device strings followed by their crc32 hashes */ |
83 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed, | 83 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed, |
84 | 0xc3901202), | 84 | 0xc3901202), |
85 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay Controller", 0xd9f522ed, | ||
86 | 0xace80909), | ||
85 | PCMCIA_DEVICE_NULL, | 87 | PCMCIA_DEVICE_NULL, |
86 | }; | 88 | }; |
87 | 89 | ||
@@ -463,7 +465,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev, | |||
463 | 465 | ||
464 | err: | 466 | err: |
465 | if (iobase) | 467 | if (iobase) |
466 | iounmap(iobase); | 468 | pci_iounmap(pci_dev, iobase); |
467 | if (mmc) | 469 | if (mmc) |
468 | mmc_free_host(mmc); | 470 | mmc_free_host(mmc); |
469 | 471 | ||
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index 95430b81ec11..6a7a61904833 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c | |||
@@ -224,7 +224,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host) | |||
224 | { | 224 | { |
225 | void __iomem *ctl = host->ctl; | 225 | void __iomem *ctl = host->ctl; |
226 | struct mmc_data *data = host->data; | 226 | struct mmc_data *data = host->data; |
227 | struct mmc_command *stop = data->stop; | 227 | struct mmc_command *stop; |
228 | 228 | ||
229 | host->data = NULL; | 229 | host->data = NULL; |
230 | 230 | ||
@@ -232,6 +232,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host) | |||
232 | pr_debug("Spurious data end IRQ\n"); | 232 | pr_debug("Spurious data end IRQ\n"); |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | stop = data->stop; | ||
235 | 236 | ||
236 | /* FIXME - return correct transfer count on errors */ | 237 | /* FIXME - return correct transfer count on errors */ |
237 | if (!data->error) | 238 | if (!data->error) |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index c7630a228310..ba0bd3d5775b 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -815,19 +815,20 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) | |||
815 | if (err) | 815 | if (err) |
816 | goto out_free; | 816 | goto out_free; |
817 | 817 | ||
818 | err = -ENOMEM; | ||
818 | ubi->peb_buf1 = vmalloc(ubi->peb_size); | 819 | ubi->peb_buf1 = vmalloc(ubi->peb_size); |
819 | if (!ubi->peb_buf1) | 820 | if (!ubi->peb_buf1) |
820 | goto out_free; | 821 | goto out_free; |
821 | 822 | ||
822 | ubi->peb_buf2 = vmalloc(ubi->peb_size); | 823 | ubi->peb_buf2 = vmalloc(ubi->peb_size); |
823 | if (!ubi->peb_buf2) | 824 | if (!ubi->peb_buf2) |
824 | goto out_free; | 825 | goto out_free; |
825 | 826 | ||
826 | #ifdef CONFIG_MTD_UBI_DEBUG | 827 | #ifdef CONFIG_MTD_UBI_DEBUG |
827 | mutex_init(&ubi->dbg_buf_mutex); | 828 | mutex_init(&ubi->dbg_buf_mutex); |
828 | ubi->dbg_peb_buf = vmalloc(ubi->peb_size); | 829 | ubi->dbg_peb_buf = vmalloc(ubi->peb_size); |
829 | if (!ubi->dbg_peb_buf) | 830 | if (!ubi->dbg_peb_buf) |
830 | goto out_free; | 831 | goto out_free; |
831 | #endif | 832 | #endif |
832 | 833 | ||
833 | err = attach_by_scanning(ubi); | 834 | err = attach_by_scanning(ubi); |
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index b30a0b83d7f1..98cf31ed0814 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -721,7 +721,8 @@ static int rename_volumes(struct ubi_device *ubi, | |||
721 | * It seems we need to remove volume with name @re->new_name, | 721 | * It seems we need to remove volume with name @re->new_name, |
722 | * if it exists. | 722 | * if it exists. |
723 | */ | 723 | */ |
724 | desc = ubi_open_volume_nm(ubi->ubi_num, re->new_name, UBI_EXCLUSIVE); | 724 | desc = ubi_open_volume_nm(ubi->ubi_num, re->new_name, |
725 | UBI_EXCLUSIVE); | ||
725 | if (IS_ERR(desc)) { | 726 | if (IS_ERR(desc)) { |
726 | err = PTR_ERR(desc); | 727 | err = PTR_ERR(desc); |
727 | if (err == -ENODEV) | 728 | if (err == -ENODEV) |
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 78e914d23ece..13777e5beac9 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -27,11 +27,11 @@ | |||
27 | #define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) | 27 | #define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) |
28 | 28 | ||
29 | #define ubi_assert(expr) do { \ | 29 | #define ubi_assert(expr) do { \ |
30 | if (unlikely(!(expr))) { \ | 30 | if (unlikely(!(expr))) { \ |
31 | printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ | 31 | printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ |
32 | __func__, __LINE__, current->pid); \ | 32 | __func__, __LINE__, current->pid); \ |
33 | ubi_dbg_dump_stack(); \ | 33 | ubi_dbg_dump_stack(); \ |
34 | } \ | 34 | } \ |
35 | } while (0) | 35 | } while (0) |
36 | 36 | ||
37 | #define dbg_msg(fmt, ...) \ | 37 | #define dbg_msg(fmt, ...) \ |
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index d8966bae0e0b..048a606cebde 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -504,12 +504,9 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, | |||
504 | if (!vid_hdr) | 504 | if (!vid_hdr) |
505 | return -ENOMEM; | 505 | return -ENOMEM; |
506 | 506 | ||
507 | mutex_lock(&ubi->buf_mutex); | ||
508 | |||
509 | retry: | 507 | retry: |
510 | new_pnum = ubi_wl_get_peb(ubi, UBI_UNKNOWN); | 508 | new_pnum = ubi_wl_get_peb(ubi, UBI_UNKNOWN); |
511 | if (new_pnum < 0) { | 509 | if (new_pnum < 0) { |
512 | mutex_unlock(&ubi->buf_mutex); | ||
513 | ubi_free_vid_hdr(ubi, vid_hdr); | 510 | ubi_free_vid_hdr(ubi, vid_hdr); |
514 | return new_pnum; | 511 | return new_pnum; |
515 | } | 512 | } |
@@ -529,20 +526,23 @@ retry: | |||
529 | goto write_error; | 526 | goto write_error; |
530 | 527 | ||
531 | data_size = offset + len; | 528 | data_size = offset + len; |
529 | mutex_lock(&ubi->buf_mutex); | ||
532 | memset(ubi->peb_buf1 + offset, 0xFF, len); | 530 | memset(ubi->peb_buf1 + offset, 0xFF, len); |
533 | 531 | ||
534 | /* Read everything before the area where the write failure happened */ | 532 | /* Read everything before the area where the write failure happened */ |
535 | if (offset > 0) { | 533 | if (offset > 0) { |
536 | err = ubi_io_read_data(ubi, ubi->peb_buf1, pnum, 0, offset); | 534 | err = ubi_io_read_data(ubi, ubi->peb_buf1, pnum, 0, offset); |
537 | if (err && err != UBI_IO_BITFLIPS) | 535 | if (err && err != UBI_IO_BITFLIPS) |
538 | goto out_put; | 536 | goto out_unlock; |
539 | } | 537 | } |
540 | 538 | ||
541 | memcpy(ubi->peb_buf1 + offset, buf, len); | 539 | memcpy(ubi->peb_buf1 + offset, buf, len); |
542 | 540 | ||
543 | err = ubi_io_write_data(ubi, ubi->peb_buf1, new_pnum, 0, data_size); | 541 | err = ubi_io_write_data(ubi, ubi->peb_buf1, new_pnum, 0, data_size); |
544 | if (err) | 542 | if (err) { |
543 | mutex_unlock(&ubi->buf_mutex); | ||
545 | goto write_error; | 544 | goto write_error; |
545 | } | ||
546 | 546 | ||
547 | mutex_unlock(&ubi->buf_mutex); | 547 | mutex_unlock(&ubi->buf_mutex); |
548 | ubi_free_vid_hdr(ubi, vid_hdr); | 548 | ubi_free_vid_hdr(ubi, vid_hdr); |
@@ -553,8 +553,9 @@ retry: | |||
553 | ubi_msg("data was successfully recovered"); | 553 | ubi_msg("data was successfully recovered"); |
554 | return 0; | 554 | return 0; |
555 | 555 | ||
556 | out_put: | 556 | out_unlock: |
557 | mutex_unlock(&ubi->buf_mutex); | 557 | mutex_unlock(&ubi->buf_mutex); |
558 | out_put: | ||
558 | ubi_wl_put_peb(ubi, new_pnum, 1); | 559 | ubi_wl_put_peb(ubi, new_pnum, 1); |
559 | ubi_free_vid_hdr(ubi, vid_hdr); | 560 | ubi_free_vid_hdr(ubi, vid_hdr); |
560 | return err; | 561 | return err; |
@@ -567,7 +568,6 @@ write_error: | |||
567 | ubi_warn("failed to write to PEB %d", new_pnum); | 568 | ubi_warn("failed to write to PEB %d", new_pnum); |
568 | ubi_wl_put_peb(ubi, new_pnum, 1); | 569 | ubi_wl_put_peb(ubi, new_pnum, 1); |
569 | if (++tries > UBI_IO_RETRIES) { | 570 | if (++tries > UBI_IO_RETRIES) { |
570 | mutex_unlock(&ubi->buf_mutex); | ||
571 | ubi_free_vid_hdr(ubi, vid_hdr); | 571 | ubi_free_vid_hdr(ubi, vid_hdr); |
572 | return err; | 572 | return err; |
573 | } | 573 | } |
@@ -949,10 +949,14 @@ write_error: | |||
949 | * This function copies logical eraseblock from physical eraseblock @from to | 949 | * This function copies logical eraseblock from physical eraseblock @from to |
950 | * physical eraseblock @to. The @vid_hdr buffer may be changed by this | 950 | * physical eraseblock @to. The @vid_hdr buffer may be changed by this |
951 | * function. Returns: | 951 | * function. Returns: |
952 | * o %0 in case of success; | 952 | * o %0 in case of success; |
953 | * o %1 if the operation was canceled and should be tried later (e.g., | 953 | * o %1 if the operation was canceled because the volume is being deleted |
954 | * because a bit-flip was detected at the target PEB); | 954 | * or because the PEB was put meanwhile; |
955 | * o %2 if the volume is being deleted and this LEB should not be moved. | 955 | * o %2 if the operation was canceled because there was a write error to the |
956 | * target PEB; | ||
957 | * o %-EAGAIN if the operation was canceled because a bit-flip was detected | ||
958 | * in the target PEB; | ||
959 | * o a negative error code in case of failure. | ||
956 | */ | 960 | */ |
957 | int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | 961 | int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, |
958 | struct ubi_vid_hdr *vid_hdr) | 962 | struct ubi_vid_hdr *vid_hdr) |
@@ -978,7 +982,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
978 | /* | 982 | /* |
979 | * Note, we may race with volume deletion, which means that the volume | 983 | * Note, we may race with volume deletion, which means that the volume |
980 | * this logical eraseblock belongs to might be being deleted. Since the | 984 | * this logical eraseblock belongs to might be being deleted. Since the |
981 | * volume deletion unmaps all the volume's logical eraseblocks, it will | 985 | * volume deletion un-maps all the volume's logical eraseblocks, it will |
982 | * be locked in 'ubi_wl_put_peb()' and wait for the WL worker to finish. | 986 | * be locked in 'ubi_wl_put_peb()' and wait for the WL worker to finish. |
983 | */ | 987 | */ |
984 | vol = ubi->volumes[idx]; | 988 | vol = ubi->volumes[idx]; |
@@ -986,7 +990,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
986 | /* No need to do further work, cancel */ | 990 | /* No need to do further work, cancel */ |
987 | dbg_eba("volume %d is being removed, cancel", vol_id); | 991 | dbg_eba("volume %d is being removed, cancel", vol_id); |
988 | spin_unlock(&ubi->volumes_lock); | 992 | spin_unlock(&ubi->volumes_lock); |
989 | return 2; | 993 | return 1; |
990 | } | 994 | } |
991 | spin_unlock(&ubi->volumes_lock); | 995 | spin_unlock(&ubi->volumes_lock); |
992 | 996 | ||
@@ -1023,7 +1027,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1023 | 1027 | ||
1024 | /* | 1028 | /* |
1025 | * OK, now the LEB is locked and we can safely start moving it. Since | 1029 | * OK, now the LEB is locked and we can safely start moving it. Since |
1026 | * this function utilizes thie @ubi->peb1_buf buffer which is shared | 1030 | * this function utilizes the @ubi->peb1_buf buffer which is shared |
1027 | * with some other functions, so lock the buffer by taking the | 1031 | * with some other functions, so lock the buffer by taking the |
1028 | * @ubi->buf_mutex. | 1032 | * @ubi->buf_mutex. |
1029 | */ | 1033 | */ |
@@ -1068,8 +1072,11 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1068 | vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi)); | 1072 | vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi)); |
1069 | 1073 | ||
1070 | err = ubi_io_write_vid_hdr(ubi, to, vid_hdr); | 1074 | err = ubi_io_write_vid_hdr(ubi, to, vid_hdr); |
1071 | if (err) | 1075 | if (err) { |
1076 | if (err == -EIO) | ||
1077 | err = 2; | ||
1072 | goto out_unlock_buf; | 1078 | goto out_unlock_buf; |
1079 | } | ||
1073 | 1080 | ||
1074 | cond_resched(); | 1081 | cond_resched(); |
1075 | 1082 | ||
@@ -1079,14 +1086,17 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1079 | if (err != UBI_IO_BITFLIPS) | 1086 | if (err != UBI_IO_BITFLIPS) |
1080 | ubi_warn("cannot read VID header back from PEB %d", to); | 1087 | ubi_warn("cannot read VID header back from PEB %d", to); |
1081 | else | 1088 | else |
1082 | err = 1; | 1089 | err = -EAGAIN; |
1083 | goto out_unlock_buf; | 1090 | goto out_unlock_buf; |
1084 | } | 1091 | } |
1085 | 1092 | ||
1086 | if (data_size > 0) { | 1093 | if (data_size > 0) { |
1087 | err = ubi_io_write_data(ubi, ubi->peb_buf1, to, 0, aldata_size); | 1094 | err = ubi_io_write_data(ubi, ubi->peb_buf1, to, 0, aldata_size); |
1088 | if (err) | 1095 | if (err) { |
1096 | if (err == -EIO) | ||
1097 | err = 2; | ||
1089 | goto out_unlock_buf; | 1098 | goto out_unlock_buf; |
1099 | } | ||
1090 | 1100 | ||
1091 | cond_resched(); | 1101 | cond_resched(); |
1092 | 1102 | ||
@@ -1101,15 +1111,16 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1101 | ubi_warn("cannot read data back from PEB %d", | 1111 | ubi_warn("cannot read data back from PEB %d", |
1102 | to); | 1112 | to); |
1103 | else | 1113 | else |
1104 | err = 1; | 1114 | err = -EAGAIN; |
1105 | goto out_unlock_buf; | 1115 | goto out_unlock_buf; |
1106 | } | 1116 | } |
1107 | 1117 | ||
1108 | cond_resched(); | 1118 | cond_resched(); |
1109 | 1119 | ||
1110 | if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) { | 1120 | if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) { |
1111 | ubi_warn("read data back from PEB %d - it is different", | 1121 | ubi_warn("read data back from PEB %d and it is " |
1112 | to); | 1122 | "different", to); |
1123 | err = -EINVAL; | ||
1113 | goto out_unlock_buf; | 1124 | goto out_unlock_buf; |
1114 | } | 1125 | } |
1115 | } | 1126 | } |
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 2fb64be44f1b..a74118c05745 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -637,8 +637,6 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
637 | 637 | ||
638 | dbg_io("read EC header from PEB %d", pnum); | 638 | dbg_io("read EC header from PEB %d", pnum); |
639 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); | 639 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); |
640 | if (UBI_IO_DEBUG) | ||
641 | verbose = 1; | ||
642 | 640 | ||
643 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); | 641 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); |
644 | if (err) { | 642 | if (err) { |
@@ -685,6 +683,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
685 | if (verbose) | 683 | if (verbose) |
686 | ubi_warn("no EC header found at PEB %d, " | 684 | ubi_warn("no EC header found at PEB %d, " |
687 | "only 0xFF bytes", pnum); | 685 | "only 0xFF bytes", pnum); |
686 | else if (UBI_IO_DEBUG) | ||
687 | dbg_msg("no EC header found at PEB %d, " | ||
688 | "only 0xFF bytes", pnum); | ||
688 | return UBI_IO_PEB_EMPTY; | 689 | return UBI_IO_PEB_EMPTY; |
689 | } | 690 | } |
690 | 691 | ||
@@ -696,7 +697,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
696 | ubi_warn("bad magic number at PEB %d: %08x instead of " | 697 | ubi_warn("bad magic number at PEB %d: %08x instead of " |
697 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); | 698 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); |
698 | ubi_dbg_dump_ec_hdr(ec_hdr); | 699 | ubi_dbg_dump_ec_hdr(ec_hdr); |
699 | } | 700 | } else if (UBI_IO_DEBUG) |
701 | dbg_msg("bad magic number at PEB %d: %08x instead of " | ||
702 | "%08x", pnum, magic, UBI_EC_HDR_MAGIC); | ||
700 | return UBI_IO_BAD_EC_HDR; | 703 | return UBI_IO_BAD_EC_HDR; |
701 | } | 704 | } |
702 | 705 | ||
@@ -708,7 +711,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
708 | ubi_warn("bad EC header CRC at PEB %d, calculated " | 711 | ubi_warn("bad EC header CRC at PEB %d, calculated " |
709 | "%#08x, read %#08x", pnum, crc, hdr_crc); | 712 | "%#08x, read %#08x", pnum, crc, hdr_crc); |
710 | ubi_dbg_dump_ec_hdr(ec_hdr); | 713 | ubi_dbg_dump_ec_hdr(ec_hdr); |
711 | } | 714 | } else if (UBI_IO_DEBUG) |
715 | dbg_msg("bad EC header CRC at PEB %d, calculated " | ||
716 | "%#08x, read %#08x", pnum, crc, hdr_crc); | ||
712 | return UBI_IO_BAD_EC_HDR; | 717 | return UBI_IO_BAD_EC_HDR; |
713 | } | 718 | } |
714 | 719 | ||
@@ -912,8 +917,6 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
912 | 917 | ||
913 | dbg_io("read VID header from PEB %d", pnum); | 918 | dbg_io("read VID header from PEB %d", pnum); |
914 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); | 919 | ubi_assert(pnum >= 0 && pnum < ubi->peb_count); |
915 | if (UBI_IO_DEBUG) | ||
916 | verbose = 1; | ||
917 | 920 | ||
918 | p = (char *)vid_hdr - ubi->vid_hdr_shift; | 921 | p = (char *)vid_hdr - ubi->vid_hdr_shift; |
919 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, | 922 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, |
@@ -960,6 +963,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
960 | if (verbose) | 963 | if (verbose) |
961 | ubi_warn("no VID header found at PEB %d, " | 964 | ubi_warn("no VID header found at PEB %d, " |
962 | "only 0xFF bytes", pnum); | 965 | "only 0xFF bytes", pnum); |
966 | else if (UBI_IO_DEBUG) | ||
967 | dbg_msg("no VID header found at PEB %d, " | ||
968 | "only 0xFF bytes", pnum); | ||
963 | return UBI_IO_PEB_FREE; | 969 | return UBI_IO_PEB_FREE; |
964 | } | 970 | } |
965 | 971 | ||
@@ -971,7 +977,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
971 | ubi_warn("bad magic number at PEB %d: %08x instead of " | 977 | ubi_warn("bad magic number at PEB %d: %08x instead of " |
972 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); | 978 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); |
973 | ubi_dbg_dump_vid_hdr(vid_hdr); | 979 | ubi_dbg_dump_vid_hdr(vid_hdr); |
974 | } | 980 | } else if (UBI_IO_DEBUG) |
981 | dbg_msg("bad magic number at PEB %d: %08x instead of " | ||
982 | "%08x", pnum, magic, UBI_VID_HDR_MAGIC); | ||
975 | return UBI_IO_BAD_VID_HDR; | 983 | return UBI_IO_BAD_VID_HDR; |
976 | } | 984 | } |
977 | 985 | ||
@@ -983,7 +991,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
983 | ubi_warn("bad CRC at PEB %d, calculated %#08x, " | 991 | ubi_warn("bad CRC at PEB %d, calculated %#08x, " |
984 | "read %#08x", pnum, crc, hdr_crc); | 992 | "read %#08x", pnum, crc, hdr_crc); |
985 | ubi_dbg_dump_vid_hdr(vid_hdr); | 993 | ubi_dbg_dump_vid_hdr(vid_hdr); |
986 | } | 994 | } else if (UBI_IO_DEBUG) |
995 | dbg_msg("bad CRC at PEB %d, calculated %#08x, " | ||
996 | "read %#08x", pnum, crc, hdr_crc); | ||
987 | return UBI_IO_BAD_VID_HDR; | 997 | return UBI_IO_BAD_VID_HDR; |
988 | } | 998 | } |
989 | 999 | ||
@@ -1024,7 +1034,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | |||
1024 | 1034 | ||
1025 | err = paranoid_check_peb_ec_hdr(ubi, pnum); | 1035 | err = paranoid_check_peb_ec_hdr(ubi, pnum); |
1026 | if (err) | 1036 | if (err) |
1027 | return err > 0 ? -EINVAL: err; | 1037 | return err > 0 ? -EINVAL : err; |
1028 | 1038 | ||
1029 | vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); | 1039 | vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); |
1030 | vid_hdr->version = UBI_VERSION; | 1040 | vid_hdr->version = UBI_VERSION; |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 1c3fa18c26a7..4a8ec485c91d 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -74,6 +74,13 @@ | |||
74 | #define UBI_IO_RETRIES 3 | 74 | #define UBI_IO_RETRIES 3 |
75 | 75 | ||
76 | /* | 76 | /* |
77 | * Length of the protection queue. The length is effectively equivalent to the | ||
78 | * number of (global) erase cycles PEBs are protected from the wear-leveling | ||
79 | * worker. | ||
80 | */ | ||
81 | #define UBI_PROT_QUEUE_LEN 10 | ||
82 | |||
83 | /* | ||
77 | * Error codes returned by the I/O sub-system. | 84 | * Error codes returned by the I/O sub-system. |
78 | * | 85 | * |
79 | * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only | 86 | * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only |
@@ -95,7 +102,8 @@ enum { | |||
95 | 102 | ||
96 | /** | 103 | /** |
97 | * struct ubi_wl_entry - wear-leveling entry. | 104 | * struct ubi_wl_entry - wear-leveling entry. |
98 | * @rb: link in the corresponding RB-tree | 105 | * @u.rb: link in the corresponding (free/used) RB-tree |
106 | * @u.list: link in the protection queue | ||
99 | * @ec: erase counter | 107 | * @ec: erase counter |
100 | * @pnum: physical eraseblock number | 108 | * @pnum: physical eraseblock number |
101 | * | 109 | * |
@@ -104,7 +112,10 @@ enum { | |||
104 | * RB-trees. See WL sub-system for details. | 112 | * RB-trees. See WL sub-system for details. |
105 | */ | 113 | */ |
106 | struct ubi_wl_entry { | 114 | struct ubi_wl_entry { |
107 | struct rb_node rb; | 115 | union { |
116 | struct rb_node rb; | ||
117 | struct list_head list; | ||
118 | } u; | ||
108 | int ec; | 119 | int ec; |
109 | int pnum; | 120 | int pnum; |
110 | }; | 121 | }; |
@@ -288,7 +299,7 @@ struct ubi_wl_entry; | |||
288 | * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling | 299 | * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling |
289 | * | 300 | * |
290 | * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end | 301 | * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end |
291 | * of UBI ititializetion | 302 | * of UBI initialization |
292 | * @vtbl_slots: how many slots are available in the volume table | 303 | * @vtbl_slots: how many slots are available in the volume table |
293 | * @vtbl_size: size of the volume table in bytes | 304 | * @vtbl_size: size of the volume table in bytes |
294 | * @vtbl: in-RAM volume table copy | 305 | * @vtbl: in-RAM volume table copy |
@@ -306,18 +317,17 @@ struct ubi_wl_entry; | |||
306 | * @used: RB-tree of used physical eraseblocks | 317 | * @used: RB-tree of used physical eraseblocks |
307 | * @free: RB-tree of free physical eraseblocks | 318 | * @free: RB-tree of free physical eraseblocks |
308 | * @scrub: RB-tree of physical eraseblocks which need scrubbing | 319 | * @scrub: RB-tree of physical eraseblocks which need scrubbing |
309 | * @prot: protection trees | 320 | * @pq: protection queue (contain physical eraseblocks which are temporarily |
310 | * @prot.pnum: protection tree indexed by physical eraseblock numbers | 321 | * protected from the wear-leveling worker) |
311 | * @prot.aec: protection tree indexed by absolute erase counter value | 322 | * @pq_head: protection queue head |
312 | * @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, | 323 | * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from, |
313 | * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works | 324 | * @move_to, @move_to_put @erase_pending, @wl_scheduled and @works |
314 | * fields | 325 | * fields |
315 | * @move_mutex: serializes eraseblock moves | 326 | * @move_mutex: serializes eraseblock moves |
316 | * @work_sem: sycnhronizes the WL worker with use tasks | 327 | * @work_sem: synchronizes the WL worker with use tasks |
317 | * @wl_scheduled: non-zero if the wear-leveling was scheduled | 328 | * @wl_scheduled: non-zero if the wear-leveling was scheduled |
318 | * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any | 329 | * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any |
319 | * physical eraseblock | 330 | * physical eraseblock |
320 | * @abs_ec: absolute erase counter | ||
321 | * @move_from: physical eraseblock from where the data is being moved | 331 | * @move_from: physical eraseblock from where the data is being moved |
322 | * @move_to: physical eraseblock where the data is being moved to | 332 | * @move_to: physical eraseblock where the data is being moved to |
323 | * @move_to_put: if the "to" PEB was put | 333 | * @move_to_put: if the "to" PEB was put |
@@ -351,11 +361,11 @@ struct ubi_wl_entry; | |||
351 | * | 361 | * |
352 | * @peb_buf1: a buffer of PEB size used for different purposes | 362 | * @peb_buf1: a buffer of PEB size used for different purposes |
353 | * @peb_buf2: another buffer of PEB size used for different purposes | 363 | * @peb_buf2: another buffer of PEB size used for different purposes |
354 | * @buf_mutex: proptects @peb_buf1 and @peb_buf2 | 364 | * @buf_mutex: protects @peb_buf1 and @peb_buf2 |
355 | * @ckvol_mutex: serializes static volume checking when opening | 365 | * @ckvol_mutex: serializes static volume checking when opening |
356 | * @mult_mutex: serializes operations on multiple volumes, like re-nameing | 366 | * @mult_mutex: serializes operations on multiple volumes, like re-naming |
357 | * @dbg_peb_buf: buffer of PEB size used for debugging | 367 | * @dbg_peb_buf: buffer of PEB size used for debugging |
358 | * @dbg_buf_mutex: proptects @dbg_peb_buf | 368 | * @dbg_buf_mutex: protects @dbg_peb_buf |
359 | */ | 369 | */ |
360 | struct ubi_device { | 370 | struct ubi_device { |
361 | struct cdev cdev; | 371 | struct cdev cdev; |
@@ -392,16 +402,13 @@ struct ubi_device { | |||
392 | struct rb_root used; | 402 | struct rb_root used; |
393 | struct rb_root free; | 403 | struct rb_root free; |
394 | struct rb_root scrub; | 404 | struct rb_root scrub; |
395 | struct { | 405 | struct list_head pq[UBI_PROT_QUEUE_LEN]; |
396 | struct rb_root pnum; | 406 | int pq_head; |
397 | struct rb_root aec; | ||
398 | } prot; | ||
399 | spinlock_t wl_lock; | 407 | spinlock_t wl_lock; |
400 | struct mutex move_mutex; | 408 | struct mutex move_mutex; |
401 | struct rw_semaphore work_sem; | 409 | struct rw_semaphore work_sem; |
402 | int wl_scheduled; | 410 | int wl_scheduled; |
403 | struct ubi_wl_entry **lookuptbl; | 411 | struct ubi_wl_entry **lookuptbl; |
404 | unsigned long long abs_ec; | ||
405 | struct ubi_wl_entry *move_from; | 412 | struct ubi_wl_entry *move_from; |
406 | struct ubi_wl_entry *move_to; | 413 | struct ubi_wl_entry *move_to; |
407 | int move_to_put; | 414 | int move_to_put; |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index dcb6dac1dc54..14901cb82c18 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * UBI wear-leveling sub-system. | 22 | * UBI wear-leveling sub-system. |
23 | * | 23 | * |
24 | * This sub-system is responsible for wear-leveling. It works in terms of | 24 | * This sub-system is responsible for wear-leveling. It works in terms of |
25 | * physical* eraseblocks and erase counters and knows nothing about logical | 25 | * physical eraseblocks and erase counters and knows nothing about logical |
26 | * eraseblocks, volumes, etc. From this sub-system's perspective all physical | 26 | * eraseblocks, volumes, etc. From this sub-system's perspective all physical |
27 | * eraseblocks are of two types - used and free. Used physical eraseblocks are | 27 | * eraseblocks are of two types - used and free. Used physical eraseblocks are |
28 | * those that were "get" by the 'ubi_wl_get_peb()' function, and free physical | 28 | * those that were "get" by the 'ubi_wl_get_peb()' function, and free physical |
@@ -55,8 +55,39 @@ | |||
55 | * | 55 | * |
56 | * As it was said, for the UBI sub-system all physical eraseblocks are either | 56 | * As it was said, for the UBI sub-system all physical eraseblocks are either |
57 | * "free" or "used". Free eraseblock are kept in the @wl->free RB-tree, while | 57 | * "free" or "used". Free eraseblock are kept in the @wl->free RB-tree, while |
58 | * used eraseblocks are kept in a set of different RB-trees: @wl->used, | 58 | * used eraseblocks are kept in @wl->used or @wl->scrub RB-trees, or |
59 | * @wl->prot.pnum, @wl->prot.aec, and @wl->scrub. | 59 | * (temporarily) in the @wl->pq queue. |
60 | * | ||
61 | * When the WL sub-system returns a physical eraseblock, the physical | ||
62 | * eraseblock is protected from being moved for some "time". For this reason, | ||
63 | * the physical eraseblock is not directly moved from the @wl->free tree to the | ||
64 | * @wl->used tree. There is a protection queue in between where this | ||
65 | * physical eraseblock is temporarily stored (@wl->pq). | ||
66 | * | ||
67 | * All this protection stuff is needed because: | ||
68 | * o we don't want to move physical eraseblocks just after we have given them | ||
69 | * to the user; instead, we first want to let users fill them up with data; | ||
70 | * | ||
71 | * o there is a chance that the user will put the physical eraseblock very | ||
72 | * soon, so it makes sense not to move it for some time, but wait; this is | ||
73 | * especially important in case of "short term" physical eraseblocks. | ||
74 | * | ||
75 | * Physical eraseblocks stay protected only for limited time. But the "time" is | ||
76 | * measured in erase cycles in this case. This is implemented with help of the | ||
77 | * protection queue. Eraseblocks are put to the tail of this queue when they | ||
78 | * are returned by the 'ubi_wl_get_peb()', and eraseblocks are removed from the | ||
79 | * head of the queue on each erase operation (for any eraseblock). So the | ||
80 | * length of the queue defines how may (global) erase cycles PEBs are protected. | ||
81 | * | ||
82 | * To put it differently, each physical eraseblock has 2 main states: free and | ||
83 | * used. The former state corresponds to the @wl->free tree. The latter state | ||
84 | * is split up on several sub-states: | ||
85 | * o the WL movement is allowed (@wl->used tree); | ||
86 | * o the WL movement is temporarily prohibited (@wl->pq queue); | ||
87 | * o scrubbing is needed (@wl->scrub tree). | ||
88 | * | ||
89 | * Depending on the sub-state, wear-leveling entries of the used physical | ||
90 | * eraseblocks may be kept in one of those structures. | ||
60 | * | 91 | * |
61 | * Note, in this implementation, we keep a small in-RAM object for each physical | 92 | * Note, in this implementation, we keep a small in-RAM object for each physical |
62 | * eraseblock. This is surely not a scalable solution. But it appears to be good | 93 | * eraseblock. This is surely not a scalable solution. But it appears to be good |
@@ -70,9 +101,6 @@ | |||
70 | * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we | 101 | * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we |
71 | * pick target PEB with an average EC if our PEB is not very "old". This is a | 102 | * pick target PEB with an average EC if our PEB is not very "old". This is a |
72 | * room for future re-works of the WL sub-system. | 103 | * room for future re-works of the WL sub-system. |
73 | * | ||
74 | * Note: the stuff with protection trees looks too complex and is difficult to | ||
75 | * understand. Should be fixed. | ||
76 | */ | 104 | */ |
77 | 105 | ||
78 | #include <linux/slab.h> | 106 | #include <linux/slab.h> |
@@ -85,14 +113,6 @@ | |||
85 | #define WL_RESERVED_PEBS 1 | 113 | #define WL_RESERVED_PEBS 1 |
86 | 114 | ||
87 | /* | 115 | /* |
88 | * How many erase cycles are short term, unknown, and long term physical | ||
89 | * eraseblocks protected. | ||
90 | */ | ||
91 | #define ST_PROTECTION 16 | ||
92 | #define U_PROTECTION 10 | ||
93 | #define LT_PROTECTION 4 | ||
94 | |||
95 | /* | ||
96 | * Maximum difference between two erase counters. If this threshold is | 116 | * Maximum difference between two erase counters. If this threshold is |
97 | * exceeded, the WL sub-system starts moving data from used physical | 117 | * exceeded, the WL sub-system starts moving data from used physical |
98 | * eraseblocks with low erase counter to free physical eraseblocks with high | 118 | * eraseblocks with low erase counter to free physical eraseblocks with high |
@@ -120,64 +140,9 @@ | |||
120 | #define WL_MAX_FAILURES 32 | 140 | #define WL_MAX_FAILURES 32 |
121 | 141 | ||
122 | /** | 142 | /** |
123 | * struct ubi_wl_prot_entry - PEB protection entry. | ||
124 | * @rb_pnum: link in the @wl->prot.pnum RB-tree | ||
125 | * @rb_aec: link in the @wl->prot.aec RB-tree | ||
126 | * @abs_ec: the absolute erase counter value when the protection ends | ||
127 | * @e: the wear-leveling entry of the physical eraseblock under protection | ||
128 | * | ||
129 | * When the WL sub-system returns a physical eraseblock, the physical | ||
130 | * eraseblock is protected from being moved for some "time". For this reason, | ||
131 | * the physical eraseblock is not directly moved from the @wl->free tree to the | ||
132 | * @wl->used tree. There is one more tree in between where this physical | ||
133 | * eraseblock is temporarily stored (@wl->prot). | ||
134 | * | ||
135 | * All this protection stuff is needed because: | ||
136 | * o we don't want to move physical eraseblocks just after we have given them | ||
137 | * to the user; instead, we first want to let users fill them up with data; | ||
138 | * | ||
139 | * o there is a chance that the user will put the physical eraseblock very | ||
140 | * soon, so it makes sense not to move it for some time, but wait; this is | ||
141 | * especially important in case of "short term" physical eraseblocks. | ||
142 | * | ||
143 | * Physical eraseblocks stay protected only for limited time. But the "time" is | ||
144 | * measured in erase cycles in this case. This is implemented with help of the | ||
145 | * absolute erase counter (@wl->abs_ec). When it reaches certain value, the | ||
146 | * physical eraseblocks are moved from the protection trees (@wl->prot.*) to | ||
147 | * the @wl->used tree. | ||
148 | * | ||
149 | * Protected physical eraseblocks are searched by physical eraseblock number | ||
150 | * (when they are put) and by the absolute erase counter (to check if it is | ||
151 | * time to move them to the @wl->used tree). So there are actually 2 RB-trees | ||
152 | * storing the protected physical eraseblocks: @wl->prot.pnum and | ||
153 | * @wl->prot.aec. They are referred to as the "protection" trees. The | ||
154 | * first one is indexed by the physical eraseblock number. The second one is | ||
155 | * indexed by the absolute erase counter. Both trees store | ||
156 | * &struct ubi_wl_prot_entry objects. | ||
157 | * | ||
158 | * Each physical eraseblock has 2 main states: free and used. The former state | ||
159 | * corresponds to the @wl->free tree. The latter state is split up on several | ||
160 | * sub-states: | ||
161 | * o the WL movement is allowed (@wl->used tree); | ||
162 | * o the WL movement is temporarily prohibited (@wl->prot.pnum and | ||
163 | * @wl->prot.aec trees); | ||
164 | * o scrubbing is needed (@wl->scrub tree). | ||
165 | * | ||
166 | * Depending on the sub-state, wear-leveling entries of the used physical | ||
167 | * eraseblocks may be kept in one of those trees. | ||
168 | */ | ||
169 | struct ubi_wl_prot_entry { | ||
170 | struct rb_node rb_pnum; | ||
171 | struct rb_node rb_aec; | ||
172 | unsigned long long abs_ec; | ||
173 | struct ubi_wl_entry *e; | ||
174 | }; | ||
175 | |||
176 | /** | ||
177 | * struct ubi_work - UBI work description data structure. | 143 | * struct ubi_work - UBI work description data structure. |
178 | * @list: a link in the list of pending works | 144 | * @list: a link in the list of pending works |
179 | * @func: worker function | 145 | * @func: worker function |
180 | * @priv: private data of the worker function | ||
181 | * @e: physical eraseblock to erase | 146 | * @e: physical eraseblock to erase |
182 | * @torture: if the physical eraseblock has to be tortured | 147 | * @torture: if the physical eraseblock has to be tortured |
183 | * | 148 | * |
@@ -198,9 +163,11 @@ struct ubi_work { | |||
198 | static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); | 163 | static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); |
199 | static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e, | 164 | static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e, |
200 | struct rb_root *root); | 165 | struct rb_root *root); |
166 | static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e); | ||
201 | #else | 167 | #else |
202 | #define paranoid_check_ec(ubi, pnum, ec) 0 | 168 | #define paranoid_check_ec(ubi, pnum, ec) 0 |
203 | #define paranoid_check_in_wl_tree(e, root) | 169 | #define paranoid_check_in_wl_tree(e, root) |
170 | #define paranoid_check_in_pq(ubi, e) 0 | ||
204 | #endif | 171 | #endif |
205 | 172 | ||
206 | /** | 173 | /** |
@@ -220,7 +187,7 @@ static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root) | |||
220 | struct ubi_wl_entry *e1; | 187 | struct ubi_wl_entry *e1; |
221 | 188 | ||
222 | parent = *p; | 189 | parent = *p; |
223 | e1 = rb_entry(parent, struct ubi_wl_entry, rb); | 190 | e1 = rb_entry(parent, struct ubi_wl_entry, u.rb); |
224 | 191 | ||
225 | if (e->ec < e1->ec) | 192 | if (e->ec < e1->ec) |
226 | p = &(*p)->rb_left; | 193 | p = &(*p)->rb_left; |
@@ -235,8 +202,8 @@ static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root) | |||
235 | } | 202 | } |
236 | } | 203 | } |
237 | 204 | ||
238 | rb_link_node(&e->rb, parent, p); | 205 | rb_link_node(&e->u.rb, parent, p); |
239 | rb_insert_color(&e->rb, root); | 206 | rb_insert_color(&e->u.rb, root); |
240 | } | 207 | } |
241 | 208 | ||
242 | /** | 209 | /** |
@@ -331,7 +298,7 @@ static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root) | |||
331 | while (p) { | 298 | while (p) { |
332 | struct ubi_wl_entry *e1; | 299 | struct ubi_wl_entry *e1; |
333 | 300 | ||
334 | e1 = rb_entry(p, struct ubi_wl_entry, rb); | 301 | e1 = rb_entry(p, struct ubi_wl_entry, u.rb); |
335 | 302 | ||
336 | if (e->pnum == e1->pnum) { | 303 | if (e->pnum == e1->pnum) { |
337 | ubi_assert(e == e1); | 304 | ubi_assert(e == e1); |
@@ -355,50 +322,24 @@ static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root) | |||
355 | } | 322 | } |
356 | 323 | ||
357 | /** | 324 | /** |
358 | * prot_tree_add - add physical eraseblock to protection trees. | 325 | * prot_queue_add - add physical eraseblock to the protection queue. |
359 | * @ubi: UBI device description object | 326 | * @ubi: UBI device description object |
360 | * @e: the physical eraseblock to add | 327 | * @e: the physical eraseblock to add |
361 | * @pe: protection entry object to use | ||
362 | * @abs_ec: absolute erase counter value when this physical eraseblock has | ||
363 | * to be removed from the protection trees. | ||
364 | * | 328 | * |
365 | * @wl->lock has to be locked. | 329 | * This function adds @e to the tail of the protection queue @ubi->pq, where |
330 | * @e will stay for %UBI_PROT_QUEUE_LEN erase operations and will be | ||
331 | * temporarily protected from the wear-leveling worker. Note, @wl->lock has to | ||
332 | * be locked. | ||
366 | */ | 333 | */ |
367 | static void prot_tree_add(struct ubi_device *ubi, struct ubi_wl_entry *e, | 334 | static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e) |
368 | struct ubi_wl_prot_entry *pe, int abs_ec) | ||
369 | { | 335 | { |
370 | struct rb_node **p, *parent = NULL; | 336 | int pq_tail = ubi->pq_head - 1; |
371 | struct ubi_wl_prot_entry *pe1; | ||
372 | |||
373 | pe->e = e; | ||
374 | pe->abs_ec = ubi->abs_ec + abs_ec; | ||
375 | |||
376 | p = &ubi->prot.pnum.rb_node; | ||
377 | while (*p) { | ||
378 | parent = *p; | ||
379 | pe1 = rb_entry(parent, struct ubi_wl_prot_entry, rb_pnum); | ||
380 | |||
381 | if (e->pnum < pe1->e->pnum) | ||
382 | p = &(*p)->rb_left; | ||
383 | else | ||
384 | p = &(*p)->rb_right; | ||
385 | } | ||
386 | rb_link_node(&pe->rb_pnum, parent, p); | ||
387 | rb_insert_color(&pe->rb_pnum, &ubi->prot.pnum); | ||
388 | |||
389 | p = &ubi->prot.aec.rb_node; | ||
390 | parent = NULL; | ||
391 | while (*p) { | ||
392 | parent = *p; | ||
393 | pe1 = rb_entry(parent, struct ubi_wl_prot_entry, rb_aec); | ||
394 | 337 | ||
395 | if (pe->abs_ec < pe1->abs_ec) | 338 | if (pq_tail < 0) |
396 | p = &(*p)->rb_left; | 339 | pq_tail = UBI_PROT_QUEUE_LEN - 1; |
397 | else | 340 | ubi_assert(pq_tail >= 0 && pq_tail < UBI_PROT_QUEUE_LEN); |
398 | p = &(*p)->rb_right; | 341 | list_add_tail(&e->u.list, &ubi->pq[pq_tail]); |
399 | } | 342 | dbg_wl("added PEB %d EC %d to the protection queue", e->pnum, e->ec); |
400 | rb_link_node(&pe->rb_aec, parent, p); | ||
401 | rb_insert_color(&pe->rb_aec, &ubi->prot.aec); | ||
402 | } | 343 | } |
403 | 344 | ||
404 | /** | 345 | /** |
@@ -414,14 +355,14 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max) | |||
414 | struct rb_node *p; | 355 | struct rb_node *p; |
415 | struct ubi_wl_entry *e; | 356 | struct ubi_wl_entry *e; |
416 | 357 | ||
417 | e = rb_entry(rb_first(root), struct ubi_wl_entry, rb); | 358 | e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb); |
418 | max += e->ec; | 359 | max += e->ec; |
419 | 360 | ||
420 | p = root->rb_node; | 361 | p = root->rb_node; |
421 | while (p) { | 362 | while (p) { |
422 | struct ubi_wl_entry *e1; | 363 | struct ubi_wl_entry *e1; |
423 | 364 | ||
424 | e1 = rb_entry(p, struct ubi_wl_entry, rb); | 365 | e1 = rb_entry(p, struct ubi_wl_entry, u.rb); |
425 | if (e1->ec >= max) | 366 | if (e1->ec >= max) |
426 | p = p->rb_left; | 367 | p = p->rb_left; |
427 | else { | 368 | else { |
@@ -443,17 +384,12 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max) | |||
443 | */ | 384 | */ |
444 | int ubi_wl_get_peb(struct ubi_device *ubi, int dtype) | 385 | int ubi_wl_get_peb(struct ubi_device *ubi, int dtype) |
445 | { | 386 | { |
446 | int err, protect, medium_ec; | 387 | int err, medium_ec; |
447 | struct ubi_wl_entry *e, *first, *last; | 388 | struct ubi_wl_entry *e, *first, *last; |
448 | struct ubi_wl_prot_entry *pe; | ||
449 | 389 | ||
450 | ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM || | 390 | ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM || |
451 | dtype == UBI_UNKNOWN); | 391 | dtype == UBI_UNKNOWN); |
452 | 392 | ||
453 | pe = kmalloc(sizeof(struct ubi_wl_prot_entry), GFP_NOFS); | ||
454 | if (!pe) | ||
455 | return -ENOMEM; | ||
456 | |||
457 | retry: | 393 | retry: |
458 | spin_lock(&ubi->wl_lock); | 394 | spin_lock(&ubi->wl_lock); |
459 | if (!ubi->free.rb_node) { | 395 | if (!ubi->free.rb_node) { |
@@ -461,16 +397,13 @@ retry: | |||
461 | ubi_assert(list_empty(&ubi->works)); | 397 | ubi_assert(list_empty(&ubi->works)); |
462 | ubi_err("no free eraseblocks"); | 398 | ubi_err("no free eraseblocks"); |
463 | spin_unlock(&ubi->wl_lock); | 399 | spin_unlock(&ubi->wl_lock); |
464 | kfree(pe); | ||
465 | return -ENOSPC; | 400 | return -ENOSPC; |
466 | } | 401 | } |
467 | spin_unlock(&ubi->wl_lock); | 402 | spin_unlock(&ubi->wl_lock); |
468 | 403 | ||
469 | err = produce_free_peb(ubi); | 404 | err = produce_free_peb(ubi); |
470 | if (err < 0) { | 405 | if (err < 0) |
471 | kfree(pe); | ||
472 | return err; | 406 | return err; |
473 | } | ||
474 | goto retry; | 407 | goto retry; |
475 | } | 408 | } |
476 | 409 | ||
@@ -483,7 +416,6 @@ retry: | |||
483 | * %WL_FREE_MAX_DIFF. | 416 | * %WL_FREE_MAX_DIFF. |
484 | */ | 417 | */ |
485 | e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); | 418 | e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); |
486 | protect = LT_PROTECTION; | ||
487 | break; | 419 | break; |
488 | case UBI_UNKNOWN: | 420 | case UBI_UNKNOWN: |
489 | /* | 421 | /* |
@@ -492,81 +424,63 @@ retry: | |||
492 | * eraseblock with erase counter greater or equivalent than the | 424 | * eraseblock with erase counter greater or equivalent than the |
493 | * lowest erase counter plus %WL_FREE_MAX_DIFF. | 425 | * lowest erase counter plus %WL_FREE_MAX_DIFF. |
494 | */ | 426 | */ |
495 | first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb); | 427 | first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, |
496 | last = rb_entry(rb_last(&ubi->free), struct ubi_wl_entry, rb); | 428 | u.rb); |
429 | last = rb_entry(rb_last(&ubi->free), struct ubi_wl_entry, u.rb); | ||
497 | 430 | ||
498 | if (last->ec - first->ec < WL_FREE_MAX_DIFF) | 431 | if (last->ec - first->ec < WL_FREE_MAX_DIFF) |
499 | e = rb_entry(ubi->free.rb_node, | 432 | e = rb_entry(ubi->free.rb_node, |
500 | struct ubi_wl_entry, rb); | 433 | struct ubi_wl_entry, u.rb); |
501 | else { | 434 | else { |
502 | medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2; | 435 | medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2; |
503 | e = find_wl_entry(&ubi->free, medium_ec); | 436 | e = find_wl_entry(&ubi->free, medium_ec); |
504 | } | 437 | } |
505 | protect = U_PROTECTION; | ||
506 | break; | 438 | break; |
507 | case UBI_SHORTTERM: | 439 | case UBI_SHORTTERM: |
508 | /* | 440 | /* |
509 | * For short term data we pick a physical eraseblock with the | 441 | * For short term data we pick a physical eraseblock with the |
510 | * lowest erase counter as we expect it will be erased soon. | 442 | * lowest erase counter as we expect it will be erased soon. |
511 | */ | 443 | */ |
512 | e = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb); | 444 | e = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, u.rb); |
513 | protect = ST_PROTECTION; | ||
514 | break; | 445 | break; |
515 | default: | 446 | default: |
516 | protect = 0; | ||
517 | e = NULL; | ||
518 | BUG(); | 447 | BUG(); |
519 | } | 448 | } |
520 | 449 | ||
450 | paranoid_check_in_wl_tree(e, &ubi->free); | ||
451 | |||
521 | /* | 452 | /* |
522 | * Move the physical eraseblock to the protection trees where it will | 453 | * Move the physical eraseblock to the protection queue where it will |
523 | * be protected from being moved for some time. | 454 | * be protected from being moved for some time. |
524 | */ | 455 | */ |
525 | paranoid_check_in_wl_tree(e, &ubi->free); | 456 | rb_erase(&e->u.rb, &ubi->free); |
526 | rb_erase(&e->rb, &ubi->free); | 457 | dbg_wl("PEB %d EC %d", e->pnum, e->ec); |
527 | prot_tree_add(ubi, e, pe, protect); | 458 | prot_queue_add(ubi, e); |
528 | |||
529 | dbg_wl("PEB %d EC %d, protection %d", e->pnum, e->ec, protect); | ||
530 | spin_unlock(&ubi->wl_lock); | 459 | spin_unlock(&ubi->wl_lock); |
531 | |||
532 | return e->pnum; | 460 | return e->pnum; |
533 | } | 461 | } |
534 | 462 | ||
535 | /** | 463 | /** |
536 | * prot_tree_del - remove a physical eraseblock from the protection trees | 464 | * prot_queue_del - remove a physical eraseblock from the protection queue. |
537 | * @ubi: UBI device description object | 465 | * @ubi: UBI device description object |
538 | * @pnum: the physical eraseblock to remove | 466 | * @pnum: the physical eraseblock to remove |
539 | * | 467 | * |
540 | * This function returns PEB @pnum from the protection trees and returns zero | 468 | * This function deletes PEB @pnum from the protection queue and returns zero |
541 | * in case of success and %-ENODEV if the PEB was not found in the protection | 469 | * in case of success and %-ENODEV if the PEB was not found. |
542 | * trees. | ||
543 | */ | 470 | */ |
544 | static int prot_tree_del(struct ubi_device *ubi, int pnum) | 471 | static int prot_queue_del(struct ubi_device *ubi, int pnum) |
545 | { | 472 | { |
546 | struct rb_node *p; | 473 | struct ubi_wl_entry *e; |
547 | struct ubi_wl_prot_entry *pe = NULL; | ||
548 | |||
549 | p = ubi->prot.pnum.rb_node; | ||
550 | while (p) { | ||
551 | |||
552 | pe = rb_entry(p, struct ubi_wl_prot_entry, rb_pnum); | ||
553 | |||
554 | if (pnum == pe->e->pnum) | ||
555 | goto found; | ||
556 | 474 | ||
557 | if (pnum < pe->e->pnum) | 475 | e = ubi->lookuptbl[pnum]; |
558 | p = p->rb_left; | 476 | if (!e) |
559 | else | 477 | return -ENODEV; |
560 | p = p->rb_right; | ||
561 | } | ||
562 | 478 | ||
563 | return -ENODEV; | 479 | if (paranoid_check_in_pq(ubi, e)) |
480 | return -ENODEV; | ||
564 | 481 | ||
565 | found: | 482 | list_del(&e->u.list); |
566 | ubi_assert(pe->e->pnum == pnum); | 483 | dbg_wl("deleted PEB %d from the protection queue", e->pnum); |
567 | rb_erase(&pe->rb_aec, &ubi->prot.aec); | ||
568 | rb_erase(&pe->rb_pnum, &ubi->prot.pnum); | ||
569 | kfree(pe); | ||
570 | return 0; | 484 | return 0; |
571 | } | 485 | } |
572 | 486 | ||
@@ -632,47 +546,47 @@ out_free: | |||
632 | } | 546 | } |
633 | 547 | ||
634 | /** | 548 | /** |
635 | * check_protection_over - check if it is time to stop protecting some PEBs. | 549 | * serve_prot_queue - check if it is time to stop protecting PEBs. |
636 | * @ubi: UBI device description object | 550 | * @ubi: UBI device description object |
637 | * | 551 | * |
638 | * This function is called after each erase operation, when the absolute erase | 552 | * This function is called after each erase operation and removes PEBs from the |
639 | * counter is incremented, to check if some physical eraseblock have not to be | 553 | * tail of the protection queue. These PEBs have been protected for long enough |
640 | * protected any longer. These physical eraseblocks are moved from the | 554 | * and should be moved to the used tree. |
641 | * protection trees to the used tree. | ||
642 | */ | 555 | */ |
643 | static void check_protection_over(struct ubi_device *ubi) | 556 | static void serve_prot_queue(struct ubi_device *ubi) |
644 | { | 557 | { |
645 | struct ubi_wl_prot_entry *pe; | 558 | struct ubi_wl_entry *e, *tmp; |
559 | int count; | ||
646 | 560 | ||
647 | /* | 561 | /* |
648 | * There may be several protected physical eraseblock to remove, | 562 | * There may be several protected physical eraseblock to remove, |
649 | * process them all. | 563 | * process them all. |
650 | */ | 564 | */ |
651 | while (1) { | 565 | repeat: |
652 | spin_lock(&ubi->wl_lock); | 566 | count = 0; |
653 | if (!ubi->prot.aec.rb_node) { | 567 | spin_lock(&ubi->wl_lock); |
654 | spin_unlock(&ubi->wl_lock); | 568 | list_for_each_entry_safe(e, tmp, &ubi->pq[ubi->pq_head], u.list) { |
655 | break; | 569 | dbg_wl("PEB %d EC %d protection over, move to used tree", |
656 | } | 570 | e->pnum, e->ec); |
657 | |||
658 | pe = rb_entry(rb_first(&ubi->prot.aec), | ||
659 | struct ubi_wl_prot_entry, rb_aec); | ||
660 | 571 | ||
661 | if (pe->abs_ec > ubi->abs_ec) { | 572 | list_del(&e->u.list); |
573 | wl_tree_add(e, &ubi->used); | ||
574 | if (count++ > 32) { | ||
575 | /* | ||
576 | * Let's be nice and avoid holding the spinlock for | ||
577 | * too long. | ||
578 | */ | ||
662 | spin_unlock(&ubi->wl_lock); | 579 | spin_unlock(&ubi->wl_lock); |
663 | break; | 580 | cond_resched(); |
581 | goto repeat; | ||
664 | } | 582 | } |
665 | |||
666 | dbg_wl("PEB %d protection over, abs_ec %llu, PEB abs_ec %llu", | ||
667 | pe->e->pnum, ubi->abs_ec, pe->abs_ec); | ||
668 | rb_erase(&pe->rb_aec, &ubi->prot.aec); | ||
669 | rb_erase(&pe->rb_pnum, &ubi->prot.pnum); | ||
670 | wl_tree_add(pe->e, &ubi->used); | ||
671 | spin_unlock(&ubi->wl_lock); | ||
672 | |||
673 | kfree(pe); | ||
674 | cond_resched(); | ||
675 | } | 583 | } |
584 | |||
585 | ubi->pq_head += 1; | ||
586 | if (ubi->pq_head == UBI_PROT_QUEUE_LEN) | ||
587 | ubi->pq_head = 0; | ||
588 | ubi_assert(ubi->pq_head >= 0 && ubi->pq_head < UBI_PROT_QUEUE_LEN); | ||
589 | spin_unlock(&ubi->wl_lock); | ||
676 | } | 590 | } |
677 | 591 | ||
678 | /** | 592 | /** |
@@ -680,8 +594,8 @@ static void check_protection_over(struct ubi_device *ubi) | |||
680 | * @ubi: UBI device description object | 594 | * @ubi: UBI device description object |
681 | * @wrk: the work to schedule | 595 | * @wrk: the work to schedule |
682 | * | 596 | * |
683 | * This function enqueues a work defined by @wrk to the tail of the pending | 597 | * This function adds a work defined by @wrk to the tail of the pending works |
684 | * works list. | 598 | * list. |
685 | */ | 599 | */ |
686 | static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk) | 600 | static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk) |
687 | { | 601 | { |
@@ -739,13 +653,11 @@ static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, | |||
739 | static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | 653 | static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, |
740 | int cancel) | 654 | int cancel) |
741 | { | 655 | { |
742 | int err, put = 0, scrubbing = 0, protect = 0; | 656 | int err, scrubbing = 0, torture = 0; |
743 | struct ubi_wl_prot_entry *uninitialized_var(pe); | ||
744 | struct ubi_wl_entry *e1, *e2; | 657 | struct ubi_wl_entry *e1, *e2; |
745 | struct ubi_vid_hdr *vid_hdr; | 658 | struct ubi_vid_hdr *vid_hdr; |
746 | 659 | ||
747 | kfree(wrk); | 660 | kfree(wrk); |
748 | |||
749 | if (cancel) | 661 | if (cancel) |
750 | return 0; | 662 | return 0; |
751 | 663 | ||
@@ -781,7 +693,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
781 | * highly worn-out free physical eraseblock. If the erase | 693 | * highly worn-out free physical eraseblock. If the erase |
782 | * counters differ much enough, start wear-leveling. | 694 | * counters differ much enough, start wear-leveling. |
783 | */ | 695 | */ |
784 | e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, rb); | 696 | e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb); |
785 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); | 697 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); |
786 | 698 | ||
787 | if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) { | 699 | if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) { |
@@ -790,21 +702,21 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
790 | goto out_cancel; | 702 | goto out_cancel; |
791 | } | 703 | } |
792 | paranoid_check_in_wl_tree(e1, &ubi->used); | 704 | paranoid_check_in_wl_tree(e1, &ubi->used); |
793 | rb_erase(&e1->rb, &ubi->used); | 705 | rb_erase(&e1->u.rb, &ubi->used); |
794 | dbg_wl("move PEB %d EC %d to PEB %d EC %d", | 706 | dbg_wl("move PEB %d EC %d to PEB %d EC %d", |
795 | e1->pnum, e1->ec, e2->pnum, e2->ec); | 707 | e1->pnum, e1->ec, e2->pnum, e2->ec); |
796 | } else { | 708 | } else { |
797 | /* Perform scrubbing */ | 709 | /* Perform scrubbing */ |
798 | scrubbing = 1; | 710 | scrubbing = 1; |
799 | e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, rb); | 711 | e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, u.rb); |
800 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); | 712 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); |
801 | paranoid_check_in_wl_tree(e1, &ubi->scrub); | 713 | paranoid_check_in_wl_tree(e1, &ubi->scrub); |
802 | rb_erase(&e1->rb, &ubi->scrub); | 714 | rb_erase(&e1->u.rb, &ubi->scrub); |
803 | dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum); | 715 | dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum); |
804 | } | 716 | } |
805 | 717 | ||
806 | paranoid_check_in_wl_tree(e2, &ubi->free); | 718 | paranoid_check_in_wl_tree(e2, &ubi->free); |
807 | rb_erase(&e2->rb, &ubi->free); | 719 | rb_erase(&e2->u.rb, &ubi->free); |
808 | ubi->move_from = e1; | 720 | ubi->move_from = e1; |
809 | ubi->move_to = e2; | 721 | ubi->move_to = e2; |
810 | spin_unlock(&ubi->wl_lock); | 722 | spin_unlock(&ubi->wl_lock); |
@@ -844,46 +756,67 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
844 | 756 | ||
845 | err = ubi_eba_copy_leb(ubi, e1->pnum, e2->pnum, vid_hdr); | 757 | err = ubi_eba_copy_leb(ubi, e1->pnum, e2->pnum, vid_hdr); |
846 | if (err) { | 758 | if (err) { |
847 | 759 | if (err == -EAGAIN) | |
760 | goto out_not_moved; | ||
848 | if (err < 0) | 761 | if (err < 0) |
849 | goto out_error; | 762 | goto out_error; |
850 | if (err == 1) | 763 | if (err == 2) { |
764 | /* Target PEB write error, torture it */ | ||
765 | torture = 1; | ||
851 | goto out_not_moved; | 766 | goto out_not_moved; |
767 | } | ||
852 | 768 | ||
853 | /* | 769 | /* |
854 | * For some reason the LEB was not moved - it might be because | 770 | * The LEB has not been moved because the volume is being |
855 | * the volume is being deleted. We should prevent this PEB from | 771 | * deleted or the PEB has been put meanwhile. We should prevent |
856 | * being selected for wear-levelling movement for some "time", | 772 | * this PEB from being selected for wear-leveling movement |
857 | * so put it to the protection tree. | 773 | * again, so put it to the protection queue. |
858 | */ | 774 | */ |
859 | 775 | ||
860 | dbg_wl("cancelled moving PEB %d", e1->pnum); | 776 | dbg_wl("canceled moving PEB %d", e1->pnum); |
861 | pe = kmalloc(sizeof(struct ubi_wl_prot_entry), GFP_NOFS); | 777 | ubi_assert(err == 1); |
862 | if (!pe) { | 778 | |
863 | err = -ENOMEM; | 779 | ubi_free_vid_hdr(ubi, vid_hdr); |
864 | goto out_error; | 780 | vid_hdr = NULL; |
865 | } | 781 | |
782 | spin_lock(&ubi->wl_lock); | ||
783 | prot_queue_add(ubi, e1); | ||
784 | ubi_assert(!ubi->move_to_put); | ||
785 | ubi->move_from = ubi->move_to = NULL; | ||
786 | ubi->wl_scheduled = 0; | ||
787 | spin_unlock(&ubi->wl_lock); | ||
866 | 788 | ||
867 | protect = 1; | 789 | e1 = NULL; |
790 | err = schedule_erase(ubi, e2, 0); | ||
791 | if (err) | ||
792 | goto out_error; | ||
793 | mutex_unlock(&ubi->move_mutex); | ||
794 | return 0; | ||
868 | } | 795 | } |
869 | 796 | ||
797 | /* The PEB has been successfully moved */ | ||
870 | ubi_free_vid_hdr(ubi, vid_hdr); | 798 | ubi_free_vid_hdr(ubi, vid_hdr); |
871 | if (scrubbing && !protect) | 799 | vid_hdr = NULL; |
800 | if (scrubbing) | ||
872 | ubi_msg("scrubbed PEB %d, data moved to PEB %d", | 801 | ubi_msg("scrubbed PEB %d, data moved to PEB %d", |
873 | e1->pnum, e2->pnum); | 802 | e1->pnum, e2->pnum); |
874 | 803 | ||
875 | spin_lock(&ubi->wl_lock); | 804 | spin_lock(&ubi->wl_lock); |
876 | if (protect) | 805 | if (!ubi->move_to_put) { |
877 | prot_tree_add(ubi, e1, pe, protect); | ||
878 | if (!ubi->move_to_put) | ||
879 | wl_tree_add(e2, &ubi->used); | 806 | wl_tree_add(e2, &ubi->used); |
880 | else | 807 | e2 = NULL; |
881 | put = 1; | 808 | } |
882 | ubi->move_from = ubi->move_to = NULL; | 809 | ubi->move_from = ubi->move_to = NULL; |
883 | ubi->move_to_put = ubi->wl_scheduled = 0; | 810 | ubi->move_to_put = ubi->wl_scheduled = 0; |
884 | spin_unlock(&ubi->wl_lock); | 811 | spin_unlock(&ubi->wl_lock); |
885 | 812 | ||
886 | if (put) { | 813 | err = schedule_erase(ubi, e1, 0); |
814 | if (err) { | ||
815 | e1 = NULL; | ||
816 | goto out_error; | ||
817 | } | ||
818 | |||
819 | if (e2) { | ||
887 | /* | 820 | /* |
888 | * Well, the target PEB was put meanwhile, schedule it for | 821 | * Well, the target PEB was put meanwhile, schedule it for |
889 | * erasure. | 822 | * erasure. |
@@ -894,13 +827,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
894 | goto out_error; | 827 | goto out_error; |
895 | } | 828 | } |
896 | 829 | ||
897 | if (!protect) { | ||
898 | err = schedule_erase(ubi, e1, 0); | ||
899 | if (err) | ||
900 | goto out_error; | ||
901 | } | ||
902 | |||
903 | |||
904 | dbg_wl("done"); | 830 | dbg_wl("done"); |
905 | mutex_unlock(&ubi->move_mutex); | 831 | mutex_unlock(&ubi->move_mutex); |
906 | return 0; | 832 | return 0; |
@@ -908,20 +834,24 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
908 | /* | 834 | /* |
909 | * For some reasons the LEB was not moved, might be an error, might be | 835 | * For some reasons the LEB was not moved, might be an error, might be |
910 | * something else. @e1 was not changed, so return it back. @e2 might | 836 | * something else. @e1 was not changed, so return it back. @e2 might |
911 | * be changed, schedule it for erasure. | 837 | * have been changed, schedule it for erasure. |
912 | */ | 838 | */ |
913 | out_not_moved: | 839 | out_not_moved: |
840 | dbg_wl("canceled moving PEB %d", e1->pnum); | ||
914 | ubi_free_vid_hdr(ubi, vid_hdr); | 841 | ubi_free_vid_hdr(ubi, vid_hdr); |
842 | vid_hdr = NULL; | ||
915 | spin_lock(&ubi->wl_lock); | 843 | spin_lock(&ubi->wl_lock); |
916 | if (scrubbing) | 844 | if (scrubbing) |
917 | wl_tree_add(e1, &ubi->scrub); | 845 | wl_tree_add(e1, &ubi->scrub); |
918 | else | 846 | else |
919 | wl_tree_add(e1, &ubi->used); | 847 | wl_tree_add(e1, &ubi->used); |
848 | ubi_assert(!ubi->move_to_put); | ||
920 | ubi->move_from = ubi->move_to = NULL; | 849 | ubi->move_from = ubi->move_to = NULL; |
921 | ubi->move_to_put = ubi->wl_scheduled = 0; | 850 | ubi->wl_scheduled = 0; |
922 | spin_unlock(&ubi->wl_lock); | 851 | spin_unlock(&ubi->wl_lock); |
923 | 852 | ||
924 | err = schedule_erase(ubi, e2, 0); | 853 | e1 = NULL; |
854 | err = schedule_erase(ubi, e2, torture); | ||
925 | if (err) | 855 | if (err) |
926 | goto out_error; | 856 | goto out_error; |
927 | 857 | ||
@@ -938,8 +868,10 @@ out_error: | |||
938 | ubi->move_to_put = ubi->wl_scheduled = 0; | 868 | ubi->move_to_put = ubi->wl_scheduled = 0; |
939 | spin_unlock(&ubi->wl_lock); | 869 | spin_unlock(&ubi->wl_lock); |
940 | 870 | ||
941 | kmem_cache_free(ubi_wl_entry_slab, e1); | 871 | if (e1) |
942 | kmem_cache_free(ubi_wl_entry_slab, e2); | 872 | kmem_cache_free(ubi_wl_entry_slab, e1); |
873 | if (e2) | ||
874 | kmem_cache_free(ubi_wl_entry_slab, e2); | ||
943 | ubi_ro_mode(ubi); | 875 | ubi_ro_mode(ubi); |
944 | 876 | ||
945 | mutex_unlock(&ubi->move_mutex); | 877 | mutex_unlock(&ubi->move_mutex); |
@@ -988,7 +920,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi) | |||
988 | * erase counter of free physical eraseblocks is greater then | 920 | * erase counter of free physical eraseblocks is greater then |
989 | * %UBI_WL_THRESHOLD. | 921 | * %UBI_WL_THRESHOLD. |
990 | */ | 922 | */ |
991 | e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, rb); | 923 | e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb); |
992 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); | 924 | e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); |
993 | 925 | ||
994 | if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) | 926 | if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) |
@@ -1050,7 +982,6 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, | |||
1050 | kfree(wl_wrk); | 982 | kfree(wl_wrk); |
1051 | 983 | ||
1052 | spin_lock(&ubi->wl_lock); | 984 | spin_lock(&ubi->wl_lock); |
1053 | ubi->abs_ec += 1; | ||
1054 | wl_tree_add(e, &ubi->free); | 985 | wl_tree_add(e, &ubi->free); |
1055 | spin_unlock(&ubi->wl_lock); | 986 | spin_unlock(&ubi->wl_lock); |
1056 | 987 | ||
@@ -1058,7 +989,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, | |||
1058 | * One more erase operation has happened, take care about | 989 | * One more erase operation has happened, take care about |
1059 | * protected physical eraseblocks. | 990 | * protected physical eraseblocks. |
1060 | */ | 991 | */ |
1061 | check_protection_over(ubi); | 992 | serve_prot_queue(ubi); |
1062 | 993 | ||
1063 | /* And take care about wear-leveling */ | 994 | /* And take care about wear-leveling */ |
1064 | err = ensure_wear_leveling(ubi); | 995 | err = ensure_wear_leveling(ubi); |
@@ -1190,12 +1121,12 @@ retry: | |||
1190 | } else { | 1121 | } else { |
1191 | if (in_wl_tree(e, &ubi->used)) { | 1122 | if (in_wl_tree(e, &ubi->used)) { |
1192 | paranoid_check_in_wl_tree(e, &ubi->used); | 1123 | paranoid_check_in_wl_tree(e, &ubi->used); |
1193 | rb_erase(&e->rb, &ubi->used); | 1124 | rb_erase(&e->u.rb, &ubi->used); |
1194 | } else if (in_wl_tree(e, &ubi->scrub)) { | 1125 | } else if (in_wl_tree(e, &ubi->scrub)) { |
1195 | paranoid_check_in_wl_tree(e, &ubi->scrub); | 1126 | paranoid_check_in_wl_tree(e, &ubi->scrub); |
1196 | rb_erase(&e->rb, &ubi->scrub); | 1127 | rb_erase(&e->u.rb, &ubi->scrub); |
1197 | } else { | 1128 | } else { |
1198 | err = prot_tree_del(ubi, e->pnum); | 1129 | err = prot_queue_del(ubi, e->pnum); |
1199 | if (err) { | 1130 | if (err) { |
1200 | ubi_err("PEB %d not found", pnum); | 1131 | ubi_err("PEB %d not found", pnum); |
1201 | ubi_ro_mode(ubi); | 1132 | ubi_ro_mode(ubi); |
@@ -1255,11 +1186,11 @@ retry: | |||
1255 | 1186 | ||
1256 | if (in_wl_tree(e, &ubi->used)) { | 1187 | if (in_wl_tree(e, &ubi->used)) { |
1257 | paranoid_check_in_wl_tree(e, &ubi->used); | 1188 | paranoid_check_in_wl_tree(e, &ubi->used); |
1258 | rb_erase(&e->rb, &ubi->used); | 1189 | rb_erase(&e->u.rb, &ubi->used); |
1259 | } else { | 1190 | } else { |
1260 | int err; | 1191 | int err; |
1261 | 1192 | ||
1262 | err = prot_tree_del(ubi, e->pnum); | 1193 | err = prot_queue_del(ubi, e->pnum); |
1263 | if (err) { | 1194 | if (err) { |
1264 | ubi_err("PEB %d not found", pnum); | 1195 | ubi_err("PEB %d not found", pnum); |
1265 | ubi_ro_mode(ubi); | 1196 | ubi_ro_mode(ubi); |
@@ -1290,7 +1221,7 @@ int ubi_wl_flush(struct ubi_device *ubi) | |||
1290 | int err; | 1221 | int err; |
1291 | 1222 | ||
1292 | /* | 1223 | /* |
1293 | * Erase while the pending works queue is not empty, but not more then | 1224 | * Erase while the pending works queue is not empty, but not more than |
1294 | * the number of currently pending works. | 1225 | * the number of currently pending works. |
1295 | */ | 1226 | */ |
1296 | dbg_wl("flush (%d pending works)", ubi->works_count); | 1227 | dbg_wl("flush (%d pending works)", ubi->works_count); |
@@ -1308,7 +1239,7 @@ int ubi_wl_flush(struct ubi_device *ubi) | |||
1308 | up_write(&ubi->work_sem); | 1239 | up_write(&ubi->work_sem); |
1309 | 1240 | ||
1310 | /* | 1241 | /* |
1311 | * And in case last was the WL worker and it cancelled the LEB | 1242 | * And in case last was the WL worker and it canceled the LEB |
1312 | * movement, flush again. | 1243 | * movement, flush again. |
1313 | */ | 1244 | */ |
1314 | while (ubi->works_count) { | 1245 | while (ubi->works_count) { |
@@ -1337,11 +1268,11 @@ static void tree_destroy(struct rb_root *root) | |||
1337 | else if (rb->rb_right) | 1268 | else if (rb->rb_right) |
1338 | rb = rb->rb_right; | 1269 | rb = rb->rb_right; |
1339 | else { | 1270 | else { |
1340 | e = rb_entry(rb, struct ubi_wl_entry, rb); | 1271 | e = rb_entry(rb, struct ubi_wl_entry, u.rb); |
1341 | 1272 | ||
1342 | rb = rb_parent(rb); | 1273 | rb = rb_parent(rb); |
1343 | if (rb) { | 1274 | if (rb) { |
1344 | if (rb->rb_left == &e->rb) | 1275 | if (rb->rb_left == &e->u.rb) |
1345 | rb->rb_left = NULL; | 1276 | rb->rb_left = NULL; |
1346 | else | 1277 | else |
1347 | rb->rb_right = NULL; | 1278 | rb->rb_right = NULL; |
@@ -1436,15 +1367,13 @@ static void cancel_pending(struct ubi_device *ubi) | |||
1436 | */ | 1367 | */ |
1437 | int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) | 1368 | int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) |
1438 | { | 1369 | { |
1439 | int err; | 1370 | int err, i; |
1440 | struct rb_node *rb1, *rb2; | 1371 | struct rb_node *rb1, *rb2; |
1441 | struct ubi_scan_volume *sv; | 1372 | struct ubi_scan_volume *sv; |
1442 | struct ubi_scan_leb *seb, *tmp; | 1373 | struct ubi_scan_leb *seb, *tmp; |
1443 | struct ubi_wl_entry *e; | 1374 | struct ubi_wl_entry *e; |
1444 | 1375 | ||
1445 | |||
1446 | ubi->used = ubi->free = ubi->scrub = RB_ROOT; | 1376 | ubi->used = ubi->free = ubi->scrub = RB_ROOT; |
1447 | ubi->prot.pnum = ubi->prot.aec = RB_ROOT; | ||
1448 | spin_lock_init(&ubi->wl_lock); | 1377 | spin_lock_init(&ubi->wl_lock); |
1449 | mutex_init(&ubi->move_mutex); | 1378 | mutex_init(&ubi->move_mutex); |
1450 | init_rwsem(&ubi->work_sem); | 1379 | init_rwsem(&ubi->work_sem); |
@@ -1458,6 +1387,10 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) | |||
1458 | if (!ubi->lookuptbl) | 1387 | if (!ubi->lookuptbl) |
1459 | return err; | 1388 | return err; |
1460 | 1389 | ||
1390 | for (i = 0; i < UBI_PROT_QUEUE_LEN; i++) | ||
1391 | INIT_LIST_HEAD(&ubi->pq[i]); | ||
1392 | ubi->pq_head = 0; | ||
1393 | |||
1461 | list_for_each_entry_safe(seb, tmp, &si->erase, u.list) { | 1394 | list_for_each_entry_safe(seb, tmp, &si->erase, u.list) { |
1462 | cond_resched(); | 1395 | cond_resched(); |
1463 | 1396 | ||
@@ -1552,33 +1485,18 @@ out_free: | |||
1552 | } | 1485 | } |
1553 | 1486 | ||
1554 | /** | 1487 | /** |
1555 | * protection_trees_destroy - destroy the protection RB-trees. | 1488 | * protection_queue_destroy - destroy the protection queue. |
1556 | * @ubi: UBI device description object | 1489 | * @ubi: UBI device description object |
1557 | */ | 1490 | */ |
1558 | static void protection_trees_destroy(struct ubi_device *ubi) | 1491 | static void protection_queue_destroy(struct ubi_device *ubi) |
1559 | { | 1492 | { |
1560 | struct rb_node *rb; | 1493 | int i; |
1561 | struct ubi_wl_prot_entry *pe; | 1494 | struct ubi_wl_entry *e, *tmp; |
1562 | |||
1563 | rb = ubi->prot.aec.rb_node; | ||
1564 | while (rb) { | ||
1565 | if (rb->rb_left) | ||
1566 | rb = rb->rb_left; | ||
1567 | else if (rb->rb_right) | ||
1568 | rb = rb->rb_right; | ||
1569 | else { | ||
1570 | pe = rb_entry(rb, struct ubi_wl_prot_entry, rb_aec); | ||
1571 | |||
1572 | rb = rb_parent(rb); | ||
1573 | if (rb) { | ||
1574 | if (rb->rb_left == &pe->rb_aec) | ||
1575 | rb->rb_left = NULL; | ||
1576 | else | ||
1577 | rb->rb_right = NULL; | ||
1578 | } | ||
1579 | 1495 | ||
1580 | kmem_cache_free(ubi_wl_entry_slab, pe->e); | 1496 | for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) { |
1581 | kfree(pe); | 1497 | list_for_each_entry_safe(e, tmp, &ubi->pq[i], u.list) { |
1498 | list_del(&e->u.list); | ||
1499 | kmem_cache_free(ubi_wl_entry_slab, e); | ||
1582 | } | 1500 | } |
1583 | } | 1501 | } |
1584 | } | 1502 | } |
@@ -1591,7 +1509,7 @@ void ubi_wl_close(struct ubi_device *ubi) | |||
1591 | { | 1509 | { |
1592 | dbg_wl("close the WL sub-system"); | 1510 | dbg_wl("close the WL sub-system"); |
1593 | cancel_pending(ubi); | 1511 | cancel_pending(ubi); |
1594 | protection_trees_destroy(ubi); | 1512 | protection_queue_destroy(ubi); |
1595 | tree_destroy(&ubi->used); | 1513 | tree_destroy(&ubi->used); |
1596 | tree_destroy(&ubi->free); | 1514 | tree_destroy(&ubi->free); |
1597 | tree_destroy(&ubi->scrub); | 1515 | tree_destroy(&ubi->scrub); |
@@ -1661,4 +1579,27 @@ static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e, | |||
1661 | return 1; | 1579 | return 1; |
1662 | } | 1580 | } |
1663 | 1581 | ||
1582 | /** | ||
1583 | * paranoid_check_in_pq - check if wear-leveling entry is in the protection | ||
1584 | * queue. | ||
1585 | * @ubi: UBI device description object | ||
1586 | * @e: the wear-leveling entry to check | ||
1587 | * | ||
1588 | * This function returns zero if @e is in @ubi->pq and %1 if it is not. | ||
1589 | */ | ||
1590 | static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e) | ||
1591 | { | ||
1592 | struct ubi_wl_entry *p; | ||
1593 | int i; | ||
1594 | |||
1595 | for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) | ||
1596 | list_for_each_entry(p, &ubi->pq[i], u.list) | ||
1597 | if (p == e) | ||
1598 | return 0; | ||
1599 | |||
1600 | ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue", | ||
1601 | e->pnum, e->ec); | ||
1602 | ubi_dbg_dump_stack(); | ||
1603 | return 1; | ||
1604 | } | ||
1664 | #endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ | 1605 | #endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index 691b3adeb870..f5a662a50acb 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -191,26 +191,17 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header) | |||
191 | static int __init dmar_parse_dev(struct dmar_drhd_unit *dmaru) | 191 | static int __init dmar_parse_dev(struct dmar_drhd_unit *dmaru) |
192 | { | 192 | { |
193 | struct acpi_dmar_hardware_unit *drhd; | 193 | struct acpi_dmar_hardware_unit *drhd; |
194 | static int include_all; | ||
195 | int ret = 0; | 194 | int ret = 0; |
196 | 195 | ||
197 | drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr; | 196 | drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr; |
198 | 197 | ||
199 | if (!dmaru->include_all) | 198 | if (dmaru->include_all) |
200 | ret = dmar_parse_dev_scope((void *)(drhd + 1), | 199 | return 0; |
200 | |||
201 | ret = dmar_parse_dev_scope((void *)(drhd + 1), | ||
201 | ((void *)drhd) + drhd->header.length, | 202 | ((void *)drhd) + drhd->header.length, |
202 | &dmaru->devices_cnt, &dmaru->devices, | 203 | &dmaru->devices_cnt, &dmaru->devices, |
203 | drhd->segment); | 204 | drhd->segment); |
204 | else { | ||
205 | /* Only allow one INCLUDE_ALL */ | ||
206 | if (include_all) { | ||
207 | printk(KERN_WARNING PREFIX "Only one INCLUDE_ALL " | ||
208 | "device scope is allowed\n"); | ||
209 | ret = -EINVAL; | ||
210 | } | ||
211 | include_all = 1; | ||
212 | } | ||
213 | |||
214 | if (ret) { | 205 | if (ret) { |
215 | list_del(&dmaru->list); | 206 | list_del(&dmaru->list); |
216 | kfree(dmaru); | 207 | kfree(dmaru); |
@@ -384,12 +375,21 @@ int dmar_pci_device_match(struct pci_dev *devices[], int cnt, | |||
384 | struct dmar_drhd_unit * | 375 | struct dmar_drhd_unit * |
385 | dmar_find_matched_drhd_unit(struct pci_dev *dev) | 376 | dmar_find_matched_drhd_unit(struct pci_dev *dev) |
386 | { | 377 | { |
387 | struct dmar_drhd_unit *drhd = NULL; | 378 | struct dmar_drhd_unit *dmaru = NULL; |
379 | struct acpi_dmar_hardware_unit *drhd; | ||
388 | 380 | ||
389 | list_for_each_entry(drhd, &dmar_drhd_units, list) { | 381 | list_for_each_entry(dmaru, &dmar_drhd_units, list) { |
390 | if (drhd->include_all || dmar_pci_device_match(drhd->devices, | 382 | drhd = container_of(dmaru->hdr, |
391 | drhd->devices_cnt, dev)) | 383 | struct acpi_dmar_hardware_unit, |
392 | return drhd; | 384 | header); |
385 | |||
386 | if (dmaru->include_all && | ||
387 | drhd->segment == pci_domain_nr(dev->bus)) | ||
388 | return dmaru; | ||
389 | |||
390 | if (dmar_pci_device_match(dmaru->devices, | ||
391 | dmaru->devices_cnt, dev)) | ||
392 | return dmaru; | ||
393 | } | 393 | } |
394 | 394 | ||
395 | return NULL; | 395 | return NULL; |
@@ -491,6 +491,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) | |||
491 | int map_size; | 491 | int map_size; |
492 | u32 ver; | 492 | u32 ver; |
493 | static int iommu_allocated = 0; | 493 | static int iommu_allocated = 0; |
494 | int agaw; | ||
494 | 495 | ||
495 | iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); | 496 | iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); |
496 | if (!iommu) | 497 | if (!iommu) |
@@ -506,6 +507,15 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) | |||
506 | iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); | 507 | iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); |
507 | iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); | 508 | iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); |
508 | 509 | ||
510 | agaw = iommu_calculate_agaw(iommu); | ||
511 | if (agaw < 0) { | ||
512 | printk(KERN_ERR | ||
513 | "Cannot get a valid agaw for iommu (seq_id = %d)\n", | ||
514 | iommu->seq_id); | ||
515 | goto error; | ||
516 | } | ||
517 | iommu->agaw = agaw; | ||
518 | |||
509 | /* the registers might be more than one page */ | 519 | /* the registers might be more than one page */ |
510 | map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), | 520 | map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), |
511 | cap_max_fault_reg_offset(iommu->cap)); | 521 | cap_max_fault_reg_offset(iommu->cap)); |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 8514c3a1746a..c2e1bcbb28a7 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | #include "cpqphp.h" | 46 | #include "cpqphp.h" |
47 | #include "cpqphp_nvram.h" | 47 | #include "cpqphp_nvram.h" |
48 | #include "../../../arch/x86/pci/pci.h" /* horrible hack showing how processor dependent we are... */ | 48 | #include <asm/pci_x86.h> |
49 | 49 | ||
50 | 50 | ||
51 | /* Global variables */ | 51 | /* Global variables */ |
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 09021930589f..df146be9d2e9 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include "../pci.h" | 37 | #include "../pci.h" |
38 | #include "cpqphp.h" | 38 | #include "cpqphp.h" |
39 | #include "cpqphp_nvram.h" | 39 | #include "cpqphp_nvram.h" |
40 | #include "../../../arch/x86/pci/pci.h" /* horrible hack showing how processor dependent we are... */ | 40 | #include <asm/pci_x86.h> |
41 | 41 | ||
42 | 42 | ||
43 | u8 cpqhp_nic_irq; | 43 | u8 cpqhp_nic_irq; |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 633e743442ac..dd18f857dfb0 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/wait.h> | 36 | #include <linux/wait.h> |
37 | #include "../pci.h" | 37 | #include "../pci.h" |
38 | #include "../../../arch/x86/pci/pci.h" /* for struct irq_routing_table */ | 38 | #include <asm/pci_x86.h> /* for struct irq_routing_table */ |
39 | #include "ibmphp.h" | 39 | #include "ibmphp.h" |
40 | 40 | ||
41 | #define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON) | 41 | #define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON) |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 5c8baa43ac9c..235fb7a5a8a5 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/irq.h> | 28 | #include <linux/irq.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/sysdev.h> | ||
31 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
32 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
33 | #include <linux/dmar.h> | 32 | #include <linux/dmar.h> |
@@ -35,6 +34,7 @@ | |||
35 | #include <linux/mempool.h> | 34 | #include <linux/mempool.h> |
36 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
37 | #include <linux/iova.h> | 36 | #include <linux/iova.h> |
37 | #include <linux/iommu.h> | ||
38 | #include <linux/intel-iommu.h> | 38 | #include <linux/intel-iommu.h> |
39 | #include <asm/cacheflush.h> | 39 | #include <asm/cacheflush.h> |
40 | #include <asm/iommu.h> | 40 | #include <asm/iommu.h> |
@@ -54,6 +54,195 @@ | |||
54 | 54 | ||
55 | #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) | 55 | #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) |
56 | 56 | ||
57 | #define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT) | ||
58 | #define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK) | ||
59 | #define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK) | ||
60 | |||
61 | /* global iommu list, set NULL for ignored DMAR units */ | ||
62 | static struct intel_iommu **g_iommus; | ||
63 | |||
64 | /* | ||
65 | * 0: Present | ||
66 | * 1-11: Reserved | ||
67 | * 12-63: Context Ptr (12 - (haw-1)) | ||
68 | * 64-127: Reserved | ||
69 | */ | ||
70 | struct root_entry { | ||
71 | u64 val; | ||
72 | u64 rsvd1; | ||
73 | }; | ||
74 | #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry)) | ||
75 | static inline bool root_present(struct root_entry *root) | ||
76 | { | ||
77 | return (root->val & 1); | ||
78 | } | ||
79 | static inline void set_root_present(struct root_entry *root) | ||
80 | { | ||
81 | root->val |= 1; | ||
82 | } | ||
83 | static inline void set_root_value(struct root_entry *root, unsigned long value) | ||
84 | { | ||
85 | root->val |= value & VTD_PAGE_MASK; | ||
86 | } | ||
87 | |||
88 | static inline struct context_entry * | ||
89 | get_context_addr_from_root(struct root_entry *root) | ||
90 | { | ||
91 | return (struct context_entry *) | ||
92 | (root_present(root)?phys_to_virt( | ||
93 | root->val & VTD_PAGE_MASK) : | ||
94 | NULL); | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * low 64 bits: | ||
99 | * 0: present | ||
100 | * 1: fault processing disable | ||
101 | * 2-3: translation type | ||
102 | * 12-63: address space root | ||
103 | * high 64 bits: | ||
104 | * 0-2: address width | ||
105 | * 3-6: aval | ||
106 | * 8-23: domain id | ||
107 | */ | ||
108 | struct context_entry { | ||
109 | u64 lo; | ||
110 | u64 hi; | ||
111 | }; | ||
112 | |||
113 | static inline bool context_present(struct context_entry *context) | ||
114 | { | ||
115 | return (context->lo & 1); | ||
116 | } | ||
117 | static inline void context_set_present(struct context_entry *context) | ||
118 | { | ||
119 | context->lo |= 1; | ||
120 | } | ||
121 | |||
122 | static inline void context_set_fault_enable(struct context_entry *context) | ||
123 | { | ||
124 | context->lo &= (((u64)-1) << 2) | 1; | ||
125 | } | ||
126 | |||
127 | #define CONTEXT_TT_MULTI_LEVEL 0 | ||
128 | |||
129 | static inline void context_set_translation_type(struct context_entry *context, | ||
130 | unsigned long value) | ||
131 | { | ||
132 | context->lo &= (((u64)-1) << 4) | 3; | ||
133 | context->lo |= (value & 3) << 2; | ||
134 | } | ||
135 | |||
136 | static inline void context_set_address_root(struct context_entry *context, | ||
137 | unsigned long value) | ||
138 | { | ||
139 | context->lo |= value & VTD_PAGE_MASK; | ||
140 | } | ||
141 | |||
142 | static inline void context_set_address_width(struct context_entry *context, | ||
143 | unsigned long value) | ||
144 | { | ||
145 | context->hi |= value & 7; | ||
146 | } | ||
147 | |||
148 | static inline void context_set_domain_id(struct context_entry *context, | ||
149 | unsigned long value) | ||
150 | { | ||
151 | context->hi |= (value & ((1 << 16) - 1)) << 8; | ||
152 | } | ||
153 | |||
154 | static inline void context_clear_entry(struct context_entry *context) | ||
155 | { | ||
156 | context->lo = 0; | ||
157 | context->hi = 0; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * 0: readable | ||
162 | * 1: writable | ||
163 | * 2-6: reserved | ||
164 | * 7: super page | ||
165 | * 8-11: available | ||
166 | * 12-63: Host physcial address | ||
167 | */ | ||
168 | struct dma_pte { | ||
169 | u64 val; | ||
170 | }; | ||
171 | |||
172 | static inline void dma_clear_pte(struct dma_pte *pte) | ||
173 | { | ||
174 | pte->val = 0; | ||
175 | } | ||
176 | |||
177 | static inline void dma_set_pte_readable(struct dma_pte *pte) | ||
178 | { | ||
179 | pte->val |= DMA_PTE_READ; | ||
180 | } | ||
181 | |||
182 | static inline void dma_set_pte_writable(struct dma_pte *pte) | ||
183 | { | ||
184 | pte->val |= DMA_PTE_WRITE; | ||
185 | } | ||
186 | |||
187 | static inline void dma_set_pte_prot(struct dma_pte *pte, unsigned long prot) | ||
188 | { | ||
189 | pte->val = (pte->val & ~3) | (prot & 3); | ||
190 | } | ||
191 | |||
192 | static inline u64 dma_pte_addr(struct dma_pte *pte) | ||
193 | { | ||
194 | return (pte->val & VTD_PAGE_MASK); | ||
195 | } | ||
196 | |||
197 | static inline void dma_set_pte_addr(struct dma_pte *pte, u64 addr) | ||
198 | { | ||
199 | pte->val |= (addr & VTD_PAGE_MASK); | ||
200 | } | ||
201 | |||
202 | static inline bool dma_pte_present(struct dma_pte *pte) | ||
203 | { | ||
204 | return (pte->val & 3) != 0; | ||
205 | } | ||
206 | |||
207 | /* devices under the same p2p bridge are owned in one domain */ | ||
208 | #define DOMAIN_FLAG_P2P_MULTIPLE_DEVICES (1 << 0) | ||
209 | |||
210 | /* domain represents a virtual machine, more than one devices | ||
211 | * across iommus may be owned in one domain, e.g. kvm guest. | ||
212 | */ | ||
213 | #define DOMAIN_FLAG_VIRTUAL_MACHINE (1 << 1) | ||
214 | |||
215 | struct dmar_domain { | ||
216 | int id; /* domain id */ | ||
217 | unsigned long iommu_bmp; /* bitmap of iommus this domain uses*/ | ||
218 | |||
219 | struct list_head devices; /* all devices' list */ | ||
220 | struct iova_domain iovad; /* iova's that belong to this domain */ | ||
221 | |||
222 | struct dma_pte *pgd; /* virtual address */ | ||
223 | spinlock_t mapping_lock; /* page table lock */ | ||
224 | int gaw; /* max guest address width */ | ||
225 | |||
226 | /* adjusted guest address width, 0 is level 2 30-bit */ | ||
227 | int agaw; | ||
228 | |||
229 | int flags; /* flags to find out type of domain */ | ||
230 | |||
231 | int iommu_coherency;/* indicate coherency of iommu access */ | ||
232 | int iommu_count; /* reference count of iommu */ | ||
233 | spinlock_t iommu_lock; /* protect iommu set in domain */ | ||
234 | u64 max_addr; /* maximum mapped address */ | ||
235 | }; | ||
236 | |||
237 | /* PCI domain-device relationship */ | ||
238 | struct device_domain_info { | ||
239 | struct list_head link; /* link to domain siblings */ | ||
240 | struct list_head global; /* link to global list */ | ||
241 | u8 bus; /* PCI bus numer */ | ||
242 | u8 devfn; /* PCI devfn number */ | ||
243 | struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */ | ||
244 | struct dmar_domain *domain; /* pointer to domain */ | ||
245 | }; | ||
57 | 246 | ||
58 | static void flush_unmaps_timeout(unsigned long data); | 247 | static void flush_unmaps_timeout(unsigned long data); |
59 | 248 | ||
@@ -88,6 +277,8 @@ static int intel_iommu_strict; | |||
88 | static DEFINE_SPINLOCK(device_domain_lock); | 277 | static DEFINE_SPINLOCK(device_domain_lock); |
89 | static LIST_HEAD(device_domain_list); | 278 | static LIST_HEAD(device_domain_list); |
90 | 279 | ||
280 | static struct iommu_ops intel_iommu_ops; | ||
281 | |||
91 | static int __init intel_iommu_setup(char *str) | 282 | static int __init intel_iommu_setup(char *str) |
92 | { | 283 | { |
93 | if (!str) | 284 | if (!str) |
@@ -184,6 +375,87 @@ void free_iova_mem(struct iova *iova) | |||
184 | kmem_cache_free(iommu_iova_cache, iova); | 375 | kmem_cache_free(iommu_iova_cache, iova); |
185 | } | 376 | } |
186 | 377 | ||
378 | |||
379 | static inline int width_to_agaw(int width); | ||
380 | |||
381 | /* calculate agaw for each iommu. | ||
382 | * "SAGAW" may be different across iommus, use a default agaw, and | ||
383 | * get a supported less agaw for iommus that don't support the default agaw. | ||
384 | */ | ||
385 | int iommu_calculate_agaw(struct intel_iommu *iommu) | ||
386 | { | ||
387 | unsigned long sagaw; | ||
388 | int agaw = -1; | ||
389 | |||
390 | sagaw = cap_sagaw(iommu->cap); | ||
391 | for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH); | ||
392 | agaw >= 0; agaw--) { | ||
393 | if (test_bit(agaw, &sagaw)) | ||
394 | break; | ||
395 | } | ||
396 | |||
397 | return agaw; | ||
398 | } | ||
399 | |||
400 | /* in native case, each domain is related to only one iommu */ | ||
401 | static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain) | ||
402 | { | ||
403 | int iommu_id; | ||
404 | |||
405 | BUG_ON(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE); | ||
406 | |||
407 | iommu_id = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); | ||
408 | if (iommu_id < 0 || iommu_id >= g_num_of_iommus) | ||
409 | return NULL; | ||
410 | |||
411 | return g_iommus[iommu_id]; | ||
412 | } | ||
413 | |||
414 | /* "Coherency" capability may be different across iommus */ | ||
415 | static void domain_update_iommu_coherency(struct dmar_domain *domain) | ||
416 | { | ||
417 | int i; | ||
418 | |||
419 | domain->iommu_coherency = 1; | ||
420 | |||
421 | i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); | ||
422 | for (; i < g_num_of_iommus; ) { | ||
423 | if (!ecap_coherent(g_iommus[i]->ecap)) { | ||
424 | domain->iommu_coherency = 0; | ||
425 | break; | ||
426 | } | ||
427 | i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1); | ||
428 | } | ||
429 | } | ||
430 | |||
431 | static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn) | ||
432 | { | ||
433 | struct dmar_drhd_unit *drhd = NULL; | ||
434 | int i; | ||
435 | |||
436 | for_each_drhd_unit(drhd) { | ||
437 | if (drhd->ignored) | ||
438 | continue; | ||
439 | |||
440 | for (i = 0; i < drhd->devices_cnt; i++) | ||
441 | if (drhd->devices[i]->bus->number == bus && | ||
442 | drhd->devices[i]->devfn == devfn) | ||
443 | return drhd->iommu; | ||
444 | |||
445 | if (drhd->include_all) | ||
446 | return drhd->iommu; | ||
447 | } | ||
448 | |||
449 | return NULL; | ||
450 | } | ||
451 | |||
452 | static void domain_flush_cache(struct dmar_domain *domain, | ||
453 | void *addr, int size) | ||
454 | { | ||
455 | if (!domain->iommu_coherency) | ||
456 | clflush_cache_range(addr, size); | ||
457 | } | ||
458 | |||
187 | /* Gets context entry for a given bus and devfn */ | 459 | /* Gets context entry for a given bus and devfn */ |
188 | static struct context_entry * device_to_context_entry(struct intel_iommu *iommu, | 460 | static struct context_entry * device_to_context_entry(struct intel_iommu *iommu, |
189 | u8 bus, u8 devfn) | 461 | u8 bus, u8 devfn) |
@@ -226,7 +498,7 @@ static int device_context_mapped(struct intel_iommu *iommu, u8 bus, u8 devfn) | |||
226 | ret = 0; | 498 | ret = 0; |
227 | goto out; | 499 | goto out; |
228 | } | 500 | } |
229 | ret = context_present(context[devfn]); | 501 | ret = context_present(&context[devfn]); |
230 | out: | 502 | out: |
231 | spin_unlock_irqrestore(&iommu->lock, flags); | 503 | spin_unlock_irqrestore(&iommu->lock, flags); |
232 | return ret; | 504 | return ret; |
@@ -242,7 +514,7 @@ static void clear_context_table(struct intel_iommu *iommu, u8 bus, u8 devfn) | |||
242 | root = &iommu->root_entry[bus]; | 514 | root = &iommu->root_entry[bus]; |
243 | context = get_context_addr_from_root(root); | 515 | context = get_context_addr_from_root(root); |
244 | if (context) { | 516 | if (context) { |
245 | context_clear_entry(context[devfn]); | 517 | context_clear_entry(&context[devfn]); |
246 | __iommu_flush_cache(iommu, &context[devfn], \ | 518 | __iommu_flush_cache(iommu, &context[devfn], \ |
247 | sizeof(*context)); | 519 | sizeof(*context)); |
248 | } | 520 | } |
@@ -339,7 +611,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) | |||
339 | if (level == 1) | 611 | if (level == 1) |
340 | break; | 612 | break; |
341 | 613 | ||
342 | if (!dma_pte_present(*pte)) { | 614 | if (!dma_pte_present(pte)) { |
343 | tmp_page = alloc_pgtable_page(); | 615 | tmp_page = alloc_pgtable_page(); |
344 | 616 | ||
345 | if (!tmp_page) { | 617 | if (!tmp_page) { |
@@ -347,18 +619,17 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) | |||
347 | flags); | 619 | flags); |
348 | return NULL; | 620 | return NULL; |
349 | } | 621 | } |
350 | __iommu_flush_cache(domain->iommu, tmp_page, | 622 | domain_flush_cache(domain, tmp_page, PAGE_SIZE); |
351 | PAGE_SIZE); | 623 | dma_set_pte_addr(pte, virt_to_phys(tmp_page)); |
352 | dma_set_pte_addr(*pte, virt_to_phys(tmp_page)); | ||
353 | /* | 624 | /* |
354 | * high level table always sets r/w, last level page | 625 | * high level table always sets r/w, last level page |
355 | * table control read/write | 626 | * table control read/write |
356 | */ | 627 | */ |
357 | dma_set_pte_readable(*pte); | 628 | dma_set_pte_readable(pte); |
358 | dma_set_pte_writable(*pte); | 629 | dma_set_pte_writable(pte); |
359 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | 630 | domain_flush_cache(domain, pte, sizeof(*pte)); |
360 | } | 631 | } |
361 | parent = phys_to_virt(dma_pte_addr(*pte)); | 632 | parent = phys_to_virt(dma_pte_addr(pte)); |
362 | level--; | 633 | level--; |
363 | } | 634 | } |
364 | 635 | ||
@@ -381,9 +652,9 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr, | |||
381 | if (level == total) | 652 | if (level == total) |
382 | return pte; | 653 | return pte; |
383 | 654 | ||
384 | if (!dma_pte_present(*pte)) | 655 | if (!dma_pte_present(pte)) |
385 | break; | 656 | break; |
386 | parent = phys_to_virt(dma_pte_addr(*pte)); | 657 | parent = phys_to_virt(dma_pte_addr(pte)); |
387 | total--; | 658 | total--; |
388 | } | 659 | } |
389 | return NULL; | 660 | return NULL; |
@@ -398,8 +669,8 @@ static void dma_pte_clear_one(struct dmar_domain *domain, u64 addr) | |||
398 | pte = dma_addr_level_pte(domain, addr, 1); | 669 | pte = dma_addr_level_pte(domain, addr, 1); |
399 | 670 | ||
400 | if (pte) { | 671 | if (pte) { |
401 | dma_clear_pte(*pte); | 672 | dma_clear_pte(pte); |
402 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | 673 | domain_flush_cache(domain, pte, sizeof(*pte)); |
403 | } | 674 | } |
404 | } | 675 | } |
405 | 676 | ||
@@ -445,10 +716,9 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain, | |||
445 | pte = dma_addr_level_pte(domain, tmp, level); | 716 | pte = dma_addr_level_pte(domain, tmp, level); |
446 | if (pte) { | 717 | if (pte) { |
447 | free_pgtable_page( | 718 | free_pgtable_page( |
448 | phys_to_virt(dma_pte_addr(*pte))); | 719 | phys_to_virt(dma_pte_addr(pte))); |
449 | dma_clear_pte(*pte); | 720 | dma_clear_pte(pte); |
450 | __iommu_flush_cache(domain->iommu, | 721 | domain_flush_cache(domain, pte, sizeof(*pte)); |
451 | pte, sizeof(*pte)); | ||
452 | } | 722 | } |
453 | tmp += level_size(level); | 723 | tmp += level_size(level); |
454 | } | 724 | } |
@@ -950,17 +1220,28 @@ static int iommu_init_domains(struct intel_iommu *iommu) | |||
950 | 1220 | ||
951 | 1221 | ||
952 | static void domain_exit(struct dmar_domain *domain); | 1222 | static void domain_exit(struct dmar_domain *domain); |
1223 | static void vm_domain_exit(struct dmar_domain *domain); | ||
953 | 1224 | ||
954 | void free_dmar_iommu(struct intel_iommu *iommu) | 1225 | void free_dmar_iommu(struct intel_iommu *iommu) |
955 | { | 1226 | { |
956 | struct dmar_domain *domain; | 1227 | struct dmar_domain *domain; |
957 | int i; | 1228 | int i; |
1229 | unsigned long flags; | ||
958 | 1230 | ||
959 | i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap)); | 1231 | i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap)); |
960 | for (; i < cap_ndoms(iommu->cap); ) { | 1232 | for (; i < cap_ndoms(iommu->cap); ) { |
961 | domain = iommu->domains[i]; | 1233 | domain = iommu->domains[i]; |
962 | clear_bit(i, iommu->domain_ids); | 1234 | clear_bit(i, iommu->domain_ids); |
963 | domain_exit(domain); | 1235 | |
1236 | spin_lock_irqsave(&domain->iommu_lock, flags); | ||
1237 | if (--domain->iommu_count == 0) { | ||
1238 | if (domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) | ||
1239 | vm_domain_exit(domain); | ||
1240 | else | ||
1241 | domain_exit(domain); | ||
1242 | } | ||
1243 | spin_unlock_irqrestore(&domain->iommu_lock, flags); | ||
1244 | |||
964 | i = find_next_bit(iommu->domain_ids, | 1245 | i = find_next_bit(iommu->domain_ids, |
965 | cap_ndoms(iommu->cap), i+1); | 1246 | cap_ndoms(iommu->cap), i+1); |
966 | } | 1247 | } |
@@ -978,6 +1259,17 @@ void free_dmar_iommu(struct intel_iommu *iommu) | |||
978 | kfree(iommu->domains); | 1259 | kfree(iommu->domains); |
979 | kfree(iommu->domain_ids); | 1260 | kfree(iommu->domain_ids); |
980 | 1261 | ||
1262 | g_iommus[iommu->seq_id] = NULL; | ||
1263 | |||
1264 | /* if all iommus are freed, free g_iommus */ | ||
1265 | for (i = 0; i < g_num_of_iommus; i++) { | ||
1266 | if (g_iommus[i]) | ||
1267 | break; | ||
1268 | } | ||
1269 | |||
1270 | if (i == g_num_of_iommus) | ||
1271 | kfree(g_iommus); | ||
1272 | |||
981 | /* free context mapping */ | 1273 | /* free context mapping */ |
982 | free_context_table(iommu); | 1274 | free_context_table(iommu); |
983 | } | 1275 | } |
@@ -1006,7 +1298,9 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu) | |||
1006 | 1298 | ||
1007 | set_bit(num, iommu->domain_ids); | 1299 | set_bit(num, iommu->domain_ids); |
1008 | domain->id = num; | 1300 | domain->id = num; |
1009 | domain->iommu = iommu; | 1301 | memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); |
1302 | set_bit(iommu->seq_id, &domain->iommu_bmp); | ||
1303 | domain->flags = 0; | ||
1010 | iommu->domains[num] = domain; | 1304 | iommu->domains[num] = domain; |
1011 | spin_unlock_irqrestore(&iommu->lock, flags); | 1305 | spin_unlock_irqrestore(&iommu->lock, flags); |
1012 | 1306 | ||
@@ -1016,10 +1310,13 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu) | |||
1016 | static void iommu_free_domain(struct dmar_domain *domain) | 1310 | static void iommu_free_domain(struct dmar_domain *domain) |
1017 | { | 1311 | { |
1018 | unsigned long flags; | 1312 | unsigned long flags; |
1313 | struct intel_iommu *iommu; | ||
1314 | |||
1315 | iommu = domain_get_iommu(domain); | ||
1019 | 1316 | ||
1020 | spin_lock_irqsave(&domain->iommu->lock, flags); | 1317 | spin_lock_irqsave(&iommu->lock, flags); |
1021 | clear_bit(domain->id, domain->iommu->domain_ids); | 1318 | clear_bit(domain->id, iommu->domain_ids); |
1022 | spin_unlock_irqrestore(&domain->iommu->lock, flags); | 1319 | spin_unlock_irqrestore(&iommu->lock, flags); |
1023 | } | 1320 | } |
1024 | 1321 | ||
1025 | static struct iova_domain reserved_iova_list; | 1322 | static struct iova_domain reserved_iova_list; |
@@ -1094,11 +1391,12 @@ static int domain_init(struct dmar_domain *domain, int guest_width) | |||
1094 | 1391 | ||
1095 | init_iova_domain(&domain->iovad, DMA_32BIT_PFN); | 1392 | init_iova_domain(&domain->iovad, DMA_32BIT_PFN); |
1096 | spin_lock_init(&domain->mapping_lock); | 1393 | spin_lock_init(&domain->mapping_lock); |
1394 | spin_lock_init(&domain->iommu_lock); | ||
1097 | 1395 | ||
1098 | domain_reserve_special_ranges(domain); | 1396 | domain_reserve_special_ranges(domain); |
1099 | 1397 | ||
1100 | /* calculate AGAW */ | 1398 | /* calculate AGAW */ |
1101 | iommu = domain->iommu; | 1399 | iommu = domain_get_iommu(domain); |
1102 | if (guest_width > cap_mgaw(iommu->cap)) | 1400 | if (guest_width > cap_mgaw(iommu->cap)) |
1103 | guest_width = cap_mgaw(iommu->cap); | 1401 | guest_width = cap_mgaw(iommu->cap); |
1104 | domain->gaw = guest_width; | 1402 | domain->gaw = guest_width; |
@@ -1115,6 +1413,13 @@ static int domain_init(struct dmar_domain *domain, int guest_width) | |||
1115 | domain->agaw = agaw; | 1413 | domain->agaw = agaw; |
1116 | INIT_LIST_HEAD(&domain->devices); | 1414 | INIT_LIST_HEAD(&domain->devices); |
1117 | 1415 | ||
1416 | if (ecap_coherent(iommu->ecap)) | ||
1417 | domain->iommu_coherency = 1; | ||
1418 | else | ||
1419 | domain->iommu_coherency = 0; | ||
1420 | |||
1421 | domain->iommu_count = 1; | ||
1422 | |||
1118 | /* always allocate the top pgd */ | 1423 | /* always allocate the top pgd */ |
1119 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); | 1424 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); |
1120 | if (!domain->pgd) | 1425 | if (!domain->pgd) |
@@ -1151,28 +1456,82 @@ static int domain_context_mapping_one(struct dmar_domain *domain, | |||
1151 | u8 bus, u8 devfn) | 1456 | u8 bus, u8 devfn) |
1152 | { | 1457 | { |
1153 | struct context_entry *context; | 1458 | struct context_entry *context; |
1154 | struct intel_iommu *iommu = domain->iommu; | ||
1155 | unsigned long flags; | 1459 | unsigned long flags; |
1460 | struct intel_iommu *iommu; | ||
1461 | struct dma_pte *pgd; | ||
1462 | unsigned long num; | ||
1463 | unsigned long ndomains; | ||
1464 | int id; | ||
1465 | int agaw; | ||
1156 | 1466 | ||
1157 | pr_debug("Set context mapping for %02x:%02x.%d\n", | 1467 | pr_debug("Set context mapping for %02x:%02x.%d\n", |
1158 | bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); | 1468 | bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
1159 | BUG_ON(!domain->pgd); | 1469 | BUG_ON(!domain->pgd); |
1470 | |||
1471 | iommu = device_to_iommu(bus, devfn); | ||
1472 | if (!iommu) | ||
1473 | return -ENODEV; | ||
1474 | |||
1160 | context = device_to_context_entry(iommu, bus, devfn); | 1475 | context = device_to_context_entry(iommu, bus, devfn); |
1161 | if (!context) | 1476 | if (!context) |
1162 | return -ENOMEM; | 1477 | return -ENOMEM; |
1163 | spin_lock_irqsave(&iommu->lock, flags); | 1478 | spin_lock_irqsave(&iommu->lock, flags); |
1164 | if (context_present(*context)) { | 1479 | if (context_present(context)) { |
1165 | spin_unlock_irqrestore(&iommu->lock, flags); | 1480 | spin_unlock_irqrestore(&iommu->lock, flags); |
1166 | return 0; | 1481 | return 0; |
1167 | } | 1482 | } |
1168 | 1483 | ||
1169 | context_set_domain_id(*context, domain->id); | 1484 | id = domain->id; |
1170 | context_set_address_width(*context, domain->agaw); | 1485 | pgd = domain->pgd; |
1171 | context_set_address_root(*context, virt_to_phys(domain->pgd)); | 1486 | |
1172 | context_set_translation_type(*context, CONTEXT_TT_MULTI_LEVEL); | 1487 | if (domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) { |
1173 | context_set_fault_enable(*context); | 1488 | int found = 0; |
1174 | context_set_present(*context); | 1489 | |
1175 | __iommu_flush_cache(iommu, context, sizeof(*context)); | 1490 | /* find an available domain id for this device in iommu */ |
1491 | ndomains = cap_ndoms(iommu->cap); | ||
1492 | num = find_first_bit(iommu->domain_ids, ndomains); | ||
1493 | for (; num < ndomains; ) { | ||
1494 | if (iommu->domains[num] == domain) { | ||
1495 | id = num; | ||
1496 | found = 1; | ||
1497 | break; | ||
1498 | } | ||
1499 | num = find_next_bit(iommu->domain_ids, | ||
1500 | cap_ndoms(iommu->cap), num+1); | ||
1501 | } | ||
1502 | |||
1503 | if (found == 0) { | ||
1504 | num = find_first_zero_bit(iommu->domain_ids, ndomains); | ||
1505 | if (num >= ndomains) { | ||
1506 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
1507 | printk(KERN_ERR "IOMMU: no free domain ids\n"); | ||
1508 | return -EFAULT; | ||
1509 | } | ||
1510 | |||
1511 | set_bit(num, iommu->domain_ids); | ||
1512 | iommu->domains[num] = domain; | ||
1513 | id = num; | ||
1514 | } | ||
1515 | |||
1516 | /* Skip top levels of page tables for | ||
1517 | * iommu which has less agaw than default. | ||
1518 | */ | ||
1519 | for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) { | ||
1520 | pgd = phys_to_virt(dma_pte_addr(pgd)); | ||
1521 | if (!dma_pte_present(pgd)) { | ||
1522 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
1523 | return -ENOMEM; | ||
1524 | } | ||
1525 | } | ||
1526 | } | ||
1527 | |||
1528 | context_set_domain_id(context, id); | ||
1529 | context_set_address_width(context, iommu->agaw); | ||
1530 | context_set_address_root(context, virt_to_phys(pgd)); | ||
1531 | context_set_translation_type(context, CONTEXT_TT_MULTI_LEVEL); | ||
1532 | context_set_fault_enable(context); | ||
1533 | context_set_present(context); | ||
1534 | domain_flush_cache(domain, context, sizeof(*context)); | ||
1176 | 1535 | ||
1177 | /* it's a non-present to present mapping */ | 1536 | /* it's a non-present to present mapping */ |
1178 | if (iommu->flush.flush_context(iommu, domain->id, | 1537 | if (iommu->flush.flush_context(iommu, domain->id, |
@@ -1183,6 +1542,13 @@ static int domain_context_mapping_one(struct dmar_domain *domain, | |||
1183 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0); | 1542 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0); |
1184 | 1543 | ||
1185 | spin_unlock_irqrestore(&iommu->lock, flags); | 1544 | spin_unlock_irqrestore(&iommu->lock, flags); |
1545 | |||
1546 | spin_lock_irqsave(&domain->iommu_lock, flags); | ||
1547 | if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) { | ||
1548 | domain->iommu_count++; | ||
1549 | domain_update_iommu_coherency(domain); | ||
1550 | } | ||
1551 | spin_unlock_irqrestore(&domain->iommu_lock, flags); | ||
1186 | return 0; | 1552 | return 0; |
1187 | } | 1553 | } |
1188 | 1554 | ||
@@ -1218,13 +1584,17 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev) | |||
1218 | tmp->bus->number, tmp->devfn); | 1584 | tmp->bus->number, tmp->devfn); |
1219 | } | 1585 | } |
1220 | 1586 | ||
1221 | static int domain_context_mapped(struct dmar_domain *domain, | 1587 | static int domain_context_mapped(struct pci_dev *pdev) |
1222 | struct pci_dev *pdev) | ||
1223 | { | 1588 | { |
1224 | int ret; | 1589 | int ret; |
1225 | struct pci_dev *tmp, *parent; | 1590 | struct pci_dev *tmp, *parent; |
1591 | struct intel_iommu *iommu; | ||
1592 | |||
1593 | iommu = device_to_iommu(pdev->bus->number, pdev->devfn); | ||
1594 | if (!iommu) | ||
1595 | return -ENODEV; | ||
1226 | 1596 | ||
1227 | ret = device_context_mapped(domain->iommu, | 1597 | ret = device_context_mapped(iommu, |
1228 | pdev->bus->number, pdev->devfn); | 1598 | pdev->bus->number, pdev->devfn); |
1229 | if (!ret) | 1599 | if (!ret) |
1230 | return ret; | 1600 | return ret; |
@@ -1235,17 +1605,17 @@ static int domain_context_mapped(struct dmar_domain *domain, | |||
1235 | /* Secondary interface's bus number and devfn 0 */ | 1605 | /* Secondary interface's bus number and devfn 0 */ |
1236 | parent = pdev->bus->self; | 1606 | parent = pdev->bus->self; |
1237 | while (parent != tmp) { | 1607 | while (parent != tmp) { |
1238 | ret = device_context_mapped(domain->iommu, parent->bus->number, | 1608 | ret = device_context_mapped(iommu, parent->bus->number, |
1239 | parent->devfn); | 1609 | parent->devfn); |
1240 | if (!ret) | 1610 | if (!ret) |
1241 | return ret; | 1611 | return ret; |
1242 | parent = parent->bus->self; | 1612 | parent = parent->bus->self; |
1243 | } | 1613 | } |
1244 | if (tmp->is_pcie) | 1614 | if (tmp->is_pcie) |
1245 | return device_context_mapped(domain->iommu, | 1615 | return device_context_mapped(iommu, |
1246 | tmp->subordinate->number, 0); | 1616 | tmp->subordinate->number, 0); |
1247 | else | 1617 | else |
1248 | return device_context_mapped(domain->iommu, | 1618 | return device_context_mapped(iommu, |
1249 | tmp->bus->number, tmp->devfn); | 1619 | tmp->bus->number, tmp->devfn); |
1250 | } | 1620 | } |
1251 | 1621 | ||
@@ -1273,22 +1643,25 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, | |||
1273 | /* We don't need lock here, nobody else | 1643 | /* We don't need lock here, nobody else |
1274 | * touches the iova range | 1644 | * touches the iova range |
1275 | */ | 1645 | */ |
1276 | BUG_ON(dma_pte_addr(*pte)); | 1646 | BUG_ON(dma_pte_addr(pte)); |
1277 | dma_set_pte_addr(*pte, start_pfn << VTD_PAGE_SHIFT); | 1647 | dma_set_pte_addr(pte, start_pfn << VTD_PAGE_SHIFT); |
1278 | dma_set_pte_prot(*pte, prot); | 1648 | dma_set_pte_prot(pte, prot); |
1279 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | 1649 | domain_flush_cache(domain, pte, sizeof(*pte)); |
1280 | start_pfn++; | 1650 | start_pfn++; |
1281 | index++; | 1651 | index++; |
1282 | } | 1652 | } |
1283 | return 0; | 1653 | return 0; |
1284 | } | 1654 | } |
1285 | 1655 | ||
1286 | static void detach_domain_for_dev(struct dmar_domain *domain, u8 bus, u8 devfn) | 1656 | static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn) |
1287 | { | 1657 | { |
1288 | clear_context_table(domain->iommu, bus, devfn); | 1658 | if (!iommu) |
1289 | domain->iommu->flush.flush_context(domain->iommu, 0, 0, 0, | 1659 | return; |
1660 | |||
1661 | clear_context_table(iommu, bus, devfn); | ||
1662 | iommu->flush.flush_context(iommu, 0, 0, 0, | ||
1290 | DMA_CCMD_GLOBAL_INVL, 0); | 1663 | DMA_CCMD_GLOBAL_INVL, 0); |
1291 | domain->iommu->flush.flush_iotlb(domain->iommu, 0, 0, 0, | 1664 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, |
1292 | DMA_TLB_GLOBAL_FLUSH, 0); | 1665 | DMA_TLB_GLOBAL_FLUSH, 0); |
1293 | } | 1666 | } |
1294 | 1667 | ||
@@ -1296,6 +1669,7 @@ static void domain_remove_dev_info(struct dmar_domain *domain) | |||
1296 | { | 1669 | { |
1297 | struct device_domain_info *info; | 1670 | struct device_domain_info *info; |
1298 | unsigned long flags; | 1671 | unsigned long flags; |
1672 | struct intel_iommu *iommu; | ||
1299 | 1673 | ||
1300 | spin_lock_irqsave(&device_domain_lock, flags); | 1674 | spin_lock_irqsave(&device_domain_lock, flags); |
1301 | while (!list_empty(&domain->devices)) { | 1675 | while (!list_empty(&domain->devices)) { |
@@ -1307,7 +1681,8 @@ static void domain_remove_dev_info(struct dmar_domain *domain) | |||
1307 | info->dev->dev.archdata.iommu = NULL; | 1681 | info->dev->dev.archdata.iommu = NULL; |
1308 | spin_unlock_irqrestore(&device_domain_lock, flags); | 1682 | spin_unlock_irqrestore(&device_domain_lock, flags); |
1309 | 1683 | ||
1310 | detach_domain_for_dev(info->domain, info->bus, info->devfn); | 1684 | iommu = device_to_iommu(info->bus, info->devfn); |
1685 | iommu_detach_dev(iommu, info->bus, info->devfn); | ||
1311 | free_devinfo_mem(info); | 1686 | free_devinfo_mem(info); |
1312 | 1687 | ||
1313 | spin_lock_irqsave(&device_domain_lock, flags); | 1688 | spin_lock_irqsave(&device_domain_lock, flags); |
@@ -1400,7 +1775,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw) | |||
1400 | info->dev = NULL; | 1775 | info->dev = NULL; |
1401 | info->domain = domain; | 1776 | info->domain = domain; |
1402 | /* This domain is shared by devices under p2p bridge */ | 1777 | /* This domain is shared by devices under p2p bridge */ |
1403 | domain->flags |= DOMAIN_FLAG_MULTIPLE_DEVICES; | 1778 | domain->flags |= DOMAIN_FLAG_P2P_MULTIPLE_DEVICES; |
1404 | 1779 | ||
1405 | /* pcie-to-pci bridge already has a domain, uses it */ | 1780 | /* pcie-to-pci bridge already has a domain, uses it */ |
1406 | found = NULL; | 1781 | found = NULL; |
@@ -1563,6 +1938,11 @@ static void __init iommu_prepare_gfx_mapping(void) | |||
1563 | printk(KERN_ERR "IOMMU: mapping reserved region failed\n"); | 1938 | printk(KERN_ERR "IOMMU: mapping reserved region failed\n"); |
1564 | } | 1939 | } |
1565 | } | 1940 | } |
1941 | #else /* !CONFIG_DMAR_GFX_WA */ | ||
1942 | static inline void iommu_prepare_gfx_mapping(void) | ||
1943 | { | ||
1944 | return; | ||
1945 | } | ||
1566 | #endif | 1946 | #endif |
1567 | 1947 | ||
1568 | #ifdef CONFIG_DMAR_FLOPPY_WA | 1948 | #ifdef CONFIG_DMAR_FLOPPY_WA |
@@ -1590,7 +1970,7 @@ static inline void iommu_prepare_isa(void) | |||
1590 | } | 1970 | } |
1591 | #endif /* !CONFIG_DMAR_FLPY_WA */ | 1971 | #endif /* !CONFIG_DMAR_FLPY_WA */ |
1592 | 1972 | ||
1593 | int __init init_dmars(void) | 1973 | static int __init init_dmars(void) |
1594 | { | 1974 | { |
1595 | struct dmar_drhd_unit *drhd; | 1975 | struct dmar_drhd_unit *drhd; |
1596 | struct dmar_rmrr_unit *rmrr; | 1976 | struct dmar_rmrr_unit *rmrr; |
@@ -1613,9 +1993,18 @@ int __init init_dmars(void) | |||
1613 | */ | 1993 | */ |
1614 | } | 1994 | } |
1615 | 1995 | ||
1996 | g_iommus = kcalloc(g_num_of_iommus, sizeof(struct intel_iommu *), | ||
1997 | GFP_KERNEL); | ||
1998 | if (!g_iommus) { | ||
1999 | printk(KERN_ERR "Allocating global iommu array failed\n"); | ||
2000 | ret = -ENOMEM; | ||
2001 | goto error; | ||
2002 | } | ||
2003 | |||
1616 | deferred_flush = kzalloc(g_num_of_iommus * | 2004 | deferred_flush = kzalloc(g_num_of_iommus * |
1617 | sizeof(struct deferred_flush_tables), GFP_KERNEL); | 2005 | sizeof(struct deferred_flush_tables), GFP_KERNEL); |
1618 | if (!deferred_flush) { | 2006 | if (!deferred_flush) { |
2007 | kfree(g_iommus); | ||
1619 | ret = -ENOMEM; | 2008 | ret = -ENOMEM; |
1620 | goto error; | 2009 | goto error; |
1621 | } | 2010 | } |
@@ -1625,6 +2014,7 @@ int __init init_dmars(void) | |||
1625 | continue; | 2014 | continue; |
1626 | 2015 | ||
1627 | iommu = drhd->iommu; | 2016 | iommu = drhd->iommu; |
2017 | g_iommus[iommu->seq_id] = iommu; | ||
1628 | 2018 | ||
1629 | ret = iommu_init_domains(iommu); | 2019 | ret = iommu_init_domains(iommu); |
1630 | if (ret) | 2020 | if (ret) |
@@ -1737,6 +2127,7 @@ error: | |||
1737 | iommu = drhd->iommu; | 2127 | iommu = drhd->iommu; |
1738 | free_iommu(iommu); | 2128 | free_iommu(iommu); |
1739 | } | 2129 | } |
2130 | kfree(g_iommus); | ||
1740 | return ret; | 2131 | return ret; |
1741 | } | 2132 | } |
1742 | 2133 | ||
@@ -1805,7 +2196,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev) | |||
1805 | } | 2196 | } |
1806 | 2197 | ||
1807 | /* make sure context mapping is ok */ | 2198 | /* make sure context mapping is ok */ |
1808 | if (unlikely(!domain_context_mapped(domain, pdev))) { | 2199 | if (unlikely(!domain_context_mapped(pdev))) { |
1809 | ret = domain_context_mapping(domain, pdev); | 2200 | ret = domain_context_mapping(domain, pdev); |
1810 | if (ret) { | 2201 | if (ret) { |
1811 | printk(KERN_ERR | 2202 | printk(KERN_ERR |
@@ -1827,6 +2218,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, | |||
1827 | struct iova *iova; | 2218 | struct iova *iova; |
1828 | int prot = 0; | 2219 | int prot = 0; |
1829 | int ret; | 2220 | int ret; |
2221 | struct intel_iommu *iommu; | ||
1830 | 2222 | ||
1831 | BUG_ON(dir == DMA_NONE); | 2223 | BUG_ON(dir == DMA_NONE); |
1832 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | 2224 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) |
@@ -1836,6 +2228,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, | |||
1836 | if (!domain) | 2228 | if (!domain) |
1837 | return 0; | 2229 | return 0; |
1838 | 2230 | ||
2231 | iommu = domain_get_iommu(domain); | ||
1839 | size = aligned_size((u64)paddr, size); | 2232 | size = aligned_size((u64)paddr, size); |
1840 | 2233 | ||
1841 | iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); | 2234 | iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); |
@@ -1849,7 +2242,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, | |||
1849 | * mappings.. | 2242 | * mappings.. |
1850 | */ | 2243 | */ |
1851 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ | 2244 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ |
1852 | !cap_zlr(domain->iommu->cap)) | 2245 | !cap_zlr(iommu->cap)) |
1853 | prot |= DMA_PTE_READ; | 2246 | prot |= DMA_PTE_READ; |
1854 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) | 2247 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) |
1855 | prot |= DMA_PTE_WRITE; | 2248 | prot |= DMA_PTE_WRITE; |
@@ -1865,10 +2258,10 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, | |||
1865 | goto error; | 2258 | goto error; |
1866 | 2259 | ||
1867 | /* it's a non-present to present mapping */ | 2260 | /* it's a non-present to present mapping */ |
1868 | ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, | 2261 | ret = iommu_flush_iotlb_psi(iommu, domain->id, |
1869 | start_paddr, size >> VTD_PAGE_SHIFT, 1); | 2262 | start_paddr, size >> VTD_PAGE_SHIFT, 1); |
1870 | if (ret) | 2263 | if (ret) |
1871 | iommu_flush_write_buffer(domain->iommu); | 2264 | iommu_flush_write_buffer(iommu); |
1872 | 2265 | ||
1873 | return start_paddr + ((u64)paddr & (~PAGE_MASK)); | 2266 | return start_paddr + ((u64)paddr & (~PAGE_MASK)); |
1874 | 2267 | ||
@@ -1895,10 +2288,11 @@ static void flush_unmaps(void) | |||
1895 | 2288 | ||
1896 | /* just flush them all */ | 2289 | /* just flush them all */ |
1897 | for (i = 0; i < g_num_of_iommus; i++) { | 2290 | for (i = 0; i < g_num_of_iommus; i++) { |
1898 | if (deferred_flush[i].next) { | 2291 | struct intel_iommu *iommu = g_iommus[i]; |
1899 | struct intel_iommu *iommu = | 2292 | if (!iommu) |
1900 | deferred_flush[i].domain[0]->iommu; | 2293 | continue; |
1901 | 2294 | ||
2295 | if (deferred_flush[i].next) { | ||
1902 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, | 2296 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, |
1903 | DMA_TLB_GLOBAL_FLUSH, 0); | 2297 | DMA_TLB_GLOBAL_FLUSH, 0); |
1904 | for (j = 0; j < deferred_flush[i].next; j++) { | 2298 | for (j = 0; j < deferred_flush[i].next; j++) { |
@@ -1925,12 +2319,14 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova) | |||
1925 | { | 2319 | { |
1926 | unsigned long flags; | 2320 | unsigned long flags; |
1927 | int next, iommu_id; | 2321 | int next, iommu_id; |
2322 | struct intel_iommu *iommu; | ||
1928 | 2323 | ||
1929 | spin_lock_irqsave(&async_umap_flush_lock, flags); | 2324 | spin_lock_irqsave(&async_umap_flush_lock, flags); |
1930 | if (list_size == HIGH_WATER_MARK) | 2325 | if (list_size == HIGH_WATER_MARK) |
1931 | flush_unmaps(); | 2326 | flush_unmaps(); |
1932 | 2327 | ||
1933 | iommu_id = dom->iommu->seq_id; | 2328 | iommu = domain_get_iommu(dom); |
2329 | iommu_id = iommu->seq_id; | ||
1934 | 2330 | ||
1935 | next = deferred_flush[iommu_id].next; | 2331 | next = deferred_flush[iommu_id].next; |
1936 | deferred_flush[iommu_id].domain[next] = dom; | 2332 | deferred_flush[iommu_id].domain[next] = dom; |
@@ -1952,12 +2348,15 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | |||
1952 | struct dmar_domain *domain; | 2348 | struct dmar_domain *domain; |
1953 | unsigned long start_addr; | 2349 | unsigned long start_addr; |
1954 | struct iova *iova; | 2350 | struct iova *iova; |
2351 | struct intel_iommu *iommu; | ||
1955 | 2352 | ||
1956 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | 2353 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) |
1957 | return; | 2354 | return; |
1958 | domain = find_domain(pdev); | 2355 | domain = find_domain(pdev); |
1959 | BUG_ON(!domain); | 2356 | BUG_ON(!domain); |
1960 | 2357 | ||
2358 | iommu = domain_get_iommu(domain); | ||
2359 | |||
1961 | iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr)); | 2360 | iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr)); |
1962 | if (!iova) | 2361 | if (!iova) |
1963 | return; | 2362 | return; |
@@ -1973,9 +2372,9 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | |||
1973 | /* free page tables */ | 2372 | /* free page tables */ |
1974 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | 2373 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); |
1975 | if (intel_iommu_strict) { | 2374 | if (intel_iommu_strict) { |
1976 | if (iommu_flush_iotlb_psi(domain->iommu, | 2375 | if (iommu_flush_iotlb_psi(iommu, |
1977 | domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0)) | 2376 | domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0)) |
1978 | iommu_flush_write_buffer(domain->iommu); | 2377 | iommu_flush_write_buffer(iommu); |
1979 | /* free iova */ | 2378 | /* free iova */ |
1980 | __free_iova(&domain->iovad, iova); | 2379 | __free_iova(&domain->iovad, iova); |
1981 | } else { | 2380 | } else { |
@@ -2036,11 +2435,15 @@ void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2036 | size_t size = 0; | 2435 | size_t size = 0; |
2037 | void *addr; | 2436 | void *addr; |
2038 | struct scatterlist *sg; | 2437 | struct scatterlist *sg; |
2438 | struct intel_iommu *iommu; | ||
2039 | 2439 | ||
2040 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | 2440 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) |
2041 | return; | 2441 | return; |
2042 | 2442 | ||
2043 | domain = find_domain(pdev); | 2443 | domain = find_domain(pdev); |
2444 | BUG_ON(!domain); | ||
2445 | |||
2446 | iommu = domain_get_iommu(domain); | ||
2044 | 2447 | ||
2045 | iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address)); | 2448 | iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address)); |
2046 | if (!iova) | 2449 | if (!iova) |
@@ -2057,9 +2460,9 @@ void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2057 | /* free page tables */ | 2460 | /* free page tables */ |
2058 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | 2461 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); |
2059 | 2462 | ||
2060 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, | 2463 | if (iommu_flush_iotlb_psi(iommu, domain->id, start_addr, |
2061 | size >> VTD_PAGE_SHIFT, 0)) | 2464 | size >> VTD_PAGE_SHIFT, 0)) |
2062 | iommu_flush_write_buffer(domain->iommu); | 2465 | iommu_flush_write_buffer(iommu); |
2063 | 2466 | ||
2064 | /* free iova */ | 2467 | /* free iova */ |
2065 | __free_iova(&domain->iovad, iova); | 2468 | __free_iova(&domain->iovad, iova); |
@@ -2093,6 +2496,7 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2093 | int ret; | 2496 | int ret; |
2094 | struct scatterlist *sg; | 2497 | struct scatterlist *sg; |
2095 | unsigned long start_addr; | 2498 | unsigned long start_addr; |
2499 | struct intel_iommu *iommu; | ||
2096 | 2500 | ||
2097 | BUG_ON(dir == DMA_NONE); | 2501 | BUG_ON(dir == DMA_NONE); |
2098 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | 2502 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) |
@@ -2102,6 +2506,8 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2102 | if (!domain) | 2506 | if (!domain) |
2103 | return 0; | 2507 | return 0; |
2104 | 2508 | ||
2509 | iommu = domain_get_iommu(domain); | ||
2510 | |||
2105 | for_each_sg(sglist, sg, nelems, i) { | 2511 | for_each_sg(sglist, sg, nelems, i) { |
2106 | addr = SG_ENT_VIRT_ADDRESS(sg); | 2512 | addr = SG_ENT_VIRT_ADDRESS(sg); |
2107 | addr = (void *)virt_to_phys(addr); | 2513 | addr = (void *)virt_to_phys(addr); |
@@ -2119,7 +2525,7 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2119 | * mappings.. | 2525 | * mappings.. |
2120 | */ | 2526 | */ |
2121 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ | 2527 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ |
2122 | !cap_zlr(domain->iommu->cap)) | 2528 | !cap_zlr(iommu->cap)) |
2123 | prot |= DMA_PTE_READ; | 2529 | prot |= DMA_PTE_READ; |
2124 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) | 2530 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) |
2125 | prot |= DMA_PTE_WRITE; | 2531 | prot |= DMA_PTE_WRITE; |
@@ -2151,9 +2557,9 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2151 | } | 2557 | } |
2152 | 2558 | ||
2153 | /* it's a non-present to present mapping */ | 2559 | /* it's a non-present to present mapping */ |
2154 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, | 2560 | if (iommu_flush_iotlb_psi(iommu, domain->id, |
2155 | start_addr, offset >> VTD_PAGE_SHIFT, 1)) | 2561 | start_addr, offset >> VTD_PAGE_SHIFT, 1)) |
2156 | iommu_flush_write_buffer(domain->iommu); | 2562 | iommu_flush_write_buffer(iommu); |
2157 | return nelems; | 2563 | return nelems; |
2158 | } | 2564 | } |
2159 | 2565 | ||
@@ -2325,10 +2731,220 @@ int __init intel_iommu_init(void) | |||
2325 | init_timer(&unmap_timer); | 2731 | init_timer(&unmap_timer); |
2326 | force_iommu = 1; | 2732 | force_iommu = 1; |
2327 | dma_ops = &intel_dma_ops; | 2733 | dma_ops = &intel_dma_ops; |
2734 | |||
2735 | register_iommu(&intel_iommu_ops); | ||
2736 | |||
2737 | return 0; | ||
2738 | } | ||
2739 | |||
2740 | static int vm_domain_add_dev_info(struct dmar_domain *domain, | ||
2741 | struct pci_dev *pdev) | ||
2742 | { | ||
2743 | struct device_domain_info *info; | ||
2744 | unsigned long flags; | ||
2745 | |||
2746 | info = alloc_devinfo_mem(); | ||
2747 | if (!info) | ||
2748 | return -ENOMEM; | ||
2749 | |||
2750 | info->bus = pdev->bus->number; | ||
2751 | info->devfn = pdev->devfn; | ||
2752 | info->dev = pdev; | ||
2753 | info->domain = domain; | ||
2754 | |||
2755 | spin_lock_irqsave(&device_domain_lock, flags); | ||
2756 | list_add(&info->link, &domain->devices); | ||
2757 | list_add(&info->global, &device_domain_list); | ||
2758 | pdev->dev.archdata.iommu = info; | ||
2759 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
2760 | |||
2761 | return 0; | ||
2762 | } | ||
2763 | |||
2764 | static void vm_domain_remove_one_dev_info(struct dmar_domain *domain, | ||
2765 | struct pci_dev *pdev) | ||
2766 | { | ||
2767 | struct device_domain_info *info; | ||
2768 | struct intel_iommu *iommu; | ||
2769 | unsigned long flags; | ||
2770 | int found = 0; | ||
2771 | struct list_head *entry, *tmp; | ||
2772 | |||
2773 | iommu = device_to_iommu(pdev->bus->number, pdev->devfn); | ||
2774 | if (!iommu) | ||
2775 | return; | ||
2776 | |||
2777 | spin_lock_irqsave(&device_domain_lock, flags); | ||
2778 | list_for_each_safe(entry, tmp, &domain->devices) { | ||
2779 | info = list_entry(entry, struct device_domain_info, link); | ||
2780 | if (info->bus == pdev->bus->number && | ||
2781 | info->devfn == pdev->devfn) { | ||
2782 | list_del(&info->link); | ||
2783 | list_del(&info->global); | ||
2784 | if (info->dev) | ||
2785 | info->dev->dev.archdata.iommu = NULL; | ||
2786 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
2787 | |||
2788 | iommu_detach_dev(iommu, info->bus, info->devfn); | ||
2789 | free_devinfo_mem(info); | ||
2790 | |||
2791 | spin_lock_irqsave(&device_domain_lock, flags); | ||
2792 | |||
2793 | if (found) | ||
2794 | break; | ||
2795 | else | ||
2796 | continue; | ||
2797 | } | ||
2798 | |||
2799 | /* if there is no other devices under the same iommu | ||
2800 | * owned by this domain, clear this iommu in iommu_bmp | ||
2801 | * update iommu count and coherency | ||
2802 | */ | ||
2803 | if (device_to_iommu(info->bus, info->devfn) == iommu) | ||
2804 | found = 1; | ||
2805 | } | ||
2806 | |||
2807 | if (found == 0) { | ||
2808 | unsigned long tmp_flags; | ||
2809 | spin_lock_irqsave(&domain->iommu_lock, tmp_flags); | ||
2810 | clear_bit(iommu->seq_id, &domain->iommu_bmp); | ||
2811 | domain->iommu_count--; | ||
2812 | domain_update_iommu_coherency(domain); | ||
2813 | spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); | ||
2814 | } | ||
2815 | |||
2816 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
2817 | } | ||
2818 | |||
2819 | static void vm_domain_remove_all_dev_info(struct dmar_domain *domain) | ||
2820 | { | ||
2821 | struct device_domain_info *info; | ||
2822 | struct intel_iommu *iommu; | ||
2823 | unsigned long flags1, flags2; | ||
2824 | |||
2825 | spin_lock_irqsave(&device_domain_lock, flags1); | ||
2826 | while (!list_empty(&domain->devices)) { | ||
2827 | info = list_entry(domain->devices.next, | ||
2828 | struct device_domain_info, link); | ||
2829 | list_del(&info->link); | ||
2830 | list_del(&info->global); | ||
2831 | if (info->dev) | ||
2832 | info->dev->dev.archdata.iommu = NULL; | ||
2833 | |||
2834 | spin_unlock_irqrestore(&device_domain_lock, flags1); | ||
2835 | |||
2836 | iommu = device_to_iommu(info->bus, info->devfn); | ||
2837 | iommu_detach_dev(iommu, info->bus, info->devfn); | ||
2838 | |||
2839 | /* clear this iommu in iommu_bmp, update iommu count | ||
2840 | * and coherency | ||
2841 | */ | ||
2842 | spin_lock_irqsave(&domain->iommu_lock, flags2); | ||
2843 | if (test_and_clear_bit(iommu->seq_id, | ||
2844 | &domain->iommu_bmp)) { | ||
2845 | domain->iommu_count--; | ||
2846 | domain_update_iommu_coherency(domain); | ||
2847 | } | ||
2848 | spin_unlock_irqrestore(&domain->iommu_lock, flags2); | ||
2849 | |||
2850 | free_devinfo_mem(info); | ||
2851 | spin_lock_irqsave(&device_domain_lock, flags1); | ||
2852 | } | ||
2853 | spin_unlock_irqrestore(&device_domain_lock, flags1); | ||
2854 | } | ||
2855 | |||
2856 | /* domain id for virtual machine, it won't be set in context */ | ||
2857 | static unsigned long vm_domid; | ||
2858 | |||
2859 | static int vm_domain_min_agaw(struct dmar_domain *domain) | ||
2860 | { | ||
2861 | int i; | ||
2862 | int min_agaw = domain->agaw; | ||
2863 | |||
2864 | i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus); | ||
2865 | for (; i < g_num_of_iommus; ) { | ||
2866 | if (min_agaw > g_iommus[i]->agaw) | ||
2867 | min_agaw = g_iommus[i]->agaw; | ||
2868 | |||
2869 | i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1); | ||
2870 | } | ||
2871 | |||
2872 | return min_agaw; | ||
2873 | } | ||
2874 | |||
2875 | static struct dmar_domain *iommu_alloc_vm_domain(void) | ||
2876 | { | ||
2877 | struct dmar_domain *domain; | ||
2878 | |||
2879 | domain = alloc_domain_mem(); | ||
2880 | if (!domain) | ||
2881 | return NULL; | ||
2882 | |||
2883 | domain->id = vm_domid++; | ||
2884 | memset(&domain->iommu_bmp, 0, sizeof(unsigned long)); | ||
2885 | domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE; | ||
2886 | |||
2887 | return domain; | ||
2888 | } | ||
2889 | |||
2890 | static int vm_domain_init(struct dmar_domain *domain, int guest_width) | ||
2891 | { | ||
2892 | int adjust_width; | ||
2893 | |||
2894 | init_iova_domain(&domain->iovad, DMA_32BIT_PFN); | ||
2895 | spin_lock_init(&domain->mapping_lock); | ||
2896 | spin_lock_init(&domain->iommu_lock); | ||
2897 | |||
2898 | domain_reserve_special_ranges(domain); | ||
2899 | |||
2900 | /* calculate AGAW */ | ||
2901 | domain->gaw = guest_width; | ||
2902 | adjust_width = guestwidth_to_adjustwidth(guest_width); | ||
2903 | domain->agaw = width_to_agaw(adjust_width); | ||
2904 | |||
2905 | INIT_LIST_HEAD(&domain->devices); | ||
2906 | |||
2907 | domain->iommu_count = 0; | ||
2908 | domain->iommu_coherency = 0; | ||
2909 | domain->max_addr = 0; | ||
2910 | |||
2911 | /* always allocate the top pgd */ | ||
2912 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); | ||
2913 | if (!domain->pgd) | ||
2914 | return -ENOMEM; | ||
2915 | domain_flush_cache(domain, domain->pgd, PAGE_SIZE); | ||
2328 | return 0; | 2916 | return 0; |
2329 | } | 2917 | } |
2330 | 2918 | ||
2331 | void intel_iommu_domain_exit(struct dmar_domain *domain) | 2919 | static void iommu_free_vm_domain(struct dmar_domain *domain) |
2920 | { | ||
2921 | unsigned long flags; | ||
2922 | struct dmar_drhd_unit *drhd; | ||
2923 | struct intel_iommu *iommu; | ||
2924 | unsigned long i; | ||
2925 | unsigned long ndomains; | ||
2926 | |||
2927 | for_each_drhd_unit(drhd) { | ||
2928 | if (drhd->ignored) | ||
2929 | continue; | ||
2930 | iommu = drhd->iommu; | ||
2931 | |||
2932 | ndomains = cap_ndoms(iommu->cap); | ||
2933 | i = find_first_bit(iommu->domain_ids, ndomains); | ||
2934 | for (; i < ndomains; ) { | ||
2935 | if (iommu->domains[i] == domain) { | ||
2936 | spin_lock_irqsave(&iommu->lock, flags); | ||
2937 | clear_bit(i, iommu->domain_ids); | ||
2938 | iommu->domains[i] = NULL; | ||
2939 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
2940 | break; | ||
2941 | } | ||
2942 | i = find_next_bit(iommu->domain_ids, ndomains, i+1); | ||
2943 | } | ||
2944 | } | ||
2945 | } | ||
2946 | |||
2947 | static void vm_domain_exit(struct dmar_domain *domain) | ||
2332 | { | 2948 | { |
2333 | u64 end; | 2949 | u64 end; |
2334 | 2950 | ||
@@ -2336,6 +2952,9 @@ void intel_iommu_domain_exit(struct dmar_domain *domain) | |||
2336 | if (!domain) | 2952 | if (!domain) |
2337 | return; | 2953 | return; |
2338 | 2954 | ||
2955 | vm_domain_remove_all_dev_info(domain); | ||
2956 | /* destroy iovas */ | ||
2957 | put_iova_domain(&domain->iovad); | ||
2339 | end = DOMAIN_MAX_ADDR(domain->gaw); | 2958 | end = DOMAIN_MAX_ADDR(domain->gaw); |
2340 | end = end & (~VTD_PAGE_MASK); | 2959 | end = end & (~VTD_PAGE_MASK); |
2341 | 2960 | ||
@@ -2345,94 +2964,167 @@ void intel_iommu_domain_exit(struct dmar_domain *domain) | |||
2345 | /* free page tables */ | 2964 | /* free page tables */ |
2346 | dma_pte_free_pagetable(domain, 0, end); | 2965 | dma_pte_free_pagetable(domain, 0, end); |
2347 | 2966 | ||
2348 | iommu_free_domain(domain); | 2967 | iommu_free_vm_domain(domain); |
2349 | free_domain_mem(domain); | 2968 | free_domain_mem(domain); |
2350 | } | 2969 | } |
2351 | EXPORT_SYMBOL_GPL(intel_iommu_domain_exit); | ||
2352 | 2970 | ||
2353 | struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev) | 2971 | static int intel_iommu_domain_init(struct iommu_domain *domain) |
2354 | { | 2972 | { |
2355 | struct dmar_drhd_unit *drhd; | 2973 | struct dmar_domain *dmar_domain; |
2356 | struct dmar_domain *domain; | ||
2357 | struct intel_iommu *iommu; | ||
2358 | |||
2359 | drhd = dmar_find_matched_drhd_unit(pdev); | ||
2360 | if (!drhd) { | ||
2361 | printk(KERN_ERR "intel_iommu_domain_alloc: drhd == NULL\n"); | ||
2362 | return NULL; | ||
2363 | } | ||
2364 | 2974 | ||
2365 | iommu = drhd->iommu; | 2975 | dmar_domain = iommu_alloc_vm_domain(); |
2366 | if (!iommu) { | 2976 | if (!dmar_domain) { |
2367 | printk(KERN_ERR | ||
2368 | "intel_iommu_domain_alloc: iommu == NULL\n"); | ||
2369 | return NULL; | ||
2370 | } | ||
2371 | domain = iommu_alloc_domain(iommu); | ||
2372 | if (!domain) { | ||
2373 | printk(KERN_ERR | 2977 | printk(KERN_ERR |
2374 | "intel_iommu_domain_alloc: domain == NULL\n"); | 2978 | "intel_iommu_domain_init: dmar_domain == NULL\n"); |
2375 | return NULL; | 2979 | return -ENOMEM; |
2376 | } | 2980 | } |
2377 | if (domain_init(domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) { | 2981 | if (vm_domain_init(dmar_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) { |
2378 | printk(KERN_ERR | 2982 | printk(KERN_ERR |
2379 | "intel_iommu_domain_alloc: domain_init() failed\n"); | 2983 | "intel_iommu_domain_init() failed\n"); |
2380 | intel_iommu_domain_exit(domain); | 2984 | vm_domain_exit(dmar_domain); |
2381 | return NULL; | 2985 | return -ENOMEM; |
2382 | } | 2986 | } |
2383 | return domain; | 2987 | domain->priv = dmar_domain; |
2988 | |||
2989 | return 0; | ||
2384 | } | 2990 | } |
2385 | EXPORT_SYMBOL_GPL(intel_iommu_domain_alloc); | ||
2386 | 2991 | ||
2387 | int intel_iommu_context_mapping( | 2992 | static void intel_iommu_domain_destroy(struct iommu_domain *domain) |
2388 | struct dmar_domain *domain, struct pci_dev *pdev) | ||
2389 | { | 2993 | { |
2390 | int rc; | 2994 | struct dmar_domain *dmar_domain = domain->priv; |
2391 | rc = domain_context_mapping(domain, pdev); | 2995 | |
2392 | return rc; | 2996 | domain->priv = NULL; |
2997 | vm_domain_exit(dmar_domain); | ||
2393 | } | 2998 | } |
2394 | EXPORT_SYMBOL_GPL(intel_iommu_context_mapping); | ||
2395 | 2999 | ||
2396 | int intel_iommu_page_mapping( | 3000 | static int intel_iommu_attach_device(struct iommu_domain *domain, |
2397 | struct dmar_domain *domain, dma_addr_t iova, | 3001 | struct device *dev) |
2398 | u64 hpa, size_t size, int prot) | ||
2399 | { | 3002 | { |
2400 | int rc; | 3003 | struct dmar_domain *dmar_domain = domain->priv; |
2401 | rc = domain_page_mapping(domain, iova, hpa, size, prot); | 3004 | struct pci_dev *pdev = to_pci_dev(dev); |
2402 | return rc; | 3005 | struct intel_iommu *iommu; |
3006 | int addr_width; | ||
3007 | u64 end; | ||
3008 | int ret; | ||
3009 | |||
3010 | /* normally pdev is not mapped */ | ||
3011 | if (unlikely(domain_context_mapped(pdev))) { | ||
3012 | struct dmar_domain *old_domain; | ||
3013 | |||
3014 | old_domain = find_domain(pdev); | ||
3015 | if (old_domain) { | ||
3016 | if (dmar_domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) | ||
3017 | vm_domain_remove_one_dev_info(old_domain, pdev); | ||
3018 | else | ||
3019 | domain_remove_dev_info(old_domain); | ||
3020 | } | ||
3021 | } | ||
3022 | |||
3023 | iommu = device_to_iommu(pdev->bus->number, pdev->devfn); | ||
3024 | if (!iommu) | ||
3025 | return -ENODEV; | ||
3026 | |||
3027 | /* check if this iommu agaw is sufficient for max mapped address */ | ||
3028 | addr_width = agaw_to_width(iommu->agaw); | ||
3029 | end = DOMAIN_MAX_ADDR(addr_width); | ||
3030 | end = end & VTD_PAGE_MASK; | ||
3031 | if (end < dmar_domain->max_addr) { | ||
3032 | printk(KERN_ERR "%s: iommu agaw (%d) is not " | ||
3033 | "sufficient for the mapped address (%llx)\n", | ||
3034 | __func__, iommu->agaw, dmar_domain->max_addr); | ||
3035 | return -EFAULT; | ||
3036 | } | ||
3037 | |||
3038 | ret = domain_context_mapping(dmar_domain, pdev); | ||
3039 | if (ret) | ||
3040 | return ret; | ||
3041 | |||
3042 | ret = vm_domain_add_dev_info(dmar_domain, pdev); | ||
3043 | return ret; | ||
2403 | } | 3044 | } |
2404 | EXPORT_SYMBOL_GPL(intel_iommu_page_mapping); | ||
2405 | 3045 | ||
2406 | void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn) | 3046 | static void intel_iommu_detach_device(struct iommu_domain *domain, |
3047 | struct device *dev) | ||
2407 | { | 3048 | { |
2408 | detach_domain_for_dev(domain, bus, devfn); | 3049 | struct dmar_domain *dmar_domain = domain->priv; |
3050 | struct pci_dev *pdev = to_pci_dev(dev); | ||
3051 | |||
3052 | vm_domain_remove_one_dev_info(dmar_domain, pdev); | ||
2409 | } | 3053 | } |
2410 | EXPORT_SYMBOL_GPL(intel_iommu_detach_dev); | ||
2411 | 3054 | ||
2412 | struct dmar_domain * | 3055 | static int intel_iommu_map_range(struct iommu_domain *domain, |
2413 | intel_iommu_find_domain(struct pci_dev *pdev) | 3056 | unsigned long iova, phys_addr_t hpa, |
3057 | size_t size, int iommu_prot) | ||
2414 | { | 3058 | { |
2415 | return find_domain(pdev); | 3059 | struct dmar_domain *dmar_domain = domain->priv; |
3060 | u64 max_addr; | ||
3061 | int addr_width; | ||
3062 | int prot = 0; | ||
3063 | int ret; | ||
3064 | |||
3065 | if (iommu_prot & IOMMU_READ) | ||
3066 | prot |= DMA_PTE_READ; | ||
3067 | if (iommu_prot & IOMMU_WRITE) | ||
3068 | prot |= DMA_PTE_WRITE; | ||
3069 | |||
3070 | max_addr = (iova & VTD_PAGE_MASK) + VTD_PAGE_ALIGN(size); | ||
3071 | if (dmar_domain->max_addr < max_addr) { | ||
3072 | int min_agaw; | ||
3073 | u64 end; | ||
3074 | |||
3075 | /* check if minimum agaw is sufficient for mapped address */ | ||
3076 | min_agaw = vm_domain_min_agaw(dmar_domain); | ||
3077 | addr_width = agaw_to_width(min_agaw); | ||
3078 | end = DOMAIN_MAX_ADDR(addr_width); | ||
3079 | end = end & VTD_PAGE_MASK; | ||
3080 | if (end < max_addr) { | ||
3081 | printk(KERN_ERR "%s: iommu agaw (%d) is not " | ||
3082 | "sufficient for the mapped address (%llx)\n", | ||
3083 | __func__, min_agaw, max_addr); | ||
3084 | return -EFAULT; | ||
3085 | } | ||
3086 | dmar_domain->max_addr = max_addr; | ||
3087 | } | ||
3088 | |||
3089 | ret = domain_page_mapping(dmar_domain, iova, hpa, size, prot); | ||
3090 | return ret; | ||
2416 | } | 3091 | } |
2417 | EXPORT_SYMBOL_GPL(intel_iommu_find_domain); | ||
2418 | 3092 | ||
2419 | int intel_iommu_found(void) | 3093 | static void intel_iommu_unmap_range(struct iommu_domain *domain, |
3094 | unsigned long iova, size_t size) | ||
2420 | { | 3095 | { |
2421 | return g_num_of_iommus; | 3096 | struct dmar_domain *dmar_domain = domain->priv; |
3097 | dma_addr_t base; | ||
3098 | |||
3099 | /* The address might not be aligned */ | ||
3100 | base = iova & VTD_PAGE_MASK; | ||
3101 | size = VTD_PAGE_ALIGN(size); | ||
3102 | dma_pte_clear_range(dmar_domain, base, base + size); | ||
3103 | |||
3104 | if (dmar_domain->max_addr == base + size) | ||
3105 | dmar_domain->max_addr = base; | ||
2422 | } | 3106 | } |
2423 | EXPORT_SYMBOL_GPL(intel_iommu_found); | ||
2424 | 3107 | ||
2425 | u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova) | 3108 | static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, |
3109 | unsigned long iova) | ||
2426 | { | 3110 | { |
3111 | struct dmar_domain *dmar_domain = domain->priv; | ||
2427 | struct dma_pte *pte; | 3112 | struct dma_pte *pte; |
2428 | u64 pfn; | 3113 | u64 phys = 0; |
2429 | |||
2430 | pfn = 0; | ||
2431 | pte = addr_to_dma_pte(domain, iova); | ||
2432 | 3114 | ||
3115 | pte = addr_to_dma_pte(dmar_domain, iova); | ||
2433 | if (pte) | 3116 | if (pte) |
2434 | pfn = dma_pte_addr(*pte); | 3117 | phys = dma_pte_addr(pte); |
2435 | 3118 | ||
2436 | return pfn >> VTD_PAGE_SHIFT; | 3119 | return phys; |
2437 | } | 3120 | } |
2438 | EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn); | 3121 | |
3122 | static struct iommu_ops intel_iommu_ops = { | ||
3123 | .domain_init = intel_iommu_domain_init, | ||
3124 | .domain_destroy = intel_iommu_domain_destroy, | ||
3125 | .attach_dev = intel_iommu_attach_device, | ||
3126 | .detach_dev = intel_iommu_detach_device, | ||
3127 | .map = intel_iommu_map_range, | ||
3128 | .unmap = intel_iommu_unmap_range, | ||
3129 | .iova_to_phys = intel_iommu_iova_to_phys, | ||
3130 | }; | ||
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index 7ff824496b39..7e6b5a3b3281 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c | |||
@@ -481,7 +481,7 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header) | |||
481 | 481 | ||
482 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); | 482 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); |
483 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); | 483 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); |
484 | for (i = 0; i < NR_CPUS; i++) { | 484 | for_each_possible_cpu(i) { |
485 | struct desc_struct *gdt = get_cpu_gdt_table(i); | 485 | struct desc_struct *gdt = get_cpu_gdt_table(i); |
486 | if (!gdt) | 486 | if (!gdt) |
487 | continue; | 487 | continue; |
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 8a8df7552969..06b71823f399 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c | |||
@@ -632,8 +632,8 @@ do_IRQ (struct pt_regs *regs) | |||
632 | struct pt_regs *old_regs; | 632 | struct pt_regs *old_regs; |
633 | 633 | ||
634 | old_regs = set_irq_regs(regs); | 634 | old_regs = set_irq_regs(regs); |
635 | irq_enter(); | ||
636 | s390_idle_check(); | 635 | s390_idle_check(); |
636 | irq_enter(); | ||
637 | if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator) | 637 | if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator) |
638 | /* Serve timer interrupts first. */ | 638 | /* Serve timer interrupts first. */ |
639 | clock_comparator_work(); | 639 | clock_comparator_work(); |
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c index 834e9ee7e934..92b0417f8e12 100644 --- a/drivers/s390/s390mach.c +++ b/drivers/s390/s390mach.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/etr.h> | 18 | #include <asm/etr.h> |
19 | #include <asm/lowcore.h> | 19 | #include <asm/lowcore.h> |
20 | #include <asm/cio.h> | 20 | #include <asm/cio.h> |
21 | #include <asm/cpu.h> | ||
21 | #include "s390mach.h" | 22 | #include "s390mach.h" |
22 | 23 | ||
23 | static struct semaphore m_sem; | 24 | static struct semaphore m_sem; |
@@ -369,6 +370,8 @@ s390_do_machine_check(struct pt_regs *regs) | |||
369 | 370 | ||
370 | lockdep_off(); | 371 | lockdep_off(); |
371 | 372 | ||
373 | s390_idle_check(); | ||
374 | |||
372 | mci = (struct mci *) &S390_lowcore.mcck_interruption_code; | 375 | mci = (struct mci *) &S390_lowcore.mcck_interruption_code; |
373 | mcck = &__get_cpu_var(cpu_mcck); | 376 | mcck = &__get_cpu_var(cpu_mcck); |
374 | umode = user_mode(regs); | 377 | umode = user_mode(regs); |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 4fd3fa5546b1..ec68c741b564 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -55,6 +55,13 @@ config SOFT_WATCHDOG | |||
55 | To compile this driver as a module, choose M here: the | 55 | To compile this driver as a module, choose M here: the |
56 | module will be called softdog. | 56 | module will be called softdog. |
57 | 57 | ||
58 | config WM8350_WATCHDOG | ||
59 | tristate "WM8350 watchdog" | ||
60 | depends on MFD_WM8350 | ||
61 | help | ||
62 | Support for the watchdog in the WM8350 AudioPlus PMIC. When | ||
63 | the watchdog triggers the system will be reset. | ||
64 | |||
58 | # ALPHA Architecture | 65 | # ALPHA Architecture |
59 | 66 | ||
60 | # ARM Architecture | 67 | # ARM Architecture |
@@ -551,6 +558,18 @@ config CPU5_WDT | |||
551 | To compile this driver as a module, choose M here: the | 558 | To compile this driver as a module, choose M here: the |
552 | module will be called cpu5wdt. | 559 | module will be called cpu5wdt. |
553 | 560 | ||
561 | config SMSC_SCH311X_WDT | ||
562 | tristate "SMSC SCH311X Watchdog Timer" | ||
563 | depends on X86 | ||
564 | ---help--- | ||
565 | This is the driver for the hardware watchdog timer on the | ||
566 | SMSC SCH3112, SCH3114 and SCH3116 Super IO chipset | ||
567 | (LPC IO with 8042 KBC, Reset Generation, HWM and multiple | ||
568 | serial ports). | ||
569 | |||
570 | To compile this driver as a module, choose M here: the | ||
571 | module will be called sch311x_wdt. | ||
572 | |||
554 | config SMSC37B787_WDT | 573 | config SMSC37B787_WDT |
555 | tristate "Winbond SMsC37B787 Watchdog Timer" | 574 | tristate "Winbond SMsC37B787 Watchdog Timer" |
556 | depends on X86 | 575 | depends on X86 |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index e352bbb7630b..c19b866f5ed1 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -83,6 +83,7 @@ obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | |||
83 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o | 83 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o |
84 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o | 84 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o |
85 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o | 85 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o |
86 | obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o | ||
86 | obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o | 87 | obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o |
87 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o | 88 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o |
88 | obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o | 89 | obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o |
@@ -133,4 +134,5 @@ obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o | |||
133 | # XTENSA Architecture | 134 | # XTENSA Architecture |
134 | 135 | ||
135 | # Architecture Independant | 136 | # Architecture Independant |
137 | obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o | ||
136 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o | 138 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o |
diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c index 317ef2b16cff..4bef3ddff4a5 100644 --- a/drivers/watchdog/ib700wdt.c +++ b/drivers/watchdog/ib700wdt.c | |||
@@ -91,32 +91,16 @@ static char expect_close; | |||
91 | * | 91 | * |
92 | */ | 92 | */ |
93 | 93 | ||
94 | static int wd_times[] = { | ||
95 | 30, /* 0x0 */ | ||
96 | 28, /* 0x1 */ | ||
97 | 26, /* 0x2 */ | ||
98 | 24, /* 0x3 */ | ||
99 | 22, /* 0x4 */ | ||
100 | 20, /* 0x5 */ | ||
101 | 18, /* 0x6 */ | ||
102 | 16, /* 0x7 */ | ||
103 | 14, /* 0x8 */ | ||
104 | 12, /* 0x9 */ | ||
105 | 10, /* 0xA */ | ||
106 | 8, /* 0xB */ | ||
107 | 6, /* 0xC */ | ||
108 | 4, /* 0xD */ | ||
109 | 2, /* 0xE */ | ||
110 | 0, /* 0xF */ | ||
111 | }; | ||
112 | |||
113 | #define WDT_STOP 0x441 | 94 | #define WDT_STOP 0x441 |
114 | #define WDT_START 0x443 | 95 | #define WDT_START 0x443 |
115 | 96 | ||
116 | /* Default timeout */ | 97 | /* Default timeout */ |
117 | #define WD_TIMO 0 /* 30 seconds +/- 20%, from table */ | 98 | #define WATCHDOG_TIMEOUT 30 /* 30 seconds +/- 20% */ |
118 | 99 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ | |
119 | static int wd_margin = WD_TIMO; | 100 | module_param(timeout, int, 0); |
101 | MODULE_PARM_DESC(timeout, | ||
102 | "Watchdog timeout in seconds. 0<= timeout <=30, default=" | ||
103 | __MODULE_STRING(WATCHDOG_TIMEOUT) "."); | ||
120 | 104 | ||
121 | static int nowayout = WATCHDOG_NOWAYOUT; | 105 | static int nowayout = WATCHDOG_NOWAYOUT; |
122 | module_param(nowayout, int, 0); | 106 | module_param(nowayout, int, 0); |
@@ -131,6 +115,8 @@ MODULE_PARM_DESC(nowayout, | |||
131 | 115 | ||
132 | static void ibwdt_ping(void) | 116 | static void ibwdt_ping(void) |
133 | { | 117 | { |
118 | int wd_margin = 15 - ((timeout + 1) / 2); | ||
119 | |||
134 | spin_lock(&ibwdt_lock); | 120 | spin_lock(&ibwdt_lock); |
135 | 121 | ||
136 | /* Write a watchdog value */ | 122 | /* Write a watchdog value */ |
@@ -148,15 +134,10 @@ static void ibwdt_disable(void) | |||
148 | 134 | ||
149 | static int ibwdt_set_heartbeat(int t) | 135 | static int ibwdt_set_heartbeat(int t) |
150 | { | 136 | { |
151 | int i; | 137 | if (t < 0 || t > 30) |
152 | |||
153 | if ((t < 0) || (t > 30)) | ||
154 | return -EINVAL; | 138 | return -EINVAL; |
155 | 139 | ||
156 | for (i = 0x0F; i > -1; i--) | 140 | timeout = t; |
157 | if (wd_times[i] >= t) | ||
158 | break; | ||
159 | wd_margin = i; | ||
160 | return 0; | 141 | return 0; |
161 | } | 142 | } |
162 | 143 | ||
@@ -240,7 +221,7 @@ static long ibwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
240 | /* Fall */ | 221 | /* Fall */ |
241 | 222 | ||
242 | case WDIOC_GETTIMEOUT: | 223 | case WDIOC_GETTIMEOUT: |
243 | return put_user(wd_times[wd_margin], p); | 224 | return put_user(timeout, p); |
244 | 225 | ||
245 | default: | 226 | default: |
246 | return -ENOTTY; | 227 | return -ENOTTY; |
@@ -317,6 +298,14 @@ static int __devinit ibwdt_probe(struct platform_device *dev) | |||
317 | goto out_nostartreg; | 298 | goto out_nostartreg; |
318 | } | 299 | } |
319 | 300 | ||
301 | /* Check that the heartbeat value is within it's range ; | ||
302 | * if not reset to the default */ | ||
303 | if (ibwdt_set_heartbeat(timeout)) { | ||
304 | ibwdt_set_heartbeat(WATCHDOG_TIMEOUT); | ||
305 | printk(KERN_INFO PFX | ||
306 | "timeout value must be 0<=x<=30, using %d\n", timeout); | ||
307 | } | ||
308 | |||
320 | res = misc_register(&ibwdt_miscdev); | 309 | res = misc_register(&ibwdt_miscdev); |
321 | if (res) { | 310 | if (res) { |
322 | printk(KERN_ERR PFX "failed to register misc device\n"); | 311 | printk(KERN_ERR PFX "failed to register misc device\n"); |
diff --git a/drivers/watchdog/sch311x_wdt.c b/drivers/watchdog/sch311x_wdt.c new file mode 100644 index 000000000000..569eb295a7a8 --- /dev/null +++ b/drivers/watchdog/sch311x_wdt.c | |||
@@ -0,0 +1,578 @@ | |||
1 | /* | ||
2 | * sch311x_wdt.c - Driver for the SCH311x Super-I/O chips | ||
3 | * integrated watchdog. | ||
4 | * | ||
5 | * (c) Copyright 2008 Wim Van Sebroeck <wim@iguana.be>. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor | ||
13 | * provide warranty for any of this software. This material is | ||
14 | * provided "AS-IS" and at no charge. | ||
15 | */ | ||
16 | |||
17 | /* | ||
18 | * Includes, defines, variables, module parameters, ... | ||
19 | */ | ||
20 | |||
21 | /* Includes */ | ||
22 | #include <linux/module.h> /* For module specific items */ | ||
23 | #include <linux/moduleparam.h> /* For new moduleparam's */ | ||
24 | #include <linux/types.h> /* For standard types (like size_t) */ | ||
25 | #include <linux/errno.h> /* For the -ENODEV/... values */ | ||
26 | #include <linux/kernel.h> /* For printk/... */ | ||
27 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV | ||
28 | (WATCHDOG_MINOR) */ | ||
29 | #include <linux/watchdog.h> /* For the watchdog specific items */ | ||
30 | #include <linux/init.h> /* For __init/__exit/... */ | ||
31 | #include <linux/fs.h> /* For file operations */ | ||
32 | #include <linux/platform_device.h> /* For platform_driver framework */ | ||
33 | #include <linux/ioport.h> /* For io-port access */ | ||
34 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ | ||
35 | #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ | ||
36 | #include <linux/io.h> /* For inb/outb/... */ | ||
37 | |||
38 | /* Module and version information */ | ||
39 | #define DRV_NAME "sch311x_wdt" | ||
40 | #define PFX DRV_NAME ": " | ||
41 | |||
42 | /* Runtime registers */ | ||
43 | #define RESGEN 0x1d | ||
44 | #define GP60 0x47 | ||
45 | #define WDT_TIME_OUT 0x65 | ||
46 | #define WDT_VAL 0x66 | ||
47 | #define WDT_CFG 0x67 | ||
48 | #define WDT_CTRL 0x68 | ||
49 | |||
50 | /* internal variables */ | ||
51 | static unsigned long sch311x_wdt_is_open; | ||
52 | static char sch311x_wdt_expect_close; | ||
53 | static struct platform_device *sch311x_wdt_pdev; | ||
54 | |||
55 | static int sch311x_ioports[] = { 0x2e, 0x4e, 0x162e, 0x164e, 0x00 }; | ||
56 | |||
57 | static struct { /* The devices private data */ | ||
58 | /* the Runtime Register base address */ | ||
59 | unsigned short runtime_reg; | ||
60 | /* The card's boot status */ | ||
61 | int boot_status; | ||
62 | /* the lock for io operations */ | ||
63 | spinlock_t io_lock; | ||
64 | } sch311x_wdt_data; | ||
65 | |||
66 | /* Module load parameters */ | ||
67 | static unsigned short force_id; | ||
68 | module_param(force_id, ushort, 0); | ||
69 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | ||
70 | |||
71 | static unsigned short therm_trip; | ||
72 | module_param(therm_trip, ushort, 0); | ||
73 | MODULE_PARM_DESC(therm_trip, "Should a ThermTrip trigger the reset generator"); | ||
74 | |||
75 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ | ||
76 | static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ | ||
77 | module_param(timeout, int, 0); | ||
78 | MODULE_PARM_DESC(timeout, | ||
79 | "Watchdog timeout in seconds. 1<= timeout <=15300, default=" | ||
80 | __MODULE_STRING(WATCHDOG_TIMEOUT) "."); | ||
81 | |||
82 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
83 | module_param(nowayout, int, 0); | ||
84 | MODULE_PARM_DESC(nowayout, | ||
85 | "Watchdog cannot be stopped once started (default=" | ||
86 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
87 | |||
88 | /* | ||
89 | * Super-IO functions | ||
90 | */ | ||
91 | |||
92 | static inline void sch311x_sio_enter(int sio_config_port) | ||
93 | { | ||
94 | outb(0x55, sio_config_port); | ||
95 | } | ||
96 | |||
97 | static inline void sch311x_sio_exit(int sio_config_port) | ||
98 | { | ||
99 | outb(0xaa, sio_config_port); | ||
100 | } | ||
101 | |||
102 | static inline int sch311x_sio_inb(int sio_config_port, int reg) | ||
103 | { | ||
104 | outb(reg, sio_config_port); | ||
105 | return inb(sio_config_port + 1); | ||
106 | } | ||
107 | |||
108 | static inline void sch311x_sio_outb(int sio_config_port, int reg, int val) | ||
109 | { | ||
110 | outb(reg, sio_config_port); | ||
111 | outb(val, sio_config_port + 1); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Watchdog Operations | ||
116 | */ | ||
117 | |||
118 | static void sch311x_wdt_set_timeout(int t) | ||
119 | { | ||
120 | unsigned char timeout_unit = 0x80; | ||
121 | |||
122 | /* When new timeout is bigger then 255 seconds, we will use minutes */ | ||
123 | if (t > 255) { | ||
124 | timeout_unit = 0; | ||
125 | t /= 60; | ||
126 | } | ||
127 | |||
128 | /* -- Watchdog Timeout -- | ||
129 | * Bit 0-6 (Reserved) | ||
130 | * Bit 7 WDT Time-out Value Units Select | ||
131 | * (0 = Minutes, 1 = Seconds) | ||
132 | */ | ||
133 | outb(timeout_unit, sch311x_wdt_data.runtime_reg + WDT_TIME_OUT); | ||
134 | |||
135 | /* -- Watchdog Timer Time-out Value -- | ||
136 | * Bit 0-7 Binary coded units (0=Disabled, 1..255) | ||
137 | */ | ||
138 | outb(t, sch311x_wdt_data.runtime_reg + WDT_VAL); | ||
139 | } | ||
140 | |||
141 | static void sch311x_wdt_start(void) | ||
142 | { | ||
143 | spin_lock(&sch311x_wdt_data.io_lock); | ||
144 | |||
145 | /* set watchdog's timeout */ | ||
146 | sch311x_wdt_set_timeout(timeout); | ||
147 | /* enable the watchdog */ | ||
148 | /* -- General Purpose I/O Bit 6.0 -- | ||
149 | * Bit 0, In/Out: 0 = Output, 1 = Input | ||
150 | * Bit 1, Polarity: 0 = No Invert, 1 = Invert | ||
151 | * Bit 2-3, Function select: 00 = GPI/O, 01 = LED1, 11 = WDT, | ||
152 | * 10 = Either Edge Triggered Intr.4 | ||
153 | * Bit 4-6 (Reserved) | ||
154 | * Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain | ||
155 | */ | ||
156 | outb(0x0e, sch311x_wdt_data.runtime_reg + GP60); | ||
157 | |||
158 | spin_unlock(&sch311x_wdt_data.io_lock); | ||
159 | |||
160 | } | ||
161 | |||
162 | static void sch311x_wdt_stop(void) | ||
163 | { | ||
164 | spin_lock(&sch311x_wdt_data.io_lock); | ||
165 | |||
166 | /* stop the watchdog */ | ||
167 | outb(0x01, sch311x_wdt_data.runtime_reg + GP60); | ||
168 | /* disable timeout by setting it to 0 */ | ||
169 | sch311x_wdt_set_timeout(0); | ||
170 | |||
171 | spin_unlock(&sch311x_wdt_data.io_lock); | ||
172 | } | ||
173 | |||
174 | static void sch311x_wdt_keepalive(void) | ||
175 | { | ||
176 | spin_lock(&sch311x_wdt_data.io_lock); | ||
177 | sch311x_wdt_set_timeout(timeout); | ||
178 | spin_unlock(&sch311x_wdt_data.io_lock); | ||
179 | } | ||
180 | |||
181 | static int sch311x_wdt_set_heartbeat(int t) | ||
182 | { | ||
183 | if (t < 1 || t > (255*60)) | ||
184 | return -EINVAL; | ||
185 | |||
186 | /* When new timeout is bigger then 255 seconds, | ||
187 | * we will round up to minutes (with a max of 255) */ | ||
188 | if (t > 255) | ||
189 | t = (((t - 1) / 60) + 1) * 60; | ||
190 | |||
191 | timeout = t; | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static void sch311x_wdt_get_status(int *status) | ||
196 | { | ||
197 | unsigned char new_status; | ||
198 | |||
199 | *status = 0; | ||
200 | |||
201 | spin_lock(&sch311x_wdt_data.io_lock); | ||
202 | |||
203 | /* -- Watchdog timer control -- | ||
204 | * Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occured | ||
205 | * Bit 1 Reserved | ||
206 | * Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning) | ||
207 | * Bit 3 P20 Force Timeout enabled: | ||
208 | * 0 = P20 activity does not generate the WD timeout event | ||
209 | * 1 = P20 Allows rising edge of P20, from the keyboard | ||
210 | * controller, to force the WD timeout event. | ||
211 | * Bit 4-7 Reserved | ||
212 | */ | ||
213 | new_status = inb(sch311x_wdt_data.runtime_reg + WDT_CTRL); | ||
214 | if (new_status & 0x01) | ||
215 | *status |= WDIOF_CARDRESET; | ||
216 | |||
217 | spin_unlock(&sch311x_wdt_data.io_lock); | ||
218 | } | ||
219 | |||
220 | /* | ||
221 | * /dev/watchdog handling | ||
222 | */ | ||
223 | |||
224 | static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf, | ||
225 | size_t count, loff_t *ppos) | ||
226 | { | ||
227 | if (count) { | ||
228 | if (!nowayout) { | ||
229 | size_t i; | ||
230 | |||
231 | sch311x_wdt_expect_close = 0; | ||
232 | |||
233 | for (i = 0; i != count; i++) { | ||
234 | char c; | ||
235 | if (get_user(c, buf + i)) | ||
236 | return -EFAULT; | ||
237 | if (c == 'V') | ||
238 | sch311x_wdt_expect_close = 42; | ||
239 | } | ||
240 | } | ||
241 | sch311x_wdt_keepalive(); | ||
242 | } | ||
243 | return count; | ||
244 | } | ||
245 | |||
246 | static long sch311x_wdt_ioctl(struct file *file, unsigned int cmd, | ||
247 | unsigned long arg) | ||
248 | { | ||
249 | int status; | ||
250 | int new_timeout; | ||
251 | void __user *argp = (void __user *)arg; | ||
252 | int __user *p = argp; | ||
253 | static struct watchdog_info ident = { | ||
254 | .options = WDIOF_KEEPALIVEPING | | ||
255 | WDIOF_SETTIMEOUT | | ||
256 | WDIOF_MAGICCLOSE, | ||
257 | .firmware_version = 1, | ||
258 | .identity = DRV_NAME, | ||
259 | }; | ||
260 | |||
261 | switch (cmd) { | ||
262 | case WDIOC_GETSUPPORT: | ||
263 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
264 | return -EFAULT; | ||
265 | break; | ||
266 | |||
267 | case WDIOC_GETSTATUS: | ||
268 | { | ||
269 | sch311x_wdt_get_status(&status); | ||
270 | return put_user(status, p); | ||
271 | } | ||
272 | case WDIOC_GETBOOTSTATUS: | ||
273 | return put_user(sch311x_wdt_data.boot_status, p); | ||
274 | |||
275 | case WDIOC_SETOPTIONS: | ||
276 | { | ||
277 | int options, retval = -EINVAL; | ||
278 | |||
279 | if (get_user(options, p)) | ||
280 | return -EFAULT; | ||
281 | if (options & WDIOS_DISABLECARD) { | ||
282 | sch311x_wdt_stop(); | ||
283 | retval = 0; | ||
284 | } | ||
285 | if (options & WDIOS_ENABLECARD) { | ||
286 | sch311x_wdt_start(); | ||
287 | retval = 0; | ||
288 | } | ||
289 | return retval; | ||
290 | } | ||
291 | case WDIOC_KEEPALIVE: | ||
292 | sch311x_wdt_keepalive(); | ||
293 | break; | ||
294 | |||
295 | case WDIOC_SETTIMEOUT: | ||
296 | if (get_user(new_timeout, p)) | ||
297 | return -EFAULT; | ||
298 | if (sch311x_wdt_set_heartbeat(new_timeout)) | ||
299 | return -EINVAL; | ||
300 | sch311x_wdt_keepalive(); | ||
301 | /* Fall */ | ||
302 | case WDIOC_GETTIMEOUT: | ||
303 | return put_user(timeout, p); | ||
304 | default: | ||
305 | return -ENOTTY; | ||
306 | } | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | static int sch311x_wdt_open(struct inode *inode, struct file *file) | ||
311 | { | ||
312 | if (test_and_set_bit(0, &sch311x_wdt_is_open)) | ||
313 | return -EBUSY; | ||
314 | /* | ||
315 | * Activate | ||
316 | */ | ||
317 | sch311x_wdt_start(); | ||
318 | return nonseekable_open(inode, file); | ||
319 | } | ||
320 | |||
321 | static int sch311x_wdt_close(struct inode *inode, struct file *file) | ||
322 | { | ||
323 | if (sch311x_wdt_expect_close == 42) { | ||
324 | sch311x_wdt_stop(); | ||
325 | } else { | ||
326 | printk(KERN_CRIT PFX | ||
327 | "Unexpected close, not stopping watchdog!\n"); | ||
328 | sch311x_wdt_keepalive(); | ||
329 | } | ||
330 | clear_bit(0, &sch311x_wdt_is_open); | ||
331 | sch311x_wdt_expect_close = 0; | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | * Kernel Interfaces | ||
337 | */ | ||
338 | |||
339 | static const struct file_operations sch311x_wdt_fops = { | ||
340 | .owner = THIS_MODULE, | ||
341 | .llseek = no_llseek, | ||
342 | .write = sch311x_wdt_write, | ||
343 | .unlocked_ioctl = sch311x_wdt_ioctl, | ||
344 | .open = sch311x_wdt_open, | ||
345 | .release = sch311x_wdt_close, | ||
346 | }; | ||
347 | |||
348 | static struct miscdevice sch311x_wdt_miscdev = { | ||
349 | .minor = WATCHDOG_MINOR, | ||
350 | .name = "watchdog", | ||
351 | .fops = &sch311x_wdt_fops, | ||
352 | }; | ||
353 | |||
354 | /* | ||
355 | * Init & exit routines | ||
356 | */ | ||
357 | |||
358 | static int __devinit sch311x_wdt_probe(struct platform_device *pdev) | ||
359 | { | ||
360 | struct device *dev = &pdev->dev; | ||
361 | unsigned char val; | ||
362 | int err; | ||
363 | |||
364 | spin_lock_init(&sch311x_wdt_data.io_lock); | ||
365 | |||
366 | if (!request_region(sch311x_wdt_data.runtime_reg + RESGEN, 1, | ||
367 | DRV_NAME)) { | ||
368 | dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", | ||
369 | sch311x_wdt_data.runtime_reg + RESGEN, | ||
370 | sch311x_wdt_data.runtime_reg + RESGEN); | ||
371 | err = -EBUSY; | ||
372 | goto exit; | ||
373 | } | ||
374 | |||
375 | if (!request_region(sch311x_wdt_data.runtime_reg + GP60, 1, DRV_NAME)) { | ||
376 | dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", | ||
377 | sch311x_wdt_data.runtime_reg + GP60, | ||
378 | sch311x_wdt_data.runtime_reg + GP60); | ||
379 | err = -EBUSY; | ||
380 | goto exit_release_region; | ||
381 | } | ||
382 | |||
383 | if (!request_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4, | ||
384 | DRV_NAME)) { | ||
385 | dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", | ||
386 | sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, | ||
387 | sch311x_wdt_data.runtime_reg + WDT_CTRL); | ||
388 | err = -EBUSY; | ||
389 | goto exit_release_region2; | ||
390 | } | ||
391 | |||
392 | /* Make sure that the watchdog is not running */ | ||
393 | sch311x_wdt_stop(); | ||
394 | |||
395 | /* Disable keyboard and mouse interaction and interrupt */ | ||
396 | /* -- Watchdog timer configuration -- | ||
397 | * Bit 0 Reserved | ||
398 | * Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr. | ||
399 | * Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr | ||
400 | * Bit 3 Reserved | ||
401 | * Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled, | ||
402 | * 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15) | ||
403 | */ | ||
404 | outb(0, sch311x_wdt_data.runtime_reg + WDT_CFG); | ||
405 | |||
406 | /* Check that the heartbeat value is within it's range ; | ||
407 | * if not reset to the default */ | ||
408 | if (sch311x_wdt_set_heartbeat(timeout)) { | ||
409 | sch311x_wdt_set_heartbeat(WATCHDOG_TIMEOUT); | ||
410 | dev_info(dev, "timeout value must be 1<=x<=15300, using %d\n", | ||
411 | timeout); | ||
412 | } | ||
413 | |||
414 | /* Get status at boot */ | ||
415 | sch311x_wdt_get_status(&sch311x_wdt_data.boot_status); | ||
416 | |||
417 | /* enable watchdog */ | ||
418 | /* -- Reset Generator -- | ||
419 | * Bit 0 Enable Watchdog Timer Generation: 0* = Enabled, 1 = Disabled | ||
420 | * Bit 1 Thermtrip Source Select: O* = No Source, 1 = Source | ||
421 | * Bit 2 WDT2_CTL: WDT input bit | ||
422 | * Bit 3-7 Reserved | ||
423 | */ | ||
424 | outb(0, sch311x_wdt_data.runtime_reg + RESGEN); | ||
425 | val = therm_trip ? 0x06 : 0x04; | ||
426 | outb(val, sch311x_wdt_data.runtime_reg + RESGEN); | ||
427 | |||
428 | err = misc_register(&sch311x_wdt_miscdev); | ||
429 | if (err != 0) { | ||
430 | dev_err(dev, "cannot register miscdev on minor=%d (err=%d)\n", | ||
431 | WATCHDOG_MINOR, err); | ||
432 | goto exit_release_region3; | ||
433 | } | ||
434 | |||
435 | sch311x_wdt_miscdev.parent = dev; | ||
436 | |||
437 | dev_info(dev, | ||
438 | "SMSC SCH311x WDT initialized. timeout=%d sec (nowayout=%d)\n", | ||
439 | timeout, nowayout); | ||
440 | |||
441 | return 0; | ||
442 | |||
443 | exit_release_region3: | ||
444 | release_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4); | ||
445 | exit_release_region2: | ||
446 | release_region(sch311x_wdt_data.runtime_reg + GP60, 1); | ||
447 | exit_release_region: | ||
448 | release_region(sch311x_wdt_data.runtime_reg + RESGEN, 1); | ||
449 | sch311x_wdt_data.runtime_reg = 0; | ||
450 | exit: | ||
451 | return err; | ||
452 | } | ||
453 | |||
454 | static int __devexit sch311x_wdt_remove(struct platform_device *pdev) | ||
455 | { | ||
456 | /* Stop the timer before we leave */ | ||
457 | if (!nowayout) | ||
458 | sch311x_wdt_stop(); | ||
459 | |||
460 | /* Deregister */ | ||
461 | misc_deregister(&sch311x_wdt_miscdev); | ||
462 | release_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4); | ||
463 | release_region(sch311x_wdt_data.runtime_reg + GP60, 1); | ||
464 | release_region(sch311x_wdt_data.runtime_reg + RESGEN, 1); | ||
465 | sch311x_wdt_data.runtime_reg = 0; | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static void sch311x_wdt_shutdown(struct platform_device *dev) | ||
470 | { | ||
471 | /* Turn the WDT off if we have a soft shutdown */ | ||
472 | sch311x_wdt_stop(); | ||
473 | } | ||
474 | |||
475 | #define sch311x_wdt_suspend NULL | ||
476 | #define sch311x_wdt_resume NULL | ||
477 | |||
478 | static struct platform_driver sch311x_wdt_driver = { | ||
479 | .probe = sch311x_wdt_probe, | ||
480 | .remove = __devexit_p(sch311x_wdt_remove), | ||
481 | .shutdown = sch311x_wdt_shutdown, | ||
482 | .suspend = sch311x_wdt_suspend, | ||
483 | .resume = sch311x_wdt_resume, | ||
484 | .driver = { | ||
485 | .owner = THIS_MODULE, | ||
486 | .name = DRV_NAME, | ||
487 | }, | ||
488 | }; | ||
489 | |||
490 | static int __init sch311x_detect(int sio_config_port, unsigned short *addr) | ||
491 | { | ||
492 | int err = 0, reg; | ||
493 | unsigned short base_addr; | ||
494 | unsigned char dev_id; | ||
495 | |||
496 | sch311x_sio_enter(sio_config_port); | ||
497 | |||
498 | /* Check device ID. We currently know about: | ||
499 | * SCH3112 (0x7c), SCH3114 (0x7d), and SCH3116 (0x7f). */ | ||
500 | reg = force_id ? force_id : sch311x_sio_inb(sio_config_port, 0x20); | ||
501 | if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) { | ||
502 | err = -ENODEV; | ||
503 | goto exit; | ||
504 | } | ||
505 | dev_id = reg == 0x7c ? 2 : reg == 0x7d ? 4 : 6; | ||
506 | |||
507 | /* Select logical device A (runtime registers) */ | ||
508 | sch311x_sio_outb(sio_config_port, 0x07, 0x0a); | ||
509 | |||
510 | /* Check if Logical Device Register is currently active */ | ||
511 | if (sch311x_sio_inb(sio_config_port, 0x30) && 0x01 == 0) | ||
512 | printk(KERN_INFO PFX "Seems that LDN 0x0a is not active...\n"); | ||
513 | |||
514 | /* Get the base address of the runtime registers */ | ||
515 | base_addr = (sch311x_sio_inb(sio_config_port, 0x60) << 8) | | ||
516 | sch311x_sio_inb(sio_config_port, 0x61); | ||
517 | if (!base_addr) { | ||
518 | printk(KERN_ERR PFX "Base address not set.\n"); | ||
519 | err = -ENODEV; | ||
520 | goto exit; | ||
521 | } | ||
522 | *addr = base_addr; | ||
523 | |||
524 | printk(KERN_INFO PFX "Found an SMSC SCH311%d chip at 0x%04x\n", | ||
525 | dev_id, base_addr); | ||
526 | |||
527 | exit: | ||
528 | sch311x_sio_exit(sio_config_port); | ||
529 | return err; | ||
530 | } | ||
531 | |||
532 | static int __init sch311x_wdt_init(void) | ||
533 | { | ||
534 | int err, i, found = 0; | ||
535 | unsigned short addr = 0; | ||
536 | |||
537 | for (i = 0; !found && sch311x_ioports[i]; i++) | ||
538 | if (sch311x_detect(sch311x_ioports[i], &addr) == 0) | ||
539 | found++; | ||
540 | |||
541 | if (!found) | ||
542 | return -ENODEV; | ||
543 | |||
544 | sch311x_wdt_data.runtime_reg = addr; | ||
545 | |||
546 | err = platform_driver_register(&sch311x_wdt_driver); | ||
547 | if (err) | ||
548 | return err; | ||
549 | |||
550 | sch311x_wdt_pdev = platform_device_register_simple(DRV_NAME, addr, | ||
551 | NULL, 0); | ||
552 | |||
553 | if (IS_ERR(sch311x_wdt_pdev)) { | ||
554 | err = PTR_ERR(sch311x_wdt_pdev); | ||
555 | goto unreg_platform_driver; | ||
556 | } | ||
557 | |||
558 | return 0; | ||
559 | |||
560 | unreg_platform_driver: | ||
561 | platform_driver_unregister(&sch311x_wdt_driver); | ||
562 | return err; | ||
563 | } | ||
564 | |||
565 | static void __exit sch311x_wdt_exit(void) | ||
566 | { | ||
567 | platform_device_unregister(sch311x_wdt_pdev); | ||
568 | platform_driver_unregister(&sch311x_wdt_driver); | ||
569 | } | ||
570 | |||
571 | module_init(sch311x_wdt_init); | ||
572 | module_exit(sch311x_wdt_exit); | ||
573 | |||
574 | MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); | ||
575 | MODULE_DESCRIPTION("SMSC SCH311x WatchDog Timer Driver"); | ||
576 | MODULE_LICENSE("GPL"); | ||
577 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
578 | |||
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c new file mode 100644 index 000000000000..2bc0d4d4b415 --- /dev/null +++ b/drivers/watchdog/wm8350_wdt.c | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | * Watchdog driver for the wm8350 | ||
3 | * | ||
4 | * Copyright (C) 2007, 2008 Wolfson Microelectronics <linux@wolfsonmicro.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/moduleparam.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <linux/miscdevice.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/watchdog.h> | ||
19 | #include <linux/uaccess.h> | ||
20 | #include <linux/mfd/wm8350/core.h> | ||
21 | |||
22 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
23 | module_param(nowayout, int, 0); | ||
24 | MODULE_PARM_DESC(nowayout, | ||
25 | "Watchdog cannot be stopped once started (default=" | ||
26 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
27 | |||
28 | static unsigned long wm8350_wdt_users; | ||
29 | static struct miscdevice wm8350_wdt_miscdev; | ||
30 | static int wm8350_wdt_expect_close; | ||
31 | static DEFINE_MUTEX(wdt_mutex); | ||
32 | |||
33 | static struct { | ||
34 | int time; /* Seconds */ | ||
35 | u16 val; /* To be set in WM8350_SYSTEM_CONTROL_2 */ | ||
36 | } wm8350_wdt_cfgs[] = { | ||
37 | { 1, 0x02 }, | ||
38 | { 2, 0x04 }, | ||
39 | { 4, 0x05 }, | ||
40 | }; | ||
41 | |||
42 | static struct wm8350 *get_wm8350(void) | ||
43 | { | ||
44 | return dev_get_drvdata(wm8350_wdt_miscdev.parent); | ||
45 | } | ||
46 | |||
47 | static int wm8350_wdt_set_timeout(struct wm8350 *wm8350, u16 value) | ||
48 | { | ||
49 | int ret; | ||
50 | u16 reg; | ||
51 | |||
52 | mutex_lock(&wdt_mutex); | ||
53 | wm8350_reg_unlock(wm8350); | ||
54 | |||
55 | reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2); | ||
56 | reg &= ~WM8350_WDOG_TO_MASK; | ||
57 | reg |= value; | ||
58 | ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg); | ||
59 | |||
60 | wm8350_reg_lock(wm8350); | ||
61 | mutex_unlock(&wdt_mutex); | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int wm8350_wdt_start(struct wm8350 *wm8350) | ||
67 | { | ||
68 | int ret; | ||
69 | u16 reg; | ||
70 | |||
71 | mutex_lock(&wdt_mutex); | ||
72 | wm8350_reg_unlock(wm8350); | ||
73 | |||
74 | reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2); | ||
75 | reg &= ~WM8350_WDOG_MODE_MASK; | ||
76 | reg |= 0x20; | ||
77 | ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg); | ||
78 | |||
79 | wm8350_reg_lock(wm8350); | ||
80 | mutex_unlock(&wdt_mutex); | ||
81 | |||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static int wm8350_wdt_stop(struct wm8350 *wm8350) | ||
86 | { | ||
87 | int ret; | ||
88 | u16 reg; | ||
89 | |||
90 | mutex_lock(&wdt_mutex); | ||
91 | wm8350_reg_unlock(wm8350); | ||
92 | |||
93 | reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2); | ||
94 | reg &= ~WM8350_WDOG_MODE_MASK; | ||
95 | ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg); | ||
96 | |||
97 | wm8350_reg_lock(wm8350); | ||
98 | mutex_unlock(&wdt_mutex); | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | static int wm8350_wdt_kick(struct wm8350 *wm8350) | ||
104 | { | ||
105 | int ret; | ||
106 | u16 reg; | ||
107 | |||
108 | mutex_lock(&wdt_mutex); | ||
109 | |||
110 | reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2); | ||
111 | ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg); | ||
112 | |||
113 | mutex_unlock(&wdt_mutex); | ||
114 | |||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | static int wm8350_wdt_open(struct inode *inode, struct file *file) | ||
119 | { | ||
120 | struct wm8350 *wm8350 = get_wm8350(); | ||
121 | int ret; | ||
122 | |||
123 | if (!wm8350) | ||
124 | return -ENODEV; | ||
125 | |||
126 | if (test_and_set_bit(0, &wm8350_wdt_users)) | ||
127 | return -EBUSY; | ||
128 | |||
129 | ret = wm8350_wdt_start(wm8350); | ||
130 | if (ret != 0) | ||
131 | return ret; | ||
132 | |||
133 | return nonseekable_open(inode, file); | ||
134 | } | ||
135 | |||
136 | static int wm8350_wdt_release(struct inode *inode, struct file *file) | ||
137 | { | ||
138 | struct wm8350 *wm8350 = get_wm8350(); | ||
139 | |||
140 | if (wm8350_wdt_expect_close) | ||
141 | wm8350_wdt_stop(wm8350); | ||
142 | else { | ||
143 | dev_warn(wm8350->dev, "Watchdog device closed uncleanly\n"); | ||
144 | wm8350_wdt_kick(wm8350); | ||
145 | } | ||
146 | |||
147 | clear_bit(0, &wm8350_wdt_users); | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static ssize_t wm8350_wdt_write(struct file *file, | ||
153 | const char __user *data, size_t count, | ||
154 | loff_t *ppos) | ||
155 | { | ||
156 | struct wm8350 *wm8350 = get_wm8350(); | ||
157 | size_t i; | ||
158 | |||
159 | if (count) { | ||
160 | wm8350_wdt_kick(wm8350); | ||
161 | |||
162 | if (!nowayout) { | ||
163 | /* In case it was set long ago */ | ||
164 | wm8350_wdt_expect_close = 0; | ||
165 | |||
166 | /* scan to see whether or not we got the magic | ||
167 | character */ | ||
168 | for (i = 0; i != count; i++) { | ||
169 | char c; | ||
170 | if (get_user(c, data + i)) | ||
171 | return -EFAULT; | ||
172 | if (c == 'V') | ||
173 | wm8350_wdt_expect_close = 42; | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | return count; | ||
178 | } | ||
179 | |||
180 | static struct watchdog_info ident = { | ||
181 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, | ||
182 | .identity = "WM8350 Watchdog", | ||
183 | }; | ||
184 | |||
185 | static long wm8350_wdt_ioctl(struct file *file, unsigned int cmd, | ||
186 | unsigned long arg) | ||
187 | { | ||
188 | struct wm8350 *wm8350 = get_wm8350(); | ||
189 | int ret = -ENOTTY, time, i; | ||
190 | void __user *argp = (void __user *)arg; | ||
191 | int __user *p = argp; | ||
192 | u16 reg; | ||
193 | |||
194 | switch (cmd) { | ||
195 | case WDIOC_GETSUPPORT: | ||
196 | ret = copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; | ||
197 | break; | ||
198 | |||
199 | case WDIOC_GETSTATUS: | ||
200 | case WDIOC_GETBOOTSTATUS: | ||
201 | ret = put_user(0, p); | ||
202 | break; | ||
203 | |||
204 | case WDIOC_SETOPTIONS: | ||
205 | { | ||
206 | int options; | ||
207 | |||
208 | if (get_user(options, p)) | ||
209 | return -EFAULT; | ||
210 | |||
211 | ret = -EINVAL; | ||
212 | |||
213 | /* Setting both simultaneously means at least one must fail */ | ||
214 | if (options == WDIOS_DISABLECARD) | ||
215 | ret = wm8350_wdt_start(wm8350); | ||
216 | |||
217 | if (options == WDIOS_ENABLECARD) | ||
218 | ret = wm8350_wdt_stop(wm8350); | ||
219 | break; | ||
220 | } | ||
221 | |||
222 | case WDIOC_KEEPALIVE: | ||
223 | ret = wm8350_wdt_kick(wm8350); | ||
224 | break; | ||
225 | |||
226 | case WDIOC_SETTIMEOUT: | ||
227 | ret = get_user(time, p); | ||
228 | if (ret) | ||
229 | break; | ||
230 | |||
231 | if (time == 0) { | ||
232 | if (nowayout) | ||
233 | ret = -EINVAL; | ||
234 | else | ||
235 | wm8350_wdt_stop(wm8350); | ||
236 | break; | ||
237 | } | ||
238 | |||
239 | for (i = 0; i < ARRAY_SIZE(wm8350_wdt_cfgs); i++) | ||
240 | if (wm8350_wdt_cfgs[i].time == time) | ||
241 | break; | ||
242 | if (i == ARRAY_SIZE(wm8350_wdt_cfgs)) | ||
243 | ret = -EINVAL; | ||
244 | else | ||
245 | ret = wm8350_wdt_set_timeout(wm8350, | ||
246 | wm8350_wdt_cfgs[i].val); | ||
247 | break; | ||
248 | |||
249 | case WDIOC_GETTIMEOUT: | ||
250 | reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2); | ||
251 | reg &= WM8350_WDOG_TO_MASK; | ||
252 | for (i = 0; i < ARRAY_SIZE(wm8350_wdt_cfgs); i++) | ||
253 | if (wm8350_wdt_cfgs[i].val == reg) | ||
254 | break; | ||
255 | if (i == ARRAY_SIZE(wm8350_wdt_cfgs)) { | ||
256 | dev_warn(wm8350->dev, | ||
257 | "Unknown watchdog configuration: %x\n", reg); | ||
258 | ret = -EINVAL; | ||
259 | } else | ||
260 | ret = put_user(wm8350_wdt_cfgs[i].time, p); | ||
261 | |||
262 | } | ||
263 | |||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | static const struct file_operations wm8350_wdt_fops = { | ||
268 | .owner = THIS_MODULE, | ||
269 | .llseek = no_llseek, | ||
270 | .write = wm8350_wdt_write, | ||
271 | .unlocked_ioctl = wm8350_wdt_ioctl, | ||
272 | .open = wm8350_wdt_open, | ||
273 | .release = wm8350_wdt_release, | ||
274 | }; | ||
275 | |||
276 | static struct miscdevice wm8350_wdt_miscdev = { | ||
277 | .minor = WATCHDOG_MINOR, | ||
278 | .name = "watchdog", | ||
279 | .fops = &wm8350_wdt_fops, | ||
280 | }; | ||
281 | |||
282 | static int wm8350_wdt_probe(struct platform_device *pdev) | ||
283 | { | ||
284 | struct wm8350 *wm8350 = platform_get_drvdata(pdev); | ||
285 | |||
286 | if (!wm8350) { | ||
287 | dev_err(wm8350->dev, "No driver data supplied\n"); | ||
288 | return -ENODEV; | ||
289 | } | ||
290 | |||
291 | /* Default to 4s timeout */ | ||
292 | wm8350_wdt_set_timeout(wm8350, 0x05); | ||
293 | |||
294 | wm8350_wdt_miscdev.parent = &pdev->dev; | ||
295 | |||
296 | return misc_register(&wm8350_wdt_miscdev); | ||
297 | } | ||
298 | |||
299 | static int __exit wm8350_wdt_remove(struct platform_device *pdev) | ||
300 | { | ||
301 | misc_deregister(&wm8350_wdt_miscdev); | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | static struct platform_driver wm8350_wdt_driver = { | ||
307 | .probe = wm8350_wdt_probe, | ||
308 | .remove = wm8350_wdt_remove, | ||
309 | .driver = { | ||
310 | .name = "wm8350-wdt", | ||
311 | }, | ||
312 | }; | ||
313 | |||
314 | static int __init wm8350_wdt_init(void) | ||
315 | { | ||
316 | return platform_driver_register(&wm8350_wdt_driver); | ||
317 | } | ||
318 | module_init(wm8350_wdt_init); | ||
319 | |||
320 | static void __exit wm8350_wdt_exit(void) | ||
321 | { | ||
322 | platform_driver_unregister(&wm8350_wdt_driver); | ||
323 | } | ||
324 | module_exit(wm8350_wdt_exit); | ||
325 | |||
326 | MODULE_AUTHOR("Mark Brown"); | ||
327 | MODULE_DESCRIPTION("WM8350 Watchdog"); | ||
328 | MODULE_LICENSE("GPL"); | ||
329 | MODULE_ALIAS("platform:wm8350-wdt"); | ||