public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Kumba <kumba@gentoo.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Can I nest kobjects to create directories under parent directories for my driver?
Date: Wed, 2 Mar 2011 15:38:23 -0500	[thread overview]
Message-ID: <20110302203823.GA18879@kroah.com> (raw)
In-Reply-To: <4D6C68A4.3020306@gentoo.org>

On Mon, Feb 28, 2011 at 10:31:48PM -0500, Kumba wrote:
> So I'm attempting to write my first kernel driver for an RTC chip
> (Dallas/Maxim DS1685/DS1687), and running into a problem with using
> sysfs properly.  First off, a patch for this specific RTC was sent
> int to rtc-linux about two years ago, but never made it anywhere.  I
> based off of that and have pretty much re-written the thing since
> then.  It's undergoing a second re-write after some initial feedback
> from the rtc-linux folks.
> 
> What I'm trying to do, is, in sysfs, create individual attributes
> for the bits in each control register.  DS1685 defines 6 control
> registers (4 are the standard DS1286-style, and 2 are "extended" in
> another address bank).
> 
> I want to organize it such that:
> 
> # ls /sys/devices/platform/rtc-ds1685/
> driver@  misc/  modalias  nvram  regs/  rtc/  subsystem@  uevent
> 
> And in regs/:
> ctrla/  ctrlb/  ctrlc/  ctrld/  ctrl4a/  ctrl4b/

That's nice, but it really isn't a good idea to do things this deep.
Userspace tools will not be able to find things properly (like libudev)
and your kernel code will get very messy (as you have found out.)

Why not look at how the other rtc drivers work, they don't nest things
this deep and you need to sick with the standard userspace api and not
invent a new one if at all possible.

But to answer your question, you can do this, but I strongly discourage
it.

good luck,

greg k-h

  reply	other threads:[~2011-03-02 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01  3:31 Can I nest kobjects to create directories under parent directories for my driver? Kumba
2011-03-02 20:38 ` Greg KH [this message]
2011-03-02 21:49   ` Kumba
2011-03-03  6:19     ` 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=20110302203823.GA18879@kroah.com \
    --to=greg@kroah.com \
    --cc=kumba@gentoo.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