cpu: Convert the methods to use a const udevice *

These functions should not modify the device. Convert them to const so
that callers don't need to cast if they have a const udevice *.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/cpu/bmips_cpu.c b/drivers/cpu/bmips_cpu.c
index 2649c5c..421cc7a 100644
--- a/drivers/cpu/bmips_cpu.c
+++ b/drivers/cpu/bmips_cpu.c
@@ -379,7 +379,7 @@
 };
 
 /* Generic CPU Ops */
-static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size)
+static int bmips_cpu_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	struct bmips_cpu_priv *priv = dev_get_priv(dev);
 	const struct bmips_cpu_hw *hw = priv->hw;
@@ -387,7 +387,7 @@
 	return hw->get_cpu_desc(priv, buf, size);
 }
 
-static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info)
+static int bmips_cpu_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	struct bmips_cpu_priv *priv = dev_get_priv(dev);
 	const struct bmips_cpu_hw *hw = priv->hw;
@@ -400,7 +400,7 @@
 	return 0;
 }
 
-static int bmips_cpu_get_count(struct udevice *dev)
+static int bmips_cpu_get_count(const struct udevice *dev)
 {
 	struct bmips_cpu_priv *priv = dev_get_priv(dev);
 	const struct bmips_cpu_hw *hw = priv->hw;
@@ -408,7 +408,7 @@
 	return hw->get_cpu_count(priv);
 }
 
-static int bmips_cpu_get_vendor(struct udevice *dev, char *buf, int size)
+static int bmips_cpu_get_vendor(const struct udevice *dev, char *buf, int size)
 {
 	snprintf(buf, size, "Broadcom");
 
diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index cbb4419..37e3cf2 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -69,7 +69,7 @@
 	return cpu;
 }
 
-int cpu_get_desc(struct udevice *dev, char *buf, int size)
+int cpu_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	struct cpu_ops *ops = cpu_get_ops(dev);
 
@@ -79,7 +79,7 @@
 	return ops->get_desc(dev, buf, size);
 }
 
-int cpu_get_info(struct udevice *dev, struct cpu_info *info)
+int cpu_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	struct cpu_ops *ops = cpu_get_ops(dev);
 
@@ -92,7 +92,7 @@
 	return ops->get_info(dev, info);
 }
 
-int cpu_get_count(struct udevice *dev)
+int cpu_get_count(const struct udevice *dev)
 {
 	struct cpu_ops *ops = cpu_get_ops(dev);
 
@@ -102,7 +102,7 @@
 	return ops->get_count(dev);
 }
 
-int cpu_get_vendor(struct udevice *dev, char *buf, int size)
+int cpu_get_vendor(const struct udevice *dev, char *buf, int size)
 {
 	struct cpu_ops *ops = cpu_get_ops(dev);
 
diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c
index 30a12e5..caa26e5 100644
--- a/drivers/cpu/cpu_sandbox.c
+++ b/drivers/cpu/cpu_sandbox.c
@@ -8,14 +8,14 @@
 #include <dm.h>
 #include <cpu.h>
 
-int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size)
+int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
 
 	return 0;
 }
 
-int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info)
+int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	info->cpu_freq = 42 * 42 * 42 * 42 * 42;
 	info->features = 0x42424242;
@@ -24,12 +24,12 @@
 	return 0;
 }
 
-int cpu_sandbox_get_count(struct udevice *dev)
+int cpu_sandbox_get_count(const struct udevice *dev)
 {
 	return 42;
 }
 
-int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size)
+int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size)
 {
 	snprintf(buf, size, "Languid Example Garbage Inc.");
 
diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index 6345cd0..502c8eb 100644
--- a/drivers/cpu/imx8_cpu.c
+++ b/drivers/cpu/imx8_cpu.c
@@ -100,7 +100,7 @@
 }
 #endif
 
-int cpu_imx_get_desc(struct udevice *dev, char *buf, int size)
+int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	struct cpu_imx_platdata *plat = dev_get_platdata(dev);
 	int ret, temp;
@@ -126,7 +126,7 @@
 	return 0;
 }
 
-static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info)
+static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	struct cpu_imx_platdata *plat = dev_get_platdata(dev);
 
@@ -135,7 +135,7 @@
 	return 0;
 }
 
-static int cpu_imx_get_count(struct udevice *dev)
+static int cpu_imx_get_count(const struct udevice *dev)
 {
 	ofnode node;
 	int num = 0;
@@ -157,7 +157,7 @@
 	return num;
 }
 
