diff mbox series

[U-Boot,2/4] dm: gpio: Add a comment about not copying some drivers

Message ID 20170917225455.116717-2-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series [U-Boot,1/4] dm: gpio: vybrid_gpio: Correct driver's use of bind() method | expand

Commit Message

Simon Glass Sept. 17, 2017, 10:54 p.m. UTC
These three drivers all use U_BOOT_DEVICE rather than device tree to
create devices, so have to do manual allocation of platform data. This is
not true for new platforms.

Add a more explicit comment so that people do not copy this approach with
new boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
---

 drivers/gpio/imx_rgpio2p.c | 5 +++++
 drivers/gpio/mxc_gpio.c    | 5 +++++
 drivers/gpio/omap_gpio.c   | 9 +++++----
 3 files changed, 15 insertions(+), 4 deletions(-)

Comments

Simon Glass Sept. 29, 2017, 9 p.m. UTC | #1
These three drivers all use U_BOOT_DEVICE rather than device tree to
create devices, so have to do manual allocation of platform data. This is
not true for new platforms.

Add a more explicit comment so that people do not copy this approach with
new boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
---

 drivers/gpio/imx_rgpio2p.c | 5 +++++
 drivers/gpio/mxc_gpio.c    | 5 +++++
 drivers/gpio/omap_gpio.c   | 9 +++++----
 3 files changed, 15 insertions(+), 4 deletions(-)

Applied to u-boot-dm thanks!
diff mbox series

Patch

diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 5abc88ba54..e60e9d2a01 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -175,6 +175,11 @@  static int imx_rgpio2p_bind(struct udevice *dev)
 	 * When every board is converted to driver model and DT is supported,
 	 * this can be done by auto-alloc feature, but not using calloc
 	 * to alloc memory for platdata.
+	 *
+	 * For example imx_rgpio2p_plat uses platform data rather than device
+	 * tree.
+	 *
+	 * NOTE: DO NOT COPY this code if you are using device tree.
 	 */
 	plat = calloc(1, sizeof(*plat));
 	if (!plat)
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 0eb6c600f1..0c42bd6cec 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -311,6 +311,11 @@  static int mxc_gpio_bind(struct udevice *dev)
 	 * When every board is converted to driver model and DT is supported,
 	 * this can be done by auto-alloc feature, but not using calloc
 	 * to alloc memory for platdata.
+	 *
+	 * For example mxc_plat below uses platform data rather than device
+	 * tree.
+	 *
+	 * NOTE: DO NOT COPY this code if you are using device tree.
 	 */
 	plat = calloc(1, sizeof(*plat));
 	if (!plat)
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index b423e34ca4..5c55e6929e 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -299,12 +299,9 @@  static int omap_gpio_probe(struct udevice *dev)
 
 static int omap_gpio_bind(struct udevice *dev)
 {
-	struct omap_gpio_platdata *plat = dev->platdata;
+	struct omap_gpio_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t base_addr;
 
-	if (plat)
-		return 0;
-
 	base_addr = devfdt_get_addr(dev);
 	if (base_addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
@@ -314,6 +311,10 @@  static int omap_gpio_bind(struct udevice *dev)
 	* When every board is converted to driver model and DT is
 	* supported, this can be done by auto-alloc feature, but
 	* not using calloc to alloc memory for platdata.
+	*
+	* For example am33xx_gpio uses platform data rather than device tree.
+	*
+	* NOTE: DO NOT COPY this code if you are using device tree.
 	*/
 	plat = calloc(1, sizeof(*plat));
 	if (!plat)