Porting Device Driver to 2.6
Dominik Brodowski
linux at dominikbrodowski.net
Wed Apr 20 08:51:52 EDT 2005
On Wed, Apr 20, 2005 at 08:41:53AM -0400, Alex Holeczy wrote:
> On Wed, 20 Apr 2005, Dominik Brodowski wrote:
>
> >On Mon, Apr 18, 2005 at 11:59:00AM -0400, Alex Holeczy wrote:
> >>
> >>How do you register the device release function for a generic device under
> >>kernel 2.6? It appears that sound cards have a method for registering a
> >>free function.
> >>
> >>Using the kernel 2.4 there was a 'release' element in the dev_link_t
> >>structure used to register the device release function. The 'release'
> >>element does not exists in the dev_link_t structure for the 2.6 kernel.
> >
> >Yes, there was, but it was using a timer which is not the preferred way of
> >doing things. For what purposes do you need it exactly?
>
>
> In the 2.4 kernel environment, the release() function was used to free any
> resources allocated by a call to the config() function. The release()
> function would only free resources if the device was not currently opened.
>
> The release() would also call the detach(), if the detach() function was
> called prior to the resource being closed.
>
> I thought that in the 2.6 kernel, the release() function would be required
> to perform the same function.
OK, I now understand what you mean. Thanks. 2.6. now serializes this
behaviour - release() should be called within detach(); however, the
allocation and freeing of memory (kfree) should be done outside of this. As
you're writing a sound device driver, I'd suggest that you keep close to
what the other two PCMCIA sound drivers already do.
> Currently my 2.6 driver, calls the release() function in the detach()
> function. But if the device is still open when the detach() function is
> called, it does not make sense to free the system resources because the
> user application may try to access the device.
>
> Maybe if the detach() function is called when the device is still opened,
> the close() function should be responsible for calling the release()
> function.
>
> What do you think?
The device should be "closed" when it is detached==released.
Dominik
More information about the linux-pcmcia
mailing list