Clean up drivers/char.
[releases.git] / deblob-check
index 1231bfc4163b9dff19fbc32672ccf25abd97f3a0..78136262d55591b2f750d72fb9d8ada6c28c4e95 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# deblob-check version 2009-01-23
+# deblob-check version 2009-01-24
 # Inspired in gNewSense's find-firmware script.
 # Written by Alexandre Oliva <lxoliva@fsfla.org>
 
@@ -26,7 +26,7 @@
 
 
 # usage: deblob-check [-S] [-vv] [-s S] [-lDdBbCcXxPpFftVh?H] \
-#        [*.tar* patch-* *.patch *.diff]
+#        *.tar* patch-* [-i prefix/] *.patch *.diff...
 
 # Look for and report too-long undocumented sequences of numbers
 # (generally blobs in disguise) in source files, as well as requests
 # -v --verbose: increase verbosity level, for internal debugging.  May
 #              be given at most twice.
 
+
+# file options:
+
+# --: Don't process command-line options any further.  All following
+#              arguments are taken as filenames.
+
+# -i --implied-prefix --prefix: prepend the given prefix to each filename
+#              listed after this option, when configuring false positives
+#              and negatives.
+
+# *.tar*: iterate over all files in the named tar file.
+
+# *.patch, patch-*, *.diff: Look for blobs in the [ +] parts of the
+#              *patch, unless --reverse-patch is given, in which case
+#              the [ -] parts will be used.
+
+# Anything else is assumed to be a source file.
+
+# *.gz | *.bz2: Decompress automatically.
+
+
 # The exit status is only significant for the --list options: it will
 # be true if nothing was found, and false otherwise.
 
@@ -262,6 +283,20 @@ case $1 in
   ;;
 esac
 
+prefix=/
+case $1 in
+--implied-prefix | --prefix| -i)
+  prefix=$2
+  case $prefix in
+  /*/) ;;
+  */) prefix=/$prefix ;;
+  /*) prefix=$prefix/ ;;
+  *) prefix=/$prefix/ ;;
+  esac
+  shift 2 || exit 1
+  ;;
+esac
+
 test_mode=false
 
 name=deblob-check
@@ -387,9 +422,10 @@ q 1;"
 
 *)
   case $1 in
-  -- | -l | --list-blobs) shift;;
+  -l | --list-blobs) shift;;
   esac
   case $1 in
+  -- | --implied-prefix | --prefix | -i) ;;
   -*)
     if test ! -f "$1"; then
       echo "$name: \`$1' given too late or out of the proper sequence." >&2
@@ -410,7 +446,9 @@ q 1;"
 esac
 
 case $1 in
---) shift;;
+--)
+  sawdashdash=t
+  shift;;
 esac
 
 if $test_mode; then
@@ -532,27 +570,12 @@ set_except () {
     badx "$1" $2
   }
 
-  blobna "request_firmware\\(_nowait\\)\\?"
-
-  case /$1 in
-  /drivers/net/tg3.c)
-    # This file contains firmwares that we deblob with high
-    # sensitivity, so make sure the sequences of numbers that are not
-    # blobs are not deblobbed.  FIXME: we should have patterns to
-    # recognize the blobs instead.
-    defsnc '   static const u32 test_pat\[4\]\[6\] =' drivers/net/tg3.c
-    accept "   }\\(,\\? mem_tbl_5\\(70x\\|705\\|755\\|906\\)\\[\\] = {$sepx$blobpat*$sepx}\\)*;" drivers/net/tg3.c
-    ;;
-
-  /drivers/media/video/gspca/conex.c)
-    # FIXME: we shouldn't have to duplicate this here, but deblob
-    # doesn't pass us a pathname that matches linux-*.*.*/, and then
-    # we end up deblobbing false positives.
-    defsnc 'static const __u8 cx_inits_\(176\|320\|352\|640\)\[\] =' drivers/media/video/gspca/conex.c
-    defsnc 'static const __u8 cx_jpeg_init\[\]\[8\] =' drivers/media/video/gspca/conex.c
-    defsnc 'static const __u8 cxjpeg_\(640\|352\|320\|176\|qtable\)\[\]\[8\] =' drivers/media/video/gspca/conex.c
-    ;;
+  blobna "request_firmware_nowait"
+  blobna "request_firmware"
+  blobna "request_ihex_firmware"
+  blobna "MODULE_FIRMWARE([^;]*)[^;]*;"
 
