@@ -192,7 +192,8 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
priv->ucc_pram_offset = qe_muram_alloc(sizeof(struct ucc_hdlc_param),
ALIGNMENT_OF_UCC_HDLC_PRAM);
- if (priv->ucc_pram_offset < 0) {
+ if (priv->ucc_pram_offset == (unsigned long)-ENOMEM ||
+ priv->ucc_pram_offset == (unsigned long)-ENOSYS) {
dev_err(priv->dev, "Can not allocate MURAM for hdlc parameter.\n");
ret = -ENOMEM;
goto free_tx_bd;
@@ -228,14 +229,16 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
/* Alloc riptr, tiptr */
riptr = qe_muram_alloc(32, 32);
- if (riptr < 0) {
+ if (riptr == (unsigned long)-ENOMEM ||
+ riptr == (unsigned long)-ENOSYS) {
dev_err(priv->dev, "Cannot allocate MURAM mem for Receive internal temp data pointer\n");
ret = -ENOMEM;
goto free_tx_skbuff;
}
tiptr = qe_muram_alloc(32, 32);
- if (tiptr < 0) {
+ if (tiptr == (unsigned long)-ENOMEM ||
+ tiptr == (unsigned long)-ENOSYS) {
dev_err(priv->dev, "Cannot allocate MURAM mem for Transmit internal temp data pointer\n");
ret = -ENOMEM;
goto free_riptr;
Presence of comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug, usually wrong type of variable. When using the qe_muram_alloc to alloc memory, return an offset into the muram area on success and (unsigned long)-ENOMEM or -ENOSYS (if not config CONFIG_CPM and CONFIG_QUICC_ENGINE) on failure. Generated by: scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci Fix c19b6d24('drivers/net: support hdlc function for QE-UCC') Cc: Zhao Qiang <qiang.zhao@nxp.com> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com> --- drivers/net/wan/fsl_ucc_hdlc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)