Re: [PATCH v4 04/12] scsi: ufs: core: Add support for TX Equalization

From: Peter Wang (王信友)

Date: Tue Mar 24 2026 - 03:53:55 EST


On Fri, 2026-03-20 at 20:10 -0700, Can Guo wrote:
> +static int ufshcd_tx_eqtr(struct ufs_hba *hba,
> +                         struct ufshcd_tx_eq_params *params,
> +                         struct ufs_pa_layer_attr *pwr_mode)
> +{
> +       struct ufs_pa_layer_attr old_pwr_info;
> +       u32 gear = pwr_mode->gear_tx;
> +       int ret;
> +
> +       if (gear < UFS_HS_G4 || gear > UFS_HS_G6) {
> +               dev_err(hba->dev, "TX EQTR is not implemented for HS-
> G%u\n",
> +                       gear);
> +               return -EINVAL;
> +       }
>

Hi Can,

This check can be removed since ufshcd_config_tx_eq_settings
has already checked it.


> +       params = &hba->tx_eq_params[gear - 1];
> +
> +       if (gear < UFS_HS_G1 || gear > UFS_HS_GEAR_MAX) {
> +               dev_err(hba->dev, "Invalid HS-Gear (%u) for TX
> Equalization\n",
> +                       gear);
> +               return -EINVAL;
> +       } else if (gear < adaptive_txeq_gear) {
> +               return 0;
> +       }
>

"gear" should be checked before use?

> +       /* TX EQTR is supported for HS-G4 and higher Gears */
> +       if (gear < UFS_HS_G4)
> +               goto apply_tx_eq_settings;
> +

Could we return 0 directly?
and move this to the previous check, like this:
} else if (gear < max_t(u32, adaptive_txeq_gear, UFS_HS_G4) {
return 0;
}

Thanks
Peter