Skip to content

Commit fa3dca8

Browse files
quic-cangmartinkpetersen
authored andcommitted
scsi: ufs: host: Rename structure ufs_dev_params to ufs_host_params
Structure ufs_dev_params is actually used in UFS host drivers to declare host specific power mode parameters, like ufs_<vendor>_params or host_cap, which makes the code not very straightforward to read. Rename the structure ufs_dev_params to ufs_host_params and unify the declarations in all drivers to host_params. In addition, rename the two functions ufshcd_init_pwr_dev_param() and ufshcd_get_pwr_dev_param() which work based on the ufs_host_params to ufshcd_init_host_params() and ufshcd_negotiate_pwr_params() respectively to avoid confusions. This change does not change any functionalities or logic. Acked-by: Andrew Halaney <[email protected]> Reviewed-by: Nitin Rawat <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Can Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Peter Wang <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on SM8550-QRD Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b85ea95 commit fa3dca8

File tree

6 files changed

+57
-64
lines changed

6 files changed

+57
-64
lines changed

drivers/ufs/host/ufs-exynos.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
765765
{
766766
struct exynos_ufs *ufs = ufshcd_get_variant(hba);
767767
struct phy *generic_phy = ufs->phy;
768-
struct ufs_dev_params ufs_exynos_cap;
768+
struct ufs_host_params host_params;
769769
int ret;
770770

771771
if (!dev_req_params) {
@@ -774,10 +774,9 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
774774
goto out;
775775
}
776776

777-
ufshcd_init_pwr_dev_param(&ufs_exynos_cap);
777+
ufshcd_init_host_params(&host_params);
778778

779-
ret = ufshcd_get_pwr_dev_param(&ufs_exynos_cap,
780-
dev_max_params, dev_req_params);
779+
ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
781780
if (ret) {
782781
pr_err("%s: failed to determine capabilities\n", __func__);
783782
goto out;

drivers/ufs/host/ufs-hisi.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ static int ufs_hisi_link_startup_notify(struct ufs_hba *hba,
293293
return err;
294294
}
295295

296-
static void ufs_hisi_set_dev_cap(struct ufs_dev_params *hisi_param)
296+
static void ufs_hisi_set_dev_cap(struct ufs_host_params *host_params)
297297
{
298-
ufshcd_init_pwr_dev_param(hisi_param);
298+
ufshcd_init_host_params(host_params);
299299
}
300300

301301
static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)
@@ -365,7 +365,7 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
365365
struct ufs_pa_layer_attr *dev_max_params,
366366
struct ufs_pa_layer_attr *dev_req_params)
367367
{
368-
struct ufs_dev_params ufs_hisi_cap;
368+
struct ufs_host_params host_params;
369369
int ret = 0;
370370

371371
if (!dev_req_params) {
@@ -377,9 +377,8 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
377377

378378
switch (status) {
379379
case PRE_CHANGE:
380-
ufs_hisi_set_dev_cap(&ufs_hisi_cap);
381-
ret = ufshcd_get_pwr_dev_param(&ufs_hisi_cap,
382-
dev_max_params, dev_req_params);
380+
ufs_hisi_set_dev_cap(&host_params);
381+
ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
383382
if (ret) {
384383
dev_err(hba->dev,
385384
"%s: failed to determine capabilities\n", __func__);

drivers/ufs/host/ufs-mediatek.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -996,16 +996,14 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
996996
struct ufs_pa_layer_attr *dev_req_params)
997997
{
998998
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
999-
struct ufs_dev_params host_cap;
999+
struct ufs_host_params host_params;
10001000
int ret;
10011001

1002-
ufshcd_init_pwr_dev_param(&host_cap);
1003-
host_cap.hs_rx_gear = UFS_HS_G5;
1004-
host_cap.hs_tx_gear = UFS_HS_G5;
1002+
ufshcd_init_host_params(&host_params);
1003+
host_params.hs_rx_gear = UFS_HS_G5;
1004+
host_params.hs_tx_gear = UFS_HS_G5;
10051005

1006-
ret = ufshcd_get_pwr_dev_param(&host_cap,
1007-
dev_max_params,
1008-
dev_req_params);
1006+
ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
10091007
if (ret) {
10101008
pr_info("%s: failed to determine capabilities\n",
10111009
__func__);

drivers/ufs/host/ufs-qcom.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
898898
struct ufs_pa_layer_attr *dev_req_params)
899899
{
900900
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
901-
struct ufs_dev_params ufs_qcom_cap;
901+
struct ufs_host_params host_params;
902902
int ret = 0;
903903

904904
if (!dev_req_params) {
@@ -908,15 +908,13 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
908908

909909
switch (status) {
910910
case PRE_CHANGE:
911-
ufshcd_init_pwr_dev_param(&ufs_qcom_cap);
912-
ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE;
911+
ufshcd_init_host_params(&host_params);
912+
host_params.hs_rate = UFS_QCOM_LIMIT_HS_RATE;
913913

914914
/* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */
915-
ufs_qcom_cap.hs_tx_gear = ufs_qcom_cap.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
915+
host_params.hs_tx_gear = host_params.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
916916

917-
ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap,
918-
dev_max_params,
919-
dev_req_params);
917+
ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params);
920918
if (ret) {
921919
dev_err(hba->dev, "%s: failed to determine capabilities\n",
922920
__func__);

drivers/ufs/host/ufshcd-pltfrm.c

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -285,61 +285,60 @@ static int ufshcd_parse_operating_points(struct ufs_hba *hba)
285285
}
286286

287287
/**
288-
* ufshcd_get_pwr_dev_param - get finally agreed attributes for
289-
* power mode change
290-
* @pltfrm_param: pointer to platform parameters
288+
* ufshcd_negotiate_pwr_params - find power mode settings that are supported by
289+
both the controller and the device
290+
* @host_params: pointer to host parameters
291291
* @dev_max: pointer to device attributes
292292
* @agreed_pwr: returned agreed attributes
293293
*
294294
* Return: 0 on success, non-zero value on failure.
295295
*/
296-
int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
297-
const struct ufs_pa_layer_attr *dev_max,
298-
struct ufs_pa_layer_attr *agreed_pwr)
296+
int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
297+
const struct ufs_pa_layer_attr *dev_max,
298+
struct ufs_pa_layer_attr *agreed_pwr)
299299
{
300-
int min_pltfrm_gear;
300+
int min_host_gear;
301301
int min_dev_gear;
302302
bool is_dev_sup_hs = false;
303-
bool is_pltfrm_max_hs = false;
303+
bool is_host_max_hs = false;
304304

305305
if (dev_max->pwr_rx == FAST_MODE)
306306
is_dev_sup_hs = true;
307307

308-
if (pltfrm_param->desired_working_mode == UFS_HS_MODE) {
309-
is_pltfrm_max_hs = true;
310-
min_pltfrm_gear = min_t(u32, pltfrm_param->hs_rx_gear,
311-
pltfrm_param->hs_tx_gear);
308+
if (host_params->desired_working_mode == UFS_HS_MODE) {
309+
is_host_max_hs = true;
310+
min_host_gear = min_t(u32, host_params->hs_rx_gear,
311+
host_params->hs_tx_gear);
312312
} else {
313-
min_pltfrm_gear = min_t(u32, pltfrm_param->pwm_rx_gear,
314-
pltfrm_param->pwm_tx_gear);
313+
min_host_gear = min_t(u32, host_params->pwm_rx_gear,
314+
host_params->pwm_tx_gear);
315315
}
316316

317317
/*
318-
* device doesn't support HS but
319-
* pltfrm_param->desired_working_mode is HS,
320-
* thus device and pltfrm_param don't agree
318+
* device doesn't support HS but host_params->desired_working_mode is HS,
319+
* thus device and host_params don't agree
321320
*/
322-
if (!is_dev_sup_hs && is_pltfrm_max_hs) {
321+
if (!is_dev_sup_hs && is_host_max_hs) {
323322
pr_info("%s: device doesn't support HS\n",
324323
__func__);
325324
return -ENOTSUPP;
326-
} else if (is_dev_sup_hs && is_pltfrm_max_hs) {
325+
} else if (is_dev_sup_hs && is_host_max_hs) {
327326
/*
328327
* since device supports HS, it supports FAST_MODE.
329-
* since pltfrm_param->desired_working_mode is also HS
328+
* since host_params->desired_working_mode is also HS
330329
* then final decision (FAST/FASTAUTO) is done according
331330
* to pltfrm_params as it is the restricting factor
332331
*/
333-
agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_hs;
332+
agreed_pwr->pwr_rx = host_params->rx_pwr_hs;
334333
agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
335334
} else {
336335
/*
337-
* here pltfrm_param->desired_working_mode is PWM.
336+
* here host_params->desired_working_mode is PWM.
338337
* it doesn't matter whether device supports HS or PWM,
339-
* in both cases pltfrm_param->desired_working_mode will
338+
* in both cases host_params->desired_working_mode will
340339
* determine the mode
341340
*/
342-
agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_pwm;
341+
agreed_pwr->pwr_rx = host_params->rx_pwr_pwm;
343342
agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
344343
}
345344

@@ -349,9 +348,9 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
349348
* the same decision will be made for rx
350349
*/
351350
agreed_pwr->lane_tx = min_t(u32, dev_max->lane_tx,
352-
pltfrm_param->tx_lanes);
351+
host_params->tx_lanes);
353352
agreed_pwr->lane_rx = min_t(u32, dev_max->lane_rx,
354-
pltfrm_param->rx_lanes);
353+
host_params->rx_lanes);
355354

356355
/* device maximum gear is the minimum between device rx and tx gears */
357356
min_dev_gear = min_t(u32, dev_max->gear_rx, dev_max->gear_tx);
@@ -364,26 +363,26 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
364363
* what is the gear, as it is the one that also decided previously what
365364
* pwr the device will be configured to.
366365
*/
367-
if ((is_dev_sup_hs && is_pltfrm_max_hs) ||
368-
(!is_dev_sup_hs && !is_pltfrm_max_hs)) {
366+
if ((is_dev_sup_hs && is_host_max_hs) ||
367+
(!is_dev_sup_hs && !is_host_max_hs)) {
369368
agreed_pwr->gear_rx =
370-
min_t(u32, min_dev_gear, min_pltfrm_gear);
369+
min_t(u32, min_dev_gear, min_host_gear);
371370
} else if (!is_dev_sup_hs) {
372371
agreed_pwr->gear_rx = min_dev_gear;
373372
} else {
374-
agreed_pwr->gear_rx = min_pltfrm_gear;
373+
agreed_pwr->gear_rx = min_host_gear;
375374
}
376375
agreed_pwr->gear_tx = agreed_pwr->gear_rx;
377376

378-
agreed_pwr->hs_rate = pltfrm_param->hs_rate;
377+
agreed_pwr->hs_rate = host_params->hs_rate;
379378

380379
return 0;
381380
}
382-
EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
381+
EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_params);
383382

384-
void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
383+
void ufshcd_init_host_params(struct ufs_host_params *host_params)
385384
{
386-
*dev_param = (struct ufs_dev_params){
385+
*host_params = (struct ufs_host_params){
387386
.tx_lanes = UFS_LANE_2,
388387
.rx_lanes = UFS_LANE_2,
389388
.hs_rx_gear = UFS_HS_G3,
@@ -398,7 +397,7 @@ void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
398397
.desired_working_mode = UFS_HS_MODE,
399398
};
400399
}
401-
EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
400+
EXPORT_SYMBOL_GPL(ufshcd_init_host_params);
402401

403402
/**
404403
* ufshcd_pltfrm_init - probe routine of the driver

drivers/ufs/host/ufshcd-pltfrm.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define UFS_PWM_MODE 1
1111
#define UFS_HS_MODE 2
1212

13-
struct ufs_dev_params {
13+
struct ufs_host_params {
1414
u32 pwm_rx_gear; /* pwm rx gear to work in */
1515
u32 pwm_tx_gear; /* pwm tx gear to work in */
1616
u32 hs_rx_gear; /* hs rx gear to work in */
@@ -25,10 +25,10 @@ struct ufs_dev_params {
2525
u32 desired_working_mode;
2626
};
2727

28-
int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *dev_param,
29-
const struct ufs_pa_layer_attr *dev_max,
30-
struct ufs_pa_layer_attr *agreed_pwr);
31-
void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param);
28+
int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
29+
const struct ufs_pa_layer_attr *dev_max,
30+
struct ufs_pa_layer_attr *agreed_pwr);
31+
void ufshcd_init_host_params(struct ufs_host_params *host_params);
3232
int ufshcd_pltfrm_init(struct platform_device *pdev,
3333
const struct ufs_hba_variant_ops *vops);
3434
int ufshcd_populate_vreg(struct device *dev, const char *name,

0 commit comments

Comments
 (0)