Staging: fwserial: Convert macro into an inline function
PATCH 1/1 Staging: fwserial: Convert macro into an inline function
Convert macro into an inline function to make codebase better
--- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/fwserial/fwserial.c +4 -1
@@ -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 */
Signature · 1 line
2.17.1
Greg KH
maintainerQuoted 12 lines · Madhumitha Prabakaran
Convert macro into an inline function to make codebase better
Signed-off-by Madhumitha Prabakaran <[email protected]>--- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/staging/fwserial/fwserial.c +0
-0
drivers/staging/fwserial/fwserial.c line 25
Quoted 8 lines
drivers/staging/fwserial/fwserial.c +4
-1@@ -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
Quoted 16 lines · Greg KH
Quoted 15 lines · Madhumitha Prabakaran
Convert macro into an inline function to make codebase better
Signed-off-by Madhumitha Prabakaran <[email protected]>--- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/staging/fwserial/fwserial.c +0
-0@@ -19,7 +19,10 @@#include "fwserial.h"
Quoted 10 lines
drivers/staging/fwserial/fwserial.c line 25
Quoted 5 lines
drivers/staging/fwserial/fwserial.c +4
-1-#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
Greg KH
maintainerQuoted 31 lines · Julia Lawall
Quoted 16 lines · Greg KH
Quoted 15 lines · Madhumitha Prabakaran
Convert macro into an inline function to make codebase better
Signed-off-by Madhumitha Prabakaran <[email protected]>--- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/staging/fwserial/fwserial.c +0
-0@@ -19,7 +19,10 @@#include "fwserial.h" Quoted 10 lines
drivers/staging/fwserial/fwserial.c line 25
Quoted 5 lines
drivers/staging/fwserial/fwserial.c +4
-1-#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.
Quoted 5 lines
Actually, as far as I can see, only two occurrences, in
drivers/target/sbp/sbp_target.canddrivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.cPerhaps 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
Quoted 32 lines · Greg KH
Quoted 31 lines · Julia Lawall
Quoted 26 lines · Greg KH
Quoted 12 lines · Madhumitha Prabakaran
Convert macro into an inline function to make codebase better
Signed-off-by Madhumitha Prabakaran <[email protected]>--- drivers/staging/fwserial/fwserial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/staging/fwserial/fwserial.c +0
-0drivers/staging/fwserial/fwserial.c line 25
Quoted 8 lines
drivers/staging/fwserial/fwserial.c +4
-1@@ -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.
Quoted 8 lines
Quoted 5 lines
Actually, as far as I can see, only two occurrences, in
drivers/target/sbp/sbp_target.canddrivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.cPerhaps there are some other variants that are more popular.
The file
include/linux/io-64-nonatomic-hi-lo.hopen-codes this 4 different times, as doesinclude/linux/ml5/device.hand then there is
Ah, I only looked at .c files :)
julia
Quoted 9 lines
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