drm/amdgpu: Add double-sscanf but invert
Add back the double-sscanf so that both decimal and hexadecimal values could be read in, but this time invert the scan so that hexadecimal format with a leading 0x is tried first, and if that fails, then try decimal format. Also use a logical-AND instead of nesting double if-conditional. See commit "drm/amdgpu: Fix a bug for input with double sscanf" Cc: Alexander Deucher <Alexander.Deucher@amd.com> Cc: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Luben Tuikov <luben.tuikov@amd.com> Reviewed-by: John Clements <john.clements@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
b960cb25b1
commit
546aa546b0
@ -229,7 +229,8 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
|
||||
|
||||
if (op != -1) {
|
||||
if (op == 3) {
|
||||
if (sscanf(str, "%*s %llx", &address) != 1)
|
||||
if (sscanf(str, "%*s 0x%llx", &address) != 1 &&
|
||||
sscanf(str, "%*s %llu", &address) != 1)
|
||||
return -EINVAL;
|
||||
|
||||
data->op = op;
|
||||
@ -253,7 +254,9 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
|
||||
data->op = op;
|
||||
|
||||
if (op == 2) {
|
||||
if (sscanf(str, "%*s %*s %*s %x %llx %llx",
|
||||
if (sscanf(str, "%*s %*s %*s 0x%x 0x%llx 0x%llx",
|
||||
&sub_block, &address, &value) != 3 &&
|
||||
sscanf(str, "%*s %*s %*s %u %llu %llu",
|
||||
&sub_block, &address, &value) != 3)
|
||||
return -EINVAL;
|
||||
data->head.sub_block_index = sub_block;
|
||||
|
Loading…
x
Reference in New Issue
Block a user