Browse Source

serial: Enhance the manual relocation

Enhance the manual relocation of drivers operations structure by
checking if the entries are NULL and increment them only if they
are not. This allows for setting any entry to NULL and it will
survive the manual relocation.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Rini <trini@ti.com>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Stefan Roese <sr@denx.de>
Marek Vasut 12 năm trước cách đây
mục cha
commit
f2760c4acd
1 tập tin đã thay đổi với 14 bổ sung6 xóa
  1. 14 6
      drivers/serial/serial.c

+ 14 - 6
drivers/serial/serial.c

@@ -97,12 +97,20 @@ serial_initfunc(sh_serial_initialize);
 void serial_register(struct serial_device *dev)
 {
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
-	dev->start += gd->reloc_off;
-	dev->setbrg += gd->reloc_off;
-	dev->getc += gd->reloc_off;
-	dev->tstc += gd->reloc_off;
-	dev->putc += gd->reloc_off;
-	dev->puts += gd->reloc_off;
+	if (dev->start)
+		dev->start += gd->reloc_off;
+	if (dev->stop)
+		dev->stop += gd->reloc_off;
+	if (dev->setbrg)
+		dev->setbrg += gd->reloc_off;
+	if (dev->getc)
+		dev->getc += gd->reloc_off;
+	if (dev->tstc)
+		dev->tstc += gd->reloc_off;
+	if (dev->putc)
+		dev->putc += gd->reloc_off;
+	if (dev->puts)
+		dev->puts += gd->reloc_off;
 #endif
 
 	dev->next = serial_devices;