[U-Boot] gpio: zynq: Read of mach data in platdata with dev_get_driver_data

Message ID b959c2259e6a522e1d3bb938af07be65465da96e.1531396140.git.michal.simek@xilinx.com
State Accepted
Commit 0df9bea4340ae64ec82004852ab325e869c371b8
Delegated to: Michal Simek
Headers show
Series
  • [U-Boot] gpio: zynq: Read of mach data in platdata with dev_get_driver_data
Related show

Commit Message

Michal Simek July 12, 2018, 11:49 a.m.
Remove bogus zynq_gpio_getplat_data() and read driver data directly.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Driver should use platdata structure but this change should be fine
before this is fixed.
Simon: Is ofdata_to_platdata correct function where this should be read?

---
 drivers/gpio/zynq_gpio.c | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

Comments

Simon Glass July 15, 2018, 9:22 p.m. | #1
On 12 July 2018 at 05:49, Michal Simek <michal.simek@xilinx.com> wrote:
> Remove bogus zynq_gpio_getplat_data() and read driver data directly.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Driver should use platdata structure but this change should be fine
> before this is fixed.
> Simon: Is ofdata_to_platdata correct function where this should be read?

Yes.

>
> ---
>  drivers/gpio/zynq_gpio.c | 29 ++---------------------------
>  1 file changed, 2 insertions(+), 27 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Patch

diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c
index 9a915544784d..26f69b1a713f 100644
--- a/drivers/gpio/zynq_gpio.c
+++ b/drivers/gpio/zynq_gpio.c
@@ -15,8 +15,6 @@ 
 #include <dm.h>
 #include <fdtdec.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /* Maximum banks */
 #define ZYNQ_GPIO_MAX_BANK	4
 
@@ -334,36 +332,11 @@  static const struct udevice_id zynq_gpio_ids[] = {
 	{ }
 };
 
-static void zynq_gpio_getplat_data(struct udevice *dev)
-{
-	const struct udevice_id *of_match = zynq_gpio_ids;
-	int ret;
-	struct zynq_gpio_privdata *priv = dev_get_priv(dev);
-
-	while (of_match->compatible) {
-		ret = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-						    of_match->compatible);
-		if (ret >= 0) {
-			priv->p_data =
-				    (struct zynq_platform_data *)of_match->data;
-			break;
-		} else  {
-			of_match++;
-			continue;
-		}
-	}
-
-	if (!priv->p_data)
-		printf("No Platform data found\n");
-}
-
 static int zynq_gpio_probe(struct udevice *dev)
 {
 	struct zynq_gpio_privdata *priv = dev_get_priv(dev);
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-	zynq_gpio_getplat_data(dev);
-
 	if (priv->p_data)
 		uc_priv->gpio_count = priv->p_data->ngpio;
 
@@ -376,6 +349,8 @@  static int zynq_gpio_ofdata_to_platdata(struct udevice *dev)
 
 	priv->base = (phys_addr_t)dev_read_addr(dev);
 
+	priv->p_data = (struct zynq_platform_data *)dev_get_driver_data(dev);
+
 	return 0;
 }