Re: [PATCH v7 4/7] serial: core: Add support for DEVNAME:0.0 style naming for kernel console

Dhruva Gole
2024-03-28T10:33:46Z

On Mar 28, 2024 at 08:22:26 +0100, Greg Kroah-Hartman wrote:
> On Thu, Mar 28, 2024 at 12:01:52PM +0530, Dhruva Gole wrote:
> > Hi,
> >
> > On Mar 27, 2024 at 12:59:38 +0200, Tony Lindgren wrote:
> > > We can now add hardware based addressing for serial ports. Starting with
> > > commit 84a9582fd203 ("serial: core: Start managing serial controllers to
> > > enable runtime PM"), and all the related fixes to this commit, the serial
> > > core now knows to which serial port controller the ports are connected.
[...]
> > >
> > > +#ifdef CONFIG_SERIAL_CORE_CONSOLE
> > > +
> > > +static int serial_base_add_one_prefcon(const char *match, const char *dev_name,
> > > + int port_id)
> > > +{
> > > + int ret;
> > > +
> > > + ret = add_preferred_console_match(match, dev_name, port_id);
> > > + if (ret == -ENOENT)
> > > + return 0;
> > > +
> > > + return ret;
> >
> > Can we do this instead?
> > return (ret == -ENOENT ? 0 : ret);
>
> No, please no.
>
> Just spell it out, like was done here, dealing with ? : is a pain to
> read and follow and the generated code should be identical.
>
> Only use ? : in places where it's the only way to do it (i.e. as
> function parameters or in printk-like lines.)
>
> Write for people first, compilers second.

Okay understood, I will keep this in mind from now on.
Thanks.

Tony,
Please feel free to take my R-by and ignore this suggestion as per
Greg's comments.

--
Best regards,
Dhruva