Hmm... on consideration I don't think it's as ugly as I first
thought. But I think I have a better idea, see below...
> > Plus with the "loading" file, a interrupted load will just appear to
> > be unterminated - and if the scripts run again they'll have to check
> > that the loading file was 0 to start with - and if it isn't there's
> > nothing they can do except wait for the dead load to time out.
>
> The script will not automatically run at least until the timeout is
> expired.
>
> But in case you are doing things by hand, how about:
>
> $ echo cancel > .../loading
>
> or if you want to keep the content numeric:
>
> $ echo -1 > .../loading
>
> This will also allow the regular script to just cancel the load in case
> of error, like if the firmware image is not available or a read error
> happened while reading it.
>
> I'll implement that and the other stuff that came out of Oliver's
> comments later today and post the new code.
>
> > Better to catch the close, check the length, then return the firmware
> > or throw the junk image away as appropriate.
>
> If 'loading' stays the above should fix your timeout issue, and if it
> goes, yes, that is probably the way to go.
How about combining these two ideas: instead of "loading" and "data"
we have "size" and "data". First you write the size, then the data -
the driver accepts it once it gets the expected number of bytes.
Writing a new size throws away any partial image that's there, and
restarts the upload. Writing 0 cancels the upload entirely, and the
driver will presumably fail to initialize (or maybe use a default
image if it has one).
There's another question - what happens if userspace tries to write an
image when the driver hasn't requested one through hotplug?
-- David Gibson | For every complex problem there is a david@gibson.dropbear.id.au | solution which is simple, neat and | wrong. http://www.ozlabs.org/people/dgibson - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/