public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: Timur Tabi <timur@freescale.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Scott Wood <scottwood@freescale.com>,
	Stuart Yoder <stuart.yoder@freescale.com>
Subject: Re: How do I choose an arbitrary minor number for my tty device?
Date: Wed, 17 Nov 2010 14:19:03 -0800	[thread overview]
Message-ID: <20101117221903.GA4066@suse.de> (raw)
In-Reply-To: <4CE452CD.3050001@freescale.com>

On Wed, Nov 17, 2010 at 04:10:21PM -0600, Timur Tabi wrote:
> Greg KH wrote:
> 
> > What is ePAPR?
> 
> It's a specification for an interface between the boot loader and the operating
> system.  It's based on the device tree model that exists on PowerPC today.
> ePAPR defines a bunch of extensions, including one for hypervisors.  The byte
> channel concept is an example of that.
> 
> > Why would you need this mapping?  Just do a first-come-first serve
> > assignment of tty minor devices like all other subsystems do (usb,
> > serial, acm, etc.)
> 
> Without some kind of mapping, there's no way for an application to know which
> /dev entry to open.  Each byte channel goes to a different
> 
> > 
> > sysfs will show the representation between your ePAPR device "handle"
> > and the tty device minor just fine, as it does today for those other
> > types of devices.
> 
> I don't see how.  A byte channel node defines several properties, one of which
> could be a text string that acts as a label.  So if an application is looking
> for the "channel-to-partition-two" byte channel, it can search for that string
> in the device tree.  Once it finds the matching node, it can extract the byte
> channel handle.
> 
> At this point, the application will want to open a /dev entry that corresponds
> to that byte channel handle.  This is the piece I'm missing with the tty layer.
> 
> If I want to create a regular character device, I can do this:
> 
> bc->dev_id = MKDEV(MAJOR(dev_id), MINOR(dev_id) + i);
> device_create(ehv_bc_class, NULL, bc->dev_id, bc, "bc%u", bc->handle);
> 
> Here, I control the name of the /dev entry via "bc%u".  I want something similar
> for tty devices.

No, you want to have a tty device attached to your "byte channel
device".  That will give you the correct mapping here.  Your tty device
number is sequencial and has nothing in its name to do with your "byte
channel device number" just like ttyS1 has nothing in its pci device id
that it lives on with my multi-port serial card.

> > Bonus being that udev will create a persistant device id for your tty
> > device based on that handle so you can just open that if you want to, no
> > need to get the kernel involved in sparse minor mappings at all.
> 
> I'm not sure I understand that.  In order for udev to do this, I need to tell it
> what the byte channel handle actually is.  How do I do that using the tty layer?

You just create your tty device and assign the parent of it to be your
"byte channel device".  Just like we do for PCI, USB, and all other bus
device types.

I think you are forgetting that your byte channel devices must be
"devices" in the system here, right?  There is a 'struct bus_id" for
your bus that these devices live on.  Then you create a tty device in
your tty driver that attaches to the byte channel that shows up as a tty
device on your bus.

Does that help explain things a bit better?

thanks,

greg k-h

  reply	other threads:[~2010-11-17 22:19 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-17 21:37 How do I choose an arbitrary minor number for my tty device? Timur Tabi
2010-11-17 21:51 ` Greg KH
2010-11-17 22:10   ` Timur Tabi
2010-11-17 22:19     ` Greg KH [this message]
2010-11-17 22:42       ` Timur Tabi
2010-11-18  2:24         ` Greg KH
2010-11-18 15:31           ` Timur Tabi
2010-11-18 15:39             ` Greg KH
2010-11-18 16:03               ` Timur Tabi
2010-11-18 16:33                 ` Greg KH
2010-11-18 16:36                   ` Timur Tabi
2010-11-18 16:51                     ` Greg KH
2010-11-18 16:56                       ` Timur Tabi
2010-11-18 17:18                         ` Greg KH
2010-11-18 17:38                           ` Timur Tabi
2010-11-18 17:58                             ` Greg KH
2010-11-18 19:35                               ` Timur Tabi
2010-11-18 20:02                                 ` Greg KH
2010-11-18 20:06                                   ` Timur Tabi
2010-11-18 20:10                                     ` Greg KH
2010-11-18 20:43                                       ` Timur Tabi
2010-11-18 20:56                                         ` Alan Cox
2010-11-22 16:32                                           ` Timur Tabi
2010-11-22 20:12                                             ` Timur Tabi
2010-11-23 13:56                                             ` Alan Cox
2010-11-23 17:14                                               ` Timur Tabi
2010-11-23 23:03                                                 ` Alan Cox
2010-11-18 20:58                                 ` Alan Cox
2010-11-18 17:21                 ` Scott Wood
2010-11-18 17:42                   ` Timur Tabi
2010-11-18 17:58                     ` Greg KH
2010-11-18 18:13                     ` Scott Wood
2010-11-24 10:23                       ` Michael Ellerman
2010-11-24 18:08                         ` Scott Wood
2010-11-24 18:23                           ` Greg KH
2010-11-24 22:44                             ` Michael Ellerman
2010-11-29 21:44                               ` Greg KH
2010-11-29 21:51                                 ` Timur Tabi
2010-11-29 22:30                                   ` Greg KH
2010-11-29 22:36                                     ` Timur Tabi
2010-11-30  3:29                                       ` Greg KH
2010-11-30  4:15                                         ` Tabi Timur-B04825
2010-11-30 19:33                                         ` Timur Tabi
2010-12-01  1:00                                           ` Greg KH
2010-12-01  9:54                                             ` Kay Sievers
2010-12-02 16:12                                               ` Timur Tabi
2010-11-24 22:46                           ` Michael Ellerman
2010-11-25  4:10                             ` Grant Likely
2010-11-24 18:13                         ` Scott Wood

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=20101117221903.GA4066@suse.de \
    --to=gregkh@suse.de \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.com \
    --cc=timur@freescale.com \
    /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