[U-Boot] [PATCH v2 4/6] clk: change the type of return value to long

Masahiro Yamada yamada.masahiro at socionext.com
Wed Jan 13 05:16:11 CET 2016


The comments in include/clk.h state "or -ve error code" for these
functions, and actually the functions return negative error code
here and there.  Returning unsigned value is not suitable.

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

Changes in v2: None

 drivers/clk/clk-uclass.c  |  8 ++++----
 drivers/clk/clk_rk3036.c  |  6 +++---
 drivers/clk/clk_rk3288.c  |  6 +++---
 drivers/clk/clk_sandbox.c |  9 ++++-----
 include/clk.h             | 16 ++++++++--------
 5 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 73dfd7d..a5bef59 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -12,7 +12,7 @@
 #include <dm/lists.h>
 #include <dm/root.h>
 
-ulong clk_get_rate(struct udevice *dev)
+long clk_get_rate(struct udevice *dev)
 {
 	struct clk_ops *ops = clk_get_ops(dev);
 
@@ -22,7 +22,7 @@ ulong clk_get_rate(struct udevice *dev)
 	return ops->get_rate(dev);
 }
 
-ulong clk_set_rate(struct udevice *dev, ulong rate)
+long clk_set_rate(struct udevice *dev, ulong rate)
 {
 	struct clk_ops *ops = clk_get_ops(dev);
 
@@ -32,7 +32,7 @@ ulong clk_set_rate(struct udevice *dev, ulong rate)
 	return ops->set_rate(dev, rate);
 }
 
-ulong clk_get_periph_rate(struct udevice *dev, int periph)
+long clk_get_periph_rate(struct udevice *dev, int periph)
 {
 	struct clk_ops *ops = clk_get_ops(dev);
 
@@ -42,7 +42,7 @@ ulong clk_get_periph_rate(struct udevice *dev, int periph)
 	return ops->get_periph_rate(dev, periph);
 }
 
-ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
+long clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
 {
 	struct clk_ops *ops = clk_get_ops(dev);
 
diff --git a/drivers/clk/clk_rk3036.c b/drivers/clk/clk_rk3036.c
index f650810..8613123 100644
--- a/drivers/clk/clk_rk3036.c
+++ b/drivers/clk/clk_rk3036.c
@@ -298,7 +298,7 @@ static ulong rockchip_mmc_set_clk(struct rk3036_cru *cru, uint clk_general_rate,
 	return rockchip_mmc_get_clk(cru, clk_general_rate, periph);
 }
 
-static ulong rk3036_clk_get_rate(struct udevice *dev)
+static long rk3036_clk_get_rate(struct udevice *dev)
 {
 	struct rk3036_clk_plat *plat = dev_get_platdata(dev);
 	struct rk3036_clk_priv *priv = dev_get_priv(dev);
@@ -307,14 +307,14 @@ static ulong rk3036_clk_get_rate(struct udevice *dev)
 	return rkclk_pll_get_rate(priv->cru, plat->clk_id);
 }
 
-static ulong rk3036_clk_set_rate(struct udevice *dev, ulong rate)
+static long rk3036_clk_set_rate(struct udevice *dev, ulong rate)
 {
 	debug("%s\n", dev->name);
 
 	return 0;
 }
 
-static ulong rk3036_set_periph_rate(struct udevice *dev, int periph, ulong rate)
+static long rk3036_set_periph_rate(struct udevice *dev, int periph, ulong rate)
 {
 	struct rk3036_clk_priv *priv = dev_get_priv(dev);
 	ulong new_rate;
diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c
index 0172ad1..8ed0bff 100644
--- a/drivers/clk/clk_rk3288.c
+++ b/drivers/clk/clk_rk3288.c
@@ -337,7 +337,7 @@ static uint32_t rkclk_pll_get_rate(struct rk3288_cru *cru,
 	}
 }
 
-static ulong rk3288_clk_get_rate(struct udevice *dev)
+static long rk3288_clk_get_rate(struct udevice *dev)
 {
 	struct rk3288_clk_plat *plat = dev_get_platdata(dev);
 	struct rk3288_clk_priv *priv = dev_get_priv(dev);
@@ -346,7 +346,7 @@ static ulong rk3288_clk_get_rate(struct udevice *dev)
 	return rkclk_pll_get_rate(priv->cru, plat->clk_id);
 }
 
-static ulong rk3288_clk_set_rate(struct udevice *dev, ulong rate)
+static long rk3288_clk_set_rate(struct udevice *dev, ulong rate)
 {
 	struct rk3288_clk_plat *plat = dev_get_platdata(dev);
 	struct rk3288_clk_priv *priv = dev_get_priv(dev);
@@ -508,7 +508,7 @@ static ulong rockchip_spi_set_clk(struct rk3288_cru *cru, uint clk_general_rate,
 	return rockchip_spi_get_clk(cru, clk_general_rate, periph);
 }
 
-static ulong rk3288_set_periph_rate(struct udevice *dev, int periph, ulong rate)
+static long rk3288_set_periph_rate(struct udevice *dev, int periph, ulong rate)
 {
 	struct rk3288_clk_priv *priv = dev_get_priv(dev);
 	ulong new_rate;
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index 367130f..0ff4605 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -15,14 +15,14 @@ struct sandbox_clk_priv {
 	ulong periph_rate[PERIPH_ID_COUNT];
 };
 
-static ulong sandbox_clk_get_rate(struct udevice *dev)
+static long sandbox_clk_get_rate(struct udevice *dev)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(dev);
 
 	return priv->rate;
 }
 
-static ulong sandbox_clk_set_rate(struct udevice *dev, ulong rate)
+static long sandbox_clk_set_rate(struct udevice *dev, ulong rate)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(dev);
 
@@ -32,7 +32,7 @@ static ulong sandbox_clk_set_rate(struct udevice *dev, ulong rate)
 	return 0;
 }
 
-static ulong sandbox_get_periph_rate(struct udevice *dev, int periph)
+static long sandbox_get_periph_rate(struct udevice *dev, int periph)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(dev);
 
@@ -41,8 +41,7 @@ static ulong sandbox_get_periph_rate(struct udevice *dev, int periph)
 	return priv->periph_rate[periph];
 }
 
