mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 02:53:16 -04:00
scsi: ufs: Use unsigned types for the BSG query
The UPIU query length field is an unsigned 16-bit value per the UFS standard, but ufs_bsg carried it around in signed int. Switch the descriptor length and buffer pointer to u16/u8, fold the trivial ufs_bsg_get_query_desc_size() helper into its only caller, and replace min_t(int, ...) with min(). No functional change intended. Signed-off-by: Hyeoncheol Jeong <hyenc.jeong@samsung.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20260728092434epcms2p56b013ab7a2df90d3df9186322de54340@epcms2p5 Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
committed by
Martin K. Petersen (Oracle)
parent
dc59e4fea9
commit
dca46c4ff2
@@ -13,21 +13,8 @@
|
||||
#include <ufs/ufshcd.h>
|
||||
#include "ufshcd-priv.h"
|
||||
|
||||
static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
|
||||
struct utp_upiu_query *qr)
|
||||
{
|
||||
int desc_size = be16_to_cpu(qr->length);
|
||||
|
||||
if (desc_size <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
*desc_len = min_t(int, QUERY_DESC_MAX_SIZE, desc_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ufs_bsg_alloc_desc_buffer(struct ufs_hba *hba, struct bsg_job *job,
|
||||
uint8_t **desc_buff, int *desc_len,
|
||||
u8 **desc_buff, u16 *desc_len,
|
||||
enum query_opcode desc_op)
|
||||
{
|
||||
struct ufs_bsg_request *bsg_request = job->request;
|
||||
@@ -39,11 +26,14 @@ static int ufs_bsg_alloc_desc_buffer(struct ufs_hba *hba, struct bsg_job *job,
|
||||
goto out;
|
||||
|
||||
qr = &bsg_request->upiu_req.qr;
|
||||
if (ufs_bsg_get_query_desc_size(hba, desc_len, qr)) {
|
||||
*desc_len = be16_to_cpu(qr->length);
|
||||
if (*desc_len == 0) {
|
||||
dev_err(hba->dev, "Illegal desc size\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*desc_len = min(*desc_len, QUERY_DESC_MAX_SIZE);
|
||||
|
||||
if (*desc_len > job->request_payload.payload_len) {
|
||||
dev_err(hba->dev, "Illegal desc size\n");
|
||||
return -EINVAL;
|
||||
@@ -136,8 +126,9 @@ static int ufs_bsg_request(struct bsg_job *job)
|
||||
struct ufs_hba *hba = shost_priv(dev_to_shost(job->dev->parent));
|
||||
struct uic_command uc = {};
|
||||
int msgcode;
|
||||
uint8_t *buff = NULL;
|
||||
int desc_len = 0;
|
||||
u8 *buff = NULL;
|
||||
u16 desc_len = 0;
|
||||
int buff_len;
|
||||
enum query_opcode desc_op = UPIU_QUERY_OPCODE_NOP;
|
||||
int ret;
|
||||
bool rpmb = false;
|
||||
@@ -156,9 +147,11 @@ static int ufs_bsg_request(struct bsg_job *job)
|
||||
fallthrough;
|
||||
case UPIU_TRANSACTION_NOP_OUT:
|
||||
case UPIU_TRANSACTION_TASK_REQ:
|
||||
buff_len = desc_len;
|
||||
ret = ufshcd_exec_raw_upiu_cmd(hba, &bsg_request->upiu_req,
|
||||
&bsg_reply->upiu_rsp, msgcode,
|
||||
buff, &desc_len, desc_op);
|
||||
buff, &buff_len, desc_op);
|
||||
desc_len = buff_len;
|
||||
if (ret)
|
||||
dev_err(hba->dev, "exe raw upiu: error code %d\n", ret);
|
||||
else if (desc_op == UPIU_QUERY_OPCODE_READ_DESC && desc_len) {
|
||||
|
||||
Reference in New Issue
Block a user