Hi Joseph,

Since the kernel checks the module count (MOD_IN_USE) before calling
your cleanup_module, you can't place it there. I put a piece of code in
the ioctl handler - I think this is something described in the linux
device drivers book. When the ATIFT_IOC_HARDRESET command is passed to
the driver (compiled with ATIFT_DEBUG defined) it brings the count down
to 1, so when the device is closed (this code is for a readable device)
the count will be further reduced to 0.

I used a little loop to bring the count to 1 as I don't am not aware of
any official way of setting the count directly. The macros I use here
are all sanctioned kernel interfaces.

The complete source with a manual for using the driver is at:
  http://www.mech.ubc.ca/~watsma/ATI-FT_driver/
The manual shows how to open and close, and how to use the ioctl() call.

Willem
..

int atift_ioctl(struct inode *inodep, struct file *filep, unsigned int
cmd, unsigned long arg)
{
        struct ATIFT_Device *dev = (struct ATIFT_Device *) filep->private_data
;
        unsigned long flags ;
        int result ;

                /* check for correct command */
        if (_IOC_TYPE(cmd) != ATIFT_IOC_MAGIC) return -EINVAL ;
        if (_IOC_NR(cmd) > ATIFT_IOC_MAXNR) return -EINVAL ;

        switch (cmd) {

#ifdef ATIFT_DEBUG
                case ATIFT_IOC_HARDRESET:
                        {
                                /* set module use count to 1 and close the device */
                                int i = MOD_IN_USE ;
                                for(;i>1;i--) MOD_DEC_USE_COUNT ;
                                atift_release(inodep, filep);
                        }
                        break ;
#endif




joseph canou wrote:
> 
> hello
> can you tell me how to set the module use count to zero
> thank you for your help
> > -------Message d'origine-------
> > De : WJ Atsma <[EMAIL PROTECTED]>
> > Date : 16/08/2000 23:37:52
> >
> > Another way is to set the module use count to zero before unloading the
> > module. When you do this you can always unload the module, and lsmod
> > will still get you the correct number. Clearly you should only use this
> > for debugging.
> >
> > Willem
> > 
> >
> > Bas Kruiderink wrote:
> > >
> > > Hello,
> > >
> > > Can someone tell me how to 'force' a module to unload? When debugging my
> > > rt-application the application somtimes crashes. This leaves the
> > > rt-modules loaded and somtimes used. When (for example) the mbuff module
> > > is not removed, I have to do a complete reboot to try again.
> > > I know this may cause stability problems, but it would speed up the
> > > debugging!
> > > Anyone have an idea how to solve this, rmmod does not work (says module
> > > is in use), lsmod also shows module is used.
> > >
> > > Greetings,
> > > Bas Kruiderink.
> > >
> > > -- [rtl] ---
> > > To unsubscribe:
> > > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > > echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
> > > ---
> > > For more information on Real-Time Linux see:
> > > http://www.rtlinux.org/rtlinux/
> >
> >
> > --
> > ~~
> > Willem J. Atsma        - [EMAIL PROTECTED]
> > url: http://www.mech.ubc.ca/~watsma
> > ~~
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
> > ---
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/rtlinux/
> >
> >
> >
> ______________________________________________________
> Boîte aux lettres - Caramail - http://www.caramail.com

-- 
    ~~
Willem J. Atsma   -    [EMAIL PROTECTED]
url: http://www.mech.ubc.ca/~watsma
  ~~
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to