Skip to content

Commit 9ee35fd

Browse files
bvanasschemartinkpetersen
authored andcommitted
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 <[email protected]> Fixes: cc59f3b ("scsi: ufs: core: Improve return value documentation") Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Peter Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e5203d8 commit 9ee35fd

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
31993199
}
32003200

32013201
/*
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.
32033204
*/
32043205
static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
32053206
struct ufshcd_lrb *lrbp, int max_timeout)
@@ -3275,7 +3276,6 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
32753276
}
32763277
}
32773278

3278-
WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err);
32793279
return err;
32803280
}
32813281

@@ -3294,7 +3294,8 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
32943294
}
32953295

32963296
/*
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.
32983299
*/
32993300
static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
33003301
const u32 tag, int timeout)
@@ -3317,7 +3318,8 @@ static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
33173318
* @cmd_type: specifies the type (NOP, Query...)
33183319
* @timeout: timeout in milliseconds
33193320
*
3320-
* Return: 0 upon success; < 0 upon failure.
3321+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3322+
* < 0 if another error occurred.
33213323
*
33223324
* NOTE: Since there is only one available tag for device management commands,
33233325
* it is expected you hold the hba->dev_cmd.lock mutex.
@@ -3363,6 +3365,10 @@ static inline void ufshcd_init_query(struct ufs_hba *hba,
33633365
(*request)->upiu_req.selector = selector;
33643366
}
33653367

3368+
/*
3369+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3370+
* < 0 if another error occurred.
3371+
*/
33663372
static int ufshcd_query_flag_retry(struct ufs_hba *hba,
33673373
enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res)
33683374
{
@@ -3383,7 +3389,6 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
33833389
dev_err(hba->dev,
33843390
"%s: query flag, opcode %d, idn %d, failed with error %d after %d retries\n",
33853391
__func__, opcode, idn, ret, retries);
3386-
WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret);
33873392
return ret;
33883393
}
33893394

@@ -3395,7 +3400,8 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
33953400
* @index: flag index to access
33963401
* @flag_res: the flag value after the query request completes
33973402
*
3398-
* Return: 0 for success; < 0 upon failure.
3403+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3404+
* < 0 if another error occurred.
33993405
*/
34003406
int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
34013407
enum flag_idn idn, u8 index, bool *flag_res)
@@ -3451,7 +3457,6 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
34513457

34523458
out_unlock:
34533459
ufshcd_dev_man_unlock(hba);
3454-
WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err);
34553460
return err;
34563461
}
34573462

@@ -3464,8 +3469,9 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
34643469
* @selector: selector field
34653470
* @attr_val: the attribute value after the query request completes
34663471
*
3467-
* Return: 0 upon success; < 0 upon failure.
3468-
*/
3472+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3473+
* < 0 if another error occurred.
3474+
*/
34693475
int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
34703476
enum attr_idn idn, u8 index, u8 selector, u32 *attr_val)
34713477
{
@@ -3513,7 +3519,6 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
35133519

35143520
out_unlock:
35153521
ufshcd_dev_man_unlock(hba);
3516-
WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err);
35173522
return err;
35183523
}
35193524

@@ -3528,8 +3533,9 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
35283533
* @attr_val: the attribute value after the query request
35293534
* completes
35303535
*
3531-
* Return: 0 for success; < 0 upon failure.
3532-
*/
3536+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3537+
* < 0 if another error occurred.
3538+
*/
35333539
int ufshcd_query_attr_retry(struct ufs_hba *hba,
35343540
enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector,
35353541
u32 *attr_val)
@@ -3551,12 +3557,12 @@ int ufshcd_query_attr_retry(struct ufs_hba *hba,
35513557
dev_err(hba->dev,
35523558
"%s: query attribute, idn %d, failed with error %d after %d retries\n",
35533559
__func__, idn, ret, QUERY_REQ_RETRIES);
3554-
WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret);
35553560
return ret;
35563561
}
35573562

35583563
/*
3559-
* Return: 0 if successful; < 0 upon failure.
3564+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3565+
* < 0 if another error occurred.
35603566
*/
35613567
static int __ufshcd_query_descriptor(struct ufs_hba *hba,
35623568
enum query_opcode opcode, enum desc_idn idn, u8 index,
@@ -3615,7 +3621,6 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
36153621
out_unlock:
36163622
hba->dev_cmd.query.descriptor = NULL;
36173623
ufshcd_dev_man_unlock(hba);
3618-
WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err);
36193624
return err;
36203625
}
36213626

@@ -3632,7 +3637,8 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
36323637
* The buf_len parameter will contain, on return, the length parameter
36333638
* received on the response.
36343639
*
3635-
* Return: 0 for success; < 0 upon failure.
3640+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3641+
* < 0 if another error occurred.
36363642
*/
36373643
int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
36383644
enum query_opcode opcode,
@@ -3650,7 +3656,6 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
36503656
break;
36513657
}
36523658

3653-
WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err);
36543659
return err;
36553660
}
36563661

@@ -3663,7 +3668,8 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
36633668
* @param_read_buf: pointer to buffer where parameter would be read
36643669
* @param_size: sizeof(param_read_buf)
36653670
*
3666-
* Return: 0 in case of success; < 0 upon failure.
3671+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
3672+
* < 0 if another error occurred.
36673673
*/
36683674
int ufshcd_read_desc_param(struct ufs_hba *hba,
36693675
enum desc_idn desc_id,
@@ -3730,7 +3736,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
37303736
out:
37313737
if (is_kmalloc)
37323738
kfree(desc_buf);
3733-
WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret);
37343739
return ret;
37353740
}
37363741

@@ -4781,7 +4786,8 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);
47814786
*
47824787
* Set fDeviceInit flag and poll until device toggles it.
47834788
*
4784-
* Return: 0 upon success; < 0 upon failure.
4789+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
4790+
* < 0 if another error occurred.
47854791
*/
47864792
static int ufshcd_complete_dev_init(struct ufs_hba *hba)
47874793
{
@@ -5135,7 +5141,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
51355141
* not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT
51365142
* and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations.
51375143
*
5138-
* Return: 0 upon success; < 0 upon failure.
5144+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5145+
* < 0 if another error occurred.
51395146
*/
51405147
static int ufshcd_verify_dev_init(struct ufs_hba *hba)
51415148
{
@@ -5867,7 +5874,8 @@ static inline int ufshcd_enable_ee(struct ufs_hba *hba, u16 mask)
58675874
* as the device is allowed to manage its own way of handling background
58685875
* operations.
58695876
*
5870-
* Return: zero on success, non-zero on failure.
5877+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5878+
* < 0 if another error occurred.
58715879
*/
58725880
static int ufshcd_enable_auto_bkops(struct ufs_hba *hba)
58735881
{
@@ -5906,7 +5914,8 @@ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba)
59065914
* host is idle so that BKOPS are managed effectively without any negative
59075915
* impacts.
59085916
*
5909-
* Return: zero on success, non-zero on failure.
5917+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
5918+
* < 0 if another error occurred.
59105919
*/
59115920
static int ufshcd_disable_auto_bkops(struct ufs_hba *hba)
59125921
{
@@ -6056,6 +6065,10 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba)
60566065
__func__, err);
60576066
}
60586067

6068+
/*
6069+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
6070+
* < 0 if another error occurred.
6071+
*/
60596072
int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id)
60606073
{
60616074
struct utp_upiu_query_v4_0 *upiu_resp;
@@ -7452,7 +7465,8 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
74527465
* @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation
74537466
* @dir: DMA direction
74547467
*
7455-
* Return: zero on success, non-zero on failure.
7468+
* Return: 0 upon success; > 0 in case the UFS device reported an OCS error;
7469+
* < 0 if another error occurred.
74567470
*/
74577471
int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu,
74587472
struct utp_upiu_req *rsp_upiu, struct ufs_ehs *req_ehs,

0 commit comments

Comments
 (0)