Commit 73bce7a4 authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher

drm/amdgpu: Use flexible array member

Use flexible array member in ip discovery struct as recommended[1].

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

v2: squash in struct_size fixes
Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 25faeddc
...@@ -430,7 +430,7 @@ static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev, ...@@ -430,7 +430,7 @@ static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
} }
} }
next_ip: next_ip:
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); ip_offset += struct_size(ip, base_address, ip->num_base_address);
} }
} }
} }
...@@ -798,7 +798,7 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, ...@@ -798,7 +798,7 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
res = kobject_add(&ip_hw_instance->kobj, NULL, res = kobject_add(&ip_hw_instance->kobj, NULL,
"%d", ip_hw_instance->num_instance); "%d", ip_hw_instance->num_instance);
next_ip: next_ip:
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); ip_offset += struct_size(ip, base_address, ip->num_base_address);
} }
} }
...@@ -1063,7 +1063,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) ...@@ -1063,7 +1063,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
} }
next_ip: next_ip:
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); ip_offset += struct_size(ip, base_address, ip->num_base_address);
} }
} }
...@@ -1113,7 +1113,7 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int n ...@@ -1113,7 +1113,7 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int n
*revision = ip->revision; *revision = ip->revision;
return 0; return 0;
} }
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); ip_offset += struct_size(ip, base_address, ip->num_base_address);
} }
} }
......
...@@ -93,7 +93,7 @@ typedef struct ip ...@@ -93,7 +93,7 @@ typedef struct ip
uint8_t harvest : 4; /* Harvest */ uint8_t harvest : 4; /* Harvest */
uint8_t reserved : 4; /* Placeholder field */ uint8_t reserved : 4; /* Placeholder field */
#endif #endif
uint32_t base_address[1]; /* variable number of Addresses */ uint32_t base_address[]; /* variable number of Addresses */
} ip; } ip;
typedef struct die_header typedef struct die_header
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment