[v6,066/102] spi: ich: Convert to livetree
diff mbox series

Message ID 20191206213936.v6.66.I10916bc38eb7b44e59e68879c9a97e5349247bdd@changeid
State Accepted
Delegated to: Bin Meng
Headers show
Series
  • x86: Add initial support for apollolake
Related show

Commit Message

Simon Glass Dec. 7, 2019, 4:42 a.m. UTC
Use dev_get_driver_data() to obtain the device type. It has the same
effect and is shorter.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

Comments

Bin Meng Dec. 8, 2019, 3:38 a.m. UTC | #1
On Sat, Dec 7, 2019 at 12:51 PM Simon Glass <sjg@chromium.org> wrote:
>
> Use dev_get_driver_data() to obtain the device type. It has the same
> effect and is shorter.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/spi/ich.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
>

applied to u-boot-x86/next, thanks!

Patch
diff mbox series

diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 4d61be02ec..6460144560 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -597,28 +597,16 @@  static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 {
 	struct ich_spi_platdata *plat = dev_get_platdata(dev);
 	struct ich_spi_priv *priv = dev_get_priv(dev);
-	int node = dev_of_offset(dev);
-	int ret;
 
 	/* Find a PCH if there is one */
 	uclass_first_device(UCLASS_PCH, &priv->pch);
 	if (!priv->pch)
 		priv->pch = dev_get_parent(dev);
 
-	ret = fdt_node_check_compatible(gd->fdt_blob, node, "intel,ich7-spi");
-	if (ret == 0) {
-		plat->ich_version = ICHV_7;
-	} else {
-		ret = fdt_node_check_compatible(gd->fdt_blob, node,
-						"intel,ich9-spi");
-		if (ret == 0)
-			plat->ich_version = ICHV_9;
-	}
+	plat->ich_version = dev_get_driver_data(dev);
+	plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
 
-	plat->lockdown = fdtdec_get_bool(gd->fdt_blob, node,
-					 "intel,spi-lock-down");
-
-	return ret;
+	return 0;
 }
 
 static const struct spi_controller_mem_ops ich_controller_mem_ops = {
@@ -639,8 +627,8 @@  static const struct dm_spi_ops ich_spi_ops = {
 };
 
 static const struct udevice_id ich_spi_ids[] = {
-	{ .compatible = "intel,ich7-spi" },
-	{ .compatible = "intel,ich9-spi" },
+	{ .compatible = "intel,ich7-spi", ICHV_7 },
+	{ .compatible = "intel,ich9-spi", ICHV_9 },
 	{ }
 };