diff mbox

phy: exynos-mipi-video: Simplify code by using regmap_update_bits()

Message ID 20180416161938.26958-1-s.nawrocki@samsung.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

There is no functional change, just replacing regmap_read()/modify/
regmap_write() with regmap_update_bits() function calls.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/phy/samsung/phy-exynos-mipi-video.c | 34 ++++++++++++-----------------
 1 file changed, 14 insertions(+), 20 deletions(-)

Comments

Kishon Vijay Abraham I April 23, 2018, 6:43 a.m. UTC | #1
On Monday 16 April 2018 09:49 PM, Sylwester Nawrocki wrote:
> There is no functional change, just replacing regmap_read()/modify/
> regmap_write() with regmap_update_bits() function calls.

merged, thanks!

-Kishon

> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  drivers/phy/samsung/phy-exynos-mipi-video.c | 34 ++++++++++++-----------------
>  1 file changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/phy/samsung/phy-exynos-mipi-video.c b/drivers/phy/samsung/phy-exynos-mipi-video.c
> index c198886f80a3..00d89599c67d 100644
> --- a/drivers/phy/samsung/phy-exynos-mipi-video.c
> +++ b/drivers/phy/samsung/phy-exynos-mipi-video.c
> @@ -231,33 +231,27 @@ struct exynos_mipi_video_phy {
>  static int __set_phy_state(const struct exynos_mipi_phy_desc *data,
>  			   struct exynos_mipi_video_phy *state, unsigned int on)
>  {
> -	u32 val;
> +	struct regmap *enable_map = state->regmaps[data->enable_map];
> +	struct regmap *resetn_map = state->regmaps[data->resetn_map];
>  
>  	spin_lock(&state->slock);
>  
>  	/* disable in PMU sysreg */
>  	if (!on && data->coupled_phy_id >= 0 &&
> -	    state->phys[data->coupled_phy_id].phy->power_count == 0) {
> -		regmap_read(state->regmaps[data->enable_map], data->enable_reg,
> -			    &val);
> -		val &= ~data->enable_val;
> -		regmap_write(state->regmaps[data->enable_map], data->enable_reg,
> -			     val);
> -	}
> -
> +	    state->phys[data->coupled_phy_id].phy->power_count == 0)
> +		regmap_update_bits(enable_map, data->enable_reg,
> +				   data->enable_val, 0);
>  	/* PHY reset */
> -	regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val);
> -	val = on ? (val | data->resetn_val) : (val & ~data->resetn_val);
> -	regmap_write(state->regmaps[data->resetn_map], data->resetn_reg, val);
> -
> +	if (on)
> +		regmap_update_bits(resetn_map, data->resetn_reg,
> +				   data->resetn_val, data->resetn_val);
> +	else
> +		regmap_update_bits(resetn_map, data->resetn_reg,
> +				   data->resetn_val, 0);
>  	/* enable in PMU sysreg */
> -	if (on) {
> -		regmap_read(state->regmaps[data->enable_map], data->enable_reg,
> -			    &val);
> -		val |= data->enable_val;
> -		regmap_write(state->regmaps[data->enable_map], data->enable_reg,
> -			     val);
> -	}
> +	if (on)
> +		regmap_update_bits(enable_map, data->enable_reg,
> +				   data->enable_val, data->enable_val);
>  
>  	spin_unlock(&state->slock);
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/phy/samsung/phy-exynos-mipi-video.c b/drivers/phy/samsung/phy-exynos-mipi-video.c
index c198886f80a3..00d89599c67d 100644
--- a/drivers/phy/samsung/phy-exynos-mipi-video.c
+++ b/drivers/phy/samsung/phy-exynos-mipi-video.c
@@ -231,33 +231,27 @@  struct exynos_mipi_video_phy {
 static int __set_phy_state(const struct exynos_mipi_phy_desc *data,
 			   struct exynos_mipi_video_phy *state, unsigned int on)
 {
-	u32 val;
+	struct regmap *enable_map = state->regmaps[data->enable_map];
+	struct regmap *resetn_map = state->regmaps[data->resetn_map];
 
 	spin_lock(&state->slock);
 
 	/* disable in PMU sysreg */
 	if (!on && data->coupled_phy_id >= 0 &&
-	    state->phys[data->coupled_phy_id].phy->power_count == 0) {
-		regmap_read(state->regmaps[data->enable_map], data->enable_reg,
-			    &val);
-		val &= ~data->enable_val;
-		regmap_write(state->regmaps[data->enable_map], data->enable_reg,
-			     val);
-	}
-
+	    state->phys[data->coupled_phy_id].phy->power_count == 0)
+		regmap_update_bits(enable_map, data->enable_reg,
+				   data->enable_val, 0);
 	/* PHY reset */
-	regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val);
-	val = on ? (val | data->resetn_val) : (val & ~data->resetn_val);
-	regmap_write(state->regmaps[data->resetn_map], data->resetn_reg, val);
-
+	if (on)
+		regmap_update_bits(resetn_map, data->resetn_reg,
+				   data->resetn_val, data->resetn_val);
+	else
+		regmap_update_bits(resetn_map, data->resetn_reg,
+				   data->resetn_val, 0);
 	/* enable in PMU sysreg */
-	if (on) {
-		regmap_read(state->regmaps[data->enable_map], data->enable_reg,
-			    &val);
-		val |= data->enable_val;
-		regmap_write(state->regmaps[data->enable_map], data->enable_reg,
-			     val);
-	}
+	if (on)
+		regmap_update_bits(enable_map, data->enable_reg,
+				   data->enable_val, data->enable_val);
 
 	spin_unlock(&state->slock);