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