Commit f2760c4acd5b7a198632d002528ec7c227ea27b8

Authored by Marek Vasut
Committed by Tom Rini
1 parent c1f5805a9d

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>

Showing 1 changed file with 14 additions and 6 deletions Side-by-side Diff

drivers/serial/serial.c
... ... @@ -97,12 +97,20 @@
97 97 void serial_register(struct serial_device *dev)
98 98 {
99 99 #ifdef CONFIG_NEEDS_MANUAL_RELOC
100   - dev->start += gd->reloc_off;
101   - dev->setbrg += gd->reloc_off;
102   - dev->getc += gd->reloc_off;
103   - dev->tstc += gd->reloc_off;
104   - dev->putc += gd->reloc_off;
105   - dev->puts += gd->reloc_off;
  100 + if (dev->start)
  101 + dev->start += gd->reloc_off;
  102 + if (dev->stop)
  103 + dev->stop += gd->reloc_off;
  104 + if (dev->setbrg)
  105 + dev->setbrg += gd->reloc_off;
  106 + if (dev->getc)
  107 + dev->getc += gd->reloc_off;
  108 + if (dev->tstc)
  109 + dev->tstc += gd->reloc_off;
  110 + if (dev->putc)
  111 + dev->putc += gd->reloc_off;
  112 + if (dev->puts)
  113 + dev->puts += gd->reloc_off;
106 114 #endif
107 115  
108 116 dev->next = serial_devices;