From: Ralf Baechle <ralf@linux-mips.org>
To: Tony <tony.uestc@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: MOD_INC_USE_COUNT
Date: Wed, 16 Nov 2005 13:24:21 +0000 [thread overview]
Message-ID: <20051116132421.GC3229@linux-mips.org> (raw)
In-Reply-To: <437AE21D.9040501@gmail.com>
On Wed, Nov 16, 2005 at 03:39:09PM +0800, Tony wrote:
> >>>Not strange at all. The typical network driver is implemented using
> >>>pci_register_driver which will set the owner filed of the driver's struct
> >>>driver which then is being used for internal reference counting. Other
> >>>busses or line disciplines (SLIP, PPP, AX.25 ...) need to do the
> >>>equivalent
> >>>or the kernel will believe reference counting isn't necessary and it's
> >>>ok to unload the module at any time.
> >>>
> >>>In which driver did you hit this problem?
> >>>
> >>>Ralf
> >>>
> >>
> >>I have a radio connected to host using ethernet. I'm writing a radio
> >>driver that masquerade radio as a NIC. when the module is loaded, I just
> >>register_netdev a net_device struct, while unregister_netdev at module
> >>cleanup.
> >
> >
> >register_netdev / unregister_netdev don't deal with the .owner stuff, so
> >your bug isn't there. If your NIC is a PCI card, it should register it's
> >driver through pci_register_driver which would deal with the necessary
> >reference counting. If it's implemented as a platform device you're
> >presumably calling driver_register() before platform_device_register() and
> >driver_register() would do the necessary magic for you. If you're using a
> >different bus it may have it's own variant of driver_register which you
> >should call. If you don't, you have a problem :-)
> >
> > Ralf
> >
> That is indeed my problem. My driver is none of types of drivers, it's
> just a software virtual one. I think I should mimic the way SLIP handle
> it. thank a loooooooot!!!
SLIP is a line discipline; it's reference counting happens through
tty_register_ldisc() but probably your code isn't a line discipline ...
You however might use the platform device code - see
include/linux/platform_device.h and the many users throughout the kernel.
The platform device concept was really meant to support physical hardware
but it should work just fine in your case. Maybe
drivers/net/mipsnet.c can serve as an example - it's a driver for virtual
NIC on a software emulator.
Ralf
next prev parent reply other threads:[~2005-11-16 13:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-10 13:14 MOD_INC_USE_COUNT Tony
2005-11-10 14:03 ` MOD_INC_USE_COUNT linux-os (Dick Johnson)
2005-11-10 14:21 ` MOD_INC_USE_COUNT Tony
2005-11-10 15:28 ` MOD_INC_USE_COUNT linux-os (Dick Johnson)
2005-11-13 10:29 ` MOD_INC_USE_COUNT Ralf Baechle
2005-11-15 3:56 ` MOD_INC_USE_COUNT Tony
2005-11-15 15:34 ` MOD_INC_USE_COUNT Ralf Baechle
2005-11-16 7:39 ` MOD_INC_USE_COUNT Tony
2005-11-16 13:24 ` Ralf Baechle [this message]
2005-11-15 18:52 ` MOD_INC_USE_COUNT Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051116132421.GC3229@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.uestc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox