linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duncan Sands <baldrick@free.fr>
To: linux-hotplug@vger.kernel.org
Subject: firmware.agent and trailing newlines
Date: Fri, 02 Sep 2005 11:41:54 +0000	[thread overview]
Message-ID: <200509021341.54762.baldrick@free.fr> (raw)

After upgrading to a newer kernel (2.6.12 + ubuntu patches) I'm
having all kinds of problems with the kernel firmware loader.
The first problem is that request_firmware is not loading
firmware that is present.  This is due to firmware.agent
using echo rather than echo -n when writing to loading, i.e.:

load() {
    echo 1 > $SYSFS/$DEVPATH/loading
    cat "$1" > $SYSFS/$DEVPATH/data
    echo 0 > $SYSFS/$DEVPATH/loading
    exit
}

and

    echo -1 > $SYSFS/$DEVPATH/loading

rather than

load() {
    echo -n 1 > $SYSFS/$DEVPATH/loading
    cat "$1" > $SYSFS/$DEVPATH/data
    echo -n 0 > $SYSFS/$DEVPATH/loading
    exit
}

and

    echo -n -1 > $SYSFS/$DEVPATH/loading

This seems to cause firmware_loading_store to be
called twice for each echo: once with the number,
and once with a string containing just the newline
(or an empty string, I didn't check this point).
This results in messages like this:

firmware_loading_store: unexpected value (0)

and the firmware load being aborted.

(A) Since distributions are shipping kernels
with this behaviour, I think the following patch
should be applied to firmware.agent:

--- firmware.agent.orig	2005-09-01 16:47:24.000000000 +0200
+++ firmware.agent	2005-09-02 13:10:16.000000000 +0200
@@ -19,9 +19,9 @@
 . ./hotplug.functions
 
 load() {
-    echo 1 > $SYSFS/$DEVPATH/loading
+    echo -n 1 > $SYSFS/$DEVPATH/loading
     cat "$1" > $SYSFS/$DEVPATH/data
-    echo 0 > $SYSFS/$DEVPATH/loading
+    echo -n 0 > $SYSFS/$DEVPATH/loading
     exit
 }
 
@@ -59,7 +59,7 @@
     done
 
     # the firmware was not found
-    echo -1 > $SYSFS/$DEVPATH/loading
+    echo -n -1 > $SYSFS/$DEVPATH/loading
 
     ;;
 
(B) Is whitespace stripped off values written to
sysfs attributes?  If so, why?  What if you want
trailing/leading spaces?  What about trailing
newlines - are they stripped?  Should they be?
What is the policy/rationale on sysfs attributes
and whitespace?

(C) firmware_loading_store doesn't do much checking
on the values it gets: since it uses simple_strtol,
it will happily accept eg "1A" and interpret it as
"1"; it interprets empty strings as "0".  Wouldn't
it be better to add some validity checks?

(D) firmware_loading_store aborts firmware loading
on the slightest error.  If someone writes a strange
value to loading, maybe it should just return an
error, rather than returning an error and aborting the
load.

Thoughts?

All the best,

Duncan.


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2005-09-02 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-02 11:41 Duncan Sands [this message]
2005-09-04 16:07 ` firmware.agent and trailing newlines Greg KH
2005-09-06 19:21 ` Duncan Sands

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200509021341.54762.baldrick@free.fr \
    --to=baldrick@free.fr \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).