Use struct binary_header directly as parameter of amdgpu_discovery_verify_binary_signature() Signed-off-by: Ma Jun <Jun.Ma2@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index 230412fc4d62..e6041f0b72fa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -334,11 +334,8 @@ static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size return !!(amdgpu_discovery_calculate_checksum(data, size) == expected); } -static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary) +static inline bool amdgpu_discovery_verify_binary_signature(struct binary_header *bhdr) { - struct binary_header *bhdr; - bhdr = (struct binary_header *)binary; - return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE); } @@ -399,16 +396,16 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) goto out; } + bhdr = (struct binary_header *)adev->mman.discovery_bin; + /* check the ip discovery binary signature */ - if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) { + if (!amdgpu_discovery_verify_binary_signature(bhdr)) { dev_err(adev->dev, "get invalid ip discovery binary signature\n"); r = -EINVAL; goto out; } - bhdr = (struct binary_header *)adev->mman.discovery_bin; - offset = offsetof(struct binary_header, binary_checksum) + sizeof(bhdr->binary_checksum); size = le16_to_cpu(bhdr->binary_size) - offset; -- 2.34.1