LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Markku Savela <msa@moth.iki.fi>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to get /dev entry created automaticly for dynamic major number?
Date: Thu, 25 Jan 2007 00:25:44 -0800	[thread overview]
Message-ID: <20070125082544.GA16300@kroah.com> (raw)
In-Reply-To: <200701250735.l0P7Z7aN018630@moth.iki.fi>

On Thu, Jan 25, 2007 at 09:35:07AM +0200, Markku Savela wrote:
> 
> If want to write a loadable module which "implements" a char device
> ("virtual", no real device present). How do I get the correct
> "/dev/foo" to appear automaticly?  What is the current recommended
> solution (kernel 2.6.17 in Ubuntu and later).
> 
> static int major;
> 
> static int __init foo_init(void)
>     {
>     ...
>     major = register_chrdev(0, "foo", &fops);
>     ....
>     }
> 
> static void __exit foo_exit(void)
>     {
>     ...
>     if (major > 0)
>         unregister_chrdev(major, "foo");
>     ...
>     }
> 
> I thought that the above code would be enough to trigger the "udevd",
> but apparently not (if it should, what is the match rule I have to
> use? DRIVER=="foo" or KERNEL="foo[0-9]*"? None of these seem to
> work). Do I have to do some additional poking with sysfs?  I can see
> my module there, but nothing else.
> 
> The problem seems to be that most information I find from books or net
> is out of date for 2.6, or carries note "these things are currently
> been changed". A pointer to a definitive documentation would also do!

If you look in the book, Linux Device Drivers, third edition, free
online, there's a section on what is needed for udev to work properly.

The ideas are still the same, but the way to do it has changed since the
book was written.  Just use a struct device and a class, and you will be
fine.  Look at the misc device core or the mem code in
drivers/char/mem.c for examples of what you need to do.

Hope this helps,

greg k-h

  reply	other threads:[~2007-01-25  8:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-25  7:35 Markku Savela
2007-01-25  8:25 ` Greg KH [this message]
2007-01-25 13:11   ` Markku Savela
2007-01-25 13:17     ` Markku Savela
2007-01-25 13:37     ` Jiri Kosina
2007-01-25 15:51     ` Greg KH

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=20070125082544.GA16300@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msa@moth.iki.fi \
    --subject='Re: How to get /dev entry created automaticly for dynamic major number?' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).