soc: fsl: qe: fold qe_get_num_of_snums into qe_snums_init
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Mon, 13 May 2019 11:15:01 +0000 (11:15 +0000)
committerLi Yang <leoyang.li@nxp.com>
Wed, 5 Jun 2019 19:26:52 +0000 (14:26 -0500)
commit21560067fb1f5e87abedc3ecec5d46f67ac0c019
tree6009697a30935d7b99166a58d9289acf4914bcfb
parent5cfca8911ddd59150ba53cff16956eabe1b3dcac
soc: fsl: qe: fold qe_get_num_of_snums into qe_snums_init

The comment "No QE ever has fewer than 28 SNUMs" is false; e.g. the
MPC8309 has 14. The code path returning -EINVAL is also a recipe for
instant disaster, since the caller (qe_snums_init) uncritically
assigns the return value to the unsigned qe_num_of_snum, and would
thus proceed to attempt to copy 4GB from snum_init_46[] to the snum[]
array.

So fold the handling of the legacy fsl,qe-num-snums into
qe_snums_init, and make sure we do not end up using the snum_init_46
array in cases other than the two where we know it makes sense.

Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Qiang Zhao <qiang.zhao@nxp.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/qe/qe.c