From: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
To: Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC] simple_char: New infrastructure to simplify chardev management
Date: Thu, 23 Apr 2015 10:25:43 +0200 [thread overview]
Message-ID: <20150423082543.GA10801@kroah.com> (raw)
In-Reply-To: <d3ab93173d51cebf00dd2263fd0ce9f8cd6258f7.1423609645.git.luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
On Tue, Feb 10, 2015 at 03:44:05PM -0800, Andy Lutomirski wrote:
> This isn't adequately tested, and I don't have a demonstration (yet).
> It's here for review for whether it's a good idea in the first place
> and for weather the fully_dynamic mechanism is a good idea.
Sorry for the long delay.
I looked at this, and at a first glance, this looks good. The existing
char interface is a mess, and needs to really be simplified. I think
this code can go a long way toward making that happen.
But I'm a bit confused as to how to use this. Can you pick some
in-kernel driver and convert it to this interface to see how it would
"work"?
Ideally, between an interface like this, and the miscdevice interface,
that should be the main way to create character devices, simplifying a
lot of "boilerplate" code we have in drivers today.
Some minor comments on the code:
> + ret = -ENOMEM;
> + major = kmalloc(sizeof(struct simple_char_major), GFP_KERNEL);
> + if (!major)
> + goto out_unregister;
> + cdev_init(&major->cdev, &simple_char_fops);
> + kobject_set_name(&major->cdev.kobj, "%s", name);
The kobject in a cdev isn't a "real" kobject in that the name doesn't
matter, and it's never "registered" with sysfs. It's only use for the
kobject map code, for looking up the cdev very quickly. I really would
like to just split the kmap code out from being related to a kobject as
it's something that confuses a lot of people, but never spent the time
to do the work.
So a line like this shouldn't do anything, you don't have to set the
name here.
> +void simple_char_major_free(struct simple_char_major *major)
> +{
> + BUG_ON(!idr_is_empty(&major->idr));
WARN_ON is best, we never want to add new BUG calls to the kernel. Or,
if this really can never happen, we don't need to test for it.
thanks,
greg k-h
next prev parent reply other threads:[~2015-04-23 8:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 23:44 [RFC] simple_char: New infrastructure to simplify chardev management Andy Lutomirski
2015-03-26 0:16 ` Andy Lutomirski
[not found] ` <CALCETrUXgqAY1MzMP80W_YC-zCi3nostJE2sLA+X_U0Xu6hoFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-26 9:26 ` Greg Kroah-Hartman
2015-10-11 7:26 ` Christoph Hellwig
[not found] ` <20151011072605.GA28986-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-10-12 20:02 ` Andy Lutomirski
[not found] ` <d3ab93173d51cebf00dd2263fd0ce9f8cd6258f7.1423609645.git.luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
2015-02-11 0:44 ` Greg Kroah-Hartman
[not found] ` <20150211004459.GA30746-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-02-11 20:04 ` Andy Lutomirski
2015-02-11 10:10 ` Jiri Kosina
2015-03-27 8:45 ` Christoph Hellwig
2015-04-23 8:25 ` Greg Kroah-Hartman [this message]
2015-04-23 9:34 ` David Herrmann
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=20150423082543.GA10801@kroah.com \
--to=gregkh-hqyy1w1ycw8ekmwlsbkhg0b+6bgklq7r@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).