-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1531 from mmichal10/fix-make-req-type
configure framework: detect make_req_fn type
- Loading branch information
Showing
2 changed files
with
91 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright(c) 2024 Huawei Technologies | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
. $(dirname $3)/conf_framework.sh | ||
|
||
check() { | ||
cur_name=$(basename $2) | ||
config_file_path=$1 | ||
|
||
|
||
# The commit c62b37d96b6eb3ec5 in the kernel repo introduces `submit_bio` | ||
# and removes make_request_fn | ||
if compile_module $cur_name "struct block_device_operations x; x.submit_bio;" "linux/blkdev.h"; | ||
then | ||
# If it's impossible to cast the return value of submit_bio() | ||
# to an int we're assuming the function is of type void. | ||
# It's not a generic solution because the check would pass if | ||
# the return type would be a struct, but it can't happend in this | ||
# specific scenario | ||
# Mind the negation in the condition | ||
if ! compile_module $cur_name \ | ||
"struct block_device_operations x; int y = (int)x.submit_bio(NULL);" "linux/blkdev.h"; | ||
then | ||
# submit_bio is of type void | ||
echo $cur_name "1" >> $config_file_path | ||
elif compile_module $cur_name \ | ||
"struct block_device_operations x; blk_qc_t y = x.submit_bio(NULL);" "linux/blkdev.h" ; | ||
then | ||
# submit_bio is of type blk_qc_t | ||
echo $cur_name "2" >> $config_file_path | ||
else | ||
echo $cur_name "X" >> $config_file_path | ||
fi | ||
else | ||
# If it's impossible to cast the return value of make_request_fn() | ||
# to an int we're assuming the function is of type void. | ||
# It's not a generic solution because the check would pass if | ||
# the return type would be a struct, but it can't happend in this | ||
# specific scenario | ||
# Mind the negation in the condition | ||
if ! compile_module $cur_name \ | ||
"struct request_queue *q; int y = (int)q->make_request_fn(NULL);" "linux/blkdev.h"; | ||
then | ||
# make_request_fn is of type void | ||
echo $cur_name "3" >> $config_file_path | ||
elif ! compile_module $cur_name \ | ||
"struct request_queue *q; blk_qc_t y = q->make_request_fn(NULL);" "linux/blkdev.h"; | ||
then | ||
# make_request_fn is of type blk_qc_t | ||
echo $cur_name "4" >> $config_file_path | ||
elif ! compile_module $cur_name \ | ||
"struct request_queue *q; int y = q->make_request_fn(NULL);" "linux/blkdev.h"; | ||
then | ||
# make_request_fn is of type int | ||
echo $cur_name "5" >> $config_file_path | ||
else | ||
echo $cur_name "X" >> $config_file_path | ||
fi | ||
fi | ||
} | ||
|
||
apply() { | ||
case "$1" in | ||
"1") | ||
add_define "CAS_KRETURN(_x) return " | ||
add_define "CAS_MAKE_REQ_RET_TYPE void " ;; | ||
"2") | ||
add_define "CAS_KRETURN(_x) ({ return (_x); }) " | ||
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;; | ||
"3") | ||
add_define "CAS_KRETURN(_x) return " | ||
add_define "CAS_MAKE_REQ_RET_TYPE void " ;; | ||
"4") | ||
add_define "CAS_KRETURN(_x) ({ return (_x); }) " | ||
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;; | ||
"5") | ||
add_define "CAS_KRETURN(_x) ({ return (_x); }) " | ||
add_define "CAS_MAKE_REQ_RET_TYPE int " ;; | ||
*) | ||
exit 1 | ||
esac | ||
} | ||
|
||
conf_run $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters