linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Aniroop Mathur <aniroop.mathur@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-hotplug@vger.kernel.org
Subject: Re: [Question: Drivers/base/core.c] Why dev->init_name = NULL in device_add function ?
Date: Mon, 04 Aug 2014 04:35:41 +0000	[thread overview]
Message-ID: <20140804043541.GA4665@kroah.com> (raw)
In-Reply-To: <CADYu30_EN78+1CdD=VF8gi-5H2Ot7ArKWq5DQ5HaptwTuL3C6A@mail.gmail.com>

On Mon, Aug 04, 2014 at 12:24:06AM +0530, Aniroop Mathur wrote:
> On Sat, Aug 2, 2014 at 8:09 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Sat, Aug 02, 2014 at 05:14:44AM +0530, Aniroop Mathur wrote:
> >> >> So, overall output will be
> >> >> /dev/input/event<x> --> /dev/input/event_accelerometer
> >> >> sys/class/input/input<x> --> sys/class/input/accelerometer
> >> >>
> >> >> In short, input and event node names are set just by
> >> >> adding one line, which i found quite efficient.
> >> >> There is other way also to set name of event node but
> >> >> it involves using extra variable and little more code,
> >> >> So I am looking for best solution possible. :)
> >> >
> >> > Only use init_name for static struct devices, for a dynamic one, jsut
> >> > set the name like everyone else does, how is that "more" code than
> >> > anything else?
> >> >
> >>
> >> Can you please elaborate what do you mean by static struct devices ?
> >
> > Exactly what you wrote there, 'static' is a C thing, right?
> >
> >> Can I consider embedded accelerometer, proximity, gyro sensor,
> >> touch panel in android mobile devices as static devices ?
> >
> > Nope, because in my Android phone, I can yank out those and add new ones
> > on the fly while the phone is running.  The kernel is fully dynamic that
> > way.
> >
> >> Input subsystem is setting default name of input and event node.
> >
> > As it should.
> >
> >> This is the normal method everyone uses.
> >
> > And so should you :)
> >
> >> I do not want to use default name like event0, event4, input2, etc
> >
> > Yes, you really do.
> >
> >> My aim is to set name of input and event node through driver as desired.
> >
> > Nope, that's userspace's job, just use udev to rename the device node,
> > or even better yet, create a symlink like /dev/input/by-id/ has if you
> > really need more than that.
> >
> > Don't mess with kernel device names, we can't do that without breaking
> > tons of things, there's a reason that we standardized on something,
> > please use it.
> >
> 
> Okay, will follow the same. :)
> 
> One last thing,
> Why init_name will go away some day ?

Because you should never have a static struct device in the kernel.
It's a reference counted object that needs to always be dynamically
allocated in order to properly work.  Unfortunatly, there are some users
who have it allocated statically (on the stack) instead of dynamically
(on the heap).  I'll get rid of them someday, it's _way_ down my list of
things to do...

thanks,

greg k-h

  reply	other threads:[~2014-08-04  4:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 17:25 [Question: Drivers/base/core.c] Why dev->init_name = NULL in device_add function ? Aniroop Mathur
2014-08-01 19:23 ` Greg KH
2014-08-01 22:36   ` Aniroop Mathur
2014-08-01 22:41     ` Greg KH
2014-08-01 23:56       ` Aniroop Mathur
2014-08-02  2:39         ` Greg KH
2014-08-03 18:54           ` Aniroop Mathur
2014-08-04  4:35             ` Greg KH [this message]
2014-08-04 17:11               ` Aniroop Mathur
2014-08-03 16:25         ` Aniroop Mathur

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=20140804043541.GA4665@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=aniroop.mathur@gmail.com \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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).