All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Matthew Howell <matthew.howell@sealevel.com>
Cc: gregkh@linuxfoundation.org, jeff.baldwin@sealevel.com,
	james.olson@sealevel.com, ryan.wenglarz@sealevel.com,
	darren.beeson@sealevel.com, linux-serial@vger.kernel.org,
	ilpo.jarvinen@linux.intel.com
Subject: Re: [PATCH V4 2/2] serial: exar: Add RS-485 support for Sealevel XR17V35X based cards
Date: Mon, 11 Sep 2023 16:37:11 +0300	[thread overview]
Message-ID: <ZP8YB9EI4ahhSySP@smile.fi.intel.com> (raw)
In-Reply-To: <f9984ae7-354f-4c14-a62d-73e51cf3ba6e@sealevel.com>

On Mon, Sep 11, 2023 at 09:22:45AM -0400, Matthew Howell wrote:
> On Wed, 6 Sep 2023, Andy Shevchenko wrote:
> > On Wed, Sep 06, 2023 at 11:05:20AM -0400, Matthew Howell wrote:
> > > On Wed, 6 Sep 2023, Andy Shevchenko wrote:
> > > > On Tue, Sep 05, 2023 at 12:06:20PM -0400, Matthew Howell wrote:

...

> > > > > +     if (rs485->flags & SER_RS485_ENABLED) {
> > > >
> > > > What I meant is to have
> > > >
> > > >         if (!)rs485->flags & SER_RS485_ENABLED))
> > > >                 return 0;
> > > >
> > > > here, which allows you to reduce indentation level in the below block.
> > > >
> > > > > +             /* Set EFR[4]=1 to enable enhanced feature registers */
> > > > > +             writeb(readb(p + UART_XR_EFR) | UART_EFR_ECB, p + UART_XR_EFR);
> > > > > +
> > > > > +             /* Set MCR to use DTR as Auto-RS485 Enable signal */
> > > > > +             writeb(UART_MCR_OUT1, p + UART_MCR);
> > > > > +
> > > > > +             /* Store original LCR and set LCR[7]=1 to enable access to DLD register */
> > > > > +             old_lcr = readb(p + UART_LCR);
> > > > > +             writeb(old_lcr | UART_LCR_DLAB, p + UART_LCR);
> > > > > +
> > > > > +             /* Set DLD[7]=1 for inverted RS485 Enable logic */
> > > > > +             writeb(readb(p + UART_EXAR_DLD) | UART_EXAR_DLD_485_POLARITY, p + UART_EXAR_DLD);
> > > > > +
> > > > > +             writeb(old_lcr, p + UART_LCR);
> > > > > +    }
> > > > > +
> > > > > +     return 0;
> > >
> > > I see where you are coming from now, but I find that slightly less clear
> > > than having the 'main action' within the conditional statement. And since
> > > the code is not heavily indented I don't see much benefit of removing the
> > > indent.
> > 
> > In that case it might make sense to split to two functions:
> > 
> > func1()
> > {
> >         ...
> > }
> > 
> > func2()
> > {
> >         if (...)
> >                 return func1()
> > 
> >         return 0;
> > }
> 
> I will have to respectfully disagree on this. Splitting the function into 
> two still adds additional redirection, however small, to the function.

You mean in the C code? Because in assembly it will be the same (as long as
the compiler optimisation is on).

But besides that it's a common practice to split in case the function is long
enough to be on a single screen page (meaning the body of the conditional ~20
LoCs threshold).

> I would also like to point out that the level of indent I am using is not 
> uncommon in 8250_exar.c and as such I do not find the styling of the 
> function to be out of place. 

You are probably referring to actually two functions, i.e.
pci_fastcom335_setup() and xr17v35x_register_gpio(), right?

Each of these three cases (including yours) are different. I do not think
there is a common ground to support your way by pointing out on them.

> I will resubmit and try to address the other concerns raised by you and 
> Ilpo but unless Greg KH says otherwise I don't see any reason to change 
> the indent at this time.


-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2023-09-11 21:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 16:06 [PATCH V4 2/2] serial: exar: Add RS-485 support for Sealevel XR17V35X based cards Matthew Howell
2023-09-06 10:06 ` Ilpo Järvinen
2023-09-06 13:31   ` Matthew Howell
2023-09-06 14:01     ` Ilpo Järvinen
2023-09-06 13:44 ` Andy Shevchenko
2023-09-06 15:05   ` Matthew Howell
2023-09-06 15:13     ` Andy Shevchenko
2023-09-11 13:22       ` Matthew Howell
2023-09-11 13:37         ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZP8YB9EI4ahhSySP@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=darren.beeson@sealevel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.olson@sealevel.com \
    --cc=jeff.baldwin@sealevel.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=matthew.howell@sealevel.com \
    --cc=ryan.wenglarz@sealevel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.