+  case $prefix$1 in
   */*linux*.tar* | */*kernel*.tar* | */*linux-*.*.*/*)
     # false alarms, contain source
     # drivers/net/wan/wanxlfw.inc_shipped -> wanxlfw.S
@@ -627,6 +650,13 @@ set_except () {
     defsnc 'static const char zr360[56]0_dqt\[0x86\] =' 'drivers/media/video/zr36060\.c\|drivers/media/video/zoran/zr36060\.c'
     defsnc 'static u8 tas3004_treble_table\[\] =' sound/aoa/codecs/tas-basstreble.h
 
+    # This file contains firmwares that we deblob with high
+    # sensitivity, so make sure the sequences of numbers that are not
+    # blobs are not deblobbed.  FIXME: we should have patterns to
+    # recognize the blobs instead.
+    defsnc '   static const u32 test_pat\[4\]\[6\] =' drivers/net/tg3.c
+    accept "   }\\(,\\? mem_tbl_5\\(70x\\|705\\|755\\|906\\)\\[\\] = {$sepx$blobpat*$sepx}\\)*;" drivers/net/tg3.c
+
     # end of generic checked expressions.
     # version-specific checked bits start here
 
@@ -789,6 +819,49 @@ set_except () {
     defsnc 'static u8 serit_sp1511lhb_inittab\[\] =' drivers/media/dvb/frontends/si21xx.c
     defsnc 'static u8 stv0288_inittab\[\] =' drivers/media/dvb/frontends/stv0288.c
     defsnc 'static const struct rf_channel rf_vals_b\[\] =' drivers/net/wireless/rt2x00/rt2400pci.c
+    defsnc 'static const u8 rtl8187b_reg_table\[\]\[3\] =' drivers/net/wireless/rtl8187_dev.c
+
+    # request_firmware matches for 2.6.28
+    accept 'D: Firmware loader (request_firmware)' CREDITS
+    accept 'FIRMWARE LOADER (request_firmware)' MAINTAINERS
+    accept '   - request_firmware() hotplug interface info.' Documentation/00-INDEX
+    accept 'This driver requires a patch for firmware_class[^\n]*[\n]request_firmware_nowait function\.' Documentation/dell_rbu.txt
+    accept ' request_firmware() hotplug interface:[\n] --*[\n].* - request_firmware_nowait() is also provided for convenience' Documentation/firmware_class/README
+    accept 'Still, there are kernel threads that may want.*For example, if request_.*_firmware() will fail regardless' Documentation/power/freezing-of-tasks.txt
+    accept 'Also, there may be some operations,.*calling request_firmware() from their .resume() routines' Documentation/power/notifiers.txt
+    accept 'There is an USB interface for downloading[/]uploading.*request_firmware interface\.' Documentation/video4linux/si470x.txt
+    accept '[\t]- move firmware loading to request_firmware()' drivers/staging/slicoss/README
+    accept 'config FIRMWARE_IN_KERNEL.*let firmware be loaded from userspace\.' drivers/base/Kconfig
+    accept 'static int[\n]_request_firmware(const struct firmware \*\*firmware_p, const char \*name,[^{]*[\n]{[\n]\([^}]\|[^\n}]}*\)*[\n]}[\n]' drivers/base/firmware_class.c
+    accept 'static int[\n]request_firmware_work_func(void \*arg)[\n]{[\n]\([^}]\|[^\n}]}*\)*ret = _request_firmware(\([^}]\|[^\n}]}*\)*[\n]}[\n]' drivers/base/firmware_class.c
+    accept '[/][*][*][\n] [*] request_firmware: - send firmware [^{]*[\n]{[\n]\([^}]\|[^\n}]}*\)*[\n]}[\n]' drivers/base/firmware_class.c
+    accept '[/][*][*][\n] [*] request_firmware_nowait: asynchronous version[^{]*[\n]{[\n]\([^}]\|[^\n}]}*\)*[\n]}[\n]' drivers/base/firmware_class.c
+    accept 'EXPORT_SYMBOL(request_firmware\(_nowait\)\?);' drivers/base/firmware_class.c
+    accept 'int request_firmware\(_nowait\)\?([^;]*);' include/linux/firmware.h
+    accept 'static inline int request_firmware\(_nowait\)\?([^{]*)[\n]{[\n][\t]return -EINVAL;[\n]}[\n]' include/linux/firmware.h
+    accept 'static inline int \(maybe_\)\?reject_firmware\(_nowait\)\?([^{;]*)[\n]{[\n]\([^}]\|[^\n}]}*\)*[\n]}[\n]' include/linux/firmware.h
+
+    accept 'static inline int request_ihex_firmware\?([^{]*)[\n]{[\n]\([^}]\|[^\n}]}*\)*[\n]}[\n]' include/linux/ihex.h
+    ocomment '[/][*] Optional firmware\([^\n]*[\n] [*]\)*[^\n]* MODULE_FIRMWARE()'
+    oprepline '#define MODULE_FIRMWARE(_firmware)' include/linux/module.h
+    accept ' [*] Sample code on how to use request_firmware() from drivers\.' samples/firmware_class/firmware_sample_driver.c
+    accept '[\t]\(retval\|error\) = request_firmware\(_nowait\)\?([^;]*"sample_driver_fw",[^;]*);' samples/firmware_class/firmware_sample_driver.c
+    ocomment ' [/][*] request_firmware blocks until userspace finished' samples/firmware_class/firmware_sample_driver.c
+    accept '           [ \t]*" request_firmware_nowait failed' samples/firmware_class/firmware_sample_driver.c
+
+    # Hunting down non-Free firmware-loading code and instructions.
+
+    blob 'atmsar11\.fw' drivers/atm/ambassador.c
+
+    blob '    sprintf([^;]*fore200[^;]*FW_EXT[^;]*);' drivers/atm/fore200e.c
+    blobna '\(pc\|sb\)a200e\(_ecd\)\?\.bin[12]?' drivers/atm/fore200e.c
+    blobna 'The supplied firmware images.*fore.*Rebuild and reinstall[^.]*\.' Documentation/networking/fore200e.txt
+
+    blobna 'intelliport2\.bin' drivers/char/ip2/ip2main.c
+
+    blobna '\(agere\|prism\)_\(sta\|ap\)_fw\.bin' drivers/net/wireless/orinoco.c
+    blobna 'symbol_sp24t_\(prim\|sec\)_fw' drivers/net/wireless/orinoco.c
+
 
     # This looks suspicious, but it pretty much just sets stuff to zero.
     initnc 'static __u8 mode8420\(pro\|con\)\[\] =' drivers/media/video/cs8420.h
@@ -2256,9 +2329,37 @@ pass=:
 tempfiles=
 trap "status=$?; test -z \"$tempfiles\" || rm -f $tempfiles; (exit $status); exit" 0 1 2 15
 
+process_arg=
+
 # Go through each of the input files in the command line.
 for file
 do
+  case $process_arg in
+  "") ;;
+  --implied-prefix | --prefix | -i)
+    prefix=$file
+    case $prefix in
+    /*/) ;;
+    */) prefix=/$prefix ;;
+    /*) prefix=$prefix/ ;;
+    *) prefix=/$prefix/ ;;
+    esac
+    process_arg=
+    continue
+    ;;
+  *)
+    echo Internal error with process_arg=$process_arg >&2
+    exit 1
+    ;;
+  esac
+
+  case $sawdashdash$file in
+  --implied-prefix | --prefix | -i)
+    process_arg=$file
+    continue
+    ;;
+  esac
+  
   # If we print anything whatsoever (even a blank line) while
   # processing it, we've failed.
   if check "$file"; then
@@ -2270,6 +2371,14 @@ do
   fi
 done
 
+case $process_arg in
+"") ;;
+*)
+  echo Missing argument to $process_arg >&2
+  exit 1
+  ;;
+esac
+
 #list: shift $n
 
 #list: exec test $# = 0