forked from Minki/linux
scsi: ufs: refactor device descriptor reading
Pull device descriptor reading out of ufs quirk so it can be used also for other purposes. Revamp the fixup setup: 1. Rename ufs_device_info to ufs_dev_desc as very similar name ufs_dev_info is already in use. 2. Make the handlers static as they are not used out of the ufshdc.c file. [mkp: applied by hand] Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
d79713f911
commit
93fdd5ac64
@ -523,4 +523,16 @@ struct ufs_dev_info {
|
||||
bool is_lu_power_on_wp;
|
||||
};
|
||||
|
||||
#define MAX_MODEL_LEN 16
|
||||
/**
|
||||
* ufs_dev_desc - ufs device details from the device descriptor
|
||||
*
|
||||
* @wmanufacturerid: card details
|
||||
* @model: card model
|
||||
*/
|
||||
struct ufs_dev_desc {
|
||||
u16 wmanufacturerid;
|
||||
char model[MAX_MODEL_LEN + 1];
|
||||
};
|
||||
|
||||
#endif /* End of Header */
|
||||
|
@ -21,41 +21,28 @@
|
||||
#define UFS_ANY_VENDOR 0xFFFF
|
||||
#define UFS_ANY_MODEL "ANY_MODEL"
|
||||
|
||||
#define MAX_MODEL_LEN 16
|
||||
|
||||
#define UFS_VENDOR_TOSHIBA 0x198
|
||||
#define UFS_VENDOR_SAMSUNG 0x1CE
|
||||
#define UFS_VENDOR_SKHYNIX 0x1AD
|
||||
|
||||
/**
|
||||
* ufs_device_info - ufs device details
|
||||
* @wmanufacturerid: card details
|
||||
* @model: card model
|
||||
*/
|
||||
struct ufs_device_info {
|
||||
u16 wmanufacturerid;
|
||||
char model[MAX_MODEL_LEN + 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* ufs_dev_fix - ufs device quirk info
|
||||
* @card: ufs card details
|
||||
* @quirk: device quirk
|
||||
*/
|
||||
struct ufs_dev_fix {
|
||||
struct ufs_device_info card;
|
||||
struct ufs_dev_desc card;
|
||||
unsigned int quirk;
|
||||
};
|
||||
|
||||
#define END_FIX { { 0 }, 0 }
|
||||
|
||||
/* add specific device quirk */
|
||||
#define UFS_FIX(_vendor, _model, _quirk) \
|
||||
{ \
|
||||
.card.wmanufacturerid = (_vendor),\
|
||||
.card.model = (_model), \
|
||||
.quirk = (_quirk), \
|
||||
}
|
||||
#define UFS_FIX(_vendor, _model, _quirk) { \
|
||||
.card.wmanufacturerid = (_vendor),\
|
||||
.card.model = (_model), \
|
||||
.quirk = (_quirk), \
|
||||
}
|
||||
|
||||
/*
|
||||
* If UFS device is having issue in processing LCC (Line Control
|
||||
@ -144,7 +131,4 @@ struct ufs_dev_fix {
|
||||
*/
|
||||
#define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8)
|
||||
|
||||
struct ufs_hba;
|
||||
void ufs_advertise_fixup_device(struct ufs_hba *hba);
|
||||
|
||||
#endif /* UFS_QUIRKS_H_ */
|
||||
|
@ -5452,8 +5452,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ufs_get_device_info(struct ufs_hba *hba,
|
||||
struct ufs_device_info *card_data)
|
||||
static int ufs_get_device_desc(struct ufs_hba *hba,
|
||||
struct ufs_dev_desc *dev_desc)
|
||||
{
|
||||
int err;
|
||||
u8 model_index;
|
||||
@ -5472,7 +5472,7 @@ static int ufs_get_device_info(struct ufs_hba *hba,
|
||||
* getting vendor (manufacturerID) and Bank Index in big endian
|
||||
* format
|
||||
*/
|
||||
card_data->wmanufacturerid = desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8 |
|
||||
dev_desc->wmanufacturerid = desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8 |
|
||||
desc_buf[DEVICE_DESC_PARAM_MANF_ID + 1];
|
||||
|
||||
model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];
|
||||
@ -5486,36 +5486,26 @@ static int ufs_get_device_info(struct ufs_hba *hba,
|
||||
}
|
||||
|
||||
str_desc_buf[QUERY_DESC_STRING_MAX_SIZE] = '\0';
|
||||
strlcpy(card_data->model, (str_desc_buf + QUERY_DESC_HDR_SIZE),
|
||||
strlcpy(dev_desc->model, (str_desc_buf + QUERY_DESC_HDR_SIZE),
|
||||
min_t(u8, str_desc_buf[QUERY_DESC_LENGTH_OFFSET],
|
||||
MAX_MODEL_LEN));
|
||||
|
||||
/* Null terminate the model string */
|
||||
card_data->model[MAX_MODEL_LEN] = '\0';
|
||||
dev_desc->model[MAX_MODEL_LEN] = '\0';
|
||||
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
void ufs_advertise_fixup_device(struct ufs_hba *hba)
|
||||
static void ufs_fixup_device_setup(struct ufs_hba *hba,
|
||||
struct ufs_dev_desc *dev_desc)
|
||||
{
|
||||
int err;
|
||||
struct ufs_dev_fix *f;
|
||||
struct ufs_device_info card_data;
|
||||
|
||||
card_data.wmanufacturerid = 0;
|
||||
|
||||
err = ufs_get_device_info(hba, &card_data);
|
||||
if (err) {
|
||||
dev_err(hba->dev, "%s: Failed getting device info. err = %d\n",
|
||||
__func__, err);
|
||||
return;
|
||||
}
|
||||
|
||||
for (f = ufs_fixups; f->quirk; f++) {
|
||||
if (((f->card.wmanufacturerid == card_data.wmanufacturerid) ||
|
||||
(f->card.wmanufacturerid == UFS_ANY_VENDOR)) &&
|
||||
(STR_PRFX_EQUAL(f->card.model, card_data.model) ||
|
||||
if ((f->card.wmanufacturerid == dev_desc->wmanufacturerid ||
|
||||
f->card.wmanufacturerid == UFS_ANY_VENDOR) &&
|
||||
(STR_PRFX_EQUAL(f->card.model, dev_desc->model) ||
|
||||
!strcmp(f->card.model, UFS_ANY_MODEL)))
|
||||
hba->dev_quirks |= f->quirk;
|
||||
}
|
||||
@ -5707,6 +5697,7 @@ static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
|
||||
*/
|
||||
static int ufshcd_probe_hba(struct ufs_hba *hba)
|
||||
{
|
||||
struct ufs_dev_desc card = {0};
|
||||
int ret;
|
||||
ktime_t start = ktime_get();
|
||||
|
||||
@ -5732,7 +5723,14 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ufs_advertise_fixup_device(hba);
|
||||
ret = ufs_get_device_desc(hba, &card);
|
||||
if (ret) {
|
||||
dev_err(hba->dev, "%s: Failed getting device info. err = %d\n",
|
||||
__func__, ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ufs_fixup_device_setup(hba, &card);
|
||||
ufshcd_tune_unipro_params(hba);
|
||||
|
||||
ret = ufshcd_set_vccq_rail_unused(hba,
|
||||
|
Loading…
Reference in New Issue
Block a user