-static ulong sandbox_set_periph_rate(struct udevice *dev, int periph,
-				     ulong rate)
+static long sandbox_set_periph_rate(struct udevice *dev, int periph, ulong rate)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(dev);
 	ulong old_rate;
diff --git a/include/clk.h b/include/clk.h
index 371784a..61bb468 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -21,7 +21,7 @@ struct clk_ops {
 	 * @dev:	Device to check (UCLASS_CLK)
 	 * @return clock rate in Hz, or -ve error code
 	 */
-	ulong (*get_rate)(struct udevice *dev);
+	long (*get_rate)(struct udevice *dev);
 
 	/**
 	 * set_rate() - Set current clock rate
@@ -30,7 +30,7 @@ struct clk_ops {
 	 * @rate:	New clock rate in Hz
 	 * @return new rate, or -ve error code
 	 */
-	ulong (*set_rate)(struct udevice *dev, ulong rate);
+	long (*set_rate)(struct udevice *dev, ulong rate);
 
 	/**
 	 * get_periph_rate() - Get clock rate for a peripheral
@@ -39,7 +39,7 @@ struct clk_ops {
 	 * @periph:	Peripheral ID to check
 	 * @return clock rate in Hz, or -ve error code
 	 */
-	ulong (*get_periph_rate)(struct udevice *dev, int periph);
+	long (*get_periph_rate)(struct udevice *dev, int periph);
 
 	/**
 	 * set_periph_rate() - Set current clock rate for a peripheral
@@ -48,7 +48,7 @@ struct clk_ops {
 	 * @periph:	Peripheral ID to update
 	 * @return new clock rate in Hz, or -ve error code
 	 */
-	ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
+	long (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
 };
 
 #define clk_get_ops(dev)	((struct clk_ops *)(dev)->driver->ops)
@@ -59,7 +59,7 @@ struct clk_ops {
  * @dev:	Device to check (UCLASS_CLK)
  * @return clock rate in Hz, or -ve error code
  */
-ulong clk_get_rate(struct udevice *dev);
+long clk_get_rate(struct udevice *dev);
 
 /**
  * clk_set_rate() - Set current clock rate
@@ -68,7 +68,7 @@ ulong clk_get_rate(struct udevice *dev);
  * @rate:	New clock rate in Hz
  * @return new rate, or -ve error code
  */
-ulong clk_set_rate(struct udevice *dev, ulong rate);
+long clk_set_rate(struct udevice *dev, ulong rate);
 
 /**
  * clk_get_periph_rate() - Get current clock rate for a peripheral
@@ -76,7 +76,7 @@ ulong clk_set_rate(struct udevice *dev, ulong rate);
  * @dev:	Device to check (UCLASS_CLK)
  * @return clock rate in Hz, -ve error code
  */
-ulong clk_get_periph_rate(struct udevice *dev, int periph);
+long clk_get_periph_rate(struct udevice *dev, int periph);
 
 /**
  * clk_set_periph_rate() - Set current clock rate for a peripheral
@@ -85,6 +85,6 @@ ulong clk_get_periph_rate(struct udevice *dev, int periph);
  * @periph:	Peripheral ID to update
  * @return new clock rate in Hz, or -ve error code
  */
-ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
+long clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
 
 #endif /* _CLK_H_ */
-- 
1.9.1



More information about the U-Boot mailing list