ntb_hw_switchtec: Fix ntb_mw_clear_trans error if size == 0
authorAlexander Fomichev <fomichev.ru@gmail.com>
Thu, 13 Feb 2020 15:05:07 +0000 (18:05 +0300)
committerJon Mason <jdmason@kudzu.us>
Fri, 13 Mar 2020 14:03:49 +0000 (10:03 -0400)
ntb_mw_set_trans() should work as ntb_mw_clear_trans() when size == 0 and/or
addr == 0. But error in xlate_pos checking condition prevents this.
Fix the condition to make ntb_mw_clear_trans() working.

Fixes: 87d11e645e31 (NTB: switchtec_ntb: Add memory window support)
Signed-off-by: Alexander Fomichev <fomichev.ru@gmail.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/hw/mscc/ntb_hw_switchtec.c

index 86ffa716eaf22893f0727f8c0883c34dc97600cb..4c6eb61a6ac62d4a87e4e7d55c33c3d5c3d4a516 100644 (file)
@@ -285,7 +285,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
        if (widx >= switchtec_ntb_mw_count(ntb, pidx))
                return -EINVAL;
 
-       if (xlate_pos < 12)
+       if (size != 0 && xlate_pos < 12)
                return -EINVAL;
 
        if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) {