From: Grant Likely <grant.likely@secretlab.ca>
To: Simon Glass <sjg@chromium.org>
Cc: lk <linux-kernel@vger.kernel.org>,
Devicetree Discuss <devicetree-discuss@lists.ozlabs.org>,
Che-liang Chiou <clchiou@chromium.org>
Subject: Re: Device tree node to major/minor?
Date: Wed, 21 Nov 2012 15:47:58 +0000 [thread overview]
Message-ID: <20121121154758.93CE43E0AE2@localhost> (raw)
In-Reply-To: <CAPnjgZ3jF7bdwqDCNzJXvSrwoP0PZVjcFO+nGOiLACLDX07Z7A@mail.gmail.com>
On Tue, 20 Nov 2012 15:48:24 -0800, Simon Glass <sjg@chromium.org> wrote:
> Hi Grant,
>
> On Tue, Nov 20, 2012 at 2:32 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
> > On Tue, Nov 20, 2012 at 10:23 PM, Simon Glass <sjg@chromium.org> wrote:
> >> Hi,
> >>
> >> I hope this is a stupid question with an easy answer, but I cannot find it.
> >>
> >> I have a device tree node for an mmc block device and I want to use
> >> that block device from another driver. I have a phandle which lets me
> >> get the node of the mmc device, but I am not sure how to convert that
> >> into a block_device. In order to do so, I think I need a major/minor
> >> number. Of course the phandle might in fact point to a SCSI driver and
> >> I want that to work correctly also.
> >>
> >> I imagine I might be able to search through the wonders of sysfs in
> >> user space, but is there a better way?
> >
> > Do you /want/ to do it from userspace? What is your use case? Mounting
> > the rootfs?
>
> The use case is storing some raw data on a block device from within a
> driver in the kernel. It is used to keep track of the verified boot
> state.
>
> >
> > Regardless, userspace can monitor the uevents when devices are added
> > (that's what udev does) and watch for the full path of the node you
> > want in the uevent attribute. Then you can look for the child device
> > with the block major/minor numbers in it.
>
> So is there a way to do this entirely in the kernel ex post? It might
> need to happen during kernel boot, before user space.
Yes, it is certainly doable within the kernel. First, you'll need to use
a notifier to get called back whenever a new device is created. Then
you'll need to look at the dev->of_node(->full_name) to see if it is the
node you actually want. You might need/want to resolve it from an alias
or something, but I presume you already have a way to find the
device_node before seaching for a struct device.
g.
next prev parent reply other threads:[~2012-11-21 15:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-20 22:23 Device tree node to major/minor? Simon Glass
2012-11-20 22:32 ` Grant Likely
2012-11-20 23:48 ` Simon Glass
2012-11-21 15:47 ` Grant Likely [this message]
2012-11-21 20:48 ` Simon Glass
[not found] ` <CAPnjgZ3W3YfJLwfmg41oM4HvM+JnH2qiwmDN6Yhf3G8KnBFRhw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-21 23:07 ` Grant Likely
2012-11-21 23:07 ` Grant Likely
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=20121121154758.93CE43E0AE2@localhost \
--to=grant.likely@secretlab.ca \
--cc=clchiou@chromium.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sjg@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.