request_firmware() hotplug interface, third round and a halve

From: Manuel Estrada Sainz (ranty@debian.org)
Date: Sat May 17 2003 - 17:19:22 EST


 Hi,

 There is some new stuff:
 -----------------------

 - 'struct device *device' is used instead of 'char *device'. So we now
   have the device symlink :)

 - request_firmware_nowait is implemented, please comment on it.
 
 - It doesn't abuse the stack any more, or at least not that much :)
 
 - There is a timeout, changeable from userspace. Feedback on a
   reasonable default value appreciated.
 
 - Extended 'loading' semantics:
         echo 1 > loading:
                start a new load, and flush any data from a previous
                partial load.
        echo 0 > loading:
                finish load.
        echo -1 > loading:
                cancel load and give an error to the driver.
                
 - adapted to new sysfs interface.
 
 - it is now a patch against current bk-cvs gateway.
 
 - There is a *working* sample on how to use the firmware class without
   using request_firmware(). It is not clean, but it works, if it is
   found to be interesting it should be further polished.

 Some random notes:
 -----------------

 - request_firmware_cancel is not needed, request_firmware_nowait will
   lock the client module into memory until after triggering the
   callback.
   The only other problem that I can think of is the device getting
   unplugged while waiting for firmware, so the driver callback should
   first make sure that the device is still there.

 - firmware-class.diff adds both samples to the kernel tree, that
   doesn't mean that I want them there, it is just for easier testing.

 Patches:
 -------

 - firmware-class.diff:
         firmware_class code and the two samples.

 - sysfs-bin-flexible-size.diff:
         Make dynamically sized files possible.
        And return the right value on successful write.

 - sysfs-bin-lost-dget.diff:
         I was having trouble when calling request_firmware() from a
        work queue, and after a little investigations it seams that this
        dget got lost along the way. Adding it back fixed the issue.
        Or am I causing a dentry leak now?

PS: If you guys consider this abusive CC:ing, please complain.

-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.


diff --exclude=CVS -urN linux-2.5.orig/fs/sysfs/bin.c linux-2.5.mine/fs/sysfs/bin.c --- linux-2.5.orig/fs/sysfs/bin.c 2003-05-17 20:44:03.000000000 +0200 +++ linux-2.5.mine/fs/sysfs/bin.c 2003-05-17 14:53:01.000000000 +0200 @@ -30,10 +30,15 @@ loff_t offs = *off; int ret; - if (offs > size) - return 0; - if (offs + count > size) - count = size - offs; + if (count > PAGE_SIZE) + count = PAGE_SIZE; + + if(size){ + if (offs > size) + return 0; + if (offs + count > size) + count = size - offs; + } ret = fill_read(dentry, buffer, offs, count); if (ret < 0) @@ -69,10 +74,14 @@ loff_t offs = *off; int ret; - if (offs > size) - return 0; - if (offs + count > size) - count = size - offs; + if (count > PAGE_SIZE) + count = PAGE_SIZE; + if (size) { + if (offs > size) + return 0; + if (offs + count > size) + count = size - offs; + } ret = -EFAULT; if (copy_from_user(buffer + offs, userbuf, count)) @@ -81,7 +90,7 @@ count = flush_write(dentry, buffer, offs, count); if (count > 0) *off = offs + count; - ret = 0; + ret = count; Done: return ret; } @@ -102,7 +111,7 @@ goto Done; error = -ENOMEM; - file->private_data = kmalloc(attr->size, GFP_KERNEL); + file->private_data = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!file->private_data) goto Done;

diff --exclude=CVS -urN linux-2.5.orig/fs/sysfs/inode.c linux-2.5.mine/fs/sysfs/inode.c --- linux-2.5.orig/fs/sysfs/inode.c 2003-05-17 20:44:03.000000000 +0200 +++ linux-2.5.mine/fs/sysfs/inode.c 2003-05-17 20:30:34.000000000 +0200 @@ -60,9 +60,10 @@ Proceed: if (init) error = init(inode); - if (!error) + if (!error){ d_instantiate(dentry, inode); - else + dget(dentry); /* Extra count - pin the dentry in core */ + } else iput(inode); Done: return error;

- 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/



This archive was generated by hypermail 2b29 : Fri May 23 2003 - 22:00:29 EST