On Jan 14, 2011, Richard Stallman <[email protected]> wrote:

>     No, it wouldn't be impossible.  A suitable userland hotplug script would
>     be perfectly capable of looking for a local file that satisfies the
>     request.

> It seems impossible to me.  Could you explain how it could do this?

Uhh...  I thought I'd already explained, but here it goes...

Nowadays, a minimal hotplug script looks like this:

# Both $DEVPATH and $FIRMWARE are already provided in the environment.
HOTPLUG_FW_DIR=/lib/firmware/
if test -f $HOTPLUG_FW_DIR/$FIRMWARE; then
  echo 1 > /sys/$DEVPATH/loading # firmware found
  cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data # upload it
  echo 0 > /sys/$DEVPATH/loading # upload complete
else
  echo -1 > /sys/$DEVPATH/loading # firmware not found
fi


If the kernel passes userland, in addition to DEVPATH and FIRMWARE, a
HASHPREFIX, the hotplug script would run:

case $FIRMWARE in md5/*)
  hash=`echo $FIRMWARE | sed 's,^md5/,,'`
  for f in `cd $HOTPLUG_FW_DIR && find . ! -type d -print | sed 's,\./,,'`; do
    case `echo -n $HASHPREFIX$f | md5sum` in
    "$hash"[    ]*)
      echo 1 > /sys/$DEVPATH/loading
      cat $HOTPLUG_FW_DIR/$f > /sys/$DEVPATH/data
      echo 0 > /sys/$DEVPATH/loading
      exit 0
      ;;
    esac
  done
;;
esac

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to