devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Thomas De Schampheleire
	<patrickdepinguin+devicetree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: Ronny Meeus <Ronny.Meeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: Device naming based on device tree
Date: Sat, 13 Apr 2013 13:48:38 +0100	[thread overview]
Message-ID: <20130413124838.EADC63E2249@localhost> (raw)
In-Reply-To: <CAAXf6LVDGC_VszCqz992SmMhM6r2w3_4zLL=NkCuzJ8ep7kiMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, 21 Jan 2013 11:25:26 +0100, Thomas De Schampheleire <patrickdepinguin+devicetree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi,
> 
> I'm trying to find a proper way for userspace to determine which
> devices to talk to. Say you have 4 SPI devices that are registered
> against spidev (the userspace SPI handling driver). The device tree
> obviously knows which device is which (e.g. a temperature sensor, a
> memory device, an actuator, ...) but userspace does not. In the case
> of SPI, it sees things like:
>     /sys/class/spidev/spidev32766.1/
> or worse
>     /sys/devices/ffe000000.soc/ffe110000.spi/spi32766.1
> but these are too specific.
> 
> The same problem occurs for devices using i2c-dev, uio, mtd, ...
> 
> For uio, it's possible to determine which device i (i.e. the userspace
> program needs to know that a) the device is an SPI devices which by
> checking the /sys/class/uio/uioX/name files.
> For mtd it is possible to do something similar by strategically
> choosing the mtd partition descriptions and creating device nodes or
> links based on that information.
> 
> Basically, I'm looking for a way to give device tree nodes a name, so
> that I can easily access or create devices like /dev/tempsensor0,
> /dev/actuator, /dev/serialnum_memory, etc. Ideally such a mechanism is
> bus-agnostic: on one board the temperature sensor may be using SPI, on
> another I2C.
> 
> I assume this is what udev is for, but I'm not sure if it fixes my
> problem. In order to name/rename devices with udev, there need to be
> rules, and these rules are part of userspace, I cannot dictate them
> from the device tree. In an embedded world, you may have three boards
> with the same userspace but with different hardware configurations and
> thus different device trees.

Yes, every time a new device is added to /sys/devices, a uevent will be
issued that lets udev know that a new device is ready to be handled. The
data associated with the uevent is exported via the 'uevent' attribute
in the new device.

The uevent attribute should have enough information to identify which
dt node is associated with the device. Check the OF_FULLNAME value in
uevent, and also the OF_ALIAS_* values.

g.

      parent reply	other threads:[~2013-04-13 12:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21 10:25 Device naming based on device tree Thomas De Schampheleire
     [not found] ` <CAAXf6LVDGC_VszCqz992SmMhM6r2w3_4zLL=NkCuzJ8ep7kiMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-04-13 12:48   ` Grant Likely [this message]

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=20130413124838.EADC63E2249@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=Ronny.Meeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=patrickdepinguin+devicetree-Re5JQEeQqe8AvxtiuMwx3w@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).