public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Module read a file?
@ 2001-10-11 20:48 Mark Atwood
  2001-10-11 21:19 ` Christopher Friesen
  2001-10-12  4:43 ` T. A.
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Atwood @ 2001-10-11 20:48 UTC (permalink / raw)
  To: Linux Kernel Development

I'm modifying a PCMCIA driver module so that it can load new firmware
into the card when it's inserted.

Rather than including the firmware inside the module's binary, I would
much rather be able to read it out of the filesystem.

Are their any good examples of kernel code or kernel modules reading a
file out of the filesystem that I could copy or at least look to for
inspiration?

-- 
Mark Atwood   | I'm wearing black only until I find something darker.
mra@pobox.com | http://www.pobox.com/~mra

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 20:48 Module read a file? Mark Atwood
@ 2001-10-11 21:19 ` Christopher Friesen
  2001-10-11 21:25   ` Mark Atwood
  2001-10-12  4:43 ` T. A.
  1 sibling, 1 reply; 10+ messages in thread
From: Christopher Friesen @ 2001-10-11 21:19 UTC (permalink / raw)
  To: Mark Atwood; +Cc: Linux Kernel Development

Mark Atwood wrote:
> 
> I'm modifying a PCMCIA driver module so that it can load new firmware
> into the card when it's inserted.
> 
> Rather than including the firmware inside the module's binary, I would
> much rather be able to read it out of the filesystem.
> 
> Are their any good examples of kernel code or kernel modules reading a
> file out of the filesystem that I could copy or at least look to for
> inspiration?

What about adding an ioctl() and making a userspace tool to pass the new
firmware down in a buffer?  This lets you do more complicated error-checking and
maybe some sort of validation of the firmware in userspace, saving on kernel
size.

Chris

-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:19 ` Christopher Friesen
@ 2001-10-11 21:25   ` Mark Atwood
  2001-10-11 21:39     ` Christopher Friesen
                       ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mark Atwood @ 2001-10-11 21:25 UTC (permalink / raw)
  To: Christopher Friesen; +Cc: Linux Kernel Development

"Christopher Friesen" <cfriesen@nortelnetworks.com> writes:
> Mark Atwood wrote:
> > I'm modifying a PCMCIA driver module so that it can load new firmware
> > into the card when it's inserted.
> > Are their any good examples of kernel code or kernel modules reading a
> > file out of the filesystem that I could copy or at least look to for
> > inspiration?
> 
> What about adding an ioctl() and making a userspace tool to pass the
> new firmware down in a buffer?  This lets you do more complicated
> error-checking and maybe some sort of validation of the firmware in
> userspace, saving on kernel size.

Because the firmware is stored in volitile memory on the card, and
vanishes on a card reset or removal, and I would like to have it Just
Work with the pcmcia-cs package with minimal changes.

Having to remember "run this userspace tool after every card reset"
(which includes power suspends and so forth) would be a major pain.

Besides, the card already has a good validator in it.

