From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sun, 2 Sep 2012 02:02:51 +0200 Subject: [U-Boot] [PATCH 3/6] stdio: dm: Make stdio_devices[] local In-Reply-To: <5042962F.4060706@googlemail.com> References: <1346453055-30888-1-git-send-email-marex@denx.de> <1346453055-30888-4-git-send-email-marex@denx.de> <5042962F.4060706@googlemail.com> Message-ID: <201209020202.51744.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Andreas Bie?mann, > Dear Marek Vasut, Heh, this Dear $recipient became really popular :-) [...] > return is not required here .. > > > } > > > > static inline void console_puts(int file, const char *s) > > { > > > > - stdio_devices[file]->puts(s); > > + struct stdio_dev *dev = stdio_get_fd(file); > > + if (dev) > > + return dev->puts(s); > > .. and here Thanks! > > } > > > > static inline void console_printdevs(int file) > > { > > > > - printf("%s\n", stdio_devices[file]->name); > > + struct stdio_dev *dev = stdio_get_fd(file); > > + if (dev) > > + printf("%s\n", dev->name); > > > > } > > > > static inline void console_doenv(int file, struct stdio_dev *dev) > > > > @@ -592,27 +604,28 @@ int console_init_f(void) > > > > void stdio_print_current_devices(void) > > { > > #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET > > > > + struct stdio_dev *sio; > > > > /* Print information */ > > puts("In: "); > > > > - if (stdio_devices[stdin] == NULL) { > > + sio = stdio_get_fd(stdin); > > + if (sio == NULL) > > > > puts("No input devices available!\n"); > > > > - } else { > > - printf ("%s\n", stdio_devices[stdin]->name); > > - } > > + else > > + printf("%s\n", sio->name); > > > > puts("Out: "); > > > > - if (stdio_devices[stdout] == NULL) { > > + sio = stdio_get_fd(stdout); > > Isn't sio still set properly here ... It is, but it still can be NULL. Also notice the argument differs, first it's stdin, then stdout and lastly stderr > > + if (sio == NULL) > > > > puts("No output devices available!\n"); > > > > - } else { > > - printf ("%s\n", stdio_devices[stdout]->name); > > - } > > + else > > + printf("%s\n", sio->name); > > > > puts("Err: "); > > > > - if (stdio_devices[stderr] == NULL) { > > + sio = stdio_get_fd(stderr); > > .. and here? > > > + if (sio == NULL) > > Side note: in your newly introduced checks you use just > > if (sio) { > ... > > Why check explicitly for NULL here? I personally favor 'if (!sio)'. Compat reason really ... I didn't wanted to introduce more change than necessary ... incremental patching can be done indeed ;-) > > puts("No error devices available!\n"); > > > > - } else { > > - printf ("%s\n", stdio_devices[stderr]->name); > > - } > > + else > > + printf("%s\n", sio->name); Thanks for the review :) > Best regards > > Andreas Bie?mann