[PATCH] serial: imx: Fix for non-devicetree boards

Philipp Zabel p.zabel at pengutronix.de
Fri Aug 15 02:10:03 PDT 2014


Commit 3843bfd0ab77eaf125ca617922927b61fc8ded74
"serial: imx: Determine device name from device tree"
broke this driver for non-devicetree boards, since
of_alias_get may not be called with a NULL pointer
as first argument.

Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
 drivers/serial/serial_imx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 474bfaf..e379f29 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -338,9 +338,11 @@ static int imx_serial_probe(struct device_d *dev)
 	cdev->flush = imx_serial_flush;
 	cdev->setbrg = imx_serial_setbaudrate;
 	cdev->linux_console_name = "ttymxc";
-	devname = of_alias_get(dev->device_node);
-	if (devname)
-		cdev->devname = xstrdup(devname);
+	if (dev->device_node) {
+		devname = of_alias_get(dev->device_node);
+		if (devname)
+			cdev->devname = xstrdup(devname);
+	}
 
 	imx_serial_init_port(cdev);
 
-- 
2.0.1




More information about the barebox mailing list