
On 07/03/2016 11:39 PM, Zhiqiang Hou wrote:
From: Hou Zhiqiang Zhiqiang.Hou@nxp.com
Up to now, the function is_serdes_configed() doesn't check if the map of serdes protocol is initialized before accessing it. The function is_serdes_configed() will get wrong result when it was called before the serdes protocol maps initialized. As the first eliment of the map
s/eliment/element
isn't used for any device, so use it as the flag to indicate if the map has been initialized.
I am not sure it is safe to presume the first element is always not used. Take LS2080A as an example, the serdes map array is initialized by serdes_init(), which calls serdes_get_prtcl() to get the index of the array. With normal condition, the index shouldn't be zero. Zero is used as an error but it is not checked before setting
serdes_prtcl_map[lane_prtcl] = 1;
If you presumption is correct, and you want to use the first one as a flag, you probably need to check all of them to make sure errors are handled correctly, instead of setting the flag unexpected. Also it is important to document this idea so future platform code follows the same.
York