-static int cpu_imx_get_vendor(struct udevice *dev,  char *buf, int size)
+static int cpu_imx_get_vendor(const struct udevice *dev,  char *buf, int size)
 {
 	snprintf(buf, size, "NXP");
 	return 0;
diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c
index f8a84ba..5f1592f 100644
--- a/drivers/cpu/mpc83xx_cpu.c
+++ b/drivers/cpu/mpc83xx_cpu.c
@@ -60,7 +60,7 @@
  * determine_type() - Determine CPU family of MPC83xx device
  * @dev: CPU device from which to read CPU family from
  */
-static inline void determine_family(struct udevice *dev)
+static inline void determine_family(const struct udevice *dev)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	/* Upper 12 bits of PARTID field (bits 0-23 in SPRIDR) */
@@ -95,7 +95,7 @@
  * determine_type() - Determine CPU type of MPC83xx device
  * @dev: CPU device from which to read CPU type from
  */
-static inline void determine_type(struct udevice *dev)
+static inline void determine_type(const struct udevice *dev)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	/* Upper 16 bits of PVR (Processor Version Register) */
@@ -169,7 +169,7 @@
  * determine_e300_type() - Determine e300 core type of MPC83xx device
  * @dev: CPU device from which to read e300 core type from
  */
-static inline void determine_e300_type(struct udevice *dev)
+static inline void determine_e300_type(const struct udevice *dev)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	/* Upper 16 bits of PVR (Processor Version Register) */
@@ -198,7 +198,7 @@
  * determine_revid() - Determine revision ID of CPU device
  * @dev: CPU device from which to read revision ID
  */
-static inline void determine_revid(struct udevice *dev)
+static inline void determine_revid(const struct udevice *dev)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	u32 REVID_MAJOR_MASK;
@@ -221,7 +221,7 @@
  * determine_cpu_data() - Determine CPU information from hardware
  * @dev: CPU device from which to read information
  */
-static void determine_cpu_data(struct udevice *dev)
+static void determine_cpu_data(const struct udevice *dev)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	const u32 E_FLAG_MASK = 0x00010000;
@@ -239,7 +239,7 @@
 	priv->is_e_processor = !bitfield_extract_by_mask(spridr, E_FLAG_MASK);
 }
 
-static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size)
+static int mpc83xx_cpu_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
 	struct clk core_clk;
@@ -248,14 +248,14 @@
 	char csb_freq[32];
 	int ret;
 
-	ret = clk_get_by_index(dev, 0, &core_clk);
+	ret = clk_get_by_index((struct udevice *)dev, 0, &core_clk);
 	if (ret) {
 		debug("%s: Failed to get core clock (err = %d)\n",
 		      dev->name, ret);
 		return ret;
 	}
 
-	ret = clk_get_by_index(dev, 1, &csb_clk);
+	ret = clk_get_by_index((struct udevice *)dev, 1, &csb_clk);
 	if (ret) {
 		debug("%s: Failed to get CSB clock (err = %d)\n",
 		      dev->name, ret);
@@ -278,13 +278,14 @@
 	return 0;
 }
 
-static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info)
+static int mpc83xx_cpu_get_info(const struct udevice *dev,
+				struct cpu_info *info)
 {
 	struct clk clock;
 	int ret;
 	ulong freq;
 
-	ret = clk_get_by_index(dev, 0, &clock);
+	ret = clk_get_by_index((struct udevice *)dev, 0, &clock);
 	if (ret) {
 		debug("%s: Failed to get core clock (err = %d)\n",
 		      dev->name, ret);
@@ -303,13 +304,14 @@
 	return 0;
 }
 
-static int mpc83xx_cpu_get_count(struct udevice *dev)
+static int mpc83xx_cpu_get_count(const struct udevice *dev)
 {
 	/* We have one e300cX core */
 	return 1;
 }
 
-static int mpc83xx_cpu_get_vendor(struct udevice *dev, char *buf, int size)
+static int mpc83xx_cpu_get_vendor(const struct udevice *dev, char *buf,
+				  int size)
 {
 	snprintf(buf, size, "NXP");
 
diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c
index 100fe55..93ce708 100644
--- a/drivers/cpu/riscv_cpu.c
+++ b/drivers/cpu/riscv_cpu.c
@@ -17,7 +17,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)
+static int riscv_cpu_get_desc(const struct udevice *dev, char *buf, int size)
 {
 	const char *isa;
 
@@ -30,7 +30,7 @@
 	return 0;
 }
 
-static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)
+static int riscv_cpu_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	int ret;
 	struct clk clk;
@@ -39,7 +39,7 @@
 	u32 d_cache_size;
 
 	/* First try getting the frequency from the assigned clock */
-	ret = clk_get_by_index(dev, 0, &clk);
+	ret = clk_get_by_index((struct udevice *)dev, 0, &clk);
 	if (!ret) {
 		ret = clk_get_rate(&clk);
 		if (!IS_ERR_VALUE(ret))
@@ -67,7 +67,7 @@
 	return 0;
 }
 
-static int riscv_cpu_get_count(struct udevice *dev)
+static int riscv_cpu_get_count(const struct udevice *dev)
 {
 	ofnode node;
 	int num = 0;