@@ -1055,8 +1055,11 @@ impl<T: Driver> Registration<T> {
1055
1055
impl < T : Driver > Registration < T > {
1056
1056
/// Driver's `init` callback.
1057
1057
///
1058
- /// SAFETY: Called from C. Inputs must be valid pointers.
1059
- extern "C" fn init_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1058
+ /// # Safety
1059
+ ///
1060
+ /// - This function may only be called from the cpufreq C infrastructure.
1061
+ /// - The pointer arguments must be valid pointers.
1062
+ unsafe extern "C" fn init_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1060
1063
from_result ( || {
1061
1064
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1062
1065
// lifetime of `policy`.
@@ -1070,8 +1073,11 @@ impl<T: Driver> Registration<T> {
1070
1073
1071
1074
/// Driver's `exit` callback.
1072
1075
///
1073
- /// SAFETY: Called from C. Inputs must be valid pointers.
1074
- extern "C" fn exit_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1076
+ /// # Safety
1077
+ ///
1078
+ /// - This function may only be called from the cpufreq C infrastructure.
1079
+ /// - The pointer arguments must be valid pointers.
1080
+ unsafe extern "C" fn exit_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1075
1081
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1076
1082
// lifetime of `policy`.
1077
1083
let policy = unsafe { Policy :: from_raw_mut ( ptr) } ;
@@ -1082,8 +1088,11 @@ impl<T: Driver> Registration<T> {
1082
1088
1083
1089
/// Driver's `online` callback.
1084
1090
///
1085
- /// SAFETY: Called from C. Inputs must be valid pointers.
1086
- extern "C" fn online_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1091
+ /// # Safety
1092
+ ///
1093
+ /// - This function may only be called from the cpufreq C infrastructure.
1094
+ /// - The pointer arguments must be valid pointers.
1095
+ unsafe extern "C" fn online_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1087
1096
from_result ( || {
1088
1097
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1089
1098
// lifetime of `policy`.
@@ -1094,8 +1103,13 @@ impl<T: Driver> Registration<T> {
1094
1103
1095
1104
/// Driver's `offline` callback.
1096
1105
///
1097
- /// SAFETY: Called from C. Inputs must be valid pointers.
1098
- extern "C" fn offline_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1106
+ /// # Safety
1107
+ ///
1108
+ /// - This function may only be called from the cpufreq C infrastructure.
1109
+ /// - The pointer arguments must be valid pointers.
1110
+ unsafe extern "C" fn offline_callback (
1111
+ ptr : * mut bindings:: cpufreq_policy ,
1112
+ ) -> kernel:: ffi:: c_int {
1099
1113
from_result ( || {
1100
1114
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1101
1115
// lifetime of `policy`.
@@ -1106,8 +1120,13 @@ impl<T: Driver> Registration<T> {
1106
1120
1107
1121
/// Driver's `suspend` callback.
1108
1122
///
1109
- /// SAFETY: Called from C. Inputs must be valid pointers.
1110
- extern "C" fn suspend_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1123
+ /// # Safety
1124
+ ///
1125
+ /// - This function may only be called from the cpufreq C infrastructure.
1126
+ /// - The pointer arguments must be valid pointers.
1127
+ unsafe extern "C" fn suspend_callback (
1128
+ ptr : * mut bindings:: cpufreq_policy ,
1129
+ ) -> kernel:: ffi:: c_int {
1111
1130
from_result ( || {
1112
1131
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1113
1132
// lifetime of `policy`.
@@ -1118,8 +1137,11 @@ impl<T: Driver> Registration<T> {
1118
1137
1119
1138
/// Driver's `resume` callback.
1120
1139
///
1121
- /// SAFETY: Called from C. Inputs must be valid pointers.
1122
- extern "C" fn resume_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1140
+ /// # Safety
1141
+ ///
1142
+ /// - This function may only be called from the cpufreq C infrastructure.
1143
+ /// - The pointer arguments must be valid pointers.
1144
+ unsafe extern "C" fn resume_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1123
1145
from_result ( || {
1124
1146
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1125
1147
// lifetime of `policy`.
@@ -1130,8 +1152,11 @@ impl<T: Driver> Registration<T> {
1130
1152
1131
1153
/// Driver's `ready` callback.
1132
1154
///
1133
- /// SAFETY: Called from C. Inputs must be valid pointers.
1134
- extern "C" fn ready_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1155
+ /// # Safety
1156
+ ///
1157
+ /// - This function may only be called from the cpufreq C infrastructure.
1158
+ /// - The pointer arguments must be valid pointers.
1159
+ unsafe extern "C" fn ready_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1135
1160
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1136
1161
// lifetime of `policy`.
1137
1162
let policy = unsafe { Policy :: from_raw_mut ( ptr) } ;
@@ -1140,8 +1165,13 @@ impl<T: Driver> Registration<T> {
1140
1165
1141
1166
/// Driver's `verify` callback.
1142
1167
///
1143
- /// SAFETY: Called from C. Inputs must be valid pointers.
1144
- extern "C" fn verify_callback ( ptr : * mut bindings:: cpufreq_policy_data ) -> kernel:: ffi:: c_int {
1168
+ /// # Safety
1169
+ ///
1170
+ /// - This function may only be called from the cpufreq C infrastructure.
1171
+ /// - The pointer arguments must be valid pointers.
1172
+ unsafe extern "C" fn verify_callback (
1173
+ ptr : * mut bindings:: cpufreq_policy_data ,
1174
+ ) -> kernel:: ffi:: c_int {
1145
1175
from_result ( || {
1146
1176
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1147
1177
// lifetime of `policy`.
@@ -1152,8 +1182,13 @@ impl<T: Driver> Registration<T> {
1152
1182
1153
1183
/// Driver's `setpolicy` callback.
1154
1184
///
1155
- /// SAFETY: Called from C. Inputs must be valid pointers.
1156
- extern "C" fn setpolicy_callback ( ptr : * mut bindings:: cpufreq_policy ) -> kernel:: ffi:: c_int {
1185
+ /// # Safety
1186
+ ///
1187
+ /// - This function may only be called from the cpufreq C infrastructure.
1188
+ /// - The pointer arguments must be valid pointers.
1189
+ unsafe extern "C" fn setpolicy_callback (
1190
+ ptr : * mut bindings:: cpufreq_policy ,
1191
+ ) -> kernel:: ffi:: c_int {
1157
1192
from_result ( || {
1158
1193
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1159
1194
// lifetime of `policy`.
@@ -1164,8 +1199,11 @@ impl<T: Driver> Registration<T> {
1164
1199
1165
1200
/// Driver's `target` callback.
1166
1201
///
1167
- /// SAFETY: Called from C. Inputs must be valid pointers.
1168
- extern "C" fn target_callback (
1202
+ /// # Safety
1203
+ ///
1204
+ /// - This function may only be called from the cpufreq C infrastructure.
1205
+ /// - The pointer arguments must be valid pointers.
1206
+ unsafe extern "C" fn target_callback (
1169
1207
ptr : * mut bindings:: cpufreq_policy ,
1170
1208
target_freq : u32 ,
1171
1209
relation : u32 ,
@@ -1180,8 +1218,11 @@ impl<T: Driver> Registration<T> {
1180
1218
1181
1219
/// Driver's `target_index` callback.
1182
1220
///
1183
- /// SAFETY: Called from C. Inputs must be valid pointers.
1184
- extern "C" fn target_index_callback (
1221
+ /// # Safety
1222
+ ///
1223
+ /// - This function may only be called from the cpufreq C infrastructure.
1224
+ /// - The pointer arguments must be valid pointers.
1225
+ unsafe extern "C" fn target_index_callback (
1185
1226
ptr : * mut bindings:: cpufreq_policy ,
1186
1227
index : u32 ,
1187
1228
) -> kernel:: ffi:: c_int {
@@ -1200,8 +1241,11 @@ impl<T: Driver> Registration<T> {
1200
1241
1201
1242
/// Driver's `fast_switch` callback.
1202
1243
///
1203
- /// SAFETY: Called from C. Inputs must be valid pointers.
1204
- extern "C" fn fast_switch_callback (
1244
+ /// # Safety
1245
+ ///
1246
+ /// - This function may only be called from the cpufreq C infrastructure.
1247
+ /// - The pointer arguments must be valid pointers.
1248
+ unsafe extern "C" fn fast_switch_callback (
1205
1249
ptr : * mut bindings:: cpufreq_policy ,
1206
1250
target_freq : u32 ,
1207
1251
) -> kernel:: ffi:: c_uint {
@@ -1212,7 +1256,11 @@ impl<T: Driver> Registration<T> {
1212
1256
}
1213
1257
1214
1258
/// Driver's `adjust_perf` callback.
1215
- extern "C" fn adjust_perf_callback (
1259
+ ///
1260
+ /// # Safety
1261
+ ///
1262
+ /// - This function may only be called from the cpufreq C infrastructure.
1263
+ unsafe extern "C" fn adjust_perf_callback (
1216
1264
cpu : u32 ,
1217
1265
min_perf : usize ,
1218
1266
target_perf : usize ,
@@ -1225,8 +1273,11 @@ impl<T: Driver> Registration<T> {
1225
1273
1226
1274
/// Driver's `get_intermediate` callback.
1227
1275
///
1228
- /// SAFETY: Called from C. Inputs must be valid pointers.
1229
- extern "C" fn get_intermediate_callback (
1276
+ /// # Safety
1277
+ ///
1278
+ /// - This function may only be called from the cpufreq C infrastructure.
1279
+ /// - The pointer arguments must be valid pointers.
1280
+ unsafe extern "C" fn get_intermediate_callback (
1230
1281
ptr : * mut bindings:: cpufreq_policy ,
1231
1282
index : u32 ,
1232
1283
) -> kernel:: ffi:: c_uint {
@@ -1243,8 +1294,11 @@ impl<T: Driver> Registration<T> {
1243
1294
1244
1295
/// Driver's `target_intermediate` callback.
1245
1296
///
1246
- /// SAFETY: Called from C. Inputs must be valid pointers.
1247
- extern "C" fn target_intermediate_callback (
1297
+ /// # Safety
1298
+ ///
1299
+ /// - This function may only be called from the cpufreq C infrastructure.
1300
+ /// - The pointer arguments must be valid pointers.
1301
+ unsafe extern "C" fn target_intermediate_callback (
1248
1302
ptr : * mut bindings:: cpufreq_policy ,
1249
1303
index : u32 ,
1250
1304
) -> kernel:: ffi:: c_int {
@@ -1262,12 +1316,21 @@ impl<T: Driver> Registration<T> {
1262
1316
}
1263
1317
1264
1318
/// Driver's `get` callback.
1265
- extern "C" fn get_callback ( cpu : u32 ) -> kernel:: ffi:: c_uint {
1319
+ ///
1320
+ /// # Safety
1321
+ ///
1322
+ /// - This function may only be called from the cpufreq C infrastructure.
1323
+ unsafe extern "C" fn get_callback ( cpu : u32 ) -> kernel:: ffi:: c_uint {
1266
1324
PolicyCpu :: from_cpu ( cpu) . map_or ( 0 , |mut policy| T :: get ( & mut policy) . map_or ( 0 , |f| f) )
1267
1325
}
1268
1326
1269
1327
/// Driver's `update_limit` callback.
1270
- extern "C" fn update_limits_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1328
+ ///
1329
+ /// # Safety
1330
+ ///
1331
+ /// - This function may only be called from the cpufreq C infrastructure.
1332
+ /// - The pointer arguments must be valid pointers.
1333
+ unsafe extern "C" fn update_limits_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1271
1334
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1272
1335
// lifetime of `policy`.
1273
1336
let policy = unsafe { Policy :: from_raw_mut ( ptr) } ;
@@ -1276,8 +1339,11 @@ impl<T: Driver> Registration<T> {
1276
1339
1277
1340
/// Driver's `bios_limit` callback.
1278
1341
///
1279
- /// SAFETY: Called from C. Inputs must be valid pointers.
1280
- extern "C" fn bios_limit_callback ( cpu : i32 , limit : * mut u32 ) -> kernel:: ffi:: c_int {
1342
+ /// # Safety
1343
+ ///
1344
+ /// - This function may only be called from the cpufreq C infrastructure.
1345
+ /// - The pointer arguments must be valid pointers.
1346
+ unsafe extern "C" fn bios_limit_callback ( cpu : i32 , limit : * mut u32 ) -> kernel:: ffi:: c_int {
1281
1347
from_result ( || {
1282
1348
let mut policy = PolicyCpu :: from_cpu ( cpu as u32 ) ?;
1283
1349
@@ -1288,8 +1354,11 @@ impl<T: Driver> Registration<T> {
1288
1354
1289
1355
/// Driver's `set_boost` callback.
1290
1356
///
1291
- /// SAFETY: Called from C. Inputs must be valid pointers.
1292
- extern "C" fn set_boost_callback (
1357
+ /// # Safety
1358
+ ///
1359
+ /// - This function may only be called from the cpufreq C infrastructure.
1360
+ /// - The pointer arguments must be valid pointers.
1361
+ unsafe extern "C" fn set_boost_callback (
1293
1362
ptr : * mut bindings:: cpufreq_policy ,
1294
1363
state : i32 ,
1295
1364
) -> kernel:: ffi:: c_int {
@@ -1303,8 +1372,11 @@ impl<T: Driver> Registration<T> {
1303
1372
1304
1373
/// Driver's `register_em` callback.
1305
1374
///
1306
- /// SAFETY: Called from C. Inputs must be valid pointers.
1307
- extern "C" fn register_em_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1375
+ /// # Safety
1376
+ ///
1377
+ /// - This function may only be called from the cpufreq C infrastructure.
1378
+ /// - The pointer arguments must be valid pointers.
1379
+ unsafe extern "C" fn register_em_callback ( ptr : * mut bindings:: cpufreq_policy ) {
1308
1380
// SAFETY: The `ptr` is guaranteed to be valid by the contract with the C code for the
1309
1381
// lifetime of `policy`.
1310
1382
let policy = unsafe { Policy :: from_raw_mut ( ptr) } ;
0 commit comments