-- 
Mark Atwood   | I'm wearing black only until I find something darker.
mra@pobox.com | http://www.pobox.com/~mra

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:25   ` Mark Atwood
@ 2001-10-11 21:39     ` Christopher Friesen
  2001-10-11 21:46     ` Greg KH
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Christopher Friesen @ 2001-10-11 21:39 UTC (permalink / raw)
  To: Mark Atwood; +Cc: Christopher Friesen, Linux Kernel Development

Mark Atwood wrote:
> 
> "Christopher Friesen" <cfriesen@nortelnetworks.com> writes:
> > Mark Atwood wrote:
> > > I'm modifying a PCMCIA driver module so that it can load new firmware
> > > into the card when it's inserted.
> > > Are their any good examples of kernel code or kernel modules reading a
> > > file out of the filesystem that I could copy or at least look to for
> > > inspiration?
> >
> > What about adding an ioctl() and making a userspace tool to pass the
> > new firmware down in a buffer?  This lets you do more complicated
> > error-checking and maybe some sort of validation of the firmware in
> > userspace, saving on kernel size.
> 
> Because the firmware is stored in volitile memory on the card, and
> vanishes on a card reset or removal, and I would like to have it Just
> Work with the pcmcia-cs package with minimal changes.

Ah, okay.  I was assuming that the firmware was stored in nonvolatile memory.

-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:25   ` Mark Atwood
  2001-10-11 21:39     ` Christopher Friesen
@ 2001-10-11 21:46     ` Greg KH
  2001-10-12  8:12       ` Ian Stirling
  2001-10-11 21:57     ` John Adams
  2001-10-11 22:18     ` Alan Cox
  3 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2001-10-11 21:46 UTC (permalink / raw)
  To: Mark Atwood; +Cc: Christopher Friesen, Linux Kernel Development

On Thu, Oct 11, 2001 at 02:25:09PM -0700, Mark Atwood wrote:
> 
> Because the firmware is stored in volitile memory on the card, and
> vanishes on a card reset or removal, and I would like to have it Just
> Work with the pcmcia-cs package with minimal changes.

Then add a script in the proper place in the linux-hotplug [1] package,
which will run everytime your card is inserted.  This is how USB
firmware loads will be done in 2.5.

thanks,

greg k-h

[1] http://linux-hotplug.sf.net/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:25   ` Mark Atwood
  2001-10-11 21:39     ` Christopher Friesen
  2001-10-11 21:46     ` Greg KH
@ 2001-10-11 21:57     ` John Adams
  2001-10-11 22:18     ` Alan Cox
  3 siblings, 0 replies; 10+ messages in thread
From: John Adams @ 2001-10-11 21:57 UTC (permalink / raw)
  To: linux-kernel

On Thursday 11 October 2001 17:25, Mark Atwood wrote:
> "Christopher Friesen" <cfriesen@nortelnetworks.com> writes:
> > Mark Atwood wrote:
> > > I'm modifying a PCMCIA driver module so that it can load new firmware
> > > into the card when it's inserted.
> > > Are their any good examples of kernel code or kernel modules reading
> > > a file out of the filesystem that I could copy or at least look to
> > > for inspiration?
> >
> > What about adding an ioctl() and making a userspace tool to pass the
> > new firmware down in a buffer?  This lets you do more complicated
> > error-checking and maybe some sort of validation of the firmware in
> > userspace, saving on kernel size.
>
> Because the firmware is stored in volitile memory on the card, and
> vanishes on a card reset or removal, and I would like to have it Just
> Work with the pcmcia-cs package with minimal changes.
>
> Having to remember "run this userspace tool after every card reset"
> (which includes power suspends and so forth) would be a major pain.
>

Have a userspace job which
1) sleeps in the kernel
2) when woken, delivers the data from the filesystem via ioctl to the driver
3) goes back to sleep

Have a driver which
1) wakes the user space job
2) receives the data via ioctl
3) reloads the card

