diff mbox series

[RFC,1/8] module: Prepare for script

Message ID 20241111111816.912388412@infradead.org (mailing list archive)
State Handled Elsewhere
Headers show
Series module: Strict per-modname namespaces | expand

Commit Message

Peter Zijlstra Nov. 11, 2024, 10:54 a.m. UTC
Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS
things are a single line.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 drivers/crypto/marvell/octeontx2/otx2_cptlf.c |   12 ++++--------
 include/kunit/visibility.h                    |    3 +--
 sound/soc/codecs/tas2781-fmwlib.c             |    6 ++----
 3 files changed, 7 insertions(+), 14 deletions(-)

Comments

Christoph Hellwig Nov. 11, 2024, 11:36 a.m. UTC | #1
On Mon, Nov 11, 2024 at 11:54:31AM +0100, Peter Zijlstra wrote:
> Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS
> things are a single line.

Eww.  Just use coccinelle or another tool not so simplistic.

> @@ -375,8 +372,7 @@ int otx2_cptlf_register_done_interrupts(
>  	otx2_cptlf_unregister_done_interrupts(lfs);
>  	return ret;
>  }
> -EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_done_interrupts,
> -		     CRYPTO_DEV_OCTEONTX2_CPT);
> +EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_done_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
>  
>  void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs)
>  {
> --- a/include/kunit/visibility.h
> +++ b/include/kunit/visibility.h
> @@ -24,8 +24,7 @@
>       * in test file in order to use symbols.
>       * @symbol: the symbol identifier to export
>       */
> -    #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \
> -	    EXPORTED_FOR_KUNIT_TESTING)
> +    #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, EXPORTED_FOR_KUNIT_TESTING)
>  #else
>      #define VISIBLE_IF_KUNIT static
>      #define EXPORT_SYMBOL_IF_KUNIT(symbol)
> --- a/sound/soc/codecs/tas2781-fmwlib.c
> +++ b/sound/soc/codecs/tas2781-fmwlib.c
> @@ -2310,8 +2310,7 @@ int tasdevice_select_tuningprm_cfg(void
>  out:
>  	return prog_status;
>  }
> -EXPORT_SYMBOL_NS_GPL(tasdevice_select_tuningprm_cfg,
> -	SND_SOC_TAS2781_FMWLIB);
> +EXPORT_SYMBOL_NS_GPL(tasdevice_select_tuningprm_cfg, SND_SOC_TAS2781_FMWLIB);
>  
>  int tasdevice_prmg_load(void *context, int prm_no)
>  {
> @@ -2392,8 +2391,7 @@ void tasdevice_tuning_switch(void *conte
>  			TASDEVICE_BIN_BLK_PRE_SHUTDOWN);
>  	}
>  }
> -EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch,
> -	SND_SOC_TAS2781_FMWLIB);
> +EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch, SND_SOC_TAS2781_FMWLIB);
>  
>  MODULE_DESCRIPTION("Texas Firmware Support");
>  MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");
> 
> 
---end quoted text---
Peter Zijlstra Nov. 11, 2024, 12:55 p.m. UTC | #2
On Mon, Nov 11, 2024 at 03:36:25AM -0800, Christoph Hellwig wrote:
> On Mon, Nov 11, 2024 at 11:54:31AM +0100, Peter Zijlstra wrote:
> > Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS
> > things are a single line.
> 
> Eww.  Just use coccinelle or another tool not so simplistic.

Feel free to do so. I've never managed to get coccinelle to do anything.
Peter Zijlstra Nov. 15, 2024, 11:49 a.m. UTC | #3
On Mon, Nov 11, 2024 at 01:55:29PM +0100, Peter Zijlstra wrote:
> On Mon, Nov 11, 2024 at 03:36:25AM -0800, Christoph Hellwig wrote:
> > On Mon, Nov 11, 2024 at 11:54:31AM +0100, Peter Zijlstra wrote:
> > > Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS
> > > things are a single line.
> > 
> > Eww.  Just use coccinelle or another tool not so simplistic.
> 
> Feel free to do so. I've never managed to get coccinelle to do anything.

So I put a little more effort in and got you this (awk needs to be
gawk>=4.1)

