extern struct fdt_serial *fdt_serial_drivers[];
extern unsigned long fdt_serial_drivers_size;
-static struct fdt_serial dummy = {
- .match_table = NULL,
- .init = NULL,
-};
-
-static struct fdt_serial *current_driver = &dummy;
-
int fdt_serial_init(void)
{
const void *prop;
if (!match)
continue;
- if (drv->init) {
- rc = drv->init(fdt, noff, match);
- if (rc == SBI_ENODEV)
- continue;
- if (rc)
- return rc;
- }
- current_driver = drv;
- break;
- }
+ /* drv->init must not be NULL */
+ if (drv->init == NULL)
+ return SBI_EFAIL;
- /* Check if we found desired driver */
- if (current_driver != &dummy)
- goto done;
+ rc = drv->init(fdt, noff, match);
+ if (rc == SBI_ENODEV)
+ continue;
+ return rc;
+ }
/* Lastly check all DT nodes */
for (pos = 0; pos < fdt_serial_drivers_size; pos++) {
if (noff < 0)
continue;
- if (drv->init) {
- rc = drv->init(fdt, noff, match);
- if (rc == SBI_ENODEV)
- continue;
- if (rc)
- return rc;
- }
- current_driver = drv;
- break;
+ /* drv->init must not be NULL */
+ if (drv->init == NULL)
+ return SBI_EFAIL;
+
+ rc = drv->init(fdt, noff, match);
+ if (rc == SBI_ENODEV)
+ continue;
+ return rc;
}
-done:
- return 0;
+ return SBI_ENODEV;
}