All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Madhumitha Prabakaran <madhumithabiw@gmail.com>,
	outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] Re: [PATCH] Staging: fwserial: Convert macro into an inline function
Date: Thu, 7 Mar 2019 21:20:26 +0100	[thread overview]
Message-ID: <20190307202026.GA5287@kroah.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1903072107520.2558@hadrien>

On Thu, Mar 07, 2019 at 09:08:53PM +0100, Julia Lawall wrote:
> 
> 
> On Thu, 7 Mar 2019, Greg KH wrote:
> 
> > On Wed, Mar 06, 2019 at 04:48:09PM -0600, Madhumitha Prabakaran wrote:
> > > Convert macro into an inline function to make codebase better
> > >
> > > Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> > > ---
> > >  drivers/staging/fwserial/fwserial.c | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
> > > index a1b90ea7fcb8..aec0f19597a9 100644
> > > --- a/drivers/staging/fwserial/fwserial.c
> > > +++ b/drivers/staging/fwserial/fwserial.c
> > > @@ -19,7 +19,10 @@
> > >
> > >  #include "fwserial.h"
> > >
> > > -#define be32_to_u64(hi, lo)  ((u64)be32_to_cpu(hi) << 32 | be32_to_cpu(lo))
> > > +inline u64 be32_to_u64(__be32 hi, __be32 lo)
> > > +{
> > > +	return ((u64)be32_to_cpu(hi) << 32 | be32_to_cpu(lo));
> > > +}
> >
> > For some reason I thought the kernel had a function that already did
> > this, but it doesn't, which is really odd.  Anyway, that's something
> > that could be done in the future, as this is done all over the place in
> > different drivers.
> 
> Actually, as far as I can see, only two occurrences, in
> drivers/target/sbp/sbp_target.c and
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
> 
> Perhaps there are some other variants that are more popular.

The file include/linux/io-64-nonatomic-hi-lo.h open-codes this 4
different times, as does include/linux/ml5/device.h and then there is
HILO_GEN() which tries to do the right thing for this type of macro, but
it's specific to a single driver.

Odds are it is also open-coded in many other drivers as well :(

thanks,

greg k-h


  reply	other threads:[~2019-03-07 20:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 22:48 [PATCH] Staging: fwserial: Convert macro into an inline function Madhumitha Prabakaran
2019-03-07 20:03 ` Greg KH
2019-03-07 20:08   ` [Outreachy kernel] " Julia Lawall
2019-03-07 20:20     ` Greg KH [this message]
2019-03-07 20:27       ` Julia Lawall

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=20190307202026.GA5287@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=julia.lawall@lip6.fr \
    --cc=madhumithabiw@gmail.com \
    --cc=outreachy-kernel@googlegroups.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.