git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
  awk -i inplace '
    /^#define EXPORT_SYMBOL_NS/ {
      gsub(/__stringify\(ns\)/, "ns");
      print;
      next;
    }
    /^#define MODULE_IMPORT_NS/ {
      gsub(/__stringify\(ns\)/, "ns");
      print;
      next;
    }
    /MODULE_IMPORT_NS/ {
      $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
    }
    /EXPORT_SYMBOL_NS/ {
      if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
        if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
            $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
            $0 !~ /^my/) {
          getline line;
          gsub(/[[:space:]]*\\$/, "");
          gsub(/[[:space:]]/, "", line);
          $0 = $0 " " line;
        }

        $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
                    "\\1(\\2, \"\\3\")", "g");
      }
    }
    { print }' $file;
done


I'm sure that wasn't worth the time I spend on it though :/
diff mbox series

Patch

--- a/drivers/crypto/marvell/octeontx2/otx2_cptlf.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptlf.c
@@ -288,8 +288,7 @@  void otx2_cptlf_unregister_misc_interrup
 
 	cptlf_set_misc_intrs(lfs, false);
 }
-EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_misc_interrupts,
-		     CRYPTO_DEV_OCTEONTX2_CPT);
+EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_misc_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
 
 void otx2_cptlf_unregister_done_interrupts(struct otx2_cptlfs_info *lfs)
 {
@@ -308,8 +307,7 @@  void otx2_cptlf_unregister_done_interrup
 
 	cptlf_set_done_intrs(lfs, false);
 }
-EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_done_interrupts,
-		     CRYPTO_DEV_OCTEONTX2_CPT);
+EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_done_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
 
 static int cptlf_do_register_interrrupts(struct otx2_cptlfs_info *lfs,
 					 int lf_num, int irq_offset,
@@ -351,8 +349,7 @@  int otx2_cptlf_register_misc_interrupts(
 	otx2_cptlf_unregister_misc_interrupts(lfs);
 	return ret;
 }
-EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_misc_interrupts,
-		     CRYPTO_DEV_OCTEONTX2_CPT);
+EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_misc_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
 
 int otx2_cptlf_register_done_interrupts(struct otx2_cptlfs_info *lfs)
 {
@@ -375,8 +372,7 @@  int otx2_cptlf_register_done_interrupts(
 	otx2_cptlf_unregister_done_interrupts(lfs);
 	return ret;
 }
-EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_done_interrupts,
-		     CRYPTO_DEV_OCTEONTX2_CPT);
+EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_done_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
 
 void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs)
 {
--- a/include/kunit/visibility.h
+++ b/include/kunit/visibility.h
@@ -24,8 +24,7 @@ 
      * in test file in order to use symbols.
      * @symbol: the symbol identifier to export
      */
-    #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \
-	    EXPORTED_FOR_KUNIT_TESTING)
+    #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, EXPORTED_FOR_KUNIT_TESTING)
 #else
     #define VISIBLE_IF_KUNIT static
     #define EXPORT_SYMBOL_IF_KUNIT(symbol)
--- a/sound/soc/codecs/tas2781-fmwlib.c
+++ b/sound/soc/codecs/tas2781-fmwlib.c
@@ -2310,8 +2310,7 @@  int tasdevice_select_tuningprm_cfg(void
 out:
 	return prog_status;
 }
-EXPORT_SYMBOL_NS_GPL(tasdevice_select_tuningprm_cfg,
-	SND_SOC_TAS2781_FMWLIB);
+EXPORT_SYMBOL_NS_GPL(tasdevice_select_tuningprm_cfg, SND_SOC_TAS2781_FMWLIB);
 
 int tasdevice_prmg_load(void *context, int prm_no)
 {
@@ -2392,8 +2391,7 @@  void tasdevice_tuning_switch(void *conte
 			TASDEVICE_BIN_BLK_PRE_SHUTDOWN);
 	}
 }
-EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch,
-	SND_SOC_TAS2781_FMWLIB);
+EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch, SND_SOC_TAS2781_FMWLIB);
 
 MODULE_DESCRIPTION("Texas Firmware Support");
 MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");