static void ufshcd_print_host_state(struct ufs_hba *hba)
{
- struct scsi_device *sdev_ufs = hba->sdev_ufs_device;
+ struct scsi_device *sdev_ufs = hba->ufs_device_wlun;
dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",
spin_unlock_irqrestore(hba->host->host_lock, flags);
if (update &&
- !pm_runtime_suspended(&hba->sdev_ufs_device->sdev_gendev)) {
+ !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
ufshcd_rpm_get_sync(hba);
ufshcd_hold(hba, false);
ufshcd_auto_hibern8_enable(hba);
* Device wlun is the supplier & rest of the luns are consumers.
* This ensures that device wlun suspends after all other luns.
*/
- if (hba->sdev_ufs_device) {
+ if (hba->ufs_device_wlun) {
link = device_link_add(&sdev->sdev_gendev,
- &hba->sdev_ufs_device->sdev_gendev,
+ &hba->ufs_device_wlun->sdev_gendev,
DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
if (!link) {
dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n",
- dev_name(&hba->sdev_ufs_device->sdev_gendev));
+ dev_name(&hba->ufs_device_wlun->sdev_gendev));
return;
}
hba->luns_avail--;
/* Drop the reference as it won't be needed anymore */
if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {
spin_lock_irqsave(hba->host->host_lock, flags);
- hba->sdev_ufs_device = NULL;
+ hba->ufs_device_wlun = NULL;
spin_unlock_irqrestore(hba->host->host_lock, flags);
- } else if (hba->sdev_ufs_device) {
+ } else if (hba->ufs_device_wlun) {
struct device *supplier = NULL;
/* Ensure UFS Device WLUN exists and does not disappear */
spin_lock_irqsave(hba->host->host_lock, flags);
- if (hba->sdev_ufs_device) {
- supplier = &hba->sdev_ufs_device->sdev_gendev;
+ if (hba->ufs_device_wlun) {
+ supplier = &hba->ufs_device_wlun->sdev_gendev;
get_device(supplier);
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
{
ufshcd_rpm_get_sync(hba);
- if (pm_runtime_status_suspended(&hba->sdev_ufs_device->sdev_gendev) ||
+ if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) ||
hba->is_sys_suspended) {
enum ufs_pm_op pm_op;
static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba)
{
return (!hba->is_powered || hba->shutting_down ||
- !hba->sdev_ufs_device ||
+ !hba->ufs_device_wlun ||
hba->ufshcd_state == UFSHCD_STATE_ERROR ||
(!(hba->saved_err || hba->saved_uic_err || hba->force_reset ||
ufshcd_is_link_broken(hba))));
* Set RPM status of wlun device to RPM_ACTIVE,
* this also clears its runtime error.
*/
- ret = pm_runtime_set_active(&hba->sdev_ufs_device->sdev_gendev);
+ ret = pm_runtime_set_active(&hba->ufs_device_wlun->sdev_gendev);
/* hba device might have a runtime error otherwise */
if (ret)
int ret = 0;
struct scsi_device *sdev_boot, *sdev_rpmb;
- hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,
+ hba->ufs_device_wlun = __scsi_add_device(hba->host, 0, 0,
ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
- if (IS_ERR(hba->sdev_ufs_device)) {
- ret = PTR_ERR(hba->sdev_ufs_device);
- hba->sdev_ufs_device = NULL;
+ if (IS_ERR(hba->ufs_device_wlun)) {
+ ret = PTR_ERR(hba->ufs_device_wlun);
+ hba->ufs_device_wlun = NULL;
goto out;
}
- scsi_device_put(hba->sdev_ufs_device);
+ scsi_device_put(hba->ufs_device_wlun);
sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
if (IS_ERR(sdev_rpmb)) {
ret = PTR_ERR(sdev_rpmb);
- goto remove_sdev_ufs_device;
+ goto remove_ufs_device_wlun;
}
ufshcd_blk_pm_runtime_init(sdev_rpmb);
scsi_device_put(sdev_rpmb);
}
goto out;
-remove_sdev_ufs_device:
- scsi_remove_device(hba->sdev_ufs_device);
+remove_ufs_device_wlun:
+ scsi_remove_device(hba->ufs_device_wlun);
out:
return ret;
}
int ret, retries;
spin_lock_irqsave(hba->host->host_lock, flags);
- sdp = hba->sdev_ufs_device;
+ sdp = hba->ufs_device_wlun;
if (sdp) {
ret = scsi_device_get(sdp);
if (!ret && !scsi_device_online(sdp)) {
ufshcd_rpm_get_sync(hba);
scsi_device_quiesce(sdev);
shost_for_each_device(sdev, hba->host) {
- if (sdev == hba->sdev_ufs_device)
+ if (sdev == hba->ufs_device_wlun)
continue;
scsi_device_quiesce(sdev);
}
*/
void ufshcd_remove(struct ufs_hba *hba)
{
- if (hba->sdev_ufs_device)
+ if (hba->ufs_device_wlun)
ufshcd_rpm_get_sync(hba);
ufs_hwmon_remove(hba);
ufs_bsg_remove(hba);
static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)
{
- struct device *dev = &hba->sdev_ufs_device->sdev_gendev;
+ struct device *dev = &hba->ufs_device_wlun->sdev_gendev;
enum ufs_dev_pwr_mode dev_pwr_mode;
enum uic_link_state link_state;
unsigned long flags;
* if it's runtime suspended. But ufs doesn't follow that.
* Refer ufshcd_resume_complete()
*/
- if (hba->sdev_ufs_device) {
+ if (hba->ufs_device_wlun) {
/* Prevent runtime suspend */
ufshcd_rpm_get_noresume(hba);
/*
* @utmrdl_dma_addr: UTMRDL DMA address
* @host: Scsi_Host instance of the driver
* @dev: device handle
+ * @ufs_device_wlun: WLUN that controls the entire UFS device.
* @lrb: local reference block
* @outstanding_tasks: Bits representing outstanding task requests
* @outstanding_lock: Protects @outstanding_reqs.
struct Scsi_Host *host;
struct device *dev;
- /*
- * This field is to keep a reference to "scsi_device" corresponding to
- * "UFS device" W-LU.
- */
- struct scsi_device *sdev_ufs_device;
+ struct scsi_device *ufs_device_wlun;
#ifdef CONFIG_SCSI_UFS_HWMON
struct device *hwmon_device;
static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
{
- return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev);
+ return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
}
static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
{
- return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev);
+ return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
}
static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
{
- pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev);
+ pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
}
static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
{
- return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev);
+ return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
}
static inline int ufshcd_rpm_put(struct ufs_hba *hba)
{
- return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev);
+ return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
}
#endif /* End of Header */