scsi: ufs: core: Fix the return value documentation

ufshcd_wait_for_dev_cmd() and all its callers can return an OCS error.
OCS errors are represented by positive integers. Remove the WARN_ONCE()
statements that complain about positive error codes and update the
documentation.

Keep the behavior of ufshcd_wait_for_dev_cmd() because this return value
may end be passed as the second argument of bsg_job_done() and
bsg_job_done() handles positive and negative error codes differently.

Cc: Peter Wang <peter.wang@mediatek.com>
Fixes: cc59f3b68542 ("scsi: ufs: core: Improve return value documentation")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20250815155842.472867-4-bvanassche@acm.org
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by Bart Van Assche and committed by Martin K. Petersen 9ee35fd4 e5203d89

+38 -24
+38 -24
drivers/ufs/core/ufshcd.c
··· 3199 } 3200 3201 /* 3202 - * Return: 0 upon success; < 0 upon failure. 3203 */ 3204 static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, 3205 struct ufshcd_lrb *lrbp, int max_timeout) ··· 3276 } 3277 } 3278 3279 - WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); 3280 return err; 3281 } 3282 ··· 3294 } 3295 3296 /* 3297 - * Return: 0 upon success; < 0 upon failure. 3298 */ 3299 static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, 3300 const u32 tag, int timeout) ··· 3318 * @cmd_type: specifies the type (NOP, Query...) 3319 * @timeout: timeout in milliseconds 3320 * 3321 - * Return: 0 upon success; < 0 upon failure. 3322 * 3323 * NOTE: Since there is only one available tag for device management commands, 3324 * it is expected you hold the hba->dev_cmd.lock mutex. ··· 3365 (*request)->upiu_req.selector = selector; 3366 } 3367 3368 static int ufshcd_query_flag_retry(struct ufs_hba *hba, 3369 enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) 3370 { ··· 3389 dev_err(hba->dev, 3390 "%s: query flag, opcode %d, idn %d, failed with error %d after %d retries\n", 3391 __func__, opcode, idn, ret, retries); 3392 - WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); 3393 return ret; 3394 } 3395 ··· 3400 * @index: flag index to access 3401 * @flag_res: the flag value after the query request completes 3402 * 3403 - * Return: 0 for success; < 0 upon failure. 3404 */ 3405 int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, 3406 enum flag_idn idn, u8 index, bool *flag_res) ··· 3457 3458 out_unlock: 3459 ufshcd_dev_man_unlock(hba); 3460 - WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); 3461 return err; 3462 } 3463 ··· 3469 * @selector: selector field 3470 * @attr_val: the attribute value after the query request completes 3471 * 3472 - * Return: 0 upon success; < 0 upon failure. 3473 - */ 3474 int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, 3475 enum attr_idn idn, u8 index, u8 selector, u32 *attr_val) 3476 { ··· 3519 3520 out_unlock: 3521 ufshcd_dev_man_unlock(hba); 3522 - WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); 3523 return err; 3524 } 3525 ··· 3533 * @attr_val: the attribute value after the query request 3534 * completes 3535 * 3536 - * Return: 0 for success; < 0 upon failure. 3537 - */ 3538 int ufshcd_query_attr_retry(struct ufs_hba *hba, 3539 enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, 3540 u32 *attr_val) ··· 3557 dev_err(hba->dev, 3558 "%s: query attribute, idn %d, failed with error %d after %d retries\n", 3559 __func__, idn, ret, QUERY_REQ_RETRIES); 3560 - WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); 3561 return ret; 3562 } 3563 3564 /* 3565 - * Return: 0 if successful; < 0 upon failure. 3566 */ 3567 static int __ufshcd_query_descriptor(struct ufs_hba *hba, 3568 enum query_opcode opcode, enum desc_idn idn, u8 index, ··· 3621 out_unlock: 3622 hba->dev_cmd.query.descriptor = NULL; 3623 ufshcd_dev_man_unlock(hba); 3624 - WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); 3625 return err; 3626 } 3627 ··· 3637 * The buf_len parameter will contain, on return, the length parameter 3638 * received on the response. 3639 * 3640 - * Return: 0 for success; < 0 upon failure. 3641 */ 3642 int ufshcd_query_descriptor_retry(struct ufs_hba *hba, 3643 enum query_opcode opcode, ··· 3656 break; 3657 } 3658 3659 - WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); 3660 return err; 3661 } 3662 ··· 3668 * @param_read_buf: pointer to buffer where parameter would be read 3669 * @param_size: sizeof(param_read_buf) 3670 * 3671 - * Return: 0 in case of success; < 0 upon failure. 3672 */ 3673 int ufshcd_read_desc_param(struct ufs_hba *hba, 3674 enum desc_idn desc_id, ··· 3736 out: 3737 if (is_kmalloc) 3738 kfree(desc_buf); 3739 - WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); 3740 return ret; 3741 } 3742 ··· 4786 * 4787 * Set fDeviceInit flag and poll until device toggles it. 4788 * 4789 - * Return: 0 upon success; < 0 upon failure. 4790 */ 4791 static int ufshcd_complete_dev_init(struct ufs_hba *hba) 4792 { ··· 5141 * not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT 5142 * and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations. 5143 * 5144 - * Return: 0 upon success; < 0 upon failure. 5145 */ 5146 static int ufshcd_verify_dev_init(struct ufs_hba *hba) 5147 { ··· 5874 * as the device is allowed to manage its own way of handling background 5875 * operations. 5876 * 5877 - * Return: zero on success, non-zero on failure. 5878 */ 5879 static int ufshcd_enable_auto_bkops(struct ufs_hba *hba) 5880 { ··· 5914 * host is idle so that BKOPS are managed effectively without any negative 5915 * impacts. 5916 * 5917 - * Return: zero on success, non-zero on failure. 5918 */ 5919 static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) 5920 { ··· 6065 __func__, err); 6066 } 6067 6068 int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id) 6069 { 6070 struct utp_upiu_query_v4_0 *upiu_resp; ··· 7465 * @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation 7466 * @dir: DMA direction 7467 * 7468 - * Return: zero on success, non-zero on failure. 7469 */ 7470 int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, 7471 struct utp_upiu_req *rsp_upiu, struct ufs_ehs *req_ehs,
··· 3199 } 3200 3201 /* 3202 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3203 + * < 0 if another error occurred. 3204 */ 3205 static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, 3206 struct ufshcd_lrb *lrbp, int max_timeout) ··· 3275 } 3276 } 3277 3278 return err; 3279 } 3280 ··· 3294 } 3295 3296 /* 3297 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3298 + * < 0 if another error occurred. 3299 */ 3300 static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, 3301 const u32 tag, int timeout) ··· 3317 * @cmd_type: specifies the type (NOP, Query...) 3318 * @timeout: timeout in milliseconds 3319 * 3320 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3321 + * < 0 if another error occurred. 3322 * 3323 * NOTE: Since there is only one available tag for device management commands, 3324 * it is expected you hold the hba->dev_cmd.lock mutex. ··· 3363 (*request)->upiu_req.selector = selector; 3364 } 3365 3366 + /* 3367 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3368 + * < 0 if another error occurred. 3369 + */ 3370 static int ufshcd_query_flag_retry(struct ufs_hba *hba, 3371 enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) 3372 { ··· 3383 dev_err(hba->dev, 3384 "%s: query flag, opcode %d, idn %d, failed with error %d after %d retries\n", 3385 __func__, opcode, idn, ret, retries); 3386 return ret; 3387 } 3388 ··· 3395 * @index: flag index to access 3396 * @flag_res: the flag value after the query request completes 3397 * 3398 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3399 + * < 0 if another error occurred. 3400 */ 3401 int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, 3402 enum flag_idn idn, u8 index, bool *flag_res) ··· 3451 3452 out_unlock: 3453 ufshcd_dev_man_unlock(hba); 3454 return err; 3455 } 3456 ··· 3464 * @selector: selector field 3465 * @attr_val: the attribute value after the query request completes 3466 * 3467 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3468 + * < 0 if another error occurred. 3469 + */ 3470 int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, 3471 enum attr_idn idn, u8 index, u8 selector, u32 *attr_val) 3472 { ··· 3513 3514 out_unlock: 3515 ufshcd_dev_man_unlock(hba); 3516 return err; 3517 } 3518 ··· 3528 * @attr_val: the attribute value after the query request 3529 * completes 3530 * 3531 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3532 + * < 0 if another error occurred. 3533 + */ 3534 int ufshcd_query_attr_retry(struct ufs_hba *hba, 3535 enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, 3536 u32 *attr_val) ··· 3551 dev_err(hba->dev, 3552 "%s: query attribute, idn %d, failed with error %d after %d retries\n", 3553 __func__, idn, ret, QUERY_REQ_RETRIES); 3554 return ret; 3555 } 3556 3557 /* 3558 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3559 + * < 0 if another error occurred. 3560 */ 3561 static int __ufshcd_query_descriptor(struct ufs_hba *hba, 3562 enum query_opcode opcode, enum desc_idn idn, u8 index, ··· 3615 out_unlock: 3616 hba->dev_cmd.query.descriptor = NULL; 3617 ufshcd_dev_man_unlock(hba); 3618 return err; 3619 } 3620 ··· 3632 * The buf_len parameter will contain, on return, the length parameter 3633 * received on the response. 3634 * 3635 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3636 + * < 0 if another error occurred. 3637 */ 3638 int ufshcd_query_descriptor_retry(struct ufs_hba *hba, 3639 enum query_opcode opcode, ··· 3650 break; 3651 } 3652 3653 return err; 3654 } 3655 ··· 3663 * @param_read_buf: pointer to buffer where parameter would be read 3664 * @param_size: sizeof(param_read_buf) 3665 * 3666 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 3667 + * < 0 if another error occurred. 3668 */ 3669 int ufshcd_read_desc_param(struct ufs_hba *hba, 3670 enum desc_idn desc_id, ··· 3730 out: 3731 if (is_kmalloc) 3732 kfree(desc_buf); 3733 return ret; 3734 } 3735 ··· 4781 * 4782 * Set fDeviceInit flag and poll until device toggles it. 4783 * 4784 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 4785 + * < 0 if another error occurred. 4786 */ 4787 static int ufshcd_complete_dev_init(struct ufs_hba *hba) 4788 { ··· 5135 * not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT 5136 * and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations. 5137 * 5138 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 5139 + * < 0 if another error occurred. 5140 */ 5141 static int ufshcd_verify_dev_init(struct ufs_hba *hba) 5142 { ··· 5867 * as the device is allowed to manage its own way of handling background 5868 * operations. 5869 * 5870 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 5871 + * < 0 if another error occurred. 5872 */ 5873 static int ufshcd_enable_auto_bkops(struct ufs_hba *hba) 5874 { ··· 5906 * host is idle so that BKOPS are managed effectively without any negative 5907 * impacts. 5908 * 5909 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 5910 + * < 0 if another error occurred. 5911 */ 5912 static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) 5913 { ··· 6056 __func__, err); 6057 } 6058 6059 + /* 6060 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 6061 + * < 0 if another error occurred. 6062 + */ 6063 int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id) 6064 { 6065 struct utp_upiu_query_v4_0 *upiu_resp; ··· 7452 * @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation 7453 * @dir: DMA direction 7454 * 7455 + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; 7456 + * < 0 if another error occurred. 7457 */ 7458 int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, 7459 struct utp_upiu_req *rsp_upiu, struct ufs_ehs *req_ehs,