Re: [PATCH v3 5/8] scsi: ufs: creates wrapper functions for vops

2015-08-25 Thread ygardi
Reviewed-by: Akinobu Mita 


> In order to simplify the code a set of wrapper functions is created
> to test and call each of the variant operations.
>
> Signed-off-by: Yaniv Gardi 
>
> ---
>  drivers/scsi/ufs/ufs-qcom.c |   1 -
>  drivers/scsi/ufs/ufshcd.c   | 104
> +---
>  drivers/scsi/ufs/ufshcd.h   |  98
> +
>  3 files changed, 137 insertions(+), 66 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 64c54b7..329ac84 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1049,6 +1049,5 @@ static const struct ufs_hba_variant_ops
> ufs_hba_qcom_vops = {
>   .suspend= ufs_qcom_suspend,
>   .resume = ufs_qcom_resume,
>  };
> -EXPORT_SYMBOL(ufs_hba_qcom_vops);
>
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index b0ade73..9e79c33 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -271,10 +271,8 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba
> *hba)
>   */
>  static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
>  {
> - if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION) {
> - if (hba->vops && hba->vops->get_ufs_hci_version)
> - return hba->vops->get_ufs_hci_version(hba);
> - }
> + if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
> + return ufshcd_vops_get_ufs_hci_version(hba);
>
>   return ufshcd_readl(hba, REG_UFS_VERSION);
>  }
> @@ -2473,9 +2471,8 @@ static int ufshcd_change_power_mode(struct ufs_hba
> *hba,
>   dev_err(hba->dev,
>   "%s: power mode change failed %d\n", __func__, ret);
>   } else {
> - if (hba->vops && hba->vops->pwr_change_notify)
> - hba->vops->pwr_change_notify(hba,
> - POST_CHANGE, NULL, pwr_mode);
> + ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
> + pwr_mode);
>
>   memcpy(>pwr_info, pwr_mode,
>   sizeof(struct ufs_pa_layer_attr));
> @@ -2495,10 +2492,10 @@ static int ufshcd_config_pwr_mode(struct ufs_hba
> *hba,
>   struct ufs_pa_layer_attr final_params = { 0 };
>   int ret;
>
> - if (hba->vops && hba->vops->pwr_change_notify)
> - hba->vops->pwr_change_notify(hba,
> -  PRE_CHANGE, desired_pwr_mode, _params);
> - else
> + ret = ufshcd_vops_pwr_change_notify(hba, PRE_CHANGE,
> + desired_pwr_mode, _params);
> +
> + if (ret)
>   memcpy(_params, desired_pwr_mode, sizeof(final_params));
>
>   ret = ufshcd_change_power_mode(hba, _params);
> @@ -2647,8 +2644,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
>   /* UniPro link is disabled at this point */
>   ufshcd_set_link_off(hba);
>
> - if (hba->vops && hba->vops->hce_enable_notify)
> - hba->vops->hce_enable_notify(hba, PRE_CHANGE);
> + ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
>
>   /* start controller initialization sequence */
>   ufshcd_hba_start(hba);
> @@ -2681,8 +2677,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
>   /* enable UIC related interrupts */
>   ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
>
> - if (hba->vops && hba->vops->hce_enable_notify)
> - hba->vops->hce_enable_notify(hba, POST_CHANGE);
> + ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
>
>   return 0;
>  }
> @@ -2735,8 +2730,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
>   int retries = DME_LINKSTARTUP_RETRIES;
>
>   do {
> - if (hba->vops && hba->vops->link_startup_notify)
> - hba->vops->link_startup_notify(hba, PRE_CHANGE);
> + ufshcd_vops_link_startup_notify(hba, PRE_CHANGE);
>
>   ret = ufshcd_dme_link_startup(hba);
>
> @@ -2767,11 +2761,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
>   }
>
>   /* Include any host controller configuration via UIC commands */
> - if (hba->vops && hba->vops->link_startup_notify) {
> - ret = hba->vops->link_startup_notify(hba, POST_CHANGE);
> - if (ret)
> - goto out;
> - }
> + ret = ufshcd_vops_link_startup_notify(hba, POST_CHANGE);
> + if (ret)
> + goto out;
>
>   ret = ufshcd_make_hba_operational(hba);
>  out:
> @@ -4578,8 +4570,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba
> *hba, bool on,
>   }
>   }
>
> - if (hba->vops && hba->vops->setup_clocks)
> - ret = hba->vops->setup_clocks(hba, on);
> + ret = ufshcd_vops_setup_clocks(hba, on);
>  out:
>   if (ret) {
>   list_for_each_entry(clki, head, list) {
> @@ -4645,27 +4636,22 @@ static int 

Re: [PATCH v3 5/8] scsi: ufs: creates wrapper functions for vops

2015-08-25 Thread ygardi
Reviewed-by: Akinobu Mita akinobu.m...@gmail.com


 In order to simplify the code a set of wrapper functions is created
 to test and call each of the variant operations.

 Signed-off-by: Yaniv Gardi yga...@codeaurora.org

 ---
  drivers/scsi/ufs/ufs-qcom.c |   1 -
  drivers/scsi/ufs/ufshcd.c   | 104
 +---
  drivers/scsi/ufs/ufshcd.h   |  98
 +
  3 files changed, 137 insertions(+), 66 deletions(-)

 diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
 index 64c54b7..329ac84 100644
 --- a/drivers/scsi/ufs/ufs-qcom.c
 +++ b/drivers/scsi/ufs/ufs-qcom.c
 @@ -1049,6 +1049,5 @@ static const struct ufs_hba_variant_ops
 ufs_hba_qcom_vops = {
   .suspend= ufs_qcom_suspend,
   .resume = ufs_qcom_resume,
  };
 -EXPORT_SYMBOL(ufs_hba_qcom_vops);

  MODULE_LICENSE(GPL v2);
 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
 index b0ade73..9e79c33 100644
 --- a/drivers/scsi/ufs/ufshcd.c
 +++ b/drivers/scsi/ufs/ufshcd.c
 @@ -271,10 +271,8 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba
 *hba)
   */
  static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
  {
 - if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION) {
 - if (hba-vops  hba-vops-get_ufs_hci_version)
 - return hba-vops-get_ufs_hci_version(hba);
 - }
 + if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
 + return ufshcd_vops_get_ufs_hci_version(hba);

   return ufshcd_readl(hba, REG_UFS_VERSION);
  }
 @@ -2473,9 +2471,8 @@ static int ufshcd_change_power_mode(struct ufs_hba
 *hba,
   dev_err(hba-dev,
   %s: power mode change failed %d\n, __func__, ret);
   } else {
 - if (hba-vops  hba-vops-pwr_change_notify)
 - hba-vops-pwr_change_notify(hba,
 - POST_CHANGE, NULL, pwr_mode);
 + ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
 + pwr_mode);

   memcpy(hba-pwr_info, pwr_mode,
   sizeof(struct ufs_pa_layer_attr));
 @@ -2495,10 +2492,10 @@ static int ufshcd_config_pwr_mode(struct ufs_hba
 *hba,
   struct ufs_pa_layer_attr final_params = { 0 };
   int ret;

 - if (hba-vops  hba-vops-pwr_change_notify)
 - hba-vops-pwr_change_notify(hba,
 -  PRE_CHANGE, desired_pwr_mode, final_params);
 - else
 + ret = ufshcd_vops_pwr_change_notify(hba, PRE_CHANGE,
 + desired_pwr_mode, final_params);
 +
 + if (ret)
   memcpy(final_params, desired_pwr_mode, sizeof(final_params));

   ret = ufshcd_change_power_mode(hba, final_params);
 @@ -2647,8 +2644,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
   /* UniPro link is disabled at this point */
   ufshcd_set_link_off(hba);

 - if (hba-vops  hba-vops-hce_enable_notify)
 - hba-vops-hce_enable_notify(hba, PRE_CHANGE);
 + ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);

   /* start controller initialization sequence */
   ufshcd_hba_start(hba);
 @@ -2681,8 +2677,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
   /* enable UIC related interrupts */
   ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);

 - if (hba-vops  hba-vops-hce_enable_notify)
 - hba-vops-hce_enable_notify(hba, POST_CHANGE);
 + ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);

   return 0;
  }
 @@ -2735,8 +2730,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
   int retries = DME_LINKSTARTUP_RETRIES;

   do {
 - if (hba-vops  hba-vops-link_startup_notify)
 - hba-vops-link_startup_notify(hba, PRE_CHANGE);
 + ufshcd_vops_link_startup_notify(hba, PRE_CHANGE);

   ret = ufshcd_dme_link_startup(hba);

 @@ -2767,11 +2761,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
   }

   /* Include any host controller configuration via UIC commands */
 - if (hba-vops  hba-vops-link_startup_notify) {
 - ret = hba-vops-link_startup_notify(hba, POST_CHANGE);
 - if (ret)
 - goto out;
 - }
 + ret = ufshcd_vops_link_startup_notify(hba, POST_CHANGE);
 + if (ret)
 + goto out;

   ret = ufshcd_make_hba_operational(hba);
  out:
 @@ -4578,8 +4570,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba
 *hba, bool on,
   }
   }

 - if (hba-vops  hba-vops-setup_clocks)
 - ret = hba-vops-setup_clocks(hba, on);
 + ret = ufshcd_vops_setup_clocks(hba, on);
  out:
   if (ret) {
   list_for_each_entry(clki, head, list) {
 @@ -4645,27 +4636,22 @@ static int ufshcd_variant_hba_init(struct ufs_hba
 *hba)
   if (!hba-vops)
   goto out;

 - if (hba-vops-init) {
 - 

[PATCH v3 5/8] scsi: ufs: creates wrapper functions for vops

2015-08-23 Thread Yaniv Gardi
In order to simplify the code a set of wrapper functions is created
to test and call each of the variant operations.

Signed-off-by: Yaniv Gardi 

---
 drivers/scsi/ufs/ufs-qcom.c |   1 -
 drivers/scsi/ufs/ufshcd.c   | 104 +---
 drivers/scsi/ufs/ufshcd.h   |  98 +
 3 files changed, 137 insertions(+), 66 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 64c54b7..329ac84 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1049,6 +1049,5 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops 
= {
.suspend= ufs_qcom_suspend,
.resume = ufs_qcom_resume,
 };
-EXPORT_SYMBOL(ufs_hba_qcom_vops);
 
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b0ade73..9e79c33 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -271,10 +271,8 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
  */
 static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
 {
-   if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION) {
-   if (hba->vops && hba->vops->get_ufs_hci_version)
-   return hba->vops->get_ufs_hci_version(hba);
-   }
+   if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
+   return ufshcd_vops_get_ufs_hci_version(hba);
 
return ufshcd_readl(hba, REG_UFS_VERSION);
 }
@@ -2473,9 +2471,8 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
dev_err(hba->dev,
"%s: power mode change failed %d\n", __func__, ret);
} else {
-   if (hba->vops && hba->vops->pwr_change_notify)
-   hba->vops->pwr_change_notify(hba,
-   POST_CHANGE, NULL, pwr_mode);
+   ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
+   pwr_mode);
 
memcpy(>pwr_info, pwr_mode,
sizeof(struct ufs_pa_layer_attr));
@@ -2495,10 +2492,10 @@ static int ufshcd_config_pwr_mode(struct ufs_hba *hba,
struct ufs_pa_layer_attr final_params = { 0 };
int ret;
 
-   if (hba->vops && hba->vops->pwr_change_notify)
-   hba->vops->pwr_change_notify(hba,
-PRE_CHANGE, desired_pwr_mode, _params);
-   else
+   ret = ufshcd_vops_pwr_change_notify(hba, PRE_CHANGE,
+   desired_pwr_mode, _params);
+
+   if (ret)
memcpy(_params, desired_pwr_mode, sizeof(final_params));
 
ret = ufshcd_change_power_mode(hba, _params);
@@ -2647,8 +2644,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* UniPro link is disabled at this point */
ufshcd_set_link_off(hba);
 
-   if (hba->vops && hba->vops->hce_enable_notify)
-   hba->vops->hce_enable_notify(hba, PRE_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
 
/* start controller initialization sequence */
ufshcd_hba_start(hba);
@@ -2681,8 +2677,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* enable UIC related interrupts */
ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
 
-   if (hba->vops && hba->vops->hce_enable_notify)
-   hba->vops->hce_enable_notify(hba, POST_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
 
return 0;
 }
@@ -2735,8 +2730,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
int retries = DME_LINKSTARTUP_RETRIES;
 
do {
-   if (hba->vops && hba->vops->link_startup_notify)
-   hba->vops->link_startup_notify(hba, PRE_CHANGE);
+   ufshcd_vops_link_startup_notify(hba, PRE_CHANGE);
 
ret = ufshcd_dme_link_startup(hba);
 
@@ -2767,11 +2761,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
}
 
/* Include any host controller configuration via UIC commands */
-   if (hba->vops && hba->vops->link_startup_notify) {
-   ret = hba->vops->link_startup_notify(hba, POST_CHANGE);
-   if (ret)
-   goto out;
-   }
+   ret = ufshcd_vops_link_startup_notify(hba, POST_CHANGE);
+   if (ret)
+   goto out;
 
ret = ufshcd_make_hba_operational(hba);
 out:
@@ -4578,8 +4570,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
}
}
 
-   if (hba->vops && hba->vops->setup_clocks)
-   ret = hba->vops->setup_clocks(hba, on);
+   ret = ufshcd_vops_setup_clocks(hba, on);
 out:
if (ret) {
list_for_each_entry(clki, head, list) {
@@ -4645,27 +4636,22 @@ static int ufshcd_variant_hba_init(struct ufs_hba *hba)
if (!hba->vops)
goto out;
 
-   if (hba->vops->init) {

[PATCH v3 5/8] scsi: ufs: creates wrapper functions for vops

2015-08-23 Thread Yaniv Gardi
In order to simplify the code a set of wrapper functions is created
to test and call each of the variant operations.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c |   1 -
 drivers/scsi/ufs/ufshcd.c   | 104 +---
 drivers/scsi/ufs/ufshcd.h   |  98 +
 3 files changed, 137 insertions(+), 66 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 64c54b7..329ac84 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1049,6 +1049,5 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops 
= {
.suspend= ufs_qcom_suspend,
.resume = ufs_qcom_resume,
 };
-EXPORT_SYMBOL(ufs_hba_qcom_vops);
 
 MODULE_LICENSE(GPL v2);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b0ade73..9e79c33 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -271,10 +271,8 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
  */
 static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
 {
-   if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION) {
-   if (hba-vops  hba-vops-get_ufs_hci_version)
-   return hba-vops-get_ufs_hci_version(hba);
-   }
+   if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
+   return ufshcd_vops_get_ufs_hci_version(hba);
 
return ufshcd_readl(hba, REG_UFS_VERSION);
 }
@@ -2473,9 +2471,8 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
dev_err(hba-dev,
%s: power mode change failed %d\n, __func__, ret);
} else {
-   if (hba-vops  hba-vops-pwr_change_notify)
-   hba-vops-pwr_change_notify(hba,
-   POST_CHANGE, NULL, pwr_mode);
+   ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
+   pwr_mode);
 
memcpy(hba-pwr_info, pwr_mode,
sizeof(struct ufs_pa_layer_attr));
@@ -2495,10 +2492,10 @@ static int ufshcd_config_pwr_mode(struct ufs_hba *hba,
struct ufs_pa_layer_attr final_params = { 0 };
int ret;
 
-   if (hba-vops  hba-vops-pwr_change_notify)
-   hba-vops-pwr_change_notify(hba,
-PRE_CHANGE, desired_pwr_mode, final_params);
-   else
+   ret = ufshcd_vops_pwr_change_notify(hba, PRE_CHANGE,
+   desired_pwr_mode, final_params);
+
+   if (ret)
memcpy(final_params, desired_pwr_mode, sizeof(final_params));
 
ret = ufshcd_change_power_mode(hba, final_params);
@@ -2647,8 +2644,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* UniPro link is disabled at this point */
ufshcd_set_link_off(hba);
 
-   if (hba-vops  hba-vops-hce_enable_notify)
-   hba-vops-hce_enable_notify(hba, PRE_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
 
/* start controller initialization sequence */
ufshcd_hba_start(hba);
@@ -2681,8 +2677,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* enable UIC related interrupts */
ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
 
-   if (hba-vops  hba-vops-hce_enable_notify)
-   hba-vops-hce_enable_notify(hba, POST_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
 
return 0;
 }
@@ -2735,8 +2730,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
int retries = DME_LINKSTARTUP_RETRIES;
 
do {
-   if (hba-vops  hba-vops-link_startup_notify)
-   hba-vops-link_startup_notify(hba, PRE_CHANGE);
+   ufshcd_vops_link_startup_notify(hba, PRE_CHANGE);
 
ret = ufshcd_dme_link_startup(hba);
 
@@ -2767,11 +2761,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
}
 
/* Include any host controller configuration via UIC commands */
-   if (hba-vops  hba-vops-link_startup_notify) {
-   ret = hba-vops-link_startup_notify(hba, POST_CHANGE);
-   if (ret)
-   goto out;
-   }
+   ret = ufshcd_vops_link_startup_notify(hba, POST_CHANGE);
+   if (ret)
+   goto out;
 
ret = ufshcd_make_hba_operational(hba);
 out:
@@ -4578,8 +4570,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
}
}
 
-   if (hba-vops  hba-vops-setup_clocks)
-   ret = hba-vops-setup_clocks(hba, on);
+   ret = ufshcd_vops_setup_clocks(hba, on);
 out:
if (ret) {
list_for_each_entry(clki, head, list) {
@@ -4645,27 +4636,22 @@ static int ufshcd_variant_hba_init(struct ufs_hba *hba)
if (!hba-vops)
goto out;
 
-   if (hba-vops-init) {
-   err =