* [PATCH] Staging: fwserial: Convert macro into an inline function
@ 2019-03-06 22:48 Madhumitha Prabakaran
2019-03-07 20:03 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-06 22:48 UTC (permalink / raw)
To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran
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));
+}
#define LINUX_VENDOR_ID 0xd00d1eU /* same id used in card root directory */
#define FWSERIAL_VERSION 0x00e81cU /* must be unique within LINUX_VENDOR_ID */
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging: fwserial: Convert macro into an inline function
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
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-03-07 20:03 UTC (permalink / raw)
To: Madhumitha Prabakaran; +Cc: outreachy-kernel
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.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] Staging: fwserial: Convert macro into an inline function
2019-03-07 20:03 ` Greg KH
@ 2019-03-07 20:08 ` Julia Lawall
2019-03-07 20:20 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2019-03-07 20:08 UTC (permalink / raw)
To: Greg KH; +Cc: Madhumitha Prabakaran, outreachy-kernel
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.
julia
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] Staging: fwserial: Convert macro into an inline function
2019-03-07 20:08 ` [Outreachy kernel] " Julia Lawall
@ 2019-03-07 20:20 ` Greg KH
2019-03-07 20:27 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2019-03-07 20:20 UTC (permalink / raw)
To: Julia Lawall; +Cc: Madhumitha Prabakaran, outreachy-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] Staging: fwserial: Convert macro into an inline function
2019-03-07 20:20 ` Greg KH
@ 2019-03-07 20:27 ` Julia Lawall
0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-03-07 20:27 UTC (permalink / raw)
To: Greg KH; +Cc: Madhumitha Prabakaran, outreachy-kernel
On Thu, 7 Mar 2019, Greg KH wrote:
> 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
Ah, I only looked at .c files :)
julia
> 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-07 20:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-03-07 20:27 ` Julia Lawall
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.