ata: libata-core: Simplify ata_print_version_once
PATCH 1/1 ata: libata-core: Simplify ata_print_version_once
Use dev_dbg_once() instead of open-coding the once functionality.
--- drivers/ata/libata-core.c | 6 +++--- include/linux/libata.h | 13 +------------ 2 files changed, 4 insertions(+), 15 deletions(-)
drivers/ata/libata-core.c +3 -3
@@ -6682,11 +6682,11 @@ const struct ata_port_info ata_dummy_port_info = { };EXPORT_SYMBOL_GPL (ata_dummy_port_info); -void ata_print_version (const struct device *dev,const char *version) +void ata_print_version_once (const struct device *dev,const char *version) { -dev_printk (KERN_DEBUG , dev,"version %s\n" , version); +dev_dbg_once (dev,"version %s\n" , version); } -EXPORT_SYMBOL (ata_print_version); +EXPORT_SYMBOL (ata_print_version_once);EXPORT_TRACEPOINT_SYMBOL_GPL (ata_tf_load);EXPORT_TRACEPOINT_SYMBOL_GPL (ata_exec_command);
include/linux/libata.h +1 -12
@@ -41,16 +41,7 @@*/ #undef ATA_IRQ_TRAP/* define to ack screaming irqs */ - -#define ata_print_version_once (dev, version) \ -({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - ata_print_version(dev, version); \ - } \ -}) +void ata_print_version_once (const struct device *dev,const char *version);/* defines only for the constants which don't work well as enums */ #define ATA_TAG_POISON 0xfafbfcfdU
@@ -1593,8 +1584,6 @@ do { \#define ata_dev_dbg (dev, fmt, ...) \ ata_dev_printk(debug, dev, fmt, ##__VA_ARGS__) -void ata_print_version (const struct device *dev,const char *version); -/* * ata_eh_info helpers */
Signature · 1 line
2.49.0
Damien Le Moal
maintainerQuoted 14 lines · Heiner Kallweit
Use
dev_dbg_once()instead of open-coding the once functionality.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/ata/libata-core.c | 6 +++--- include/linux/libata.h | 13 +------------ 2 files changed, 4 insertions(+), 15 deletions(-)drivers/ata/libata-core.c +0
-0@@ -6682,11 +6682,11 @@ const struct ata_port_info ata_dummy_port_info = { };
drivers/ata/libata-core.c const struct ata_port_info ata_dummy_port_info = { · line 6689
Quoted 10 lines
drivers/ata/libata-core.c +3
-3EXPORT_SYMBOL_GPL (ata_dummy_port_info); -void ata_print_version (const struct device *dev,const char *version) +void ata_print_version_once (const struct device *dev,const char *version) { -dev_printk (KERN_DEBUG , dev,"version %s\n" , version); +dev_dbg_once (dev,"version %s\n" , version); } -EXPORT_SYMBOL (ata_print_version); +EXPORT_SYMBOL (ata_print_version_once);
Overall, looks good, but I really do not see the point of having this as an exported function. So while at it, can you change it to be inline in libata.h ?
Quoted 34 lines
drivers/ata/libata-core.c +0
-0EXPORT_TRACEPOINT_SYMBOL_GPL (ata_tf_load);EXPORT_TRACEPOINT_SYMBOL_GPL (ata_exec_command);include/linux/libata.h +1
-12@@ -41,16 +41,7 @@*/ #undef ATA_IRQ_TRAP/* define to ack screaming irqs */ - -#define ata_print_version_once (dev, version) \ -({ \ - static bool __print_once; \ - \ - if (!__print_once) { \ - __print_once = true; \ - ata_print_version(dev, version); \ - } \ -}) +void ata_print_version_once (const struct device *dev,const char *version);/* defines only for the constants which don't work well as enums */ #define ATA_TAG_POISON 0xfafbfcfdU@@ -1593,8 +1584,6 @@ do { \#define ata_dev_dbg (dev, fmt, ...) \ ata_dev_printk(debug, dev, fmt, ##__VA_ARGS__) -void ata_print_version (const struct device *dev,const char *version); -/* * ata_eh_info helpers */
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 17 lines · Damien Le Moal
Quoted 16 lines · Heiner Kallweit
Use
dev_dbg_once()instead of open-coding the once functionality.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/ata/libata-core.c | 6 +++--- include/linux/libata.h | 13 +------------ 2 files changed, 4 insertions(+), 15 deletions(-)drivers/ata/libata-core.c +0
-0@@ -6682,11 +6682,11 @@ const struct ata_port_info ata_dummy_port_info = { };EXPORT_SYMBOL_GPL (ata_dummy_port_info);
Quoted 12 lines
drivers/ata/libata-core.c const struct ata_port_info ata_dummy_port_info = { · line 6689
Quoted 8 lines
drivers/ata/libata-core.c +3
-3-void ata_print_version (const struct device *dev,const char *version) +void ata_print_version_once (const struct device *dev,const char *version) { -dev_printk (KERN_DEBUG , dev,"version %s\n" , version); +dev_dbg_once (dev,"version %s\n" , version); } -EXPORT_SYMBOL (ata_print_version); +EXPORT_SYMBOL (ata_print_version_once);Overall, looks good, but I really do not see the point of having this as an exported function. So while at it, can you change it to be inline in
libata.h?
Right, this would be better. I'll submit a v2.