* [PATCH] drm/amdgpu: Use flexible array member
@ 2022-04-08 4:02 Lijo Lazar
2022-04-08 8:48 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Lijo Lazar @ 2022-04-08 4:02 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Hawking.Zhang
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
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
drivers/gpu/drm/amd/include/discovery.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 5a182288391b..b577fa1d7ecc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -430,7 +430,7 @@ static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
}
}
next_ip:
- ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1);
+ ip_offset += sizeof(*ip) + sizeof(uint32_t) * (ip->num_base_address);
}
}
}
diff --git a/drivers/gpu/drm/amd/include/discovery.h b/drivers/gpu/drm/amd/include/discovery.h
index a486769b66c6..b25026c3ec96 100644
--- a/drivers/gpu/drm/amd/include/discovery.h
+++ b/drivers/gpu/drm/amd/include/discovery.h
@@ -93,7 +93,7 @@ typedef struct ip
uint8_t harvest : 4; /* Harvest */
uint8_t reserved : 4; /* Placeholder field */
#endif
- uint32_t base_address[1]; /* variable number of Addresses */
+ uint32_t base_address[]; /* variable number of Addresses */
} ip;
typedef struct die_header
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu: Use flexible array member
2022-04-08 4:02 [PATCH] drm/amdgpu: Use flexible array member Lijo Lazar
@ 2022-04-08 8:48 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2022-04-08 8:48 UTC (permalink / raw)
To: Lijo Lazar, amd-gfx; +Cc: Alexander.Deucher, Hawking.Zhang
Am 08.04.22 um 06:02 schrieb Lijo Lazar:
> 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
>
> Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
> drivers/gpu/drm/amd/include/discovery.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> index 5a182288391b..b577fa1d7ecc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -430,7 +430,7 @@ static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
> }
> }
> next_ip:
> - ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1);
> + ip_offset += sizeof(*ip) + sizeof(uint32_t) * (ip->num_base_address);
Please use the struct_size() macro for this, apart from that looks good
to me.
Thanks,
Christian.
> }
> }
> }
> diff --git a/drivers/gpu/drm/amd/include/discovery.h b/drivers/gpu/drm/amd/include/discovery.h
> index a486769b66c6..b25026c3ec96 100644
> --- a/drivers/gpu/drm/amd/include/discovery.h
> +++ b/drivers/gpu/drm/amd/include/discovery.h
> @@ -93,7 +93,7 @@ typedef struct ip
> uint8_t harvest : 4; /* Harvest */
> uint8_t reserved : 4; /* Placeholder field */
> #endif
> - uint32_t base_address[1]; /* variable number of Addresses */
> + uint32_t base_address[]; /* variable number of Addresses */
> } ip;
>
> typedef struct die_header
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-08 8:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 4:02 [PATCH] drm/amdgpu: Use flexible array member Lijo Lazar
2022-04-08 8:48 ` Christian König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.