Fix access to cpu_model[] in mtk_soc_set_cpu_model()

There may be cases where cpu_model[] may not be 32bit aligned, so it is
better to not try to access it as such in order to avoid unaligned access.

Sponsored by:	Smartcom - Bulgaria AD
This commit is contained in:
Stanislav Galabov 2018-11-19 06:48:48 +00:00
parent be7af100ad
commit ef4e6c8fe8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340613

View File

@ -401,7 +401,9 @@ extern char cpu_model[];
void
mtk_soc_set_cpu_model(void)
{
uint32_t *p_model = (uint32_t *)cpu_model;
int idx, offset = sizeof(mtk_soc_chipid0_3);
char *chipid0_3 = (char *)(&mtk_soc_chipid0_3);
char *chipid4_7 = (char *)(&mtk_soc_chipid4_7);
/*
* CHIPID is always 2x32 bit registers, containing the ASCII
@ -411,11 +413,13 @@ mtk_soc_set_cpu_model(void)
* it is left at its default value of "unknown " if it could not be
* obtained for some reason.
*/
p_model[0] = mtk_soc_chipid0_3;
p_model[1] = mtk_soc_chipid4_7;
for (idx = 0; idx < offset; idx++) {
cpu_model[idx] = chipid0_3[idx];
cpu_model[idx + offset] = chipid4_7[idx];
}
/* Null-terminate the string */
cpu_model[8] = 0;
cpu_model[2 * offset] = 0;
}
uint32_t