omap2+: add drm device
[pandora-kernel.git] / scripts / coccicheck
index b8bcf1f..1bb1a1b 100755 (executable)
@@ -16,6 +16,7 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
 else
     ONLINE=0
     FLAGS="-very_quiet"
+    OPTIONS="-dir $srctree"
 fi
 
 if [ ! -x "$SPATCH" ]; then
@@ -25,11 +26,13 @@ fi
 
 if [ "$MODE" = "" ] ; then
     if [ "$ONLINE" = "0" ] ; then
-       echo 'You have not explicitly specify the mode to use. Fallback to "report".'
+       echo 'You have not explicitly specified the mode to use. Using default "chain" mode.'
+       echo 'All available modes will be tried (in that order): patch, report, context, org'
        echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
-       echo 'Available modes are: report, patch, context, org'
     fi
-    MODE="report"
+    MODE="chain"
+elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
+    FLAGS="$FLAGS -no_show_diff"
 fi
 
 if [ "$ONLINE" = "0" ] ; then
@@ -44,7 +47,7 @@ coccinelle () {
 
     OPT=`grep "Option" $COCCI | cut -d':' -f2`
 
-#   The option '-parse_cocci' can be used to syntaxically check the SmPL files.
+#   The option '-parse_cocci' can be used to syntactically check the SmPL files.
 #
 #    $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
 
@@ -52,21 +55,44 @@ coccinelle () {
 
        FILE=`echo $COCCI | sed "s|$srctree/||"`
 
-       echo "Processing `basename $COCCI` with option(s) \"$OPT\""
+       echo "Processing `basename $COCCI`"
+       echo "with option(s) \"$OPT\""
+       echo ''
        echo 'Message example to submit a patch:'
 
-       sed -e '/\/\/\//!d' -e 's|^///||' $COCCI
-
-       echo ' The semantic patch that makes this change is available'
+       sed -ne 's|^///||p' $COCCI
+
+       if [ "$MODE" = "patch" ] ; then
+           echo ' The semantic patch that makes this change is available'
+       elif [ "$MODE" = "report" ] ; then
+           echo ' The semantic patch that makes this report is available'
+       elif [ "$MODE" = "context" ] ; then
+           echo ' The semantic patch that spots this code is available'
+       elif [ "$MODE" = "org" ] ; then
+           echo ' The semantic patch that makes this Org report is available'
+       else
+           echo ' The semantic patch that makes this output is available'
+       fi
        echo " in $FILE."
        echo ''
        echo ' More information about semantic patching is available at'
        echo ' http://coccinelle.lip6.fr/'
        echo ''
 
-       $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1
+       if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
+           echo 'Semantic patch information:'
+           sed -ne 's|^//#||p' $COCCI
+           echo ''
+       fi
+    fi
+
+    if [ "$MODE" = "chain" ] ; then
+       $SPATCH -D patch   $FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
+       $SPATCH -D report  $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
+       $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
+       $SPATCH -D org     $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
     else
-       $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
+       $SPATCH -D $MODE   $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
     fi
 
 }