The userspace job is started at boot and lives forever.
Its probably easiest to build the driver into the kernel.

	johna

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:25   ` Mark Atwood
                       ` (2 preceding siblings ...)
  2001-10-11 21:57     ` John Adams
@ 2001-10-11 22:18     ` Alan Cox
  2001-10-11 22:29       ` Mark Atwood
  3 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2001-10-11 22:18 UTC (permalink / raw)
  To: Mark Atwood; +Cc: Christopher Friesen, Linux Kernel Development

> Because the firmware is stored in volitile memory on the card, and
> vanishes on a card reset or removal, and I would like to have it Just
> Work with the pcmcia-cs package with minimal changes.

Longer term that is precisely what the hot plug interface is there fore

> Having to remember "run this userspace tool after every card reset"
> (which includes power suspends and so forth) would be a major pain.
> 
> Besides, the card already has a good validator in it.

What do you do if the card is compiled in and initialised before the
firmware holding fs is mounted ?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 22:18     ` Alan Cox
@ 2001-10-11 22:29       ` Mark Atwood
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Atwood @ 2001-10-11 22:29 UTC (permalink / raw)
  To: Alan Cox; +Cc: Mark Atwood, Christopher Friesen, Linux Kernel Development

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:
> > Because the firmware is stored in volitile memory on the card, and
> > vanishes on a card reset or removal, and I would like to have it Just
> > Work with the pcmcia-cs package with minimal changes.
> 
> Longer term that is precisely what the hot plug interface is there fore

And in the longer term, I plan on migrating this product over to the
hot plug interface.

In the medium term, this will be a really useful feature for quite a
few users of this driver.

In the short term, I just want to get this thing working.

> 
> > Having to remember "run this userspace tool after every card reset"
> > (which includes power suspends and so forth) would be a major pain.
> > 
> > Besides, the card already has a good validator in it.
> 
> What do you do if the card is compiled in and initialised before the
> firmware holding fs is mounted ?

Tell the packager and/or user of the module Dont Do That, and have the
card_reset and card_insert functions return with an error.

-- 
Mark Atwood   | I'm wearing black only until I find something darker.
mra@pobox.com | http://www.pobox.com/~mra

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 20:48 Module read a file? Mark Atwood
  2001-10-11 21:19 ` Christopher Friesen
@ 2001-10-12  4:43 ` T. A.
  1 sibling, 0 replies; 10+ messages in thread
From: T. A. @ 2001-10-12  4:43 UTC (permalink / raw)
  To: Linux Kernel Development, Mark Atwood

Check the PSS sound driver code.  In either 2.2.x or 2.4.x.  It allows you
to load a firmware from a selected file.

----- Original Message -----
From: "Mark Atwood" <mra@pobox.com>
To: "Linux Kernel Development" <linux-kernel@vger.kernel.org>
Sent: Thursday, October 11, 2001 4:48 PM
Subject: Module read a file?


> I'm modifying a PCMCIA driver module so that it can load new firmware
> into the card when it's inserted.
>
> Rather than including the firmware inside the module's binary, I would
> much rather be able to read it out of the filesystem.
>
> Are their any good examples of kernel code or kernel modules reading a
> file out of the filesystem that I could copy or at least look to for
> inspiration?
>
> --
> Mark Atwood   | I'm wearing black only until I find something darker.
> mra@pobox.com | http://www.pobox.com/~mra
> -
> 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/
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Module read a file?
  2001-10-11 21:46     ` Greg KH
@ 2001-10-12  8:12       ` Ian Stirling
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Stirling @ 2001-10-12  8:12 UTC (permalink / raw)
  To: linux-kernel

> 
> On Thu, Oct 11, 2001 at 02:25:09PM -0700, Mark Atwood wrote:
> > 
> > Because the firmware is stored in volitile memory on the card, and
> > vanishes on a card reset or removal, and I would like to have it Just
> > Work with the pcmcia-cs package with minimal changes.
> 
> Then add a script in the proper place in the linux-hotplug [1] package,
> which will run everytime your card is inserted.  This is how USB
> firmware loads will be done in 2.5.

Or, the existing PCMCIA scripts from the pcmcia-cs package in
/etc/pcmcia
Assuming the card is recognised in some way, perhaps as a memory card,
you just stick the program to load the code into memory.opts

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-10-12  8:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-11 20:48 Module read a file? Mark Atwood
2001-10-11 21:19 ` Christopher Friesen
2001-10-11 21:25   ` Mark Atwood
2001-10-11 21:39     ` Christopher Friesen
2001-10-11 21:46     ` Greg KH
2001-10-12  8:12       ` Ian Stirling
2001-10-11 21:57     ` John Adams
2001-10-11 22:18     ` Alan Cox
2001-10-11 22:29       ` Mark Atwood
2001-10-12  4:43 ` T. A.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox