Re: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O

From: Andy Shevchenko
Date: Thu Mar 28 2019 - 09:11:47 EST


On Thu, Mar 28, 2019 at 01:32:50PM +0100, Borislav Petkov wrote:
> On Tue, Mar 19, 2019 at 09:43:20PM +0300, Andy Shevchenko wrote:
> > As preparatory to enable earlyprintk on non-standard ports on x86,
> > introduce serial_in() and serial_out() helpers to perform serial I/O.
> >
> > No functional change intended.
>
> ...
>
> > +/* Assign serial I/O accessors */
> > +static void early_serial_use_io_accessors(void)
> > +{
> > + /* These will always be IO based ports */
> > + serial_in = io_serial_in;
> > + serial_out = io_serial_out;
> > +}
>
> This and the early_serial_use_mmio_accessors() in a later patch is just
> silly because you need to export and forward-declare those serial_in and
> serial_out function pointers in a bunch of places.

This is the same approach as it's done in earlyprintk support in the main part
of the kernel. Besides the fact that many drivers do it in the same way.

And I wouldn't call 'few' a 'bunch'...

> Just define exactly *two* simple functions serial_in() and serial_out()
> which have enough logic to decide whether to do serial IO or MMIO and
> put all that logic in those functions.

Any idea how it can be done?

> No need for all that function
> pointer assignment "fun".

--
With Best Regards,
Andy Shevchenko